1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47953d25-47fd-4230-bda2-11463cc2d473",e._sentryDebugIdIdentifier="sentry-dbid-47953d25-47fd-4230-bda2-11463cc2d473")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6361],{46361:(e,t,n)=>{n.d(t,{B1:()=>A,K0:()=>S,LZ:()=>R,Rm:()=>M,X7:()=>T,Xu:()=>r,Zs:()=>i,aG:()=>_,hI:()=>B,qv:()=>q,rs:()=>I,xB:()=>E,xO:()=>U,y8:()=>b});class r extends Error{constructor(e,t,n,r=null){super(e),this.name="BillingResponseError",this.billingStatus=t,this.billingProblemType=n,this.retryAfterMs=r}}function i(e){return e instanceof r&&409===e.billingStatus&&"https://api.silentsuite.io/errors/plan-not-purchasable"===e.billingProblemType}function o(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function a(e,t){let n=Object.keys(e).sort();return n.length===t.length&&n.every((e,n)=>e===[...t].sort()[n])}function l(e){return"string"==typeof e&&/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$/.test(e)&&!Number.isNaN(Date.parse(e))}function s(e){return null===e||l(e)}function c(e){return"string"==typeof e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function u(e){return"string"==typeof e&&/^[A-Za-z0-9_-]{43,128}$/.test(e)}function d(e,t){if("string"!=typeof e||e.length>8192)return!1;let n=e.split(".");if(3!==n.length||n[0].length>1024||86!==n[2].length)return!1;try{let e=n.map(e=>{if(!/^[A-Za-z0-9_-]+$/.test(e))throw Error("Invalid JWS encoding");let t=atob(e.replace(/-/g,"+").replace(/_/g,"/"));if(btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")!==e)throw Error("Invalid JWS encoding");return Uint8Array.from(t,e=>e.charCodeAt(0))}),r=new TextDecoder("utf-8",{fatal:!0}),i=JSON.parse(r.decode(e[0])),l=JSON.parse(r.decode(e[1])),s="checkout-intent"===t;return o(i)&&a(i,["alg","typ","kid"])&&"ES256"===i.alg&&i.typ==="ss-".concat(t,"+jwt")&&"string"==typeof i.kid&&i.kid.length>0&&64===e[2].length&&o(l)&&"silentsuite-billing"===l.iss&&l.aud===(s?"silentsuite-billing-checkout":"silentsuite-billing-signup-email-ownership")&&l.purpose===(s?"checkout_intent":"email_ownership")&&2===l.contractVersion}catch(e){return!1}}function f(e){try{return"string"==typeof e&&"https:"===new URL(e).protocol}catch(e){return!1}}function p(e){let t;try{t=new URL(e)}catch(e){throw Error("Billing return URL must be an absolute HTTP(S) URL")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("Billing return URL must be an absolute HTTP(S) URL");return t.toString()}function y(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n])}function h(e){if(!o(e)||!a(e,["contractVersion","requestId","offer"])||2!==e.contractVersion||!c(e.requestId)||!o(e.offer))throw Error("Billing did not return a valid annual offer");let t=e.offer;if(!a(t,["planId","customerClass","billingInterval","annualAmountMinor","monthlyEquivalentMinor","currency","providers","offerRevision","offerToken","expiresAt"]))throw Error("Billing did not return a canonical annual offer");let n="early_annual"===t.planId&&"early"===t.customerClass&&3600===t.annualAmountMinor&&300===t.monthlyEquivalentMinor&&y(t.providers,["stripe","btcpay"]),r="standard_annual"===t.planId&&"standard"===t.customerClass&&4800===t.annualAmountMinor&&400===t.monthlyEquivalentMinor&&y(t.providers,["stripe"]);if(!n&&!r||"annual"!==t.billingInterval||"EUR"!==t.currency||!Number.isInteger(t.offerRevision)||"string"!=typeof t.offerToken||!t.offerToken||!l(t.expiresAt))throw Error("Billing did not return a canonical annual offer")}function g(e){if(!o(e)||!a(e,["kind","annualAmountMinor","firstChargeAmountMinor","renewalAmountMinor","monthlyEquivalentMinor","currency","trialEndsAt","firstChargeAt","cancelBy","cancelByInclusive","autoRenew","prepaid","refundWindowDays","bonusDays","periodEndRule","renewalAt","entitlementEndsAt"])||!((3600===e.annualAmountMinor&&300===e.monthlyEquivalentMinor||4800===e.annualAmountMinor&&400===e.monthlyEquivalentMinor)&&"EUR"===e.currency&&"number"==typeof e.firstChargeAmountMinor&&("number"==typeof e.renewalAmountMinor||null===e.renewalAmountMinor)&&s(e.trialEndsAt)&&s(e.firstChargeAt)&&s(e.cancelBy)&&!1===e.cancelByInclusive&&"boolean"==typeof e.autoRenew&&"boolean"==typeof e.prepaid&&(30===e.refundWindowDays||null===e.refundWindowDays)&&(0===e.bonusDays||14===e.bonusDays)&&["activation_plus_trial","first_charge_plus_1_utc_calendar_year","confirmation_plus_1_utc_calendar_year","confirmation_bonus_then_1_utc_calendar_year"].includes(String(e.periodEndRule))&&s(e.renewalAt)&&s(e.entitlementEndsAt)))throw Error("Billing did n
1ot return complete annual terms");let t=e.annualAmountMinor,n="no_auto_charge"===e.kind&&0===e.firstChargeAmountMinor&&null===e.renewalAmountMinor&&null!==e.trialEndsAt&&null===e.firstChargeAt&&null===e.cancelBy&&!e.autoRenew&&!e.prepaid&&null===e.refundWindowDays&&0===e.bonusDays&&"activation_plus_trial"===e.periodEndRule&&null===e.renewalAt&&e.entitlementEndsAt===e.trialEndsAt,r="card_trial"===e.kind&&e.firstChargeAmountMinor===t&&e.renewalAmountMinor===t&&null!==e.trialEndsAt&&e.firstChargeAt===e.trialEndsAt&&e.cancelBy===e.trialEndsAt&&e.autoRenew&&!e.prepaid&&30===e.refundWindowDays&&0===e.bonusDays&&"first_charge_plus_1_utc_calendar_year"===e.periodEndRule&&null!==e.renewalAt&&e.entitlementEndsAt===e.renewalAt,i=14===e.bonusDays?"confirmation_bonus_then_1_utc_calendar_year":"confirmation_plus_1_utc_calendar_year",l="charge_now"===e.kind&&e.firstChargeAmountMinor===t&&e.renewalAmountMinor===t&&null===e.trialEndsAt&&null===e.firstChargeAt&&null===e.cancelBy&&e.autoRenew&&!e.prepaid&&30===e.refundWindowDays&&e.periodEndRule===i&&null===e.renewalAt&&null===e.entitlementEndsAt,c="prepaid"===e.kind&&e.firstChargeAmountMinor===t&&null===e.renewalAmountMinor&&null===e.trialEndsAt&&null===e.firstChargeAt&&null===e.cancelBy&&!e.autoRenew&&e.prepaid&&30===e.refundWindowDays&&e.periodEndRule===i&&null===e.renewalAt&&null===e.entitlementEndsAt;if(!n&&!r&&!l&&!c)throw Error("Billing returned inconsistent annual terms")}function m(e){if(!o(e)||!a(e,["contractVersion","checkoutIntentToken","expiresAt","disclosure"])||2!==e.contractVersion||!d(e.checkoutIntentToken,"checkout-intent")||!l(e.expiresAt))throw Error("Billing did not return a valid annual checkout authority");g(e.disclosure)}async function w(e){var t,n;let i,a=null!=(n=null==(t=e.headers)?void 0:t.get("retry-after"))?n:null,l=null===a?NaN:/^\d+$/.test(a.trim())?1e3*Number(a):Date.parse(a)-Date.now(),s=Number.isFinite(l)?Math.max(0,l):429===e.status?9e5:null;try{i=await e.json()}catch(t){if(!e.ok)throw new r("Billing returned an invalid error response",e.status,null,s);throw Error("Billing returned an invalid response")}if(!e.ok)throw new r(o(i)&&"string"==typeof i.detail?i.detail:"Billing request failed",e.status,o(i)&&"string"==typeof i.type?i.type:null,s);return i}function v(e,t){return"".concat(e.replace(/\/$/,"")).concat(t)}function k(e,t){return{method:e,credentials:"include",headers:{"content-type":"application/json"},...t?{body:JSON.stringify(t)}:{}}}async function b(e){let{fetcher:t}=e;if(!c(e.requestId)||!d(e.checkoutIntentToken,"checkout-intent")||!d(e.emailOwnershipToken,"email-ownership"))throw Error("Invalid selection cancellation request");let n=JSON.parse(atob(e.checkoutIntentToken.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")));if(!o(n)||!c(n.jti)||n.requestId!==e.requestId)throw Error("Invalid selection cancellation identity");let r=await t(v(e.billingApiUrl,"/auth/offers/v2/cancel"),k("POST",{contractVersion:2,email:e.email,requestId:e.requestId,checkoutIntentToken:e.checkoutIntentToken,emailOwnershipToken:e.emailOwnershipToken})),i=await w(r);if(200!==r.status||!o(i)||!a(i,["contractVersion","requestId","checkoutIntentJti","state"])||2!==i.contractVersion||"released"!==i.state||i.requestId!==e.requestId||i.checkoutIntentJti!==n.jti)throw Error("Billing did not confirm cancellation of this exact selection");return i}async function I(e){let{fetcher:t}=e,n=await w(await t(v(e.billingApiUrl,"/auth/offers/v2"),k("POST",{contractVersion:2,email:e.email,requestId:e.requestId})));if(h(n),n.requestId!==e.requestId)throw Error("Billing returned an offer for another request");return n}async function A(e){let{fetcher:t}=e;h(e.offer);let n=await w(await t(v(e.billingApiUrl,"/auth/offers/v2/activate"),k("POST",{contractVersion:2,offerToken:e.offer.offer.offerToken,requestId:e.offer.requestId,email:e.email,emailOwnershipToken:e.emailOwnershipToken,trialPath:e.trialPath,provider:e.provider,behavior:e.behavior})));return m(n),n}async function E(e){let{fetcher:t}=e,n=await t(v(e.billingApiUrl,"/auth/signup-email-verifications/v2"),k("POST",{contractVersion:2,email:e.email,requestId:e.requestId}));
1if(202!==n.status)throw await w(n),Error("Billing did not acknowledge email proof delivery")}async function _(e){let{fetcher:t}=e,n=await w(await t(v(e.billingApiUrl,"/auth/signup-email-verifications/v2/consume"),k("POST",{contractVersion:2,email:e.email,token:e.token})));if(!o(n)||!a(n,["contractVersion","emailOwnershipToken","expiresAt"])||2!==n.contractVersion||!d(n.emailOwnershipToken,"email-ownership")||!l(n.expiresAt))throw Error("Billing did not return valid email proof");return n}async function T(e){let{fetcher:t}=e,n=await w(await t(v(e.billingApiUrl,"/subscription/offers/v2"),k("GET")));return h(n),n}async function S(e){let{fetcher:t}=e;h(e.offer);let n=await w(await t(v(e.billingApiUrl,"/subscription/offers/v2/activate"),k("POST",{contractVersion:2,offerToken:e.offer.offer.offerToken,requestId:e.offer.requestId,trialPath:e.trialPath,provider:e.provider,behavior:e.behavior})));return m(n),n}async function q(e){let{fetcher:t}=e,n=p(e.returnUrl),r=await w(await t(v(e.billingApiUrl,"/auth/signup/payment-session/v2"),k("POST",{contractVersion:2,checkoutIntentToken:e.checkoutIntentToken,email:e.email,requestKey:e.requestKey,recoverySecret:e.recoverySecret,wantsProductUpdates:e.wantsProductUpdates,rememberDevice:e.rememberDevice,returnUrl:n})));if(!o(r)||2!==r.contractVersion||"stripe"!==r.kind&&"btcpay"!==r.kind)throw Error("Billing did not return a valid payment session");if("stripe"===r.kind){if(!a(r,["contractVersion","kind","clientSecret","paymentSessionToken"])||"string"!=typeof r.clientSecret||!r.clientSecret||!u(r.paymentSessionToken))throw Error("Billing did not return a valid payment session")}else if(!a(r,["contractVersion","kind","cryptoCheckoutUrl","cryptoInvoiceId","cryptoInvoiceLookupToken","paymentSessionToken"])||!f(r.cryptoCheckoutUrl)||"string"!=typeof r.cryptoInvoiceId||!r.cryptoInvoiceId||!u(r.cryptoInvoiceLookupToken)||!u(r.paymentSessionToken))throw Error("Billing did not return a valid payment session");if(r.paymentSessionToken!==e.recoverySecret)throw Error("Billing returned payment recovery for another signup");if("btcpay"===r.kind&&r.cryptoInvoiceLookupToken!==e.recoverySecret)throw Error("Billing returned cryptocurrency recovery for another signup");return r}async function B(e){let{fetcher:t}=e;if(!c(e.expectedAuthorityId))throw Error("The expected annual authority is invali
1d");let n=p(e.returnUrl),r=await w(await t(v(e.billingApiUrl,"/subscription/payment-flows/v2"),k("POST",{contractVersion:2,checkoutIntentToken:e.checkoutIntentToken,returnUrl:n})));if(!o(r)||2!==r.contractVersion||"stripe"!==r.kind&&"btcpay"!==r.kind)throw Error("Billing did not return a valid payment session");if("stripe"===r.kind){if(!a(r,["contractVersion","kind","authorityId","clientSecret"])||!c(r.authorityId)||"string"!=typeof r.clientSecret||!r.clientSecret)throw Error("Billing did not return a valid payment session")}else if(!a(r,["contractVersion","kind","authorityId","checkoutUrl","invoiceId","invoiceLookupToken"])||!c(r.authorityId)||!f(r.checkoutUrl)||"string"!=typeof r.invoiceId||!r.invoiceId||"string"!=typeof r.invoiceLookupToken||!r.invoiceLookupToken)throw Error("Billing did not return a valid payment session");if(r.authorityId!==e.expectedAuthorityId)throw Error("Billing returned payment details for another annual authority");return r}async function O(e,t){let{fetcher:n}=t;if(void 0!==t.confirmNoBitcoinSent&&"boolean"!=typeof t.confirmNoBitcoinSent||!u(t.paymentSessionToken)||!u(t.recoverySecret)||t.paymentSessionToken!==t.recoverySecret||!c(t.requestKey)||"string"!=typeof t.email||0===t.email.length||t.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.email))throw Error("The annual payment recovery context is invalid");let r=await n(v(t.billingApiUrl,"/auth/signup/payment-session/v2".concat(e)),{method:"POST",credentials:"omit",headers:{"content-type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({contractVersion:2,email:t.email,requestKey:t.requestKey,recoverySecret:t.recoverySecret,switchingProfile:"v1",..."/cancel"===e&&void 0!==t.confirmNoBitcoinSent?{confirmNoBitcoinSent:t.confirmNoBitcoinSent}:{}})}),i=await w(r);if(200!==r.status)throw Error("Billing returned an invalid annual payment recovery response status");if(!function(e){let t=()=>{throw Error("Billing did not return valid annual payment recovery")};if(!o(e)||!a(e,["contractVersion","state","flow",..."release"in e?["release"]:[],..."continuation"in e?["continuation"]:[]])||2!==e.contractVersion||!["open","confirmed","closed","released"].includes(String(e.state))||null!==e.flow&&(!o(e.flow)||!a(e.flow,["provider","status"])||!["stripe","btcpay"].includes(String(e.flow.provider))||"string"!=typeof e.flow.status))return t();if("released"===e.state){let n=e.release;if(!o(n)||!a(n,["requestKey","provider","providerObjectId"])||!c(n.requestKey)||!o(e.flow)||n.provider!==e.flow.provider||null!==n.providerObjectId&&("string"!=typeof n.providerObjectId||!n.providerObjectId))return t()}else if("release"in e)return t();if("continuation"in e){let n=e.continuation;if("open"!==e.state||!o(n)||!o(e.flow)||n.provider!==e.flow.provider||!c(n.requestKey)||"string"!=typeof n.providerObjectId||!n.providerObjectId)return t();let r="stripe"===n.provider?"clientSecret":"checkoutUrl";if(!a(n,["requestKey","provider","providerObjectId","disclosure",r])||"string"!=typeof n[r]||!n[r]||(g(n.disclosure),"stripe"===n.provider&&!["card_trial","charge_now"].includes(n.disclosure.kind)))return t();if("btcpay"===n.provider){if("prepaid"!==n.disclosure.kind)return t();try{let e=new URL(n.checkoutUrl);(!["https:","http:"].includes(e.protocol)||e.username||e.password)&&t()}catch(e){return t()}}}}(i),i.release&&i.release.requestKey!==t.requestKey||i.continuation&&i.continuation.requestKey!==t.requestKey)throw Error("Billing returned mismatched payment recovery identity");return i}function U(e){return O("/current",e)}function M(e){return O("/cancel",e)}function R(e){return O("/reconcile",e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.