@whop/checkout 0.0.38 → 0.0.39
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/README.md +2 -380
- package/dist/static/checkout/chunk-D7BU562Q.mjs +1 -0
- package/dist/static/checkout/index.cjs +1 -1
- package/dist/static/checkout/index.js +1 -1
- package/dist/static/checkout/index.mjs +1 -1
- package/dist/static/checkout/loader.cjs +1 -1
- package/dist/static/checkout/loader.js +1 -1
- package/dist/static/checkout/loader.mjs +1 -1
- package/dist/static/checkout/react/index.cjs +1 -1
- package/dist/static/checkout/react/index.d.mts +28 -2
- package/dist/static/checkout/react/index.d.ts +28 -2
- package/dist/static/checkout/react/index.js +1 -1
- package/dist/static/checkout/react/index.mjs +1 -1
- package/dist/static/checkout/util-B5tOGbpF.d.mts +130 -0
- package/dist/static/checkout/util-B5tOGbpF.d.ts +130 -0
- package/dist/static/checkout/util.cjs +1 -1
- package/dist/static/checkout/util.d.mts +1 -82
- package/dist/static/checkout/util.d.ts +1 -82
- package/dist/static/checkout/util.js +1 -1
- package/dist/static/checkout/util.mjs +1 -1
- package/package.json +1 -1
- package/dist/static/checkout/chunk-N2KVERZN.mjs +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
wco?: {
|
|
4
|
+
injected: true;
|
|
5
|
+
listening: boolean;
|
|
6
|
+
frames: Map<HTMLIFrameElement, () => void>;
|
|
7
|
+
identifiedFrames: Map<string, HTMLIFrameElement>;
|
|
8
|
+
submit: (identifier: string, data?: WhopCheckoutSubmitDetails) => void;
|
|
9
|
+
getEmail: (identifier: string, timeout?: number) => Promise<string>;
|
|
10
|
+
setEmail: (
|
|
11
|
+
identifier: string,
|
|
12
|
+
email: string,
|
|
13
|
+
timeout?: number,
|
|
14
|
+
) => Promise<void>;
|
|
15
|
+
getAddress: (
|
|
16
|
+
identifier: string,
|
|
17
|
+
timeout?: number,
|
|
18
|
+
) => Promise<{
|
|
19
|
+
address: WhopCheckoutAddress;
|
|
20
|
+
isComplete: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
setAddress: (
|
|
23
|
+
identifier: string,
|
|
24
|
+
address: WhopCheckoutAddress,
|
|
25
|
+
timeout?: number,
|
|
26
|
+
) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface HTMLElementEventMap {
|
|
31
|
+
"checkout:submit": CustomEvent<WhopCheckoutSubmitDetails>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type WhopCheckoutSubmitDetails = Record<never, never>;
|
|
36
|
+
|
|
37
|
+
type WhopCheckoutAddress = {
|
|
38
|
+
name: string;
|
|
39
|
+
country: string;
|
|
40
|
+
line1: string;
|
|
41
|
+
line2?: string;
|
|
42
|
+
city: string;
|
|
43
|
+
state: string;
|
|
44
|
+
postalCode: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type WhopCheckoutState = "loading" | "ready" | "disabled";
|
|
48
|
+
type WhopCheckoutMessage = {
|
|
49
|
+
event: "resize";
|
|
50
|
+
height: number;
|
|
51
|
+
} | {
|
|
52
|
+
event: "center";
|
|
53
|
+
} | {
|
|
54
|
+
event: "complete";
|
|
55
|
+
receipt_id?: string;
|
|
56
|
+
plan_id: string;
|
|
57
|
+
} | {
|
|
58
|
+
event: "state";
|
|
59
|
+
state: WhopCheckoutState;
|
|
60
|
+
} | {
|
|
61
|
+
event: "get-email-result";
|
|
62
|
+
email: string;
|
|
63
|
+
event_id: string;
|
|
64
|
+
} | {
|
|
65
|
+
event: "set-email-result";
|
|
66
|
+
ok: true;
|
|
67
|
+
error?: never;
|
|
68
|
+
event_id: string;
|
|
69
|
+
} | {
|
|
70
|
+
event: "set-email-result";
|
|
71
|
+
ok: false;
|
|
72
|
+
error: string;
|
|
73
|
+
event_id: string;
|
|
74
|
+
} | {
|
|
75
|
+
event: "set-address-result";
|
|
76
|
+
ok: true;
|
|
77
|
+
error?: never;
|
|
78
|
+
event_id: string;
|
|
79
|
+
} | {
|
|
80
|
+
event: "set-address-result";
|
|
81
|
+
ok: false;
|
|
82
|
+
error: string;
|
|
83
|
+
event_id: string;
|
|
84
|
+
} | {
|
|
85
|
+
event: "get-address-result";
|
|
86
|
+
ok: true;
|
|
87
|
+
address: WhopCheckoutAddress;
|
|
88
|
+
is_complete: boolean;
|
|
89
|
+
event_id: string;
|
|
90
|
+
} | {
|
|
91
|
+
event: "get-address-result";
|
|
92
|
+
ok: false;
|
|
93
|
+
error: string;
|
|
94
|
+
event_id: string;
|
|
95
|
+
} | {
|
|
96
|
+
event: "address-validation-error";
|
|
97
|
+
error_message: string;
|
|
98
|
+
error_code: string;
|
|
99
|
+
};
|
|
100
|
+
declare function isWhopCheckoutMessage(event: MessageEvent<unknown>): event is MessageEvent<WhopCheckoutMessage>;
|
|
101
|
+
|
|
102
|
+
declare function onWhopCheckoutMessage(iframe: HTMLIFrameElement, callback: (message: WhopCheckoutMessage) => void): () => void;
|
|
103
|
+
declare function setEmail(frame: HTMLIFrameElement, email: string, timeout?: number): Promise<void>;
|
|
104
|
+
declare function getEmail(frame: HTMLIFrameElement, timeout?: number): Promise<string>;
|
|
105
|
+
declare function setAddress(frame: HTMLIFrameElement, address: WhopCheckoutAddress, timeout?: number): Promise<void>;
|
|
106
|
+
declare function getAddress(frame: HTMLIFrameElement, timeout?: number): Promise<{
|
|
107
|
+
address: WhopCheckoutAddress;
|
|
108
|
+
isComplete: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
declare function submitCheckoutFrame(frame: HTMLIFrameElement, _data?: WhopCheckoutSubmitDetails): void;
|
|
111
|
+
|
|
112
|
+
interface WhopEmbeddedCheckoutStyleOptions {
|
|
113
|
+
container?: {
|
|
114
|
+
paddingTop?: number | string;
|
|
115
|
+
paddingBottom?: number | string;
|
|
116
|
+
paddingY?: number | string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface WhopEmbeddedCheckoutPrefillOptions {
|
|
120
|
+
email?: string;
|
|
121
|
+
address?: Partial<WhopCheckoutAddress>;
|
|
122
|
+
}
|
|
123
|
+
interface WhopEmbeddedCheckoutThemeOptions {
|
|
124
|
+
accentColor?: string;
|
|
125
|
+
}
|
|
126
|
+
declare function getEmbeddedCheckoutIframeUrl(planId: string, theme?: "light" | "dark" | "system", sessionId?: string, origin?: string, hidePrice?: boolean, skipRedirect?: boolean, utm?: Record<string, string | string[]>, styles?: WhopEmbeddedCheckoutStyleOptions, prefill?: WhopEmbeddedCheckoutPrefillOptions, themeOptions?: WhopEmbeddedCheckoutThemeOptions, hideSubmitButton?: boolean, hideTermsAndConditions?: boolean, hideEmail?: boolean, disableEmail?: boolean, hideAddressForm?: boolean, affiliateCode?: string): string;
|
|
127
|
+
declare const EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST: string[];
|
|
128
|
+
declare const EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING = "document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";
|
|
129
|
+
|
|
130
|
+
export { EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST as E, type WhopCheckoutSubmitDetails as W, type WhopCheckoutAddress as a, type WhopCheckoutState as b, type WhopEmbeddedCheckoutStyleOptions as c, type WhopEmbeddedCheckoutPrefillOptions as d, type WhopCheckoutMessage as e, setAddress as f, getEmail as g, getAddress as h, isWhopCheckoutMessage as i, submitCheckoutFrame as j, type WhopEmbeddedCheckoutThemeOptions as k, getEmbeddedCheckoutIframeUrl as l, EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING as m, onWhopCheckoutMessage as o, setEmail as s };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r,n,o,i,u){try{var a=e[i](u);var c=a.value}catch(e){r(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(n,o)}}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var u=e.apply(t,r);function a(e){n(u,o,i,a,c,"next",e)}function c(e){n(u,o,i,a,c,"throw",e)}a(undefined)})}}function i(e,t,r){t=l(t);return v(e,_()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function u(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function a(e,t,r){if(_()){a=Reflect.construct}else{a=function e(e,t,r){var n=[null];n.push.apply(n,t);var o=Function.bind.apply(e,n);var i=new o;if(r)b(i,r.prototype);return i}}return a.apply(null,arguments)}function c(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function l(e){l=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return l(e)}function f(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function s(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function p(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var o=true;var i=false;var u,a;try{for(r=r.call(e);!(o=(u=r.next()).done);o=true){n.push(u.value);if(t&&n.length===t)break}}catch(e){i=true;a=e}finally{try{if(!o&&r["return"]!=null)r["return"]()}finally{if(i)throw a}}return n}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function y(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){c(e,t,r[t])})}return e}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function m(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{h(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function v(e,t){if(t&&(g(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e,r){return t(e)||p(e,r)||O(e,r)||d()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function O(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function E(e){var t=typeof Map==="function"?new Map:undefined;E=function e(e){if(e===null||!s(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return a(e,arguments,l(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return E(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function P(e,t){var r,n,o,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=a(0),u["throw"]=a(1),u["return"]=a(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(t){return c([e,t])}}function c(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(i=0)),i)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];n=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var j=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=function(e,t,r){return t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r};var M=function(e,t){for(var r in t)j(e,r,{get:t[r],enumerable:!0})},R=function(e,t,r,n){var o=true,i=false,u=undefined;if(t&&(typeof t==="undefined"?"undefined":g(t))=="object"||typeof t=="function")try{var a=function(){var o=l.value;!k.call(e,o)&&o!==r&&j(e,o,{get:function(){return t[o]},enumerable:!(n=S(t,o))||n.enumerable})};for(var c=C(t)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)a()}catch(e){i=true;u=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(i){throw u}}}return e};var A=function(e){return R(j({},"__esModule",{value:!0}),e)};var T=function(e,t,r){return D(e,(typeof t==="undefined"?"undefined":g(t))!="symbol"?t+"":t,r)};var I={};M(I,{EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING:function(){return Q},EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST:function(){return J},getEmail:function(){return q},getEmbeddedCheckoutIframeUrl:function(){return $},isWhopCheckoutMessage:function(){return B},onWhopCheckoutMessage:function(){return X},setEmail:function(){return V},submitCheckoutFrame:function(){return z}});module.exports=A(I);var x=/*#__PURE__*/function(e){f(t,e);function t(){u(this,t);var e;e=i(this,t,arguments);T(e,"type","WhopCheckoutError");return e}return t}(E(Error));var L=/*#__PURE__*/function(e){f(t,e);function t(e){u(this,t);var r;r=i(this,t,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);T(r,"name","WhopCheckoutRpcTimeoutError");return r}return t}(x);var U=/*#__PURE__*/function(e){f(t,e);function t(){u(this,t);var e;e=i(this,t,arguments);T(e,"name","WhopCheckoutSetEmailError");return e}return t}(x);var W=["resize","center","complete","state","get-email-result","set-email-result"];function B(e){return g(e.data)=="object"&&e.data!==null&&"event"in e.data&&W.includes(e.data.event)}function F(e,t){return B(e)&&e.data.event===t}var N=[];function H(e){return N[e]||(N[e]=(e+256).toString(16).slice(1))}function K(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":g(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,H(e[0])+H(e[1])+H(e[2])+H(e[3])+"-"+H(e[4])+H(e[5])+"-"+H(e[6])+H(e[7])+"-"+H(e[8])+H(e[9])+"-"+H(e[10])+H(e[11])+H(e[12])+H(e[13])+H(e[14])+H(e[15])}function G(e,t,r,n){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var i;var u=new URL(e.src).origin,a=K();return(i=e.contentWindow)===null||i===void 0?void 0:i.postMessage(m(y({},t),{__scope:"whop-embedded-checkout",event_id:a}),u),new Promise(function(t,i){var u=setTimeout(function(){i(new L),window.removeEventListener("message",c)},o),c=function(o){if(o.source===e.contentWindow&&F(o,r)&&o.data.event===r&&o.data.event_id===a){clearTimeout(u),window.removeEventListener("message",c);try{t(n(o.data))}catch(e){i(e)}}};window.addEventListener("message",c)})}function X(e,t){function r(r){r.source===e.contentWindow&&B(r)&&t(r.data)}return window.addEventListener("message",r),function(){window.removeEventListener("message",r)}}function V(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return P(this,function(n){return[2,G(e,{event:"set-email",email:t},"set-email-result",function(e){if(!e.ok)throw new U(e.error)},r)]})})()}function q(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return P(this,function(r){return[2,G(e,{event:"get-email"},"get-email-result",function(e){return e.email},t)]})})()}function z(e,t){var r;var n=new URL(e.src).origin;(r=e.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)}function $(e,t,r,n,o,i,u,a,c,l,f,s,p,d){var y=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(y.searchParams.set("h",window.location.origin),t&&y.searchParams.set("theme",t),r&&y.searchParams.set("session",r),o&&y.searchParams.set("hide_price","true"),i&&y.searchParams.set("skip_redirect","true"),f&&y.searchParams.set("hide_submit_button","true"),s&&y.searchParams.set("hide_tos","true"),p&&y.searchParams.set("email.hidden","1"),d&&y.searchParams.set("email.disabled","1"),u){var h=true,m=false,v=undefined,b=true,g=false,O=undefined;try{for(var E=Object.entries(u).sort(function(e,t){return e[0].localeCompare(t[0])})[Symbol.iterator](),_;!(b=(_=E.next()).done);b=true){var P=w(_.value,2),j=P[0],S=P[1];if(j.startsWith("utm_"))if(Array.isArray(S))try{for(var C=S[Symbol.iterator](),k;!(h=(k=C.next()).done);h=true){var D=k.value;y.searchParams.append(j,D)}}catch(e){m=true;v=e}finally{try{if(!h&&C.return!=null){C.return()}}finally{if(m){throw v}}}else y.searchParams.set(j,S)}}catch(e){g=true;O=e}finally{try{if(!b&&E.return!=null){E.return()}}finally{if(g){throw O}}}}if(a){var M=true,R=false,A=undefined,T=true,I=false,x=undefined;try{for(var L=Object.entries(a)[Symbol.iterator](),U;!(T=(U=L.next()).done);T=true){var W=w(U.value,2),B=W[0],F=W[1];if(F)try{for(var N=Object.entries(F)[Symbol.iterator](),H;!(M=(H=N.next()).done);M=true){var K=w(H.value,2),G=K[0],X=K[1];y.searchParams.set("style.".concat(B,".").concat(G),X.toString())}}catch(e){R=true;A=e}finally{try{if(!M&&N.return!=null){N.return()}}finally{if(R){throw A}}}}}catch(e){I=true;x=e}finally{try{if(!T&&L.return!=null){L.return()}}finally{if(I){throw x}}}}var V=true,q=false,z=undefined;if((c===null||c===void 0?void 0:c.email)&&y.searchParams.set("email",c.email),l)try{for(var $=Object.entries(l)[Symbol.iterator](),J;!(V=(J=$.next()).done);V=true){var Q=w(J.value,2),Y=Q[0],Z=Q[1];Z&&y.searchParams.set("theme.".concat(Y),Z)}}catch(e){q=true;z=e}finally{try{if(!V&&$.return!=null){$.return()}}finally{if(q){throw z}}}return y.toString()}var J=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],Q="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";0&&(module.exports={EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING:EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING,EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST:EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST,getEmail:getEmail,getEmbeddedCheckoutIframeUrl:getEmbeddedCheckoutIframeUrl,isWhopCheckoutMessage:isWhopCheckoutMessage,onWhopCheckoutMessage:onWhopCheckoutMessage,setEmail:setEmail,submitCheckoutFrame:submitCheckoutFrame});
|
|
1
|
+
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r,n,o,a,i){try{var u=e[a](i);var s=u.value}catch(e){r(e);return}if(u.done){t(s)}else{Promise.resolve(s).then(n,o)}}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,a){var i=e.apply(t,r);function u(e){n(i,o,a,u,s,"next",e)}function s(e){n(i,o,a,u,s,"throw",e)}u(undefined)})}}function a(e,t,r){t=c(t);return m(e,O()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t,r){if(O()){u=Reflect.construct}else{u=function e(e,t,r){var n=[null];n.push.apply(n,t);var o=Function.bind.apply(e,n);var a=new o;if(r)b(a,r.prototype);return a}}return u.apply(null,arguments)}function s(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function c(e){c=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return c(e)}function l(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function f(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function d(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var o=true;var a=false;var i,u;try{for(r=r.call(e);!(o=(i=r.next()).done);o=true){n.push(i.value);if(t&&n.length===t)break}}catch(e){a=true;u=e}finally{try{if(!o&&r["return"]!=null)r["return"]()}finally{if(a)throw u}}return n}function v(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){s(e,t,r[t])})}return e}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function y(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{h(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function m(e,t){if(t&&(g(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e,r){return t(e)||d(e,r)||_(e,r)||v()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function _(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function E(e){var t=typeof Map==="function"?new Map:undefined;E=function e(e){if(e===null||!f(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,c(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return E(e)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function P(e,t){var r,n,o,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=u(0),i["throw"]=u(1),i["return"]=u(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(e){return function(t){return s([e,t])}}function s(u){if(r)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(a=0)),a)try{if(r=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e];n=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var j=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var A=function(e,t,r){return t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r};var D=function(e,t){for(var r in t)j(e,r,{get:t[r],enumerable:!0})},M=function(e,t,r,n){var o=true,a=false,i=undefined;if(t&&(typeof t==="undefined"?"undefined":g(t))=="object"||typeof t=="function")try{var u=function(){var o=c.value;!k.call(e,o)&&o!==r&&j(e,o,{get:function(){return t[o]},enumerable:!(n=S(t,o))||n.enumerable})};for(var s=C(t)[Symbol.iterator](),c;!(o=(c=s.next()).done);o=true)u()}catch(e){a=true;i=e}finally{try{if(!o&&s.return!=null){s.return()}}finally{if(a){throw i}}}return e};var R=function(e){return M(j({},"__esModule",{value:!0}),e)};var T=function(e,t,r){return A(e,(typeof t==="undefined"?"undefined":g(t))!="symbol"?t+"":t,r)};var I={};D(I,{EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING:function(){return et},EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST:function(){return ee},getAddress:function(){return Q},getEmail:function(){return $},getEmbeddedCheckoutIframeUrl:function(){return Z},isWhopCheckoutMessage:function(){return N},onWhopCheckoutMessage:function(){return q},setAddress:function(){return J},setEmail:function(){return z},submitCheckoutFrame:function(){return Y}});module.exports=R(I);var U=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);T(e,"type","WhopCheckoutError");return e}return t}(E(Error));var W=/*#__PURE__*/function(e){l(t,e);function t(e){i(this,t);var r;r=a(this,t,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);T(r,"name","WhopCheckoutRpcTimeoutError");return r}return t}(U);var x=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);T(e,"name","WhopCheckoutSetEmailError");return e}return t}(U);var L=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);T(e,"name","WhopCheckoutSetAddressError");return e}return t}(U);var B=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);T(e,"name","WhopCheckoutGetAddressError");return e}return t}(U);var F=["resize","center","complete","state","get-email-result","set-email-result","set-address-result","get-address-result","address-validation-error"];function N(e){return g(e.data)=="object"&&e.data!==null&&"event"in e.data&&F.includes(e.data.event)}function H(e,t){return N(e)&&e.data.event===t}var K=[];function G(e){return K[e]||(K[e]=(e+256).toString(16).slice(1))}function X(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":g(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,G(e[0])+G(e[1])+G(e[2])+G(e[3])+"-"+G(e[4])+G(e[5])+"-"+G(e[6])+G(e[7])+"-"+G(e[8])+G(e[9])+"-"+G(e[10])+G(e[11])+G(e[12])+G(e[13])+G(e[14])+G(e[15])}function V(e,t,r,n){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var a;var i=new URL(e.src).origin,u=X();return(a=e.contentWindow)===null||a===void 0?void 0:a.postMessage(y(p({},t),{__scope:"whop-embedded-checkout",event_id:u}),i),new Promise(function(t,a){var i=setTimeout(function(){a(new W),window.removeEventListener("message",s)},o),s=function(o){if(o.source===e.contentWindow&&H(o,r)&&o.data.event===r&&o.data.event_id===u){clearTimeout(i),window.removeEventListener("message",s);try{t(n(o.data))}catch(e){a(e)}}};window.addEventListener("message",s)})}function q(e,t){function r(r){r.source===e.contentWindow&&N(r)&&t(r.data)}return window.addEventListener("message",r),function(){window.removeEventListener("message",r)}}function z(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return P(this,function(n){return[2,V(e,{event:"set-email",email:t},"set-email-result",function(e){if(!e.ok)throw new x(e.error)},r)]})})()}function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return P(this,function(r){return[2,V(e,{event:"get-email"},"get-email-result",function(e){return e.email},t)]})})()}function J(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return P(this,function(n){return[2,V(e,{event:"set-address",address:t},"set-address-result",function(e){if(!e.ok)throw new L(e.error)},r)]})})()}function Q(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return P(this,function(r){return[2,V(e,{event:"get-address"},"get-address-result",function(e){if(!e.ok)throw new B(e.error);return{address:e.address,isComplete:e.is_complete}},t)]})})()}function Y(e,t){var r;var n=new URL(e.src).origin;(r=e.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)}function Z(e,t,r,n,o,a,i,u,s,c,l,f,d,v,p,h){var y,m,b,g,_,E,O;var P=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(P.searchParams.set("h",window.location.origin),t&&P.searchParams.set("theme",t),r&&P.searchParams.set("session",r),o&&P.searchParams.set("hide_price","true"),a&&P.searchParams.set("skip_redirect","true"),l&&P.searchParams.set("hide_submit_button","true"),f&&P.searchParams.set("hide_tos","true"),d&&P.searchParams.set("email.hidden","1"),v&&P.searchParams.set("email.disabled","1"),p&&P.searchParams.set("address.hidden","1"),h&&P.searchParams.set("a",h),i){var j=true,S=false,C=undefined,k=true,A=false,D=undefined;try{for(var M=Object.entries(i).sort(function(e,t){return e[0].localeCompare(t[0])})[Symbol.iterator](),R;!(k=(R=M.next()).done);k=true){var T=w(R.value,2),I=T[0],U=T[1];if(I.startsWith("utm_"))if(Array.isArray(U))try{for(var W=U[Symbol.iterator](),x;!(j=(x=W.next()).done);j=true){var L=x.value;P.searchParams.append(I,L)}}catch(e){S=true;C=e}finally{try{if(!j&&W.return!=null){W.return()}}finally{if(S){throw C}}}else P.searchParams.set(I,U)}}catch(e){A=true;D=e}finally{try{if(!k&&M.return!=null){M.return()}}finally{if(A){throw D}}}}if(u){var B=true,F=false,N=undefined,H=true,K=false,G=undefined;try{for(var X=Object.entries(u)[Symbol.iterator](),V;!(H=(V=X.next()).done);H=true){var q=w(V.value,2),z=q[0],$=q[1];if($)try{for(var J=Object.entries($)[Symbol.iterator](),Q;!(B=(Q=J.next()).done);B=true){var Y=w(Q.value,2),Z=Y[0],ee=Y[1];P.searchParams.set("style.".concat(z,".").concat(Z),ee.toString())}}catch(e){F=true;N=e}finally{try{if(!B&&J.return!=null){J.return()}}finally{if(F){throw N}}}}}catch(e){K=true;G=e}finally{try{if(!H&&X.return!=null){X.return()}}finally{if(K){throw G}}}}var et=true,er=false,en=undefined;if((s===null||s===void 0?void 0:s.email)&&P.searchParams.set("email",s.email),(s===null||s===void 0?void 0:(y=s.address)===null||y===void 0?void 0:y.name)&&P.searchParams.set("name",s.address.name),(s===null||s===void 0?void 0:(m=s.address)===null||m===void 0?void 0:m.line1)&&P.searchParams.set("address.line1",s.address.line1),(s===null||s===void 0?void 0:(b=s.address)===null||b===void 0?void 0:b.line2)&&P.searchParams.set("address.line2",s.address.line2),(s===null||s===void 0?void 0:(g=s.address)===null||g===void 0?void 0:g.city)&&P.searchParams.set("address.city",s.address.city),(s===null||s===void 0?void 0:(_=s.address)===null||_===void 0?void 0:_.country)&&P.searchParams.set("address.country",s.address.country),(s===null||s===void 0?void 0:(E=s.address)===null||E===void 0?void 0:E.state)&&P.searchParams.set("address.state",s.address.state),(s===null||s===void 0?void 0:(O=s.address)===null||O===void 0?void 0:O.postalCode)&&P.searchParams.set("address.postal_code",s.address.postalCode),c)try{for(var eo=Object.entries(c)[Symbol.iterator](),ea;!(et=(ea=eo.next()).done);et=true){var ei=w(ea.value,2),eu=ei[0],es=ei[1];es&&P.searchParams.set("theme.".concat(eu),es)}}catch(e){er=true;en=e}finally{try{if(!et&&eo.return!=null){eo.return()}}finally{if(er){throw en}}}return P.toString()}var ee=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],et="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";0&&(module.exports={EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING:EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING,EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST:EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST,getAddress:getAddress,getEmail:getEmail,getEmbeddedCheckoutIframeUrl:getEmbeddedCheckoutIframeUrl,isWhopCheckoutMessage:isWhopCheckoutMessage,onWhopCheckoutMessage:onWhopCheckoutMessage,setAddress:setAddress,setEmail:setEmail,submitCheckoutFrame:submitCheckoutFrame});
|
|
@@ -1,82 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type WhopCheckoutMessage = {
|
|
3
|
-
event: "resize";
|
|
4
|
-
height: number;
|
|
5
|
-
} | {
|
|
6
|
-
event: "center";
|
|
7
|
-
} | {
|
|
8
|
-
event: "complete";
|
|
9
|
-
receipt_id?: string;
|
|
10
|
-
plan_id: string;
|
|
11
|
-
} | {
|
|
12
|
-
event: "state";
|
|
13
|
-
state: WhopCheckoutState;
|
|
14
|
-
} | {
|
|
15
|
-
event: "get-email-result";
|
|
16
|
-
email: string;
|
|
17
|
-
event_id: string;
|
|
18
|
-
} | {
|
|
19
|
-
event: "set-email-result";
|
|
20
|
-
ok: true;
|
|
21
|
-
error?: never;
|
|
22
|
-
event_id: string;
|
|
23
|
-
} | {
|
|
24
|
-
event: "set-email-result";
|
|
25
|
-
ok: false;
|
|
26
|
-
error: string;
|
|
27
|
-
event_id: string;
|
|
28
|
-
};
|
|
29
|
-
declare function isWhopCheckoutMessage(event: MessageEvent<unknown>): event is MessageEvent<WhopCheckoutMessage>;
|
|
30
|
-
|
|
31
|
-
declare global {
|
|
32
|
-
interface Window {
|
|
33
|
-
wco?: {
|
|
34
|
-
injected: true;
|
|
35
|
-
listening: boolean;
|
|
36
|
-
frames: Map<HTMLIFrameElement, () => void>;
|
|
37
|
-
identifiedFrames: Map<string, HTMLIFrameElement>;
|
|
38
|
-
submit: (
|
|
39
|
-
identifier: string,
|
|
40
|
-
data?: {
|
|
41
|
-
email?: string;
|
|
42
|
-
},
|
|
43
|
-
) => void;
|
|
44
|
-
getEmail: (identifier: string, timeout?: number) => Promise<string>;
|
|
45
|
-
setEmail: (
|
|
46
|
-
identifier: string,
|
|
47
|
-
email: string,
|
|
48
|
-
timeout?: number,
|
|
49
|
-
) => Promise<void>;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface HTMLElementEventMap {
|
|
54
|
-
"checkout:submit": CustomEvent<WhopCheckoutSubmitDetails>;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type WhopCheckoutSubmitDetails = Record<never, never>;
|
|
59
|
-
|
|
60
|
-
declare function onWhopCheckoutMessage(iframe: HTMLIFrameElement, callback: (message: WhopCheckoutMessage) => void): () => void;
|
|
61
|
-
declare function setEmail(frame: HTMLIFrameElement, email: string, timeout?: number): Promise<void>;
|
|
62
|
-
declare function getEmail(frame: HTMLIFrameElement, timeout?: number): Promise<string>;
|
|
63
|
-
declare function submitCheckoutFrame(frame: HTMLIFrameElement, _data?: WhopCheckoutSubmitDetails): void;
|
|
64
|
-
|
|
65
|
-
interface WhopEmbeddedCheckoutStyleOptions {
|
|
66
|
-
container?: {
|
|
67
|
-
paddingTop?: number | string;
|
|
68
|
-
paddingBottom?: number | string;
|
|
69
|
-
paddingY?: number | string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
interface WhopEmbeddedCheckoutPrefillOptions {
|
|
73
|
-
email?: string;
|
|
74
|
-
}
|
|
75
|
-
interface WhopEmbeddedCheckoutThemeOptions {
|
|
76
|
-
accentColor?: string;
|
|
77
|
-
}
|
|
78
|
-
declare function getEmbeddedCheckoutIframeUrl(planId: string, theme?: "light" | "dark" | "system", sessionId?: string, origin?: string, hidePrice?: boolean, skipRedirect?: boolean, utm?: Record<string, string | string[]>, styles?: WhopEmbeddedCheckoutStyleOptions, prefill?: WhopEmbeddedCheckoutPrefillOptions, themeOptions?: WhopEmbeddedCheckoutThemeOptions, hideSubmitButton?: boolean, hideTermsAndConditions?: boolean, hideEmail?: boolean, disableEmail?: boolean): string;
|
|
79
|
-
declare const EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST: string[];
|
|
80
|
-
declare const EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING = "document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";
|
|
81
|
-
|
|
82
|
-
export { EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING, EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST, type WhopCheckoutMessage, type WhopCheckoutState, type WhopCheckoutSubmitDetails, type WhopEmbeddedCheckoutPrefillOptions, type WhopEmbeddedCheckoutStyleOptions, type WhopEmbeddedCheckoutThemeOptions, getEmail, getEmbeddedCheckoutIframeUrl, isWhopCheckoutMessage, onWhopCheckoutMessage, setEmail, submitCheckoutFrame };
|
|
1
|
+
export { m as EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING, E as EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST, e as WhopCheckoutMessage, b as WhopCheckoutState, W as WhopCheckoutSubmitDetails, d as WhopEmbeddedCheckoutPrefillOptions, c as WhopEmbeddedCheckoutStyleOptions, k as WhopEmbeddedCheckoutThemeOptions, h as getAddress, g as getEmail, l as getEmbeddedCheckoutIframeUrl, i as isWhopCheckoutMessage, o as onWhopCheckoutMessage, f as setAddress, s as setEmail, j as submitCheckoutFrame } from './util-B5tOGbpF.mjs';
|
|
@@ -1,82 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type WhopCheckoutMessage = {
|
|
3
|
-
event: "resize";
|
|
4
|
-
height: number;
|
|
5
|
-
} | {
|
|
6
|
-
event: "center";
|
|
7
|
-
} | {
|
|
8
|
-
event: "complete";
|
|
9
|
-
receipt_id?: string;
|
|
10
|
-
plan_id: string;
|
|
11
|
-
} | {
|
|
12
|
-
event: "state";
|
|
13
|
-
state: WhopCheckoutState;
|
|
14
|
-
} | {
|
|
15
|
-
event: "get-email-result";
|
|
16
|
-
email: string;
|
|
17
|
-
event_id: string;
|
|
18
|
-
} | {
|
|
19
|
-
event: "set-email-result";
|
|
20
|
-
ok: true;
|
|
21
|
-
error?: never;
|
|
22
|
-
event_id: string;
|
|
23
|
-
} | {
|
|
24
|
-
event: "set-email-result";
|
|
25
|
-
ok: false;
|
|
26
|
-
error: string;
|
|
27
|
-
event_id: string;
|
|
28
|
-
};
|
|
29
|
-
declare function isWhopCheckoutMessage(event: MessageEvent<unknown>): event is MessageEvent<WhopCheckoutMessage>;
|
|
30
|
-
|
|
31
|
-
declare global {
|
|
32
|
-
interface Window {
|
|
33
|
-
wco?: {
|
|
34
|
-
injected: true;
|
|
35
|
-
listening: boolean;
|
|
36
|
-
frames: Map<HTMLIFrameElement, () => void>;
|
|
37
|
-
identifiedFrames: Map<string, HTMLIFrameElement>;
|
|
38
|
-
submit: (
|
|
39
|
-
identifier: string,
|
|
40
|
-
data?: {
|
|
41
|
-
email?: string;
|
|
42
|
-
},
|
|
43
|
-
) => void;
|
|
44
|
-
getEmail: (identifier: string, timeout?: number) => Promise<string>;
|
|
45
|
-
setEmail: (
|
|
46
|
-
identifier: string,
|
|
47
|
-
email: string,
|
|
48
|
-
timeout?: number,
|
|
49
|
-
) => Promise<void>;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface HTMLElementEventMap {
|
|
54
|
-
"checkout:submit": CustomEvent<WhopCheckoutSubmitDetails>;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type WhopCheckoutSubmitDetails = Record<never, never>;
|
|
59
|
-
|
|
60
|
-
declare function onWhopCheckoutMessage(iframe: HTMLIFrameElement, callback: (message: WhopCheckoutMessage) => void): () => void;
|
|
61
|
-
declare function setEmail(frame: HTMLIFrameElement, email: string, timeout?: number): Promise<void>;
|
|
62
|
-
declare function getEmail(frame: HTMLIFrameElement, timeout?: number): Promise<string>;
|
|
63
|
-
declare function submitCheckoutFrame(frame: HTMLIFrameElement, _data?: WhopCheckoutSubmitDetails): void;
|
|
64
|
-
|
|
65
|
-
interface WhopEmbeddedCheckoutStyleOptions {
|
|
66
|
-
container?: {
|
|
67
|
-
paddingTop?: number | string;
|
|
68
|
-
paddingBottom?: number | string;
|
|
69
|
-
paddingY?: number | string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
interface WhopEmbeddedCheckoutPrefillOptions {
|
|
73
|
-
email?: string;
|
|
74
|
-
}
|
|
75
|
-
interface WhopEmbeddedCheckoutThemeOptions {
|
|
76
|
-
accentColor?: string;
|
|
77
|
-
}
|
|
78
|
-
declare function getEmbeddedCheckoutIframeUrl(planId: string, theme?: "light" | "dark" | "system", sessionId?: string, origin?: string, hidePrice?: boolean, skipRedirect?: boolean, utm?: Record<string, string | string[]>, styles?: WhopEmbeddedCheckoutStyleOptions, prefill?: WhopEmbeddedCheckoutPrefillOptions, themeOptions?: WhopEmbeddedCheckoutThemeOptions, hideSubmitButton?: boolean, hideTermsAndConditions?: boolean, hideEmail?: boolean, disableEmail?: boolean): string;
|
|
79
|
-
declare const EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST: string[];
|
|
80
|
-
declare const EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING = "document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";
|
|
81
|
-
|
|
82
|
-
export { EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING, EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST, type WhopCheckoutMessage, type WhopCheckoutState, type WhopCheckoutSubmitDetails, type WhopEmbeddedCheckoutPrefillOptions, type WhopEmbeddedCheckoutStyleOptions, type WhopEmbeddedCheckoutThemeOptions, getEmail, getEmbeddedCheckoutIframeUrl, isWhopCheckoutMessage, onWhopCheckoutMessage, setEmail, submitCheckoutFrame };
|
|
1
|
+
export { m as EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING, E as EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST, e as WhopCheckoutMessage, b as WhopCheckoutState, W as WhopCheckoutSubmitDetails, d as WhopEmbeddedCheckoutPrefillOptions, c as WhopEmbeddedCheckoutStyleOptions, k as WhopEmbeddedCheckoutThemeOptions, h as getAddress, g as getEmail, l as getEmbeddedCheckoutIframeUrl, i as isWhopCheckoutMessage, o as onWhopCheckoutMessage, f as setAddress, s as setEmail, j as submitCheckoutFrame } from './util-B5tOGbpF.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r,n,o,i,a){try{var u=e[i](a);var c=u.value}catch(e){r(e);return}if(u.done){t(c)}else{Promise.resolve(c).then(n,o)}}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(undefined)})}}function i(e,t,r){t=l(t);return m(e,j()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t,r){if(j()){u=Reflect.construct}else{u=function e(e,t,r){var n=[null];n.push.apply(n,t);var o=Function.bind.apply(e,n);var i=new o;if(r)b(i,r.prototype);return i}}return u.apply(null,arguments)}function c(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function l(e){l=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return l(e)}function f(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function s(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function p(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var o=true;var i=false;var a,u;try{for(r=r.call(e);!(o=(a=r.next()).done);o=true){n.push(a.value);if(t&&n.length===t)break}}catch(e){i=true;u=e}finally{try{if(!o&&r["return"]!=null)r["return"]()}finally{if(i)throw u}}return n}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){c(e,t,r[t])})}return e}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function h(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{v(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function m(e,t){if(t&&(g(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e,r){return t(e)||p(e,r)||O(e,r)||y()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function O(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function P(e){var t=typeof Map==="function"?new Map:undefined;P=function e(e){if(e===null||!s(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,l(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return P(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function _(e,t){var r,n,o,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(t){return c([e,t])}}function c(u){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(i=0)),i)try{if(r=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;n=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(u[0]===6&&i.label<o[1]){i.label=o[1];o=u;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(u);break}if(o[2])i.ops.pop();i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e];n=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}(function(){var e=function e(e){return g(e.data)=="object"&&e.data!==null&&"event"in e.data&&E.includes(e.data.event)};var t=function t(t,r){return e(t)&&t.data.event===r};var r=function e(e){return k[e]||(k[e]=(e+256).toString(16).slice(1))};var n=function e(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":g(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,r(e[0])+r(e[1])+r(e[2])+r(e[3])+"-"+r(e[4])+r(e[5])+"-"+r(e[6])+r(e[7])+"-"+r(e[8])+r(e[9])+"-"+r(e[10])+r(e[11])+r(e[12])+r(e[13])+r(e[14])+r(e[15])};var u=function e(e,r,o,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var u;var c=new URL(e.src).origin,l=n();return(u=e.contentWindow)===null||u===void 0?void 0:u.postMessage(h(d({},r),{__scope:"whop-embedded-checkout",event_id:l}),c),new Promise(function(r,n){var u=setTimeout(function(){n(new j),window.removeEventListener("message",c)},a),c=function(a){if(a.source===e.contentWindow&&t(a,o)&&a.data.event===o&&a.data.event_id===l){clearTimeout(u),window.removeEventListener("message",c);try{r(i(a.data))}catch(e){n(e)}}};window.addEventListener("message",c)})};var c=function t(t,r){function n(n){n.source===t.contentWindow&&e(n)&&r(n.data)}return window.addEventListener("message",n),function(){window.removeEventListener("message",n)}};var l=function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return _(this,function(n){return[2,u(e,{event:"set-email",email:t},"set-email-result",function(e){if(!e.ok)throw new S(e.error)},r)]})})()};var s=function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return _(this,function(r){return[2,u(e,{event:"get-email"},"get-email-result",function(e){return e.email},t)]})})()};var p=function e(e,t){var r;var n=new URL(e.src).origin;(r=e.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)};var y=function e(e,t,r,n,o,i,a,u,c,l,f,s,p,y){var d=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(d.searchParams.set("h",window.location.origin),t&&d.searchParams.set("theme",t),r&&d.searchParams.set("session",r),o&&d.searchParams.set("hide_price","true"),i&&d.searchParams.set("skip_redirect","true"),f&&d.searchParams.set("hide_submit_button","true"),s&&d.searchParams.set("hide_tos","true"),p&&d.searchParams.set("email.hidden","1"),y&&d.searchParams.set("email.disabled","1"),a){var v=true,h=false,m=undefined,b=true,g=false,O=undefined;try{for(var P=Object.entries(a).sort(function(e,t){return e[0].localeCompare(t[0])})[Symbol.iterator](),j;!(b=(j=P.next()).done);b=true){var _=w(j.value,2),S=_[0],E=_[1];if(S.startsWith("utm_"))if(Array.isArray(E))try{for(var k=E[Symbol.iterator](),x;!(v=(x=k.next()).done);v=true){var R=x.value;d.searchParams.append(S,R)}}catch(e){h=true;m=e}finally{try{if(!v&&k.return!=null){k.return()}}finally{if(h){throw m}}}else d.searchParams.set(S,E)}}catch(e){g=true;O=e}finally{try{if(!b&&P.return!=null){P.return()}}finally{if(g){throw O}}}}if(u){var A=true,T=false,L=undefined,U=true,W=false,C=undefined;try{for(var M=Object.entries(u)[Symbol.iterator](),D;!(U=(D=M.next()).done);U=true){var I=w(D.value,2),B=I[0],F=I[1];if(F)try{for(var V=Object.entries(F)[Symbol.iterator](),q;!(A=(q=V.next()).done);A=true){var z=w(q.value,2),G=z[0],$=z[1];d.searchParams.set("style.".concat(B,".").concat(G),$.toString())}}catch(e){T=true;L=e}finally{try{if(!A&&V.return!=null){V.return()}}finally{if(T){throw L}}}}}catch(e){W=true;C=e}finally{try{if(!U&&M.return!=null){M.return()}}finally{if(W){throw C}}}}var H=true,J=false,K=undefined;if((c===null||c===void 0?void 0:c.email)&&d.searchParams.set("email",c.email),l)try{for(var N=Object.entries(l)[Symbol.iterator](),Q;!(H=(Q=N.next()).done);H=true){var X=w(Q.value,2),Y=X[0],Z=X[1];Z&&d.searchParams.set("theme.".concat(Y),Z)}}catch(e){J=true;K=e}finally{try{if(!H&&N.return!=null){N.return()}}finally{if(J){throw K}}}return d.toString()};var v=Object.defineProperty;var m=function(e,t,r){return t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r};var b=function(e,t,r){return m(e,(typeof t==="undefined"?"undefined":g(t))!="symbol"?t+"":t,r)};var O=/*#__PURE__*/function(e){f(t,e);function t(){a(this,t);var e;e=i(this,t,arguments);b(e,"type","WhopCheckoutError");return e}return t}(P(Error));var j=/*#__PURE__*/function(e){f(t,e);function t(e){a(this,t);var r;r=i(this,t,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);b(r,"name","WhopCheckoutRpcTimeoutError");return r}return t}(O);var S=/*#__PURE__*/function(e){f(t,e);function t(){a(this,t);var e;e=i(this,t,arguments);b(e,"name","WhopCheckoutSetEmailError");return e}return t}(O);var E=["resize","center","complete","state","get-email-result","set-email-result"];var k=[];var x=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],R="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;"})();
|
|
1
|
+
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r,n,o,a,i){try{var u=e[a](i);var s=u.value}catch(e){r(e);return}if(u.done){t(s)}else{Promise.resolve(s).then(n,o)}}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,a){var i=e.apply(t,r);function u(e){n(i,o,a,u,s,"next",e)}function s(e){n(i,o,a,u,s,"throw",e)}u(undefined)})}}function a(e,t,r){t=c(t);return m(e,_()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t,r){if(_()){u=Reflect.construct}else{u=function e(e,t,r){var n=[null];n.push.apply(n,t);var o=Function.bind.apply(e,n);var a=new o;if(r)b(a,r.prototype);return a}}return u.apply(null,arguments)}function s(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function c(e){c=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return c(e)}function l(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function f(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function d(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var o=true;var a=false;var i,u;try{for(r=r.call(e);!(o=(i=r.next()).done);o=true){n.push(i.value);if(t&&n.length===t)break}}catch(e){a=true;u=e}finally{try{if(!o&&r["return"]!=null)r["return"]()}finally{if(a)throw u}}return n}function v(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){s(e,t,r[t])})}return e}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function h(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{y(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function m(e,t){if(t&&(g(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e,r){return t(e)||d(e,r)||P(e,r)||v()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function P(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function O(e){var t=typeof Map==="function"?new Map:undefined;O=function e(e){if(e===null||!f(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,c(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return O(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function j(e,t){var r,n,o,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=u(0),i["throw"]=u(1),i["return"]=u(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(e){return function(t){return s([e,t])}}function s(u){if(r)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(a=0)),a)try{if(r=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e];n=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}(function(){var e=function e(e){return g(e.data)=="object"&&e.data!==null&&"event"in e.data&&A.includes(e.data.event)};var t=function t(t,r){return e(t)&&t.data.event===r};var r=function e(e){return C[e]||(C[e]=(e+256).toString(16).slice(1))};var n=function e(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":g(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,r(e[0])+r(e[1])+r(e[2])+r(e[3])+"-"+r(e[4])+r(e[5])+"-"+r(e[6])+r(e[7])+"-"+r(e[8])+r(e[9])+"-"+r(e[10])+r(e[11])+r(e[12])+r(e[13])+r(e[14])+r(e[15])};var u=function e(e,r,o,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var u;var s=new URL(e.src).origin,c=n();return(u=e.contentWindow)===null||u===void 0?void 0:u.postMessage(h(p({},r),{__scope:"whop-embedded-checkout",event_id:c}),s),new Promise(function(r,n){var u=setTimeout(function(){n(new E),window.removeEventListener("message",s)},i),s=function(i){if(i.source===e.contentWindow&&t(i,o)&&i.data.event===o&&i.data.event_id===c){clearTimeout(u),window.removeEventListener("message",s);try{r(a(i.data))}catch(e){n(e)}}};window.addEventListener("message",s)})};var s=function t(t,r){function n(n){n.source===t.contentWindow&&e(n)&&r(n.data)}return window.addEventListener("message",n),function(){window.removeEventListener("message",n)}};var c=function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return j(this,function(n){return[2,u(e,{event:"set-email",email:t},"set-email-result",function(e){if(!e.ok)throw new k(e.error)},r)]})})()};var f=function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return j(this,function(r){return[2,u(e,{event:"get-email"},"get-email-result",function(e){return e.email},t)]})})()};var d=function e(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return j(this,function(n){return[2,u(e,{event:"set-address",address:t},"set-address-result",function(e){if(!e.ok)throw new R(e.error)},r)]})})()};var v=function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return j(this,function(r){return[2,u(e,{event:"get-address"},"get-address-result",function(e){if(!e.ok)throw new x(e.error);return{address:e.address,isComplete:e.is_complete}},t)]})})()};var y=function e(e,t){var r;var n=new URL(e.src).origin;(r=e.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)};var m=function e(e,t,r,n,o,a,i,u,s,c,l,f,d,v,p,y){var h,m,b,g,P,O,_;var j=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(j.searchParams.set("h",window.location.origin),t&&j.searchParams.set("theme",t),r&&j.searchParams.set("session",r),o&&j.searchParams.set("hide_price","true"),a&&j.searchParams.set("skip_redirect","true"),l&&j.searchParams.set("hide_submit_button","true"),f&&j.searchParams.set("hide_tos","true"),d&&j.searchParams.set("email.hidden","1"),v&&j.searchParams.set("email.disabled","1"),p&&j.searchParams.set("address.hidden","1"),y&&j.searchParams.set("a",y),i){var S=true,E=false,k=undefined,R=true,x=false,A=undefined;try{for(var C=Object.entries(i).sort(function(e,t){return e[0].localeCompare(t[0])})[Symbol.iterator](),U;!(R=(U=C.next()).done);R=true){var W=w(U.value,2),T=W[0],L=W[1];if(T.startsWith("utm_"))if(Array.isArray(L))try{for(var M=L[Symbol.iterator](),D;!(S=(D=M.next()).done);S=true){var I=D.value;j.searchParams.append(T,I)}}catch(e){E=true;k=e}finally{try{if(!S&&M.return!=null){M.return()}}finally{if(E){throw k}}}else j.searchParams.set(T,L)}}catch(e){x=true;A=e}finally{try{if(!R&&C.return!=null){C.return()}}finally{if(x){throw A}}}}if(u){var B=true,F=false,G=undefined,V=true,q=false,z=undefined;try{for(var $=Object.entries(u)[Symbol.iterator](),H;!(V=(H=$.next()).done);V=true){var J=w(H.value,2),K=J[0],N=J[1];if(N)try{for(var Q=Object.entries(N)[Symbol.iterator](),X;!(B=(X=Q.next()).done);B=true){var Y=w(X.value,2),Z=Y[0],ee=Y[1];j.searchParams.set("style.".concat(K,".").concat(Z),ee.toString())}}catch(e){F=true;G=e}finally{try{if(!B&&Q.return!=null){Q.return()}}finally{if(F){throw G}}}}}catch(e){q=true;z=e}finally{try{if(!V&&$.return!=null){$.return()}}finally{if(q){throw z}}}}var et=true,er=false,en=undefined;if((s===null||s===void 0?void 0:s.email)&&j.searchParams.set("email",s.email),(s===null||s===void 0?void 0:(h=s.address)===null||h===void 0?void 0:h.name)&&j.searchParams.set("name",s.address.name),(s===null||s===void 0?void 0:(m=s.address)===null||m===void 0?void 0:m.line1)&&j.searchParams.set("address.line1",s.address.line1),(s===null||s===void 0?void 0:(b=s.address)===null||b===void 0?void 0:b.line2)&&j.searchParams.set("address.line2",s.address.line2),(s===null||s===void 0?void 0:(g=s.address)===null||g===void 0?void 0:g.city)&&j.searchParams.set("address.city",s.address.city),(s===null||s===void 0?void 0:(P=s.address)===null||P===void 0?void 0:P.country)&&j.searchParams.set("address.country",s.address.country),(s===null||s===void 0?void 0:(O=s.address)===null||O===void 0?void 0:O.state)&&j.searchParams.set("address.state",s.address.state),(s===null||s===void 0?void 0:(_=s.address)===null||_===void 0?void 0:_.postalCode)&&j.searchParams.set("address.postal_code",s.address.postalCode),c)try{for(var eo=Object.entries(c)[Symbol.iterator](),ea;!(et=(ea=eo.next()).done);et=true){var ei=w(ea.value,2),eu=ei[0],es=ei[1];es&&j.searchParams.set("theme.".concat(eu),es)}}catch(e){er=true;en=e}finally{try{if(!et&&eo.return!=null){eo.return()}}finally{if(er){throw en}}}return j.toString()};var b=Object.defineProperty;var P=function(e,t,r){return t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r};var _=function(e,t,r){return P(e,(typeof t==="undefined"?"undefined":g(t))!="symbol"?t+"":t,r)};var S=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);_(e,"type","WhopCheckoutError");return e}return t}(O(Error));var E=/*#__PURE__*/function(e){l(t,e);function t(e){i(this,t);var r;r=a(this,t,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);_(r,"name","WhopCheckoutRpcTimeoutError");return r}return t}(S);var k=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);_(e,"name","WhopCheckoutSetEmailError");return e}return t}(S);var R=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);_(e,"name","WhopCheckoutSetAddressError");return e}return t}(S);var x=/*#__PURE__*/function(e){l(t,e);function t(){i(this,t);var e;e=a(this,t,arguments);_(e,"name","WhopCheckoutGetAddressError");return e}return t}(S);var A=["resize","center","complete","state","get-email-result","set-email-result","set-address-result","get-address-result","address-validation-error"];var C=[];var U=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],W="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;"})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as s,b as e,c as a,d as E,e as t,f as o,g as m,h as d,i as h,j as r}from"./chunk-D7BU562Q.mjs";export{r as EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING,h as EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST,o as getAddress,E as getEmail,d as getEmbeddedCheckoutIframeUrl,s as isWhopCheckoutMessage,e as onWhopCheckoutMessage,t as setAddress,a as setEmail,m as submitCheckoutFrame};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(e){if(Array.isArray(e))return e}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r,n,o,i,a){try{var u=e[i](a);var c=u.value}catch(e){r(e);return}if(u.done){t(c)}else{Promise.resolve(c).then(n,o)}}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(undefined)})}}function i(e,t,r){t=l(t);return m(e,j()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t,r){if(j()){u=Reflect.construct}else{u=function e(e,t,r){var n=[null];n.push.apply(n,t);var o=Function.bind.apply(e,n);var i=new o;if(r)b(i,r.prototype);return i}}return u.apply(null,arguments)}function c(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function l(e){l=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return l(e)}function s(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function f(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function p(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var o=true;var i=false;var a,u;try{for(r=r.call(e);!(o=(a=r.next()).done);o=true){n.push(a.value);if(t&&n.length===t)break}}catch(e){i=true;u=e}finally{try{if(!o&&r["return"]!=null)r["return"]()}finally{if(i)throw u}}return n}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){c(e,t,r[t])})}return e}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function h(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{v(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function m(e,t){if(t&&(g(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e,r){return t(e)||p(e,r)||O(e,r)||y()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function O(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function P(e){var t=typeof Map==="function"?new Map:undefined;P=function e(e){if(e===null||!f(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,l(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return P(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function _(e,t){var r,n,o,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(t){return c([e,t])}}function c(u){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(i=0)),i)try{if(r=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;n=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(u[0]===6&&i.label<o[1]){i.label=o[1];o=u;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(u);break}if(o[2])i.ops.pop();i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e];n=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var S=Object.defineProperty;var E=function(e,t,r){return t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r};var k=function(e,t,r){return E(e,(typeof t==="undefined"?"undefined":g(t))!="symbol"?t+"":t,r)};var x=/*#__PURE__*/function(e){"use strict";s(t,e);function t(){a(this,t);var e;e=i(this,t,arguments);k(e,"type","WhopCheckoutError");return e}return t}(P(Error));var R=/*#__PURE__*/function(e){"use strict";s(t,e);function t(e){a(this,t);var r;r=i(this,t,[e!==null&&e!==void 0?e:"Timeout waiting for embed response"]);k(r,"name","WhopCheckoutRpcTimeoutError");return r}return t}(x);var A=/*#__PURE__*/function(e){"use strict";s(t,e);function t(){a(this,t);var e;e=i(this,t,arguments);k(e,"name","WhopCheckoutSetEmailError");return e}return t}(x);var T=["resize","center","complete","state","get-email-result","set-email-result"];function L(e){return g(e.data)=="object"&&e.data!==null&&"event"in e.data&&T.includes(e.data.event)}function U(e,t){return L(e)&&e.data.event===t}var W=[];function C(e){return W[e]||(W[e]=(e+256).toString(16).slice(1))}function M(){var e=new Uint8Array(16);if((typeof crypto==="undefined"?"undefined":g(crypto))<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.random()*256|0;return e[6]=e[6]&15|64,e[8]=e[8]&63|128,C(e[0])+C(e[1])+C(e[2])+C(e[3])+"-"+C(e[4])+C(e[5])+"-"+C(e[6])+C(e[7])+"-"+C(e[8])+C(e[9])+"-"+C(e[10])+C(e[11])+C(e[12])+C(e[13])+C(e[14])+C(e[15])}function D(e,t,r,n){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:2e3;var i;var a=new URL(e.src).origin,u=M();return(i=e.contentWindow)===null||i===void 0?void 0:i.postMessage(h(d({},t),{__scope:"whop-embedded-checkout",event_id:u}),a),new Promise(function(t,i){var a=setTimeout(function(){i(new R),window.removeEventListener("message",c)},o),c=function(o){if(o.source===e.contentWindow&&U(o,r)&&o.data.event===r&&o.data.event_id===u){clearTimeout(a),window.removeEventListener("message",c);try{t(n(o.data))}catch(e){i(e)}}};window.addEventListener("message",c)})}function I(e,t){function r(r){r.source===e.contentWindow&&L(r)&&t(r.data)}return window.addEventListener("message",r),function(){window.removeEventListener("message",r)}}function B(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:2e3;return o(function(){return _(this,function(n){return[2,D(e,{event:"set-email",email:t},"set-email-result",function(e){if(!e.ok)throw new A(e.error)},r)]})})()}function F(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2e3;return o(function(){return _(this,function(r){return[2,D(e,{event:"get-email"},"get-email-result",function(e){return e.email},t)]})})()}function G(e,t){var r;var n=new URL(e.src).origin;(r=e.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"submit"},n)}function V(e,t,r,n,o,i,a,u,c,l,s,f,p,y){var d=new URL("/embedded/checkout/".concat(e,"/"),n!==null&&n!==void 0?n:"https://whop.com/");if(d.searchParams.set("h",window.location.origin),t&&d.searchParams.set("theme",t),r&&d.searchParams.set("session",r),o&&d.searchParams.set("hide_price","true"),i&&d.searchParams.set("skip_redirect","true"),s&&d.searchParams.set("hide_submit_button","true"),f&&d.searchParams.set("hide_tos","true"),p&&d.searchParams.set("email.hidden","1"),y&&d.searchParams.set("email.disabled","1"),a){var v=true,h=false,m=undefined,b=true,g=false,O=undefined;try{for(var P=Object.entries(a).sort(function(e,t){return e[0].localeCompare(t[0])})[Symbol.iterator](),j;!(b=(j=P.next()).done);b=true){var _=w(j.value,2),S=_[0],E=_[1];if(S.startsWith("utm_"))if(Array.isArray(E))try{for(var k=E[Symbol.iterator](),x;!(v=(x=k.next()).done);v=true){var R=x.value;d.searchParams.append(S,R)}}catch(e){h=true;m=e}finally{try{if(!v&&k.return!=null){k.return()}}finally{if(h){throw m}}}else d.searchParams.set(S,E)}}catch(e){g=true;O=e}finally{try{if(!b&&P.return!=null){P.return()}}finally{if(g){throw O}}}}if(u){var A=true,T=false,L=undefined,U=true,W=false,C=undefined;try{for(var M=Object.entries(u)[Symbol.iterator](),D;!(U=(D=M.next()).done);U=true){var I=w(D.value,2),B=I[0],F=I[1];if(F)try{for(var G=Object.entries(F)[Symbol.iterator](),V;!(A=(V=G.next()).done);A=true){var q=w(V.value,2),z=q[0],J=q[1];d.searchParams.set("style.".concat(B,".").concat(z),J.toString())}}catch(e){T=true;L=e}finally{try{if(!A&&G.return!=null){G.return()}}finally{if(T){throw L}}}}}catch(e){W=true;C=e}finally{try{if(!U&&M.return!=null){M.return()}}finally{if(W){throw C}}}}var Q=true,Z=false,$=undefined;if((c===null||c===void 0?void 0:c.email)&&d.searchParams.set("email",c.email),l)try{for(var H=Object.entries(l)[Symbol.iterator](),K;!(Q=(K=H.next()).done);Q=true){var N=w(K.value,2),X=N[0],Y=N[1];Y&&d.searchParams.set("theme.".concat(X),Y)}}catch(e){Z=true;$=e}finally{try{if(!Q&&H.return!=null){H.return()}}finally{if(Z){throw $}}}return d.toString()}var q=["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation","allow-top-navigation-by-user-activation","allow-downloads"],z="document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;";export{L as a,I as b,B as c,F as d,G as e,V as f,q as g,z as h};
|