@revenuecat/purchases-js 1.8.0 → 1.9.0
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/Purchases.es.js +2 -2
- package/dist/Purchases.umd.js +2 -2
- package/package.json +1 -1
package/dist/Purchases.es.js
CHANGED
|
@@ -9802,7 +9802,7 @@ function a_(e, r) {
|
|
|
9802
9802
|
n.trackSDKEvent($), D(k, !0), await vr() ? r.onContinue() : D(k, !1);
|
|
9803
9803
|
}
|
|
9804
9804
|
async function ke(F, $) {
|
|
9805
|
-
D(S, L(F)), D(h, L($)), await ce();
|
|
9805
|
+
D(S, L(F)), D(h, L(r.customerEmail ?? $)), await ce();
|
|
9806
9806
|
}
|
|
9807
9807
|
async function Pe() {
|
|
9808
9808
|
d(S) !== "card" || !d(y) || !d(T) || d(k) || d(s) === "disabled" || (d(s) !== "loading" && (D(Y, L(d(s))), D(s, "loading")), await _r(async (F) => {
|
|
@@ -11879,7 +11879,7 @@ function ym(e) {
|
|
|
11879
11879
|
}
|
|
11880
11880
|
return r;
|
|
11881
11881
|
}
|
|
11882
|
-
const Gi = "1.
|
|
11882
|
+
const Gi = "1.9.0", bm = "https://api.revenuecat.com", hm = "https://e.revenue.cat";
|
|
11883
11883
|
var da;
|
|
11884
11884
|
(function(e) {
|
|
11885
11885
|
e[e.CONTINUE = 100] = "CONTINUE", e[e.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", e[e.PROCESSING = 102] = "PROCESSING", e[e.EARLY_HINTS = 103] = "EARLY_HINTS", e[e.OK = 200] = "OK", e[e.CREATED = 201] = "CREATED", e[e.ACCEPTED = 202] = "ACCEPTED", e[e.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", e[e.NO_CONTENT = 204] = "NO_CONTENT", e[e.RESET_CONTENT = 205] = "RESET_CONTENT", e[e.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", e[e.MULTI_STATUS = 207] = "MULTI_STATUS", e[e.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", e[e.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", e[e.MOVED_TEMPORARILY = 302] = "MOVED_TEMPORARILY", e[e.SEE_OTHER = 303] = "SEE_OTHER", e[e.NOT_MODIFIED = 304] = "NOT_MODIFIED", e[e.USE_PROXY = 305] = "USE_PROXY", e[e.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", e[e.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", e[e.BAD_REQUEST = 400] = "BAD_REQUEST", e[e.UNAUTHORIZED = 401] = "UNAUTHORIZED", e[e.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", e[e.FORBIDDEN = 403] = "FORBIDDEN", e[e.NOT_FOUND = 404] = "NOT_FOUND", e[e.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", e[e.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", e[e.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", e[e.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", e[e.CONFLICT = 409] = "CONFLICT", e[e.GONE = 410] = "GONE", e[e.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", e[e.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", e[e.REQUEST_TOO_LONG = 413] = "REQUEST_TOO_LONG", e[e.REQUEST_URI_TOO_LONG = 414] = "REQUEST_URI_TOO_LONG", e[e.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", e[e.REQUESTED_RANGE_NOT_SATISFIABLE = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE", e[e.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", e[e.IM_A_TEAPOT = 418] = "IM_A_TEAPOT", e[e.INSUFFICIENT_SPACE_ON_RESOURCE = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE", e[e.METHOD_FAILURE = 420] = "METHOD_FAILURE", e[e.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", e[e.UNPROCESSABLE_ENTITY = 422] = "UNPROCESSABLE_ENTITY", e[e.LOCKED = 423] = "LOCKED", e[e.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", e[e.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", e[e.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", e[e.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", e[e.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", e[e.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", e[e.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", e[e.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", e[e.BAD_GATEWAY = 502] = "BAD_GATEWAY", e[e.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", e[e.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", e[e.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", e[e.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", e[e.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
package/dist/Purchases.umd.js
CHANGED
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
@container layout-query-container (width >= 768px) {.rc-checkout-secure-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-container.svelte-dg9m6p {gap:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-pay-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-price-update-info-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}
|
|
244
|
-
}form.svelte-dg9m6p {display:flex;flex-direction:column;flex-grow:1;}`};function a_(e,r){var Es,Ts,Is;H(r,!0),R(e,t_);const t=Re(),a=()=>Be(o,"$translator",t),n=Ae(Dn),o=Ae(Ye),i=(Es=r.productDetails.subscriptionOptions)==null?void 0:Es[r.purchaseOption.id];let s=K(B(((Ts=r.defaultPriceBreakdown)==null?void 0:Ts.taxCalculationStatus)??((Is=r.brandingInfo)!=null&&Is.gateway_tax_collection_enabled?"unavailable":"disabled"))),l=K(null),c=K(null),u=K(B(r.productDetails.currentPrice.amountMicros)),p=K(B(r.productDetails.currentPrice.amountMicros)),_=E(()=>r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:d(p),totalExcludingTaxInMicros:d(u),taxCalculationStatus:d(s),taxAmountInMicros:d(l),taxBreakdown:d(c)}),g=K(B(r.gatewayParams.elements_configuration)),m=K(null),f=K(null),v=K(null),h=K(B(r.customerEmail??void 0)),y=K(B(!!r.customerEmail)),P=K(!0),I=K(!1),S=K(void 0),z=K(void 0),V=K(void 0),k=K(!1),w=K(null),q=E(()=>d(P)||d(k)?"loading":d(z)?"error":"form"),G=K("unavailable"),Y=E(()=>!d(k)&&d(I)&&d(y)&&(d(s)==="disabled"||d(s)==="calculated"||d(s)==="miss-match")),re=E(()=>i&&r.managementUrl&&d(_)?Ee.buildStripeExpressCheckoutOptionsForSubscription(r.productDetails,d(_),i,a(),r.managementUrl):void 0);dt(()=>{r.onPriceBreakdownUpdated(d(_))}),Qe(async()=>{d(s)==="unavailable"&&await Q(null).catch(cr)}),Rt(()=>{d(w)&&(d(w).abort(),D(w,null))});async function Q(F,ne){await r.purchaseOperationHelper.checkoutCalculateTax(F==null?void 0:F.countryCode,F==null?void 0:F.postalCode,ne).then(me=>{const at=lp({taxCalculation:me,taxCustomerDetails:F});n.trackSDKEvent(at),ne==null||ne.throwIfAborted(),me.failed_reason?!F&&me.failed_reason===Mn.invalid_tax_location?D(s,"pending"):D(s,"disabled"):D(s,"calculated"),D(l,B(me.tax_amount_in_micros)),D(u,B(me.total_excluding_tax_in_micros)),D(p,B(me.total_amount_in_micros)),D(c,B(me.pricing_phases.base.tax_breakdown)),D(g,B(me.gateway_params.elements_configuration)),D(m,B(F))})}function ie(){n.trackSDKEvent({eventName:Ve.CheckoutPaymentFormImpression}),D(P,!1)}async function fe(F,ne){D(h,B(ne)),D(y,B(F)),await je()}async function we({complete:F,paymentMethod:ne}){D(S,B(ne)),D(I,B(F)),await je()}async function _e(F){if(F==null||F.preventDefault(),d(k))return;const ne=cp({selectedPaymentMethod:d(S)??null});n.trackSDKEvent(ne),D(k,!0),await Vr()?r.onContinue():D(k,!1)}async function Fe(F,ne){D(S,B(F)),D(h,B(ne)),await _e()}async function je(){d(S)!=="card"||!d(y)||!d(I)||d(k)||d(s)==="disabled"||(d(s)!=="loading"&&(D(G,B(d(s))),D(s,"loading")),await zr(async F=>{await lr().then(()=>F.throwIfAborted()).then(()=>ar(F)).then(()=>F.throwIfAborted()).catch(ne=>{F.aborted||cr(ne)}).finally(()=>{d(s)==="loading"&&!F.aborted&&D(s,B(d(G)))})}))}async function Vr(){return await zr(async F=>{const ne=d(p);let me;return await lr().then(()=>F.throwIfAborted()).then(()=>ar(F)).then(at=>{me=at}).then(()=>F.throwIfAborted()).then(Hr(ne)).then(()=>F.throwIfAborted()).then(Pr).then(()=>F.throwIfAborted()).then(()=>Wr(me)).then(()=>F.throwIfAborted()).then(()=>!0).catch(at=>(F.aborted||cr(at),!1))})}async function zr(F){d(w)&&d(w).abort(),D(w,B(new AbortController));const ne=d(w).signal;try{return await F(ne)}catch(me){if(me instanceof DOMException&&me.name==="AbortError")return Promise.resolve(void 0);throw me}}async function lr(){d(v)&&await Ee.submitElements(d(v))}async function ar(F){var nt,ra;if(d(s)==="unavailable"||d(s)==="disabled"||!d(v)||!d(f))return;const{customerDetails:ne,confirmationTokenId:me}=await Ee.extractTaxCustomerDetails(d(v),d(f));return F==null||F.throwIfAborted(),ne.postalCode===((nt=d(m))==null?void 0:nt.postalCode)&&ne.countryCode===((ra=d(m))==null?void 0:ra.countryCode)||await Q(ne,F),me&&d(S)!=="card"?me:void 0}function Hr(F){return()=>{if(d(p)!==F)throw new Ri}}async function Pr(){var me;const F=await r.purchaseOperationHelper.checkoutComplete(d(h)),ne=(me=F==null?void 0:F.gateway_params)==null?void 0:me.client_secret;ne&&D(V,B(ne))}async function Wr(F){!d(f)||!d(v)||!d(V)||await Ee.confirmElements(d(f),d(v),d(V),F)}async function cr(F){if(F instanceof Ri)D(s,"miss-match");else if(F instanceof ge){const ne=ap({errorCode:F.errorCode.toString(),errorMessage:F.message});n.trackSDKEvent(ne),F.errorCode===de.MissingEmailError?D(z,B(a().translate(L.ErrorPageErrorMessageInvalidEmailError,{email:d(h)}))):r.onError(F)}else if(F instanceof Ma)await xt(F);else throw F}async function xt(F){const ne=dp({errorCode:F.gatewayErrorCode??"",errorMessage:F.message??""});n.trackSDKEvent(ne),F.code===Rn.HandledFormError||(F.code===Rn.UnhandledFormError?D(z,B(F.message)):r.onError(new ge(de.ErrorSettingUpPurchase,"Failed to initialize payment form",F.message)))}const Ua=()=>{D(z,void 0)};var Yr=r_(),ea=x(Yr);{var Va=F=>{var ne=e_(),me=x(ne);Fi(me),b(F,ne)};C(ea,F=>{d(q)==="loading"&&F(Va)})}var Ha=O(ea,2);{var Jn=F=>{var ne=E(()=>a().translate(L.ErrorButtonTryAgain));jn(F,{title:null,type:"error",get closeButtonTitle(){return d(ne)},onDismiss:Ua,icon:nt=>{ii(nt)},message:nt=>{var ra=ce();A(()=>oe(ra,d(z))),b(nt,ra)},$$slots:{icon:!0,message:!0}})};C(Ha,F=>{d(q)==="error"&&F(Jn)})}var Wa=O(Ha,2),Pt=x(Wa),Ya=x(Pt),tt=x(Ya),If=E(()=>!!r.customerEmail),qf=E(()=>d(s)!=="disabled");Yp(tt,{get stripeAccountId(){return r.gatewayParams.stripe_account_id},get publishableApiKey(){return r.gatewayParams.publishable_api_key},get elementsConfiguration(){return d(g)},get brandingInfo(){return r.brandingInfo},get skipEmail(){return d(If)},get billingAddressRequired(){return d(qf)},onLoadingComplete:ie,onError:xt,onEmailChange:fe,onPaymentInfoChange:we,onExpressCheckoutElementSubmit:Fe,get expressCheckoutOptions(){return d(re)},get stripe(){return d(f)},set stripe(F){D(f,B(F))},get elements(){return d(v)},set elements(F){D(v,B(F))}});var Qn=O(Ya,2),Ff=x(Qn);$p(Ff,{subscriptionOption:i});var Ps=O(Qn,2),Ss=x(Ps),zf=E(()=>!d(Y)),Df=E(()=>{var F;return(F=r.brandingInfo)!=null&&F.gateway_tax_collection_enabled?d(_):void 0});yp(Ss,{get disabled(){return d(zf)},subscriptionOption:i,get priceBreakdown(){return d(Df)}});var Af=O(Ss,2),jf=x(Af);rp(jf,{get brandingInfo(){return r.brandingInfo},subscriptionOption:i}),A(()=>{Er(Pt,"invisible",d(q)!=="form"),Er(Qn,"fully-hidden",d(s)!=="miss-match"||d(q)!=="form"),Er(Ps,"fully-hidden",d(q)!=="form")}),_t("submit",Wa,_e),b(e,Yr),W()}function n_(e){return e!=null}var Ui=(e=>(e.Unknown="unknown",e.Custom="custom",e.Lifetime="$rc_lifetime",e.Annual="$rc_annual",e.SixMonth="$rc_six_month",e.ThreeMonth="$rc_three_month",e.TwoMonth="$rc_two_month",e.Monthly="$rc_monthly",e.Weekly="$rc_weekly",e))(Ui||{}),Ur=(e=>(e.Subscription="subscription",e.Consumable="consumable",e.NonConsumable="non_consumable",e))(Ur||{});const Vi=e=>({amount:e.amount_micros/1e4,amountMicros:e.amount_micros,currency:e.currency,formattedPrice:Rr(e.amount_micros,e.currency)}),Hi=e=>{const r=e.period_duration,t=e.price?Vi(e.price):null,a=r?ai(r):null;let n=null,o=null,i=null;if(t!==null&&a!==null){const s=o_(a),l=1e4,c=Math.round(t.amountMicros*s.toWeek);n={amount:c/l,amountMicros:c,currency:t.currency,formattedPrice:Rr(c,t.currency)};const u=Math.round(t.amountMicros*s.toMonth);o={amount:u/l,amountMicros:u,currency:t.currency,formattedPrice:Rr(u,t.currency)};const p=Math.round(t.amountMicros*s.toYear);i={amount:p/l,amountMicros:p,currency:t.currency,formattedPrice:Rr(p,t.currency)}}return{periodDuration:r,period:a,cycleCount:e.cycle_count,price:t,pricePerWeek:n,pricePerMonth:o,pricePerYear:i}};function o_(e){const{number:r,unit:t}=e,a=7,n=30,o=365;let i;switch(t){case Se.Day:i=r;break;case Se.Week:i=r*a;break;case Se.Month:i=r*n;break;case Se.Year:i=r*o;break;default:i=0,$.errorLog(`Unknown period unit: ${t}`)}const s=i>0?a/i:0,l=i>0?n/i:0,c=i>0?o/i:0;return{toWeek:s,toMonth:l,toYear:c}}const i_=e=>e.base==null?($.debugLog("Missing base phase for subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,base:Hi(e.base),trial:e.trial?Hi(e.trial):null},s_=e=>e.base_price==null?($.debugLog("Missing base price for non-subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,basePrice:Vi(e.base_price)},l_=(e,r)=>{const t=e.product_type;return t==="subscription"?d_(e,r,t):c_(e,r,t)},c_=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([i,s])=>{const l=s_(s);l!=null&&(a[i]=l)}),Object.keys(a).length===0)return $.debugLog(`Product ${e.identifier} has no purchase options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in e.purchase_options?a[n]:null;return o==null?($.debugLog(`Product ${e.identifier} has no default purchase option. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:o.basePrice,normalPeriodDuration:null,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:null,subscriptionOptions:{},defaultNonSubscriptionOption:o}},d_=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([s,l])=>{const c=i_(l);c!=null&&(a[s]=c)}),Object.keys(a).length===0)return $.debugLog(`Product ${e.identifier} has no subscription options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in a?a[n]:null;if(o==null)return $.debugLog(`Product ${e.identifier} has no default subscription option. Ignoring.`),null;const i=o.base.price;return i==null?($.debugLog(`Product ${e.identifier} default option has no base price. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:i,normalPeriodDuration:o.base.periodDuration,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:o,subscriptionOptions:a,defaultNonSubscriptionOption:null}},u_=(e,r,t)=>{const a=t[r.platform_product_identifier];if(a===void 0)return null;const n=l_(a,e);return n===null?null:{identifier:r.identifier,rcBillingProduct:n,webBillingProduct:n,packageType:__(r.identifier)}},p_=(e,r,t,a)=>{const n={offeringIdentifier:r.identifier,targetingContext:e&&a?{ruleId:a.rule_id,revision:a.revision}:null,placementIdentifier:null},o=r.packages.map(s=>u_(n,s,t)).filter(n_),i={};for(const s of o)s!=null&&(i[s.identifier]=s);return o.length==0?null:{identifier:r.identifier,serverDescription:r.description,metadata:r.metadata,packagesById:i,availablePackages:o,lifetime:i.$rc_lifetime??null,annual:i.$rc_annual??null,sixMonth:i.$rc_six_month??null,threeMonth:i.$rc_three_month??null,twoMonth:i.$rc_two_month??null,monthly:i.$rc_monthly??null,weekly:i.$rc_weekly??null,paywall_components:r.paywall_components?r.paywall_components:null}};function __(e){switch(e){case"$rc_lifetime":return"$rc_lifetime";case"$rc_annual":return"$rc_annual";case"$rc_six_month":return"$rc_six_month";case"$rc_three_month":return"$rc_three_month";case"$rc_two_month":return"$rc_two_month";case"$rc_monthly":return"$rc_monthly";case"$rc_weekly":return"$rc_weekly";default:return e.startsWith("$rc_")?"unknown":"custom"}}var g_=_r('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.94 5.72656L8 8.7799L11.06 5.72656L12 6.66656L8 10.6666L4 6.66656L4.94 5.72656Z" class="arrow-fill svelte-1qexsu3" fill-opacity="0.7"></path></svg>');const m_={hash:"svelte-1qexsu3",code:".arrow.svelte-1qexsu3 {transition:transform 0.3s ease;}.arrow-fill.svelte-1qexsu3 {fill:var(--rc-color-grey-text-dark);}.arrow.left.svelte-1qexsu3 {transform:rotate(90deg);}.arrow.up.svelte-1qexsu3 {transform:rotate(180deg);}.arrow.right.svelte-1qexsu3 {transform:rotate(-90deg);}.arrow.down.svelte-1qexsu3 {transform:rotate(0deg);}"};function Na(e,r){R(e,m_);let t=U(r,"direction",8);var a=g_();A(()=>Ol(a,`arrow ${t()??""} svelte-1qexsu3`)),b(e,a)}var f_=_r('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="arrow"><path d="M15.41 7.41L14 6L8 12L14 18L15.41 16.59L10.83 12L15.41 7.41Z" class="arrow-fill svelte-r0zny8" fill-opacity="0.7"></path></svg>');const y_={hash:"svelte-r0zny8",code:".arrow-fill.svelte-r0zny8 {fill:var(--rc-color-grey-text-dark);}"};function b_(e){R(e,y_);var r=f_();b(e,r)}const h_=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"
|
|
244
|
+
}form.svelte-dg9m6p {display:flex;flex-direction:column;flex-grow:1;}`};function a_(e,r){var Es,Ts,Is;H(r,!0),R(e,t_);const t=Re(),a=()=>Be(o,"$translator",t),n=Ae(Dn),o=Ae(Ye),i=(Es=r.productDetails.subscriptionOptions)==null?void 0:Es[r.purchaseOption.id];let s=K(B(((Ts=r.defaultPriceBreakdown)==null?void 0:Ts.taxCalculationStatus)??((Is=r.brandingInfo)!=null&&Is.gateway_tax_collection_enabled?"unavailable":"disabled"))),l=K(null),c=K(null),u=K(B(r.productDetails.currentPrice.amountMicros)),p=K(B(r.productDetails.currentPrice.amountMicros)),_=E(()=>r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:d(p),totalExcludingTaxInMicros:d(u),taxCalculationStatus:d(s),taxAmountInMicros:d(l),taxBreakdown:d(c)}),g=K(B(r.gatewayParams.elements_configuration)),m=K(null),f=K(null),v=K(null),h=K(B(r.customerEmail??void 0)),y=K(B(!!r.customerEmail)),P=K(!0),I=K(!1),S=K(void 0),z=K(void 0),V=K(void 0),k=K(!1),w=K(null),q=E(()=>d(P)||d(k)?"loading":d(z)?"error":"form"),G=K("unavailable"),Y=E(()=>!d(k)&&d(I)&&d(y)&&(d(s)==="disabled"||d(s)==="calculated"||d(s)==="miss-match")),re=E(()=>i&&r.managementUrl&&d(_)?Ee.buildStripeExpressCheckoutOptionsForSubscription(r.productDetails,d(_),i,a(),r.managementUrl):void 0);dt(()=>{r.onPriceBreakdownUpdated(d(_))}),Qe(async()=>{d(s)==="unavailable"&&await Q(null).catch(cr)}),Rt(()=>{d(w)&&(d(w).abort(),D(w,null))});async function Q(F,ne){await r.purchaseOperationHelper.checkoutCalculateTax(F==null?void 0:F.countryCode,F==null?void 0:F.postalCode,ne).then(me=>{const at=lp({taxCalculation:me,taxCustomerDetails:F});n.trackSDKEvent(at),ne==null||ne.throwIfAborted(),me.failed_reason?!F&&me.failed_reason===Mn.invalid_tax_location?D(s,"pending"):D(s,"disabled"):D(s,"calculated"),D(l,B(me.tax_amount_in_micros)),D(u,B(me.total_excluding_tax_in_micros)),D(p,B(me.total_amount_in_micros)),D(c,B(me.pricing_phases.base.tax_breakdown)),D(g,B(me.gateway_params.elements_configuration)),D(m,B(F))})}function ie(){n.trackSDKEvent({eventName:Ve.CheckoutPaymentFormImpression}),D(P,!1)}async function fe(F,ne){D(h,B(ne)),D(y,B(F)),await je()}async function we({complete:F,paymentMethod:ne}){D(S,B(ne)),D(I,B(F)),await je()}async function _e(F){if(F==null||F.preventDefault(),d(k))return;const ne=cp({selectedPaymentMethod:d(S)??null});n.trackSDKEvent(ne),D(k,!0),await Vr()?r.onContinue():D(k,!1)}async function Fe(F,ne){D(S,B(F)),D(h,B(r.customerEmail??ne)),await _e()}async function je(){d(S)!=="card"||!d(y)||!d(I)||d(k)||d(s)==="disabled"||(d(s)!=="loading"&&(D(G,B(d(s))),D(s,"loading")),await zr(async F=>{await lr().then(()=>F.throwIfAborted()).then(()=>ar(F)).then(()=>F.throwIfAborted()).catch(ne=>{F.aborted||cr(ne)}).finally(()=>{d(s)==="loading"&&!F.aborted&&D(s,B(d(G)))})}))}async function Vr(){return await zr(async F=>{const ne=d(p);let me;return await lr().then(()=>F.throwIfAborted()).then(()=>ar(F)).then(at=>{me=at}).then(()=>F.throwIfAborted()).then(Hr(ne)).then(()=>F.throwIfAborted()).then(Pr).then(()=>F.throwIfAborted()).then(()=>Wr(me)).then(()=>F.throwIfAborted()).then(()=>!0).catch(at=>(F.aborted||cr(at),!1))})}async function zr(F){d(w)&&d(w).abort(),D(w,B(new AbortController));const ne=d(w).signal;try{return await F(ne)}catch(me){if(me instanceof DOMException&&me.name==="AbortError")return Promise.resolve(void 0);throw me}}async function lr(){d(v)&&await Ee.submitElements(d(v))}async function ar(F){var nt,ra;if(d(s)==="unavailable"||d(s)==="disabled"||!d(v)||!d(f))return;const{customerDetails:ne,confirmationTokenId:me}=await Ee.extractTaxCustomerDetails(d(v),d(f));return F==null||F.throwIfAborted(),ne.postalCode===((nt=d(m))==null?void 0:nt.postalCode)&&ne.countryCode===((ra=d(m))==null?void 0:ra.countryCode)||await Q(ne,F),me&&d(S)!=="card"?me:void 0}function Hr(F){return()=>{if(d(p)!==F)throw new Ri}}async function Pr(){var me;const F=await r.purchaseOperationHelper.checkoutComplete(d(h)),ne=(me=F==null?void 0:F.gateway_params)==null?void 0:me.client_secret;ne&&D(V,B(ne))}async function Wr(F){!d(f)||!d(v)||!d(V)||await Ee.confirmElements(d(f),d(v),d(V),F)}async function cr(F){if(F instanceof Ri)D(s,"miss-match");else if(F instanceof ge){const ne=ap({errorCode:F.errorCode.toString(),errorMessage:F.message});n.trackSDKEvent(ne),F.errorCode===de.MissingEmailError?D(z,B(a().translate(L.ErrorPageErrorMessageInvalidEmailError,{email:d(h)}))):r.onError(F)}else if(F instanceof Ma)await xt(F);else throw F}async function xt(F){const ne=dp({errorCode:F.gatewayErrorCode??"",errorMessage:F.message??""});n.trackSDKEvent(ne),F.code===Rn.HandledFormError||(F.code===Rn.UnhandledFormError?D(z,B(F.message)):r.onError(new ge(de.ErrorSettingUpPurchase,"Failed to initialize payment form",F.message)))}const Ua=()=>{D(z,void 0)};var Yr=r_(),ea=x(Yr);{var Va=F=>{var ne=e_(),me=x(ne);Fi(me),b(F,ne)};C(ea,F=>{d(q)==="loading"&&F(Va)})}var Ha=O(ea,2);{var Jn=F=>{var ne=E(()=>a().translate(L.ErrorButtonTryAgain));jn(F,{title:null,type:"error",get closeButtonTitle(){return d(ne)},onDismiss:Ua,icon:nt=>{ii(nt)},message:nt=>{var ra=ce();A(()=>oe(ra,d(z))),b(nt,ra)},$$slots:{icon:!0,message:!0}})};C(Ha,F=>{d(q)==="error"&&F(Jn)})}var Wa=O(Ha,2),Pt=x(Wa),Ya=x(Pt),tt=x(Ya),If=E(()=>!!r.customerEmail),qf=E(()=>d(s)!=="disabled");Yp(tt,{get stripeAccountId(){return r.gatewayParams.stripe_account_id},get publishableApiKey(){return r.gatewayParams.publishable_api_key},get elementsConfiguration(){return d(g)},get brandingInfo(){return r.brandingInfo},get skipEmail(){return d(If)},get billingAddressRequired(){return d(qf)},onLoadingComplete:ie,onError:xt,onEmailChange:fe,onPaymentInfoChange:we,onExpressCheckoutElementSubmit:Fe,get expressCheckoutOptions(){return d(re)},get stripe(){return d(f)},set stripe(F){D(f,B(F))},get elements(){return d(v)},set elements(F){D(v,B(F))}});var Qn=O(Ya,2),Ff=x(Qn);$p(Ff,{subscriptionOption:i});var Ps=O(Qn,2),Ss=x(Ps),zf=E(()=>!d(Y)),Df=E(()=>{var F;return(F=r.brandingInfo)!=null&&F.gateway_tax_collection_enabled?d(_):void 0});yp(Ss,{get disabled(){return d(zf)},subscriptionOption:i,get priceBreakdown(){return d(Df)}});var Af=O(Ss,2),jf=x(Af);rp(jf,{get brandingInfo(){return r.brandingInfo},subscriptionOption:i}),A(()=>{Er(Pt,"invisible",d(q)!=="form"),Er(Qn,"fully-hidden",d(s)!=="miss-match"||d(q)!=="form"),Er(Ps,"fully-hidden",d(q)!=="form")}),_t("submit",Wa,_e),b(e,Yr),W()}function n_(e){return e!=null}var Ui=(e=>(e.Unknown="unknown",e.Custom="custom",e.Lifetime="$rc_lifetime",e.Annual="$rc_annual",e.SixMonth="$rc_six_month",e.ThreeMonth="$rc_three_month",e.TwoMonth="$rc_two_month",e.Monthly="$rc_monthly",e.Weekly="$rc_weekly",e))(Ui||{}),Ur=(e=>(e.Subscription="subscription",e.Consumable="consumable",e.NonConsumable="non_consumable",e))(Ur||{});const Vi=e=>({amount:e.amount_micros/1e4,amountMicros:e.amount_micros,currency:e.currency,formattedPrice:Rr(e.amount_micros,e.currency)}),Hi=e=>{const r=e.period_duration,t=e.price?Vi(e.price):null,a=r?ai(r):null;let n=null,o=null,i=null;if(t!==null&&a!==null){const s=o_(a),l=1e4,c=Math.round(t.amountMicros*s.toWeek);n={amount:c/l,amountMicros:c,currency:t.currency,formattedPrice:Rr(c,t.currency)};const u=Math.round(t.amountMicros*s.toMonth);o={amount:u/l,amountMicros:u,currency:t.currency,formattedPrice:Rr(u,t.currency)};const p=Math.round(t.amountMicros*s.toYear);i={amount:p/l,amountMicros:p,currency:t.currency,formattedPrice:Rr(p,t.currency)}}return{periodDuration:r,period:a,cycleCount:e.cycle_count,price:t,pricePerWeek:n,pricePerMonth:o,pricePerYear:i}};function o_(e){const{number:r,unit:t}=e,a=7,n=30,o=365;let i;switch(t){case Se.Day:i=r;break;case Se.Week:i=r*a;break;case Se.Month:i=r*n;break;case Se.Year:i=r*o;break;default:i=0,$.errorLog(`Unknown period unit: ${t}`)}const s=i>0?a/i:0,l=i>0?n/i:0,c=i>0?o/i:0;return{toWeek:s,toMonth:l,toYear:c}}const i_=e=>e.base==null?($.debugLog("Missing base phase for subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,base:Hi(e.base),trial:e.trial?Hi(e.trial):null},s_=e=>e.base_price==null?($.debugLog("Missing base price for non-subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,basePrice:Vi(e.base_price)},l_=(e,r)=>{const t=e.product_type;return t==="subscription"?d_(e,r,t):c_(e,r,t)},c_=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([i,s])=>{const l=s_(s);l!=null&&(a[i]=l)}),Object.keys(a).length===0)return $.debugLog(`Product ${e.identifier} has no purchase options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in e.purchase_options?a[n]:null;return o==null?($.debugLog(`Product ${e.identifier} has no default purchase option. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:o.basePrice,normalPeriodDuration:null,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:null,subscriptionOptions:{},defaultNonSubscriptionOption:o}},d_=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([s,l])=>{const c=i_(l);c!=null&&(a[s]=c)}),Object.keys(a).length===0)return $.debugLog(`Product ${e.identifier} has no subscription options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in a?a[n]:null;if(o==null)return $.debugLog(`Product ${e.identifier} has no default subscription option. Ignoring.`),null;const i=o.base.price;return i==null?($.debugLog(`Product ${e.identifier} default option has no base price. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:i,normalPeriodDuration:o.base.periodDuration,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:o,subscriptionOptions:a,defaultNonSubscriptionOption:null}},u_=(e,r,t)=>{const a=t[r.platform_product_identifier];if(a===void 0)return null;const n=l_(a,e);return n===null?null:{identifier:r.identifier,rcBillingProduct:n,webBillingProduct:n,packageType:__(r.identifier)}},p_=(e,r,t,a)=>{const n={offeringIdentifier:r.identifier,targetingContext:e&&a?{ruleId:a.rule_id,revision:a.revision}:null,placementIdentifier:null},o=r.packages.map(s=>u_(n,s,t)).filter(n_),i={};for(const s of o)s!=null&&(i[s.identifier]=s);return o.length==0?null:{identifier:r.identifier,serverDescription:r.description,metadata:r.metadata,packagesById:i,availablePackages:o,lifetime:i.$rc_lifetime??null,annual:i.$rc_annual??null,sixMonth:i.$rc_six_month??null,threeMonth:i.$rc_three_month??null,twoMonth:i.$rc_two_month??null,monthly:i.$rc_monthly??null,weekly:i.$rc_weekly??null,paywall_components:r.paywall_components?r.paywall_components:null}};function __(e){switch(e){case"$rc_lifetime":return"$rc_lifetime";case"$rc_annual":return"$rc_annual";case"$rc_six_month":return"$rc_six_month";case"$rc_three_month":return"$rc_three_month";case"$rc_two_month":return"$rc_two_month";case"$rc_monthly":return"$rc_monthly";case"$rc_weekly":return"$rc_weekly";default:return e.startsWith("$rc_")?"unknown":"custom"}}var g_=_r('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.94 5.72656L8 8.7799L11.06 5.72656L12 6.66656L8 10.6666L4 6.66656L4.94 5.72656Z" class="arrow-fill svelte-1qexsu3" fill-opacity="0.7"></path></svg>');const m_={hash:"svelte-1qexsu3",code:".arrow.svelte-1qexsu3 {transition:transform 0.3s ease;}.arrow-fill.svelte-1qexsu3 {fill:var(--rc-color-grey-text-dark);}.arrow.left.svelte-1qexsu3 {transform:rotate(90deg);}.arrow.up.svelte-1qexsu3 {transform:rotate(180deg);}.arrow.right.svelte-1qexsu3 {transform:rotate(-90deg);}.arrow.down.svelte-1qexsu3 {transform:rotate(0deg);}"};function Na(e,r){R(e,m_);let t=U(r,"direction",8);var a=g_();A(()=>Ol(a,`arrow ${t()??""} svelte-1qexsu3`)),b(e,a)}var f_=_r('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="arrow"><path d="M15.41 7.41L14 6L8 12L14 18L15.41 16.59L10.83 12L15.41 7.41Z" class="arrow-fill svelte-r0zny8" fill-opacity="0.7"></path></svg>');const y_={hash:"svelte-r0zny8",code:".arrow-fill.svelte-r0zny8 {fill:var(--rc-color-grey-text-dark);}"};function b_(e){R(e,y_);var r=f_();b(e,r)}const h_=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"
|
|
245
245
|
xmlns="http://www.w3.org/2000/svg">
|
|
246
246
|
<g opacity="0.5" clip-path="url(#clip0_344_3390)">
|
|
247
247
|
<path d="M7 18C5.9 18 5.01 18.9 5.01 20C5.01 21.1 5.9 22 7 22C8.1 22 9 21.1 9 20C9 18.9 8.1 18 7 18ZM1 2V4H3L6.6 11.59L5.25 14.04C5.09 14.32 5 14.65 5 15C5 16.1 5.9 17 7 17H19V15H7.42C7.28 15 7.17 14.89 7.17 14.75L7.2 14.63L8.1 13H15.55C16.3 13 16.96 12.59 17.3 11.97L20.88 5.48C20.96 5.34 21 5.17 21 5C21 4.45 20.55 4 20 4H5.21L4.27 2H1ZM17 18C15.9 18 15.01 18.9 15.01 20C15.01 21.1 15.9 22 17 22C18.1 22 19 21.1 19 20C19 18.9 18.1 18 17 18Z"
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
@container layout-query-container (width >= 768px) {.rcb-close-wrapper.svelte-11zapuq {display:none;}.rcb-back-wrapper.svelte-11zapuq {position:absolute;left:-48px;margin-left:0;}
|
|
337
|
-
}`};function tm(e,r){H(r,!0),R(e,rm);const t=k=>k==null||k==null||k==""?null:k,a=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon)}),n=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon_webp)}),o=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark)}),i=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark_webp)}),s=E(()=>d(a)?Jt(d(a)):null),l=E(()=>d(n)?Jt(d(n)):null),c=E(()=>d(o)?Jt(d(o)):null),u=E(()=>d(i)?Jt(d(i)):null),p=()=>{r.onClose&&r.onClose()};var _=em(),g=x(_);{var m=k=>{var w=Qg(),q=x(w);Gg(q,{$$events:{click:p}}),b(k,w)};C(g,k=>{r.showCloseButton&&k(m)})}var f=O(g,2),v=x(f),h=x(v);{var y=k=>{Jg(k,{get src(){return d(c)},get srcWebp(){return d(u)}})},P=k=>{var w=ae(),q=X(w);{var G=Y=>{Hg(Y,{get src(){return d(s)},get srcWebp(){return d(l)}})};C(q,Y=>{d(s)!==null&&d(l)!==null&&Y(G)},!0)}b(k,w)};C(h,k=>{d(c)!==null?k(y):k(P,!1)})}var I=O(h,2);{var S=k=>{ue(k,{size:"body-base",children:(w,q)=>{var G=ce();A(()=>{var Y;return oe(G,(Y=r.brandingInfo)==null?void 0:Y.app_name)}),b(w,G)},$$slots:{default:!0}})};C(I,k=>{d(c)===null&&k(S)})}var z=O(f,2);{var V=k=>{var w=$g(),q=x(w);Xi(q,{$$events:{click:p}}),b(k,w)};C(z,k=>{r.showCloseButton&&k(V)})}A(()=>Er(_,"rcb-with-close-button",r.showCloseButton)),b(e,_),W()}var am=T("<!> <!> <!> <!>",1);function nm(e,r){H(r,!0);const t=U(r,"onClose",3,void 0);let a=K(B(r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:r.productDetails.currentPrice.amountMicros,totalExcludingTaxInMicros:r.productDetails.currentPrice.amountMicros,taxCalculationStatus:"unavailable",taxAmountInMicros:null,taxBreakdown:null}));const n=o=>{D(a,B(o))};Lg(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var c=E(()=>!r.isInElement&&!!t());tm(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return d(c)}})},navbarBodyContent:l=>{var c=E(()=>{var u,p;return((p=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:p.show_product_description)??!1});dg(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return d(c)},get priceBreakdown(){return d(a)}})},mainContent:l=>{var c=am(),u=X(c);{var p=y=>{O_(y)};C(u,y=>{r.currentPage==="payment-entry-loading"&&y(p)})}var _=O(u,2);{var g=y=>{a_(y,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get brandingInfo(){return r.brandingInfo},get purchaseOperationHelper(){return r.purchaseOperationHelper},get gatewayParams(){return r.gatewayParams},get managementUrl(){return r.managementUrl},get customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};C(_,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(_,2);{var f=y=>{var P=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.support_email)??null}),I=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.app_name)??null});N_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return d(P)},get onDismiss(){return r.closeWithError},get appName(){return d(I)}})};C(m,y=>{r.currentPage==="error"&&y(f)})}var v=O(m,2);{var h=y=>{C_(y,{get onContinue(){return r.onContinue}})};C(v,y=>{r.currentPage==="success"&&y(h)})}b(l,c)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),W()}function om(e){return e.trim()===""?"You need to provide your email address to continue.":e.match(/^[^@]+@[^@]+\.[^@]+$/)?null:"Email is not valid. Please provide a valid email address."}function im(e){if(e&&!e.match(/^[A-Z]{3}$/)){const r=`Currency code ${e} is not valid. Please provide a valid ISO 4217 currency code.`;throw $.errorLog(r),new be(xe.ConfigurationError,r)}}function sm(e,r){var k;H(r,!0);const t=U(r,"customTranslations",19,()=>({})),a=U(r,"skipSuccessPage",3,!1),n=r.customerEmail?om(r.customerEmail):null;let o=K(B(n?void 0:r.customerEmail)),i=r.rcPackage.webBillingProduct,s=K(null);const l=r.rcPackage.webBillingProduct.identifier??null;let c=K("payment-entry-loading"),u=K(null),p=K(null),_=K(B({})),g=K(null),m=K(null),f=K(null),v=K(null),h=new Pa(t(),r.selectedLocale,r.defaultLocale);var y=li(h);un(Ye,y),un(An,(k=r.brandingInfo)==null?void 0:k.appearance),Qe(()=>{r.isInElement||(D(m,B(document.documentElement.style.height)),D(f,B(document.documentElement.style.overflow)),D(v,B(document.body.style.height)),document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Rt(()=>{if(!r.isInElement){const w=(q,G,Y)=>{Y===""?q.style.removeProperty(G):q.style.setProperty(G,Y)};w(document.documentElement,"height",d(m)),w(document.body,"height",d(v)),w(document.documentElement,"overflow",d(f))}}),un(Dn,r.eventsTracker),Qe(async()=>{if(l===null){I(new ge(de.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,l,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(o),r.metadata).then(w=>{D(s,null),D(c,"payment-entry"),D(_,B(w.gateway_params)),D(g,B(w.management_url))}).catch(w=>{if(w.errorCode===de.MissingEmailError)return D(o,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,l,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(o),r.metadata).then(q=>{D(s,null),D(c,"payment-entry"),D(_,B(q.gateway_params)),D(g,B(q.management_url))}).catch(q=>{I(q)});I(w)})});const P=()=>{if(d(c)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(w=>{D(u,B(w.redemptionInfo)),D(p,B(w.operationSessionId)),a()?r.onFinished(d(p),d(u)):D(c,"success")}).catch(w=>{I(w)});return}if(d(c)==="success"||d(c)==="error"){r.onFinished(d(p),d(u));return}D(c,"success")},I=w=>{const q=tp({errorCode:w.getErrorCode().toString(),errorMessage:w.message});r.eventsTracker.trackSDKEvent(q),D(s,B(w)),D(c,"error")},S=()=>{r.onError(d(s)??new ge(de.UnknownError,"Unknown error without state set."))};var z=E(()=>r.purchases.isSandbox()),V=E(()=>d(o)??null);nm(e,{get isSandbox(){return d(z)},get currentPage(){return d(c)},get brandingInfo(){return r.brandingInfo},productDetails:i,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return d(s)},get gatewayParams(){return d(_)},get managementUrl(){return d(g)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return d(V)},closeWithError:S,onContinue:P,onError:I,get onClose(){return r.onClose}}),W()}function Zi(e){return e==null?!0:new Date(e)>new Date}function lm(e,r,t,a){const n=r.product_identifier;if(n in t)return cm(e,r,t[n]);if(n in a)return dm(e,r,a[n]);throw new be(xe.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function cm(e,r,t){return{identifier:e,isActive:Zi(r.expires_date),willRenew:Ki(r.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:xr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:xr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:xr(t==null?void 0:t.billing_issues_detected_at),isSandbox:(t==null?void 0:t.is_sandbox)??!1,periodType:(t==null?void 0:t.period_type)??"normal",ownershipType:(t==null?void 0:t.ownership_type)??"UNKNOWN"}}function dm(e,r,t){return{identifier:e,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:r.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function um(e,r,t){const a={},n={};for(const o in e){const i=lm(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function xr(e){return e==null?null:new Date(e)}function pm(e){const r=gm(e),t=e.subscriber,a=fm(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(c=>({transactionIdentifier:c.id,productIdentifier:s,purchaseDate:new Date(c.purchase_date||c.original_purchase_date),storeTransactionId:c.store_transaction_id||null,store:c.store}))),o=new Date(e.request_date),i=Object.fromEntries(Object.entries(e.subscriber.subscriptions).map(([s,l])=>[s,{productIdentifier:s,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:xr(l.original_purchase_date),expiresDate:xr(l.expires_date),store:l.store,unsubscribeDetectedAt:xr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:xr(l.billing_issues_detected_at),gracePeriodExpiresDate:xr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:xr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Zi(l.expires_date),willRenew:Ki(l.expires_date,l)}]));return{entitlements:um(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:_m(e,a),activeSubscriptions:mm(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:xr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Ki(e,r){if(r==null)return!1;const t=r.store=="promotional",a=e==null,n=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||a||n||o)}function _m(e,r){const t={};for(const a in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[a];t[a]=new Date(n.purchase_date)}for(const a in r){const n=r[a].purchase_date;n==null?t[a]=null:t[a]=new Date(n)}return t}function gm(e){const r={};for(const t in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[t];a.expires_date==null?r[t]=null:r[t]=new Date(a.expires_date)}return r}function mm(e){const r=new Set,t=new Date;for(const a in e){const n=e[a];(n==null||n>t)&&r.add(a)}return r}function fm(e){const r={};for(const t in e){if(e[t].length===0)continue;const a=e[t].length;r[t]=e[t][a-1]}return r}const Ji="1.8.0",ym="https://api.revenuecat.com",bm="https://e.revenue.cat";var Ca;(function(e){e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.MULTI_STATUS=207]="MULTI_STATUS",e[e.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.USE_PROXY=305]="USE_PROXY",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",e[e.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.IM_A_TEAPOT=418]="IM_A_TEAPOT",e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",e[e.METHOD_FAILURE=420]="METHOD_FAILURE",e[e.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.LOCKED=423]="LOCKED",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e[e.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",e[e.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Ca||(Ca={}));function Oa(e){return e?e.startsWith("rcb_sb_"):!1}async function Fr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??ym}${e.urlPath()}`;try{const c=await fetch(l,{method:e.method,headers:is(a,o,i==null?void 0:i.additionalHeaders),body:vm(n),signal:t});return await hm(c,e),await c.json()}catch(c){throw c instanceof TypeError?new be(xe.NetworkError,Ut.getPublicMessage(xe.NetworkError),c.message):c}}async function hm(e,r){const t=e.status;if(t>=Ca.INTERNAL_SERVER_ERROR)Un(r,t,await e.text());else if(t>=Ca.BAD_REQUEST){const a=await e.json(),n=a?JSON.stringify(a):null,o=a==null?void 0:a.code,i=a==null?void 0:a.message;if(o!=null){const s=Ut.convertCodeToBackendErrorCode(o);if(s==null)Un(r,t,n,o);else throw be.getForBackendError(s,i)}else Un(r,t,n)}}function Un(e,r,t,a){throw new be(xe.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function vm(e){return e==null?null:JSON.stringify(e)}const Qi="Authorization",$i="Content-Type",es="Accept",rs="X-Platform",ts="X-Version",as="X-Platform-Flavor",ns="X-Platform-Flavor-Version",os="X-Is-Sandbox",km=new Set([Qi,$i,es,rs,ts,os,as,ns]);function is(e,r,t){let a={[Qi]:`Bearer ${e}`,[$i]:"application/json",[es]:"application/json",[rs]:"web",[ts]:Ji,[os]:`${Oa(e)}`};const n=La.getPlatformInfo();if(n){const o={[as]:n.flavor,[ns]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const Vn="/v1/subscribers",kt="/rcbilling/v1";class wm{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/offerings`}}class xm{constructor(r,t,a){j(this,"method","GET");j(this,"name","getProducts");j(this,"appUserId");j(this,"productIds");j(this,"currency");this.appUserId=r,this.productIds=t,this.currency=a}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),a=this.currency?`¤cy=${this.currency}`:"";return`${kt}/subscribers/${r}/products?id=${t}${a}`}}class Pm{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}`}}class Sm{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${kt}/branding`}}class Em{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${kt}/checkout/start`}}class Tm{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/calculate_taxes`}}class Im{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/complete`}}class qm{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}`}}class Fm{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/attributes`}}const Hn={};class zm{constructor(r,t=Hn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Oa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Fr(new wm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Fr(new Pm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Fr(new xm(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Fr(new Sm,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutStart(r,t,a,n,o,i,s=void 0){const l={app_user_id:r,product_id:t,email:i,price_id:n.priceId,presented_offering_identifier:a.offeringIdentifier,trace_id:o};return s&&(l.metadata=s),n.id!=="base_option"&&(l.offer_id=n.id),a.targetingContext&&(l.applied_targeting_rule={rule_id:a.targetingContext.ruleId,revision:a.targetingContext.revision}),a.placementIdentifier&&(l.presented_placement_identifier=a.placementIdentifier),await Fr(new Em,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async postCheckoutCalculateTax(r,t,a,n){const o={country_code:t,postal_code:a};return await Fr(new Tm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Fr(new Im(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Fr(new qm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(r,t){const a=Date.now(),n={};for(const[i,s]of Object.entries(t))n[i]={value:s,updated_at_ms:a};const o={attributes:n};return await Fr(new Fm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Dm(e){const r=/^rcb_[a-zA-Z0-9_.-]+$/,t=/^pdl_[a-zA-Z0-9_.-]+$/;if(!r.test(e)&&!t.test(e))throw new be(xe.InvalidCredentialsError,"Invalid API key. Use your Web Billing or Paddle API key.")}function ss(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new be(xe.InvalidAppUserIdError,'Provided user id: "'+(e??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function Am(e){if(e!=null&&e.endsWith("/"))throw new be(xe.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function jm(e){if(e){for(const r in e)if(km.has(r))throw new be(xe.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Wn=(e=>(e.Current="current",e))(Wn||{});function Mm(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const ls=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},rt=(e,r)=>e==null?null:ls(e,r),Nm=(e,r,t)=>{const a=e.offering_ids_by_placement??null;if(a==null)return null;const n=e.fallback_offering_id??null;let o;if(t in a){const s=a[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[n])}else o=r[n];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,ls(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:rt(o.weekly,t),monthly:rt(o.monthly,t),twoMonth:rt(o.twoMonth,t),threeMonth:rt(o.threeMonth,t),sixMonth:rt(o.sixMonth,t),annual:rt(o.annual,t),lifetime:rt(o.lifetime,t)}};function Cm(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const a={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=p_(i,o,t,e.targeting);s!=null&&(a[o.identifier]=s)});const n=e.current_offering_id?a[e.current_offering_id]??null:null;return Object.keys(a).length==0&&$.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:a,current:n}}const Om=1000001;function Lm(e){return e.webBillingProduct.defaultPurchaseOption}function cs(e,r,t,a=!1){return t.translate(L.PaywallVariablesPricePerPeriod,{formattedPrice:e,period:r.base.period?t.translatePeriod(r.base.period.number,r.base.period.unit,{noWhitespace:!0,short:!a}):""})}function Bm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,Se.Month):r.translatePeriod(e.number,e.unit)}function Rm({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return r?r.unit==="year"?t.formatPrice(e.amountMicros/12/4,e.currency):r.unit==="month"||r.unit==="week"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*7/r.number,e.currency):a:a}function Um({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return!r||!r.number?a:r.unit==="year"?t.formatPrice(e.amountMicros/12,e.currency):r.unit==="month"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="week"?t.formatPrice(e.amountMicros*4/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*30/r.number,e.currency):a}function ds({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===Se.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case Se.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case Se.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case Se.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case Se.Day:n=a.formatPrice(e.amountMicros*30/r.number,e.currency);break}return a.translate(L.PaywallVariablesTotalPriceAndPerMonth,{formattedPrice:a.formatPrice(e.amountMicros,e.currency),period:a.translatePeriod(r.number,r.unit,{noWhitespace:!0,short:!t}),formattedPricePerMonth:n,monthPeriod:a.translatePeriodUnit(Se.Month,{noWhitespace:!0,short:!t})})}function Vm(e,r){const t=e.availablePackages,a=t.reduce((n,o)=>n.webBillingProduct.currentPrice.amountMicros>o.webBillingProduct.currentPrice.amountMicros?n:o);return t.reduce((n,o)=>(n[o.identifier]=Hm(o,a,r),n),{})}function Hm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=Lm(e),i=a.productType,s={product_name:a.title,price:n,price_per_period:"",price_per_period_full:"",total_price_and_per_month:"",total_price_and_per_month_full:"",sub_price_per_month:"",sub_price_per_week:"",sub_duration:"",sub_duration_in_months:"",sub_period:"",sub_period_length:"",sub_period_abbreviated:"",sub_offer_duration:void 0,sub_offer_duration_2:void 0,sub_offer_price:void 0,sub_offer_price_2:void 0,sub_relative_discount:""};if(i===Ur.Subscription&&o){s.price_per_period=cs(n,o,t),s.price_per_period_full=cs(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=ds({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=ds({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=Um({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=Rm({price:a.currentPrice,period:l,translator:t}),s.sub_duration=t.translatePeriod(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_duration_in_months=Bm(l,t),s.sub_period=t.translatePeriodFrequency(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_period_length=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0}):void 0,s.sub_period_abbreviated=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0,short:!0}):void 0;const c=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,p=((u-c)*100/u).toFixed(0);s.sub_relative_discount=c===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:p})}return(i===Ur.NonConsumable||i===Ur.Consumable)&&o&&(s.price=n,s.price_per_period=n,s.price_per_period_full=n,s.total_price_and_per_month=n,s.sub_price_per_month=n,s.sub_duration=t.translate(L.PeriodsLifetime),s.sub_duration_in_months=t.translate(L.PeriodsLifetime),s.sub_period=t.translate(L.PeriodsLifetime),s.sub_price_per_week=void 0,s.sub_relative_discount=void 0,s.price_per_period_full=n,s.total_price_and_per_month_full=n,s.sub_period_length=void 0,s.sub_period_abbreviated=void 0),s}const qe=[];for(let e=0;e<256;++e)qe.push((e+256).toString(16).slice(1));function Wm(e,r=0){return(qe[e[r+0]]+qe[e[r+1]]+qe[e[r+2]]+qe[e[r+3]]+"-"+qe[e[r+4]]+qe[e[r+5]]+"-"+qe[e[r+6]]+qe[e[r+7]]+"-"+qe[e[r+8]]+qe[e[r+9]]+"-"+qe[e[r+10]]+qe[e[r+11]]+qe[e[r+12]]+qe[e[r+13]]+qe[e[r+14]]+qe[e[r+15]]).toLowerCase()}let Yn;const Ym=new Uint8Array(16);function Gm(){if(!Yn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yn=crypto.getRandomValues.bind(crypto)}return Yn(Ym)}const us={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ps(e,r,t){var n;if(us.randomUUID&&!e)return us.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??Gm();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Wm(a)}var Xm=/(%?)(%([sdijo]))/g;function Zm(e,r){switch(r){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const t=JSON.stringify(e);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?e:t}}}function Gn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(Xm,(n,o,i,s)=>{const l=r[t],c=Zm(l,s);return o?n:(t++,c)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var Km=2;function Jm(e){if(!e.stack)return;const r=e.stack.split(`
|
|
337
|
+
}`};function tm(e,r){H(r,!0),R(e,rm);const t=k=>k==null||k==null||k==""?null:k,a=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon)}),n=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon_webp)}),o=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark)}),i=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark_webp)}),s=E(()=>d(a)?Jt(d(a)):null),l=E(()=>d(n)?Jt(d(n)):null),c=E(()=>d(o)?Jt(d(o)):null),u=E(()=>d(i)?Jt(d(i)):null),p=()=>{r.onClose&&r.onClose()};var _=em(),g=x(_);{var m=k=>{var w=Qg(),q=x(w);Gg(q,{$$events:{click:p}}),b(k,w)};C(g,k=>{r.showCloseButton&&k(m)})}var f=O(g,2),v=x(f),h=x(v);{var y=k=>{Jg(k,{get src(){return d(c)},get srcWebp(){return d(u)}})},P=k=>{var w=ae(),q=X(w);{var G=Y=>{Hg(Y,{get src(){return d(s)},get srcWebp(){return d(l)}})};C(q,Y=>{d(s)!==null&&d(l)!==null&&Y(G)},!0)}b(k,w)};C(h,k=>{d(c)!==null?k(y):k(P,!1)})}var I=O(h,2);{var S=k=>{ue(k,{size:"body-base",children:(w,q)=>{var G=ce();A(()=>{var Y;return oe(G,(Y=r.brandingInfo)==null?void 0:Y.app_name)}),b(w,G)},$$slots:{default:!0}})};C(I,k=>{d(c)===null&&k(S)})}var z=O(f,2);{var V=k=>{var w=$g(),q=x(w);Xi(q,{$$events:{click:p}}),b(k,w)};C(z,k=>{r.showCloseButton&&k(V)})}A(()=>Er(_,"rcb-with-close-button",r.showCloseButton)),b(e,_),W()}var am=T("<!> <!> <!> <!>",1);function nm(e,r){H(r,!0);const t=U(r,"onClose",3,void 0);let a=K(B(r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:r.productDetails.currentPrice.amountMicros,totalExcludingTaxInMicros:r.productDetails.currentPrice.amountMicros,taxCalculationStatus:"unavailable",taxAmountInMicros:null,taxBreakdown:null}));const n=o=>{D(a,B(o))};Lg(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var c=E(()=>!r.isInElement&&!!t());tm(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return d(c)}})},navbarBodyContent:l=>{var c=E(()=>{var u,p;return((p=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:p.show_product_description)??!1});dg(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return d(c)},get priceBreakdown(){return d(a)}})},mainContent:l=>{var c=am(),u=X(c);{var p=y=>{O_(y)};C(u,y=>{r.currentPage==="payment-entry-loading"&&y(p)})}var _=O(u,2);{var g=y=>{a_(y,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get brandingInfo(){return r.brandingInfo},get purchaseOperationHelper(){return r.purchaseOperationHelper},get gatewayParams(){return r.gatewayParams},get managementUrl(){return r.managementUrl},get customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};C(_,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(_,2);{var f=y=>{var P=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.support_email)??null}),I=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.app_name)??null});N_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return d(P)},get onDismiss(){return r.closeWithError},get appName(){return d(I)}})};C(m,y=>{r.currentPage==="error"&&y(f)})}var v=O(m,2);{var h=y=>{C_(y,{get onContinue(){return r.onContinue}})};C(v,y=>{r.currentPage==="success"&&y(h)})}b(l,c)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),W()}function om(e){return e.trim()===""?"You need to provide your email address to continue.":e.match(/^[^@]+@[^@]+\.[^@]+$/)?null:"Email is not valid. Please provide a valid email address."}function im(e){if(e&&!e.match(/^[A-Z]{3}$/)){const r=`Currency code ${e} is not valid. Please provide a valid ISO 4217 currency code.`;throw $.errorLog(r),new be(xe.ConfigurationError,r)}}function sm(e,r){var k;H(r,!0);const t=U(r,"customTranslations",19,()=>({})),a=U(r,"skipSuccessPage",3,!1),n=r.customerEmail?om(r.customerEmail):null;let o=K(B(n?void 0:r.customerEmail)),i=r.rcPackage.webBillingProduct,s=K(null);const l=r.rcPackage.webBillingProduct.identifier??null;let c=K("payment-entry-loading"),u=K(null),p=K(null),_=K(B({})),g=K(null),m=K(null),f=K(null),v=K(null),h=new Pa(t(),r.selectedLocale,r.defaultLocale);var y=li(h);un(Ye,y),un(An,(k=r.brandingInfo)==null?void 0:k.appearance),Qe(()=>{r.isInElement||(D(m,B(document.documentElement.style.height)),D(f,B(document.documentElement.style.overflow)),D(v,B(document.body.style.height)),document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Rt(()=>{if(!r.isInElement){const w=(q,G,Y)=>{Y===""?q.style.removeProperty(G):q.style.setProperty(G,Y)};w(document.documentElement,"height",d(m)),w(document.body,"height",d(v)),w(document.documentElement,"overflow",d(f))}}),un(Dn,r.eventsTracker),Qe(async()=>{if(l===null){I(new ge(de.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,l,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(o),r.metadata).then(w=>{D(s,null),D(c,"payment-entry"),D(_,B(w.gateway_params)),D(g,B(w.management_url))}).catch(w=>{if(w.errorCode===de.MissingEmailError)return D(o,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,l,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(o),r.metadata).then(q=>{D(s,null),D(c,"payment-entry"),D(_,B(q.gateway_params)),D(g,B(q.management_url))}).catch(q=>{I(q)});I(w)})});const P=()=>{if(d(c)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(w=>{D(u,B(w.redemptionInfo)),D(p,B(w.operationSessionId)),a()?r.onFinished(d(p),d(u)):D(c,"success")}).catch(w=>{I(w)});return}if(d(c)==="success"||d(c)==="error"){r.onFinished(d(p),d(u));return}D(c,"success")},I=w=>{const q=tp({errorCode:w.getErrorCode().toString(),errorMessage:w.message});r.eventsTracker.trackSDKEvent(q),D(s,B(w)),D(c,"error")},S=()=>{r.onError(d(s)??new ge(de.UnknownError,"Unknown error without state set."))};var z=E(()=>r.purchases.isSandbox()),V=E(()=>d(o)??null);nm(e,{get isSandbox(){return d(z)},get currentPage(){return d(c)},get brandingInfo(){return r.brandingInfo},productDetails:i,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return d(s)},get gatewayParams(){return d(_)},get managementUrl(){return d(g)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return d(V)},closeWithError:S,onContinue:P,onError:I,get onClose(){return r.onClose}}),W()}function Zi(e){return e==null?!0:new Date(e)>new Date}function lm(e,r,t,a){const n=r.product_identifier;if(n in t)return cm(e,r,t[n]);if(n in a)return dm(e,r,a[n]);throw new be(xe.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function cm(e,r,t){return{identifier:e,isActive:Zi(r.expires_date),willRenew:Ki(r.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:xr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:xr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:xr(t==null?void 0:t.billing_issues_detected_at),isSandbox:(t==null?void 0:t.is_sandbox)??!1,periodType:(t==null?void 0:t.period_type)??"normal",ownershipType:(t==null?void 0:t.ownership_type)??"UNKNOWN"}}function dm(e,r,t){return{identifier:e,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:r.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function um(e,r,t){const a={},n={};for(const o in e){const i=lm(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function xr(e){return e==null?null:new Date(e)}function pm(e){const r=gm(e),t=e.subscriber,a=fm(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(c=>({transactionIdentifier:c.id,productIdentifier:s,purchaseDate:new Date(c.purchase_date||c.original_purchase_date),storeTransactionId:c.store_transaction_id||null,store:c.store}))),o=new Date(e.request_date),i=Object.fromEntries(Object.entries(e.subscriber.subscriptions).map(([s,l])=>[s,{productIdentifier:s,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:xr(l.original_purchase_date),expiresDate:xr(l.expires_date),store:l.store,unsubscribeDetectedAt:xr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:xr(l.billing_issues_detected_at),gracePeriodExpiresDate:xr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:xr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Zi(l.expires_date),willRenew:Ki(l.expires_date,l)}]));return{entitlements:um(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:_m(e,a),activeSubscriptions:mm(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:xr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Ki(e,r){if(r==null)return!1;const t=r.store=="promotional",a=e==null,n=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||a||n||o)}function _m(e,r){const t={};for(const a in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[a];t[a]=new Date(n.purchase_date)}for(const a in r){const n=r[a].purchase_date;n==null?t[a]=null:t[a]=new Date(n)}return t}function gm(e){const r={};for(const t in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[t];a.expires_date==null?r[t]=null:r[t]=new Date(a.expires_date)}return r}function mm(e){const r=new Set,t=new Date;for(const a in e){const n=e[a];(n==null||n>t)&&r.add(a)}return r}function fm(e){const r={};for(const t in e){if(e[t].length===0)continue;const a=e[t].length;r[t]=e[t][a-1]}return r}const Ji="1.9.0",ym="https://api.revenuecat.com",bm="https://e.revenue.cat";var Ca;(function(e){e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.MULTI_STATUS=207]="MULTI_STATUS",e[e.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.USE_PROXY=305]="USE_PROXY",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",e[e.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.IM_A_TEAPOT=418]="IM_A_TEAPOT",e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",e[e.METHOD_FAILURE=420]="METHOD_FAILURE",e[e.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.LOCKED=423]="LOCKED",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e[e.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",e[e.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Ca||(Ca={}));function Oa(e){return e?e.startsWith("rcb_sb_"):!1}async function Fr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??ym}${e.urlPath()}`;try{const c=await fetch(l,{method:e.method,headers:is(a,o,i==null?void 0:i.additionalHeaders),body:vm(n),signal:t});return await hm(c,e),await c.json()}catch(c){throw c instanceof TypeError?new be(xe.NetworkError,Ut.getPublicMessage(xe.NetworkError),c.message):c}}async function hm(e,r){const t=e.status;if(t>=Ca.INTERNAL_SERVER_ERROR)Un(r,t,await e.text());else if(t>=Ca.BAD_REQUEST){const a=await e.json(),n=a?JSON.stringify(a):null,o=a==null?void 0:a.code,i=a==null?void 0:a.message;if(o!=null){const s=Ut.convertCodeToBackendErrorCode(o);if(s==null)Un(r,t,n,o);else throw be.getForBackendError(s,i)}else Un(r,t,n)}}function Un(e,r,t,a){throw new be(xe.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function vm(e){return e==null?null:JSON.stringify(e)}const Qi="Authorization",$i="Content-Type",es="Accept",rs="X-Platform",ts="X-Version",as="X-Platform-Flavor",ns="X-Platform-Flavor-Version",os="X-Is-Sandbox",km=new Set([Qi,$i,es,rs,ts,os,as,ns]);function is(e,r,t){let a={[Qi]:`Bearer ${e}`,[$i]:"application/json",[es]:"application/json",[rs]:"web",[ts]:Ji,[os]:`${Oa(e)}`};const n=La.getPlatformInfo();if(n){const o={[as]:n.flavor,[ns]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const Vn="/v1/subscribers",kt="/rcbilling/v1";class wm{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/offerings`}}class xm{constructor(r,t,a){j(this,"method","GET");j(this,"name","getProducts");j(this,"appUserId");j(this,"productIds");j(this,"currency");this.appUserId=r,this.productIds=t,this.currency=a}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),a=this.currency?`¤cy=${this.currency}`:"";return`${kt}/subscribers/${r}/products?id=${t}${a}`}}class Pm{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}`}}class Sm{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${kt}/branding`}}class Em{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${kt}/checkout/start`}}class Tm{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/calculate_taxes`}}class Im{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/complete`}}class qm{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}`}}class Fm{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/attributes`}}const Hn={};class zm{constructor(r,t=Hn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Oa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Fr(new wm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Fr(new Pm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Fr(new xm(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Fr(new Sm,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutStart(r,t,a,n,o,i,s=void 0){const l={app_user_id:r,product_id:t,email:i,price_id:n.priceId,presented_offering_identifier:a.offeringIdentifier,trace_id:o};return s&&(l.metadata=s),n.id!=="base_option"&&(l.offer_id=n.id),a.targetingContext&&(l.applied_targeting_rule={rule_id:a.targetingContext.ruleId,revision:a.targetingContext.revision}),a.placementIdentifier&&(l.presented_placement_identifier=a.placementIdentifier),await Fr(new Em,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async postCheckoutCalculateTax(r,t,a,n){const o={country_code:t,postal_code:a};return await Fr(new Tm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Fr(new Im(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Fr(new qm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(r,t){const a=Date.now(),n={};for(const[i,s]of Object.entries(t))n[i]={value:s,updated_at_ms:a};const o={attributes:n};return await Fr(new Fm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Dm(e){const r=/^rcb_[a-zA-Z0-9_.-]+$/,t=/^pdl_[a-zA-Z0-9_.-]+$/;if(!r.test(e)&&!t.test(e))throw new be(xe.InvalidCredentialsError,"Invalid API key. Use your Web Billing or Paddle API key.")}function ss(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new be(xe.InvalidAppUserIdError,'Provided user id: "'+(e??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function Am(e){if(e!=null&&e.endsWith("/"))throw new be(xe.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function jm(e){if(e){for(const r in e)if(km.has(r))throw new be(xe.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Wn=(e=>(e.Current="current",e))(Wn||{});function Mm(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const ls=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},rt=(e,r)=>e==null?null:ls(e,r),Nm=(e,r,t)=>{const a=e.offering_ids_by_placement??null;if(a==null)return null;const n=e.fallback_offering_id??null;let o;if(t in a){const s=a[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[n])}else o=r[n];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,ls(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:rt(o.weekly,t),monthly:rt(o.monthly,t),twoMonth:rt(o.twoMonth,t),threeMonth:rt(o.threeMonth,t),sixMonth:rt(o.sixMonth,t),annual:rt(o.annual,t),lifetime:rt(o.lifetime,t)}};function Cm(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const a={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=p_(i,o,t,e.targeting);s!=null&&(a[o.identifier]=s)});const n=e.current_offering_id?a[e.current_offering_id]??null:null;return Object.keys(a).length==0&&$.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:a,current:n}}const Om=1000001;function Lm(e){return e.webBillingProduct.defaultPurchaseOption}function cs(e,r,t,a=!1){return t.translate(L.PaywallVariablesPricePerPeriod,{formattedPrice:e,period:r.base.period?t.translatePeriod(r.base.period.number,r.base.period.unit,{noWhitespace:!0,short:!a}):""})}function Bm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,Se.Month):r.translatePeriod(e.number,e.unit)}function Rm({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return r?r.unit==="year"?t.formatPrice(e.amountMicros/12/4,e.currency):r.unit==="month"||r.unit==="week"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*7/r.number,e.currency):a:a}function Um({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return!r||!r.number?a:r.unit==="year"?t.formatPrice(e.amountMicros/12,e.currency):r.unit==="month"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="week"?t.formatPrice(e.amountMicros*4/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*30/r.number,e.currency):a}function ds({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===Se.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case Se.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case Se.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case Se.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case Se.Day:n=a.formatPrice(e.amountMicros*30/r.number,e.currency);break}return a.translate(L.PaywallVariablesTotalPriceAndPerMonth,{formattedPrice:a.formatPrice(e.amountMicros,e.currency),period:a.translatePeriod(r.number,r.unit,{noWhitespace:!0,short:!t}),formattedPricePerMonth:n,monthPeriod:a.translatePeriodUnit(Se.Month,{noWhitespace:!0,short:!t})})}function Vm(e,r){const t=e.availablePackages,a=t.reduce((n,o)=>n.webBillingProduct.currentPrice.amountMicros>o.webBillingProduct.currentPrice.amountMicros?n:o);return t.reduce((n,o)=>(n[o.identifier]=Hm(o,a,r),n),{})}function Hm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=Lm(e),i=a.productType,s={product_name:a.title,price:n,price_per_period:"",price_per_period_full:"",total_price_and_per_month:"",total_price_and_per_month_full:"",sub_price_per_month:"",sub_price_per_week:"",sub_duration:"",sub_duration_in_months:"",sub_period:"",sub_period_length:"",sub_period_abbreviated:"",sub_offer_duration:void 0,sub_offer_duration_2:void 0,sub_offer_price:void 0,sub_offer_price_2:void 0,sub_relative_discount:""};if(i===Ur.Subscription&&o){s.price_per_period=cs(n,o,t),s.price_per_period_full=cs(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=ds({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=ds({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=Um({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=Rm({price:a.currentPrice,period:l,translator:t}),s.sub_duration=t.translatePeriod(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_duration_in_months=Bm(l,t),s.sub_period=t.translatePeriodFrequency(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_period_length=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0}):void 0,s.sub_period_abbreviated=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0,short:!0}):void 0;const c=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,p=((u-c)*100/u).toFixed(0);s.sub_relative_discount=c===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:p})}return(i===Ur.NonConsumable||i===Ur.Consumable)&&o&&(s.price=n,s.price_per_period=n,s.price_per_period_full=n,s.total_price_and_per_month=n,s.sub_price_per_month=n,s.sub_duration=t.translate(L.PeriodsLifetime),s.sub_duration_in_months=t.translate(L.PeriodsLifetime),s.sub_period=t.translate(L.PeriodsLifetime),s.sub_price_per_week=void 0,s.sub_relative_discount=void 0,s.price_per_period_full=n,s.total_price_and_per_month_full=n,s.sub_period_length=void 0,s.sub_period_abbreviated=void 0),s}const qe=[];for(let e=0;e<256;++e)qe.push((e+256).toString(16).slice(1));function Wm(e,r=0){return(qe[e[r+0]]+qe[e[r+1]]+qe[e[r+2]]+qe[e[r+3]]+"-"+qe[e[r+4]]+qe[e[r+5]]+"-"+qe[e[r+6]]+qe[e[r+7]]+"-"+qe[e[r+8]]+qe[e[r+9]]+"-"+qe[e[r+10]]+qe[e[r+11]]+qe[e[r+12]]+qe[e[r+13]]+qe[e[r+14]]+qe[e[r+15]]).toLowerCase()}let Yn;const Ym=new Uint8Array(16);function Gm(){if(!Yn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yn=crypto.getRandomValues.bind(crypto)}return Yn(Ym)}const us={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ps(e,r,t){var n;if(us.randomUUID&&!e)return us.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??Gm();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Wm(a)}var Xm=/(%?)(%([sdijo]))/g;function Zm(e,r){switch(r){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const t=JSON.stringify(e);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?e:t}}}function Gn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(Xm,(n,o,i,s)=>{const l=r[t],c=Zm(l,s);return o?n:(t++,c)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var Km=2;function Jm(e){if(!e.stack)return;const r=e.stack.split(`
|
|
338
338
|
`);r.splice(1,Km),e.stack=r.join(`
|
|
339
339
|
`)}var Qm=class extends Error{constructor(e,...r){super(e),this.message=e,this.name="Invariant Violation",this.message=Gn(e,...r),Jm(this)}},_s=(e,r,...t)=>{if(!e)throw new Qm(r,...t)};_s.as=(e,r,t,...a)=>{if(!r){const n=a.length===0?t:Gn(t,...a);let o;try{o=Reflect.construct(e,[n])}catch{o=e(n)}throw o}};const $m="[MSW]";function Xn(e,...r){const t=Gn(e,...r);return`${$m} ${t}`}function ef(e,...r){console.warn(Xn(e,...r))}function rf(e,...r){console.error(Xn(e,...r))}const tf={formatMessage:Xn,warn:ef,error:rf};function af(){_s(typeof URL<"u",tf.formatMessage(`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`))}var gs=(e=>(e.HEAD="HEAD",e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.DELETE="DELETE",e))(gs||{});af();class nf{constructor(r,t,a,n){j(this,"initialDelay");j(this,"maxDelay");j(this,"jitterPercent");j(this,"callback");j(this,"currentDelay");j(this,"timeoutId");j(this,"executingCallback",!1);this.initialDelay=r,this.currentDelay=r,this.maxDelay=t,this.jitterPercent=a,this.callback=n}tryFlush(){if(this.backingOff()){$.debugLog("Backing off, not flushing");return}this.clearTimeout(),this.executeCallbackWithRetries()}stop(){this.clearTimeout()}schedule(r){if(this.timeoutId!==void 0)return;const t=this.addJitter(r||this.currentDelay);this.timeoutId=setTimeout(()=>{this.timeoutId=void 0,this.executeCallbackWithRetries()},t)}backoff(){const r=this.currentDelay,t=Math.min(this.currentDelay*2,this.maxDelay);$.debugLog(`Backing next off to ${r}ms delay`),this.clearTimeout(),this.currentDelay=t,this.schedule(r)}reset(){this.currentDelay!==this.initialDelay&&(this.clearTimeout(),this.currentDelay=this.initialDelay)}async executeCallbackWithRetries(){if(this.executingCallback){$.debugLog("Callback already running, rescheduling"),this.schedule();return}this.executingCallback=!0;try{await this.callback(),this.reset()}catch{this.backoff()}finally{this.executingCallback=!1}}backingOff(){return this.currentDelay>this.initialDelay}clearTimeout(){clearTimeout(this.timeoutId),this.timeoutId=void 0}addJitter(r){const t=r*this.jitterPercent,a=r-t,n=r+t;return Math.floor(Math.random()*(n-a+1)+a)}}function ms(e){const r={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const a=t.replace(/([A-Z])/g,"_$1").toLowerCase(),n=e[t];n&&typeof n=="object"&&!Array.isArray(n)?r[a]=ms(n):r[a]=n}return r}class of{constructor(r){j(this,"EVENT_TYPE","web_billing");j(this,"id");j(this,"timestampMs");j(this,"data");this.id=ps(),this.timestampMs=Date.now(),this.data=r}toJSON(){return ms({id:this.id,timestampMs:this.timestampMs,type:this.EVENT_TYPE,eventName:this.data.eventName,appUserId:this.data.appUserId,context:{...this.data.context},properties:{...this.data.properties,traceId:this.data.traceId}})}}function sf(e,r){const t=new URLSearchParams(window.location.search);return{libraryName:"purchases-js",libraryVersion:Ji,locale:navigator.language,userAgent:navigator.userAgent,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,utmSource:t.get("utm_source")??null,utmMedium:t.get("utm_medium")??null,utmCampaign:t.get("utm_campaign")??null,utmContent:t.get("utm_content")??null,utmTerm:t.get("utm_term")??null,pageReferrer:document.referrer,pageUrl:`${window.location.origin}${window.location.pathname}`,pageTitle:document.title,source:e,rcSource:r}}const lf=2e3,cf=5*6e4,df=.1;class uf{constructor(r){j(this,"apiKey");j(this,"eventsQueue",[]);j(this,"eventsUrl");j(this,"flushManager");j(this,"traceId",ps());j(this,"appUserId");j(this,"isSilent");j(this,"rcSource");this.apiKey=r.apiKey,this.eventsUrl=`${bm}/v1/events`,this.appUserId=r.appUserId,this.isSilent=r.silent||!1,this.rcSource=r.rcSource,this.flushManager=new nf(lf,cf,df,this.flushEvents.bind(this))}async updateUser(r){this.appUserId=r}getTraceId(){return this.traceId}trackSDKEvent(r){this.trackEvent({...r,source:"sdk"})}trackExternalEvent(r){this.trackEvent({...r})}trackEvent(r){if(this.isSilent){$.verboseLog("Skipping event tracking, the EventsTracker is silent");return}try{const t=new of({eventName:r.eventName,traceId:this.traceId,appUserId:this.appUserId,context:sf(r.source,this.rcSource),properties:r.properties||{}});this.eventsQueue.push(t),this.flushManager.tryFlush()}catch{$.errorLog(`Error while tracking event ${r.eventName}`)}}dispose(){this.flushManager.stop()}flushEvents(){if(this.eventsQueue.length===0)return Promise.resolve();const r=[...this.eventsQueue];return fetch(this.eventsUrl,{method:gs.POST,headers:is(this.apiKey),body:JSON.stringify({events:r})}).then(t=>{if(t.status===200||t.status===201){this.eventsQueue.splice(0,r.length);return}else throw $.debugLog("Events failed to flush due to server error"),new Error("Events failed to flush due to server error")}).catch(t=>{throw $.debugLog("Error while flushing events"),t})}}const pf=()=>{const e=new URLSearchParams(window.location.search),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],t={};return r.forEach(a=>{const n=e.get(a);n!==null&&(t[a]=n)}),t},_f=["app","embedded"],Zn={autoCollectUTMAsMetadata:!0,collectAnalyticsEvents:!0};function gf(){if(crypto&&crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(16);if(crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const r=Array.from(e).map(t=>t.toString(16).padStart(2,"0"));return[r.slice(0,4).join(""),r.slice(4,6).join(""),r.slice(6,8).join(""),r.slice(8,10).join(""),r.slice(10,16).join("")].join("-")}var fs=(e=>(e.DisplayName="$displayName",e.Email="$email",e.PhoneNumber="$phoneNumber",e.IDFA="$idfa",e.IDFV="$idfv",e.GPSAdId="$gpsAdId",e.AndroidId="$androidId",e.AmazonAdId="$amazonAdId",e.IP="$ip",e.AdjustId="$adjustId",e.AmplitudeDeviceId="$amplitudeDeviceId",e.AmplitudeUserId="$amplitudeUserId",e.AppsflyerId="$appsflyerId",e.AppsflyerSharingFilter="$appsflyerSharingFilter",e.BranchId="$branchId",e.BrazeAliasName="$brazeAliasName",e.BrazeAliasLabel="$brazeAliasLabel",e.ClevertapId="$clevertapId",e.FbAnonId="$fbAnonId",e.MparticleId="$mparticleId",e.OnesignalId="$onesignalId",e.OnesignalUserId="$onesignalUserId",e.IntercomContactId="$intercomContactId",e.MediaSource="$mediaSource",e.Campaign="$campaign",e.AdGroup="$adGroup",e.AdId="$ad",e.Keyword="$keyword",e.Creative="$creative",e.APNSTokens="$apnsTokens",e.FCMTokens="$fcmTokens",e.AirshipChannelId="$airshipChannelId",e.SegmentId="$segmentId",e.IterableUserId="$iterableUserId",e.IterableCampaignId="$iterableCampaignId",e.IterableTemplateId="$iterableTemplateId",e.FirebaseAppInstanceId="$firebaseAppInstanceId",e.MixpanelDistinctId="$mixpanelDistinctId",e.ATTConsentStatus="$attConsentStatus",e.KochavaDeviceId="$kochavaDeviceId",e.DeviceVersion="$deviceVersion",e.PosthogUserId="$posthogUserId",e.TelemetryDeckUserId="$telemetryDeckUserId",e.TelemetryDeckAppId="$telemetryDeckAppId",e.AppleRefundHandlingPreference="$appleRefundHandlingPreference",e.CustomerioId="$customerioId",e.TenjinId="$tenjinId",e))(fs||{});const ys="$RCAnonymousID:";xs=[Mm];const Pe=class Pe{constructor(r,t,a=Hn,n=Zn){Ns(Kn,5,this);j(this,"_API_KEY");j(this,"_appUserId");j(this,"_brandingInfo",null);j(this,"_loadingResourcesPromise",null);j(this,"_flags");j(this,"backend");j(this,"purchaseOperationHelper");j(this,"eventsTracker");this._API_KEY=r,this._appUserId=t,this._flags={...Zn,...n},Oa(r)&&$.debugLog("Initializing Purchases SDK with sandbox API Key"),this.eventsTracker=new uf({apiKey:this._API_KEY,appUserId:this._appUserId,silent:!this._flags.collectAnalyticsEvents,rcSource:this._flags.rcSource??null}),this.backend=new zm(this._API_KEY,a),this.purchaseOperationHelper=new Kl(this.backend,this.eventsTracker),this.eventsTracker.trackSDKEvent({eventName:Ve.SDKInitialized})}static setLogLevel(r){$.setLogLevel(r)}static setPlatformInfo(r){Pe._platformInfo=r}static getPlatformInfo(){return Pe._platformInfo}static getSharedInstance(){if(Pe.isConfigured())return Pe.instance;throw new ti}static isConfigured(){return Pe.instance!==void 0}static configure(r,t,a,n){Pe.instance!==void 0&&$.warnLog("Purchases is already initialized. You normally should only configure Purchases once. Creating and returning new instance.");let o;if(typeof r=="object"&&r!==null)o=r;else{if(typeof r!="string")throw new be(xe.ConfigurationError,"API key must be provided as a string");if(typeof t!="string")throw new be(xe.ConfigurationError,"App user ID must be provided as a string");o={apiKey:r,appUserId:t,httpConfig:a,flags:n}}return Pe.configureInternal(o),Pe.getSharedInstance()}static configureInternal(r){const{apiKey:t,appUserId:a,httpConfig:n,flags:o}=r,i=n??Hn,s=o??Zn;Pe.validateConfig(r),Pe.instance=new Pe(t,a,i,s)}static validateConfig(r){var t,a;Dm(r.apiKey),ss(r.appUserId),Am((t=r.httpConfig)==null?void 0:t.proxyURL),jm((a=r.httpConfig)==null?void 0:a.additionalHeaders)}async preload(){if(this.hasLoadedResources()){$.verboseLog("Purchases resources are loaded. Skipping.");return}if(this._loadingResourcesPromise!==null){$.verboseLog("Purchases resources are loading. Waiting."),await this._loadingResourcesPromise;return}return this._loadingResourcesPromise=this.fetchAndCacheBrandingInfo().catch(r=>{let t=`${r}`;r instanceof be&&(t=`${r.message}. ${r.underlyingErrorMessage?`Underlying error: ${r.underlyingErrorMessage}`:""}`),$.errorLog(`Error fetching branding info: ${t}`)}).finally(()=>{this._loadingResourcesPromise=null}),this._loadingResourcesPromise}fetchAndCacheBrandingInfo(){return this.backend.getBrandingInfo().then(r=>{this._brandingInfo=r})}hasLoadedResources(){return this._brandingInfo!==null}async renderPaywall(r){console.warn("This method is @experimental, Paywalls are not generally available but they will come soon!");let a=r.htmlTarget??document.getElementById("rcb-ui-pw-root");if(a===null){const g=document.createElement("div");g.id="rcb-ui-pw-root",g.className="rcb-ui-pw-root",g.style.zIndex=`${Om}`,document.body.appendChild(g),a=g}if(a===null)throw new Error("Could not generate a mount point for the billing widget");const n=a;n.innerHTML="";const o=r.offering;if(!o.paywall_components)throw new Error("You cannot use paywalls yet, they are coming soon!");const i=r.selectedLocale||navigator.language,s=new Pa({},i,o.paywall_components.default_locale),l=g=>{var f;const m=o.availablePackages.find(v=>v.identifier===g);if(m===void 0)throw new Error(`No package found for ${g}`);return this.purchase({rcPackage:m,htmlTarget:r.purchaseHtmlTarget,customerEmail:r.customerEmail,selectedLocale:i,defaultLocale:((f=o.paywall_components)==null?void 0:f.default_locale)||bt})},c=g=>{var m;if(r.onNavigateToUrl){r.onNavigateToUrl(g);return}(m=window.open(g,"_blank"))==null||m.focus()},u=()=>{},p=()=>{if(r.onVisitCustomerCenter){r.onVisitCustomerCenter();return}},_=Vm(o,s);return new Promise((g,m)=>{Bo(kd,{target:n,props:{paywallData:o.paywall_components,selectedLocale:i,onNavigateToUrlClicked:c,onVisitCustomerCenterClicked:p,onBackClicked:()=>{if(r.onBack){r.onBack();return}n.innerHTML="",$.debugLog("Purchase cancelled by user"),m(new be(xe.UserCancelledError))},onRestorePurchasesClicked:u,onPurchaseClicked:f=>{l(f).then(v=>{g(v)}).catch(v=>m(v))},onError:f=>m(f),variablesPerPackage:_}})})}async getOfferings(r){im(r==null?void 0:r.currency);const t=this._appUserId,a=await this.backend.getOfferings(t),n=(r==null?void 0:r.offeringIdentifier)===Wn.Current?a.current_offering_id:r==null?void 0:r.offeringIdentifier;return n&&(a.offerings=a.offerings.filter(o=>o.identifier===n)),await this.getAllOfferings(a,t,r)}async getCurrentOfferingForPlacement(r,t){const a=this._appUserId,n=await this.backend.getOfferings(a),o=await this.getAllOfferings(n,a,t),i=n.placements??null;return i==null?null:Nm(i,o.all,r)}async getAllOfferings(r,t,a){const n=r.offerings.flatMap(i=>i.packages).map(i=>i.platform_product_identifier),o=await this.backend.getProducts(t,n,a==null?void 0:a.currency);return this.logMissingProductIds(n,o.product_details),Cm(r,o)}async isEntitledTo(r){const t=await this.getCustomerInfo();return r in t.entitlements.active}purchasePackage(r,t,a){return this.purchase({rcPackage:r,customerEmail:t,htmlTarget:a})}purchase(r){var I;const{rcPackage:t,purchaseOption:a,htmlTarget:n,customerEmail:o,selectedLocale:i=bt,defaultLocale:s=bt,skipSuccessPage:l=!1}=r;let c=n??document.getElementById("rcb-ui-root");if(c===null){const S=document.createElement("div");S.className="rcb-ui-root",document.body.appendChild(S),c=S}if(c===null)throw new Error("Could not generate a mount point for the billing widget");const u=c,p=this._appUserId;$.debugLog(`Presenting purchase form for package ${t.identifier}`);const _=i||s,g=a??t.webBillingProduct.defaultPurchaseOption,m=np({appearance:(I=this._brandingInfo)==null?void 0:I.appearance,rcPackage:t,purchaseOptionToUse:g,customerEmail:o});this.eventsTracker.trackSDKEvent(m);const v={...this._flags.autoCollectUTMAsMetadata?pf():{},...r.metadata||{}};let h=null;const y=this._brandingInfo;y&&r.brandingAppearanceOverride&&(y.appearance=r.brandingAppearanceOverride);const P=n!==void 0;return new Promise((S,z)=>{P||window.history.pushState({checkoutOpen:!0},"");const k=this._flags.rcSource&&_f.includes(this._flags.rcSource)?void 0:()=>{const G=ip();this.eventsTracker.trackSDKEvent(G),window.removeEventListener("popstate",k),h&&yn(h),u.innerHTML="",$.debugLog("Purchase cancelled by user"),z(new be(xe.UserCancelledError))};!P&&k&&window.addEventListener("popstate",k),h=Bo(sm,{target:u,props:{isInElement:P,appUserId:p,rcPackage:t,purchaseOption:g,customerEmail:o,onFinished:async(G,Y)=>{const re=op({redemptionInfo:Y});this.eventsTracker.trackSDKEvent(re),$.debugLog("Purchase finished"),h&&yn(h),u.innerHTML="";const Q={customerInfo:await this._getCustomerInfoForUserId(p),redemptionInfo:Y,operationSessionId:G};S(Q)},onClose:k,onError:G=>{var re;const Y=sp({errorCode:(re=G.errorCode)==null?void 0:re.toString(),errorMessage:G.message});this.eventsTracker.trackSDKEvent(Y),h&&yn(h),u.innerHTML="",z(be.getForPurchasesFlowError(G))},purchases:this,eventsTracker:this.eventsTracker,brandingInfo:this._brandingInfo,purchaseOperationHelper:this.purchaseOperationHelper,selectedLocale:_,metadata:v,defaultLocale:s,customTranslations:r.labelsOverride,skipSuccessPage:l}})})}async getCustomerInfo(){return await this._getCustomerInfoForUserId(this._appUserId)}getAppUserId(){return this._appUserId}async setAttributes(r){return await this.getCustomerInfo(),await this.backend.setAttributes(this._appUserId,r)}async changeUser(r){return ss(r),this._appUserId=r,this.eventsTracker.updateUser(r),await this.getCustomerInfo()}logMissingProductIds(r,t){const a={};t.forEach(o=>a[o.identifier]=o);const n=[];r.forEach(o=>{a[o]===void 0&&n.push(o)}),n.length>0&&$.debugLog(`Could not find product data for product ids:
|
|
340
340
|
${n.join()}.
|