@revenuecat/purchases-js 0.18.1 → 0.18.2

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.
@@ -440,9 +440,10 @@ export declare interface Period {
440
440
  * - "normal" If the entitlement is not under an introductory or trial period.
441
441
  * - "intro" If the entitlement is under an introductory period.
442
442
  * - "trial" If the entitlement is under a trial period.
443
+ * - "prepaid" If the entitlement is a prepaid entitlement. Only for Google Play subscriptions.
443
444
  * @public
444
445
  */
445
- export declare type PeriodType = "normal" | "intro" | "trial";
446
+ export declare type PeriodType = "normal" | "intro" | "trial" | "prepaid";
446
447
 
447
448
  /**
448
449
  * Represents a unit of time.
@@ -6955,7 +6955,7 @@ function Sd(e) {
6955
6955
  }
6956
6956
  return r;
6957
6957
  }
6958
- const Vo = "0.18.1", Id = "https://api.revenuecat.com", Td = "https://e.revenue.cat";
6958
+ const Vo = "0.18.2", Id = "https://api.revenuecat.com", Td = "https://e.revenue.cat";
6959
6959
  var Ct;
6960
6960
  (function(e) {
6961
6961
  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";
@@ -121,7 +121,7 @@
121
121
  }`};function td(e,r){ne(r,!1),V(e,rd);let t=w(r,"brandingAppearance",8,void 0),n=new Zn(t()).productInfoStyleVars;Xe();var a=ed();K(a,"style",n);var o=I(a);Bo(o,{children:(i,s)=>{var l=$c(),u=D(l);he(u,r,"header",{});var c=A(u,2);he(c,r,"default",{}),y(i,l)},$$slots:{default:!0}}),y(e,a),ae()}var nd=x("<!> <!>",1),ad=x('<div class="rcb-ui-main svelte-kxew5e"><!></div>');const od={hash:"svelte-kxew5e",code:`.rcb-ui-main.svelte-kxew5e {flex:480px 1 0;max-width:640px;}
122
122
 
123
123
  @media screen and (max-width: 960px) {.rcb-ui-main.svelte-kxew5e {flex:none;max-width:none;min-width:100%;}
124
- }`};function id(e,r){ne(r,!1),V(e,od);let t=w(r,"brandingAppearance",8,void 0),n=new Zn(t()).formStyleVars;Xe();var a=ad();K(a,"style",n);var o=I(a);Bo(o,{style:"min-height: 360px;",children:(i,s)=>{var l=nd(),u=D(l);he(u,r,"header",{});var c=A(u,2);he(c,r,"default",{}),y(i,l)},$$slots:{default:!0}}),y(e,a),ae()}var sd=x("<!> <!>",1),ld=x("<!> <!> <!> <!> <!> <!> <!>",1),ud=x("<!> <!>",1);function cd(e,r){ne(r,!1);let t=w(r,"asModal",8,!0),n=w(r,"customerEmail",12),a=w(r,"appUserId",8),o=w(r,"rcPackage",8),i=w(r,"purchaseOption",8),s=w(r,"metadata",8),l=w(r,"brandingInfo",8),u=w(r,"onFinished",8),c=w(r,"onError",8),_=w(r,"onClose",8),p=w(r,"purchases",8),f=w(r,"eventsTracker",8),m=w(r,"purchaseOperationHelper",8),h=w(r,"selectedLocale",8,pr),S=w(r,"defaultLocale",8,pr),b=w(r,"customTranslations",24,()=>({})),g=Ee(""),v=Ee(null),E=Ee(null),k=Ee(null);const q=o().webBillingProduct.identifier??null;let P=Ee("present-offer"),N=null,L=null;const J=["present-offer","needs-auth-info","processing-auth-info","needs-payment-info","polling-purchase-status","loading"];Vt(Mr,new $e(b(),h(),S())),Vt(Qt,f()),Gr(async()=>{var Z;if(M(v,o().webBillingProduct),M(g,Lo((Z=l())==null?void 0:Z.appearance)),d(P)==="present-offer"){n()?W():M(P,"needs-auth-info");return}});const ie=()=>{_()()},W=()=>{if(q===null){le(new ye(pe.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}else d(P)==="present-offer"&&M(P,"loading");if(!n()){le(new ye(pe.MissingEmailError));return}m().startPurchase(a(),q,i(),n(),o().webBillingProduct.presentedOfferingContext,s()).then(Z=>{if(Z.next_action==="collect_payment_info"){M(k,null),M(P,"needs-payment-info"),M(E,Z);return}if(Z.next_action==="completed"){M(k,null),M(P,"success");return}}).catch(Z=>{le(Z)})},se=Z=>{if(d(P)==="needs-auth-info"){Z&&(n(Z.email),M(P,"processing-auth-info")),W();return}if(d(P)==="needs-payment-info"){M(P,"polling-purchase-status"),m().pollCurrentPurchaseForCompletion().then(R=>{M(P,"success"),N=R.redemptionInfo,L=R.operationSessionId}).catch(R=>{le(R)});return}if(d(P)==="success"||d(P)==="error"){u()(L,N);return}M(P,"success")},le=Z=>{const R=_c({errorCode:Z.getErrorCode().toString(),errorMessage:Z.message});if(f().trackSDKEvent(R),d(P)==="processing-auth-info"&&Z.isRecoverable()){M(k,Z),M(P,"needs-auth-info");return}M(k,Z),M(P,"error")},Ie=()=>{c()(d(k)??new ye(pe.UnknownError,"Unknown error without state set."))};Xe(),Xc(e,{children:(Z,R)=>{Lc(Z,{get condition(){return t()},children:(fe,ue)=>{Qc(fe,{get style(){return d(g)},children:(sr,cn)=>{var Nr=ud(),Xr=D(Nr);{var lr=Te=>{var re=oe(()=>{var ee;return(ee=l())==null?void 0:ee.appearance});td(Te,{get brandingAppearance(){return d(re)},children:(ee,Ne)=>{var ve=te(),er=D(ve);{var ur=Ae=>{var hr=oe(()=>{var cr;return(cr=l())==null?void 0:cr.appearance});vo(Ae,{get productDetails(){return d(v)},get brandingAppearance(){return d(hr)},get purchaseOption(){return i()}})};j(er,Ae=>{d(v)&&i()&&Ae(ur)})}y(ee,ve)},$$slots:{default:!0,header:(ee,Ne)=>{Gn(ee,{slot:"header",children:(ve,er)=>{var ur=sd(),Ae=D(ur);So(Ae,{get brandingInfo(){return l()}});var hr=A(Ae,2);{var cr=ze=>{Gc(ze)},Ce=ze=>{Vc(ze)};j(hr,ze=>{p().isSandbox()?ze(cr):ze(Ce,!1)})}y(ve,ur)},$$slots:{default:!0}})}}})};j(Xr,Te=>{J.includes(d(P))&&Te(lr)})}var qt=A(Xr,2),mr=oe(()=>{var Te;return(Te=l())==null?void 0:Te.appearance});id(qt,{get brandingAppearance(){return d(mr)},children:(Te,re)=>{var ee=ld(),Ne=D(ee);{var ve=Q=>{vo(Q,{get productDetails(){return d(v)},get purchaseOption(){return i()}})};j(Ne,Q=>{d(P)==="present-offer"&&d(v)&&i()&&Q(ve)})}var er=A(Ne,2);{var ur=Q=>{Bn(Q)};j(er,Q=>{d(P)==="present-offer"&&!d(v)&&Q(ur)})}var Ae=A(er,2);{var hr=Q=>{var Sr=oe(()=>d(P)==="processing-auth-info");Oc(Q,{onContinue:se,onClose:ie,get processing(){return d(Sr)},get lastError(){return d(k)}})};j(Ae,Q=>{(d(P)==="needs-auth-info"||d(P)==="processing-auth-info")&&Q(hr)})}var cr=A(Ae,2);{var Ce=Q=>{var Sr=oe(()=>d(P)==="polling-purchase-status");Sc(Q,{get paymentInfoCollectionMetadata(){return d(E)},onContinue:se,onClose:ie,get processing(){return d(Sr)},get productDetails(){return d(v)},get purchaseOption(){return i()},get brandingInfo(){return l()}})};j(cr,Q=>{d(E)&&(d(P)==="needs-payment-info"||d(P)==="polling-purchase-status")&&d(v)&&i()&&Q(Ce)})}var ze=A(cr,2);{var $r=Q=>{Bn(Q)};j(ze,Q=>{d(P)==="loading"&&Q($r)})}var Rr=A(ze,2);{var et=Q=>{var Sr=oe(()=>d(k)??new ye(pe.UnknownError,"Unknown error without state set.")),fa=oe(()=>{var dn;return(dn=l())==null?void 0:dn.support_email});Su(Q,{get brandingInfo(){return l()},get lastError(){return d(Sr)},get supportEmail(){return d(fa)},get productDetails(){return d(v)},onContinue:Ie})};j(Rr,Q=>{d(P)==="error"&&Q(et)})}var _a=A(Rr,2);{var pa=Q=>{Au(Q,{get productDetails(){return d(v)},get brandingInfo(){return l()},onContinue:se})};j(_a,Q=>{d(P)==="success"&&Q(pa)})}y(Te,ee)},$$slots:{default:!0}}),y(sr,Nr)},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}}),ae()}function dd(e){return e.expires_date==null?!0:new Date(e.expires_date)>new Date}function _d(e,r,t,n){const a=r.product_identifier;if(a in t)return pd(e,r,t[a]);if(a in n)return fd(e,r,n[a]);throw new ge(we.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function pd(e,r,t){return{identifier:e,isActive:dd(r),willRenew:gd(r,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:$t(r.expires_date),productIdentifier:r.product_identifier,unsubscribeDetectedAt:$t(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:$t(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"}}function fd(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,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal"}}function md(e,r,t){const n={},a={};for(const o in e){const i=_d(o,e[o],r,t);n[o]=i,i.isActive&&(a[o]=i)}return{all:n,active:a}}function $t(e){return e==null?null:new Date(e)}function hd(e){const r=bd(e),t=e.subscriber,n=kd(t.non_subscriptions);return{entitlements:md(t.entitlements,t.subscriptions,n),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:yd(e,n),activeSubscriptions:vd(r),managementURL:t.management_url,requestDate:new Date(e.request_date),firstSeenDate:new Date(t.first_seen),originalPurchaseDate:$t(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id}}function gd(e,r){if(r==null)return!1;const t=r.store=="promotional",n=e.expires_date==null,a=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||n||a||o)}function yd(e,r){const t={};for(const n in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[n];t[n]=new Date(a.purchase_date)}for(const n in r){const a=r[n].purchase_date;a==null?t[n]=null:t[n]=new Date(a)}return t}function bd(e){const r={};for(const t in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[t];n.expires_date==null?r[t]=null:r[t]=new Date(n.expires_date)}return r}function vd(e){const r=new Set,t=new Date;for(const n in e){const a=e[n];(a==null||a>t)&&r.add(n)}return r}function kd(e){const r={};for(const t in e){if(e[t].length===0)continue;const n=e[t].length;r[t]=e[t][n-1]}return r}const zo="0.18.1",wd="https://api.revenuecat.com",Pd="https://e.revenue.cat";var en;(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"})(en||(en={}));function Qn(e){return e?e.startsWith("rcb_sb_"):!1}async function Jr(e,r){const{apiKey:t,body:n,headers:a,httpConfig:o}=r,s=`${(o==null?void 0:o.proxyURL)??wd}${e.urlPath()}`;try{const l=await fetch(s,{method:e.method,headers:Qo(t,a,o==null?void 0:o.additionalHeaders),body:Ed(n)});return await xd(l,e),await l.json()}catch(l){throw l instanceof TypeError?new ge(we.NetworkError,wt.getPublicMessage(we.NetworkError),l.message):l}}async function xd(e,r){const t=e.status;if(t>=en.INTERNAL_SERVER_ERROR)Jn(r,t,await e.text());else if(t>=en.BAD_REQUEST){const n=await e.json(),a=n?JSON.stringify(n):null,o=n==null?void 0:n.code,i=n==null?void 0:n.message;if(o!=null){const s=wt.convertCodeToBackendErrorCode(o);if(s==null)Jn(r,t,a,o);else throw ge.getForBackendError(s,i)}else Jn(r,t,a)}}function Jn(e,r,t,n){throw new ge(we.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:n})}function Ed(e){return e==null?null:JSON.stringify(e)}const Vo="Authorization",Ho="Content-Type",Yo="Accept",Go="X-Platform",Wo="X-Version",Zo="X-Is-Sandbox",Sd=new Set([Vo,Ho,Yo,Go,Wo,Zo]);function Qo(e,r,t){let n={[Vo]:`Bearer ${e}`,[Ho]:"application/json",[Yo]:"application/json",[Go]:"web",[Wo]:zo,[Zo]:`${Qn(e)}`};return r&&(n={...n,...r}),t&&(n={...t,...n}),n}const Jo="/v1/subscribers",rn="/rcbilling/v1";class Id{constructor(r){F(this,"appUserId");F(this,"method","GET");F(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Jo}/${r}/offerings`}}class Td{constructor(){F(this,"method","POST");F(this,"name","purchase")}urlPath(){return`${rn}/purchase`}}class qd{constructor(r,t,n){F(this,"method","GET");F(this,"name","getProducts");F(this,"appUserId");F(this,"productIds");F(this,"currency");this.appUserId=r,this.productIds=t,this.currency=n}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),n=this.currency?`&currency=${this.currency}`:"";return`${rn}/subscribers/${r}/products?id=${t}${n}`}}class Fd{constructor(r){F(this,"method","GET");F(this,"name","getCustomerInfo");F(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Jo}/${r}`}}class Ad{constructor(){F(this,"method","GET");F(this,"name","getBrandingInfo")}urlPath(){return`${rn}/branding`}}class Cd{constructor(r){F(this,"method","GET");F(this,"name","getCheckoutStatus");F(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${rn}/checkout/${this.operationSessionId}`}}const Kn={};class Dd{constructor(r,t=Kn){F(this,"API_KEY");F(this,"httpConfig");this.API_KEY=r,this.httpConfig=t}async getOfferings(r){return await Jr(new Id(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Jr(new Fd(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,n){return await Jr(new qd(r,t,n),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Jr(new Ad,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postPurchase(r,t,n,a,o,i=void 0,s){const l={app_user_id:r,product_id:t,email:n,price_id:o.priceId,presented_offering_identifier:a.offeringIdentifier,supports_direct_payment:!0,trace_id:s};return i&&(l.metadata=i),o.id!=="base_option"&&(l.offer_id=o.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 Jr(new Td,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Jr(new Cd(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}}function Od(e){if(!/^rcb_[a-zA-Z0-9_.-]+$/.test(e))throw new ge(we.InvalidCredentialsError,"Invalid API key. Use your Web Billing API key.")}function Md(e){if(new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new ge(we.InvalidAppUserIdError,'Provided user id: "'+e+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function jd(e){if(e!=null&&e.endsWith("/"))throw new ge(we.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function Nd(e){if(e){for(const r in e)if(Sd.has(r))throw new ge(we.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Xn=(e=>(e.Current="current",e))(Xn||{});function Rd(e,r){async function t(...n){return await this.preload(),await e.call(this,...n)}return t}const Ko=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},jr=(e,r)=>e==null?null:Ko(e,r),Ud=(e,r,t)=>{const n=e.offering_ids_by_placement??null;if(n==null)return null;const a=e.fallback_offering_id??null;let o;if(t in n){const s=n[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[a])}else o=r[a];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,Ko(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:jr(o.weekly,t),monthly:jr(o.monthly,t),twoMonth:jr(o.twoMonth,t),threeMonth:jr(o.threeMonth,t),sixMonth:jr(o.sixMonth,t),annual:jr(o.annual,t),lifetime:jr(o.lifetime,t)}};function Ld(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const n={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=Dl(i,o,t,e.targeting);s!=null&&(n[o.identifier]=s)});const a=e.current_offering_id?n[e.current_offering_id]??null:null;return Object.keys(n).length==0&&G.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:n,current:a}}var $n;(function(e){e.body_s="p",e.body_m="p",e.body_l="p",e.body_xl="p",e.heading_xs="h6",e.heading_s="h5",e.heading_m="h4",e.heading_l="h3",e.heading_xl="h2",e.heading_xxl="h1"})($n||($n={}));var tn;(function(e){e[e.extra_light=100]="extra_light",e[e.thin=200]="thin",e[e.light=300]="light",e[e.regular=400]="regular",e[e.medium=500]="medium",e[e.semibold=600]="semibold",e[e.bold=700]="bold",e[e.extra_bold=800]="extra_bold",e[e.black=900]="black"})(tn||(tn={}));var nn;(function(e){e.body_s="13px",e.body_m="14px",e.body_l="15px",e.body_xl="16px",e.heading_xs="14px",e.heading_s="16px",e.heading_m="18px",e.heading_l="20px",e.heading_xl="26px",e.heading_xxl="32px"})(nn||(nn={}));var an;(function(e){e.leading="start",e.center="center",e.trailing="end"})(an||(an={}));var ea;(function(e){e.vertical="column",e.horizontal="row",e.zlayer="zstack"})(ea||(ea={}));var ra;(function(e){e.top="flex-start",e.leading="flex-start",e.center="center",e.bottom="flex-end",e.trailing="flex-end"})(ra||(ra={}));var ta;(function(e){e.space_between="space-between",e.space_around="space-around",e.space_evenly="space-evenly",e.start="flex-start",e.center="center",e.end="flex-end"})(ta||(ta={}));const Bd=["product_name","price","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","sub_offer_duration_2","sub_offer_price","sub_offer_price_2","sub_relative_discount"],zd=({value:e="",variableDictionary:r})=>r?Bd.reduce((t,n)=>{var o;return t.replaceAll(`{{ ${n} }}`,((o=r[n])==null?void 0:o.toString())||"N/A")},e):e;function Xo(e,r,t,n){var o;if(!e)return"";const a=(o=n[t])==null?void 0:o[e];return(n[r]||{})[e]?n[r][e]:a}function na({text_lid:e,locale:r,defaultLocale:t,labels:n,variableDictionary:a}){if(!e)return"";const o=Xo(e,r,t,n);return zd({value:o,variableDictionary:a})}const Kr=[];function Vd(e,r){return{subscribe:Hd(e,r).subscribe}}function Hd(e,r=rr){let t=null;const n=new Set;function a(s){if(xa(e,s)&&(e=s,t)){const l=!Kr.length;for(const u of n)u[1](),Kr.push(u,e);if(l){for(let u=0;u<Kr.length;u+=2)Kr[u][0](Kr[u+1]);Kr.length=0}}}function o(s){a(s(e))}function i(s,l=rr){const u=[s,l];return n.add(u),n.size===1&&(t=r(a,o)||rr),s(e),()=>{n.delete(u),n.size===0&&t&&(t(),t=null)}}return{set:a,update:o,subscribe:i}}const $o=Vd(!1,e=>{if(typeof window<"u"){const r=window.matchMedia("(prefers-color-scheme: dark)");e(r.matches);const t=n=>e(n.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)}return()=>{}});function ei(e,r){const t={[`--${r}-block-start`]:"0px",[`--${r}-inline-end`]:"0px",[`--${r}-block-end`]:"0px",[`--${r}-inline-start`]:"0px"};return!e||!r||Object.assign(t,{[`--${r}-block-start`]:`${e.top??0}px`,[`--${r}-inline-end`]:`${e.trailing??0}px`,[`--${r}-block-end`]:`${e.bottom??0}px`,[`--${r}-inline-start`]:`${e.leading??0}px`}),t}function Yd(e){return $n[e]}function fr({colorMap:e,colorMode:r="light",fallback:t="FFFFFF"}){if(!e)return t;const n=e[r]||e.light;let a="";switch(n.type){case"hex":case"alias":return n.value??t;case"linear":return a=(n.points||[]).map(o=>`${o.color} ${o.percent}%`).join(", "),`linear-gradient(${n.degrees}deg, ${a})`;case"radial":return a=(n.points||[]).map(o=>`${o.color} ${o.percent}%`).join(", "),`radial-gradient(${a})`;default:return t}}function ri(e,r="light"){if(!e)return"";const t=fr({colorMap:e.color,colorMode:r});return`${e.width}px solid ${t}`}function on(e){return{"--border-start-start-radius":`${e.top_leading}px`,"--border-start-end-radius":`${e.top_trailing}px`,"--border-end-start-radius":`${e.bottom_leading}px`,"--border-end-end-radius":`${e.bottom_trailing}px`}}function sn({background_color:e,border:r,margin:t,padding:n,color:a,colorMode:o="light",shape:i,shadow:s}){const l={"--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"initial","--text-color":"initial","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none"};return n&&Object.assign(l,ei(n,"padding")),t&&Object.assign(l,ei(t,"margin")),e&&(l["--background"]=fr({colorMap:e,colorMode:o,fallback:"transparent"})),a&&(l["--text-color"]=fr({colorMap:a,colorMode:o,fallback:"#000000"})),r&&(l["--border"]=ri(r,o)),(i==null?void 0:i.type)==="rectangle"&&i.corners&&Object.assign(l,on(i.corners)),(i==null?void 0:i.type)==="pill"&&Object.assign(l,on({bottom_leading:9999,bottom_trailing:9999,top_leading:9999,top_trailing:9999})),s&&(l["--shadow"]=`${s.x}px ${s.y}px ${s.radius}px
124
+ }`};function id(e,r){ne(r,!1),V(e,od);let t=w(r,"brandingAppearance",8,void 0),n=new Zn(t()).formStyleVars;Xe();var a=ad();K(a,"style",n);var o=I(a);Bo(o,{style:"min-height: 360px;",children:(i,s)=>{var l=nd(),u=D(l);he(u,r,"header",{});var c=A(u,2);he(c,r,"default",{}),y(i,l)},$$slots:{default:!0}}),y(e,a),ae()}var sd=x("<!> <!>",1),ld=x("<!> <!> <!> <!> <!> <!> <!>",1),ud=x("<!> <!>",1);function cd(e,r){ne(r,!1);let t=w(r,"asModal",8,!0),n=w(r,"customerEmail",12),a=w(r,"appUserId",8),o=w(r,"rcPackage",8),i=w(r,"purchaseOption",8),s=w(r,"metadata",8),l=w(r,"brandingInfo",8),u=w(r,"onFinished",8),c=w(r,"onError",8),_=w(r,"onClose",8),p=w(r,"purchases",8),f=w(r,"eventsTracker",8),m=w(r,"purchaseOperationHelper",8),h=w(r,"selectedLocale",8,pr),S=w(r,"defaultLocale",8,pr),b=w(r,"customTranslations",24,()=>({})),g=Ee(""),v=Ee(null),E=Ee(null),k=Ee(null);const q=o().webBillingProduct.identifier??null;let P=Ee("present-offer"),N=null,L=null;const J=["present-offer","needs-auth-info","processing-auth-info","needs-payment-info","polling-purchase-status","loading"];Vt(Mr,new $e(b(),h(),S())),Vt(Qt,f()),Gr(async()=>{var Z;if(M(v,o().webBillingProduct),M(g,Lo((Z=l())==null?void 0:Z.appearance)),d(P)==="present-offer"){n()?W():M(P,"needs-auth-info");return}});const ie=()=>{_()()},W=()=>{if(q===null){le(new ye(pe.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}else d(P)==="present-offer"&&M(P,"loading");if(!n()){le(new ye(pe.MissingEmailError));return}m().startPurchase(a(),q,i(),n(),o().webBillingProduct.presentedOfferingContext,s()).then(Z=>{if(Z.next_action==="collect_payment_info"){M(k,null),M(P,"needs-payment-info"),M(E,Z);return}if(Z.next_action==="completed"){M(k,null),M(P,"success");return}}).catch(Z=>{le(Z)})},se=Z=>{if(d(P)==="needs-auth-info"){Z&&(n(Z.email),M(P,"processing-auth-info")),W();return}if(d(P)==="needs-payment-info"){M(P,"polling-purchase-status"),m().pollCurrentPurchaseForCompletion().then(R=>{M(P,"success"),N=R.redemptionInfo,L=R.operationSessionId}).catch(R=>{le(R)});return}if(d(P)==="success"||d(P)==="error"){u()(L,N);return}M(P,"success")},le=Z=>{const R=_c({errorCode:Z.getErrorCode().toString(),errorMessage:Z.message});if(f().trackSDKEvent(R),d(P)==="processing-auth-info"&&Z.isRecoverable()){M(k,Z),M(P,"needs-auth-info");return}M(k,Z),M(P,"error")},Ie=()=>{c()(d(k)??new ye(pe.UnknownError,"Unknown error without state set."))};Xe(),Xc(e,{children:(Z,R)=>{Lc(Z,{get condition(){return t()},children:(fe,ue)=>{Qc(fe,{get style(){return d(g)},children:(sr,cn)=>{var Nr=ud(),Xr=D(Nr);{var lr=Te=>{var re=oe(()=>{var ee;return(ee=l())==null?void 0:ee.appearance});td(Te,{get brandingAppearance(){return d(re)},children:(ee,Ne)=>{var ve=te(),er=D(ve);{var ur=Ae=>{var hr=oe(()=>{var cr;return(cr=l())==null?void 0:cr.appearance});vo(Ae,{get productDetails(){return d(v)},get brandingAppearance(){return d(hr)},get purchaseOption(){return i()}})};j(er,Ae=>{d(v)&&i()&&Ae(ur)})}y(ee,ve)},$$slots:{default:!0,header:(ee,Ne)=>{Gn(ee,{slot:"header",children:(ve,er)=>{var ur=sd(),Ae=D(ur);So(Ae,{get brandingInfo(){return l()}});var hr=A(Ae,2);{var cr=ze=>{Gc(ze)},Ce=ze=>{Vc(ze)};j(hr,ze=>{p().isSandbox()?ze(cr):ze(Ce,!1)})}y(ve,ur)},$$slots:{default:!0}})}}})};j(Xr,Te=>{J.includes(d(P))&&Te(lr)})}var qt=A(Xr,2),mr=oe(()=>{var Te;return(Te=l())==null?void 0:Te.appearance});id(qt,{get brandingAppearance(){return d(mr)},children:(Te,re)=>{var ee=ld(),Ne=D(ee);{var ve=Q=>{vo(Q,{get productDetails(){return d(v)},get purchaseOption(){return i()}})};j(Ne,Q=>{d(P)==="present-offer"&&d(v)&&i()&&Q(ve)})}var er=A(Ne,2);{var ur=Q=>{Bn(Q)};j(er,Q=>{d(P)==="present-offer"&&!d(v)&&Q(ur)})}var Ae=A(er,2);{var hr=Q=>{var Sr=oe(()=>d(P)==="processing-auth-info");Oc(Q,{onContinue:se,onClose:ie,get processing(){return d(Sr)},get lastError(){return d(k)}})};j(Ae,Q=>{(d(P)==="needs-auth-info"||d(P)==="processing-auth-info")&&Q(hr)})}var cr=A(Ae,2);{var Ce=Q=>{var Sr=oe(()=>d(P)==="polling-purchase-status");Sc(Q,{get paymentInfoCollectionMetadata(){return d(E)},onContinue:se,onClose:ie,get processing(){return d(Sr)},get productDetails(){return d(v)},get purchaseOption(){return i()},get brandingInfo(){return l()}})};j(cr,Q=>{d(E)&&(d(P)==="needs-payment-info"||d(P)==="polling-purchase-status")&&d(v)&&i()&&Q(Ce)})}var ze=A(cr,2);{var $r=Q=>{Bn(Q)};j(ze,Q=>{d(P)==="loading"&&Q($r)})}var Rr=A(ze,2);{var et=Q=>{var Sr=oe(()=>d(k)??new ye(pe.UnknownError,"Unknown error without state set.")),fa=oe(()=>{var dn;return(dn=l())==null?void 0:dn.support_email});Su(Q,{get brandingInfo(){return l()},get lastError(){return d(Sr)},get supportEmail(){return d(fa)},get productDetails(){return d(v)},onContinue:Ie})};j(Rr,Q=>{d(P)==="error"&&Q(et)})}var _a=A(Rr,2);{var pa=Q=>{Au(Q,{get productDetails(){return d(v)},get brandingInfo(){return l()},onContinue:se})};j(_a,Q=>{d(P)==="success"&&Q(pa)})}y(Te,ee)},$$slots:{default:!0}}),y(sr,Nr)},$$slots:{default:!0}})},$$slots:{default:!0}})},$$slots:{default:!0}}),ae()}function dd(e){return e.expires_date==null?!0:new Date(e.expires_date)>new Date}function _d(e,r,t,n){const a=r.product_identifier;if(a in t)return pd(e,r,t[a]);if(a in n)return fd(e,r,n[a]);throw new ge(we.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function pd(e,r,t){return{identifier:e,isActive:dd(r),willRenew:gd(r,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:$t(r.expires_date),productIdentifier:r.product_identifier,unsubscribeDetectedAt:$t(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:$t(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"}}function fd(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,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal"}}function md(e,r,t){const n={},a={};for(const o in e){const i=_d(o,e[o],r,t);n[o]=i,i.isActive&&(a[o]=i)}return{all:n,active:a}}function $t(e){return e==null?null:new Date(e)}function hd(e){const r=bd(e),t=e.subscriber,n=kd(t.non_subscriptions);return{entitlements:md(t.entitlements,t.subscriptions,n),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:yd(e,n),activeSubscriptions:vd(r),managementURL:t.management_url,requestDate:new Date(e.request_date),firstSeenDate:new Date(t.first_seen),originalPurchaseDate:$t(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id}}function gd(e,r){if(r==null)return!1;const t=r.store=="promotional",n=e.expires_date==null,a=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||n||a||o)}function yd(e,r){const t={};for(const n in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[n];t[n]=new Date(a.purchase_date)}for(const n in r){const a=r[n].purchase_date;a==null?t[n]=null:t[n]=new Date(a)}return t}function bd(e){const r={};for(const t in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[t];n.expires_date==null?r[t]=null:r[t]=new Date(n.expires_date)}return r}function vd(e){const r=new Set,t=new Date;for(const n in e){const a=e[n];(a==null||a>t)&&r.add(n)}return r}function kd(e){const r={};for(const t in e){if(e[t].length===0)continue;const n=e[t].length;r[t]=e[t][n-1]}return r}const zo="0.18.2",wd="https://api.revenuecat.com",Pd="https://e.revenue.cat";var en;(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"})(en||(en={}));function Qn(e){return e?e.startsWith("rcb_sb_"):!1}async function Jr(e,r){const{apiKey:t,body:n,headers:a,httpConfig:o}=r,s=`${(o==null?void 0:o.proxyURL)??wd}${e.urlPath()}`;try{const l=await fetch(s,{method:e.method,headers:Qo(t,a,o==null?void 0:o.additionalHeaders),body:Ed(n)});return await xd(l,e),await l.json()}catch(l){throw l instanceof TypeError?new ge(we.NetworkError,wt.getPublicMessage(we.NetworkError),l.message):l}}async function xd(e,r){const t=e.status;if(t>=en.INTERNAL_SERVER_ERROR)Jn(r,t,await e.text());else if(t>=en.BAD_REQUEST){const n=await e.json(),a=n?JSON.stringify(n):null,o=n==null?void 0:n.code,i=n==null?void 0:n.message;if(o!=null){const s=wt.convertCodeToBackendErrorCode(o);if(s==null)Jn(r,t,a,o);else throw ge.getForBackendError(s,i)}else Jn(r,t,a)}}function Jn(e,r,t,n){throw new ge(we.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:n})}function Ed(e){return e==null?null:JSON.stringify(e)}const Vo="Authorization",Ho="Content-Type",Yo="Accept",Go="X-Platform",Wo="X-Version",Zo="X-Is-Sandbox",Sd=new Set([Vo,Ho,Yo,Go,Wo,Zo]);function Qo(e,r,t){let n={[Vo]:`Bearer ${e}`,[Ho]:"application/json",[Yo]:"application/json",[Go]:"web",[Wo]:zo,[Zo]:`${Qn(e)}`};return r&&(n={...n,...r}),t&&(n={...t,...n}),n}const Jo="/v1/subscribers",rn="/rcbilling/v1";class Id{constructor(r){F(this,"appUserId");F(this,"method","GET");F(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Jo}/${r}/offerings`}}class Td{constructor(){F(this,"method","POST");F(this,"name","purchase")}urlPath(){return`${rn}/purchase`}}class qd{constructor(r,t,n){F(this,"method","GET");F(this,"name","getProducts");F(this,"appUserId");F(this,"productIds");F(this,"currency");this.appUserId=r,this.productIds=t,this.currency=n}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),n=this.currency?`&currency=${this.currency}`:"";return`${rn}/subscribers/${r}/products?id=${t}${n}`}}class Fd{constructor(r){F(this,"method","GET");F(this,"name","getCustomerInfo");F(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Jo}/${r}`}}class Ad{constructor(){F(this,"method","GET");F(this,"name","getBrandingInfo")}urlPath(){return`${rn}/branding`}}class Cd{constructor(r){F(this,"method","GET");F(this,"name","getCheckoutStatus");F(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${rn}/checkout/${this.operationSessionId}`}}const Kn={};class Dd{constructor(r,t=Kn){F(this,"API_KEY");F(this,"httpConfig");this.API_KEY=r,this.httpConfig=t}async getOfferings(r){return await Jr(new Id(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Jr(new Fd(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,n){return await Jr(new qd(r,t,n),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Jr(new Ad,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postPurchase(r,t,n,a,o,i=void 0,s){const l={app_user_id:r,product_id:t,email:n,price_id:o.priceId,presented_offering_identifier:a.offeringIdentifier,supports_direct_payment:!0,trace_id:s};return i&&(l.metadata=i),o.id!=="base_option"&&(l.offer_id=o.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 Jr(new Td,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Jr(new Cd(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}}function Od(e){if(!/^rcb_[a-zA-Z0-9_.-]+$/.test(e))throw new ge(we.InvalidCredentialsError,"Invalid API key. Use your Web Billing API key.")}function Md(e){if(new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new ge(we.InvalidAppUserIdError,'Provided user id: "'+e+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function jd(e){if(e!=null&&e.endsWith("/"))throw new ge(we.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function Nd(e){if(e){for(const r in e)if(Sd.has(r))throw new ge(we.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Xn=(e=>(e.Current="current",e))(Xn||{});function Rd(e,r){async function t(...n){return await this.preload(),await e.call(this,...n)}return t}const Ko=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},jr=(e,r)=>e==null?null:Ko(e,r),Ud=(e,r,t)=>{const n=e.offering_ids_by_placement??null;if(n==null)return null;const a=e.fallback_offering_id??null;let o;if(t in n){const s=n[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[a])}else o=r[a];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,Ko(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:jr(o.weekly,t),monthly:jr(o.monthly,t),twoMonth:jr(o.twoMonth,t),threeMonth:jr(o.threeMonth,t),sixMonth:jr(o.sixMonth,t),annual:jr(o.annual,t),lifetime:jr(o.lifetime,t)}};function Ld(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const n={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=Dl(i,o,t,e.targeting);s!=null&&(n[o.identifier]=s)});const a=e.current_offering_id?n[e.current_offering_id]??null:null;return Object.keys(n).length==0&&G.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:n,current:a}}var $n;(function(e){e.body_s="p",e.body_m="p",e.body_l="p",e.body_xl="p",e.heading_xs="h6",e.heading_s="h5",e.heading_m="h4",e.heading_l="h3",e.heading_xl="h2",e.heading_xxl="h1"})($n||($n={}));var tn;(function(e){e[e.extra_light=100]="extra_light",e[e.thin=200]="thin",e[e.light=300]="light",e[e.regular=400]="regular",e[e.medium=500]="medium",e[e.semibold=600]="semibold",e[e.bold=700]="bold",e[e.extra_bold=800]="extra_bold",e[e.black=900]="black"})(tn||(tn={}));var nn;(function(e){e.body_s="13px",e.body_m="14px",e.body_l="15px",e.body_xl="16px",e.heading_xs="14px",e.heading_s="16px",e.heading_m="18px",e.heading_l="20px",e.heading_xl="26px",e.heading_xxl="32px"})(nn||(nn={}));var an;(function(e){e.leading="start",e.center="center",e.trailing="end"})(an||(an={}));var ea;(function(e){e.vertical="column",e.horizontal="row",e.zlayer="zstack"})(ea||(ea={}));var ra;(function(e){e.top="flex-start",e.leading="flex-start",e.center="center",e.bottom="flex-end",e.trailing="flex-end"})(ra||(ra={}));var ta;(function(e){e.space_between="space-between",e.space_around="space-around",e.space_evenly="space-evenly",e.start="flex-start",e.center="center",e.end="flex-end"})(ta||(ta={}));const Bd=["product_name","price","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","sub_offer_duration_2","sub_offer_price","sub_offer_price_2","sub_relative_discount"],zd=({value:e="",variableDictionary:r})=>r?Bd.reduce((t,n)=>{var o;return t.replaceAll(`{{ ${n} }}`,((o=r[n])==null?void 0:o.toString())||"N/A")},e):e;function Xo(e,r,t,n){var o;if(!e)return"";const a=(o=n[t])==null?void 0:o[e];return(n[r]||{})[e]?n[r][e]:a}function na({text_lid:e,locale:r,defaultLocale:t,labels:n,variableDictionary:a}){if(!e)return"";const o=Xo(e,r,t,n);return zd({value:o,variableDictionary:a})}const Kr=[];function Vd(e,r){return{subscribe:Hd(e,r).subscribe}}function Hd(e,r=rr){let t=null;const n=new Set;function a(s){if(xa(e,s)&&(e=s,t)){const l=!Kr.length;for(const u of n)u[1](),Kr.push(u,e);if(l){for(let u=0;u<Kr.length;u+=2)Kr[u][0](Kr[u+1]);Kr.length=0}}}function o(s){a(s(e))}function i(s,l=rr){const u=[s,l];return n.add(u),n.size===1&&(t=r(a,o)||rr),s(e),()=>{n.delete(u),n.size===0&&t&&(t(),t=null)}}return{set:a,update:o,subscribe:i}}const $o=Vd(!1,e=>{if(typeof window<"u"){const r=window.matchMedia("(prefers-color-scheme: dark)");e(r.matches);const t=n=>e(n.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)}return()=>{}});function ei(e,r){const t={[`--${r}-block-start`]:"0px",[`--${r}-inline-end`]:"0px",[`--${r}-block-end`]:"0px",[`--${r}-inline-start`]:"0px"};return!e||!r||Object.assign(t,{[`--${r}-block-start`]:`${e.top??0}px`,[`--${r}-inline-end`]:`${e.trailing??0}px`,[`--${r}-block-end`]:`${e.bottom??0}px`,[`--${r}-inline-start`]:`${e.leading??0}px`}),t}function Yd(e){return $n[e]}function fr({colorMap:e,colorMode:r="light",fallback:t="FFFFFF"}){if(!e)return t;const n=e[r]||e.light;let a="";switch(n.type){case"hex":case"alias":return n.value??t;case"linear":return a=(n.points||[]).map(o=>`${o.color} ${o.percent}%`).join(", "),`linear-gradient(${n.degrees}deg, ${a})`;case"radial":return a=(n.points||[]).map(o=>`${o.color} ${o.percent}%`).join(", "),`radial-gradient(${a})`;default:return t}}function ri(e,r="light"){if(!e)return"";const t=fr({colorMap:e.color,colorMode:r});return`${e.width}px solid ${t}`}function on(e){return{"--border-start-start-radius":`${e.top_leading}px`,"--border-start-end-radius":`${e.top_trailing}px`,"--border-end-start-radius":`${e.bottom_leading}px`,"--border-end-end-radius":`${e.bottom_trailing}px`}}function sn({background_color:e,border:r,margin:t,padding:n,color:a,colorMode:o="light",shape:i,shadow:s}){const l={"--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"initial","--text-color":"initial","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none"};return n&&Object.assign(l,ei(n,"padding")),t&&Object.assign(l,ei(t,"margin")),e&&(l["--background"]=fr({colorMap:e,colorMode:o,fallback:"transparent"})),a&&(l["--text-color"]=fr({colorMap:a,colorMode:o,fallback:"#000000"})),r&&(l["--border"]=ri(r,o)),(i==null?void 0:i.type)==="rectangle"&&i.corners&&Object.assign(l,on(i.corners)),(i==null?void 0:i.type)==="pill"&&Object.assign(l,on({bottom_leading:9999,bottom_trailing:9999,top_leading:9999,top_trailing:9999})),s&&(l["--shadow"]=`${s.x}px ${s.y}px ${s.radius}px
125
125
  ${fr({colorMap:s.color,colorMode:o,fallback:"#000000"})}`),l}function ti(e){return e.type==="fixed"?`${e.value}px`:e.type==="fit"?"fit-content":e.type==="fill"?navigator.userAgent.match(/firefox|fxios/i)?"-moz-available":"-webkit-fill-available":"initial"}function It(e){const r={"--width":"initial","--height":"initial","--flex":"initial"},t=ti(e.width),n=ti(e.height),a=e.width.type==="fill"||e.height.type==="fill";return Object.assign(r,{"--width":t,"--height":n,"--flex":a?"initial":"0 1 auto"}),r}function Gd(e,r){return r?{"--background":`linear-gradient(${r.map(t=>{var n;return((n=t[e])==null?void 0:n.value)||t.light.value}).join(", ")})`}:{"--background":"none"}}const Wd=e=>{const r={"--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--clip-path":"none"};return(e==null?void 0:e.type)==="circle"&&Object.assign(r,{"--border-end-start-radius":"50%","--border-end-end-radius":"50%","--border-start-start-radius":"50%","--border-start-end-radius":"50%"}),(e==null?void 0:e.type)==="rectangle"&&e.corners&&Object.assign(r,on(e.corners)),(e==null?void 0:e.type)==="convex"&&Object.assign(r,{"--border-start-start-radius":"0%","--border-start-end-radius":"0%","--border-end-start-radius":"50%","--border-end-end-radius":"50%"}),(e==null?void 0:e.type)==="concave"&&Object.assign(r,{"--clip-path":"polygon(0 0, 100% 0, 100% 100%, 50% 110%, 0 100%);"}),r};function ni(e){const r={"--inset":"initial","--transform":"initial"};switch(e.alignment){case"top_leading":r["--inset"]="0 auto auto 0";break;case"top":r["--inset"]="auto auto auto 50%",r["--transform"]="translate(-50%, 0)";break;case"top_trailing":r["--inset"]="0 0 auto auto";break;case"leading":r["--inset"]="50% 0 50% 0",r["--transform"]="translate(0, -50%)";break;case"center":r["--inset"]="50% auto auto 50%",r["--transform"]="translate(-50%, -50%)";break;case"trailing":r["--inset"]="50% 0 50% auto",r["--transform"]="translate(0, -50%)";break;case"bottom_leading":r["--inset"]="auto auto 0 0";break;case"bottom":r["--inset"]="auto 50% 0 auto",r["--transform"]="translate(50%, 0)";break;case"bottom_trailing":r["--inset"]="auto 0 0 auto";break}return r}function Zd(e){const r={"--direction":"initial","--alignment":"initial","--distribution":"initial","--position":"relative","--inset":"initial","--transform":"initial"};return e.type!=="zlayer"&&(Object.assign(r,{"--direction":ea[e.type],"--alignment":ra[e.alignment]}),e.distribution&&Object.assign(r,{"--distribution":ta[e.distribution]})),r}function Qd(e,r="light"){var l,u;const{font_size:t,horizontal_alignment:n,font_weight:a,font_name:o,color:i}=e,s={"--text-align":"initial","--font-weight":"initial","--font-size":"initial","--font-family":"sans-serif","--background-clip":"none","--text-fill-color":"none","--background":"unset"};return Object.assign(s,{"--text-align":an[n]||an.leading,"--font-weight":tn[a]||tn.regular,"--font-size":nn[t]||nn.body_m,"--font-family":o||"sans-serif"}),i&&(((l=i[r])==null?void 0:l.type)==="linear"||((u=i[r])==null?void 0:u.type)==="radial")&&Object.assign(s,{"--background-clip":"text","--text-fill-color":"transparent","--background":fr({colorMap:i,colorMode:r})}),s}function Me(e){return Object.entries(e).map(([r,t])=>`${r}: ${t}`).join("; ")}function Jd(e){const r=n=>{if(n.type==="package"&&n.is_selected_by_default)return n;if(n.components&&Array.isArray(n.components))for(const a of n.components){const o=r(a);if(o)return o}if(n.stack!==void 0){const a=r(n.stack);if(a)return a}},t=r(e.components_config.base.stack);if(t!==void 0)return t.package_id}const aa=(e,r)=>r?Kd(r).reduce((a,o)=>{var i;if(e){const s=((i=e==null?void 0:e.states)==null?void 0:i[o])||{};return{...a,...s}}return a},{}):{},Kd=e=>e?Object.entries(e).reduce((t,[n,a])=>(a&&t.push(n),t),[]):[];function Be(e,r){return e?r?Object.entries(e).reduce((t,[n,a])=>{const o=n.replace(/^--/,`${r}-`);return t[`--${o}`]=a,t},{}):e:{}}const ai={light:{type:"hex",value:"#000000"}},Xd={light:{type:"hex",value:"#FFFFFF"}},oa=e=>{const{font_size:r="body_m",color:t=ai,background_color:n=Xd,padding:a,margin:o,size:i,purchaseState:s}=e,l={"--width":"unset","--height":"unset","--text-align":"initial","--font-weight":"initial","--font-size":"initial","--font-family":"sans-serif","--background-clip":"unset","--text-fill-color":"unset","--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"transparent","--text-color":"inherit","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none","--flex":"0 1 auto"},u=aa(e.overrides,e.componentState),c=Yd(r),_=Qd({...e,...u},s.colorMode),p=sn({background_color:n,color:t,margin:o,padding:a,colorMode:s.colorMode,...u}),f=It({...i,...u}),m={...l,...p,..._,...f};return{textStyles:Be(m,"text"),tagToRender:c}};function $d(e,r,t){const n={"--width":"unset","--height":"unset","--flex":"0 1 auto","--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"transparent","--text-color":"inherit","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none","--position":"relative","--inset":"0","--transform":"initial"};Object.assign(n,sn({background_color:t,...e}),It(r)),Object.assign(n,e.zStackChildStyles);const a=Be(n,"text");return Me(a)}function e_(e){const r={"--text-margin-block-start":"0px","--text-margin-inline-end":"0px","--text-margin-block-end":"0px","--text-margin-inline-start":"0px","--text-padding-block-start":"0px","--text-padding-inline-end":"0px","--text-padding-block-end":"0px","--text-padding-inline-start":"0px","--text-background":"transparent","--text-text-color":"inherit","--text-border":"none","--text-border-end-start-radius":"0px","--text-border-end-end-radius":"0px","--text-border-start-start-radius":"0px","--text-border-start-end-radius":"0px","--text-shadow":"none","--text-text-align":"initial","--text-font-weight":"initial","--text-font-size":"initial","--text-font-family":"sans-serif","--text-background-clip":"initial","--text-text-fill-color":"initial","--text-width":"unset","--text-height":"unset","--text-flex":"0 1 auto"},{tagToRender:t,textStyles:n}=oa(e);return Object.assign(r,n),{tagToRender:t,textStyles:Me(r)}}function r_(e){return e?Object.values({newLine:{regexp:/\\\n/g,output:"<br/>"},bold:{regexp:/\*\*(.*?)\*\*/g,output:"<b>$1</b>"},italic:{regexp:/\*(.*?)\*/g,output:"<i>$1</i>"},strikethrough:{regexp:/~(.*?)~/g,output:"<s>$1</s>"},code:{regexp:/`(.*?)`/g,output:"<span style='font-family: monospace'>$1</span>"},link:{regexp:/\[(.*?)\]\((.*?)\)/g,output:"<a href=$2 target='_blank' rel='noopener noreferrer'>$1</a>"}}).reduce((t,{regexp:n,output:a})=>t.replaceAll(n,a),e):""}const t_={hash:"svelte-1wz4si8",code:".rc-pw-text-block.svelte-1wz4si8 {display:block;padding-block-start:var(--text-padding-block-start, initial);padding-inline-end:var(--text-padding-inline-end, initial);padding-block-end:var(--text-padding-block-end, initial);padding-inline-start:var(--text-padding-inline-start, initial);margin-block-start:var(--text-margin-block-start, initial);margin-inline-end:var(--text-margin-inline-end, initial);margin-block-end:var(--text-margin-block-end, initial);margin-inline-start:var(--text-margin-inline-start, initial);color:var(--text-text-color, #ffffff);background:var(--text-background, none);font-size:var(--text-font-size, 1rem);font-weight:var(--text-font-weight, normal);text-align:var(--text-text-align, center);font-family:var(--text-font-family, sans-serif);-webkit-background-clip:var(--text-background-clip, initial);background-clip:var(--text-background-clip, initial);-webkit-text-fill-color:var(--text-text-fill-color, initial);}"};function oi(e,r){ne(r,!0),V(e,t_);const t=w(r,"styleVariables",3,""),n=w(r,"component",3,"p");var a=te(),o=D(a);Yt(o,n,!1,(i,s)=>{let l;H(()=>l=Gt(i,l,{id:r.id,style:t(),class:"rc-pw-text-block"},"svelte-1wz4si8",i.namespaceURI===ke,i.nodeName.includes("-")));var u=te(),c=D(u);jn(c,()=>r.children??rr),y(s,u)}),y(e,a),ae()}var n_=x('<span class="rc-pw-text-wrapper svelte-11gzifq"><!></span>');const a_={hash:"svelte-11gzifq",code:".rc-pw-text-wrapper.svelte-11gzifq {display:block;height:var(--text-height, initial);width:var(--text-width, initial);background:var(--text-background, none);position:var(--text-position, relative);inset:var(--text-inset, 0);transform:var(--text-transform, initial);}"};function o_(e,r){ne(r,!0),V(e,a_);const t=Pr(r,["$$slots","$$events","$$legacy","id","labels","text_lid","purchaseState","variableDictionary","background_color","size"]),n=C(()=>e_({id:r.id,labels:r.labels,text_lid:r.text_lid,purchaseState:r.purchaseState,background_color:r.background_color,size:r.size,...t})),a=C(()=>d(n).tagToRender),o=C(()=>d(n).textStyles),i=C(()=>$d(t,r.size,r.background_color)),s=C(()=>na({text_lid:r.text_lid,locale:r.purchaseState.locale,defaultLocale:r.purchaseState.defaultLocale,labels:r.labels,variableDictionary:r.variableDictionary})),l=C(()=>r_(d(s)));var u=n_(),c=I(u);oi(c,{get styleVariables(){return d(o)},get component(){return d(a)},get id(){return r.id},children:(_,p)=>{var f=te(),m=D(f);Or(m,()=>d(l)),y(_,f)},$$slots:{default:!0}}),H(()=>K(u,"style",d(i))),y(e,u),ae()}const i_=(e,r)=>{var t;(t=r.onclick)==null||t.call(r)};var s_=x("<button><!></button>");function ii(e,r){ne(r,!0);var t=s_();t.__click=[i_,r];var n=I(t);jn(n,()=>r.children??rr),H(()=>{Nn(t,ao(r.class)),t.disabled=!r.onclick,K(t,"style",r.style)}),y(e,t),ae()}Dn(["click"]);const l_=e=>{const{background_color:r,margin:t,padding:n,spacing:a,size:o,border:i,shape:s,shadow:l,dimension:u,componentState:c,overrides:_,purchaseState:p,zStackChildStyles:f}=e,m={"--flex":"0 1 auto","--height":"initial","--width":"initial","--spacing":`${a||0}px`,"--direction":"unset","--alignment":"unset","--distribution":"flex-start","--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"unset","--text-color":"inherit","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none","--position":"relative","--transform":"initial","--inset":"initial"},h=aa(_,c);Object.assign(m,sn({background_color:r,margin:t,padding:n,border:i,colorMode:p.colorMode,shape:s,shadow:l,...h}),Zd({...u,...h}),It({...o,...h})),Object.assign(m,f);const S=Be(m,"stack");return Me(S)};function u_(e){var a,o,i,s,l,u;const{badge:r}=e;if(!r)return"";const t={"--inset":"unset","--transform":"unset","--margin-block-start":"0px","--margin-inline-end":"0px","--margin-block-end":"0px","--margin-inline-start":"0px","--padding-block-start":"0px","--padding-inline-end":"0px","--padding-block-end":"0px","--padding-inline-start":"0px","--background":"unset","--text-color":"inherit","--border":"none","--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px","--shadow":"none","--badge-width":"unset","--z-index":"unset"};if(Object.assign(t,ni({type:"zlayer",alignment:r.alignment}),sn({...r,background_color:r.background_color,color:r.color,colorMode:e.purchaseState.colorMode})),r.style==="overlay"&&(t["--margin-block-start"]="0px",t["--margin-block-end"]="0px",t["--transform"]=ln(r,0,-(((a=e.border)==null?void 0:a.width)||0))),r.style==="edge_to_edge")if(t["--margin-block-start"]="0px",t["--margin-block-end"]="0px",t["--margin-inline-start"]="0px",t["--margin-inline-end"]="0px",r.alignment==="top"||r.alignment==="bottom"){t["--badge-width"]=`calc(100% + ${(((o=e.border)==null?void 0:o.width)||0)*2}px)`,t["--z-index"]="-1";const c=Math.max(((s=(i=e.shape)==null?void 0:i.corners)==null?void 0:s.top_leading)||0,((u=(l=e.shape)==null?void 0:l.corners)==null?void 0:u.top_trailing)||0);r.alignment==="top"&&(t["--padding-block-end"]=`${c+r.padding.bottom}px`,t["--transform"]=ln(r,c)),r.alignment==="bottom"&&(t["--padding-block-start"]=`${c+r.padding.top}px`,t["--transform"]=ln(r,-c))}else t["--transform"]=ln(r),Object.assign(t,c_(e));const n=Be(t,"stack-badge");return Me(n)}const si={top_leading:"bottom_trailing",top_trailing:"bottom_leading",bottom_leading:"top_trailing",bottom_trailing:"top_leading"},li={top_leading:"--border-start-start-radius",top_trailing:"--border-start-end-radius",bottom_leading:"--border-end-start-radius",bottom_trailing:"--border-end-end-radius"};function c_(e){var o,i,s;const r={"--border-end-start-radius":"0px","--border-end-end-radius":"0px","--border-start-start-radius":"0px","--border-start-end-radius":"0px"},{badge:t}=e;if(!t)return r;const n=((o=e.border)==null?void 0:o.width)||0,a=t.alignment;return r[li[si[a]]]=`${(i=t.shape)==null?void 0:i.corners[si[a]]}px`,r[li[a]]=`${((s=e.shape)==null?void 0:s.corners[a])-n}px`,r}function ln(e,r=0,t=0){if(!e)return"";if(e.style==="overlay"){if(e.alignment==="top_leading")return`translate(${t}px, calc(-50% + ${r}px))`;if(e.alignment==="top_trailing")return`translate(calc(0% - ${t}px), calc(-50% + ${r}px))`;if(e.alignment==="bottom_leading")return`translate(${t}px, calc(50% + ${r}px))`;if(e.alignment==="bottom_trailing")return`translate(calc(0% - ${t}px), calc(50% + ${r}px))`;if(e.alignment==="top")return`translate(calc(-50% + ${t}px), calc(-50% + ${r}px))`;if(e.alignment==="bottom")return`translate(calc(50% + ${t}px), calc(50% + ${r}px))`}if(e.style==="edge_to_edge"){if(e.alignment==="top")return`translate(calc(-50% + ${t}px), calc(-100% - ${r}px + 16px))`;if(e.alignment==="bottom")return`translate(calc(50% + ${t}px), calc(100% + ${r}px))`}return""}function d_(e){const{badge:r}=e;if(!r)return{tagToRender:"",textStyles:""};const{tagToRender:t,textStyles:n}=oa({id:e.id,labels:e.labels,purchaseState:e.purchaseState,...r,components:[],type:"text",size:{width:{type:"fit"},height:{type:"fit"}},color:r==null?void 0:r.color,name:e.name}),o={...n,...{"--text-margin-block-start":"0px","--text-margin-inline-end":"0px","--text-margin-block-end":"0px","--text-margin-inline-start":"0px","--text-padding-block-start":"0px","--text-padding-inline-end":"0px","--text-padding-block-end":"0px","--text-padding-inline-start":"0px"}},i=Me(o);return{tagToRender:t,textStyles:i}}function __(e){const{dimension:r}=e,t={"--inset":"initial","--transform":"initial","--position":"relative"};if(r.type!=="zlayer")return;const n=ni({...r,type:"zlayer"});return Object.assign(t,{...n,"--position":"absolute"}),t}var p_=x('<span class="rc-pw-badge svelte-1b5bst5"><!></span>'),f_=x('<div class="rc-pw-stack-wrapper svelte-1b5bst5"><!> <div class="rc-pw-stack svelte-1b5bst5"></div></div>');const m_={hash:"svelte-1b5bst5",code:`.rc-pw-stack-wrapper.svelte-1b5bst5 {display:block;box-sizing:border-box;width:var(--stack-width, unset);height:var(--stack-height, unset);box-shadow:var(--stack-shadow, none);background:var(--stack-background, unset);position:var(--stack-position, relative);transform:var(--stack-transform, initial);inset:var(--stack-inset, initial);margin-block-start:var(--stack-margin-block-start, 0);margin-inline-end:var(--stack-margin-inline-end, 0);margin-block-end:var(--stack-margin-block-end, 0);margin-inline-start:var(--stack-margin-inline-start, 0);border:var(--stack-border, none);border-end-start-radius:var(--stack-border-end-start-radius, 0px);border-end-end-radius:var(--stack-border-end-end-radius, 0px);border-start-start-radius:var(--stack-border-start-start-radius, 0px);border-start-end-radius:var(--stack-border-start-end-radius, 0px);}.rc-pw-stack.svelte-1b5bst5 {background:none;overflow:hidden;box-sizing:border-box;width:100%;height:100%;display:flex;gap:var(--stack-spacing, 0);flex:var(--stack-flex, 0 1 auto);flex-direction:var(--stack-direction, unset);justify-content:var(--stack-distribution, flex-start);align-items:var(--stack-alignment, flex-start);padding-block-start:var(--stack-padding-block-start, 0);padding-inline-end:var(--stack-padding-inline-end, 0);padding-block-end:var(--stack-padding-block-end, 0);padding-inline-start:var(--stack-padding-inline-start, 0);}.rc-pw-badge.svelte-1b5bst5 {box-sizing:border-box;font-family:var(--stack-badge-font-family, sans-serif);position:absolute;inset:var(--stack-badge-inset, unset);transform:var(--stack-badge-transform, initial);margin-block-start:var(--stack-badge-margin-block-start, 0px);margin-inline-end:var(--stack-badge-margin-inline-end, 0px);margin-block-end:var(--stack-badge-margin-block-end, 0px);margin-inline-start:var(--stack-badge-margin-inline-start, 0px);padding-block-start:var(--stack-badge-padding-block-start, 0px);padding-inline-end:var(--stack-badge-padding-inline-end, 0px);padding-block-end:var(--stack-badge-padding-block-end, 0px);padding-inline-start:var(--stack-badge-padding-inline-start, 0px);background:var(--stack-badge-background, initial);color:var(--stack-badge-text-color, inherit);border:var(--stack-badge-border, none);border-end-start-radius:var(--stack-badge-border-end-start-radius, 0px);border-end-end-radius:var(--stack-badge-border-end-end-radius, 0px);border-start-start-radius:var(
126
126
  --stack-badge-border-start-start-radius,
127
127
  0px
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-js",
3
3
  "description": "Web subscriptions made easy. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "0.18.1",
5
+ "version": "0.18.2",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"