@monetize.software/sdk-extension 3.0.0-alpha.20 → 3.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content.cjs +2 -2
- package/dist/content.cjs.map +1 -1
- package/dist/content.js +362 -315
- package/dist/content.js.map +1 -1
- package/package.json +3 -3
package/dist/content.cjs
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
cursor: auto !important;
|
|
17
17
|
visibility: visible !important;
|
|
18
18
|
}
|
|
19
|
-
`,a=document.createElement("style");a.textContent=o+me+(t.injectCss??""),i.appendChild(a);const
|
|
19
|
+
`,a=document.createElement("style");a.textContent=o+me+(t.injectCss??""),i.appendChild(a);const l=document.createElement("div");l.style.pointerEvents="auto",i.appendChild(l);let c=e;return U.render(U.h(r,c),l),{shadowRoot:i,update(h){c={...c,...h},U.render(U.h(r,c),l)},unmount(){U.render(null,l),s.remove()}}}const Ve=(r,e,t)=>{const s=r[e];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((i,o)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(o.bind(null,new Error("Unknown variable dynamic import: "+e+(e.split("/").length!==t?". Note that variables only represent file names one level deep.":""))))})},$e=["ru","uk","de","es","fr","it","pt","pl","cs","hu","ro","nl","sv","da","no","fi","el","tr","id","ar","ja","ko","zh","hi","th","vi","he"],ye=(r,e,t)=>we(e,t),be=U.createContext({t:ye,locale:"en"});function we(r,e){if(!e)return r;let t=r;for(const[s,i]of Object.entries(e))t=t.split(`{${s}}`).join(String(i));return t}const K=new Map,X=new Map;function ke(r){return $e.includes(r)}function He(r){const e=[];if(typeof navigator<"u"&&navigator.language){e.push(navigator.language);const s=navigator.language.split("-")[0];s&&s!==navigator.language&&e.push(s)}const t=r.settings.locale_default;if(t){e.push(t);const s=t.split("-")[0];s&&s!==t&&e.push(s)}for(const s of e)if(ke(s))return s;return null}function Ge(r,e){return!!r.locales&&r.locales[e]!==void 0}async function We(r){const e=K.get(r);if(e)return e;const t=X.get(r);if(t)return t;const s=Ve(Object.assign({"./locales/ar.ts":()=>Promise.resolve().then(()=>require("./chunks/ar-7cgIM-Vl.js")),"./locales/cs.ts":()=>Promise.resolve().then(()=>require("./chunks/cs-S05PC5AC.js")),"./locales/da.ts":()=>Promise.resolve().then(()=>require("./chunks/da-Bi4zBG14.js")),"./locales/de.ts":()=>Promise.resolve().then(()=>require("./chunks/de-nCDB6D2W.js")),"./locales/el.ts":()=>Promise.resolve().then(()=>require("./chunks/el-BrKaa978.js")),"./locales/es.ts":()=>Promise.resolve().then(()=>require("./chunks/es-B-Wtyzrl.js")),"./locales/fi.ts":()=>Promise.resolve().then(()=>require("./chunks/fi-D1SGXjnO.js")),"./locales/fr.ts":()=>Promise.resolve().then(()=>require("./chunks/fr-BhYf-iKk.js")),"./locales/he.ts":()=>Promise.resolve().then(()=>require("./chunks/he-BXAaFv6Y.js")),"./locales/hi.ts":()=>Promise.resolve().then(()=>require("./chunks/hi-xblDO0O7.js")),"./locales/hu.ts":()=>Promise.resolve().then(()=>require("./chunks/hu-Wa46p0y4.js")),"./locales/id.ts":()=>Promise.resolve().then(()=>require("./chunks/id-CQEo5X94.js")),"./locales/it.ts":()=>Promise.resolve().then(()=>require("./chunks/it-8AYCm0xz.js")),"./locales/ja.ts":()=>Promise.resolve().then(()=>require("./chunks/ja-q-COVayn.js")),"./locales/ko.ts":()=>Promise.resolve().then(()=>require("./chunks/ko-B6HRCscZ.js")),"./locales/nl.ts":()=>Promise.resolve().then(()=>require("./chunks/nl-CAd6_xlm.js")),"./locales/no.ts":()=>Promise.resolve().then(()=>require("./chunks/no-CAmz6bz6.js")),"./locales/pl.ts":()=>Promise.resolve().then(()=>require("./chunks/pl-DqUSTCaF.js")),"./locales/pt.ts":()=>Promise.resolve().then(()=>require("./chunks/pt-8ARZnH0_.js")),"./locales/ro.ts":()=>Promise.resolve().then(()=>require("./chunks/ro-D-NMbp2F.js")),"./locales/ru.ts":()=>Promise.resolve().then(()=>require("./chunks/ru-8gbHPh0g.js")),"./locales/sv.ts":()=>Promise.resolve().then(()=>require("./chunks/sv-D8a8hmx9.js")),"./locales/th.ts":()=>Promise.resolve().then(()=>require("./chunks/th-DfjUK0Y7.js")),"./locales/tr.ts":()=>Promise.resolve().then(()=>require("./chunks/tr-BdBpz4tL.js")),"./locales/uk.ts":()=>Promise.resolve().then(()=>require("./chunks/uk-Cx1zv1ao.js")),"./locales/vi.ts":()=>Promise.resolve().then(()=>require("./chunks/vi-oe2dW21I.js")),"./locales/zh.ts":()=>Promise.resolve().then(()=>require("./chunks/zh-CwczPMPp.js"))}),`./locales/${r}.ts`,3).then(i=>{const o=i.default??{};return K.set(r,o),o}).catch(i=>{console.warn(`[paywall] failed to load locale chunk "${r}"`,i);const o={};return K.set(r,o),o}).finally(()=>{X.delete(r)});return X.set(r,s),s}function Ze({bootstrap:r,forceLocale:e,children:t}){const[s,i]=d.useState("en"),[o,a]=d.useState(null);d.useEffect(()=>{const h=(e&&ke(e)?e:null)??(()=>{if(!r)return null;const g=He(r);return!g||!Ge(r,g)?null:g})();if(!h){(o!==null||s!=="en")&&(i("en"),a(null));return}if(h===s&&o)return;let u=!1;return We(h).then(g=>{u||(i(h),a(g))}),()=>{u=!0}},[r,e]);const l={locale:s,t:o?(c,h,u)=>we(o[c]??h,u):ye};return n.jsx(be.Provider,{value:l,children:t})}function j(){return d.useContext(be)}const oe='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ye({open:r,onClose:e,labelledBy:t,brandColor:s,topBanner:i,allowClose:o=!0,hideCloseButton:a=!1,inline:l=!1,children:c}){const{t:h}=j(),u=d.useRef(null),g=d.useRef(null);if(d.useEffect(()=>{if(!r)return;g.current=document.activeElement??null;const x=u.current;x&&(x.querySelector(oe)??x).focus({preventScroll:!0});const I=m=>{if(m.key==="Escape"){if(!o)return;m.stopPropagation(),e();return}if(m.key!=="Tab"||!u.current)return;const S=Array.from(u.current.querySelectorAll(oe)).filter(B=>!B.hasAttribute("disabled")&&B.tabIndex!==-1);if(S.length===0){m.preventDefault();return}const C=S[0],T=S[S.length-1],P=document.activeElement;m.shiftKey&&P===C?(m.preventDefault(),T.focus()):!m.shiftKey&&P===T&&(m.preventDefault(),C.focus())};document.addEventListener("keydown",I,!0);const y=document.body.style.overflow;return l||(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",I,!0),l||(document.body.style.overflow=y),g.current?.focus?.({preventScroll:!0})}},[r,e,o,l]),!r)return null;const _=x=>{o&&x.target===x.currentTarget&&e()},p=s??"#3b82f6",k=`${l?"absolute z-[1]":"fixed z-[2147483647]"} inset-0 flex items-center justify-center bg-slate-950/50 p-2 sm:p-4 backdrop-blur-md animate-[pw-fade-in_180ms_ease-out]`;return n.jsxs("div",{class:k,onClick:_,"data-pw-root":!0,children:[n.jsxs("div",{class:"relative flex w-full max-w-[400px] flex-col animate-[pw-scale-in_220ms_cubic-bezier(0.16,1,0.3,1)]",style:{"--pw-accent":p},children:[i,n.jsxs("div",{ref:u,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,class:"relative flex max-h-[calc(100dvh-1rem)] sm:max-h-[calc(100dvh-2rem)] w-full flex-col overflow-hidden rounded-xl bg-white outline-none",style:{boxShadow:"0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"},children:[c,o&&!a?n.jsx("button",{type:"button",onClick:e,"aria-label":h("modal.close_aria","Close"),class:"absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-white/80 text-gray-500 backdrop-blur-sm transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:n.jsx("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round"})})}):null]})]}),n.jsx("style",{children:`
|
|
20
20
|
@keyframes pw-fade-in { from { opacity: 0 } to { opacity: 1 } }
|
|
21
21
|
@keyframes pw-scale-in {
|
|
22
22
|
from { opacity: 0; transform: translateY(12px) scale(0.96) }
|
|
23
23
|
to { opacity: 1; transform: none }
|
|
24
24
|
}
|
|
25
|
-
`})]})}function Ke(r,e){switch(r){case"google":return e("auth.continue_with_google","Continue with Google");case"apple":return e("auth.continue_with_apple","Continue with Apple");case"github":return e("auth.continue_with_github","Continue with GitHub");case"facebook":return e("auth.continue_with_facebook","Continue with Facebook")}}function ae(r,e,t){const s=e==="signup"?t("auth.signup_failed","Sign-up failed"):t("auth.signin_failed","Sign-in failed");if(!(r instanceof v.PaywallError))return s;switch(r.code){case"invalid_credentials":return t("auth.invalid_credentials","Invalid email or password");case"email_not_confirmed":return t("auth.email_not_confirmed","Please confirm your email before signing in.");case"email_exists":case"user_already_exists":return t("auth.email_exists","An account with this email already exists.");case"weak_password":return t("auth.weak_password","Password is too weak.");case"invalid_otp":case"otp_expired":case"token_expired":return t("auth.invalid_otp","The code is invalid or has expired.");case"over_email_send_rate_limit":case"over_request_rate_limit":case"rate_limited":case"http_429":return t("auth.rate_limited","Too many requests. Please try again later.");case"network_error":return t("auth.network_error","Network error. Please check your connection and try again.");case"upstream":case"upstream_error":case"http_502":case"http_503":case"http_504":return t("auth.service_unavailable","Service is temporarily unavailable. Please try again.");default:return s}}function ve({block:r,ctx:e}){const t=e.auth,s=e.authSession,i=r.allow_signup!==!1,o=r.allow_password_reset!==!1,a=r.hide_when_authenticated!==!1;if(!t)return typeof console<"u"&&console.warn("[paywall] auth_panel rendered without AuthClient — pass `auth: true` to PaywallUI"),null;const c=s&&!s.user.is_anonymous?s:null;return c&&a?null:c?n.jsx(Xe,{email:c.user.email??"",onSignOut:()=>t.signOut().catch(()=>{})}):n.jsx(Je,{block:r,allowSignup:i,allowReset:o,ctx:e})}function Xe({email:r,onSignOut:e}){const{t}=j();return n.jsxs("div",{class:"flex items-center justify-between gap-3 rounded-2xl bg-gray-100 px-4 py-3",children:[n.jsxs("div",{class:"flex flex-col",children:[n.jsx("span",{class:"text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:t("auth.signed_in","Signed in")}),n.jsx("span",{class:"text-sm font-medium text-gray-900",children:r})]}),n.jsx("button",{type:"button",onClick:e,class:"rounded-md px-1.5 py-0.5 text-xs font-medium text-gray-600 transition-colors hover:bg-white hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t("auth.sign_out","Sign out")})]})}function Je({block:r,allowSignup:e,allowReset:t,ctx:s}){const{t:i}=j(),o=s.auth,a=r.providers??[],c=s.initialAuthMode==="signup"&&e?"signup":"signin",[l,h]=d.useState(c),[u,g]=d.useState(""),[_,p]=d.useState(""),[k,x]=d.useState(""),[I,y]=d.useState(""),[m,S]=d.useState(null),C=d.useRef(!1),[M,P]=d.useState(null),[T,B]=d.useState(null),[O,A]=d.useState(!1),[E,q]=d.useState(null);d.useEffect(()=>{if(typeof o.getLastLogin!="function")return;let f=!1;return o.getLastLogin().then(w=>{f||!w||(q(w),w.email&&g(L=>L===""?w.email:L))},()=>{}),()=>{f=!0}},[o]);const R=f=>{h(f),P(null),B(null),A(!1)},W=async f=>{if(f.preventDefault(),!(C.current||m)){C.current=!0;try{if(P(null),B(null),l==="signup"&&!O){if(!u.trim())return;A(!0);return}if(l==="signup"&&_!==k){P(i("auth.passwords_mismatch","Passwords don't match"));return}S("email");try{l==="signin"?await o.signInWithEmail({email:u,password:_}):l==="signup"?(await o.signUp({email:u,password:_})).kind==="confirmation_required"&&(p(""),h("signup_verify"),B(i("auth.check_email_message","Check your email for a confirmation code."))):l==="forgot"?(await o.requestPasswordReset({email:u}),h("reset_sent"),B(i("auth.reset_sent_message","If that email exists, a reset code has been sent."))):l==="signup_verify"?await o.verifyOtp({email:u,token:I,type:"email"}):l==="reset_verify"&&(await o.verifyOtp({email:u,token:I,type:_?"recovery":"email"}),_&&await o.updatePassword({password:_}))}catch(w){P(ae(w,l==="signup"?"signup":l==="signup_verify"||l==="reset_verify"?"otp":l==="forgot"?"reset":"signin",i))}finally{S(null)}}finally{C.current=!1}}},F=async f=>{if(!(C.current||m)){C.current=!0,S(f),P(null),B(null);try{await o.signInWithOAuth({provider:f,onPopupOpened:()=>S(null)})}catch(w){if(w instanceof v.PaywallError&&(w.code==="oauth_cancelled"||w.code==="oauth_timeout"))return;P(ae(w,"signin",i))}finally{C.current=!1,S(null)}}},Z=a.length>0&&(l==="signin"||l==="signup"),Y=l==="signin"||l==="signup"||l==="forgot",b=l==="signin"||l==="signup"&&O;return n.jsxs("div",{class:"flex flex-col gap-5",children:[n.jsx(Qe,{mode:l,customHeading:r.heading,customSubheading:r.subheading}),Z?n.jsxs("div",{class:"flex flex-col gap-2.5",children:[a.map(f=>n.jsxs("div",{class:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>F(f),disabled:m!==null,class:"flex h-12 w-full items-center justify-center gap-2.5 rounded-full border-1 border-gray-200 bg-white px-5 text-base font-medium text-gray-900 transition-all hover:border-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:[m===f?n.jsx("span",{class:"inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"}):n.jsx(ct,{provider:f}),n.jsx("span",{children:Ke(f,i)})]}),E?.method===f?n.jsx(ot,{email:E.email}):null]},f)),n.jsx(lt,{})]}):null,n.jsxs("form",{onSubmit:W,class:"flex flex-col gap-3",children:[Y&&n.jsx(le,{type:"email",placeholder:i("auth.email","Email address"),value:u,onInput:g,autocomplete:"email",required:!0}),b&&n.jsx(J,{placeholder:i("auth.password","Password"),value:_,onInput:p,autocomplete:l==="signin"?"current-password":"new-password",required:!0}),l==="signup"&&O&&n.jsx(J,{placeholder:i("auth.repeat_password","Repeat password"),value:k,onInput:x,autocomplete:"new-password",required:!0}),(l==="signup_verify"||l==="reset_verify")&&n.jsx(le,{type:"text",placeholder:i("auth.confirmation_code","Confirmation code"),value:I,onInput:y,autocomplete:"one-time-code",inputMode:"numeric",required:!0}),l==="reset_verify"&&n.jsx(J,{placeholder:i("auth.new_password_optional","New password (optional — only for password reset)"),value:_,onInput:p,autocomplete:"new-password"}),l==="reset_sent"&&T&&n.jsx("p",{class:"rounded-2xl bg-gray-100 px-4 py-3 text-sm text-gray-600",children:T}),l==="signin"&&t&&n.jsx("div",{class:"flex justify-end text-sm",children:n.jsx(G,{onClick:()=>R("forgot"),children:i("auth.forgot_password","Forgot password?")})}),M&&n.jsx("p",{class:"text-sm text-red-600",children:M}),T&&l!=="reset_sent"&&n.jsx("p",{class:"text-sm text-gray-500",children:T}),l!=="reset_sent"&&n.jsx(nt,{busy:m==="email",label:tt(l,O,r.submit_label??r.heading,i)})]}),n.jsx(rt,{mode:l,allowSignup:e,onSwitch:R})]})}function Qe({mode:r,customHeading:e,customSubheading:t}){const{t:s}=j(),i=et(r,s),o=r==="signin"||r==="signup",a=o&&e?e:i.title,c=o&&t!==void 0?t||null:i.subtitle;return n.jsxs("div",{class:"flex flex-col gap-2",children:[n.jsx("h2",{class:"text-3xl font-bold tracking-tight text-gray-900",children:a}),c?n.jsx("p",{class:"text-base leading-relaxed text-gray-600",children:c}):null]})}function et(r,e){switch(r){case"signin":return{title:e("auth.welcome","Welcome back!"),subtitle:e("auth.default_subtitle","Sign in to access all features and sync your data.")};case"signup":return{title:e("auth.welcome_signup","Welcome!"),subtitle:e("auth.default_subtitle","Sign in to access all features and sync your data.")};case"forgot":return{title:e("auth.forgot_password_title","Forgot password?"),subtitle:e("auth.forgot_subtitle","Enter your email and we'll send you a password reset link.")};case"reset_sent":return{title:e("auth.check_email_title","Check your email"),subtitle:null};case"reset_verify":return{title:e("auth.reset_password_title","Reset password"),subtitle:e("auth.reset_password_subtitle","Enter the code from your email and a new password.")};case"signup_verify":return{title:e("auth.confirm_email_title","Confirm your email"),subtitle:e("auth.confirm_email_subtitle","Enter the code we sent to your email to finish creating your account.")}}}function tt(r,e,t,s){if(r==="signin"&&t)return t;switch(r){case"signin":return s("auth.log_in","Sign In");case"signup":return e?s("auth.create_account","Create Account"):s("auth.sign_up","Sign Up");case"forgot":return s("auth.send_reset","Send Reset Email");case"signup_verify":case"reset_verify":return s("auth.verify","Verify");default:return s("cta.continue","Continue")}}function rt({mode:r,allowSignup:e,onSwitch:t}){const{t:s}=j();return r==="signin"&&e?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.no_account","Don't have an account?")," ",n.jsx(G,{onClick:()=>t("signup"),children:s("auth.sign_up_link","Sign Up")})]}):r==="signup"||r==="signup_verify"?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.have_account","Already have an account?")," ",n.jsx(G,{onClick:()=>t("signin"),children:s("auth.log_in_link","Log In")})]}):r==="forgot"||r==="reset_sent"||r==="reset_verify"?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.no_account","Don't have an account?")," ",n.jsx(G,{onClick:()=>t("signup"),children:s("auth.sign_up_link","Sign Up")})]}):null}function G({onClick:r,children:e}){return n.jsx("button",{type:"button",onClick:r,class:"font-semibold transition-opacity hover:opacity-80 focus:outline-none focus-visible:opacity-80",style:{color:"var(--pw-accent)"},children:e})}function nt({busy:r,label:e}){return n.jsx("button",{type:"submit",disabled:r,class:"pw-cta-shimmer relative mt-1 flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:r?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:e})})}function le({type:r,placeholder:e,value:t,onInput:s,autocomplete:i,inputMode:o,required:a}){return n.jsx("input",{type:r,value:t,placeholder:e,onInput:c=>s(c.target.value),autocomplete:i,inputMode:o,required:a,class:"h-14 w-full rounded-2xl bg-gray-100 px-5 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"})}function J({placeholder:r,value:e,onInput:t,autocomplete:s,required:i}){const{t:o}=j(),[a,c]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{const g=l.current;g&&g.value!==e&&(g.value=e)},[a,e]);const h=o("auth.show_password","Show password"),u=o("auth.hide_password","Hide password");return n.jsxs("div",{class:"relative",children:[n.jsx("input",{ref:l,type:a?"text":"password",value:e,placeholder:r,onInput:g=>t(g.target.value),autocomplete:s,required:i,class:"h-14 w-full rounded-2xl bg-gray-100 pl-5 pr-12 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}),n.jsx("button",{type:"button",onClick:()=>c(g=>!g),"aria-label":a?u:h,tabIndex:-1,class:"absolute right-4 top-1/2 -translate-y-1/2 flex h-6 w-6 items-center justify-center rounded text-gray-500 transition-colors hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:a?n.jsx(it,{}):n.jsx(st,{})})]})}function st(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M1.667 10S4.583 4.167 10 4.167 18.333 10 18.333 10 15.417 15.833 10 15.833 1.667 10 1.667 10Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor","stroke-width":"1.5"})]})}function it(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M8.236 4.293A6.96 6.96 0 0 1 10 4.167C15.417 4.167 18.333 10 18.333 10a13.5 13.5 0 0 1-1.92 2.755M11.768 11.768A2.5 2.5 0 0 1 8.233 8.233",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M14.953 14.953A8.84 8.84 0 0 1 10 15.833C4.583 15.833 1.667 10 1.667 10a13.5 13.5 0 0 1 3.38-3.953M1.667 1.667l16.666 16.666",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]})}function ot({email:r}){const{t:e}=j(),t=r?e("auth.last_used","Last · {email}",{email:at(r)}):e("auth.last_used_no_email","Last");return n.jsx("span",{class:"pointer-events-none absolute -top-2 right-3 max-w-[75%] truncate rounded-full bg-gray-900 px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white shadow-sm",children:t})}function at(r){const[e,t]=r.split("@");return t?`${e.slice(0,3)}*****@${t}`:r}function lt(){const{t:r}=j();return n.jsxs("div",{class:"flex items-center gap-3 py-1 text-sm text-gray-400",children:[n.jsx("div",{class:"h-px flex-1 bg-gray-200"}),n.jsx("span",{children:r("auth.or","or")}),n.jsx("div",{class:"h-px flex-1 bg-gray-200"})]})}function ct({provider:r}){return r==="google"?n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 18 18","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.49h4.84a4.14 4.14 0 0 1-1.79 2.71v2.26h2.9c1.7-1.56 2.69-3.87 2.69-6.62Z"}),n.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.9-2.26c-.8.54-1.83.86-3.06.86-2.36 0-4.36-1.59-5.07-3.74H.92v2.33A9 9 0 0 0 9 18Z"}),n.jsx("path",{fill:"#FBBC05",d:"M3.93 10.68a5.4 5.4 0 0 1 0-3.36V4.99H.92a9 9 0 0 0 0 8.02l3-2.33Z"}),n.jsx("path",{fill:"#EA4335",d:"M9 3.58c1.32 0 2.5.45 3.44 1.34l2.58-2.58A9 9 0 0 0 .92 4.99l3.01 2.33C4.64 5.17 6.64 3.58 9 3.58Z"})]}):r==="apple"?n.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}):r==="github"?n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M8 0C3.6 0 0 3.6 0 8a8 8 0 0 0 5.5 7.6c.4.1.5-.2.5-.4v-1.5c-2.2.5-2.7-1-2.7-1-.4-.9-.9-1.2-.9-1.2-.7-.5.1-.5.1-.5.8.1 1.2.8 1.2.8.7 1.2 1.9.9 2.4.7 0-.5.3-.9.5-1.1-1.8-.2-3.6-.9-3.6-4 0-.9.3-1.6.8-2.1-.1-.2-.4-1 .1-2.1 0 0 .7-.2 2.2.8a7.6 7.6 0 0 1 4 0c1.5-1 2.2-.8 2.2-.8.4 1.1.2 1.9.1 2.1.5.5.8 1.2.8 2.1 0 3.1-1.9 3.7-3.6 3.9.3.3.6.8.6 1.6V15c0 .2.1.5.6.4A8 8 0 0 0 16 8c0-4.4-3.6-8-8-8Z"})}):n.jsx("svg",{width:"18",height:"20",viewBox:"0 0 14 16",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M14 2.7C14 1.2 12.8 0 11.3 0H2.7C1.2 0 0 1.2 0 2.7v10.6C0 14.8 1.2 16 2.7 16h4V9.8H4.7v-2H6.7V6.4c0-2 1.2-3.1 3-3.1.9 0 1.7.1 2 .2V5h-1.4c-.8 0-1 .4-1 1v1.5h2.4l-.3 2H9.3V16h2c1.5 0 2.7-1.2 2.7-2.7V2.7Z"})})}function ut({block:r,bootstrap:e,auth:t,authSession:s,onBack:i,showBack:o=!0,intent:a="preauth",initialMode:c}){const{t:l}=j(),h={bootstrap:e,selectedPriceId:null,setSelectedPriceId:()=>{},onAction:()=>{},auth:t,authSession:s,initialAuthMode:c},u=a==="restore"?{...r,heading:l("auth.restore_purchases_heading","Restore Purchases"),subheading:l("auth.restore_purchases_subheading","Please sign in to restore your purchases.")}:a==="preauth"?{...r,heading:l("auth.login_continue_purchase","Log in to continue your purchase"),subheading:l("auth.link_purchase_subheading","We'll link the purchase to your account to keep access."),submit_label:l("auth.log_in","Sign In")}:r;return n.jsxs("div",{class:"relative flex-1 min-h-0 overflow-y-auto p-6 sm:p-8",children:[o?n.jsx(dt,{onClick:i,ariaLabel:l("nav.back_aria","Back")}):null,n.jsx(ve,{block:u,ctx:h})]})}function dt({onClick:r,ariaLabel:e}){return n.jsx("button",{type:"button",onClick:r,"aria-label":e,class:"absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M5 8h8a4 4 0 0 1 0 8H9",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M8 4 4 8l4 4",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"})]})})}const _e=r=>`pw-offer-${r}-start`;function Q(r){const e=r-Date.now();return e<=0?{days:0,hours:0,minutes:0,seconds:0,expired:!0}:{days:Math.floor(e/(1e3*60*60*24)),hours:Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(e%(1e3*60*60)/(1e3*60)),seconds:Math.floor(e%(1e3*60)/1e3),expired:!1}}function ht(r){if(r.expires_at){const e=Date.parse(r.expires_at);return Number.isFinite(e)?e:null}if(r.duration_minutes&&r.duration_minutes>0){if(typeof window>"u")return null;try{const e=_e(r.id);let t=window.localStorage.getItem(e);return t||(t=new Date().toISOString(),window.localStorage.setItem(e,t)),Date.parse(t)+r.duration_minutes*6e4}catch{return null}}return null}function je(r,e){if(!r||r.length===0)return null;if(e){const t=r.find(s=>s.id===e);if(t)return t}return r.find(t=>t.expires_at||t.duration_minutes)??null}function Se(r){const e=r?ht(r):null,[t,s]=d.useState(()=>e!==null?Q(e):null),i=d.useRef(e);return i.current=e,d.useEffect(()=>{if(e===null){s(null);return}s(Q(e));const o=setInterval(()=>{const a=Q(i.current??0);if(s(a),a.expired&&(clearInterval(o),r?.duration_minutes&&typeof window<"u"))try{window.localStorage.removeItem(_e(r.id))}catch{}},1e3);return()=>clearInterval(o)},[e,r?.duration_minutes,r?.id]),t}function pt({block:r,ctx:e}){const{t}=j(),s=je(e.bootstrap.offers,r.offer_id),i=Se(s);if(!s||i===null||i.expired&&!r.force)return null;const o=r.title??s.label??t("offer.limited_time","Limited-time offer"),a=s.discount_percent?`${o} ${s.discount_percent}%`:o;return n.jsxs("div",{class:"flex flex-wrap items-center justify-center gap-2 rounded-2xl px-4 py-3 text-[15px] font-semibold leading-tight text-white",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)",textShadow:"0 0 2px rgba(0, 0, 0, 0.25)"},role:"status",children:[n.jsx(Ie,{}),n.jsx("span",{children:a}),n.jsx(Ce,{value:i,t})]})}function Ce({value:r,t:e}){return n.jsxs("div",{class:"flex items-center gap-1 font-mono text-sm",children:[r.days>0?n.jsxs(n.Fragment,{children:[n.jsx($,{children:String(r.days)}),n.jsx("span",{class:"text-xs",children:e("countdown.d","d")})]}):null,n.jsx($,{children:String(r.hours).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.h","h")}),n.jsx($,{children:String(r.minutes).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.m","m")}),n.jsx($,{children:String(r.seconds).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.s","s")})]})}function $({children:r}){return n.jsx("span",{class:"rounded bg-black/20 px-1.5 py-0.5 text-xs font-bold",children:r})}function ft({offer:r}){const{t:e}=j(),t=Se(r);if(t===null||t.expired)return null;const s=r.label??e("offer.limited_time","Limited-time offer"),i=r.discount_percent?`${s} ${r.discount_percent}%`:s;return n.jsxs("div",{class:"-mb-2 flex flex-wrap items-center justify-center gap-2 rounded-t-xl px-4 pb-5 pt-3 text-[15px] font-semibold leading-tight text-white",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)",textShadow:"0 0 2px rgba(0, 0, 0, 0.25)"},role:"status",children:[n.jsx(Ie,{}),n.jsx("span",{children:i}),n.jsx(Ce,{value:t,t:e})]})}function Ie(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:n.jsx("path",{fill:"currentColor",d:"m9.44 5.359-2.394-.895.61-3.036c.062-.31-.345-.531-.57-.291L2.434 6.105a.336.336 0 0 0 .126.537l2.395.894-.61 3.037c-.062.31.345.53.57.29l4.653-4.968a.336.336 0 0 0-.126-.536Z"})})}const ce=3,ue=200,de=5e3,ee=5,gt=10*1024*1024,he=["image/jpeg","image/png","image/webp"],xt=/.+@.+\..+/;function mt({client:r,authSession:e,origin:t,onBack:s}){const{t:i}=j(),o=e?.user.email??"",a=o||null,[c,l]=d.useState(o),[h,u]=d.useState(""),[g,_]=d.useState(""),[p,k]=d.useState([]),[x,I]=d.useState(!1),[y,m]=d.useState(null),[S,C]=d.useState({}),M=()=>{const A={},E=(a??c).trim(),q=h.trim(),R=g.trim();return E?xt.test(E.toLowerCase())||(A.email=i("support.invalid_email","Invalid email")):A.email=i("support.required","Required"),(q.length<ce||q.length>ue)&&(A.subject=i("support.subject_length","{min}–{max} characters",{min:ce,max:ue})),(R.length<1||R.length>de)&&(A.message=i("support.message_length","{min}–{max} characters",{min:1,max:de})),C(A),Object.keys(A).length===0},P=async A=>{if(A.preventDefault(),!x&&M()){I(!0),C(E=>({...E,submit:void 0}));try{const E=(a??c).trim();await r.createSupportTicket({subject:h.trim(),content:g.trim(),email:E||void 0,files:p.length>0?p:void 0}),m(E)}catch(E){const q=E instanceof v.PaywallError&&E.message||"Failed to send. Please try again.";C(R=>({...R,submit:q}))}finally{I(!1)}}},T=()=>{u(""),_(""),k([]),C({}),m(null)},B="flex flex-col gap-3 bg-white px-6 pb-6 pt-3 sm:px-8",O={boxShadow:"0 -4px 12px -4px rgba(15,23,42,0.06)"};return y?n.jsxs("div",{class:"relative flex-1 min-h-0 flex flex-col",children:[n.jsxs("div",{class:"flex-1 min-h-0 overflow-y-auto flex flex-col items-center gap-4 px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 85%, white), var(--pw-accent))",color:"#fff",boxShadow:"0 0 0 8px color-mix(in srgb, var(--pw-accent) 12%, transparent), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 45%, transparent)"},"aria-hidden":"true",children:n.jsx("svg",{viewBox:"0 0 24 24",class:"h-7 w-7",children:n.jsx("path",{fill:"currentColor",d:"M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24Zm6.93 8.2-6.85 9.29a1.01 1.01 0 0 1-1.43.19L5.76 13.77a1 1 0 1 1 1.25-1.56l4.08 3.26 6.23-8.45a1 1 0 1 1 1.61 1.18Z"})})}),n.jsx("div",{class:"text-lg font-semibold tracking-tight text-gray-900",children:i("support.success_heading","Request submitted")}),n.jsxs("div",{class:"max-w-[320px] text-sm leading-relaxed text-gray-500",children:[i("support.success_message_prefix","We've received your message and will respond to")," ",n.jsx("b",{class:"text-gray-700",children:y}),"."]})]}),n.jsx("div",{class:B,style:O,children:n.jsxs("div",{class:"flex items-center justify-center gap-3",children:[n.jsx("button",{type:"button",onClick:s,class:"rounded-xl px-3 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t==="standalone"?i("support.done_button","Done"):i("nav.back_aria","Back")}),n.jsx("button",{type:"button",onClick:T,class:"flex h-10 items-center justify-center rounded-xl px-4 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 6px 14px -4px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:i("support.send_another","Send another request")})]})})]}):n.jsxs("form",{onSubmit:P,class:"relative flex-1 min-h-0 flex flex-col",children:[n.jsx(yt,{onClick:s,ariaLabel:i("nav.back_aria","Back")}),n.jsx("div",{class:"flex-1 min-h-0 overflow-y-auto px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8",children:n.jsxs("div",{class:"flex flex-col gap-5",children:[n.jsxs("div",{class:"flex flex-col gap-2 pr-10",children:[n.jsx("h2",{class:"text-3xl font-bold tracking-tight text-gray-900",children:i("support.heading","Support")}),n.jsx("p",{class:"text-base leading-relaxed text-gray-600",children:i("support.instruction","Please fill out the form below to submit your support request.")})]}),n.jsxs("div",{class:"flex flex-col gap-3",children:[a?n.jsxs("div",{class:"rounded-2xl bg-gray-100 px-5 py-3 text-sm text-gray-600",children:[i("support.sending_as","Sending as")," ",n.jsx("b",{class:"font-medium text-gray-900",children:a})]}):n.jsx(pe,{type:"email",placeholder:i("support.email_placeholder","Enter your email *"),value:c,onInput:l,error:S.email,autocomplete:"email",required:!0}),n.jsx(pe,{type:"text",placeholder:i("support.subject_placeholder","Enter your subject *"),value:h,onInput:u,error:S.subject,required:!0}),n.jsx(bt,{placeholder:i("support.message_placeholder","Enter your message *"),value:g,onInput:_,error:S.message,required:!0}),n.jsx(wt,{files:p,onChange:k,disabled:x})]})]})}),n.jsxs("div",{class:B,style:O,children:[S.submit&&n.jsx("p",{class:"text-sm text-red-600",children:S.submit}),n.jsxs("div",{class:"flex items-center justify-end gap-3",children:[n.jsx("button",{type:"button",onClick:s,disabled:x,class:"rounded-full px-4 py-2 text-base font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t==="standalone"?i("support.close_button","Close"):i("nav.back_aria","Back")}),n.jsx("button",{type:"submit",disabled:x,class:"pw-cta-shimmer relative flex h-12 items-center justify-center overflow-hidden rounded-full px-8 text-base font-semibold text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:x?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:i("support.send_button","Send")})})]})]})]})}function yt({onClick:r,ariaLabel:e}){return n.jsx("button",{type:"button",onClick:r,"aria-label":e,class:"absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M5 8h8a4 4 0 0 1 0 8H9",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M8 4 4 8l4 4",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"})]})})}function pe({type:r,placeholder:e,value:t,onInput:s,error:i,autocomplete:o,required:a}){return n.jsxs("div",{children:[n.jsx("input",{type:r,value:t,placeholder:e,onInput:c=>s(c.target.value),autocomplete:o,required:a,class:`h-14 w-full rounded-2xl bg-gray-100 px-5 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 ${i?"shadow-[0_0_0_2px_rgba(239,68,68,0.5)]":"focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}`}),i&&n.jsx("span",{class:"mt-1 ml-2 block text-sm text-red-600",children:i})]})}function bt({placeholder:r,value:e,onInput:t,error:s,required:i}){return n.jsxs("div",{children:[n.jsx("textarea",{value:e,placeholder:r,onInput:o=>t(o.target.value),required:i,rows:5,class:`min-h-[120px] w-full rounded-2xl bg-gray-100 px-5 py-3.5 text-base leading-relaxed text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 ${s?"shadow-[0_0_0_2px_rgba(239,68,68,0.5)]":"focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}`}),s&&n.jsx("span",{class:"mt-1 ml-2 block text-sm text-red-600",children:s})]})}function wt({files:r,onChange:e,disabled:t}){const{t:s}=j(),i=d.useRef(null),[o,a]=d.useState(!1),[c,l]=d.useState(null),h=u=>{if(!u||t)return;l(null);const g=Array.from(u);if(r.length+g.length>ee){l(s("support.too_many_files","Up to {max} files",{max:ee}));return}const _=g.filter(p=>he.includes(p.type)&&p.size<=gt);if(_.length!==g.length){l(s("support.invalid_file","Only JPEG/PNG/WebP, ≤ 10MB each"));return}e([...r,..._])};return n.jsxs("div",{children:[n.jsx("span",{class:"text-xs font-medium text-gray-700",children:s("support.attachments_label","Attachments (optional)")}),n.jsxs("div",{role:"button",tabIndex:0,"aria-label":s("support.attachments_aria","Attachments upload"),onClick:()=>!t&&i.current?.click(),onDragOver:u=>{u.preventDefault(),t||a(!0)},onDragLeave:()=>a(!1),onDrop:u=>{u.preventDefault(),a(!1),h(u.dataTransfer?.files??null)},class:`mt-1.5 cursor-pointer rounded-2xl border border-dashed p-3.5 text-center transition-all ${o?"border-[var(--pw-accent)] bg-[color-mix(in_srgb,var(--pw-accent)_6%,white)]":"border-gray-300 hover:border-gray-400 hover:bg-gray-50/60"} ${t?"cursor-not-allowed opacity-60":""}`,children:[n.jsx("div",{class:"text-xs text-gray-500",children:s("support.dropzone_text","Drop images here or click to select")}),n.jsx("div",{class:"mt-0.5 text-[11px] text-gray-400",children:s("support.file_requirements","JPEG/PNG/WebP, up to {max} files, ≤ 10MB each",{max:ee})})]}),n.jsx("input",{ref:i,type:"file",multiple:!0,accept:he.join(","),class:"hidden",onChange:u=>{h(u.target.files),u.currentTarget.value=""}}),c&&n.jsx("p",{class:"mt-1 text-xs text-red-600",children:c}),r.length>0&&n.jsx("ul",{class:"mt-2 flex flex-col gap-1",children:r.map((u,g)=>n.jsxs("li",{class:"flex items-center justify-between gap-2 rounded bg-gray-50 px-2 py-1 text-xs",children:[n.jsx("span",{class:"truncate text-gray-700",children:u.name}),n.jsx("button",{type:"button",onClick:()=>{const _=[...r];_.splice(g,1),e(_)},disabled:t,class:"text-gray-500 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-60","aria-label":s("support.remove_file_aria","Remove {filename}",{filename:u.name}),children:"✕"})]},`${u.name}-${u.size}-${g}`))})]})}const kt={day:"cta.get_plan_daily",week:"cta.get_plan_weekly",month:"cta.get_plan_monthly",year:"cta.get_plan_yearly"},vt={day:"Get Daily Plan",week:"Get Weekly Plan",month:"Get Monthly Plan",year:"Get Yearly Plan"};function _t(r,e,t,s){if(e==="close")return s("cta.close","Close");if(!r)return s("cta.continue","Continue");if(!t&&r.trial_days&&r.interval&&r.interval!=="lifetime")return s("cta.start_trial","Start {days}-Day Free Trial",{days:r.trial_days});if(!r.interval||r.interval==="lifetime")return s("cta.get_lifetime_access","Get Lifetime Access");const i=kt[r.interval];return i?s(i,vt[r.interval]):s("cta.get_plan_generic","Get {interval} Plan",{interval:jt(r.interval)})}function jt(r){return r.length?r[0].toUpperCase()+r.slice(1):r}function St({block:r,ctx:e}){const{t}=j(),[s,i]=d.useState(!1),o=r.priceId??e.selectedPriceId,a=s||r.action==="checkout"&&!o,c=o?e.bootstrap.prices.find(g=>g.id===o)??null:null,l=e.bootstrap.user?.had_previous_trial??!1,h=r.label??_t(c,r.action,l,t),u=async()=>{if(!a){i(!0);try{await e.onAction(r.action,{priceId:o})}finally{i(!1)}}};return n.jsxs("button",{type:"button",disabled:a,onClick:u,class:"pw-cta-shimmer relative flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:[n.jsx("span",{class:"absolute inset-0 opacity-40",style:{background:"radial-gradient(circle at 50% 0%, color-mix(in srgb, white 40%, transparent) 0%, transparent 70%)"},"aria-hidden":"true"}),s?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:h})]})}function Ct({ctx:r}){const{t:e}=j(),t=r.authSession,s=r.auth,[i,o]=d.useState(!1),a=()=>r.onAction("support");if(t&&!t.user.is_anonymous){const c=async()=>{if(!(!s||i)){o(!0);try{await s.signOut()}catch{}finally{o(!1)}}};return n.jsxs("div",{class:"-mt-3 flex flex-col items-center gap-1.5 pt-1 text-center text-[13px] text-gray-500",children:[n.jsxs("span",{children:[e("session.signed_in_as_prefix","Signed in as")," ",n.jsx("b",{class:"font-medium text-gray-700",children:t.user.email})]}),n.jsxs("div",{class:"flex items-center justify-center gap-3",children:[n.jsx(V,{onClick:c,disabled:!s||i,children:i?e("session.signing_out","Signing out…"):e("session.sign_out","Sign Out")}),n.jsx(fe,{}),n.jsx(V,{onClick:a,children:e("session.contact_support","Contact Support")})]})]})}return n.jsxs("div",{class:"-mt-3 flex items-center justify-center gap-3 pt-1 text-center text-[13px]",children:[n.jsx(V,{onClick:()=>r.onAction("restore"),children:e("session.restore_purchases","Restore purchases")}),n.jsx(fe,{}),n.jsx(V,{onClick:a,children:e("session.contact_support","Contact Support")})]})}function V({onClick:r,disabled:e,children:t}){return n.jsx("button",{type:"button",onClick:r,disabled:e,class:"font-semibold transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:opacity-80",style:{color:"var(--pw-accent)"},children:t})}function fe(){return n.jsx("span",{class:"h-1 w-1 rounded-full bg-gray-300","aria-hidden":"true"})}function It({block:r}){return r.items.length?n.jsx("ul",{class:"flex flex-col gap-2.5",role:"list",children:r.items.map(e=>n.jsxs("li",{class:"flex items-start gap-3 text-sm text-gray-700",children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",class:"mt-0.5 flex-shrink-0 text-emerald-500","aria-hidden":"true",children:n.jsx("path",{d:"M4 10.5l3.5 3.5 8.5-8.5",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})}),n.jsxs("div",{class:"flex flex-col gap-0.5",children:[n.jsx("span",{class:"font-medium leading-snug text-gray-900",children:e.name}),e.desc?n.jsx("span",{class:"text-xs leading-relaxed text-gray-400",children:e.desc}):null]})]},e.id))}):null}function Pt({block:r}){const{t:e}=j(),t=r.title??e("pricing.money_back","30-day money-back guarantee"),s=r.subtitle,i=(r.icon??"dollar_shield")!=="none",o=Et(t);return n.jsxs("div",{class:"flex flex-col items-center gap-1.5 border-b-1 pb-4 mb-1 border-gray-100",children:[n.jsxs("div",{class:"inline-flex items-center gap-2 text-[12px] text-gray-700",children:[i?n.jsx(At,{}):null,o?n.jsxs("span",{children:[n.jsx("b",{class:"font-bold text-gray-900",children:o.bold})," ",n.jsx("span",{class:"font-medium",children:o.rest})]}):n.jsx("span",{class:"font-medium",children:t})]}),s?n.jsx("span",{class:"text-center text-xs leading-relaxed text-gray-500",children:s}):null]})}function Et(r){const e=r.match(/^(\d+[-\s]?days?)\s+(.+)$/i);return e?{bold:e[1],rest:e[2]}:null}function At(){return n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16",class:"flex-shrink-0 text-emerald-500","aria-hidden":"true",children:[n.jsx("path",{d:"M12 2 4 5v6c0 5.25 3.5 9.5 8 11 4.5-1.5 8-5.75 8-11V5l-8-3Z",stroke:"currentColor","stroke-width":"2","stroke-linejoin":"round"}),n.jsx("path",{d:"m9 12 2 2 4-4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}const Pe=24,Lt=16,Tt=2;function Mt(r,e){const t=e*Tt;let s=Pe;for(r.style.fontSize=`${s}px`;r.scrollHeight>t&&s>Lt;)s-=1,r.style.fontSize=`${s}px`}function Bt({block:r,ctx:e}){const t=r.level??1,s=`h${t}`,i=t===1?"text-[22px] sm:text-2xl font-semibold leading-tight text-center text-balance text-gray-800":t===2?"text-xl font-semibold leading-snug text-gray-900 tracking-tight":"text-base font-medium text-gray-900",o=d.useRef(null),a=t===1&&!!e.bootstrap.settings.title_auto_fit;return d.useEffect(()=>{if(!a||!o.current)return;const c=getComputedStyle(o.current),l=parseFloat(c.lineHeight)||Pe*1.5;Mt(o.current,l)},[a,r.text]),n.jsx(s,{ref:o,class:i,children:r.text})}function Ot(r){const e=r.local??{currency:r.currency,amount:r.amount};if(r.interval==="year"){const t=(r.interval_count??1)*12;return{amount:e.amount/t,currency:e.currency}}return{amount:e.amount,currency:e.currency}}function te(r,e){const t=r%1!==0?2:0;try{const s=new Intl.NumberFormat(void 0,{style:"currency",currency:e,currencyDisplay:"narrowSymbol",maximumFractionDigits:t,minimumFractionDigits:t}).formatToParts(r);let i="",o="";for(const a of s)a.type==="currency"?i=a.value:a.type!=="literal"&&(o+=a.value);return{currency:i||e,amount:o.trim()}}catch{return{currency:e,amount:String(r)}}}function ne(r,e){const{amount:t,currency:s}=Ot(r);if(!e){const{currency:c,amount:l}=te(t,s);return{currency:c,amount:l,originalAmount:null}}const i=t*(1-e/100),o=te(i,s),a=te(t,s);return{currency:o.currency,amount:o.amount,originalAmount:`${a.currency}${a.amount}`}}function Ee(r,e){if(r.label)return r.label.toUpperCase();if(!r.interval||r.interval==="lifetime")return e("pricing.plan_label.lifetime","LIFETIME");const s={day:{key:"pricing.plan_label.daily",fallback:"DAILY PLAN"},week:{key:"pricing.plan_label.weekly",fallback:"WEEKLY PLAN"},month:{key:"pricing.plan_label.monthly",fallback:"MONTHLY PLAN"},year:{key:"pricing.plan_label.yearly",fallback:"YEARLY PLAN"}}[r.interval];return s?e(s.key,s.fallback):`${r.interval.toUpperCase()} PLAN`}function se(r,e){if(!r.interval||r.interval==="lifetime")return e("pricing.interval.lifetime_short","lifetime");if(r.interval==="year")return e("pricing.interval.month","month");const t=r.interval_count??1;return t===1?e(`pricing.interval.${r.interval}`,r.interval):`${t} ${r.interval}s`}function qt({block:r,ctx:e}){const{t}=j(),s=r.priceIds&&r.priceIds.length>0?new Set(r.priceIds):null,i=e.bootstrap.prices.filter(a=>!s||s.has(a.id));if(i.length===0)return n.jsx("p",{class:"text-sm text-gray-500",children:t("pricing.no_prices","No prices available.")});const o=r.popular_label??t("pricing.most_popular","Most popular");if(r.view==="compact")return n.jsx("div",{class:"flex w-full flex-col rounded-xl border border-gray-200 bg-gray-50",role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map((a,c)=>n.jsx(Ut,{price:a,isLast:c===i.length-1,isPopular:r.popular_price_id===a.id,popularLabel:o,offer:D(e.bootstrap.offers,a.id),selected:e.selectedPriceId===a.id,onSelect:()=>{e.setSelectedPriceId(a.id),e.onAction("price_selected",{priceId:a.id,price:a})},t},a.id))});if(r.view==="horizontal"){const a=Math.min(i.length,3),c=i.some(l=>(D(e.bootstrap.offers,l.id)?.discount_percent??0)>0);return n.jsx("div",{class:"grid items-stretch gap-2",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map(l=>n.jsx(Dt,{price:l,isPopular:r.popular_price_id===l.id,popularLabel:o,offer:D(e.bootstrap.offers,l.id),reserveStrikeRow:c,selected:e.selectedPriceId===l.id,onSelect:()=>{e.setSelectedPriceId(l.id),e.onAction("price_selected",{priceId:l.id,price:l})},t},l.id))})}return n.jsx("div",{class:"flex flex-col gap-2",role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map(a=>{const c=e.selectedPriceId===a.id,l=r.popular_price_id===a.id,u=D(e.bootstrap.offers,a.id)?.discount_percent??null,{currency:g,amount:_,originalAmount:p}=ne(a,u);return n.jsxs("button",{type:"button",role:"radio","aria-checked":c,onClick:()=>{e.setSelectedPriceId(a.id),e.onAction("price_selected",{priceId:a.id,price:a})},class:["group relative inline-flex w-full mx-auto items-center justify-between flex-row-reverse gap-4 rounded-2xl border-2 px-4 py-3.5 text-left transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",c?"border-[var(--pw-accent)] bg-transparent":"border-gray-200 bg-transparent hover:bg-gray-50"].join(" "),children:[n.jsx("span",{class:["flex h-6.5 w-6.5 flex-shrink-0 items-center justify-center rounded-full border transition-colors",c?"border-[var(--pw-accent)] text-white":"border-gray-300 bg-transparent text-transparent",l?"mt-3":""].join(" "),style:c?{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 70%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)"}:void 0,"aria-hidden":"true",children:n.jsx("svg",{width:"14",height:"10",viewBox:"0 0 17 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:c?"opacity-100":"opacity-0",children:n.jsx("path",{d:"M16.5234 0.476562C16.9805 0.898438 16.9805 1.63672 16.5234 2.05859L7.52344 11.0586C7.10156 11.5156 6.36328 11.5156 5.94141 11.0586L1.44141 6.55859C0.984375 6.13672 0.984375 5.39844 1.44141 4.97656C1.86328 4.51953 2.60156 4.51953 3.02344 4.97656L6.75 8.66797L14.9414 0.476562C15.3633 0.0195312 16.1016 0.0195312 16.5234 0.476562Z",fill:"currentColor"})})}),n.jsxs("div",{class:"flex flex-1 flex-col gap-0.5",children:[n.jsxs("div",{class:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{class:"text-xs font-normal uppercase tracking-normal text-gray-800/70",children:Ee(a,t)}),p?n.jsx("span",{class:"text-[15px] font-normal text-gray-400 opacity-60 line-through decoration-gray-400 decoration-[1.5px]",children:p}):null,u?n.jsxs("span",{class:"rounded-full bg-emerald-100 px-2.5 py-1 text-xs font-bold leading-none text-emerald-700",children:["-",u,"%"]}):null]}),n.jsx("div",{class:"flex items-baseline gap-2 flex-wrap",children:n.jsxs("span",{class:"text-[26px] leading-tight whitespace-nowrap text-gray-800 font-medium",children:[n.jsx("span",{class:"opacity-90",children:g}),_,n.jsxs("span",{class:"text-sm font-normal text-gray-500",children:[" ","/ ",se(a,t)]})]})}),a.description?n.jsx("span",{class:"mt-1 text-xs leading-relaxed text-gray-500",children:a.description}):null]}),l?n.jsx("span",{class:"absolute -top-[9px] -right-[6px] rounded-[11px] border-[5px] border-white px-2 py-1 text-[12px] font-semibold text-white",style:{background:"var(--pw-accent)"},children:o}):null]},a.id)})})}function Rt(r,e){return r.label?r.label:!r.interval||r.interval==="lifetime"?e("pricing.interval.lifetime_short","lifetime"):e(`pricing.interval.${r.interval}`,r.interval)}function Ut({price:r,isLast:e,isPopular:t,popularLabel:s,offer:i,selected:o,onSelect:a,t:c}){const l=i?.discount_percent??null,{currency:h,amount:u,originalAmount:g}=ne(r,l);return n.jsxs("button",{type:"button",role:"radio","aria-checked":o,onClick:a,class:"group relative inline-flex w-full max-w-[360px] mx-auto items-center justify-between gap-4 px-4 pt-3.5 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--pw-accent)]",children:[n.jsx("span",{class:["flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border transition-colors mb-3",o?"border-[var(--pw-accent)] text-white":"border-gray-300 bg-transparent text-transparent"].join(" "),style:o?{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 70%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)"}:void 0,"aria-hidden":"true",children:n.jsx("svg",{width:"14",height:"10",viewBox:"0 0 17 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:o?"opacity-100":"opacity-0",children:n.jsx("path",{d:"M16.5234 0.476562C16.9805 0.898438 16.9805 1.63672 16.5234 2.05859L7.52344 11.0586C7.10156 11.5156 6.36328 11.5156 5.94141 11.0586L1.44141 6.55859C0.984375 6.13672 0.984375 5.39844 1.44141 4.97656C1.86328 4.51953 2.60156 4.51953 3.02344 4.97656L6.75 8.66797L14.9414 0.476562C15.3633 0.0195312 16.1016 0.0195312 16.5234 0.476562Z",fill:"currentColor"})})}),n.jsxs("div",{class:["flex flex-1 items-center gap-1.5 pb-3.5",e?"":"border-b border-gray-200"].join(" "),children:[n.jsxs("div",{class:"flex flex-wrap items-center gap-1 gap-x-1.5",children:[n.jsx("span",{class:"text-base font-normal capitalize text-gray-800",children:Rt(r,c)}),t?n.jsx("span",{class:"rounded-[9px] px-2 py-1 text-[10px] font-bold",style:{background:"linear-gradient(160deg, color-mix(in srgb, var(--pw-accent) 6%, white) 0%, color-mix(in srgb, var(--pw-accent) 15%, white) 100%)",color:"var(--pw-accent)"},children:s}):null,l?n.jsxs("span",{class:"rounded-md bg-emerald-100 px-1.5 py-0.5 text-[10px] font-bold leading-none text-emerald-700",children:["-",l,"%"]}):null]}),n.jsx("div",{class:"flex-1"}),n.jsxs("span",{class:"flex items-baseline gap-1.5 text-base font-normal text-gray-600",children:[g?n.jsx("span",{class:"text-xs text-gray-400 line-through decoration-gray-400 decoration-[1.5px]",children:g}):null,n.jsxs("span",{class:"whitespace-nowrap",children:[n.jsx("span",{class:"opacity-90",children:h}),u,n.jsxs("span",{class:"text-xs text-gray-400",children:[" ","/ ",se(r,c)]})]})]})]})]})}function Dt({price:r,isPopular:e,popularLabel:t,offer:s,reserveStrikeRow:i,selected:o,onSelect:a,t:c}){const l=s?.discount_percent??null,{currency:h,amount:u,originalAmount:g}=ne(r,l);return n.jsxs("button",{type:"button",role:"radio","aria-checked":o,onClick:a,class:["group relative flex h-full flex-col items-center justify-start gap-1 rounded-2xl border-2 px-3 pb-4 pt-3.5 text-center transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",o?"border-[var(--pw-accent)]":"border-gray-200 hover:bg-gray-50"].join(" "),style:o?{background:"color-mix(in srgb, var(--pw-accent) 6%, transparent)"}:void 0,children:[n.jsx("span",{class:"flex min-h-[2.4em] items-center text-[10px] font-normal uppercase leading-tight text-gray-800/70",children:Ee(r,c)}),i?n.jsxs("div",{class:"flex h-[22px] items-center justify-center gap-1.5",children:[g?n.jsx("span",{class:"text-[12px] text-gray-400 line-through decoration-gray-400 decoration-[1.5px]",children:g}):null,l?n.jsxs("span",{class:"rounded-md bg-emerald-100 px-1.5 py-0.5 text-[10px] font-bold leading-none text-emerald-700",children:["-",l,"%"]}):null]}):null,n.jsxs("span",{class:"text-[26px] leading-none whitespace-nowrap text-gray-800 font-medium",children:[n.jsx("span",{class:"opacity-90",children:h}),u]}),n.jsxs("span",{class:"text-xs font-normal text-gray-500",children:["/ ",se(r,c)]}),e?n.jsx("span",{class:"absolute -top-[10px] left-1/2 -translate-x-1/2 whitespace-nowrap rounded-[11px] border-[3px] border-white px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-white",style:{background:"var(--pw-accent)"},children:t}):null]})}function Nt({block:r}){return n.jsx("p",{class:"text-[0.9375rem] leading-relaxed text-gray-600",children:r.text})}const zt={week:.25,month:1,year:12};function Ft(r,e){return r?e(`pricing.interval.${r}`,r):e("pricing.interval.period","period")}function $t({block:r,ctx:e}){const{t}=j();if(!r.queries.length)return null;const i=e.bootstrap.prices.find(a=>a.id===e.selectedPriceId)?.interval??null,o=i?zt[i]:void 0;return n.jsxs("div",{class:"flex flex-col gap-2",children:[n.jsx("div",{class:"text-sm font-semibold text-gray-800",children:!i||i==="lifetime"?t("pricing.included_total","Included for lifetime:"):t("pricing.included_per","Included per {interval}:",{interval:Ft(i,t)})}),n.jsx("ul",{class:"flex flex-col gap-2",role:"list",children:r.queries.map(a=>{const c=Number.isFinite(a.count)?a.count:0,l=o!==void 0?Math.round(c*o):c;return n.jsxs("li",{class:`flex gap-3 ${a.desc?"items-start":"items-center"}`,children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",class:`flex-shrink-0 text-emerald-500 ${a.desc?"mt-0.5":""}`,"aria-hidden":"true",children:n.jsx("path",{d:"M4 10.5l3.5 3.5 8.5-8.5",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})}),n.jsxs("div",{children:[n.jsx("span",{class:"font-semibold text-gray-900 text-sm",children:l})," ",n.jsx("span",{class:"text-sm text-gray-800",children:a.name}),a.desc?n.jsxs(n.Fragment,{children:[n.jsx("br",{}),n.jsx("span",{class:"text-xs text-gray-400",children:a.desc})]}):null]})]},a.id)})})]})}const Vt={heading:Bt,text:Nt,price_grid:qt,cta_button:St,auth_panel:ve,current_session:Ct,features_list:It,tokenization_gate:$t,guarantee_badge:Pt,offer_banner:pt};function Ht({layout:r,bootstrap:e,onAction:t,auth:s,authSession:i,hasTopBanner:o}){const a=d.useMemo(()=>{for(const k of r.blocks)if(k.type==="price_grid"&&k.popular_price_id&&e.prices.some(x=>x.id===k.popular_price_id))return k.popular_price_id;return e.prices[0]?.id??null},[r.blocks,e.prices]),[c,l]=d.useState(a),h={bootstrap:e,selectedPriceId:c,setSelectedPriceId:l,onAction:t,auth:s,authSession:i},u=r.blocks.findIndex(k=>k.type==="cta_button"),g=u===-1?r.blocks:r.blocks.slice(0,u),_=u===-1?[]:r.blocks.slice(u),p=(k,x)=>{const I=Vt[k.type];return I?n.jsx(I,{block:k,ctx:h},`${k.type}-${x}`):(typeof console<"u"&&console.warn(`[paywall] unknown block type: ${k.type}`),null)};return n.jsxs(n.Fragment,{children:[n.jsx("div",{class:"flex-1 min-h-0 overflow-y-auto px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8",children:n.jsx("div",{class:"flex flex-col gap-6",children:g.map(p)})}),_.length>0?n.jsx("div",{class:"flex flex-col gap-4 bg-white px-6 pb-6 pt-3 sm:px-8",style:{boxShadow:"0 -4px 12px -4px rgba(15,23,42,0.06)"},children:_.map((k,x)=>p(k,g.length+x))}):null]})}function Gt(r,e,t,s){return r?s?{open:!0,view:"purchased",error:null,processing:!1}:e.status==="idle"||e.status==="loading"?{open:!0,view:"loading",error:null,processing:!1}:e.status==="error"?{open:!0,view:"error",error:e.error,processing:!1}:t.kind==="support"?{open:!0,view:"support",error:null,processing:!1}:t.kind==="auth_gate"?{open:!0,view:"auth",error:null,processing:!1}:t.kind==="awaiting_payment"?{open:!0,view:"awaiting_payment",error:null,processing:!1}:t.kind==="popup_blocked"?{open:!0,view:"popup_blocked",error:null,processing:!1}:t.kind==="purchase_success"?{open:!0,view:"purchased",error:null,processing:!1}:t.kind==="verifying"?{open:!0,view:"loading",error:null,processing:!1}:{open:!0,view:"layout",error:null,processing:!1}:{open:!1,view:null,error:null,processing:!1}}function Wt(r,e){return r.open===e.open&&r.view===e.view&&r.error===e.error&&r.processing===e.processing}function Zt({client:r,open:e,onClose:t,onEvent:s,initialView:i,initialAuthMode:o,initialCheckoutPriceId:a,initialCheckoutUrl:c,purchased:l,renew:h,onState:u,inline:g,locale:_}){const[p,k]=d.useState({status:"idle"}),[x,I]=d.useState(()=>r.auth?.getCachedSession()??null),[y,m]=d.useState(()=>i==="support"?{kind:"support",origin:"standalone"}:i==="auth"?a?{kind:"auth_gate",pendingCheckout:{priceId:a,direct:!0},origin:"standalone",intent:"preauth"}:{kind:"auth_gate",origin:"standalone"}:i==="awaiting_payment"&&a&&c?{kind:"awaiting_payment",priceId:a,url:c}:i==="popup_blocked"&&a&&c?{kind:"popup_blocked",priceId:a,url:c}:{kind:"layout"}),S=i==="awaiting_payment"||i==="popup_blocked"||i==="auth"&&!!a,C=d.useRef(!1),M=d.useRef(null);d.useEffect(()=>{if(!u)return;const b=Gt(e,p,y,l),f=M.current;f&&Wt(f,b)||(M.current=b,u(b))},[e,p,y,l,u]),d.useEffect(()=>{if(r.auth)return r.auth.onAuthChange((b,f)=>I(f))},[r.auth]),d.useEffect(()=>{if(typeof r.onBootstrapChange=="function")return r.onBootstrapChange(b=>{k(f=>f.status==="ready"?{status:"ready",data:b}:f)})},[r]),d.useEffect(()=>{if(!e||p.status==="ready"||p.status==="loading")return;let b=!1;return k({status:"loading"}),r.bootstrap().then(f=>{if(b)return;k({status:"ready",data:f}),s("ready",f);const w=i==="support"||i==="auth"||S;f.user?.has_active_subscription&&!h&&!w&&(s("purchase_completed",{priceId:a??null,sessionId:null,restored:!0}),m({kind:"purchase_success",restored:!0}))}).catch(f=>{if(b)return;const w=f instanceof v.PaywallError?f:new v.PaywallError("unknown","Failed to load paywall",{cause:f});k({status:"error",error:w}),s("error",w)}),()=>{b=!0}},[e,r]),d.useLayoutEffect(()=>{if(!e){m({kind:"layout"}),C.current=!1;return}i==="support"?m({kind:"support",origin:"standalone"}):i==="auth"?m(a?{kind:"auth_gate",pendingCheckout:{priceId:a,direct:!0},origin:"standalone",intent:"preauth"}:{kind:"auth_gate",origin:"standalone"}):i==="awaiting_payment"&&a&&c?m({kind:"awaiting_payment",priceId:a,url:c}):i==="popup_blocked"&&a&&c&&m({kind:"popup_blocked",priceId:a,url:c})},[e,i,a,c]);const P=async b=>{try{const f=r.getCachedOffers?.()??null,w=f?D(f,b):null,L=await r.createCheckout({priceId:b,offerId:w?.id,ignoreActivePurchase:h===!0});if(s("checkout_started",{priceId:b,url:L.url,acquiring:L.acquiring}),typeof window>"u"||!L.url)return;const z=window.open(L.url,"_blank");if(z){try{z.opener=null}catch{}m({kind:"awaiting_payment",priceId:b,url:L.url})}else m({kind:"popup_blocked",priceId:b,url:L.url})}catch(f){if(f instanceof v.PaywallError&&f.code==="already_purchased"){try{await r.getUser({force:!0})}catch{}s("purchase_completed",{priceId:b,sessionId:null,restored:!0}),S?t():m({kind:"purchase_success",restored:!0});return}const w=f instanceof v.PaywallError?f:new v.PaywallError("checkout_failed","Checkout failed",{cause:f});s("error",w),S?t():m({kind:"layout"})}},T=(b,f)=>{if(typeof window>"u")return;const w=window.open(f,"_blank");if(w){try{w.opener=null}catch{}m({kind:"awaiting_payment",priceId:b,url:f})}};d.useEffect(()=>{if(y.kind!=="auth_gate"||!x||x.user.is_anonymous||C.current)return;C.current=!0;const b=y.pendingCheckout,f=y.origin;m({kind:"verifying"}),(async()=>{if(!h)try{if((await r.getUser({force:!0})).has_active_subscription){s("purchase_completed",{priceId:b?.priceId??null,sessionId:null,restored:!0}),b?.direct?t():m({kind:"purchase_success",restored:!0});return}}catch{}if(!b){f==="standalone"?t():m({kind:"layout"});return}await P(b.priceId)})().finally(()=>{C.current=!1})},[x,y]);const B=async(b,f)=>{if(b==="close"){t();return}if(b==="price_selected"){s("price_selected",f);return}if(b==="restore"){if(!r.auth)return;const w=r.auth.getCachedSession();if(w&&!w.user.is_anonymous)return;m({kind:"auth_gate",intent:"restore"});return}if(b==="support"){m({kind:"support",origin:"layout"});return}if(b==="checkout"&&p.status==="ready"){const w=f?.priceId;if(!w){s("error",new v.PaywallError("no_price","No price selected"));return}const L=p.data.settings.checkout_mode??"guest",z=r.auth?.getCachedSession()??null,Be=!!z&&!z.user.is_anonymous;if(L==="preauth"&&!!r.auth&&!Be){m({kind:"auth_gate",pendingCheckout:{priceId:w}});return}await P(w)}},O=p.status==="ready"?p.data.settings.brand_color:null,A=p.status==="ready"?p.data.settings.allow_close!==!1:!0,q=y.kind==="layout"&&p.status==="ready"?je(p.data.offers):null,R=q?n.jsx(ft,{offer:q}):null,W={type:"auth_panel",allow_signup:!0,allow_password_reset:!0,hide_when_authenticated:!1,providers:p.status==="ready"?p.data.settings.auth_providers:void 0},F=y.kind==="support"?n.jsx(mt,{client:r,authSession:x,origin:y.origin,onBack:()=>{y.origin==="standalone"?t():m({kind:"layout"})}}):null,Z=y.kind==="auth_gate"&&y.origin!=="standalone"||y.kind==="support",Y=p.status==="ready"?p.data:null;return n.jsx(Ze,{bootstrap:Y,forceLocale:_,children:n.jsx(Ye,{open:e,onClose:t,brandColor:O,topBanner:R,allowClose:A,hideCloseButton:Z,inline:g,labelledBy:"pw-title",children:l?n.jsx(ge,{onContinue:t}):y.kind==="purchase_success"?n.jsx(ge,{restored:y.restored,onContinue:t}):F||(p.status==="loading"||p.status==="idle"||y.kind==="verifying"?n.jsx(Yt,{verifying:y.kind==="verifying"}):p.status==="error"?n.jsx(Kt,{message:p.error.message}):y.kind==="auth_gate"&&r.auth?n.jsx(ut,{block:W,bootstrap:p.data,auth:r.auth,authSession:x,showBack:y.origin!=="standalone",intent:y.intent??(y.origin==="standalone"?"standalone":"preauth"),initialMode:y.origin==="standalone"?o:void 0,onBack:()=>{y.origin==="standalone"?t():m({kind:"layout"})}}):y.kind==="awaiting_payment"?n.jsx(Jt,{client:r,onBack:()=>m({kind:"layout"}),onReopen:()=>{if(typeof window>"u")return;const b=window.open(y.url,"_blank");if(b)try{b.opener=null}catch{}},onRetry:()=>P(y.priceId)}):y.kind==="popup_blocked"?n.jsx(Xt,{onReopen:()=>T(y.priceId,y.url)}):n.jsx(Ht,{layout:p.data.layout,bootstrap:p.data,onAction:B,auth:r.auth,authSession:x}))})})}function Yt({verifying:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center justify-center gap-3 py-12",children:[n.jsx("span",{class:"inline-block h-7 w-7 animate-spin rounded-full border-[2.5px] border-gray-200 border-t-[var(--pw-accent)]"}),n.jsx("span",{class:"text-xs font-medium tracking-wide text-gray-500",children:r?e("modal.verifying_subscription","Checking your subscription…"):e("modal.loading","Loading…")})]})}function Kt({message:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-2 py-8 text-center",children:[n.jsx("div",{class:"flex h-11 w-11 items-center justify-center rounded-full bg-red-50",children:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M10 6v5M10 14h.01",stroke:"#dc2626","stroke-width":"2","stroke-linecap":"round"}),n.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"#dc2626","stroke-width":"1.75"})]})}),n.jsx("p",{class:"text-sm font-semibold tracking-tight text-gray-900",children:e("modal.error_generic","Something went wrong")}),n.jsx("p",{class:"text-xs leading-relaxed text-gray-500",children:r})]})}function Xt({onReopen:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-3 py-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full",style:{background:"color-mix(in srgb, var(--pw-accent) 12%, white)",color:"var(--pw-accent)"},"aria-hidden":"true",children:n.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("path",{d:"M14 4h6v6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M20 4l-9 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M19 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:e("payment.popup_blocked_title","Allow popups to continue")}),n.jsx("p",{class:"max-w-[20rem] text-sm leading-relaxed text-gray-500",children:e("payment.popup_blocked_message","Your browser blocked the checkout tab. Click below to open it.")}),n.jsx("button",{type:"button",onClick:r,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:e("payment.open_checkout_button","Open checkout")})]})}function Jt({client:r,onBack:e,onReopen:t,onRetry:s}){const{t:i}=j(),[o,a]=d.useState(!1),[c,l]=d.useState(!1),h=d.useRef(null);d.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current)},[]);const u=async()=>{if(!o){a(!0),l(!1);try{if((await r.getUser({force:!0})).has_active_subscription){typeof window<"u"&&window.postMessage({type:"paywall_purchase"},"*");return}l(!0),h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{l(!1),h.current=null},5e3)}catch{l(!0)}finally{a(!1)}}};return n.jsxs("div",{class:"flex flex-col gap-3 px-6 pb-6 pt-4 sm:px-8 sm:pb-8 sm:pt-5",children:[n.jsx("button",{type:"button",onClick:e,class:"-ml-1 self-start rounded-md px-1.5 py-0.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("nav.back","← Back")}),n.jsxs("div",{class:"flex flex-col items-center gap-3 py-6 text-center",children:[n.jsxs("div",{class:"relative flex h-14 w-14 items-center justify-center",children:[n.jsx("span",{class:"absolute inset-0 animate-ping rounded-full opacity-40",style:{background:"color-mix(in srgb, var(--pw-accent) 30%, transparent)"},"aria-hidden":"true"}),n.jsx("span",{class:"relative inline-block h-8 w-8 animate-spin rounded-full border-[2.5px] border-gray-200 border-t-[var(--pw-accent)]"})]}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:i("payment.awaiting_title","Complete payment in the new tab")}),n.jsx("p",{class:"max-w-[22rem] text-sm leading-relaxed text-gray-500",children:i("payment.awaiting_subtitle","We'll detect your payment automatically — or click below once you're done.")}),n.jsx("button",{type:"button",onClick:u,disabled:o,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:brightness-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:o?i("payment.checking","Checking…"):i("payment.ive_paid","I've paid")}),c?n.jsx("p",{class:"text-xs leading-relaxed text-gray-500",children:i("payment.still_processing","Payment is still being processed. Please try again in a moment.")}):null]}),n.jsxs("div",{class:"rounded-2xl border border-gray-200 bg-gray-50/60 p-3.5",children:[n.jsx("p",{class:"text-xs leading-relaxed text-gray-600",children:i("payment.popup_help_text","Checkout window didn't open or got blocked? Click here to open it again.")}),n.jsx("button",{type:"button",onClick:t,class:"mt-2.5 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-xs font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("payment.open_checkout_again","Open checkout again")})]}),n.jsx("button",{type:"button",onClick:s,class:"self-center rounded-md px-2 py-1 text-xs text-gray-500 underline-offset-2 hover:text-gray-900 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("payment.tab_closed_retry","Tab closed? Try again")})]})}function ge({onContinue:r,restored:e=!1}){const{t}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-3 py-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full ring-8",style:{background:"linear-gradient(135deg, #4ade80, #16a34a)",color:"#fff",boxShadow:"0 0 0 8px rgba(74,222,128,0.12), 0 8px 20px -6px rgba(22,163,74,0.45)"},"aria-hidden":"true",children:n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",children:n.jsx("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})})}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:e?t("modal.purchase_restored_title","Subscription restored"):t("modal.purchase_success_title","Payment received")}),n.jsx("p",{class:"text-sm leading-relaxed text-gray-500",children:e?t("modal.purchase_restored_subtitle","Welcome back — your subscription is already active."):t("modal.purchase_success_subtitle","Your subscription is now active.")}),n.jsx("button",{type:"button",onClick:r,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:t("modal.continue","Continue")})]})}const Qt=10*6e4,er=5e3,tr=3e4;class rr{constructor(e){this.timer=null,this.timeoutTimer=null,this.visibilityHandler=null,this.focusHandler=null,this.messageHandler=null,this.stopped=!1,this.checking=!1,this.opts={client:e.client,onActive:e.onActive,onTimeout:e.onTimeout??(()=>{}),timeoutMs:e.timeoutMs??Qt,visibleIntervalMs:e.visibleIntervalMs??er,hiddenIntervalMs:e.hiddenIntervalMs??tr}}start(){this.stopped||typeof document>"u"||typeof window>"u"||(this.check(),this.scheduleNext(),this.visibilityHandler=()=>this.handleVisibilityChange(),document.addEventListener("visibilitychange",this.visibilityHandler),this.focusHandler=()=>void this.check(),window.addEventListener("focus",this.focusHandler),this.messageHandler=e=>this.handleMessage(e),window.addEventListener("message",this.messageHandler),this.timeoutTimer=setTimeout(()=>{this.stopped||(this.stop(),this.opts.onTimeout())},this.opts.timeoutMs))}stop(){this.stopped=!0,this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.timeoutTimer!==null&&clearTimeout(this.timeoutTimer),this.timeoutTimer=null,typeof document<"u"&&this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),typeof window<"u"&&(this.focusHandler&&window.removeEventListener("focus",this.focusHandler),this.messageHandler&&window.removeEventListener("message",this.messageHandler)),this.visibilityHandler=null,this.focusHandler=null,this.messageHandler=null}async check(){if(!(this.stopped||this.checking)){this.checking=!0;try{const e=await this.opts.client.getUser({force:!0});if(this.stopped)return;e.has_active_subscription&&(this.stop(),this.opts.onActive(e))}catch{}finally{this.checking=!1}}}scheduleNext(){if(this.stopped)return;const t=typeof document<"u"&&document.visibilityState==="visible"?this.opts.visibleIntervalMs:this.opts.hiddenIntervalMs;this.timer=setTimeout(async()=>{await this.check(),this.scheduleNext()},t)}handleVisibilityChange(){typeof document>"u"||(document.visibilityState==="visible"&&this.check(),this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.scheduleNext())}handleMessage(e){const t=e.data;!t||typeof t!="object"||t.type==="paywall_purchase"&&this.check()}}function nr(){return!(typeof document>"u"||typeof window>"u"||typeof location<"u"&&location.protocol==="chrome-extension:")}const re={open:!1,view:null,error:null,processing:!1},N={status:"paywall_status",priceId:"paywall_price_id",sessionId:"paywall_session_id"};let sr=class{constructor(e){this.handle=null,this.isOpen=!1,this.listeners=new Map,this.userUnsub=null,this.authUnsub=null,this.watcher=null,this.tracker=null,this.purchased=!1,this.trialStore=null,this.trialStoreConfig=null,this.lastTrialStatus=null,this.trialExpiredFired=!1,this.lastVisibility=null,this.currentState=re,this.stateListeners=new Set;const{auth:t,ownsAuth:s}=ir(e);this.auth=t,this.ownsAuth=s,this.billing=e.client??new v.BillingClient({...e,auth:this.auth}),this.host=e.host,this.shadowMode=e.shadowMode??"closed",this.mountThenLoad=e.mountThenLoad??!0,this.inline=e.inline===!0,this.forceLocale=e.locale??null,this.userUnsub=this.billing.onUserChange(i=>{this.emit("userChange",i)}),this.auth&&(this.authUnsub=this.auth.onAuthChange((i,o)=>{this.emit("authChange",{event:i,session:o})})),this.initTracker(e.analytics),e.autoDetectReturn!==!1&&typeof window<"u"&&queueMicrotask(()=>this.checkReturn())}initTracker(e){if(e===!1)return;const t=typeof e=="object"&&e!==null?e:{};if(t.enabled===!1)return;const s=t.endpoint??`${this.billing.apiOrigin}/api/v1/paywall/${this.billing.paywallId}/events`;this.tracker=new v.EventTracker({endpoint:s,paywallId:this.billing.paywallId,capabilities:this.billing.capabilities,getVisitorId:()=>this.billing.getVisitorId(),getCachedVisitorId:()=>this.billing.getCachedVisitorId(),getUserId:()=>this.billing.getIdentity()?.userId??null,flushIntervalMs:t.flushIntervalMs,maxBufferSize:t.maxBufferSize,fetch:t.fetch,sendBeacon:t.sendBeacon}),this.on("open",()=>this.tracker?.track("paywall_opened")),this.on("ready",i=>this.tracker?.track("paywall_viewed",{is_test_mode:i.settings.is_test_mode,prices_count:i.prices.length,offers_count:i.offers.length})),this.on("price_selected",i=>this.tracker?.track("price_selected",{price_id:i.priceId})),this.on("checkout_started",i=>this.tracker?.track("checkout_started",{price_id:i.priceId,acquiring:i.acquiring})),this.on("purchase_completed",i=>this.tracker?.track("purchase_completed",{price_id:i.priceId,session_id:i.sessionId})),this.on("purchase_failed",i=>this.tracker?.track("purchase_failed",{reason:i.reason})),this.on("close",()=>this.tracker?.track("paywall_closed")),this.on("trial_blocked",i=>this.tracker?.track("trial_blocked",{mode:i.mode,...i.mode==="time"?{remaining_ms:i.remainingMs,total_ms:i.totalMs}:i.mode==="opens"?{remaining_actions:i.remainingActions,total_actions:i.totalActions}:{}})),this.on("trial_expired",()=>this.tracker?.track("trial_expired")),this.on("visibility_blocked",i=>this.tracker?.track("visibility_blocked",{reason:i.reason,country:i.country,tier:i.tier})),this.on("error",i=>this.tracker?.track("error",{code:i.code,message:i.message}))}track(e,t){this.tracker?.track(e,t)}onUserChange(e){return this.on("userChange",e)}setBootstrap(e){this.billing.setBootstrap(e)}setLocale(e){const t=e??null;t!==this.forceLocale&&(this.forceLocale=t,this.handle&&this.handle.update({locale:t}))}on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>s.delete(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(!s)return;const i=t[0];for(const o of s)try{o(i)}catch(a){typeof console<"u"&&console.error("[paywall] listener error",a)}}open(e={}){this.openInternal("layout",e)}async preload(e={}){try{await this.billing.bootstrap({signal:e.signal}),this.billing.auth&&await this.billing.getBalances({signal:e.signal})}catch{}}openSupport(e={}){this.openInternal("support",e)}openAuth(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0})}openSignin(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0,authMode:"signin"})}openSignup(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0,authMode:"signup"})}checkout(e,t={}){if(t.identity&&this.billing.setIdentity(t.identity),t.renew!==!0&&this.billing.getCachedUser()?.has_active_subscription){this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0});return}this.runDirectCheckout(e,t)}async runDirectCheckout(e,t){const s=t.renew===!0,i=t.skipTrial===!0,o=t.skipVisibility===!0;this.applyProcessing(!0);const a=()=>{this.applyProcessing(!1)};let c;try{c=await this.billing.bootstrap()}catch(x){const I=x instanceof v.PaywallError?x:new v.PaywallError("unknown","Failed to load paywall",{cause:x});this.emit("error",I),a();return}if(!o){const x=c.settings.visibility;if(x&&(this.lastVisibility=x,!x.visible)){this.emit("visibility_blocked",x),a();return}}if(!i&&await this.checkTrialBeforeCheckout(c)){a();return}if(!s&&c.user?.has_active_subscription){this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0}),a();return}const l=c.settings.checkout_mode??"guest",h=this.auth?.getCachedSession()??null,u=!!h&&!h.user.is_anonymous;if(l==="preauth"&&!!this.auth&&!u){this.purchased=!1,this.mountAndShow("auth",{renew:s,authMode:"signin",checkoutPriceId:e});return}const _=this.getOfferForPrice(e);let p;try{p=await this.billing.createCheckout({priceId:e,offerId:_?.offer.id,ignoreActivePurchase:s})}catch(x){if(x instanceof v.PaywallError&&x.code==="already_purchased"){try{await this.billing.getUser({force:!0})}catch{}this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0}),a();return}const I=x instanceof v.PaywallError?x:new v.PaywallError("checkout_failed","Checkout failed",{cause:x});this.emit("error",I),a();return}if(this.emit("checkout_started",{priceId:e,url:p.url,acquiring:p.acquiring}),this.startUserWatcher(),typeof window>"u"||!p.url){this.mountAndShow("awaiting_payment",{renew:s,checkoutPriceId:e,checkoutUrl:p.url});return}const k=window.open(p.url,"_blank");if(this.purchased=!1,k){try{k.opener=null}catch{}this.mountAndShow("awaiting_payment",{renew:s,checkoutPriceId:e,checkoutUrl:p.url})}else this.mountAndShow("popup_blocked",{renew:s,checkoutPriceId:e,checkoutUrl:p.url})}async checkTrialBeforeCheckout(e){const t=e.settings.trial;if(!t)return!1;const s=this.ensureTrialStore(t);try{const i=await s.check();if(this.lastTrialStatus=i,i.mode==="none")return!1;if(i.blocked){const o=await s.recordBlock();return this.lastTrialStatus=o,this.emit("trial_blocked",o),!0}return this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired")),!1}catch(i){return typeof console<"u"&&console.warn("[paywall] trial check failed",i),!1}}applyProcessing(e){this.currentState.processing!==e&&this.applyState({...this.currentState,processing:e})}signInAnonymously(){return this.auth?this.auth.signInAnonymously():Promise.reject(new v.PaywallError("invalid_config","signInAnonymously requires managed-auth. Pass `auth: true` to PaywallUI."))}openInternal(e,t){t.identity&&this.billing.setIdentity(t.identity),this.purchased=!1;const s=t.skipTrial===!0||e==="support",i=t.skipVisibility===!0||e==="support"||e==="auth",o=t.renew===!0;if(s&&i){this.mountAndShow(e,{renew:o,authMode:t.authMode});return}const a=this.billing.getCachedBootstrap();if(a){this.runOpenGates(e,a,{skipTrial:s,skipVisibility:i,renew:o});return}if(this.mountThenLoad){this.mountAndShow(e,{renew:o}),this.billing.bootstrap().then(c=>this.runDelayedGates(c,{skipTrial:s,skipVisibility:i})).catch(()=>{});return}this.billing.bootstrap().then(c=>this.runOpenGates(e,c,{skipTrial:s,skipVisibility:i,renew:o})).catch(()=>{this.mountAndShow(e,{renew:o})})}runDelayedGates(e,t){if(!this.isOpen)return;if(!t.skipVisibility){const o=e.settings.visibility;if(o&&(this.lastVisibility=o,!o.visible)){this.close(),this.emit("visibility_blocked",o);return}}if(t.skipTrial)return;const s=e.settings.trial;if(!s)return;const i=this.ensureTrialStore(s);i.check().then(async o=>{if(this.isOpen&&(this.lastTrialStatus=o,o.mode!=="none")){if(o.blocked){const a=await i.recordBlock();if(this.lastTrialStatus=a,!this.isOpen)return;this.close(),this.emit("trial_blocked",a);return}this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired"))}}).catch(o=>{typeof console<"u"&&console.warn("[paywall] trial check failed",o)})}runOpenGates(e,t,s){if(!s.skipVisibility){const i=t.settings.visibility;if(i&&(this.lastVisibility=i,!i.visible)){this.emit("visibility_blocked",i);return}}if(s.skipTrial){this.mountAndShow(e,{renew:s.renew});return}this.gateThroughTrial(e,t,s.renew)}gateThroughTrial(e,t,s){const i=t.settings.trial;if(!i){this.mountAndShow(e,{renew:s});return}const o=this.ensureTrialStore(i);o.check().then(async a=>{if(this.lastTrialStatus=a,a.mode==="none"){this.mountAndShow(e,{renew:s});return}if(a.blocked){const c=await o.recordBlock();this.lastTrialStatus=c,this.emit("trial_blocked",c);return}this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired")),this.mountAndShow(e,{renew:s})}).catch(a=>{typeof console<"u"&&console.warn("[paywall] trial check failed",a),this.mountAndShow(e,{renew:s})})}ensureTrialStore(e){if(this.trialStore&&this.trialStoreConfig&&lr(this.trialStoreConfig,e))return this.trialStore;this.trialStoreConfig=e;const t=this.billing.createTrialStore;return this.trialStore=typeof t=="function"?t.call(this.billing,e):v.createTrialStore(this.billing.getStorage(),this.billing.paywallId,e),this.trialStore}mountAndShow(e,t={}){const s=t.renew===!0,i=t.authMode,a=e==="auth"||e==="awaiting_payment"||e==="popup_blocked"?t.checkoutPriceId??null:null,c=e==="awaiting_payment"||e==="popup_blocked"?t.checkoutUrl??null:null;if(this.handle){this.isOpen=!0,this.handle.update({open:!0,initialView:e,initialAuthMode:i,initialCheckoutPriceId:a,initialCheckoutUrl:c,purchased:!1,renew:s}),this.emit("open");return}this.isOpen=!0,this.handle=Fe(Zt,{client:this.billing,open:!0,initialView:e,initialAuthMode:i,initialCheckoutPriceId:a,initialCheckoutUrl:c,purchased:!1,renew:s,onClose:()=>this.close(),onEvent:(l,h)=>{this.emit(l,h),l==="checkout_started"&&this.startUserWatcher()},onState:l=>this.applyState(l),inline:this.inline,locale:this.forceLocale},{host:this.host,shadowMode:this.shadowMode,inline:this.inline}),this.emit("open")}applyState(e){if(!ar(this.currentState,e)){this.currentState=e;for(const t of this.stateListeners)try{t(e)}catch(s){console.warn("[paywall] onStateChange listener threw",s)}}}getState(){return this.currentState}onStateChange(e,t={}){this.stateListeners.add(e);const s=t.immediate??"microtask";if(s!=="none"){const i=this.currentState;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onStateChange initial sync threw",o)}else queueMicrotask(()=>{this.stateListeners.has(e)&&e(i)})}return()=>{this.stateListeners.delete(e)}}getTrialStatus(){return this.lastTrialStatus}getVisibility(){return this.lastVisibility}getPrices(e={}){return this.billing.getPrices(e)}getCachedPrices(){return this.billing.getCachedPrices()}getCachedOffers(){return this.billing.getCachedOffers()}getOfferForPrice(e){const t=this.billing.getCachedOffers();if(!t)return null;const s=D(t,e);return s?Re(s,{now:Date.now(),readStart:Ne}):null}getUserLanguage(){return this.billing.getUserLanguage()}async getAccess(e={}){let t=this.billing.getCachedBootstrap();if(!t)try{t=await this.billing.bootstrap({signal:e.signal})}catch{const a=this.billing.getCachedUser();return a?.has_active_subscription?{access:"granted",reason:"has_subscription",visibility:null,trial:null,user:a}:{access:"blocked",reason:"no_subscription",visibility:null,trial:null,user:a}}const s=this.billing.getCachedUser()??t.user??null;if(s?.has_active_subscription)return{access:"granted",reason:"has_subscription",visibility:t.settings.visibility??null,trial:null,user:s};let i=null;if(!e.skipVisibility){const a=t.settings.visibility;if(a&&(i=a,this.lastVisibility=a,!a.visible))return{access:"granted",reason:"visibility_blocked",visibility:i,trial:null,user:s}}let o=null;if(!e.skipTrial){const a=t.settings.trial;if(a)try{if(o=await this.ensureTrialStore(a).check(),this.lastTrialStatus=o,o.blocked)return{access:"granted",reason:"trial_blocked",visibility:i,trial:o,user:s}}catch(c){typeof console<"u"&&console.warn("[paywall] getAccess: trial check failed",c)}}return{access:"blocked",reason:"no_subscription",visibility:i,trial:o,user:s}}async resetTrial(){this.trialStore&&(await this.trialStore.reset(),this.lastTrialStatus=null,this.trialExpiredFired=!1)}startUserWatcher(){this.watcher||nr()&&(this.watcher=new rr({client:this.billing,onActive:e=>{this.watcher=null,this.emit("purchase_completed",{priceId:null,sessionId:null});const t=this.billing.getCachedBootstrap()?.settings.success_redirect_url;if(t&&typeof window<"u")try{window.location.assign(t);return}catch{}this.isOpen&&this.handle&&(this.purchased=!0,this.handle.update({purchased:!0}))},onTimeout:()=>{this.watcher=null}}),this.watcher.start())}close(){!this.isOpen||!this.handle||(this.isOpen=!1,this.purchased=!1,this.handle.update({open:!1,purchased:!1}),this.applyState(re),this.emit("close"))}checkReturn(){if(typeof window>"u")return;const e=new URL(window.location.href),t=xe(e.hash.replace(/^#/,"")),s=xe(e.search.replace(/^\?/,"")),i=t??s;i&&(i.status==="paid"?(this.emit("purchase_completed",{priceId:i.priceId,sessionId:i.sessionId}),cr(i)):(i.status==="failed"||i.status==="cancelled")&&this.emit("purchase_failed",{reason:i.status}),ur(e))}destroy(){this.tracker?.destroy(),this.tracker=null,this.listeners.clear(),this.stateListeners.clear(),this.watcher?.stop(),this.watcher=null,this.userUnsub?.(),this.userUnsub=null,this.authUnsub?.(),this.authUnsub=null,this.ownsAuth&&this.auth&&this.auth.destroy?.(),this.ownsAuth=!1,this.billing.destroy?.(),this.handle?.unmount(),this.handle=null,this.isOpen=!1,this.currentState=re}};function ir(r){if(!r.auth)return{auth:void 0,ownsAuth:!1};if(r.auth instanceof v.AuthClient||or(r.auth))return{auth:r.auth,ownsAuth:!1};const e=r.auth===!0?{}:r.auth;return{auth:new v.AuthClient({paywallId:r.paywallId,apiOrigin:e.apiOrigin??r.apiOrigin,storage:e.storage??r.storage,fetch:e.fetch??r.fetch,openPopup:e.openPopup}),ownsAuth:!0}}function or(r){if(typeof r!="object"||r===null)return!1;const e=r;return typeof e.onAuthChange=="function"&&typeof e.getCachedSession=="function"&&typeof e.signOut=="function"}function ar(r,e){return r.open===e.open&&r.view===e.view&&r.error===e.error&&r.processing===e.processing}function lr(r,e){return r.mode===e.mode&&r.payload===e.payload&&r.storage===e.storage}function xe(r){if(!r)return null;const e=new URLSearchParams(r),t=e.get(N.status);return t?{status:t,priceId:e.get(N.priceId),sessionId:e.get(N.sessionId)}:null}function cr(r){if(!(typeof window>"u"||!window.opener))try{window.opener.postMessage({type:"paywall_purchase",status:r.status,priceId:r.priceId,sessionId:r.sessionId},"*")}catch{}}function ur(r){const e=(s,i)=>{if(!s)return"";const o=new URLSearchParams(s.replace(/^[?#]/,""));o.delete(N.status),o.delete(N.priceId),o.delete(N.sessionId);const a=o.toString();return a?i+a:""},t=r.pathname+e(r.search,"?")+e(r.hash,"#");window.history.replaceState(null,"",t)}class dr{constructor(e,t,s){this.transport=e,this.paywallId=t,this.config=s}async check(){return this.transport.request("trial.check",{paywallId:this.paywallId,config:this.config})}async recordBlock(){return this.transport.request("trial.recordBlock",{paywallId:this.paywallId,config:this.config})}async reset(){await this.transport.request("trial.reset",{paywallId:this.paywallId,config:this.config})}}class Ae{constructor(e,t){this.transport=e,this.cachedBootstrap=null,this.cachedUser=null,this.cachedBalances=null,this.identity=null,this.userListeners=new Set,this.balanceListeners=new Set,this.bootstrapListeners=new Set,this.unsubUserBroadcast=null,this.unsubBalancesBroadcast=null,this.paywallId=t.paywallId,this.apiOrigin=t.apiOrigin,this.remoteStorageAdapter={getItem:s=>this.transport.request("storage.get",{key:s}),setItem:async(s,i)=>{await this.transport.request("storage.set",{key:s,value:i})},removeItem:async s=>{await this.transport.request("storage.remove",{key:s})}},this.unsubUserBroadcast=this.transport.on("userChange",s=>{this.applyUser(s)}),this.unsubBalancesBroadcast=this.transport.on("balancesChange",s=>{this.applyBalances([...s])})}async bootstrap(e={}){const t=await this.transport.request("billing.bootstrap",{force:e.force},{signal:e.signal});return this.applyBootstrap(t),t.user&&this.applyUser(t.user),t}getCachedBootstrap(){return this.cachedBootstrap}onBootstrapChange(e,t={}){this.bootstrapListeners.add(e);const s=t.immediate??"microtask";if(this.cachedBootstrap&&s!=="none"){const i=this.cachedBootstrap;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onBootstrapChange initial sync threw",o)}else queueMicrotask(()=>{this.bootstrapListeners.has(e)&&e(i)})}return()=>{this.bootstrapListeners.delete(e)}}async getPrices(e={}){return(await this.bootstrap(e)).prices}getCachedPrices(){return this.cachedBootstrap?.prices??null}getCachedOffers(){return this.cachedBootstrap?.offers??null}async getVisitorId(){return this.transport.request("billing.getVisitorId",void 0)}async getUser(e={}){const t=await this.transport.request("billing.getUser",{force:e.force},{signal:e.signal});return this.applyUser(t),t}getCachedUser(){return this.cachedUser}onUserChange(e,t={}){this.userListeners.add(e);const s=t.immediate??"microtask";if(this.cachedUser&&s!=="none"){const i=this.cachedUser;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onUserChange initial sync threw",o)}else queueMicrotask(()=>{this.userListeners.has(e)&&e(i)})}return()=>{this.userListeners.delete(e)}}async getBalances(e={}){const s=[...await this.transport.request("billing.getBalances",{force:e.force},{signal:e.signal})];return this.applyBalances(s),s}getCachedBalances(){return this.cachedBalances}onBalanceChange(e,t={}){this.balanceListeners.add(e);const s=t.immediate??"microtask";if(this.cachedBalances&&s!=="none"){const i=this.cachedBalances;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onBalanceChange initial sync threw",o)}else queueMicrotask(()=>{this.balanceListeners.has(e)&&e(i)})}return()=>{this.balanceListeners.delete(e)}}async createCheckout(e){const{signal:t,...s}=e;return this.transport.request("billing.createCheckout",s,{signal:t})}async listPurchases(e={}){return[...await this.transport.request("billing.listPurchases",void 0,{signal:e.signal})]}async createSupportTicket(e){return this.transport.request("billing.createSupportTicket",e)}async cancelSubscription(e){const{signal:t,...s}=e;return this.transport.request("billing.cancelSubscription",s,{signal:t})}getStorage(){return this.remoteStorageAdapter}createTrialStore(e){return new dr(this.transport,this.paywallId,e)}getIdentity(){return this.identity}async setIdentity(e){this.identity=e,await this.transport.request("billing.setIdentity",{identity:e})}async syncIdentity(){const e=await this.transport.request("billing.getIdentity",void 0);return this.identity=e,e}destroy(){this.unsubUserBroadcast?.(),this.unsubBalancesBroadcast?.(),this.unsubUserBroadcast=null,this.unsubBalancesBroadcast=null,this.userListeners.clear(),this.balanceListeners.clear(),this.bootstrapListeners.clear(),this.cachedBootstrap=null,this.cachedUser=null,this.cachedBalances=null,this.identity=null}applyBootstrap(e){this.cachedBootstrap=e;for(const t of[...this.bootstrapListeners])try{t(e)}catch(s){console.warn("[paywall] onBootstrapChange listener threw",s)}}applyUser(e){hr(this.cachedUser,e)||(this.cachedUser=e,this.fireUserListeners(e))}applyBalances(e){pr(this.cachedBalances,e)||(this.cachedBalances=e,this.fireBalanceListeners(e))}fireUserListeners(e){for(const t of[...this.userListeners])try{t(e)}catch(s){console.warn("[paywall] onUserChange listener threw",s)}}fireBalanceListeners(e){for(const t of[...this.balanceListeners])try{t(e)}catch(s){console.warn("[paywall] onBalanceChange listener threw",s)}}}function hr(r,e){return r===e?!0:!r||!e?!1:r.has_active_subscription===e.has_active_subscription&&(r.purchases?.length??0)===(e.purchases?.length??0)}function pr(r,e){if(r===e)return!0;if(!r||!e||r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t].type!==e[t].type||r[t].count!==e[t].count)return!1;return!0}class Le{constructor(e,t){this.transport=e,this.session=null,this.listeners=new Set,this.unsubBroadcast=null,this.paywallId=t.paywallId,this.apiOrigin=t.apiOrigin,this.unsubBroadcast=this.transport.on("authChange",({event:s,session:i})=>{this.applySession(s,i)}),this.hydrated=this.transport.request("auth.getCachedSession",void 0).then(s=>{this.session===null&&s!==null&&(this.session=s)}).catch(()=>{})}ready(){return this.hydrated}getCachedSession(){return this.session}getCachedUser(){return this.session?.user??null}onAuthChange(e){return this.listeners.add(e),this.hydrated.then(()=>{if(this.listeners.has(e))try{e("INITIAL_SESSION",this.session)}catch(t){console.warn("[paywall] onAuthChange INITIAL_SESSION threw",t)}}),()=>{this.listeners.delete(e)}}async signInWithEmail(e){const t=await this.transport.request("auth.signInWithEmail",e);return this.applySession("SIGNED_IN",t),t}async signUp(e){const t=await this.transport.request("auth.signUp",e);return t.kind==="signed_in"&&this.applySession("SIGNED_IN",t.session),t}async signOut(){await this.transport.request("auth.signOut",void 0)}async refresh(){const e=await this.transport.request("auth.refresh",void 0);return this.applySession(e?"TOKEN_REFRESHED":"SIGNED_OUT",e),e}async sendOtp(e){await this.transport.request("auth.sendOtp",e)}async verifyOtp(e){const t=await this.transport.request("auth.verifyOtp",e);return this.applySession(e.type==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",t),t}async resendConfirmation(e){await this.transport.request("auth.resendConfirmation",e)}async requestPasswordReset(e){await this.transport.request("auth.requestPasswordReset",e)}async updatePassword(e){await this.transport.request("auth.updatePassword",e)}async revokeAllSessions(){await this.transport.request("auth.revokeAllSessions",void 0)}async getLastLogin(){return this.transport.request("auth.getLastLogin",void 0)}async signInAnonymously(e={}){const t=await this.transport.request("auth.signInAnonymously",{captchaToken:e.captchaToken,userMeta:e.userMeta,forceNewAnon:e.forceNewAnon});return this.applySession("SIGNED_IN",t),t}async getAccessToken(){return this.transport.request("auth.getAccessToken",void 0)}async signInWithOAuth(e){if(typeof window>"u")throw new v.PaywallError("oauth_unavailable","window is required for OAuth");const t=`pw-oauth-pending-${Math.random().toString(36).slice(2,10)}`,s=window.open("about:blank",t,"width=480,height=640,popup=yes");if(!s)throw new v.PaywallError("popup_blocked","browser blocked auth popup — call from a user gesture");xr(s,e.provider);try{const{authorizeUrl:i,state:o}=await this.transport.request("auth.oauthStart",{provider:e.provider,scopes:e.scopes,userMeta:e.userMeta});s.name=`pw-oauth-${o}`,s.location.replace(i),e.onPopupOpened?.();const a=await v.waitForOAuthCode(s,o),c=await this.transport.request("auth.oauthExchange",{state:o,code:a});return this.applySession("SIGNED_IN",c),c}catch(i){try{s.close()}catch{}throw i}}destroy(){this.unsubBroadcast?.(),this.unsubBroadcast=null,this.listeners.clear(),this.session=null}applySession(e,t){if(!fr(this.session,t)){this.session=t;for(const s of[...this.listeners])try{s(e,t)}catch(i){console.warn("[paywall] onAuthChange listener threw",i)}}}}function fr(r,e){return r===e?!0:!r||!e?!1:r.access_token===e.access_token&&r.refresh_token===e.refresh_token&&r.expires_at===e.expires_at&&r.user.id===e.user.id}const gr={google:"Google",apple:"Apple",github:"GitHub",facebook:"Facebook"};function xr(r,e){const t=gr[e]??e;try{const s=r.document;s.title=`Sign in with ${t}`;const i=s.createElement("style");i.textContent="html,body{margin:0;padding:0;height:100%;font-family:-apple-system,system-ui,sans-serif;background:#fafafa;color:#475569}.pw-oauth-wrap{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:16px}.pw-oauth-spinner{width:36px;height:36px;border:3px solid #e2e8f0;border-top-color:#7c3aed;border-radius:50%;animation:pw-oauth-spin 800ms linear infinite}.pw-oauth-label{font-size:14px;font-weight:500;letter-spacing:-0.01em}@keyframes pw-oauth-spin{to{transform:rotate(360deg)}}",s.head.appendChild(i);const o=s.createElement("div");o.className="pw-oauth-wrap";const a=s.createElement("div");a.className="pw-oauth-spinner";const c=s.createElement("div");c.className="pw-oauth-label",c.textContent=`Connecting to ${t}…`,o.appendChild(a),o.appendChild(c),s.body.appendChild(o)}catch{}}class Te{constructor(e){this.transport=e}track(e,t){typeof e!="string"||e.length===0||this.transport.request("tracker.track",{name:e,props:t}).catch(s=>{console.warn("[paywall] track failed",s)})}}class mr{constructor(e){this.factory=e,this.channel=null,this.channelDisposers=[],this.pending=new Map,this.listeners=new Map,this.destroyed=!1,this.nextId=0,this.clientId=`c-${Math.random().toString(36).slice(2,10)}`}ensureChannel(){if(this.destroyed)throw new Error("TransportClient destroyed");if(this.channel)return this.channel;const e=this.factory();this.channel=e;const t=e.onMessage(i=>this.handleMessage(i)),s=e.onDisconnect(()=>this.handleDisconnect());return this.channelDisposers=[t,s],this.request("handshake",{protocolVersion:v.PROTOCOL_VERSION,clientId:this.clientId}).then(i=>{i.protocolVersion!==v.PROTOCOL_VERSION&&console.warn(`[sdk-extension] protocol version mismatch: client=${v.PROTOCOL_VERSION}, offscreen=${i.protocolVersion}. Update host's @monetize.software/sdk-extension.`)}).catch(()=>{}),e}handleMessage(e){if(br(e)){if(e.type==="response"){const t=this.pending.get(e.id);if(!t)return;this.pending.delete(e.id),t.signal?.removeEventListener("abort",t.abortListener),e.ok?t.resolve(e.result):t.reject(v.reconstructError(e.error));return}if(e.type==="event"){const t=this.listeners.get(e.kind);if(!t)return;for(const s of[...t])try{s(e.payload)}catch(i){console.error("[sdk-extension] event handler threw",i)}}}}handleDisconnect(){for(const t of this.channelDisposers)t();this.channelDisposers=[],this.channel=null;const e=Array.from(this.pending.values());this.pending.clear();for(const t of e)t.signal?.removeEventListener("abort",t.abortListener),t.reject(new yr)}request(e,t,s={}){if(this.destroyed)return Promise.reject(new Error("TransportClient destroyed"));if(s.signal?.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));const i=this.ensureChannel(),o=`r${++this.nextId}`;return new Promise((a,c)=>{const l={resolve:a,reject:c,signal:s.signal};s.signal&&(l.abortListener=()=>{if(this.pending.delete(o)){c(new DOMException("Aborted","AbortError"));try{i.send({type:"cancel",id:o})}catch{}}},s.signal.addEventListener("abort",l.abortListener)),this.pending.set(o,l);const h={type:"request",id:o,kind:e,params:t};try{i.send(h)}catch(u){this.pending.delete(o),s.signal?.removeEventListener("abort",l.abortListener),c(u)}})}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s));const i=t;return s.add(i),this.ensureChannel(),()=>{s.delete(i)}}destroy(){if(this.destroyed)return;this.destroyed=!0;for(const t of this.channelDisposers)t();this.channelDisposers=[],this.listeners.clear();const e=Array.from(this.pending.values());this.pending.clear();for(const t of e)t.signal?.removeEventListener("abort",t.abortListener),t.reject(new Error("TransportClient destroyed"));this.channel?.close(),this.channel=null}}class yr extends Error{constructor(){super("Transport channel disconnected mid-request"),this.code="transport_disconnected",this.name="TransportDisconnectedError"}}function br(r){if(typeof r!="object"||r===null)return!1;const e=r.type;return e==="request"||e==="response"||e==="event"}let H=null;function Me(){return H||(H=new mr(()=>v.createRuntimeChannel(Oe.PORT_NAME)),H)}class wr extends sr{constructor(e){const t=Me(),s=new Ae(t,{paywallId:e.paywallId,apiOrigin:e.apiOrigin});let i;e.auth===!0?i=new Le(t,{paywallId:e.paywallId,apiOrigin:e.apiOrigin}):e.auth&&console.warn("[sdk-extension] passing AuthClient instance to PaywallUI.opts.auth is not supported in extension mode — pass `auth: true` to use offscreen-shared auth, or omit for hybrid identity-only mode."),i&&(s.auth=i),super({...e,client:s,auth:i,analytics:!1}),this.remoteTracker=null,this.trackerUnsubs=[],e.analytics!==!1&&(this.remoteTracker=new Te(t),this.bindAnalytics())}bindAnalytics(){const e=this.remoteTracker;e&&this.trackerUnsubs.push(this.on("open",()=>e.track("paywall_opened")),this.on("ready",t=>e.track("paywall_viewed",{is_test_mode:t.settings.is_test_mode,prices_count:t.prices.length,offers_count:t.offers.length})),this.on("price_selected",t=>e.track("price_selected",{price_id:t.priceId})),this.on("checkout_started",t=>e.track("checkout_started",{price_id:t.priceId,acquiring:t.acquiring})),this.on("purchase_completed",t=>e.track("purchase_completed",{price_id:t.priceId,session_id:t.sessionId})),this.on("purchase_failed",t=>e.track("purchase_failed",{reason:t.reason})),this.on("close",()=>e.track("paywall_closed")),this.on("trial_blocked",t=>e.track("trial_blocked",{mode:t.mode,...t.mode==="time"?{remaining_ms:t.remainingMs,total_ms:t.totalMs}:t.mode==="opens"?{remaining_actions:t.remainingActions,total_actions:t.totalActions}:{}})),this.on("trial_expired",()=>e.track("trial_expired")),this.on("visibility_blocked",t=>e.track("visibility_blocked",{reason:t.reason,country:t.country,tier:t.tier})),this.on("error",t=>e.track("error",{code:t.code,message:t.message})))}track(e,t){this.remoteTracker?.track(e,t)}destroy(){for(const e of this.trackerUnsubs)e();this.trackerUnsubs=[],this.remoteTracker=null,super.destroy()}}exports.PROTOCOL_VERSION=v.PROTOCOL_VERSION;exports.PaywallUI=wr;exports.RemoteAuthClient=Le;exports.RemoteBillingClient=Ae;exports.RemoteEventTracker=Te;exports.getContentTransport=Me;
|
|
25
|
+
`})]})}function Ke(r,e){switch(r){case"google":return e("auth.continue_with_google","Continue with Google");case"apple":return e("auth.continue_with_apple","Continue with Apple");case"github":return e("auth.continue_with_github","Continue with GitHub");case"facebook":return e("auth.continue_with_facebook","Continue with Facebook")}}function ae(r,e,t){const s=e==="signup"?t("auth.signup_failed","Sign-up failed"):t("auth.signin_failed","Sign-in failed");if(!(r instanceof v.PaywallError))return s;switch(r.code){case"invalid_credentials":return t("auth.invalid_credentials","Invalid email or password");case"email_not_confirmed":return t("auth.email_not_confirmed","Please confirm your email before signing in.");case"email_exists":case"user_already_exists":return t("auth.email_exists","An account with this email already exists.");case"weak_password":return t("auth.weak_password","Password is too weak.");case"invalid_otp":case"otp_expired":case"token_expired":return t("auth.invalid_otp","The code is invalid or has expired.");case"over_email_send_rate_limit":case"over_request_rate_limit":case"rate_limited":case"http_429":return t("auth.rate_limited","Too many requests. Please try again later.");case"network_error":return t("auth.network_error","Network error. Please check your connection and try again.");case"upstream":case"upstream_error":case"http_502":case"http_503":case"http_504":return t("auth.service_unavailable","Service is temporarily unavailable. Please try again.");default:return s}}function ve({block:r,ctx:e}){const t=e.auth,s=e.authSession,i=r.allow_signup!==!1,o=r.allow_password_reset!==!1,a=r.hide_when_authenticated!==!1;if(!t)return typeof console<"u"&&console.warn("[paywall] auth_panel rendered without AuthClient — pass `auth: true` to PaywallUI"),null;const l=s&&!s.user.is_anonymous?s:null;return l&&a?null:l?n.jsx(Xe,{email:l.user.email??"",onSignOut:()=>t.signOut().catch(()=>{})}):n.jsx(Je,{block:r,allowSignup:i,allowReset:o,ctx:e})}function Xe({email:r,onSignOut:e}){const{t}=j();return n.jsxs("div",{class:"flex items-center justify-between gap-3 rounded-2xl bg-gray-100 px-4 py-3",children:[n.jsxs("div",{class:"flex flex-col",children:[n.jsx("span",{class:"text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:t("auth.signed_in","Signed in")}),n.jsx("span",{class:"text-sm font-medium text-gray-900",children:r})]}),n.jsx("button",{type:"button",onClick:e,class:"rounded-md px-1.5 py-0.5 text-xs font-medium text-gray-600 transition-colors hover:bg-white hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t("auth.sign_out","Sign out")})]})}function Je({block:r,allowSignup:e,allowReset:t,ctx:s}){const{t:i}=j(),o=s.auth,a=r.providers??[],l=s.initialAuthMode==="signup"&&e?"signup":"signin",[c,h]=d.useState(l),[u,g]=d.useState(""),[_,p]=d.useState(""),[k,x]=d.useState(""),[I,y]=d.useState(""),[m,S]=d.useState(null),C=d.useRef(!1),[T,P]=d.useState(null),[B,O]=d.useState(null),[q,A]=d.useState(!1),[E,R]=d.useState(null);d.useEffect(()=>{if(typeof o.getLastLogin!="function")return;let f=!1;return o.getLastLogin().then(w=>{f||!w||(R(w),w.email&&g(L=>L===""?w.email:L))},()=>{}),()=>{f=!0}},[o]);const M=f=>{h(f),P(null),O(null),A(!1)},W=async f=>{if(f.preventDefault(),!(C.current||m)){C.current=!0;try{if(P(null),O(null),c==="signup"&&!q){if(!u.trim())return;A(!0);return}if(c==="signup"&&_!==k){P(i("auth.passwords_mismatch","Passwords don't match"));return}S("email");try{c==="signin"?await o.signInWithEmail({email:u,password:_}):c==="signup"?(await o.signUp({email:u,password:_})).kind==="confirmation_required"&&(p(""),h("signup_verify"),O(i("auth.check_email_message","Check your email for a confirmation code."))):c==="forgot"?(await o.requestPasswordReset({email:u}),h("reset_sent")):c==="signup_verify"?await o.verifyOtp({email:u,token:I,type:"email"}):c==="reset_verify"&&(await o.verifyOtp({email:u,token:I,type:_?"recovery":"email"}),_&&await o.updatePassword({password:_}))}catch(w){P(ae(w,c==="signup"?"signup":c==="signup_verify"||c==="reset_verify"?"otp":c==="forgot"?"reset":"signin",i))}finally{S(null)}}finally{C.current=!1}}},F=async f=>{if(!(C.current||m)){C.current=!0,S(f),P(null),O(null);try{await o.signInWithOAuth({provider:f,onPopupOpened:()=>S(null)})}catch(w){if(w instanceof v.PaywallError&&(w.code==="oauth_cancelled"||w.code==="oauth_timeout"))return;P(ae(w,"signin",i))}finally{C.current=!1,S(null)}}},Z=a.length>0&&(c==="signin"||c==="signup"),Y=c==="signin"||c==="signup"||c==="forgot",b=c==="signin"||c==="signup"&&q;return c==="reset_sent"?n.jsx(ut,{email:u,onBack:()=>M("signin"),t:i}):n.jsxs("div",{class:"flex flex-col gap-5",children:[n.jsx(Qe,{mode:c,customHeading:r.heading,customSubheading:r.subheading}),Z?n.jsxs("div",{class:"flex flex-col gap-2.5",children:[a.map(f=>n.jsxs("div",{class:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>F(f),disabled:m!==null,class:"flex h-12 w-full items-center justify-center gap-2.5 rounded-full border-1 border-gray-200 bg-white px-5 text-base font-medium text-gray-900 transition-all hover:border-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:[m===f?n.jsx("span",{class:"inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"}):n.jsx(ct,{provider:f}),n.jsx("span",{children:Ke(f,i)})]}),E?.method===f?n.jsx(ot,{email:E.email}):null]},f)),n.jsx(lt,{})]}):null,n.jsxs("form",{onSubmit:W,class:"flex flex-col gap-3",children:[Y&&n.jsx(le,{type:"email",placeholder:i("auth.email","Email address"),value:u,onInput:g,autocomplete:"email",required:!0}),b&&n.jsx(J,{placeholder:i("auth.password","Password"),value:_,onInput:p,autocomplete:c==="signin"?"current-password":"new-password",required:!0}),c==="signup"&&q&&n.jsx(J,{placeholder:i("auth.repeat_password","Repeat password"),value:k,onInput:x,autocomplete:"new-password",required:!0}),(c==="signup_verify"||c==="reset_verify")&&n.jsx(le,{type:"text",placeholder:i("auth.confirmation_code","Confirmation code"),value:I,onInput:y,autocomplete:"one-time-code",inputMode:"numeric",required:!0}),c==="reset_verify"&&n.jsx(J,{placeholder:i("auth.new_password_optional","New password (optional — only for password reset)"),value:_,onInput:p,autocomplete:"new-password"}),c==="signin"&&t&&n.jsx("div",{class:"flex justify-end text-sm",children:n.jsx(G,{onClick:()=>M("forgot"),children:i("auth.forgot_password","Forgot password?")})}),T&&n.jsx("p",{class:"text-sm text-red-600",children:T}),B&&n.jsx("p",{class:"text-sm text-gray-500",children:B}),n.jsx(nt,{busy:m==="email",label:tt(c,q,r.submit_label??r.heading,i)})]}),n.jsx(rt,{mode:c,allowSignup:e,onSwitch:M})]})}function Qe({mode:r,customHeading:e,customSubheading:t}){const{t:s}=j(),i=et(r,s),o=r==="signin"||r==="signup",a=o&&e?e:i.title,l=o&&t!==void 0?t||null:i.subtitle;return n.jsxs("div",{class:"flex flex-col gap-2",children:[n.jsx("h2",{class:"text-3xl font-bold tracking-tight text-gray-900",children:a}),l?n.jsx("p",{class:"text-base leading-relaxed text-gray-600",children:l}):null]})}function et(r,e){switch(r){case"signin":return{title:e("auth.welcome","Welcome back!"),subtitle:e("auth.default_subtitle","Sign in to access all features and sync your data.")};case"signup":return{title:e("auth.welcome_signup","Welcome!"),subtitle:e("auth.default_subtitle","Sign in to access all features and sync your data.")};case"forgot":return{title:e("auth.forgot_password_title","Forgot password?"),subtitle:e("auth.forgot_subtitle","Enter your email and we'll send you a password reset link.")};case"reset_sent":return{title:e("auth.check_email_title","Check your email"),subtitle:null};case"reset_verify":return{title:e("auth.reset_password_title","Reset password"),subtitle:e("auth.reset_password_subtitle","Enter the code from your email and a new password.")};case"signup_verify":return{title:e("auth.confirm_email_title","Confirm your email"),subtitle:e("auth.confirm_email_subtitle","Enter the code we sent to your email to finish creating your account.")}}}function tt(r,e,t,s){if(r==="signin"&&t)return t;switch(r){case"signin":return s("auth.log_in","Sign In");case"signup":return e?s("auth.create_account","Create Account"):s("auth.sign_up","Sign Up");case"forgot":return s("auth.send_reset","Send Reset Email");case"signup_verify":case"reset_verify":return s("auth.verify","Verify");default:return s("cta.continue","Continue")}}function rt({mode:r,allowSignup:e,onSwitch:t}){const{t:s}=j();return r==="signin"&&e?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.no_account","Don't have an account?")," ",n.jsx(G,{onClick:()=>t("signup"),children:s("auth.sign_up_link","Sign Up")})]}):r==="signup"||r==="signup_verify"?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.have_account","Already have an account?")," ",n.jsx(G,{onClick:()=>t("signin"),children:s("auth.log_in_link","Log In")})]}):r==="forgot"||r==="reset_sent"||r==="reset_verify"?n.jsxs("p",{class:"text-center text-sm text-gray-600",children:[s("auth.no_account","Don't have an account?")," ",n.jsx(G,{onClick:()=>t("signup"),children:s("auth.sign_up_link","Sign Up")})]}):null}function G({onClick:r,children:e}){return n.jsx("button",{type:"button",onClick:r,class:"font-semibold transition-opacity hover:opacity-80 focus:outline-none focus-visible:opacity-80",style:{color:"var(--pw-accent)"},children:e})}function nt({busy:r,label:e}){return n.jsx("button",{type:"submit",disabled:r,class:"pw-cta-shimmer relative mt-1 flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:r?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:e})})}function le({type:r,placeholder:e,value:t,onInput:s,autocomplete:i,inputMode:o,required:a}){return n.jsx("input",{type:r,value:t,placeholder:e,onInput:l=>s(l.target.value),autocomplete:i,inputMode:o,required:a,class:"h-14 w-full rounded-2xl bg-gray-100 px-5 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"})}function J({placeholder:r,value:e,onInput:t,autocomplete:s,required:i}){const{t:o}=j(),[a,l]=d.useState(!1),c=d.useRef(null);d.useEffect(()=>{const g=c.current;g&&g.value!==e&&(g.value=e)},[a,e]);const h=o("auth.show_password","Show password"),u=o("auth.hide_password","Hide password");return n.jsxs("div",{class:"relative",children:[n.jsx("input",{ref:c,type:a?"text":"password",value:e,placeholder:r,onInput:g=>t(g.target.value),autocomplete:s,required:i,class:"h-14 w-full rounded-2xl bg-gray-100 pl-5 pr-12 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}),n.jsx("button",{type:"button",onClick:()=>l(g=>!g),"aria-label":a?u:h,tabIndex:-1,class:"absolute right-4 top-1/2 -translate-y-1/2 flex h-6 w-6 items-center justify-center rounded text-gray-500 transition-colors hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:a?n.jsx(it,{}):n.jsx(st,{})})]})}function st(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M1.667 10S4.583 4.167 10 4.167 18.333 10 18.333 10 15.417 15.833 10 15.833 1.667 10 1.667 10Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.5",stroke:"currentColor","stroke-width":"1.5"})]})}function it(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M8.236 4.293A6.96 6.96 0 0 1 10 4.167C15.417 4.167 18.333 10 18.333 10a13.5 13.5 0 0 1-1.92 2.755M11.768 11.768A2.5 2.5 0 0 1 8.233 8.233",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M14.953 14.953A8.84 8.84 0 0 1 10 15.833C4.583 15.833 1.667 10 1.667 10a13.5 13.5 0 0 1 3.38-3.953M1.667 1.667l16.666 16.666",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]})}function ot({email:r}){const{t:e}=j(),t=r?e("auth.last_used","Last · {email}",{email:at(r)}):e("auth.last_used_no_email","Last");return n.jsx("span",{class:"pointer-events-none absolute -top-2 right-3 max-w-[75%] truncate rounded-full bg-gray-900 px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white shadow-sm",children:t})}function at(r){const[e,t]=r.split("@");return t?`${e.slice(0,3)}*****@${t}`:r}function lt(){const{t:r}=j();return n.jsxs("div",{class:"flex items-center gap-3 py-1 text-sm text-gray-400",children:[n.jsx("div",{class:"h-px flex-1 bg-gray-200"}),n.jsx("span",{children:r("auth.or","or")}),n.jsx("div",{class:"h-px flex-1 bg-gray-200"})]})}function ct({provider:r}){return r==="google"?n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 18 18","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.49h4.84a4.14 4.14 0 0 1-1.79 2.71v2.26h2.9c1.7-1.56 2.69-3.87 2.69-6.62Z"}),n.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.9-2.26c-.8.54-1.83.86-3.06.86-2.36 0-4.36-1.59-5.07-3.74H.92v2.33A9 9 0 0 0 9 18Z"}),n.jsx("path",{fill:"#FBBC05",d:"M3.93 10.68a5.4 5.4 0 0 1 0-3.36V4.99H.92a9 9 0 0 0 0 8.02l3-2.33Z"}),n.jsx("path",{fill:"#EA4335",d:"M9 3.58c1.32 0 2.5.45 3.44 1.34l2.58-2.58A9 9 0 0 0 .92 4.99l3.01 2.33C4.64 5.17 6.64 3.58 9 3.58Z"})]}):r==="apple"?n.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}):r==="github"?n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M8 0C3.6 0 0 3.6 0 8a8 8 0 0 0 5.5 7.6c.4.1.5-.2.5-.4v-1.5c-2.2.5-2.7-1-2.7-1-.4-.9-.9-1.2-.9-1.2-.7-.5.1-.5.1-.5.8.1 1.2.8 1.2.8.7 1.2 1.9.9 2.4.7 0-.5.3-.9.5-1.1-1.8-.2-3.6-.9-3.6-4 0-.9.3-1.6.8-2.1-.1-.2-.4-1 .1-2.1 0 0 .7-.2 2.2.8a7.6 7.6 0 0 1 4 0c1.5-1 2.2-.8 2.2-.8.4 1.1.2 1.9.1 2.1.5.5.8 1.2.8 2.1 0 3.1-1.9 3.7-3.6 3.9.3.3.6.8.6 1.6V15c0 .2.1.5.6.4A8 8 0 0 0 16 8c0-4.4-3.6-8-8-8Z"})}):n.jsx("svg",{width:"18",height:"20",viewBox:"0 0 14 16",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M14 2.7C14 1.2 12.8 0 11.3 0H2.7C1.2 0 0 1.2 0 2.7v10.6C0 14.8 1.2 16 2.7 16h4V9.8H4.7v-2H6.7V6.4c0-2 1.2-3.1 3-3.1.9 0 1.7.1 2 .2V5h-1.4c-.8 0-1 .4-1 1v1.5h2.4l-.3 2H9.3V16h2c1.5 0 2.7-1.2 2.7-2.7V2.7Z"})})}function ut({email:r,onBack:e,t}){return n.jsxs("div",{class:"flex flex-col items-center gap-4 py-2 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full",style:{background:"linear-gradient(135deg, #4ade80, #16a34a)",color:"#fff",boxShadow:"0 0 0 8px rgba(74,222,128,0.12), 0 8px 20px -6px rgba(22,163,74,0.45)"},"aria-hidden":"true",children:n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",children:n.jsx("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})})}),n.jsx("h2",{class:"mt-1 text-3xl font-bold tracking-tight text-gray-900",children:t("auth.check_email_title","Check your email")}),n.jsx("p",{class:"text-base leading-relaxed text-gray-600",children:t("auth.reset_sent_subtitle","We sent a password reset link. Follow the instructions in the email to reset your password.")}),r?n.jsx("p",{class:"break-all text-base font-semibold text-gray-900",children:r}):null,n.jsx("p",{class:"text-sm text-gray-500",children:t("auth.reset_link_valid","The link is valid for 1 hour.")}),n.jsx("button",{type:"button",onClick:e,class:"pw-cta-shimmer relative mt-2 flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:n.jsx("span",{class:"relative z-10",children:t("auth.back_to_login","Back to Login")})})]})}function dt({block:r,bootstrap:e,auth:t,authSession:s,onBack:i,showBack:o=!0,intent:a="preauth",initialMode:l}){const{t:c}=j(),h={bootstrap:e,selectedPriceId:null,setSelectedPriceId:()=>{},onAction:()=>{},auth:t,authSession:s,initialAuthMode:l},u=a==="restore"?{...r,heading:c("auth.restore_purchases_heading","Restore Purchases"),subheading:c("auth.restore_purchases_subheading","Please sign in to restore your purchases.")}:a==="preauth"?{...r,heading:c("auth.login_continue_purchase","Log in to continue your purchase"),subheading:c("auth.link_purchase_subheading","We'll link the purchase to your account to keep access."),submit_label:c("auth.log_in","Sign In")}:r;return n.jsxs("div",{class:"relative flex-1 min-h-0 overflow-y-auto p-6 sm:p-8",children:[o?n.jsx(ht,{onClick:i,ariaLabel:c("nav.back_aria","Back")}):null,n.jsx(ve,{block:u,ctx:h})]})}function ht({onClick:r,ariaLabel:e}){return n.jsx("button",{type:"button",onClick:r,"aria-label":e,class:"absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M5 8h8a4 4 0 0 1 0 8H9",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M8 4 4 8l4 4",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"})]})})}const _e=r=>`pw-offer-${r}-start`;function Q(r){const e=r-Date.now();return e<=0?{days:0,hours:0,minutes:0,seconds:0,expired:!0}:{days:Math.floor(e/(1e3*60*60*24)),hours:Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(e%(1e3*60*60)/(1e3*60)),seconds:Math.floor(e%(1e3*60)/1e3),expired:!1}}function pt(r){if(r.expires_at){const e=Date.parse(r.expires_at);return Number.isFinite(e)?e:null}if(r.duration_minutes&&r.duration_minutes>0){if(typeof window>"u")return null;try{const e=_e(r.id);let t=window.localStorage.getItem(e);return t||(t=new Date().toISOString(),window.localStorage.setItem(e,t)),Date.parse(t)+r.duration_minutes*6e4}catch{return null}}return null}function je(r,e){if(!r||r.length===0)return null;if(e){const t=r.find(s=>s.id===e);if(t)return t}return r.find(t=>t.expires_at||t.duration_minutes)??null}function Se(r){const e=r?pt(r):null,[t,s]=d.useState(()=>e!==null?Q(e):null),i=d.useRef(e);return i.current=e,d.useEffect(()=>{if(e===null){s(null);return}s(Q(e));const o=setInterval(()=>{const a=Q(i.current??0);if(s(a),a.expired&&(clearInterval(o),r?.duration_minutes&&typeof window<"u"))try{window.localStorage.removeItem(_e(r.id))}catch{}},1e3);return()=>clearInterval(o)},[e,r?.duration_minutes,r?.id]),t}function ft({block:r,ctx:e}){const{t}=j(),s=je(e.bootstrap.offers,r.offer_id),i=Se(s);if(!s||i===null||i.expired&&!r.force)return null;const o=r.title??s.label??t("offer.limited_time","Limited-time offer"),a=s.discount_percent?`${o} ${s.discount_percent}%`:o;return n.jsxs("div",{class:"flex flex-wrap items-center justify-center gap-2 rounded-2xl px-4 py-3 text-[15px] font-semibold leading-tight text-white",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)",textShadow:"0 0 2px rgba(0, 0, 0, 0.25)"},role:"status",children:[n.jsx(Ie,{}),n.jsx("span",{children:a}),n.jsx(Ce,{value:i,t})]})}function Ce({value:r,t:e}){return n.jsxs("div",{class:"flex items-center gap-1 font-mono text-sm",children:[r.days>0?n.jsxs(n.Fragment,{children:[n.jsx(V,{children:String(r.days)}),n.jsx("span",{class:"text-xs",children:e("countdown.d","d")})]}):null,n.jsx(V,{children:String(r.hours).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.h","h")}),n.jsx(V,{children:String(r.minutes).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.m","m")}),n.jsx(V,{children:String(r.seconds).padStart(2,"0")}),n.jsx("span",{class:"text-xs",children:e("countdown.s","s")})]})}function V({children:r}){return n.jsx("span",{class:"rounded bg-black/20 px-1.5 py-0.5 text-xs font-bold",children:r})}function gt({offer:r}){const{t:e}=j(),t=Se(r);if(t===null||t.expired)return null;const s=r.label??e("offer.limited_time","Limited-time offer"),i=r.discount_percent?`${s} ${r.discount_percent}%`:s;return n.jsxs("div",{class:"-mb-2 flex flex-wrap items-center justify-center gap-2 rounded-t-xl px-4 pb-5 pt-3 text-[15px] font-semibold leading-tight text-white",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)",textShadow:"0 0 2px rgba(0, 0, 0, 0.25)"},role:"status",children:[n.jsx(Ie,{}),n.jsx("span",{children:i}),n.jsx(Ce,{value:t,t:e})]})}function Ie(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:n.jsx("path",{fill:"currentColor",d:"m9.44 5.359-2.394-.895.61-3.036c.062-.31-.345-.531-.57-.291L2.434 6.105a.336.336 0 0 0 .126.537l2.395.894-.61 3.037c-.062.31.345.53.57.29l4.653-4.968a.336.336 0 0 0-.126-.536Z"})})}const ce=3,ue=200,de=5e3,ee=5,xt=10*1024*1024,he=["image/jpeg","image/png","image/webp"],mt=/.+@.+\..+/;function yt({client:r,authSession:e,origin:t,onBack:s}){const{t:i}=j(),o=e?.user.email??"",a=o||null,[l,c]=d.useState(o),[h,u]=d.useState(""),[g,_]=d.useState(""),[p,k]=d.useState([]),[x,I]=d.useState(!1),[y,m]=d.useState(null),[S,C]=d.useState({}),T=()=>{const A={},E=(a??l).trim(),R=h.trim(),M=g.trim();return E?mt.test(E.toLowerCase())||(A.email=i("support.invalid_email","Invalid email")):A.email=i("support.required","Required"),(R.length<ce||R.length>ue)&&(A.subject=i("support.subject_length","{min}–{max} characters",{min:ce,max:ue})),(M.length<1||M.length>de)&&(A.message=i("support.message_length","{min}–{max} characters",{min:1,max:de})),C(A),Object.keys(A).length===0},P=async A=>{if(A.preventDefault(),!x&&T()){I(!0),C(E=>({...E,submit:void 0}));try{const E=(a??l).trim();await r.createSupportTicket({subject:h.trim(),content:g.trim(),email:E||void 0,files:p.length>0?p:void 0}),m(E)}catch(E){const R=E instanceof v.PaywallError&&E.message||"Failed to send. Please try again.";C(M=>({...M,submit:R}))}finally{I(!1)}}},B=()=>{u(""),_(""),k([]),C({}),m(null)},O="flex flex-col gap-3 bg-white px-6 pb-6 pt-3 sm:px-8",q={boxShadow:"0 -4px 12px -4px rgba(15,23,42,0.06)"};return y?n.jsxs("div",{class:"relative flex-1 min-h-0 flex flex-col",children:[n.jsxs("div",{class:"flex-1 min-h-0 overflow-y-auto flex flex-col items-center gap-4 px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 85%, white), var(--pw-accent))",color:"#fff",boxShadow:"0 0 0 8px color-mix(in srgb, var(--pw-accent) 12%, transparent), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 45%, transparent)"},"aria-hidden":"true",children:n.jsx("svg",{viewBox:"0 0 24 24",class:"h-7 w-7",children:n.jsx("path",{fill:"currentColor",d:"M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24Zm6.93 8.2-6.85 9.29a1.01 1.01 0 0 1-1.43.19L5.76 13.77a1 1 0 1 1 1.25-1.56l4.08 3.26 6.23-8.45a1 1 0 1 1 1.61 1.18Z"})})}),n.jsx("div",{class:"text-lg font-semibold tracking-tight text-gray-900",children:i("support.success_heading","Request submitted")}),n.jsxs("div",{class:"max-w-[320px] text-sm leading-relaxed text-gray-500",children:[i("support.success_message_prefix","We've received your message and will respond to")," ",n.jsx("b",{class:"text-gray-700",children:y}),"."]})]}),n.jsx("div",{class:O,style:q,children:n.jsxs("div",{class:"flex items-center justify-center gap-3",children:[n.jsx("button",{type:"button",onClick:s,class:"rounded-xl px-3 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t==="standalone"?i("support.done_button","Done"):i("nav.back_aria","Back")}),n.jsx("button",{type:"button",onClick:B,class:"flex h-10 items-center justify-center rounded-xl px-4 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 6px 14px -4px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:i("support.send_another","Send another request")})]})})]}):n.jsxs("form",{onSubmit:P,class:"relative flex-1 min-h-0 flex flex-col",children:[n.jsx(bt,{onClick:s,ariaLabel:i("nav.back_aria","Back")}),n.jsx("div",{class:"flex-1 min-h-0 overflow-y-auto px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8",children:n.jsxs("div",{class:"flex flex-col gap-5",children:[n.jsxs("div",{class:"flex flex-col gap-2 pr-10",children:[n.jsx("h2",{class:"text-3xl font-bold tracking-tight text-gray-900",children:i("support.heading","Support")}),n.jsx("p",{class:"text-base leading-relaxed text-gray-600",children:i("support.instruction","Please fill out the form below to submit your support request.")})]}),n.jsxs("div",{class:"flex flex-col gap-3",children:[a?n.jsxs("div",{class:"rounded-2xl bg-gray-100 px-5 py-3 text-sm text-gray-600",children:[i("support.sending_as","Sending as")," ",n.jsx("b",{class:"font-medium text-gray-900",children:a})]}):n.jsx(pe,{type:"email",placeholder:i("support.email_placeholder","Enter your email *"),value:l,onInput:c,error:S.email,autocomplete:"email",required:!0}),n.jsx(pe,{type:"text",placeholder:i("support.subject_placeholder","Enter your subject *"),value:h,onInput:u,error:S.subject,required:!0}),n.jsx(wt,{placeholder:i("support.message_placeholder","Enter your message *"),value:g,onInput:_,error:S.message,required:!0}),n.jsx(kt,{files:p,onChange:k,disabled:x})]})]})}),n.jsxs("div",{class:O,style:q,children:[S.submit&&n.jsx("p",{class:"text-sm text-red-600",children:S.submit}),n.jsxs("div",{class:"flex items-center justify-end gap-3",children:[n.jsx("button",{type:"button",onClick:s,disabled:x,class:"rounded-full px-4 py-2 text-base font-medium text-gray-700 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:t==="standalone"?i("support.close_button","Close"):i("nav.back_aria","Back")}),n.jsx("button",{type:"submit",disabled:x,class:"pw-cta-shimmer relative flex h-12 items-center justify-center overflow-hidden rounded-full px-8 text-base font-semibold text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:x?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:i("support.send_button","Send")})})]})]})]})}function bt({onClick:r,ariaLabel:e}){return n.jsx("button",{type:"button",onClick:r,"aria-label":e,class:"absolute right-4 top-4 z-10 flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M5 8h8a4 4 0 0 1 0 8H9",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M8 4 4 8l4 4",stroke:"currentColor","stroke-width":"1.75","stroke-linecap":"round","stroke-linejoin":"round"})]})})}function pe({type:r,placeholder:e,value:t,onInput:s,error:i,autocomplete:o,required:a}){return n.jsxs("div",{children:[n.jsx("input",{type:r,value:t,placeholder:e,onInput:l=>s(l.target.value),autocomplete:o,required:a,class:`h-14 w-full rounded-2xl bg-gray-100 px-5 text-base text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 ${i?"shadow-[0_0_0_2px_rgba(239,68,68,0.5)]":"focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}`}),i&&n.jsx("span",{class:"mt-1 ml-2 block text-sm text-red-600",children:i})]})}function wt({placeholder:r,value:e,onInput:t,error:s,required:i}){return n.jsxs("div",{children:[n.jsx("textarea",{value:e,placeholder:r,onInput:o=>t(o.target.value),required:i,rows:5,class:`min-h-[120px] w-full rounded-2xl bg-gray-100 px-5 py-3.5 text-base leading-relaxed text-gray-900 outline-none transition-all placeholder:text-gray-500 hover:bg-gray-200/60 focus:bg-gray-200/60 ${s?"shadow-[0_0_0_2px_rgba(239,68,68,0.5)]":"focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--pw-accent)_30%,transparent)]"}`}),s&&n.jsx("span",{class:"mt-1 ml-2 block text-sm text-red-600",children:s})]})}function kt({files:r,onChange:e,disabled:t}){const{t:s}=j(),i=d.useRef(null),[o,a]=d.useState(!1),[l,c]=d.useState(null),h=u=>{if(!u||t)return;c(null);const g=Array.from(u);if(r.length+g.length>ee){c(s("support.too_many_files","Up to {max} files",{max:ee}));return}const _=g.filter(p=>he.includes(p.type)&&p.size<=xt);if(_.length!==g.length){c(s("support.invalid_file","Only JPEG/PNG/WebP, ≤ 10MB each"));return}e([...r,..._])};return n.jsxs("div",{children:[n.jsx("span",{class:"text-xs font-medium text-gray-700",children:s("support.attachments_label","Attachments (optional)")}),n.jsxs("div",{role:"button",tabIndex:0,"aria-label":s("support.attachments_aria","Attachments upload"),onClick:()=>!t&&i.current?.click(),onDragOver:u=>{u.preventDefault(),t||a(!0)},onDragLeave:()=>a(!1),onDrop:u=>{u.preventDefault(),a(!1),h(u.dataTransfer?.files??null)},class:`mt-1.5 cursor-pointer rounded-2xl border border-dashed p-3.5 text-center transition-all ${o?"border-[var(--pw-accent)] bg-[color-mix(in_srgb,var(--pw-accent)_6%,white)]":"border-gray-300 hover:border-gray-400 hover:bg-gray-50/60"} ${t?"cursor-not-allowed opacity-60":""}`,children:[n.jsx("div",{class:"text-xs text-gray-500",children:s("support.dropzone_text","Drop images here or click to select")}),n.jsx("div",{class:"mt-0.5 text-[11px] text-gray-400",children:s("support.file_requirements","JPEG/PNG/WebP, up to {max} files, ≤ 10MB each",{max:ee})})]}),n.jsx("input",{ref:i,type:"file",multiple:!0,accept:he.join(","),class:"hidden",onChange:u=>{h(u.target.files),u.currentTarget.value=""}}),l&&n.jsx("p",{class:"mt-1 text-xs text-red-600",children:l}),r.length>0&&n.jsx("ul",{class:"mt-2 flex flex-col gap-1",children:r.map((u,g)=>n.jsxs("li",{class:"flex items-center justify-between gap-2 rounded bg-gray-50 px-2 py-1 text-xs",children:[n.jsx("span",{class:"truncate text-gray-700",children:u.name}),n.jsx("button",{type:"button",onClick:()=>{const _=[...r];_.splice(g,1),e(_)},disabled:t,class:"text-gray-500 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-60","aria-label":s("support.remove_file_aria","Remove {filename}",{filename:u.name}),children:"✕"})]},`${u.name}-${u.size}-${g}`))})]})}const vt={day:"cta.get_plan_daily",week:"cta.get_plan_weekly",month:"cta.get_plan_monthly",year:"cta.get_plan_yearly"},_t={day:"Get Daily Plan",week:"Get Weekly Plan",month:"Get Monthly Plan",year:"Get Yearly Plan"};function jt(r,e,t,s){if(e==="close")return s("cta.close","Close");if(!r)return s("cta.continue","Continue");if(!t&&r.trial_days&&r.interval&&r.interval!=="lifetime")return s("cta.start_trial","Start {days}-Day Free Trial",{days:r.trial_days});if(!r.interval||r.interval==="lifetime")return s("cta.get_lifetime_access","Get Lifetime Access");const i=vt[r.interval];return i?s(i,_t[r.interval]):s("cta.get_plan_generic","Get {interval} Plan",{interval:St(r.interval)})}function St(r){return r.length?r[0].toUpperCase()+r.slice(1):r}function Ct({block:r,ctx:e}){const{t}=j(),[s,i]=d.useState(!1),o=r.priceId??e.selectedPriceId,a=s||r.action==="checkout"&&!o,l=o?e.bootstrap.prices.find(g=>g.id===o)??null:null,c=e.bootstrap.user?.had_previous_trial??!1,h=r.label??jt(l,r.action,c,t),u=async()=>{if(!a){i(!0);try{await e.onAction(r.action,{priceId:o})}finally{i(!1)}}};return n.jsxs("button",{type:"button",disabled:a,onClick:u,class:"pw-cta-shimmer relative flex min-h-12 w-full items-center justify-center overflow-hidden rounded-3xl px-5 py-2 text-center text-base font-semibold leading-tight text-white transition-transform duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 55%, white) 0%, var(--pw-accent) 55%, color-mix(in srgb, var(--pw-accent) 90%, black) 100%)",boxShadow:"0 0 20px 0 color-mix(in srgb, var(--pw-accent) 25%, transparent), inset 0 0 8px 0 color-mix(in srgb, white 25%, transparent)"},children:[n.jsx("span",{class:"absolute inset-0 opacity-40",style:{background:"radial-gradient(circle at 50% 0%, color-mix(in srgb, white 40%, transparent) 0%, transparent 70%)"},"aria-hidden":"true"}),s?n.jsx("span",{class:"relative z-10 inline-block h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white"}):n.jsx("span",{class:"relative z-10",children:h})]})}function It({ctx:r}){const{t:e}=j(),t=r.authSession,s=r.auth,[i,o]=d.useState(!1),a=()=>r.onAction("support");if(t&&!t.user.is_anonymous){const l=async()=>{if(!(!s||i)){o(!0);try{await s.signOut()}catch{}finally{o(!1)}}};return n.jsxs("div",{class:"-mt-3 flex flex-col items-center gap-1.5 pt-1 text-center text-[13px] text-gray-500",children:[n.jsxs("span",{children:[e("session.signed_in_as_prefix","Signed in as")," ",n.jsx("b",{class:"font-medium text-gray-700",children:t.user.email})]}),n.jsxs("div",{class:"flex items-center justify-center gap-3",children:[n.jsx($,{onClick:l,disabled:!s||i,children:i?e("session.signing_out","Signing out…"):e("session.sign_out","Sign Out")}),n.jsx(fe,{}),n.jsx($,{onClick:a,children:e("session.contact_support","Contact Support")})]})]})}return n.jsxs("div",{class:"-mt-3 flex items-center justify-center gap-3 pt-1 text-center text-[13px]",children:[n.jsx($,{onClick:()=>r.onAction("restore"),children:e("session.restore_purchases","Restore purchases")}),n.jsx(fe,{}),n.jsx($,{onClick:a,children:e("session.contact_support","Contact Support")})]})}function $({onClick:r,disabled:e,children:t}){return n.jsx("button",{type:"button",onClick:r,disabled:e,class:"font-semibold transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60 focus:outline-none focus-visible:opacity-80",style:{color:"var(--pw-accent)"},children:t})}function fe(){return n.jsx("span",{class:"h-1 w-1 rounded-full bg-gray-300","aria-hidden":"true"})}function Pt({block:r}){return r.items.length?n.jsx("ul",{class:"flex flex-col gap-2.5",role:"list",children:r.items.map(e=>n.jsxs("li",{class:"flex items-start gap-3 text-sm text-gray-700",children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",class:"mt-0.5 flex-shrink-0 text-emerald-500","aria-hidden":"true",children:n.jsx("path",{d:"M4 10.5l3.5 3.5 8.5-8.5",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})}),n.jsxs("div",{class:"flex flex-col gap-0.5",children:[n.jsx("span",{class:"font-medium leading-snug text-gray-900",children:e.name}),e.desc?n.jsx("span",{class:"text-xs leading-relaxed text-gray-400",children:e.desc}):null]})]},e.id))}):null}function Et({block:r}){const{t:e}=j(),t=r.title??e("pricing.money_back","30-day money-back guarantee"),s=r.subtitle,i=(r.icon??"dollar_shield")!=="none",o=At(t);return n.jsxs("div",{class:"flex flex-col items-center gap-1.5 border-b-1 pb-4 mb-1 border-gray-100",children:[n.jsxs("div",{class:"inline-flex items-center gap-2 text-[12px] text-gray-700",children:[i?n.jsx(Lt,{}):null,o?n.jsxs("span",{children:[n.jsx("b",{class:"font-bold text-gray-900",children:o.bold})," ",n.jsx("span",{class:"font-medium",children:o.rest})]}):n.jsx("span",{class:"font-medium",children:t})]}),s?n.jsx("span",{class:"text-center text-xs leading-relaxed text-gray-500",children:s}):null]})}function At(r){const e=r.match(/^(\d+[-\s]?days?)\s+(.+)$/i);return e?{bold:e[1],rest:e[2]}:null}function Lt(){return n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16",class:"flex-shrink-0 text-emerald-500","aria-hidden":"true",children:[n.jsx("path",{d:"M12 2 4 5v6c0 5.25 3.5 9.5 8 11 4.5-1.5 8-5.75 8-11V5l-8-3Z",stroke:"currentColor","stroke-width":"2","stroke-linejoin":"round"}),n.jsx("path",{d:"m9 12 2 2 4-4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}const Pe=24,Tt=16,Mt=2;function Bt(r,e){const t=e*Mt;let s=Pe;for(r.style.fontSize=`${s}px`;r.scrollHeight>t&&s>Tt;)s-=1,r.style.fontSize=`${s}px`}function Ot({block:r,ctx:e}){const t=r.level??1,s=`h${t}`,i=t===1?"text-[22px] sm:text-2xl font-semibold leading-tight text-center text-balance text-gray-800":t===2?"text-xl font-semibold leading-snug text-gray-900 tracking-tight":"text-base font-medium text-gray-900",o=d.useRef(null),a=t===1&&!!e.bootstrap.settings.title_auto_fit;return d.useEffect(()=>{if(!a||!o.current)return;const l=getComputedStyle(o.current),c=parseFloat(l.lineHeight)||Pe*1.5;Bt(o.current,c)},[a,r.text]),n.jsx(s,{ref:o,class:i,children:r.text})}function qt(r){const e=r.local??{currency:r.currency,amount:r.amount};if(r.interval==="year"){const t=(r.interval_count??1)*12;return{amount:e.amount/t,currency:e.currency}}return{amount:e.amount,currency:e.currency}}function te(r,e){const t=r%1!==0?2:0;try{const s=new Intl.NumberFormat(void 0,{style:"currency",currency:e,currencyDisplay:"narrowSymbol",maximumFractionDigits:t,minimumFractionDigits:t}).formatToParts(r);let i="",o="";for(const a of s)a.type==="currency"?i=a.value:a.type!=="literal"&&(o+=a.value);return{currency:i||e,amount:o.trim()}}catch{return{currency:e,amount:String(r)}}}function ne(r,e){const{amount:t,currency:s}=qt(r);if(!e){const{currency:l,amount:c}=te(t,s);return{currency:l,amount:c,originalAmount:null}}const i=t*(1-e/100),o=te(i,s),a=te(t,s);return{currency:o.currency,amount:o.amount,originalAmount:`${a.currency}${a.amount}`}}function Ee(r,e){if(r.label)return r.label.toUpperCase();if(!r.interval||r.interval==="lifetime")return e("pricing.plan_label.lifetime","LIFETIME");const s={day:{key:"pricing.plan_label.daily",fallback:"DAILY PLAN"},week:{key:"pricing.plan_label.weekly",fallback:"WEEKLY PLAN"},month:{key:"pricing.plan_label.monthly",fallback:"MONTHLY PLAN"},year:{key:"pricing.plan_label.yearly",fallback:"YEARLY PLAN"}}[r.interval];return s?e(s.key,s.fallback):`${r.interval.toUpperCase()} PLAN`}function se(r,e){if(!r.interval||r.interval==="lifetime")return e("pricing.interval.lifetime_short","lifetime");if(r.interval==="year")return e("pricing.interval.month","month");const t=r.interval_count??1;return t===1?e(`pricing.interval.${r.interval}`,r.interval):`${t} ${r.interval}s`}function Rt({block:r,ctx:e}){const{t}=j(),s=r.priceIds&&r.priceIds.length>0?new Set(r.priceIds):null,i=e.bootstrap.prices.filter(a=>!s||s.has(a.id));if(i.length===0)return n.jsx("p",{class:"text-sm text-gray-500",children:t("pricing.no_prices","No prices available.")});const o=r.popular_label??t("pricing.most_popular","Most popular");if(r.view==="compact")return n.jsx("div",{class:"flex w-full flex-col rounded-xl border border-gray-200 bg-gray-50",role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map((a,l)=>n.jsx(Dt,{price:a,isLast:l===i.length-1,isPopular:r.popular_price_id===a.id,popularLabel:o,offer:D(e.bootstrap.offers,a.id),selected:e.selectedPriceId===a.id,onSelect:()=>{e.setSelectedPriceId(a.id),e.onAction("price_selected",{priceId:a.id,price:a})},t},a.id))});if(r.view==="horizontal"){const a=Math.min(i.length,3),l=i.some(c=>(D(e.bootstrap.offers,c.id)?.discount_percent??0)>0);return n.jsx("div",{class:"grid items-stretch gap-2",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map(c=>n.jsx(Nt,{price:c,isPopular:r.popular_price_id===c.id,popularLabel:o,offer:D(e.bootstrap.offers,c.id),reserveStrikeRow:l,selected:e.selectedPriceId===c.id,onSelect:()=>{e.setSelectedPriceId(c.id),e.onAction("price_selected",{priceId:c.id,price:c})},t},c.id))})}return n.jsx("div",{class:"flex flex-col gap-2",role:"radiogroup","aria-label":t("pricing.plans_aria","Plans"),children:i.map(a=>{const l=e.selectedPriceId===a.id,c=r.popular_price_id===a.id,u=D(e.bootstrap.offers,a.id)?.discount_percent??null,{currency:g,amount:_,originalAmount:p}=ne(a,u);return n.jsxs("button",{type:"button",role:"radio","aria-checked":l,onClick:()=>{e.setSelectedPriceId(a.id),e.onAction("price_selected",{priceId:a.id,price:a})},class:["group relative inline-flex w-full mx-auto items-center justify-between flex-row-reverse gap-4 rounded-2xl border-2 px-4 py-3.5 text-left transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",l?"border-[var(--pw-accent)] bg-transparent":"border-gray-200 bg-transparent hover:bg-gray-50"].join(" "),children:[n.jsx("span",{class:["flex h-6.5 w-6.5 flex-shrink-0 items-center justify-center rounded-full border transition-colors",l?"border-[var(--pw-accent)] text-white":"border-gray-300 bg-transparent text-transparent",c?"mt-3":""].join(" "),style:l?{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 70%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)"}:void 0,"aria-hidden":"true",children:n.jsx("svg",{width:"14",height:"10",viewBox:"0 0 17 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:l?"opacity-100":"opacity-0",children:n.jsx("path",{d:"M16.5234 0.476562C16.9805 0.898438 16.9805 1.63672 16.5234 2.05859L7.52344 11.0586C7.10156 11.5156 6.36328 11.5156 5.94141 11.0586L1.44141 6.55859C0.984375 6.13672 0.984375 5.39844 1.44141 4.97656C1.86328 4.51953 2.60156 4.51953 3.02344 4.97656L6.75 8.66797L14.9414 0.476562C15.3633 0.0195312 16.1016 0.0195312 16.5234 0.476562Z",fill:"currentColor"})})}),n.jsxs("div",{class:"flex flex-1 flex-col gap-0.5",children:[n.jsxs("div",{class:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{class:"text-xs font-normal uppercase tracking-normal text-gray-800/70",children:Ee(a,t)}),p?n.jsx("span",{class:"text-[15px] font-normal text-gray-400 opacity-60 line-through decoration-gray-400 decoration-[1.5px]",children:p}):null,u?n.jsxs("span",{class:"rounded-full bg-emerald-100 px-2.5 py-1 text-xs font-bold leading-none text-emerald-700",children:["-",u,"%"]}):null]}),n.jsx("div",{class:"flex items-baseline gap-2 flex-wrap",children:n.jsxs("span",{class:"text-[26px] leading-tight whitespace-nowrap text-gray-800 font-medium",children:[n.jsx("span",{class:"opacity-90",children:g}),_,n.jsxs("span",{class:"text-sm font-normal text-gray-500",children:[" ","/ ",se(a,t)]})]})}),a.description?n.jsx("span",{class:"mt-1 text-xs leading-relaxed text-gray-500",children:a.description}):null]}),c?n.jsx("span",{class:"absolute -top-[9px] -right-[6px] rounded-[11px] border-[5px] border-white px-2 py-1 text-[12px] font-semibold text-white",style:{background:"var(--pw-accent)"},children:o}):null]},a.id)})})}function Ut(r,e){return r.label?r.label:!r.interval||r.interval==="lifetime"?e("pricing.interval.lifetime_short","lifetime"):e(`pricing.interval.${r.interval}`,r.interval)}function Dt({price:r,isLast:e,isPopular:t,popularLabel:s,offer:i,selected:o,onSelect:a,t:l}){const c=i?.discount_percent??null,{currency:h,amount:u,originalAmount:g}=ne(r,c);return n.jsxs("button",{type:"button",role:"radio","aria-checked":o,onClick:a,class:"group relative inline-flex w-full max-w-[360px] mx-auto items-center justify-between gap-4 px-4 pt-3.5 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--pw-accent)]",children:[n.jsx("span",{class:["flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border transition-colors mb-3",o?"border-[var(--pw-accent)] text-white":"border-gray-300 bg-transparent text-transparent"].join(" "),style:o?{background:"linear-gradient(135deg, color-mix(in srgb, var(--pw-accent) 70%, white) 0%, var(--pw-accent) 50%, color-mix(in srgb, var(--pw-accent) 85%, black) 100%)"}:void 0,"aria-hidden":"true",children:n.jsx("svg",{width:"14",height:"10",viewBox:"0 0 17 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",class:o?"opacity-100":"opacity-0",children:n.jsx("path",{d:"M16.5234 0.476562C16.9805 0.898438 16.9805 1.63672 16.5234 2.05859L7.52344 11.0586C7.10156 11.5156 6.36328 11.5156 5.94141 11.0586L1.44141 6.55859C0.984375 6.13672 0.984375 5.39844 1.44141 4.97656C1.86328 4.51953 2.60156 4.51953 3.02344 4.97656L6.75 8.66797L14.9414 0.476562C15.3633 0.0195312 16.1016 0.0195312 16.5234 0.476562Z",fill:"currentColor"})})}),n.jsxs("div",{class:["flex flex-1 items-center gap-1.5 pb-3.5",e?"":"border-b border-gray-200"].join(" "),children:[n.jsxs("div",{class:"flex flex-wrap items-center gap-1 gap-x-1.5",children:[n.jsx("span",{class:"text-base font-normal capitalize text-gray-800",children:Ut(r,l)}),t?n.jsx("span",{class:"rounded-[9px] px-2 py-1 text-[10px] font-bold",style:{background:"linear-gradient(160deg, color-mix(in srgb, var(--pw-accent) 6%, white) 0%, color-mix(in srgb, var(--pw-accent) 15%, white) 100%)",color:"var(--pw-accent)"},children:s}):null,c?n.jsxs("span",{class:"rounded-md bg-emerald-100 px-1.5 py-0.5 text-[10px] font-bold leading-none text-emerald-700",children:["-",c,"%"]}):null]}),n.jsx("div",{class:"flex-1"}),n.jsxs("span",{class:"flex items-baseline gap-1.5 text-base font-normal text-gray-600",children:[g?n.jsx("span",{class:"text-xs text-gray-400 line-through decoration-gray-400 decoration-[1.5px]",children:g}):null,n.jsxs("span",{class:"whitespace-nowrap",children:[n.jsx("span",{class:"opacity-90",children:h}),u,n.jsxs("span",{class:"text-xs text-gray-400",children:[" ","/ ",se(r,l)]})]})]})]})]})}function Nt({price:r,isPopular:e,popularLabel:t,offer:s,reserveStrikeRow:i,selected:o,onSelect:a,t:l}){const c=s?.discount_percent??null,{currency:h,amount:u,originalAmount:g}=ne(r,c);return n.jsxs("button",{type:"button",role:"radio","aria-checked":o,onClick:a,class:["group relative flex h-full flex-col items-center justify-start gap-1 rounded-2xl border-2 px-3 pb-4 pt-3.5 text-center transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",o?"border-[var(--pw-accent)]":"border-gray-200 hover:bg-gray-50"].join(" "),style:o?{background:"color-mix(in srgb, var(--pw-accent) 6%, transparent)"}:void 0,children:[n.jsx("span",{class:"flex min-h-[2.4em] items-center text-[10px] font-normal uppercase leading-tight text-gray-800/70",children:Ee(r,l)}),i?n.jsxs("div",{class:"flex h-[22px] items-center justify-center gap-1.5",children:[g?n.jsx("span",{class:"text-[12px] text-gray-400 line-through decoration-gray-400 decoration-[1.5px]",children:g}):null,c?n.jsxs("span",{class:"rounded-md bg-emerald-100 px-1.5 py-0.5 text-[10px] font-bold leading-none text-emerald-700",children:["-",c,"%"]}):null]}):null,n.jsxs("span",{class:"text-[26px] leading-none whitespace-nowrap text-gray-800 font-medium",children:[n.jsx("span",{class:"opacity-90",children:h}),u]}),n.jsxs("span",{class:"text-xs font-normal text-gray-500",children:["/ ",se(r,l)]}),e?n.jsx("span",{class:"absolute -top-[10px] left-1/2 -translate-x-1/2 whitespace-nowrap rounded-[11px] border-[3px] border-white px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-white",style:{background:"var(--pw-accent)"},children:t}):null]})}function zt({block:r}){return n.jsx("p",{class:"text-[0.9375rem] leading-relaxed text-gray-600",children:r.text})}const Ft={week:.25,month:1,year:12};function Vt(r,e){return r?e(`pricing.interval.${r}`,r):e("pricing.interval.period","period")}function $t({block:r,ctx:e}){const{t}=j();if(!r.queries.length)return null;const i=e.bootstrap.prices.find(a=>a.id===e.selectedPriceId)?.interval??null,o=i?Ft[i]:void 0;return n.jsxs("div",{class:"flex flex-col gap-2",children:[n.jsx("div",{class:"text-sm font-semibold text-gray-800",children:!i||i==="lifetime"?t("pricing.included_total","Included for lifetime:"):t("pricing.included_per","Included per {interval}:",{interval:Vt(i,t)})}),n.jsx("ul",{class:"flex flex-col gap-2",role:"list",children:r.queries.map(a=>{const l=Number.isFinite(a.count)?a.count:0,c=o!==void 0?Math.round(l*o):l;return n.jsxs("li",{class:`flex gap-3 ${a.desc?"items-start":"items-center"}`,children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",class:`flex-shrink-0 text-emerald-500 ${a.desc?"mt-0.5":""}`,"aria-hidden":"true",children:n.jsx("path",{d:"M4 10.5l3.5 3.5 8.5-8.5",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})}),n.jsxs("div",{children:[n.jsx("span",{class:"font-semibold text-gray-900 text-sm",children:c})," ",n.jsx("span",{class:"text-sm text-gray-800",children:a.name}),a.desc?n.jsxs(n.Fragment,{children:[n.jsx("br",{}),n.jsx("span",{class:"text-xs text-gray-400",children:a.desc})]}):null]})]},a.id)})})]})}const Ht={heading:Ot,text:zt,price_grid:Rt,cta_button:Ct,auth_panel:ve,current_session:It,features_list:Pt,tokenization_gate:$t,guarantee_badge:Et,offer_banner:ft};function Gt({layout:r,bootstrap:e,onAction:t,auth:s,authSession:i,hasTopBanner:o}){const a=d.useMemo(()=>{for(const k of r.blocks)if(k.type==="price_grid"&&k.popular_price_id&&e.prices.some(x=>x.id===k.popular_price_id))return k.popular_price_id;return e.prices[0]?.id??null},[r.blocks,e.prices]),[l,c]=d.useState(a),h={bootstrap:e,selectedPriceId:l,setSelectedPriceId:c,onAction:t,auth:s,authSession:i},u=r.blocks.findIndex(k=>k.type==="cta_button"),g=u===-1?r.blocks:r.blocks.slice(0,u),_=u===-1?[]:r.blocks.slice(u),p=(k,x)=>{const I=Ht[k.type];return I?n.jsx(I,{block:k,ctx:h},`${k.type}-${x}`):(typeof console<"u"&&console.warn(`[paywall] unknown block type: ${k.type}`),null)};return n.jsxs(n.Fragment,{children:[n.jsx("div",{class:"flex-1 min-h-0 overflow-y-auto px-6 pb-3 pt-6 sm:px-8 sm:pb-4 sm:pt-8",children:n.jsx("div",{class:"flex flex-col gap-6",children:g.map(p)})}),_.length>0?n.jsx("div",{class:"flex flex-col gap-4 bg-white px-6 pb-6 pt-3 sm:px-8",style:{boxShadow:"0 -4px 12px -4px rgba(15,23,42,0.06)"},children:_.map((k,x)=>p(k,g.length+x))}):null]})}function Wt(r,e,t,s){return r?s?{open:!0,view:"purchased",error:null,processing:!1}:e.status==="idle"||e.status==="loading"?{open:!0,view:"loading",error:null,processing:!1}:e.status==="error"?{open:!0,view:"error",error:e.error,processing:!1}:t.kind==="support"?{open:!0,view:"support",error:null,processing:!1}:t.kind==="auth_gate"?{open:!0,view:"auth",error:null,processing:!1}:t.kind==="awaiting_payment"?{open:!0,view:"awaiting_payment",error:null,processing:!1}:t.kind==="popup_blocked"?{open:!0,view:"popup_blocked",error:null,processing:!1}:t.kind==="purchase_success"?{open:!0,view:"purchased",error:null,processing:!1}:t.kind==="verifying"?{open:!0,view:"loading",error:null,processing:!1}:{open:!0,view:"layout",error:null,processing:!1}:{open:!1,view:null,error:null,processing:!1}}function Zt(r,e){return r.open===e.open&&r.view===e.view&&r.error===e.error&&r.processing===e.processing}function Yt({client:r,open:e,onClose:t,onEvent:s,initialView:i,initialAuthMode:o,initialCheckoutPriceId:a,initialCheckoutUrl:l,purchased:c,renew:h,onState:u,inline:g,locale:_}){const[p,k]=d.useState({status:"idle"}),[x,I]=d.useState(()=>r.auth?.getCachedSession()??null),[y,m]=d.useState(()=>i==="support"?{kind:"support",origin:"standalone"}:i==="auth"?a?{kind:"auth_gate",pendingCheckout:{priceId:a,direct:!0},origin:"standalone",intent:"preauth"}:{kind:"auth_gate",origin:"standalone"}:i==="awaiting_payment"&&a&&l?{kind:"awaiting_payment",priceId:a,url:l}:i==="popup_blocked"&&a&&l?{kind:"popup_blocked",priceId:a,url:l}:{kind:"layout"}),S=i==="awaiting_payment"||i==="popup_blocked"||i==="auth"&&!!a,C=d.useRef(!1),T=d.useRef(null);d.useEffect(()=>{if(!u)return;const b=Wt(e,p,y,c),f=T.current;f&&Zt(f,b)||(T.current=b,u(b))},[e,p,y,c,u]),d.useEffect(()=>{if(r.auth)return r.auth.onAuthChange((b,f)=>I(f))},[r.auth]),d.useEffect(()=>{if(typeof r.onBootstrapChange=="function")return r.onBootstrapChange(b=>{k(f=>f.status==="ready"?{status:"ready",data:b}:f)})},[r]),d.useEffect(()=>{if(!e||p.status==="ready"||p.status==="loading")return;let b=!1;return k({status:"loading"}),r.bootstrap().then(f=>{if(b)return;k({status:"ready",data:f}),s("ready",f);const w=i==="support"||i==="auth"||S;f.user?.has_active_subscription&&!h&&!w&&(s("purchase_completed",{priceId:a??null,sessionId:null,restored:!0}),m({kind:"purchase_success",restored:!0}))}).catch(f=>{if(b)return;const w=f instanceof v.PaywallError?f:new v.PaywallError("unknown","Failed to load paywall",{cause:f});k({status:"error",error:w}),s("error",w)}),()=>{b=!0}},[e,r]),d.useLayoutEffect(()=>{if(!e){m({kind:"layout"}),C.current=!1;return}i==="support"?m({kind:"support",origin:"standalone"}):i==="auth"?m(a?{kind:"auth_gate",pendingCheckout:{priceId:a,direct:!0},origin:"standalone",intent:"preauth"}:{kind:"auth_gate",origin:"standalone"}):i==="awaiting_payment"&&a&&l?m({kind:"awaiting_payment",priceId:a,url:l}):i==="popup_blocked"&&a&&l&&m({kind:"popup_blocked",priceId:a,url:l})},[e,i,a,l]);const P=async b=>{try{const f=r.getCachedOffers?.()??null,w=f?D(f,b):null,L=await r.createCheckout({priceId:b,offerId:w?.id,ignoreActivePurchase:h===!0});if(s("checkout_started",{priceId:b,url:L.url,acquiring:L.acquiring}),typeof window>"u"||!L.url)return;const z=window.open(L.url,"_blank");if(z){try{z.opener=null}catch{}m({kind:"awaiting_payment",priceId:b,url:L.url})}else m({kind:"popup_blocked",priceId:b,url:L.url})}catch(f){if(f instanceof v.PaywallError&&f.code==="already_purchased"){try{await r.getUser({force:!0})}catch{}s("purchase_completed",{priceId:b,sessionId:null,restored:!0}),S?t():m({kind:"purchase_success",restored:!0});return}const w=f instanceof v.PaywallError?f:new v.PaywallError("checkout_failed","Checkout failed",{cause:f});s("error",w),S?t():m({kind:"layout"})}},B=(b,f)=>{if(typeof window>"u")return;const w=window.open(f,"_blank");if(w){try{w.opener=null}catch{}m({kind:"awaiting_payment",priceId:b,url:f})}};d.useEffect(()=>{if(y.kind!=="auth_gate"||!x||x.user.is_anonymous||C.current)return;C.current=!0;const b=y.pendingCheckout,f=y.origin;m({kind:"verifying"}),(async()=>{if(!h)try{if((await r.getUser({force:!0})).has_active_subscription){s("purchase_completed",{priceId:b?.priceId??null,sessionId:null,restored:!0}),b?.direct?t():m({kind:"purchase_success",restored:!0});return}}catch{}if(!b){f==="standalone"?t():m({kind:"layout"});return}await P(b.priceId)})().finally(()=>{C.current=!1})},[x,y]);const O=async(b,f)=>{if(b==="close"){t();return}if(b==="price_selected"){s("price_selected",f);return}if(b==="restore"){if(!r.auth)return;const w=r.auth.getCachedSession();if(w&&!w.user.is_anonymous)return;m({kind:"auth_gate",intent:"restore"});return}if(b==="support"){m({kind:"support",origin:"layout"});return}if(b==="checkout"&&p.status==="ready"){const w=f?.priceId;if(!w){s("error",new v.PaywallError("no_price","No price selected"));return}const L=p.data.settings.checkout_mode??"guest",z=r.auth?.getCachedSession()??null,Be=!!z&&!z.user.is_anonymous;if(L==="preauth"&&!!r.auth&&!Be){m({kind:"auth_gate",pendingCheckout:{priceId:w}});return}await P(w)}},q=p.status==="ready"?p.data.settings.brand_color:null,A=p.status==="ready"?p.data.settings.allow_close!==!1:!0,R=y.kind==="layout"&&p.status==="ready"?je(p.data.offers):null,M=R?n.jsx(gt,{offer:R}):null,W={type:"auth_panel",allow_signup:!0,allow_password_reset:!0,hide_when_authenticated:!1,providers:p.status==="ready"?p.data.settings.auth_providers:void 0},F=y.kind==="support"?n.jsx(yt,{client:r,authSession:x,origin:y.origin,onBack:()=>{y.origin==="standalone"?t():m({kind:"layout"})}}):null,Z=y.kind==="auth_gate"&&y.origin!=="standalone"||y.kind==="support",Y=p.status==="ready"?p.data:null;return n.jsx(Ze,{bootstrap:Y,forceLocale:_,children:n.jsx(Ye,{open:e,onClose:t,brandColor:q,topBanner:M,allowClose:A,hideCloseButton:Z,inline:g,labelledBy:"pw-title",children:c?n.jsx(ge,{onContinue:t}):y.kind==="purchase_success"?n.jsx(ge,{restored:y.restored,onContinue:t}):F||(p.status==="loading"||p.status==="idle"||y.kind==="verifying"?n.jsx(Kt,{verifying:y.kind==="verifying"}):p.status==="error"?n.jsx(Xt,{message:p.error.message}):y.kind==="auth_gate"&&r.auth?n.jsx(dt,{block:W,bootstrap:p.data,auth:r.auth,authSession:x,showBack:y.origin!=="standalone",intent:y.intent??(y.origin==="standalone"?"standalone":"preauth"),initialMode:y.origin==="standalone"?o:void 0,onBack:()=>{y.origin==="standalone"?t():m({kind:"layout"})}}):y.kind==="awaiting_payment"?n.jsx(Qt,{client:r,onBack:()=>m({kind:"layout"}),onReopen:()=>{if(typeof window>"u")return;const b=window.open(y.url,"_blank");if(b)try{b.opener=null}catch{}},onRetry:()=>P(y.priceId)}):y.kind==="popup_blocked"?n.jsx(Jt,{onReopen:()=>B(y.priceId,y.url)}):n.jsx(Gt,{layout:p.data.layout,bootstrap:p.data,onAction:O,auth:r.auth,authSession:x}))})})}function Kt({verifying:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center justify-center gap-3 py-12",children:[n.jsx("span",{class:"inline-block h-7 w-7 animate-spin rounded-full border-[2.5px] border-gray-200 border-t-[var(--pw-accent)]"}),n.jsx("span",{class:"text-xs font-medium tracking-wide text-gray-500",children:r?e("modal.verifying_subscription","Checking your subscription…"):e("modal.loading","Loading…")})]})}function Xt({message:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-2 py-8 text-center",children:[n.jsx("div",{class:"flex h-11 w-11 items-center justify-center rounded-full bg-red-50",children:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M10 6v5M10 14h.01",stroke:"#dc2626","stroke-width":"2","stroke-linecap":"round"}),n.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"#dc2626","stroke-width":"1.75"})]})}),n.jsx("p",{class:"text-sm font-semibold tracking-tight text-gray-900",children:e("modal.error_generic","Something went wrong")}),n.jsx("p",{class:"text-xs leading-relaxed text-gray-500",children:r})]})}function Jt({onReopen:r}){const{t:e}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-3 py-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full",style:{background:"color-mix(in srgb, var(--pw-accent) 12%, white)",color:"var(--pw-accent)"},"aria-hidden":"true",children:n.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("path",{d:"M14 4h6v6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M20 4l-9 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),n.jsx("path",{d:"M19 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:e("payment.popup_blocked_title","Allow popups to continue")}),n.jsx("p",{class:"max-w-[20rem] text-sm leading-relaxed text-gray-500",children:e("payment.popup_blocked_message","Your browser blocked the checkout tab. Click below to open it.")}),n.jsx("button",{type:"button",onClick:r,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:e("payment.open_checkout_button","Open checkout")})]})}function Qt({client:r,onBack:e,onReopen:t,onRetry:s}){const{t:i}=j(),[o,a]=d.useState(!1),[l,c]=d.useState(!1),h=d.useRef(null);d.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current)},[]);const u=async()=>{if(!o){a(!0),c(!1);try{if((await r.getUser({force:!0})).has_active_subscription){typeof window<"u"&&window.postMessage({type:"paywall_purchase"},"*");return}c(!0),h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{c(!1),h.current=null},5e3)}catch{c(!0)}finally{a(!1)}}};return n.jsxs("div",{class:"flex flex-col gap-3 px-6 pb-6 pt-4 sm:px-8 sm:pb-8 sm:pt-5",children:[n.jsx("button",{type:"button",onClick:e,class:"-ml-1 self-start rounded-md px-1.5 py-0.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("nav.back","← Back")}),n.jsxs("div",{class:"flex flex-col items-center gap-3 py-6 text-center",children:[n.jsxs("div",{class:"relative flex h-14 w-14 items-center justify-center",children:[n.jsx("span",{class:"absolute inset-0 animate-ping rounded-full opacity-40",style:{background:"color-mix(in srgb, var(--pw-accent) 30%, transparent)"},"aria-hidden":"true"}),n.jsx("span",{class:"relative inline-block h-8 w-8 animate-spin rounded-full border-[2.5px] border-gray-200 border-t-[var(--pw-accent)]"})]}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:i("payment.awaiting_title","Complete payment in the new tab")}),n.jsx("p",{class:"max-w-[22rem] text-sm leading-relaxed text-gray-500",children:i("payment.awaiting_subtitle","We'll detect your payment automatically — or click below once you're done.")}),n.jsx("button",{type:"button",onClick:u,disabled:o,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:translate-y-0 disabled:hover:brightness-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:o?i("payment.checking","Checking…"):i("payment.ive_paid","I've paid")}),l?n.jsx("p",{class:"text-xs leading-relaxed text-gray-500",children:i("payment.still_processing","Payment is still being processed. Please try again in a moment.")}):null]}),n.jsxs("div",{class:"rounded-2xl border border-gray-200 bg-gray-50/60 p-3.5",children:[n.jsx("p",{class:"text-xs leading-relaxed text-gray-600",children:i("payment.popup_help_text","Checkout window didn't open or got blocked? Click here to open it again.")}),n.jsx("button",{type:"button",onClick:t,class:"mt-2.5 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-xs font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("payment.open_checkout_again","Open checkout again")})]}),n.jsx("button",{type:"button",onClick:s,class:"self-center rounded-md px-2 py-1 text-xs text-gray-500 underline-offset-2 hover:text-gray-900 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--pw-accent)]",children:i("payment.tab_closed_retry","Tab closed? Try again")})]})}function ge({onContinue:r,restored:e=!1}){const{t}=j();return n.jsxs("div",{class:"flex flex-col items-center gap-3 py-8 text-center",children:[n.jsx("div",{class:"flex h-14 w-14 items-center justify-center rounded-full ring-8",style:{background:"linear-gradient(135deg, #4ade80, #16a34a)",color:"#fff",boxShadow:"0 0 0 8px rgba(74,222,128,0.12), 0 8px 20px -6px rgba(22,163,74,0.45)"},"aria-hidden":"true",children:n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",children:n.jsx("path",{d:"M5 13l4 4L19 7",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})})}),n.jsx("p",{id:"pw-title",class:"mt-1 text-lg font-semibold tracking-tight text-gray-900",children:e?t("modal.purchase_restored_title","Subscription restored"):t("modal.purchase_success_title","Payment received")}),n.jsx("p",{class:"text-sm leading-relaxed text-gray-500",children:e?t("modal.purchase_restored_subtitle","Welcome back — your subscription is already active."):t("modal.purchase_success_subtitle","Your subscription is now active.")}),n.jsx("button",{type:"button",onClick:r,class:"mt-3 rounded-xl px-5 py-2.5 text-sm font-semibold text-white transition-all hover:-translate-y-px hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--pw-accent)]",style:{background:"linear-gradient(180deg, color-mix(in srgb, var(--pw-accent) 92%, white), var(--pw-accent))",boxShadow:"0 1px 2px rgba(15,23,42,0.08), 0 8px 20px -6px color-mix(in srgb, var(--pw-accent) 50%, transparent)"},children:t("modal.continue","Continue")})]})}const er=10*6e4,tr=5e3,rr=3e4;class nr{constructor(e){this.timer=null,this.timeoutTimer=null,this.visibilityHandler=null,this.focusHandler=null,this.messageHandler=null,this.stopped=!1,this.checking=!1,this.opts={client:e.client,onActive:e.onActive,onTimeout:e.onTimeout??(()=>{}),timeoutMs:e.timeoutMs??er,visibleIntervalMs:e.visibleIntervalMs??tr,hiddenIntervalMs:e.hiddenIntervalMs??rr}}start(){this.stopped||typeof document>"u"||typeof window>"u"||(this.check(),this.scheduleNext(),this.visibilityHandler=()=>this.handleVisibilityChange(),document.addEventListener("visibilitychange",this.visibilityHandler),this.focusHandler=()=>void this.check(),window.addEventListener("focus",this.focusHandler),this.messageHandler=e=>this.handleMessage(e),window.addEventListener("message",this.messageHandler),this.timeoutTimer=setTimeout(()=>{this.stopped||(this.stop(),this.opts.onTimeout())},this.opts.timeoutMs))}stop(){this.stopped=!0,this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.timeoutTimer!==null&&clearTimeout(this.timeoutTimer),this.timeoutTimer=null,typeof document<"u"&&this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),typeof window<"u"&&(this.focusHandler&&window.removeEventListener("focus",this.focusHandler),this.messageHandler&&window.removeEventListener("message",this.messageHandler)),this.visibilityHandler=null,this.focusHandler=null,this.messageHandler=null}async check(){if(!(this.stopped||this.checking)){this.checking=!0;try{const e=await this.opts.client.getUser({force:!0});if(this.stopped)return;e.has_active_subscription&&(this.stop(),this.opts.onActive(e))}catch{}finally{this.checking=!1}}}scheduleNext(){if(this.stopped)return;const t=typeof document<"u"&&document.visibilityState==="visible"?this.opts.visibleIntervalMs:this.opts.hiddenIntervalMs;this.timer=setTimeout(async()=>{await this.check(),this.scheduleNext()},t)}handleVisibilityChange(){typeof document>"u"||(document.visibilityState==="visible"&&this.check(),this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.scheduleNext())}handleMessage(e){const t=e.data;!t||typeof t!="object"||t.type==="paywall_purchase"&&this.check()}}function sr(){return!(typeof document>"u"||typeof window>"u"||typeof location<"u"&&location.protocol==="chrome-extension:")}const re={open:!1,view:null,error:null,processing:!1},N={status:"paywall_status",priceId:"paywall_price_id",sessionId:"paywall_session_id"};let ir=class{constructor(e){this.handle=null,this.isOpen=!1,this.listeners=new Map,this.userUnsub=null,this.authUnsub=null,this.watcher=null,this.tracker=null,this.purchased=!1,this.trialStore=null,this.trialStoreConfig=null,this.lastTrialStatus=null,this.trialExpiredFired=!1,this.lastVisibility=null,this.currentState=re,this.stateListeners=new Set;const{auth:t,ownsAuth:s}=or(e);this.auth=t,this.ownsAuth=s,this.billing=e.client??new v.BillingClient({...e,auth:this.auth}),this.host=e.host,this.shadowMode=e.shadowMode??"closed",this.mountThenLoad=e.mountThenLoad??!0,this.inline=e.inline===!0,this.forceLocale=e.locale??null,this.userUnsub=this.billing.onUserChange(i=>{this.emit("userChange",i)}),this.auth&&(this.authUnsub=this.auth.onAuthChange((i,o)=>{this.emit("authChange",{event:i,session:o})})),this.initTracker(e.analytics),e.autoDetectReturn!==!1&&typeof window<"u"&&queueMicrotask(()=>this.checkReturn())}initTracker(e){if(e===!1)return;const t=typeof e=="object"&&e!==null?e:{};if(t.enabled===!1)return;const s=t.endpoint??`${this.billing.apiOrigin}/api/v1/paywall/${this.billing.paywallId}/events`;this.tracker=new v.EventTracker({endpoint:s,paywallId:this.billing.paywallId,capabilities:this.billing.capabilities,getVisitorId:()=>this.billing.getVisitorId(),getCachedVisitorId:()=>this.billing.getCachedVisitorId(),getUserId:()=>this.billing.getIdentity()?.userId??null,flushIntervalMs:t.flushIntervalMs,maxBufferSize:t.maxBufferSize,fetch:t.fetch,sendBeacon:t.sendBeacon}),this.on("open",()=>this.tracker?.track("paywall_opened")),this.on("ready",i=>this.tracker?.track("paywall_viewed",{is_test_mode:i.settings.is_test_mode,prices_count:i.prices.length,offers_count:i.offers.length})),this.on("price_selected",i=>this.tracker?.track("price_selected",{price_id:i.priceId})),this.on("checkout_started",i=>this.tracker?.track("checkout_started",{price_id:i.priceId,acquiring:i.acquiring})),this.on("purchase_completed",i=>this.tracker?.track("purchase_completed",{price_id:i.priceId,session_id:i.sessionId})),this.on("purchase_failed",i=>this.tracker?.track("purchase_failed",{reason:i.reason})),this.on("close",()=>this.tracker?.track("paywall_closed")),this.on("trial_blocked",i=>this.tracker?.track("trial_blocked",{mode:i.mode,...i.mode==="time"?{remaining_ms:i.remainingMs,total_ms:i.totalMs}:i.mode==="opens"?{remaining_actions:i.remainingActions,total_actions:i.totalActions}:{}})),this.on("trial_expired",()=>this.tracker?.track("trial_expired")),this.on("visibility_blocked",i=>this.tracker?.track("visibility_blocked",{reason:i.reason,country:i.country,tier:i.tier})),this.on("error",i=>this.tracker?.track("error",{code:i.code,message:i.message}))}track(e,t){this.tracker?.track(e,t)}onUserChange(e){return this.on("userChange",e)}setBootstrap(e){this.billing.setBootstrap(e)}setLocale(e){const t=e??null;t!==this.forceLocale&&(this.forceLocale=t,this.handle&&this.handle.update({locale:t}))}on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>s.delete(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(!s)return;const i=t[0];for(const o of s)try{o(i)}catch(a){typeof console<"u"&&console.error("[paywall] listener error",a)}}open(e={}){this.openInternal("layout",e)}async preload(e={}){try{await this.billing.bootstrap({signal:e.signal}),this.billing.auth&&await this.billing.getBalances({signal:e.signal})}catch{}}openSupport(e={}){this.openInternal("support",e)}openAuth(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0})}openSignin(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0,authMode:"signin"})}openSignup(e={}){this.auth&&this.openInternal("auth",{...e,skipTrial:!0,authMode:"signup"})}checkout(e,t={}){if(t.identity&&this.billing.setIdentity(t.identity),t.renew!==!0&&this.billing.getCachedUser()?.has_active_subscription){this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0});return}this.runDirectCheckout(e,t)}async runDirectCheckout(e,t){const s=t.renew===!0,i=t.skipTrial===!0,o=t.skipVisibility===!0;this.applyProcessing(!0);const a=()=>{this.applyProcessing(!1)};let l;try{l=await this.billing.bootstrap()}catch(x){const I=x instanceof v.PaywallError?x:new v.PaywallError("unknown","Failed to load paywall",{cause:x});this.emit("error",I),a();return}if(!o){const x=l.settings.visibility;if(x&&(this.lastVisibility=x,!x.visible)){this.emit("visibility_blocked",x),a();return}}if(!i&&await this.checkTrialBeforeCheckout(l)){a();return}if(!s&&l.user?.has_active_subscription){this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0}),a();return}const c=l.settings.checkout_mode??"guest",h=this.auth?.getCachedSession()??null,u=!!h&&!h.user.is_anonymous;if(c==="preauth"&&!!this.auth&&!u){this.purchased=!1,this.mountAndShow("auth",{renew:s,authMode:"signin",checkoutPriceId:e});return}const _=this.getOfferForPrice(e);let p;try{p=await this.billing.createCheckout({priceId:e,offerId:_?.offer.id,ignoreActivePurchase:s})}catch(x){if(x instanceof v.PaywallError&&x.code==="already_purchased"){try{await this.billing.getUser({force:!0})}catch{}this.emit("purchase_completed",{priceId:e,sessionId:null,restored:!0}),a();return}const I=x instanceof v.PaywallError?x:new v.PaywallError("checkout_failed","Checkout failed",{cause:x});this.emit("error",I),a();return}if(this.emit("checkout_started",{priceId:e,url:p.url,acquiring:p.acquiring}),this.startUserWatcher(),typeof window>"u"||!p.url){this.mountAndShow("awaiting_payment",{renew:s,checkoutPriceId:e,checkoutUrl:p.url});return}const k=window.open(p.url,"_blank");if(this.purchased=!1,k){try{k.opener=null}catch{}this.mountAndShow("awaiting_payment",{renew:s,checkoutPriceId:e,checkoutUrl:p.url})}else this.mountAndShow("popup_blocked",{renew:s,checkoutPriceId:e,checkoutUrl:p.url})}async checkTrialBeforeCheckout(e){const t=e.settings.trial;if(!t)return!1;const s=this.ensureTrialStore(t);try{const i=await s.check();if(this.lastTrialStatus=i,i.mode==="none")return!1;if(i.blocked){const o=await s.recordBlock();return this.lastTrialStatus=o,this.emit("trial_blocked",o),!0}return this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired")),!1}catch(i){return typeof console<"u"&&console.warn("[paywall] trial check failed",i),!1}}applyProcessing(e){this.currentState.processing!==e&&this.applyState({...this.currentState,processing:e})}signInAnonymously(){return this.auth?this.auth.signInAnonymously():Promise.reject(new v.PaywallError("invalid_config","signInAnonymously requires managed-auth. Pass `auth: true` to PaywallUI."))}openInternal(e,t){t.identity&&this.billing.setIdentity(t.identity),this.purchased=!1;const s=t.skipTrial===!0||e==="support",i=t.skipVisibility===!0||e==="support"||e==="auth",o=t.renew===!0;if(s&&i){this.mountAndShow(e,{renew:o,authMode:t.authMode});return}const a=this.billing.getCachedBootstrap();if(a){this.runOpenGates(e,a,{skipTrial:s,skipVisibility:i,renew:o});return}if(this.mountThenLoad){this.mountAndShow(e,{renew:o}),this.billing.bootstrap().then(l=>this.runDelayedGates(l,{skipTrial:s,skipVisibility:i})).catch(()=>{});return}this.billing.bootstrap().then(l=>this.runOpenGates(e,l,{skipTrial:s,skipVisibility:i,renew:o})).catch(()=>{this.mountAndShow(e,{renew:o})})}runDelayedGates(e,t){if(!this.isOpen)return;if(!t.skipVisibility){const o=e.settings.visibility;if(o&&(this.lastVisibility=o,!o.visible)){this.close(),this.emit("visibility_blocked",o);return}}if(t.skipTrial)return;const s=e.settings.trial;if(!s)return;const i=this.ensureTrialStore(s);i.check().then(async o=>{if(this.isOpen&&(this.lastTrialStatus=o,o.mode!=="none")){if(o.blocked){const a=await i.recordBlock();if(this.lastTrialStatus=a,!this.isOpen)return;this.close(),this.emit("trial_blocked",a);return}this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired"))}}).catch(o=>{typeof console<"u"&&console.warn("[paywall] trial check failed",o)})}runOpenGates(e,t,s){if(!s.skipVisibility){const i=t.settings.visibility;if(i&&(this.lastVisibility=i,!i.visible)){this.emit("visibility_blocked",i);return}}if(s.skipTrial){this.mountAndShow(e,{renew:s.renew});return}this.gateThroughTrial(e,t,s.renew)}gateThroughTrial(e,t,s){const i=t.settings.trial;if(!i){this.mountAndShow(e,{renew:s});return}const o=this.ensureTrialStore(i);o.check().then(async a=>{if(this.lastTrialStatus=a,a.mode==="none"){this.mountAndShow(e,{renew:s});return}if(a.blocked){const l=await o.recordBlock();this.lastTrialStatus=l,this.emit("trial_blocked",l);return}this.trialExpiredFired||(this.trialExpiredFired=!0,this.emit("trial_expired")),this.mountAndShow(e,{renew:s})}).catch(a=>{typeof console<"u"&&console.warn("[paywall] trial check failed",a),this.mountAndShow(e,{renew:s})})}ensureTrialStore(e){if(this.trialStore&&this.trialStoreConfig&&cr(this.trialStoreConfig,e))return this.trialStore;this.trialStoreConfig=e;const t=this.billing.createTrialStore;return this.trialStore=typeof t=="function"?t.call(this.billing,e):v.createTrialStore(this.billing.getStorage(),this.billing.paywallId,e),this.trialStore}mountAndShow(e,t={}){const s=t.renew===!0,i=t.authMode,a=e==="auth"||e==="awaiting_payment"||e==="popup_blocked"?t.checkoutPriceId??null:null,l=e==="awaiting_payment"||e==="popup_blocked"?t.checkoutUrl??null:null;if(this.handle){this.isOpen=!0,this.handle.update({open:!0,initialView:e,initialAuthMode:i,initialCheckoutPriceId:a,initialCheckoutUrl:l,purchased:!1,renew:s}),this.emit("open");return}this.isOpen=!0,this.handle=Fe(Yt,{client:this.billing,open:!0,initialView:e,initialAuthMode:i,initialCheckoutPriceId:a,initialCheckoutUrl:l,purchased:!1,renew:s,onClose:()=>this.close(),onEvent:(c,h)=>{this.emit(c,h),c==="checkout_started"&&this.startUserWatcher()},onState:c=>this.applyState(c),inline:this.inline,locale:this.forceLocale},{host:this.host,shadowMode:this.shadowMode,inline:this.inline}),this.emit("open")}applyState(e){if(!lr(this.currentState,e)){this.currentState=e;for(const t of this.stateListeners)try{t(e)}catch(s){console.warn("[paywall] onStateChange listener threw",s)}}}getState(){return this.currentState}onStateChange(e,t={}){this.stateListeners.add(e);const s=t.immediate??"microtask";if(s!=="none"){const i=this.currentState;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onStateChange initial sync threw",o)}else queueMicrotask(()=>{this.stateListeners.has(e)&&e(i)})}return()=>{this.stateListeners.delete(e)}}getTrialStatus(){return this.lastTrialStatus}getVisibility(){return this.lastVisibility}getPrices(e={}){return this.billing.getPrices(e)}getCachedPrices(){return this.billing.getCachedPrices()}getCachedOffers(){return this.billing.getCachedOffers()}getOfferForPrice(e){const t=this.billing.getCachedOffers();if(!t)return null;const s=D(t,e);return s?Re(s,{now:Date.now(),readStart:Ne}):null}getUserLanguage(){return this.billing.getUserLanguage()}async getAccess(e={}){let t=this.billing.getCachedBootstrap();if(!t)try{t=await this.billing.bootstrap({signal:e.signal})}catch{const a=this.billing.getCachedUser();return a?.has_active_subscription?{access:"granted",reason:"has_subscription",visibility:null,trial:null,user:a}:{access:"blocked",reason:"no_subscription",visibility:null,trial:null,user:a}}const s=this.billing.getCachedUser()??t.user??null;if(s?.has_active_subscription)return{access:"granted",reason:"has_subscription",visibility:t.settings.visibility??null,trial:null,user:s};let i=null;if(!e.skipVisibility){const a=t.settings.visibility;if(a&&(i=a,this.lastVisibility=a,!a.visible))return{access:"granted",reason:"visibility_blocked",visibility:i,trial:null,user:s}}let o=null;if(!e.skipTrial){const a=t.settings.trial;if(a)try{if(o=await this.ensureTrialStore(a).check(),this.lastTrialStatus=o,o.blocked)return{access:"granted",reason:"trial_blocked",visibility:i,trial:o,user:s}}catch(l){typeof console<"u"&&console.warn("[paywall] getAccess: trial check failed",l)}}return{access:"blocked",reason:"no_subscription",visibility:i,trial:o,user:s}}async resetTrial(){this.trialStore&&(await this.trialStore.reset(),this.lastTrialStatus=null,this.trialExpiredFired=!1)}startUserWatcher(){this.watcher||sr()&&(this.watcher=new nr({client:this.billing,onActive:e=>{this.watcher=null,this.emit("purchase_completed",{priceId:null,sessionId:null});const t=this.billing.getCachedBootstrap()?.settings.success_redirect_url;if(t&&typeof window<"u")try{window.location.assign(t);return}catch{}this.isOpen&&this.handle&&(this.purchased=!0,this.handle.update({purchased:!0}))},onTimeout:()=>{this.watcher=null}}),this.watcher.start())}close(){!this.isOpen||!this.handle||(this.isOpen=!1,this.purchased=!1,this.handle.update({open:!1,purchased:!1}),this.applyState(re),this.emit("close"))}checkReturn(){if(typeof window>"u")return;const e=new URL(window.location.href),t=xe(e.hash.replace(/^#/,"")),s=xe(e.search.replace(/^\?/,"")),i=t??s;i&&(i.status==="paid"?(this.emit("purchase_completed",{priceId:i.priceId,sessionId:i.sessionId}),ur(i)):(i.status==="failed"||i.status==="cancelled")&&this.emit("purchase_failed",{reason:i.status}),dr(e))}destroy(){this.tracker?.destroy(),this.tracker=null,this.listeners.clear(),this.stateListeners.clear(),this.watcher?.stop(),this.watcher=null,this.userUnsub?.(),this.userUnsub=null,this.authUnsub?.(),this.authUnsub=null,this.ownsAuth&&this.auth&&this.auth.destroy?.(),this.ownsAuth=!1,this.billing.destroy?.(),this.handle?.unmount(),this.handle=null,this.isOpen=!1,this.currentState=re}};function or(r){if(!r.auth)return{auth:void 0,ownsAuth:!1};if(r.auth instanceof v.AuthClient||ar(r.auth))return{auth:r.auth,ownsAuth:!1};const e=r.auth===!0?{}:r.auth;return{auth:new v.AuthClient({paywallId:r.paywallId,apiOrigin:e.apiOrigin??r.apiOrigin,storage:e.storage??r.storage,fetch:e.fetch??r.fetch,openPopup:e.openPopup}),ownsAuth:!0}}function ar(r){if(typeof r!="object"||r===null)return!1;const e=r;return typeof e.onAuthChange=="function"&&typeof e.getCachedSession=="function"&&typeof e.signOut=="function"}function lr(r,e){return r.open===e.open&&r.view===e.view&&r.error===e.error&&r.processing===e.processing}function cr(r,e){return r.mode===e.mode&&r.payload===e.payload&&r.storage===e.storage}function xe(r){if(!r)return null;const e=new URLSearchParams(r),t=e.get(N.status);return t?{status:t,priceId:e.get(N.priceId),sessionId:e.get(N.sessionId)}:null}function ur(r){if(!(typeof window>"u"||!window.opener))try{window.opener.postMessage({type:"paywall_purchase",status:r.status,priceId:r.priceId,sessionId:r.sessionId},"*")}catch{}}function dr(r){const e=(s,i)=>{if(!s)return"";const o=new URLSearchParams(s.replace(/^[?#]/,""));o.delete(N.status),o.delete(N.priceId),o.delete(N.sessionId);const a=o.toString();return a?i+a:""},t=r.pathname+e(r.search,"?")+e(r.hash,"#");window.history.replaceState(null,"",t)}class hr{constructor(e,t,s){this.transport=e,this.paywallId=t,this.config=s}async check(){return this.transport.request("trial.check",{paywallId:this.paywallId,config:this.config})}async recordBlock(){return this.transport.request("trial.recordBlock",{paywallId:this.paywallId,config:this.config})}async reset(){await this.transport.request("trial.reset",{paywallId:this.paywallId,config:this.config})}}class Ae{constructor(e,t){this.transport=e,this.cachedBootstrap=null,this.cachedUser=null,this.cachedBalances=null,this.identity=null,this.userListeners=new Set,this.balanceListeners=new Set,this.bootstrapListeners=new Set,this.unsubUserBroadcast=null,this.unsubBalancesBroadcast=null,this.paywallId=t.paywallId,this.apiOrigin=t.apiOrigin,this.remoteStorageAdapter={getItem:s=>this.transport.request("storage.get",{key:s}),setItem:async(s,i)=>{await this.transport.request("storage.set",{key:s,value:i})},removeItem:async s=>{await this.transport.request("storage.remove",{key:s})}},this.unsubUserBroadcast=this.transport.on("userChange",s=>{this.applyUser(s)}),this.unsubBalancesBroadcast=this.transport.on("balancesChange",s=>{this.applyBalances([...s])})}async bootstrap(e={}){const t=await this.transport.request("billing.bootstrap",{force:e.force},{signal:e.signal});return this.applyBootstrap(t),t.user&&this.applyUser(t.user),t}getCachedBootstrap(){return this.cachedBootstrap}onBootstrapChange(e,t={}){this.bootstrapListeners.add(e);const s=t.immediate??"microtask";if(this.cachedBootstrap&&s!=="none"){const i=this.cachedBootstrap;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onBootstrapChange initial sync threw",o)}else queueMicrotask(()=>{this.bootstrapListeners.has(e)&&e(i)})}return()=>{this.bootstrapListeners.delete(e)}}async getPrices(e={}){return(await this.bootstrap(e)).prices}getCachedPrices(){return this.cachedBootstrap?.prices??null}getCachedOffers(){return this.cachedBootstrap?.offers??null}async getVisitorId(){return this.transport.request("billing.getVisitorId",void 0)}async getUser(e={}){const t=await this.transport.request("billing.getUser",{force:e.force},{signal:e.signal});return this.applyUser(t),t}getCachedUser(){return this.cachedUser}onUserChange(e,t={}){this.userListeners.add(e);const s=t.immediate??"microtask";if(this.cachedUser&&s!=="none"){const i=this.cachedUser;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onUserChange initial sync threw",o)}else queueMicrotask(()=>{this.userListeners.has(e)&&e(i)})}return()=>{this.userListeners.delete(e)}}async getBalances(e={}){const s=[...await this.transport.request("billing.getBalances",{force:e.force},{signal:e.signal})];return this.applyBalances(s),s}getCachedBalances(){return this.cachedBalances}onBalanceChange(e,t={}){this.balanceListeners.add(e);const s=t.immediate??"microtask";if(this.cachedBalances&&s!=="none"){const i=this.cachedBalances;if(s==="sync")try{e(i)}catch(o){console.warn("[paywall] onBalanceChange initial sync threw",o)}else queueMicrotask(()=>{this.balanceListeners.has(e)&&e(i)})}return()=>{this.balanceListeners.delete(e)}}async createCheckout(e){const{signal:t,...s}=e;return this.transport.request("billing.createCheckout",s,{signal:t})}async listPurchases(e={}){return[...await this.transport.request("billing.listPurchases",void 0,{signal:e.signal})]}async createSupportTicket(e){return this.transport.request("billing.createSupportTicket",e)}async cancelSubscription(e){const{signal:t,...s}=e;return this.transport.request("billing.cancelSubscription",s,{signal:t})}getStorage(){return this.remoteStorageAdapter}createTrialStore(e){return new hr(this.transport,this.paywallId,e)}getIdentity(){return this.identity}async setIdentity(e){this.identity=e,await this.transport.request("billing.setIdentity",{identity:e})}async syncIdentity(){const e=await this.transport.request("billing.getIdentity",void 0);return this.identity=e,e}destroy(){this.unsubUserBroadcast?.(),this.unsubBalancesBroadcast?.(),this.unsubUserBroadcast=null,this.unsubBalancesBroadcast=null,this.userListeners.clear(),this.balanceListeners.clear(),this.bootstrapListeners.clear(),this.cachedBootstrap=null,this.cachedUser=null,this.cachedBalances=null,this.identity=null}applyBootstrap(e){this.cachedBootstrap=e;for(const t of[...this.bootstrapListeners])try{t(e)}catch(s){console.warn("[paywall] onBootstrapChange listener threw",s)}}applyUser(e){pr(this.cachedUser,e)||(this.cachedUser=e,this.fireUserListeners(e))}applyBalances(e){fr(this.cachedBalances,e)||(this.cachedBalances=e,this.fireBalanceListeners(e))}fireUserListeners(e){for(const t of[...this.userListeners])try{t(e)}catch(s){console.warn("[paywall] onUserChange listener threw",s)}}fireBalanceListeners(e){for(const t of[...this.balanceListeners])try{t(e)}catch(s){console.warn("[paywall] onBalanceChange listener threw",s)}}}function pr(r,e){return r===e?!0:!r||!e?!1:r.has_active_subscription===e.has_active_subscription&&(r.purchases?.length??0)===(e.purchases?.length??0)}function fr(r,e){if(r===e)return!0;if(!r||!e||r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t].type!==e[t].type||r[t].count!==e[t].count)return!1;return!0}class Le{constructor(e,t){this.transport=e,this.session=null,this.listeners=new Set,this.unsubBroadcast=null,this.paywallId=t.paywallId,this.apiOrigin=t.apiOrigin,this.unsubBroadcast=this.transport.on("authChange",({event:s,session:i})=>{this.applySession(s,i)}),this.hydrated=this.transport.request("auth.getCachedSession",void 0).then(s=>{this.session===null&&s!==null&&(this.session=s)}).catch(()=>{})}ready(){return this.hydrated}getCachedSession(){return this.session}getCachedUser(){return this.session?.user??null}onAuthChange(e){return this.listeners.add(e),this.hydrated.then(()=>{if(this.listeners.has(e))try{e("INITIAL_SESSION",this.session)}catch(t){console.warn("[paywall] onAuthChange INITIAL_SESSION threw",t)}}),()=>{this.listeners.delete(e)}}async signInWithEmail(e){const t=await this.transport.request("auth.signInWithEmail",e);return this.applySession("SIGNED_IN",t),t}async signUp(e){const t=await this.transport.request("auth.signUp",e);return t.kind==="signed_in"&&this.applySession("SIGNED_IN",t.session),t}async signOut(){await this.transport.request("auth.signOut",void 0)}async refresh(){const e=await this.transport.request("auth.refresh",void 0);return this.applySession(e?"TOKEN_REFRESHED":"SIGNED_OUT",e),e}async sendOtp(e){await this.transport.request("auth.sendOtp",e)}async verifyOtp(e){const t=await this.transport.request("auth.verifyOtp",e);return this.applySession(e.type==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",t),t}async resendConfirmation(e){await this.transport.request("auth.resendConfirmation",e)}async requestPasswordReset(e){await this.transport.request("auth.requestPasswordReset",e)}async updatePassword(e){await this.transport.request("auth.updatePassword",e)}async revokeAllSessions(){await this.transport.request("auth.revokeAllSessions",void 0)}async getLastLogin(){return this.transport.request("auth.getLastLogin",void 0)}async signInAnonymously(e={}){const t=await this.transport.request("auth.signInAnonymously",{captchaToken:e.captchaToken,userMeta:e.userMeta,forceNewAnon:e.forceNewAnon});return this.applySession("SIGNED_IN",t),t}async getAccessToken(){return this.transport.request("auth.getAccessToken",void 0)}async signInWithOAuth(e){if(typeof window>"u")throw new v.PaywallError("oauth_unavailable","window is required for OAuth");const t=`pw-oauth-pending-${Math.random().toString(36).slice(2,10)}`,s=window.open("about:blank",t,"width=480,height=640,popup=yes");if(!s)throw new v.PaywallError("popup_blocked","browser blocked auth popup — call from a user gesture");mr(s,e.provider);try{const{authorizeUrl:i,state:o}=await this.transport.request("auth.oauthStart",{provider:e.provider,scopes:e.scopes,userMeta:e.userMeta});s.name=`pw-oauth-${o}`,s.location.replace(i),e.onPopupOpened?.();const a=await v.waitForOAuthCode(s,o),l=await this.transport.request("auth.oauthExchange",{state:o,code:a});return this.applySession("SIGNED_IN",l),l}catch(i){try{s.close()}catch{}throw i}}destroy(){this.unsubBroadcast?.(),this.unsubBroadcast=null,this.listeners.clear(),this.session=null}applySession(e,t){if(!gr(this.session,t)){this.session=t;for(const s of[...this.listeners])try{s(e,t)}catch(i){console.warn("[paywall] onAuthChange listener threw",i)}}}}function gr(r,e){return r===e?!0:!r||!e?!1:r.access_token===e.access_token&&r.refresh_token===e.refresh_token&&r.expires_at===e.expires_at&&r.user.id===e.user.id}const xr={google:"Google",apple:"Apple",github:"GitHub",facebook:"Facebook"};function mr(r,e){const t=xr[e]??e;try{const s=r.document;s.title=`Sign in with ${t}`;const i=s.createElement("style");i.textContent="html,body{margin:0;padding:0;height:100%;font-family:-apple-system,system-ui,sans-serif;background:#fafafa;color:#475569}.pw-oauth-wrap{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:16px}.pw-oauth-spinner{width:36px;height:36px;border:3px solid #e2e8f0;border-top-color:#7c3aed;border-radius:50%;animation:pw-oauth-spin 800ms linear infinite}.pw-oauth-label{font-size:14px;font-weight:500;letter-spacing:-0.01em}@keyframes pw-oauth-spin{to{transform:rotate(360deg)}}",s.head.appendChild(i);const o=s.createElement("div");o.className="pw-oauth-wrap";const a=s.createElement("div");a.className="pw-oauth-spinner";const l=s.createElement("div");l.className="pw-oauth-label",l.textContent=`Connecting to ${t}…`,o.appendChild(a),o.appendChild(l),s.body.appendChild(o)}catch{}}class Te{constructor(e){this.transport=e}track(e,t){typeof e!="string"||e.length===0||this.transport.request("tracker.track",{name:e,props:t}).catch(s=>{console.warn("[paywall] track failed",s)})}}class yr{constructor(e){this.factory=e,this.channel=null,this.channelDisposers=[],this.pending=new Map,this.listeners=new Map,this.destroyed=!1,this.nextId=0,this.clientId=`c-${Math.random().toString(36).slice(2,10)}`}ensureChannel(){if(this.destroyed)throw new Error("TransportClient destroyed");if(this.channel)return this.channel;const e=this.factory();this.channel=e;const t=e.onMessage(i=>this.handleMessage(i)),s=e.onDisconnect(()=>this.handleDisconnect());return this.channelDisposers=[t,s],this.request("handshake",{protocolVersion:v.PROTOCOL_VERSION,clientId:this.clientId}).then(i=>{i.protocolVersion!==v.PROTOCOL_VERSION&&console.warn(`[sdk-extension] protocol version mismatch: client=${v.PROTOCOL_VERSION}, offscreen=${i.protocolVersion}. Update host's @monetize.software/sdk-extension.`)}).catch(()=>{}),e}handleMessage(e){if(wr(e)){if(e.type==="response"){const t=this.pending.get(e.id);if(!t)return;this.pending.delete(e.id),t.signal?.removeEventListener("abort",t.abortListener),e.ok?t.resolve(e.result):t.reject(v.reconstructError(e.error));return}if(e.type==="event"){const t=this.listeners.get(e.kind);if(!t)return;for(const s of[...t])try{s(e.payload)}catch(i){console.error("[sdk-extension] event handler threw",i)}}}}handleDisconnect(){for(const t of this.channelDisposers)t();this.channelDisposers=[],this.channel=null;const e=Array.from(this.pending.values());this.pending.clear();for(const t of e)t.signal?.removeEventListener("abort",t.abortListener),t.reject(new br)}request(e,t,s={}){if(this.destroyed)return Promise.reject(new Error("TransportClient destroyed"));if(s.signal?.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));const i=this.ensureChannel(),o=`r${++this.nextId}`;return new Promise((a,l)=>{const c={resolve:a,reject:l,signal:s.signal};s.signal&&(c.abortListener=()=>{if(this.pending.delete(o)){l(new DOMException("Aborted","AbortError"));try{i.send({type:"cancel",id:o})}catch{}}},s.signal.addEventListener("abort",c.abortListener)),this.pending.set(o,c);const h={type:"request",id:o,kind:e,params:t};try{i.send(h)}catch(u){this.pending.delete(o),s.signal?.removeEventListener("abort",c.abortListener),l(u)}})}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s));const i=t;return s.add(i),this.ensureChannel(),()=>{s.delete(i)}}destroy(){if(this.destroyed)return;this.destroyed=!0;for(const t of this.channelDisposers)t();this.channelDisposers=[],this.listeners.clear();const e=Array.from(this.pending.values());this.pending.clear();for(const t of e)t.signal?.removeEventListener("abort",t.abortListener),t.reject(new Error("TransportClient destroyed"));this.channel?.close(),this.channel=null}}class br extends Error{constructor(){super("Transport channel disconnected mid-request"),this.code="transport_disconnected",this.name="TransportDisconnectedError"}}function wr(r){if(typeof r!="object"||r===null)return!1;const e=r.type;return e==="request"||e==="response"||e==="event"}let H=null;function Me(){return H||(H=new yr(()=>v.createRuntimeChannel(Oe.PORT_NAME)),H)}class kr extends ir{constructor(e){const t=Me(),s=new Ae(t,{paywallId:e.paywallId,apiOrigin:e.apiOrigin});let i;e.auth===!0?i=new Le(t,{paywallId:e.paywallId,apiOrigin:e.apiOrigin}):e.auth&&console.warn("[sdk-extension] passing AuthClient instance to PaywallUI.opts.auth is not supported in extension mode — pass `auth: true` to use offscreen-shared auth, or omit for hybrid identity-only mode."),i&&(s.auth=i),super({...e,client:s,auth:i,analytics:!1}),this.remoteTracker=null,this.trackerUnsubs=[],e.analytics!==!1&&(this.remoteTracker=new Te(t),this.bindAnalytics())}bindAnalytics(){const e=this.remoteTracker;e&&this.trackerUnsubs.push(this.on("open",()=>e.track("paywall_opened")),this.on("ready",t=>e.track("paywall_viewed",{is_test_mode:t.settings.is_test_mode,prices_count:t.prices.length,offers_count:t.offers.length})),this.on("price_selected",t=>e.track("price_selected",{price_id:t.priceId})),this.on("checkout_started",t=>e.track("checkout_started",{price_id:t.priceId,acquiring:t.acquiring})),this.on("purchase_completed",t=>e.track("purchase_completed",{price_id:t.priceId,session_id:t.sessionId})),this.on("purchase_failed",t=>e.track("purchase_failed",{reason:t.reason})),this.on("close",()=>e.track("paywall_closed")),this.on("trial_blocked",t=>e.track("trial_blocked",{mode:t.mode,...t.mode==="time"?{remaining_ms:t.remainingMs,total_ms:t.totalMs}:t.mode==="opens"?{remaining_actions:t.remainingActions,total_actions:t.totalActions}:{}})),this.on("trial_expired",()=>e.track("trial_expired")),this.on("visibility_blocked",t=>e.track("visibility_blocked",{reason:t.reason,country:t.country,tier:t.tier})),this.on("error",t=>e.track("error",{code:t.code,message:t.message})))}track(e,t){this.remoteTracker?.track(e,t)}destroy(){for(const e of this.trackerUnsubs)e();this.trackerUnsubs=[],this.remoteTracker=null,super.destroy()}}exports.PROTOCOL_VERSION=v.PROTOCOL_VERSION;exports.PaywallUI=kr;exports.RemoteAuthClient=Le;exports.RemoteBillingClient=Ae;exports.RemoteEventTracker=Te;exports.getContentTransport=Me;
|
|
26
26
|
//# sourceMappingURL=content.cjs.map
|