PageSourceSearch

https://whop.com/_web/assets/gha-35971278800-1/builder-Co1ciMTd.js

js whop.com collected 2026-09-24 08:32:50 UTC 159,131 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ed14330a-615d-594a-bb0f-a4ba2268cc0f")}catch(e){}}();
3const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_web/assets/gha-35971278800-1/frosted-ui-IuunJNEA.js","_web/assets/gha-35971278800-1/rolldown-runtime-CMxvf4Kt.js","_web/assets/gha-35971278800-1/index-BJYkNw1-.js","_web/assets/gha-35971278800-1/preload-helper-CHfnNNiK.js","_web/assets/gha-35971278800-1/v4-DMHn27B-.js","_web/assets/gha-35971278800-1/tslib.es6-RJO9y-u0.js","_web/assets/gha-35971278800-1/en-8ESDx1gF.js","_web/assets/gha-35971278800-1/checkout-surface-DBR33UlW.js","_web/assets/gha-35971278800-1/constants-DoV4nwOx.js","_web/assets/gha-35971278800-1/use-set-product-surface-BDN2TkQF.js","_web/assets/gha-35971278800-1/product-surface-tracker-NwKtXprE.js","_web/assets/gha-35971278800-1/registry-DDj5t4LD.js","_web/assets/gha-35971278800-1/page-view-store-CggrJ1UE.js","_web/assets/gha-35971278800-1/analytics-browser-CbgtFrhP.js","_web/assets/gha-35971278800-1/read-client-cookie-BO83ZmQ_.js","_web/assets/gha-35971278800-1/creator-onboarding-funnel-ClDtgYj-.js","_web/assets/gha-35971278800-1/js.cookie-B3BuCjeo.js","_web/assets/gha-35971278800-1/legal-paths-DuEhidag.js","_web/assets/gha-35971278800-1/whop-socket-CIM9Q_Tr.js","_web/assets/gha-35971278800-1/env-DgNObnYU.js","_web/assets/gha-35971278800-1/operations--Dg7v-t0.js","_web/assets/gha-35971278800-1/esm-DCzcdZAF.js","_web/assets/gha-35971278800-1/tslib.es6-BtpPzn5g.js","_web/assets/gha-35971278800-1/request-EDK527y9.js","_web/assets/gha-35971278800-1/app-name-ChISPmAv.js","_web/assets/gha-35971278800-1/exports-CSkmXAhq.js","_web/assets/gha-35971278800-1/useQuery-h_lbmEls.js","_web/assets/gha-35971278800-1/useParams-CScQ8WwF.js","_web/assets/gha-35971278800-1/useMatch-CxtiIuwg.js","_web/assets/gha-35971278800-1/matchContext-JSIUnm__.js","_web/assets/gha-35971278800-1/useRouter-By-0xqVW.js","_web/assets/gha-35971278800-1/useStore-DD4HLjvD.js","_web/assets/gha-35971278800-1/invariant-DEEwAagU.js","_web/assets/gha-35971278800-1/useRouterState-KKgZ0uZA.js","_web/assets/gha-35971278800-1/safe-slice-BORMMs1N.js","_web/assets/gha-35971278800-1/parsePhoneNumber-TWaZ-HO7.js","_web/assets/gha-35971278800-1/parsePhoneNumber_-BVXRnZuY.js","_web/assets/gha-35971278800-1/product-page-ui-ColsyvRX.js","_web/assets/gha-35971278800-1/interactive-star-rating-BoPOGMZe.js","_web/assets/gha-35971278800-1/reviews-list-skeleton-AS3vZ66a.js","_web/assets/gha-35971278800-1/review-media-item-BxmpGaKp.js","_web/assets/gha-35971278800-1/media-lightbox-D_3B3Byj.js","_web/assets/gha-35971278800-1/portal-container-provider-DQ2EAH7Y.js","_web/assets/gha-35971278800-1/use-is-hydrated-CgKcc-Oc.js","_web/assets/gha-35971278800-1/client-only-B7SBL-we.js","_web/assets/gha-35971278800-1/image-CRtEb3v4.js","_web/assets/gha-35971278800-1/image-loader-DFCBZPkK.js","_web/assets/gha-35971278800-1/merge-ref-DBxpTHMV.js","_web/assets/gha-35971278800-1/download-attachment-DXgdsq0c.js","_web/assets/gha-35971278800-1/react-client-D5SPP8rz.js","_web/assets/gha-35971278800-1/react-BBpLUrWf.js","_web/assets/gha-35971278800-1/toast-BSw6zLhC.js","_web/assets/gha-35971278800-1/cn-CIC46yv0.js","_web/assets/gha-35971278800-1/ArrowUpRightFromSquare16-DeJAm-tP.js","_web/assets/gha-35971278800-1/Download16-WPG7QZwv.js","_web/assets/gha-35971278800-1/Link16-fkf6sSX6.js","_web/assets/gha-35971278800-1/PlayFilled12-D8o8IKyN.js","_web/assets/gha-35971278800-1/Plus16-LqBQ7xuO.js","_web/assets/gha-35971278800-1/Subtract16-DN7K98x6.js","_web/assets/gha-35971278800-1/XMark16-D0TnfV4f.js","_web/assets/gha-35971278800-1/vt-timing-XJ4ZV4Ib.js","_web/assets/gha-35971278800-1/is-firefox-CNVzdImJ.js","_web/assets/gha-35971278800-1/lightbox-item-D38jhQxc.js","_web/assets/gha-35971278800-1/lightbox-css-vars-DTPUijJw.js","_web/assets/gha-35971278800-1/XMark12-CPhGvjyY.js","_web/assets/gha-35971278800-1/Star16-CaaYMQLb.js","_web/assets/gha-35971278800-1/StarFilled16-CTPeJhVK.js","_web/assets/gha-35971278800-1/reviews-overlay-zomq4CAp.js","_web/assets/gha-35971278800-1/review-item--0jgeiIY.js","_web/assets/gha-35971278800-1/star-rating-BKZqB5Ap.js","_web/assets/gha-35971278800-1/StarHalf12-BkQOecVg.js","_web/assets/gha-35971278800-1/avatar-DpKK1Pkg.js","_web/assets/gha-35971278800-1/dist-bXvrxWlc.js","_web/assets/gha-35971278800-1/form-DZOq8GhW.js","_web/assets/gha-35971278800-1/index.esm-DSo0jvS7.js","_web/assets/gha-35971278800-1/text-area-field-DePt7Ovp.js","_web/assets/gha-35971278800-1/helper-BYizcNM1.js","_web/assets/gha-35971278800-1/overlay-DtaskbCs.js","_web/assets/gha-35971278800-1/animated-height-B08FC17R.js","_web/assets/gha-35971278800-1/use-resize-observer-UM4u0_f0.js","_web/assets/gha-35971278800-1/proxy-BIsypWPM.js","_web/assets/gha-35971278800-1/use-reduced-motion-Ceq-MfX
3d.js","_web/assets/gha-35971278800-1/mobile-context-CuGSKzjF.js","_web/assets/gha-35971278800-1/hooks-okue38-X.js","_web/assets/gha-35971278800-1/fetcher-kCF4G5u4.js","_web/assets/gha-35971278800-1/cookies-dPL1RMP6.js","_web/assets/gha-35971278800-1/get-session-C7BEKgXR.js","_web/assets/gha-35971278800-1/elevation-controller-2REzX7j6.js","_web/assets/gha-35971278800-1/useInfiniteQuery-C0qJ3s1g.js","_web/assets/gha-35971278800-1/useMutation-Dh4GgGqL.js","_web/assets/gha-35971278800-1/use-attachment-dropzone-Ciyt0SyR.js","_web/assets/gha-35971278800-1/upload-file-DaKcZB93.js","_web/assets/gha-35971278800-1/get-whop-browser-client-Bgd_dUyI.js","_web/assets/gha-35971278800-1/Client-B_pmEYgI.js","_web/assets/gha-35971278800-1/date-helper-BS0HC58w.js","_web/assets/gha-35971278800-1/dayjs.min-drdlMfEL.js","_web/assets/gha-35971278800-1/localizedFormat-Ck18e3JA.js","_web/assets/gha-35971278800-1/relativeTime-CAuB4-70.js","_web/assets/gha-35971278800-1/ChevronDown12-iDXFt0Tp.js","_web/assets/gha-35971278800-1/InfoCircle20-CZdbtYoW.js","_web/assets/gha-35971278800-1/zod-B-bgOl0w.js","_web/assets/gha-35971278800-1/schemas-DDuGNFgy.js","_web/assets/gha-35971278800-1/useNavigate-BzphJxIr.js","_web/assets/gha-35971278800-1/utils-BkcwFzu_.js","_web/assets/gha-35971278800-1/reviews-list-DvdQFfnG.js","_web/assets/gha-35971278800-1/use-viewer-BIRiAgqq.js","_web/assets/gha-35971278800-1/auth-store-R0K-CVSk.js","_web/assets/gha-35971278800-1/handle-tag-revalidation-sW_jZjFs.js","_web/assets/gha-35971278800-1/generate-video-thumbnail-BbuueIzi.js","_web/assets/gha-35971278800-1/not-empty-pWtdodt7.js","_web/assets/gha-35971278800-1/parse-gql-error-Bx3-JJ_x.js","_web/assets/gha-35971278800-1/errors-1hiEWqXB.js","_web/assets/gha-35971278800-1/ArrowUpFromBracket16-CKxVTHpR.js","_web/assets/gha-35971278800-1/PaperAirplaneUpFilled16-Ccth44_n.js","_web/assets/gha-35971278800-1/report-product-modal-By9Vy_P6.js","_web/assets/gha-35971278800-1/types-_FVd4ZzE.js","_web/assets/gha-35971278800-1/ArrowLeft20-bjqtiyNG.js","_web/assets/gha-35971278800-1/Checkmark20-BpOY9TQ6.js","_web/assets/gha-35971278800-1/ChevronDown20-DI9S43Df.js","_web/assets/gha-35971278800-1/ExclamationTriangle32-B8Tmlf30.js","_web/assets/gha-35971278800-1/Flag20-BIlskWRw.js","_web/assets/gha-35971278800-1/Plus20-BLBp3fJ2.js","_web/assets/gha-35971278800-1/Shop32-BKCmwsW9.js","_web/assets/gha-35971278800-1/User32-C230innz.js","_web/assets/gha-35971278800-1/XCircle20-CBj3X1Iz.js","_web/assets/gha-35971278800-1/XMark20-DLvIg3IS.js","_web/assets/gha-35971278800-1/product-page-layout-view-CCgkMfKE.js","_web/assets/gha-35971278800-1/whop-logo-icon-DIP07jru.js","_web/assets/gha-35971278800-1/periods-aXv02EIc.js","_web/assets/gha-35971278800-1/flags-CYwwno39.js","_web/assets/gha-35971278800-1/client-C8ODUnom.js","_web/assets/gha-35971278800-1/whop-exposure-C20p3xN-.js","_web/assets/gha-35971278800-1/business-type-BSJFb7uM.js","_web/assets/gha-35971278800-1/track-BWZbUD-U.js","_web/assets/gha-35971278800-1/embedded-chat-viewer-path-C2lxWd0F.js","_web/assets/gha-35971278800-1/ChevronLeft16-BPNy-4ks.js","_web/assets/gha-35971278800-1/ChevronRight16-C1D1_N7m.js","_web/assets/gha-35971278800-1/Photo24-OMqH39aI.js","_web/assets/gha-35971278800-1/User16-6FOIbdSC.js","_web/assets/gha-35971278800-1/useSearch-CDO_bnp0.js","_web/assets/gha-35971278800-1/product-page-layout-view-CScCMs06.css","_web/assets/gha-35971278800-1/login-overlay-context-D_CsnPev.js","_web/assets/gha-35971278800-1/apple-icon-C3xP1VOB.js","_web/assets/gha-35971278800-1/google-icon-colored-BC40Cte8.js","_web/assets/gha-35971278800-1/pixel-track-8jotG-DN.js","_web/assets/gha-35971278800-1/read-cookie-DO9OlvdI.js","_web/assets/gha-35971278800-1/pixel-Ce-w6N6D.js","_web/assets/gha-35971278800-1/safe-internal-path-BHALxEa_.js","_web/assets/gha-35971278800-1/web-owned-paths-BFYC5m_D.js","_web/assets/gha-35971278800-1/ChevronLeft12-CAp6vE4E.js","_web/assets/gha-35971278800-1/ExclamationCircle16-CYV-ClHv.js","_web/assets/gha-35971278800-1/controller-DltsyOJx.js","_web/assets/gha-35971278800-1/whop-logo-full-CukoRWaH.js","_web/assets/gha-35971278800-1/phone-input-CmdUI1s3.js","_web/assets/gha-35971278800-1/use-immutable-callback-DDv5WypE.js","_web/assets/gha-35971278800-1/countries-DIUfaK6b.js","_web/assets/gha-35971278800-1/stop-propagation-CqJ3kEzj.js","_web/assets/gha-35971278800-1/infinite-scroll-fetcher-B1EdaQnE.js","_web/assets/gha-35971278800-1/money-tMbdBxC6.js","_web/assets/gha-35971278800-1/next-action-Dxoof7Yc.js","_web/assets/gha-35971278800-1/cdn-hosts-BjdndjtK.js","_web/assets/gha-35971278800-1/relative-url-KigqVZij.js","_web/assets/gha-35971278800-1/complete-payment-flow-Cld_TBNN.js","_web/assets/gha-35971278800-1/payment-method-icon-BxyZMzRf.js","_web/assets/gha-35971278800-1/chrome-BFk9Hveq.js","_web/assets/gha-35971278800-1/step-motion-BrVqKoA6.js","_web/assets/gha-35971278800-1/AnimatePresence-PPyKX-5K.js","_web/assets/gha-35971278800-1/Checkmark16-Iesf9iuY.js","_web/assets/gha-35971278800-1/CheckmarkCircleFilled16-BOeu1VZa.js","_web/assets/gha-35971278800-1/Copy16-BOpqGAMG.js","_web/assets/gha-35971278800-1/module-LoJoYbqM.js","_web/assets/gha-35971278800-1/Bank16-CCASCihJ.js","_web/assets/gha-35971278800-1/Bank20-C_AxaJrh.js","_web/assets/gha-35971278800-1/Clock16-CXBcl48T.js","_web/assets/gha-35971278800-1/Clock20-B3FbOQnX.js","_web/assets/gha-35971278800-1/CreditCard12-dLyY8DRU.js","_web/assets/gha-35971278800-1/CreditCard16-DSOi_OGc.js","_web/assets/gha-35971278800-1/Wallet16-W4cjWjHo.js","_web/assets/gha-35971278800-1/Wallet20-eWUwOr8v.js","_web/assets/gha-35971278800-1/esm-DGk0mjrZ.js","_web/assets/gha-35971278800-1/raw-BMs3X-qX.js","_web/assets/gha-35971278800-1/src-DJYTMIfL.js","_web/assets/gha-35971278800-1/controller-D7g3AXTh.js","_web/assets/gha-35971278800-1/animated-submit-button-R6kK9JVX.js","_web/assets/gha-35971278800-1/animated-submit-button-DRAS2yVW.css","_web/assets/gha-35971278800-1/session-api-Bv5VyMBp.js","_web/assets/gha-35971278800-1/terms-CW_WDBa8.js","_web/assets/gha-35971278800-1/affiliate-code-candidates-2YrcPx03.js","_web/assets/gha-35971278800-1/analytics-B0KPUg5B.js","_web/assets/gha-35971278800-1/identify-traits-BScDxbq4.js","_web/assets/gha-35971278800-1/src-epMYX5xc.js","_web/assets/gha-35971278800-1/analytics-DKMFh5aW.js","_web/assets/gha-35971278800-1/middleware-CGnPWcja.js","_web/assets/gha-35971278800-1/callback-CFIOA0pT.js","_web/assets/gha-35971278800-1/metric-helpers-yRfV9t1U.js","_web/assets/gha-35971278800-1/load-script-B5pn9q2J.js","_web/assets/gha-35971278800-1/helpers-Dfaq6qKi.js","_web/assets/gha-35971278800-1/gracefulDecodeURIComponent-Cjfhr3Sm.js","_web/assets/gha-35971278800-1/secure-wuid-2KwgW13C.js","_web/assets/gha-35971278800-1/discover-context-rtInbCOt.js","_web/assets/gha-35971278800-1/conversions-Q7YAaoc8.js","_web/assets/gha-35971278800-1/conversion-bus-DUzOOiBz.js","_web/assets/gha-35971278800-1/server-eval-BUg57DZx.js","_web/assets/gha-35971278800-1/format-price-OFWEBsv7.js","_web/assets/gha-35971278800-1/use-store-page-active-4sz5XG_f.js","_web/assets/gha-35971278800-1/esm-D_nuGc6T.js","_web/assets/gha-35971278800-1/vanilla--C5Lp_AM.js","_web/assets/gha-35971278800-1/get-cta-text-CC3jEFVh.js","_web/assets/gha-35971278800-1/markdown-DIT0GGog.js","_web/assets/gha-35971278800-1/shared-classes-BYkVUZpn.js","_web/assets/gha-35971278800-1/reviews-overlay-store-BHS44-sJ.js","_web/assets/gha-35971278800-1/middleware-XmSPUjPA.js","_web/assets/gha-35971278800-1/CheckmarkCircleFilled20-BMkcVRa6.js","_web/assets/gha-35971278800-1/ExclamationTriangle16-CNh6gElD.js","_web/assets/gha-35971278800-1/Gift12-BxxPbLvx.js","_web/assets/gha-35971278800-1/Trash16-PLStwT4Q.js","_web/assets/gha-35971278800-1/Truck20-CveCq5vq.js","_web/assets/gha-35971278800-1/dist-D1yFdsPp.js","_web/assets/gha-35971278800-1/dist-zAd0OwhI.js","_web/assets/gha-35971278800-1/dist-CZvhQiR3.js","_web/assets/gha-35971278800-1/link-DKs8W8IC.js","_web/assets/gha-35971278800-1/ClientOnly-DY38M7YY.js","_web/assets/gha-35971278800-1/path-CFGcM0Hb.js","_web/assets/gha-35971278800-1/use-cards-LTuTKSEn.js","_web/assets/gha-35971278800-1/team-members-api-DNWyfQJx.js","_web/assets/gha-35971278800-1/with-rest-elevation-fL0PrpUz.js","_web/assets/gha-35971278800-1/parse-rest-api-error-Cd1f1Jog.js","_web/assets/gha-35971278800-1/currencies-BpeWMwXP.js","_web/assets/gha-35971278800-1/currency-to-country-CN6Ss51N.js","_web/assets/gha-35971278800-1/balance-buckets-Ba4KNC_u.js","_web/assets/gha-35971278800-1/use-viewer-balance-query-EgClGu69.js","_web/assets/gha-35971278800-1/crypto-constants-BWBOzJ-H.js","_web/assets/gha-35971278800-1/use-debounce-whfoL8eW.js","_web/assets/gha-35971278800-1/private-request-BD-4gCgN.js","_web/assets/gha-35971278800-1/api-version-DwcpmsnO.js","_web/assets/gha-35971278800-1/use-direct-session-DpjwTtXn.js","_web/assets/gha-35971278800-1/ArrowLeft16-2G29GVyJ.js","_web/assets/gha-35971278800-1/CreditCard20-BRVEWiT1.js","_web/assets/gha-35971278800-1/DocumentPlus20-CLhCJ09L.js","_web/assets/gha-35971278800-1/ShieldCheckmark20-COMEm_Um.js","_web/assets/gha-35971278800-1/Trash12-DnCzniuH.js","_web/assets/gha-35971278800-1/event_finance_modal_open-RkSJoNjw.js","_web/assets/gha-35971278800-1/v1-SqC59lKZ.js","_web/assets/gha-35971278800-1/inner-whop-provider-FahnjX6w.js","_web/assets/gha-35971278800-1/use-resource-permissions-BI3IC7CL.js","_web/assets/gha-35971278800-1/get-whop-server-client-0VPHYF_A.js","_web/assets/gha-35971278800-1/post-body-classes-BN7HTJBM.js","_web/assets/gha-35971278800-1/mini-profile-modal-DHvEy8DB.js","_web/assets/gha-35971278800-1/simplified-content-DguPhuTo.js","_web/assets/gha-35971278800-1/icons-CLJs9mvL.js","_web/assets/gha-35971278800-1/use-refund-error-toast-BdYObdMd.js","_web/assets/gha-35971278800-1/dashboard-balance-route-TKgRp_BC.js","_web/assets/gha-35971278800-1/deny-modal-DIumPr65.js","_web/assets/gha-35971278800-1/checkbox-Bns4JHQB.js","_web/assets/gha-35971278800-1/await-poll-job-CgP-F4w_.js","_web/assets/gha-35971278800-1/createServerFn-BESixH4t.js","_web/assets/gha-35971278800-1/not-found-i5RsCZif.js","_web/assets/gha-35971278800-1/qss-CuvTgpZA.js","_web/assets/gha-35971278800-1/redirect-Dhm19zUi.js","_web/assets/gha-35971278800-1/use-follow-user-BtZnHedp.js","_web/assets/gha-35971278800-1/whop-team-member-checkmark-icon-DyEV1ORP.js","_web/assets/gha-35971278800-1/use-markup-fee-label-DU5_ZaSS.js","_web/assets/gha-35971278800-1/MagnifyingGlass16-jcDeL4wg.js","_web/assets/gha-35971278800-1/decimal-O0mMVy78.js","_web/assets/gha-35971278800-1/use-is-internal-bOiU_49_.js","_web/assets/gha-35971278800-1/account-query-CEoViFms.js","_web/assets/gha-35971278800-1/use-viewer-balances-ZdKyHn-u.js","_web/assets/gha-35971278800-1/use-boundary-navigate-BEV_sMyV.js","_web/assets/gha-35971278800-1/account-settings-modal-store-BGMAbyML.js","_web/assets/gha-35971278800-1/copy-to-cl
3ipboard-to6D_edh.js","_web/assets/gha-35971278800-1/safe-format-currency-BhRgq6iP.js","_web/assets/gha-35971278800-1/Ban16-DrJPp0DU.js","_web/assets/gha-35971278800-1/ChevronDown16-CkCG9wFv.js","_web/assets/gha-35971278800-1/DollarCircle16-DM0RnUD7.js","_web/assets/gha-35971278800-1/Flag16-D0QlU08L.js","_web/assets/gha-35971278800-1/Mail16-X6rcVMh0.js","_web/assets/gha-35971278800-1/Pencil16-BuvFUn61.js","_web/assets/gha-35971278800-1/ShareNodes16-Pj3MRBLD.js","_web/assets/gha-35971278800-1/Shield16-o8gdQPQG.js","_web/assets/gha-35971278800-1/ThreeDotsHorizontal16-DsZVLegd.js","_web/assets/gha-35971278800-1/index.module-B9XGZjuI.js","_web/assets/gha-35971278800-1/avatar-stack-BcqKbIDw.js","_web/assets/gha-35971278800-1/activity-indicator-65iQj4tZ.js","_web/assets/gha-35971278800-1/channel-subscription-manager-DhU4WAbG.js","_web/assets/gha-35971278800-1/rx-socket-DQzDBBlu.js","_web/assets/gha-35971278800-1/Observable-CC4J3rk8.js","_web/assets/gha-35971278800-1/use-user-presence-store-CcKbHQf0.js","_web/assets/gha-35971278800-1/fast-deep-equal-C93dl2ca.js","_web/assets/gha-35971278800-1/create-quick-dm-C0g85Mcu.js","_web/assets/gha-35971278800-1/PaperAirplaneUpFilled20-DWDnXgai.js","_web/assets/gha-35971278800-1/ThreeDotsVertical16-DujgRLH9.js","_web/assets/gha-35971278800-1/ThumbDown16-CzKt1Vzm.js","_web/assets/gha-35971278800-1/XCircle16-DKPjS2b1.js","_web/assets/gha-35971278800-1/capitalize-Dt5lJjON.js","_web/assets/gha-35971278800-1/toString-BN36OUXd.js","_web/assets/gha-35971278800-1/isArray-BfeOG1E2.js","_web/assets/gha-35971278800-1/upperFirst-D8fhhZEw.js","_web/assets/gha-35971278800-1/dist-D7DDR7nM.js","_web/assets/gha-35971278800-1/use-open-external-url-BVN3biTN.js","_web/assets/gha-35971278800-1/use-local-storage-B0B-yskD.js","_web/assets/gha-35971278800-1/slugify-DYTRKCUM.js","_web/assets/gha-35971278800-1/slugify-Bal3kmMQ.js","_web/assets/gha-35971278800-1/escape-string-regexp-D6qdIbgL.js","_web/assets/gha-35971278800-1/use-cache-items-DXw7lVP6.js","_web/assets/gha-35971278800-1/item-cache-rCZ1TE4h.js","_web/assets/gha-35971278800-1/use-observed-state-BlrTmk9i.js","_web/assets/gha-35971278800-1/highlight-code-Bw5Lvr6Y.js","_web/assets/gha-35971278800-1/prism-vvew-6P5.js","_web/assets/gha-35971278800-1/empty-array-Cd2uWYio.js","_web/assets/gha-35971278800-1/Download20-DDn1RCMy.js","_web/assets/gha-35971278800-1/pixels-XwJEYyhc.js","_web/assets/gha-35971278800-1/is-production-host-DMLSbgc_.js","_web/assets/gha-35971278800-1/resource-unavailable-BrHFOd8J.js","_web/assets/gha-35971278800-1/discover-entry-point-ekG1j3Pa.js","_web/assets/gha-35971278800-1/web-hide-entry-point-B2ZyI8XC.js","_web/assets/gha-35971278800-1/CompassPictogram-BYzwMAgq.js","_web/assets/gha-35971278800-1/StadiumPictogram-h06SVPoQ.js","_web/assets/gha-35971278800-1/StorePictogram-DWRNRWZC.js","_web/assets/gha-35971278800-1/build-connection-variables-CbjklxAp.js","_web/assets/gha-35971278800-1/_Map-BfHGebHC.js","_web/assets/gha-35971278800-1/isObject-CuyTkb7v.js","_web/assets/gha-35971278800-1/custom-range-menu-D3Tn3-hE.js","_web/assets/gha-35971278800-1/table-dropdown-menu-BnOeuV-Q.js","_web/assets/gha-35971278800-1/core.esm-SpOHQcim.js","_web/assets/gha-35971278800-1/sortable.esm-v4Phtnyv.js","_web/assets/gha-35971278800-1/ChevronRightSmall16-C-AGsweL.js","_web/assets/gha-35971278800-1/Lock12-DBqEqcJv.js","_web/assets/gha-35971278800-1/Calendar16-D_1loa3i.js","_web/assets/gha-35971278800-1/ExclamationCircle12-CyMTk9vZ.js","_web/assets/gha-35971278800-1/balances-data-HBcYOTUX.js","_web/assets/gha-35971278800-1/activity-filter-controls-BV_3z62x.js","_web/assets/gha-35971278800-1/activity-filters-m4GQMXLL.js","_web/assets/gha-35971278800-1/ArrowDown12-K5wo8K9b.js","_web/assets/gha-35971278800-1/Gift16-BDHfcNKX.js","_web/assets/gha-35971278800-1/Megaphone16-cD5ROuTP.js","_web/assets/gha-35971278800-1/RotateLeft12-Dp8-pZtV.js","_web/assets/gha-35971278800-1/Upload16-DgAfMzlc.js","_web/assets/gha-35971278800-1/credentialed-read-tTk3eC1F.js","_web/assets/gha-35971278800-1/infiniteQueryOptions-Dfvzj6n2.js","_web/assets/gha-35971278800-1/filters-D-d651CD.js","_web/assets/gha-35971278800-1/current-origin-BVLxTpYM.js","_web/assets/gha-35971278800-1/use-partner-DOY8zugw.js","_web/assets/gha-35971278800-1/queryOptions-Dfvzj6n2.js","_web/assets/gha-35971278800-1/fetch-company-product-page-product-CZhbFFrW.js","_web/assets/gha-35971278800-1/transforms-Nn_Jg0wN.js","_web/assets/gha-35971278800-1/fetch-company-product-page-DbFx9gpu.js","_web/assets/gha-35971278800-1/queries-CX6yknqR.js","_web/assets/gha-35971278800-1/prefetch-DOsf5KA8.js","_web/assets/gha-35971278800-1/i18n-BeUvcUWS.js","_web/assets/gha-35971278800-1/base-meta-JUszTNiv.js","_web/assets/gha-35971278800-1/page-title-D91T7nK7.js","_web/assets/gha-35971278800-1/json-ld-De7cN2JH.js","_web/assets/gha-35971278800-1/og-version-D_sQb1r8.js","_web/assets/gha-35971278800-1/sentry-QPq_eE89.js","_web/assets/gha-35971278800-1/query-keys-ONcwhtsh.js","_web/assets/gha-35971278800-1/tiptap-to-markdown-C9xYx6yj.js","_web/assets/gha-35971278800-1/use-emoji-data-BezF7m80.js","_web/assets/gha-35971278800-1/apple-ua-CkYpIsHJ.js","_web/assets/gha-35971278800-1/AlignLeft16-DQXcvzgF.js","_web/assets/gha-35971278800-1/Code16-DpJosSUd.js","_web/assets/gha-35971278800-1/Codeblock16-TZaRw3L9.js","_web/assets/gha-35971278800-1/ListBullet16-De4x978w.js","_web/assets/gha-35971278800-1/ListCheck16-CAQh4kz_.js","_web/assets/gha-35971278800-1/Photo16-BDMgTD4f.js","_web/assets/gha-35971278800-1/ArrowLeft12-BVlAXYq0.js","_web/assets/gha-35971278800-1/CheckmarkCircle16-B79Z2RDI.js","_web/assets/gha-35971278800-1/Document16-BRAljiiR.js","_web/assets/gha-35971278800-1/InfoCircle16-CO2DfAcb.js","_web/assets/gha-35971278800-1/XCircleFilled12-CSAeekAx.js","_web/assets/gha-35971278800-1/dist-4RVyzN6c.js","_web/assets/gha-35971278800-1/route-Dh4yl5qS.js","_web/assets/gha-35971278800-1/root-DLTE-HSj.js","_web/assets/gha-35971278800-1/filter-D5S4wDkM.js","_web/assets/gha-35971278800-1/flow-surface-B_K5MB-F.js","_web/assets/gha-35971278800-1/index-BB
3dW--5Z.css"])))=>i.map(i=>d[i]);
4import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{Ta as t,wa as n}from"./frosted-ui-IuunJNEA.js";import{St as r,r as i}from"./exports-CSkmXAhq.js";import{n as a,t as o}from"./preload-helper-CHfnNNiK.js";import{a as s,i as c,n as l,r as u,s as d}from"./toast-BSw6zLhC.js";import{t as f}from"./Client-B_pmEYgI.js";import{a as p,c as m,i as h,l as g,n as _,o as v,s as y}from"./flow-surface-B_K5MB-F.js";import{t as b}from"./src-DJYTMIfL.js";var x=e(t(),1);a();var S=`__whopFlowSurfaceSdk`;function C(){let e=globalThis;return e[S]??={}}function w(e){if(!e.module)return;let t={};e.sessionKey!==void 0&&(t.sessionKey=e.sessionKey),e.flow!==void 0&&(t.flow=e.flow),e.customerStamped&&(t.customerId=e.customer);let n=(e.configurationAttempt??0)+1;e.configurationAttempt=n,e.status=`loading`,e.module.then(e=>e.updateSardineConfig(t)).then(()=>{e.configurationAttempt===n&&(e.status=`ready`,e.appliedSessionKey=t.sessionKey,e.readyMs??=O(e.startedAt))}).catch(()=>{e.configurationAttempt===n&&(e.status=`error`)})}function T(e){let t=m();!t||e.sessionKey===void 0||(e.module||(e.status=`loading`,e.startedAt=performance.now(),e.loadMs=void 0,e.readyMs=void 0,e.module=o(()=>import(`./index.es-Bb3gF-Hi.js`).then(n=>(n.setupSardine({clientId:t.clientId,environment:t.environment}),e.loadMs=O(e.startedAt),n)),[]),e.module.catch(()=>{e.status=`error`,e.module=void 0})),w(e))}function E(e){if(typeof window>`u`)return;let t=C();if(t.sessionKey=e.sessionKey,e.flow!==void 0&&(t.flow=e.flow),!m()){t.armParked||(t.armParked=!0,g(()=>{t.armParked=!1,T(t)}));return}T(t)}function D(e){if(typeof window>`u`)return;let t=C();t.customer=e,t.customerStamped=!0,t.module&&t.module.then(t=>t.updateSardineConfig({customerId:e})).catch(()=>{})}function O(e){return e===void 0?void 0:Math.min(36e5,Math.max(0,Math.round(performance.now()-e)))}function k(){let e=C(),t=h();return{status:m()?e.status??`waiting`:`unconfigured`,load_ms:e.loadMs,ready_ms:e.readyMs,session_key_present:!!t,session_key_matches:e.appliedSessionKey===void 0?void 0:e.appliedSessionKey===t}}var A,ee=new Set;function te(e){if(A=e,!e)return;let t=[...ee];ee.clear();for(let n of t)n(e)}function ne(e){A?e(A):ee.add(e)}function re(e,t){if(t)try{sessionStorage.setItem(`whop-nsure:${e}`,t)}catch{}}function ie(){if(!A)return{};try{let e=sessionStorage.getItem(`whop-nsure:${A.appId}`);return e?{"x-nsure-device-id":e}:{}}catch{return{}}}function ae(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function oe(e,t={}){let n=new Map,r=(e,r)=>{n.get(e)===r&&(n.delete(e),t.onRemoved?.(e),n.size===0&&t.onEmpty?.())};return{show(i){let a=n.get(i.id);if(a!==void 0){let t=i.duration??(i.kind===`loading`?0:5e3);e.update(a,ae({title:i.message,type:i.kind,description:i.description,duration:t}));return}let o=i.id,s=``,c={description:i.description,duration:i.duration,position:i.position,onRemove:()=>r(o,s),actionProps:i.action?{children:i.action.label,onClick:()=>t.onAction?.(o)}:void 0};s=i.kind==="default"?e(i.message,c):i.kind===`info`?e.info(i.message,c):i.kind===`success`?e.success(i.message,c):i.kind===`error`?e.error(i.message,c):i.kind===`warning`?e.warning(i.message,c):e.loading(i.message,c),n.set(i.id,s)},update(t,r){let i=n.get(t);if(!i)return;let a=r.duration??(r.kind===void 0?void 0:r.kind===`loading`?0:5e3);e.update(i,ae({title:r.message,type:r.kind,description:r.description,duration:a}))},dismiss(i){if(i!==void 0){let t=n.get(i);t&&(e.dismiss(t),r(i,t));return}if(n.size!==0){for(let[r,i]of n.entries())e.dismiss(i),t.onRemoved?.(r);n.clear(),t.onEmpty?.()}}}}a();function se(e={}){let t=e.load??(()=>o(()=>import(`./frosted-ui-IuunJNEA.js`).then(e=>e.D),__vite__mapDeps([0,1]))),n=d(),r=!1,i=()=>{r||(r=!0,t().then(t=>{let r=oe(t.toast,{onEmpty:e.onEmpty,onAction:s,onRemoved:u});n.open(e=>{c(r,e),e.op})},e=>{r=!1,console.error(`whop elements toast: failed to load frosted-ui in direct mode —`,e)}))},a=e=>{i(),n.post(e)};return{show:e=>a({op:`show`,toast:e}),update:(e,t)=>a({op:`update`,id:e,patch:t}),dismiss:e=>a({op:`dismiss`,id:e})}}var ce=e=>`on${e[0].toUpperCase()}${e.slice(1)}`,j=e=>/^on[A-Z]/.test(e),M=256,le=4,ue=50,de=4096,fe=new WeakMap;function pe(){return Object.create(null)}var me=(e,t)=>
4Object.prototype.hasOwnProperty.call(e,t);function he(e){let t=fe.get(e);if(t)return t;let n=pe();for(let t of e){let e=t.split(`.`);if(e.some(e=>e.length===0))throw Error(`analytics path "${t}" has an empty segment — write dotted field names, like "items.plan".`);let r=n;for(let[n,i]of e.entries()){let a=e.slice(0,n+1).join(`.`),o=r[i];if(n===e.length-1){if(o!=null)throw Error(`analytics path "${t}" conflicts with the field paths beneath it ("${t}.<field>") — a leaf cannot also be a branch; keep the field paths and drop "${t}", which would export the whole value.`);r[i]=null;continue}if(o===null)throw Error(`analytics path "${t}" conflicts with "${a}" — a leaf cannot also be a branch; name the fields you want ("${a}.<field>") and drop "${a}", which would export the whole value.`);r=o??(r[i]=pe())}}return fe.set(e,n),n}function ge(e,t){let{value:n,violations:r}=ve(e,t);return r.some(e=>e.structural)?void 0:n}function _e(e,t){return ve(e,t).violations[0]?.message??null}function ve(e,t){let n={violations:[],bytes:0,overflow:!1},r=ye(e,t,0,``,!1,n);return!n.overflow&&typeof r==`object`&&r&&JSON.stringify(r).length>de&&(n.overflow=!0),n.overflow&&(n.violations.push({structural:!0,message:`a value serializing past ${de} characters (a value that large drops whole at emission)`}),r=void 0),{value:r,violations:n.violations}}function ye(e,t,n,r,i,a){if(a.overflow)return;let o=r===``?``:` at "${r}"`;if(e===null)return P(a,4),null;switch(typeof e){case`string`:return t===null?(P(a,Math.min(e.length,M)+2),e.length<=M?e:(a.violations.push({structural:!1,message:`a string over ${M} characters${o} (capped at emission)`}),e.slice(0,M))):N(a,!1,`a string${o} where fields were declared beneath it`);case`number`:return t===null?Number.isFinite(e)?(P(a,8),e):N(a,!1,`a non-finite number${o}`):N(a,!1,`a number${o} where fields were declared beneath it`);case`boolean`:return t===null?(P(a,5),e):N(a,!1,`a boolean${o} where fields were declared beneath it`);case`undefined`:return i?N(a,!1,`an undefined array element${o} (JSON delivers null there)`):void 0;case`object`:break;default:return N(a,!1,`a ${typeof e}${o}`)}if(n>=le)return N(a,!0,`nesting deeper than ${le} levels${o}`);if(Array.isArray(e)){if(e.length>ue)return N(a,!0,`more than ${ue} entries${o}`);let i=[];for(let[o,s]of e.entries()){P(a,1);let e=ye(s,t,n+1,`${r}[${o}]`,!0,a);e!==void 0&&i.push(e)}return i}if(!be(e))return N(a,!1,`a ${xe(e)}${o}`);if(t===null)return N(a,!1,`a whole object${o} — an allowlist names the fields to export ("${r===``?`<field>`:`${r}.<field>`}"), never a whole object`);let s={};for(let[i,o]of Object.entries(t)){let t=r===``?i:`${r}.${i}`;P(a,i.length+3);let c;try{c=me(e,i)?ye(e[i],o,n+1,t,!1,a):void 0}catch{continue}c!==void 0&&(s[i]=c)}return s}function N(e,t,n){e.violations.push({structural:t,message:n})}function P(e,t){e.bytes+=t,e.bytes>de&&(e.overflow=!0)}function be(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function xe(e){return e instanceof Date?`Date`:e instanceof Map?`Map`:e instanceof Set?`Set`:e instanceof RegExp?`RegExp`:`class instance`}function Se(){return new URLSearchParams(location.hash.slice(1)).get(`rel`)?.trim()||void 0}var Ce=`whop_anonymous_id`,we=31536e3;function Te(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();if(e?.getRandomValues){let t=e.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}return`${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`}function Ee(e){try{let t=document.cookie.match(RegExp(`(?:^|;\\s*)${e}=([^;]*)`));return t?.[1]?decodeURIComponent(t[1]):null}catch{return null}}function De(){let e=Ee(Ce);if(e)return e;let t=Te();try{let e=location.protocol===`https:`?`; Secure`:``;document.cookie=`${Ce}=${encodeURIComponent(t)}; path=/; max-age=${we}; SameSite=Lax${e}`}catch{}return Ee(`whop_anonymous_id`)??t}var Oe=null;function ke(){return Oe??={anonymousId:De(),renderId:Te()},Oe}function Ae(){return Te()}var je=10,Me=5e3,Ne=5,Pe=1e3,Fe=3e4,Ie=6e4,Le=400*1024,Re=48*1024;function ze(){let e=globalThis.crypto;if(e?.randomUUID)try{return e.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}var Be=e=>{try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 2**53-1}};function Ve(e){let t=`https://${e.apiHost}/b`,n={library:{name:`@whop/elements`,version:e.libraryVersion??`0`}},r=[],i=null,a=!1,o=!1,s=0,c=0,l=0,u=!1,d=t=>{let n=[];for(;n.length<je&&r.length>0;){let i=[...n,r[0]];if(n.length>0&&Be({writeKey:e.writeKey,batch:i,sentAt:``})>t)break;n.push(r.shift())}return n},f=e=>{for(let t of e)t._metadata={retryCount:s};r=[...e,...r]},p=(n,r)=>{if(n.length===0)return;let i=l;try{return fetch(t,{method:`POST`,keepalive:r,headers:{"Content-Type":`text/plain`},body:JSON.stringify({writeKey:e.writeKey,batch:n,sentAt:new Date().toISOString()})}).then(e=>{if(e.status<400){l===i&&(s=0,c=0);return}if(e.status===429){let t=Number.parseInt(e.headers?.get(`Retry-After`)??``,10);h(n,Number.isNaN(t)?m():Math.min(Math.max(t,0)*1e3,Ie));return}if(e.status>=500){h(n,m());return}l===i&&(s=0)},()=>h(n,m()))}catch{return}},m=()=>Math.min(Pe*2**s,Fe),h=(e,t)=>{if(l+=1,s+=1,s>Ne){s=0;return}f(e),c=Math.max(c,Date.now()+t)},g=e=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,_(!0)},e)},_=(e=!1)=>{try{if(r.length===0)return;let t=Date.now();if(t<c){g(c-t);return}if(u){if(o)return;i!==null&&(clearTimeout(i),i=null),o=!0;let e=()=>
4{o=!1,_()},t=p(d(Re),!0);t?t.then(e,e):e();return}if(a)return;if(r.length>=je||e){i!==null&&(clearTimeout(i),i=null);let e=d(Le);a=!0;let t=()=>{a=!1,_()},n=p(e,!1);n?n.then(t,t):t();return}i===null&&g(Me)}catch{}};try{addEventListener(`pagehide`,()=>{u=!0,_()}),document.addEventListener(`visibilitychange`,()=>{u=document.visibilityState===`hidden`,u&&_()})}catch{}let v=t=>{try{r.push({...t,anonymousId:e.anonymousId,timestamp:new Date().toISOString(),messageId:ze(),context:n}),_()}catch{}};return{track(e,t){v({type:`track`,event:e,properties:t})},identify(e){v({type:`identify`,traits:e})}}}var He=2e3,Ue=18e4,We=null,Ge=!1,Ke=!1;function qe(){if(Ge||!We)return;let e;try{e=globalThis.whop;let t=e?.track;if(typeof t!=`function`)return;Ge=!0,t.call(e,`id`,{anonymous_id:We,source:`link`})}catch{}}function Je(){if(Ke)return;Ke=!0;let e=[],t=()=>{Ke=!1;for(let t of e.splice(0))try{t()}catch{}},n=()=>{qe(),Ge&&t()},r=setInterval(n,He),i=setTimeout(()=>clearInterval(r),Ue);e.push(()=>{clearInterval(r),clearTimeout(i)});try{let t=()=>{document.visibilityState===`visible`&&n()};document.addEventListener(`visibilitychange`,t),e.push(()=>document.removeEventListener(`visibilitychange`,t))}catch{}}function Ye(e){try{We??=e,qe(),Ge||Je()}catch{}}var Xe=`segapi.whop.com/v1`,Ze={track:()=>void 0,identify:()=>void 0,child:()=>Ze},Qe={email:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,phone:/^\d{7,}$/},$e=new WeakMap;function et(e,t){let n=$e.get(e);n||$e.set(e,n=new Map);let r={};for(let e of Object.keys(Qe)){let i=t[e];if(typeof i!=`string`)continue;let a=e===`phone`?i.replace(/[\s\-().+]/g,``):i.trim();!Qe[e].test(a)||n.get(e)===a||(n.set(e,a),r[e]=a)}return Object.keys(r).length>0?r:void 0}var tt=new Map;function nt(e,t){let n=tt.get(e);if(n)return n;try{let n=Ve({apiHost:Xe,writeKey:e,anonymousId:t,libraryVersion:Se()??`0`});return tt.set(e,n),n}catch{return null}}function F(e){try{return e==null?0:typeof e==`object`&&!Array.isArray(e)?Object.keys(e).length:1}catch{return 0}}function I(e,t){try{if(!t?.length||typeof e!=`object`||!e||Array.isArray(e))return;let n={};for(let[r,i]of Object.entries(he(t)))try{let t=ge(e[r],i);t!=null&&(n[r]=t)}catch{}return Object.keys(n).length>0?n:void 0}catch{return}}function rt(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function it(e,t){return{track(n,r){try{e.track(n,{...t,...rt(r??{})})}catch{}},identify(t){try{let n=et(e,t);n&&e.identify(n)}catch{}},child(n){return it(e,{...t,...rt(n)})}}}var at=null;function ot(e){at=e?.writeKey?.trim()||null}function st(e){if(typeof window>`u`)return Ze;let t=null,n=null,r=()=>{let r=at;if(!r)return null;if(n?.writeKey!==r)try{let i=ke();t??=Ae();let a=nt(r,i.anonymousId);if(!a)return null;n={writeKey:r,scope:it(a,rt({namespace:e.namespace,host_origin:location.origin,mode:`direct`,render_id:i.renderId,controller_id:t}))};try{Ye(i.anonymousId)}catch{}}catch{return null}return n.scope},i=e=>({track(t,n){r()?.track(t,{...e,...n})},identify(e){r()?.identify(e)},child(t){return i({...e,...rt(t)})}});return i({})}var ct=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},L=`1.9.0`,lt=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function ut(e){var t=new Set([e]),n=new Set,r=e.match(lt);if(!r)return function(){return!1};var i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var r=e.match(lt);if(!r)return a(e);var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var dt=ut(L),ft=L.split(`.`)[0],pt=Symbol.for(`opentelemetry.js.api.`+ft),mt=ct;function ht(e,t,n,r){r===void 0&&(r=!1);var i=mt[pt]=mt[pt]??{version:L};if(!r&&i[e]){var a=Error(`@opentelemetry/api: Attempted duplicate registration of API: `+e);return n.error(a.stack||a.message),!1}if(i.version!==`1.9.0`){var a=Error(`@opentelemetry/api: Registration of version v`+i.version+` for `+e+` does not match previously registered API v`+L);return n.error(a.stack||a.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for `+e+` v`+L+`.`),!0}function gt(e){var t=mt[pt]?.version;if(!(!t||!dt(t)))return mt[pt]?.[e]}function _t(e,t){t.debug(`@opentelemetry/api: Unregistering a global for `+e+` v`+L+`.`);var n=mt[pt];n&&delete n[e]}var vt=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},yt=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;
4r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},bt=function(){function e(e){this._namespace=e.namespace||`DiagComponentLogger`}return e.prototype.debug=function(){var e=[...arguments];return xt(`debug`,this._namespace,e)},e.prototype.error=function(){var e=[...arguments];return xt(`error`,this._namespace,e)},e.prototype.info=function(){var e=[...arguments];return xt(`info`,this._namespace,e)},e.prototype.warn=function(){var e=[...arguments];return xt(`warn`,this._namespace,e)},e.prototype.verbose=function(){var e=[...arguments];return xt(`verbose`,this._namespace,e)},e}();function xt(e,t,n){var r=gt(`diag`);if(r)return n.unshift(t),r[e].apply(r,yt([],vt(n),!1))}var R;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(R||={});function St(e,t){e<R.NONE?e=R.NONE:e>R.ALL&&(e=R.ALL),t||={};function n(n,r){var i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,R.ERROR),warn:n(`warn`,R.WARN),info:n(`info`,R.INFO),debug:n(`debug`,R.DEBUG),verbose:n(`verbose`,R.VERBOSE)}}var Ct=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},wt=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Tt=`diag`,Et=function(){function e(){function e(e){return function(){var t=[...arguments],n=gt(`diag`);if(n)return n[e].apply(n,wt([],Ct(t),!1))}}var t=this;t.setLogger=function(e,n){if(n===void 0&&(n={logLevel:R.INFO}),e===t){var r=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(r.stack??r.message),!1}typeof n==`number`&&(n={logLevel:n});var i=gt(`diag`),a=St(n.logLevel??R.INFO,e);if(i&&!n.suppressOverrideMessage){var o=Error().stack??`<failed to generate stacktrace>`;i.warn(`Current logger will be overwritten from `+o),a.warn(`Current logger will over
4write one already registered from `+o)}return ht(`diag`,a,t,!0)},t.disable=function(){_t(Tt,t)},t.createComponentLogger=function(e){return new bt(e)},t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}return e.instance=function(){return this._instance||=new e,this._instance},e}();function Dt(e){return Symbol.for(e)}var Ot=new(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}}return e}()),kt=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},At=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},jt=function(){function e(){}return e.prototype.active=function(){return Ot},e.prototype.with=function(e,t,n){var r=[...arguments].slice(3);return t.call.apply(t,At([n],kt(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),Mt=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Nt=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},Pt=`context`,Ft=new jt,It=function(){function e(){}return e.getInstance=function(){return this._instance||=new e,this._instance},e.prototype.setGlobalContextManager=function(e){return ht(Pt,e,Et.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,Nt([e,t,n],Mt(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return gt(Pt)||Ft},e.prototype.disable=function(){this._getContextManager().disable(),_t(Pt,Et.instance())},e}(),Lt;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(Lt||={});var Rt={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:Lt.NONE},zt=function(){function e(e){e===void 0&&(e=Rt),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),Bt=Dt(`OpenTelemetry Context Key SPAN`);function Vt(e){return e.getValue(Bt)||void 0}function Ht(){return Vt(It.getInstance().active())}function Ut(e,t){return e.setValue(Bt,t)}function Wt(e){return e.deleteValue(Bt)}function Gt(e,t){return Ut(e,new zt(t))}function Kt(e){return Vt(e)?.spanContext()}var qt=/^([0-9a-f]{32})$/i,Jt=/^[0-9a-f]{16}$/i;function Yt(e){return qt.test(e)&&e!==`00000000000000000000000000000000`}function Xt(e){return Jt.test(e)&&e!==`0000000000000000`}function Zt(e){return Yt(e.traceId)&&Xt(e.spanId)}function Qt(e){return new zt(e)}var $t=It.getInstance(),en=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(n===void 0&&(n=$t.active()),t?.root)return new zt;var r=n&&Kt(n);return tn(r)&&Zt(r)?new zt(r):new zt},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,o;if(!(arguments.length<2)){arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);var s=a??$t.active(),c=this.startSpan(e,i,s),l=Ut(s,c);return $t.with(l,o,void 0,c)}},e}();function tn(e){return typeof e==`object`&&typeof e.spanId==`string`&&typeof e.traceId==`string`&&typeof e.traceFlags==`
4number`}var nn=new en,rn=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):nn},e}(),an=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new en},e}()),on=function(){function e(){}return e.prototype.getTracer=function(e,t,n){return this.getDelegateTracer(e,t,n)??new rn(this,e,t,n)},e.prototype.getDelegate=function(){return this._delegate??an},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){return this._delegate?.getTracer(e,t,n)},e}(),sn;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(sn||={});var cn=It.getInstance(),ln=`trace`,un=function(){function e(){this._proxyTracerProvider=new on,this.wrapSpanContext=Qt,this.isSpanContextValid=Zt,this.deleteSpan=Wt,this.getSpan=Vt,this.getActiveSpan=Ht,this.getSpanContext=Kt,this.setSpan=Ut,this.setSpanContext=Gt}return e.getInstance=function(){return this._instance||=new e,this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=ht(ln,this._proxyTracerProvider,Et.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return gt(ln)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){_t(ln,Et.instance()),this._proxyTracerProvider=new on},e}().getInstance(),dn=/^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;function fn(e){if(typeof e!=`string`)return null;let t=dn.exec(e);if(!t)return null;let[,n,r,i]=t;return/^0+$/.test(n)||/^0+$/.test(r)?null:{traceId:n,spanId:r,traceFlags:Number.parseInt(i,16)}}var pn=`@whop/elements`,mn=`settled`,hn={},gn,_n=e=>({traceparent:e,setAttributes:()=>void 0,addLinkTraceparent:()=>void 0,fail:()=>void 0,end:()=>void 0,run:e=>e()});function vn(e){let t=fn(e);return t?{activeContext:un.setSpanContext(cn.active(),{...t,isRemote:!0}),hadParent:!0}:{activeContext:cn.active(),hadParent:!1}}function yn(e){let t=Math.trunc(e/1e3);return[t,Math.round((e-t*1e3)*1e6)]}function bn(e,t){try{let n=e.spanContext();return un.isSpanContextValid(n)?`00-${n.traceId}-${n.spanId}-${(n.traceFlags&255).toString(16).padStart(2,`0`)}`:t}catch{return t}}function xn(e,t,n){return{traceparent:bn(e,t),setAttributes(t){try{e.setAttributes(t)}catch{}},addLinkTraceparent(t){try{let n=fn(t);n&&e.addLink({context:{...n,isRemote:!0}})}catch{}},fail(t){try{let n=t?.code;typeof n==`string`&&e.setAttributes({"error.code":n}),e.setStatus({code:sn.ERROR})}catch{}},end(t){try{e.end(t===void 0?void 0:yn(t))}catch{}},run(t){let r=!1,i=()=>(r=!0,t());try{return cn.with(un.setSpan(n,e),i)}catch(e){if(r)throw e;return t()}}}}function z(e,t={}){if(mn!==`settled`)return _n(t.traceparent);try{let{activeContext:n,hadParent:r}=vn(t.traceparent),i=[];for(let e of t.linkTraceparents??[]){let t=fn(e);t&&i.push({context:{...t,isRemote:!0}})}return xn(un.getTracer(pn,gn).startSpan(e,{...t.root?{root:!0}:{},...i.length?{links:i}:{},...t.startTime===void 0?{}:{startTime:yn(t.startTime)},attributes:{...hn,...t.attributes}},n),r?t.traceparent:void 0,n)}catch{return _n(t.traceparent)}}function B(e,t,n){let r={};e!==`props`&&(r[`whop.${e}_keys`]=F(t));let i=I(t,n);if(i)for(let[t,n]of Object.entries(i))r[`whop.${e}.${t}`]=Sn(n);return r}function Sn(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)&&e.length>0){let t=typeof e[0];if((t===`string`||t===`number`||t===`boolean`)&&e.every(e=>typeof e===t))return e}return JSON.stringify(e)}var Cn=128,wn=class{causes=new Set;dropped=0;note(e){if(!(typeof e!=`string`||e.length===0)&&(this.causes.delete(e),this.causes.add(e),this.causes.size>Cn)){let e=this.causes.values().next().value;this.causes.delete(e),this.dropped+=1}}clear(){this.causes.clear(),this.dropped=0}drain(e,t){let n=[...this.causes],r=this.dropped;
4if(this.clear(),n.length===0)return null;let i={coalesced_count:n.length,...r>0?{coalesced_dropped:r}:{}};return n.length===1?z(e,{traceparent:n[0],attributes:{...t,...i}}):z(e,{root:!0,linkTraceparents:n,attributes:{...t,...i}})}},V=Object.freeze({destroyed:Symbol.for(`whop.elements.child.destroyed`),dismissed:Symbol.for(`whop.elements.child.dismissed`)}),Tn={boolean:(e,t)=>({type:`boolean`,default:e,label:t?.label}),number:(e,t)=>({type:`number`,default:e,label:t?.label,min:t?.min,max:t?.max,step:t?.step}),text:(e,t)=>({type:`text`,default:e,label:t?.label,placeholder:t?.placeholder}),select:(e,t,n)=>({type:`select`,default:e,label:n?.label,options:t})},En=class{spec={props:()=>({})};propsSet=!1;get built(){return this.propsSet}controls(e){return this.spec.controls=e(Tn),this}props(e){return this.spec.props=e,this.propsSet=!0,this}state(e){return this.spec.state=e,this}hostState(e){return this.spec.hostState=e,this}sdk(e){return this.spec.sdk=e({}),this}};function Dn(e){let t=new En;kn(e(t),t);let{controls:n,props:r,sdk:i}=t.spec;return{...n?{controls:n}:{},props:r,...i?{sdk:i}:{}}}function On(e){let t=new En;return kn(e(t),t),{...t.spec}}function kn(e,t){if(e!==t||!t.built)throw Error("demo builder: `.props(() => ({…}))` is required — a demo must derive at least the consumer-set props. Call `.demo((d) => d.props(() => ({…})))`.")}function An(e){let t=H({__kind:`event`,audience:e});return Object.assign(t,{analytics(...e){return t.__analytics=e,t}})}var jn={external(){return An(`external`)},direct(){return An(`direct`)},internal(){return An(`internal`)},hostInternal(){return An(`hostInternal`)}};function H(e){return Object.assign(e,{doc(t){return e.__doc=t,e}})}function U(e){return Object.assign(e,{analytics(...t){return e.__analytics=t,e}})}var Mn={default:e=>U(H({__prop:!0,__src:`default`,default:e})),fromHost:()=>U(H({__prop:!0,__src:`host`})),fromController:()=>U(H({__prop:!0,__src:`controller`})),fromOpen:()=>U(H({__prop:!0,__src:`open`})),fromControllerOrDirect:()=>U(H({__prop:!0,__src:`controllerOrDirect`})),direct:()=>{let e=U(H({__prop:!0,__src:`direct`}));return Object.assign(e,{default(t){return e.default=t,e.__hasDirectDefault=!0,e},embedDefault(e){return H({__prop:!0,__src:`embedDefault`,default:e})}})}},Nn={default:Mn.default,fromController:()=>U(H({__prop:!0,__src:`controller`})),hostOnly:()=>U(H({__prop:!0,__src:`hostOnly`})),required:()=>U(H({__prop:!0,__src:`required`})),direct:()=>H({__prop:!0,__src:`direct`})},Pn={async:(e,t=[])=>({__hostSource:`async`,fn:e,deps:t}),sync:(e,t=[])=>({__hostSource:`sync`,fn:e,deps:t})};function Fn(e){if(typeof e==`object`&&e&&(e.__hostSource===`async`||e.__hostSource===`sync`))return e}var In={sync:(e,t)=>({__controllerSource:`sync`,fn:e,deps:t}),async:(e,t)=>({__controllerSource:`async`,fn:e,deps:t})};function Ln(e){if(typeof e!=`object`||!e)return;let t=e;return t.__controllerSource===`async`||t.__controllerSource===`sync`?t:void 0}var Rn={required:()=>H({__kind:`contribution`,required:!0}),optional:()=>H({__kind:`contribution`,required:!1})};function zn(e){if(typeof e==`object`&&e&&e.__kind===`contribution`){let t=e;return{required:t.required,doc:t.__doc}}}function Bn(e){return typeof e==`object`&&!!e&&e.__prop===!0}function Vn(e){if(typeof e==`object`&&e&&e.__kind===`event`)return e.audience}function Hn(e){if(typeof e==`object`&&e&&e.__kind===`event`)return e.__doc}function Un(e){if(typeof e==`object`&&e&&e.__kind===`event`)return e.__analytics}function Wn(e){let t={},n={},r={},i=[];for(let[a,o]of Object.entries(e))Bn(o)&&(t[a]=o.__src,(o.__src==="default"||o.__src===`embedDefault`||o.__src===`direct`&&o.__hasDirectDefault)&&(n[a]=o.default),o.__doc!==void 0&&(r[a]=o.__doc),o.__analytics&&i.push(...o.__analytics.length>0?o.__analytics.map(e=>`${a}.${e}`):[a]));return{sources:t,defaults:n,docs:r,analytics:i}}var Gn=`__whopEventHandlers`,Kn=new Set([Object.prototype,null]);function qn(e,t=`payload`){let n=[];return{value:Jn(e,t,n,new WeakSet),violations:n}}function Jn(e,t,n,r){if(typeof e==`number`)return Number.isFinite(e)?e:(n.push(`${t} (${e} — JSON serializes non-finite numbers as null)`),null);if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(e===void 0||typeof e==`function`||typeof e==`symbol`){n.push(`${t} (${typeof e})`);return}if(typeof e==`bigint`){n.push(`${t} (bigint — JSON.stringify throws on it)`);return}if(r.has(e)){n.push(`${t} (circular reference — JSON.stringify throws on it)`);return}if(Array.isArray(e)){r.add(e);let i=Array(e.length);for(let a=0;a<e.length;a++){if(!(a in e)){n.push(`${t}[${a}] (array hole — JSON delivers null)`),i[a]=null;continue}let o=Jn(e[a],`${t}[${a}]`,n,r);i[a]=o===void 0?null:o}return r.delete(e),i}if(typeof e==`object`){let i=e.toJSON;if(typeof i==`function`){n.push(`${t} (${e.constructor?.name??`object`} — serializes inconsistently across transports; send a plain value)`),r.add(e);let a=Jn(i.call(e),t,n,r);return r.delete(e),a}Kn.has(Object.getPrototypeOf(e))||n.push(`${t} (${e.constructor?.name??`class`} instance — prototypes do not cross the wire)`),r.add(e);let a={};for(let[i,o]of Object.entries(e)){if(o===void 0)continue;let e=Jn(o,`${t}.${i}`,n,r);e!==void 0&&(a[i]=e)}return r.delete(e),a}n.push(`${t} (${typeof e})`)}function W(e,t){return t}function Yn(e,t){let n=e==="default"?{__resourceOption:!0,__kind:e,default:t}:{__resourceOption:!0,__kind:e};return Object.assign(n,{doc(e){return n.__doc=e,n}})}var Xn={required:()=>Yn(`required`),optional:()=>Yn(`optional`),default:e=>Yn(`default`,e)},Zn={fn:()=>{let e={__resourceMethod:!0,__gesture:!1};return Object.assign(e,{doc(t){return e.__doc=t,e},gesture(){return e.__gesture=!0,e}})}},Qn={event:()=>{let e={__resourceEvent:!0};return Object.assign(e,{doc(t){return e.__doc=t,e},reply(t){if(typeof t!=`string`||t.length===0)throw Error(`.reply(key) requires the payload's reply-function key as a non-empty string.`);return e.__reply=t,e}})}},$n=/[#./:\s]/;function er(e,t){if(!e||$n.test(e))throw Error(`${t} ${JSON.stringify(e)}
4 is invalid — "#", ".", "/", ":" and whitespace are reserved separators; use a plain non-empty name.`);if(e.startsWith(`_`))throw Error(`${t} ${JSON.stringify(e)} is invalid — a leading "_" is the reserved framework-segment prefix; use a name that does not start with "_".`)}function tr(e,t){for(let n of e)if(j(n))throw Error(`"${n}" on the ${t} sits in the on[A-Z]… event-callback namespace (the minted instance's generated on<Event> subscriptions live there) — rename it.`)}var nr=class{config;declared=new Set;constructor(e){this.config=e}singleShot(e){if(this.declared.has(e))throw Error(`.${e}() is already declared on resource "${this.config.name}" — declaration slots are single-shot; merge both calls into one.`);this.declared.add(e)}doc(e){return this.singleShot(`doc`),this.config.description=e,this}options(e){this.singleShot(`options`);let t=e(Xn);tr(Object.keys(t),`resource "${this.config.name}" options`);for(let[e,n]of Object.entries(t)){let t=n;if(typeof t!=`object`||!t||t.__resourceOption!==!0)throw Error(`resource "${this.config.name}" option "${e}" is not an option marker — declare it via o.required<T>()/o.optional<T>()/o.default(v) with .doc(...)`);this.config.optionKinds[e]=t.__kind,t.__kind==="default"&&(this.config.optionDefaults[e]=t.default),t.__doc!==void 0&&(this.config.optionDocs[e]=t.__doc)}return this}methods(e){this.singleShot(`methods`);let t=e(Zn);tr(Object.keys(t),`resource "${this.config.name}" methods`);for(let[e,n]of Object.entries(t)){let t=n;if(typeof t!=`object`||!t||t.__resourceMethod!==!0)throw Error(`resource "${this.config.name}" method "${e}" is not a method marker — declare it via m.fn<F>() with .doc(...)`);this.config.methods[e]={gesture:t.__gesture,...t.__doc===void 0?{}:{__doc:t.__doc}}}return this}opens(e){this.singleShot(`opens`);let t=e(e=>({detached:e}));tr(Object.keys(t),`resource "${this.config.name}" opens`);for(let[e,n]of Object.entries(t)){er(e,`resource "${this.config.name}" detached-child key`);let t=n?.detached,r=t?.__config;if(!t||typeof r!=`object`||!r||typeof r.name!=`string`||typeof r.actions!=`object`)throw Error(`resource "${this.config.name}" detached child "${e}" is not an element def — declare it via o(<ElementDef>) with the def imported as a value.`);if(!r.modalChrome)throw Error(`resource "${this.config.name}" detached child "${e}" (element "${r.name}") declares no .modal() — a detached child presents as a modal overlay, so the element must declare .modal(fn) (its modal page is what the build emits and this rail opens).`);this.config.opens[e]=t}return this}events(e){this.singleShot(`events`);let t=e(Qn);for(let[e,n]of Object.entries(t)){let t=n;if(typeof t!=`object`||!t||t.__resourceEvent!==!0)throw Error(`resource "${this.config.name}" event "${e}" is not an event marker — declare it via e.event<T>() with .doc(...)`);this.config.events[e]={...t.__reply===void 0?{}:{reply:t.__reply},...t.__doc===void 0?{}:{__doc:t.__doc}}}return this}create(e){if(typeof e!=`function`)throw Error(`resource "${this.config.name}": .create() takes the factory function (({ options, emit }) => impl) — got ${typeof e}.`);return this.config.factory=e,{__slots:void 0,__config:this.config,resourceName:this.config.name}}};function rr(e){return er(e,`resource name`),new nr({name:e,description:``,optionKinds:{},optionDefaults:{},optionDocs:{},methods:{},events:{},opens:{},factory:()=>{throw Error(`resource "${e}" was never finalized with .create(factory)`)}})}function ir(e){return typeof e==`object`&&!!e&&typeof e.resourceName==`string`&&typeof e.__config==`object`}function ar(e,t={},n={}){let r=e.__config,i=async(e,t)=>{let i=(r.opens??{})[e];if(!i){let t=Object.keys(r.opens??{}).map(e=>`"${e}"`);throw Error(`resource "${r.name}": ctx.open("${e}") is not a declared detached child — ${t.length?`declared: ${t.join(`, `)}.`:`it declares none; add .opens((o) => ({ … })) to the resource.`}`)}if(t!==void 0&&(typeof t!=`object`||!t))throw Error(`resource "${r.name}": ctx.open("${e}") input must be an object carrying the element's fromOpen props — got ${t===null?`null`:typeof t}.`);if(!n.openDetached)throw Error(`resource "${r.name}": ctx.open is not wired on this mint surface — the namespace SDK surface wires it (whop.<ns>.<key>.create); a mint with no presentation runtime cannot open detached children.`);return or(r,e,i,await n.openDetached(i,e,t))};for(let[e,n]of Object.entries(r.optionKinds))if(n===`required`&&t[e]===void 0)throw Error(`resource "${r.name}": missing required option "${e}" — pass it to .create({ ${e}: … }).`);let a={...r.optionDefaults};for(let[e,n]of Object.entries(t))n!==void 0&&(a[e]=n);let o=new Map,s={};for(let[e,t]of Object.entries(r.events))s[e]=n=>{let i=[...o.get(e)??[]];t.reply!==void 0&&i.length;for(let t of i)try{t(n)}catch(t){console.error(`[whop-elements] resource "${r.name}" "${e}" handler threw`,t)}return i.length};let c=r.factory({options:a,emit:s,open:i,...n.apiBaseUrl===void 0?{}:{apiBaseUrl:n.apiBaseUrl}}),l={};for(let[e,t]of Object.entries(r.methods)){let n=c[e];if(typeof n!=`function`)throw Error(`resource "${r.name}": the .create() factory returned no "${e}" function, but .methods() declares it — the declaration is the consumer surface; implement it (or drop the declaration).`);l[e]=(t.gesture,(...e)=>n.apply(c,e))}for(let e of Object.keys(r.events))l[ce(e)]=t=>{if(typeof t!=`function`)throw Error(`resource "${r.name}".${ce(e)}(handler) takes a function — got ${typeof t}.`);let n=o.get(e);return n||(n=new Set,o.set(e,n)),n.add(t),()=>n.delete(t)};return l}function or(e,t,n,r){let i=n.__config,a={};for(let e of Object.keys(i.actions))a[e]=t=>r.call(e,t);let o=new Set,s=!1,c=()=>{s=!0;for(let e of o)e();o.clear()};return r.closed.then(c),{closed:r.closed,close:()=>{c(),r.close()},actions:a,on:(e,n)=>{if(typeof n!=`function`)throw Error(`detached child "${t}": on("${e}", handler) takes a function — got ${typeof n}.`);let a=i.events[e];if(a===void 0){let n=Object.entries(i.events).filter(([,e])=>e===`external`).map(([e])=>`"${e}"`);throw Error(`detached child "${t}" (element "${i.name}") declares no event "${e}" — ${n.length?`its external events: ${n.join(`, `)}.`:`it declares no external events.`}`)}if(a!==`external`)throw Error(`"${e}" is ${a.toUpperCase()}-audience on "${i.name}" — a detached child's handle only receives external events (internal has no controller here; direct fires only on a composed/direct mount); declare it e.external() (the detached handle is its receiver).`);if(s)throw Error(`detached child "${t}": on("${e}", …) after the open CONCLUDED (its \`closed\` promise has settled) — the handle is a session over one open; subscribe while the child is up, or re-open and subscribe on the new handle.`);let c=r.events((t,r)=>{t===e&&n(r)});return o.add(c),()=>{o.delete(c),c()}}}}var sr=[`bottom-start`,`bottom-end`,`top-start`,`top-end`,`right-start`,`left-start`],cr=/[#./:\s]/;function G(e,t){if(!e||cr.test(e))throw Error(`${t} ${JSON.stringify(e)}
4 is invalid — "#", ".", "/", ":" and whitespace are reserved separators; use a plain non-empty name.`);if(e.startsWith(`_`))throw Error(`${t} ${JSON.stringify(e)} is invalid — a leading "_" is the reserved framework-segment prefix (_controller, _playground); use a name that does not start with "_".`)}var lr=new Set([`chunks`,`css`]),ur=new Set([`children`,`fallback`,`instanceId`,`childKey`,`ref`]),dr=[`appearance`,`locale`],fr=new Set([...ur,`handleId`,...dr,`environment`,`baseUrl`,`apiBaseUrl`,`analytics`,`toasts`,`skipPixel`]),pr=new Set([Gn,`eventHandlers`,...ur,`props`,`container`,`appearance`,`page`,`channel`,`instance`,`noAutoSize`,`controllerProps`,`demoControls`,`bootProps`,`controllerSeed`,`shellVariant`,`anchored`,`openedChild`,`flowSurface`,`otelTraceparent`,`revealHold`]),mr=new Set([`iframe`,`mount`,`destroy`,`update`,`state`,`created`,`attached`,`visible`,...pr]),hr=[`update`,`destroy`],gr=new Set([`create`,`mountChild`,`destroy`,`createElement`,`createOverlay`,`update`,`teardown`,`start`,`isLoading`,`subscribeLoading`,`state`,`handleId`,`created`,`attached`,`visible`]);function K(e,t,n){for(let r of e)if(t.has(r)||j(r))throw Error(`"${r}" is a reserved name on the ${n} (reserved: ${[...t].join(`, `)}, and on[A-Z]… event-callback names) — rename it.`)}function _r(e,t,n){if(e.has(t))throw Error(`.${t}() is already declared on ${n} — declaration slots are single-shot; merge both calls into one.`);e.add(t)}function vr(e,t){for(let n of e)if(Object.hasOwn(t,n))throw Error(`"${n}" is declared as both an action and a .host() method — both install onto the element handle, so one would silently shadow the other; rename it.`)}var yr=new Set([`error`,`ready`]);function br(e,t,n){for(let[r,i]of Object.entries(e)){if(yr.has(r))throw Error(`event "${r}" is runtime-owned — the runtime itself dispatches the "${ce(r)}" callback (with a pinned payload contract), so an authored "${r}" event would collide with it; rename the event.`);let e=Vn(i);if(e===void 0)throw Error(`event "${r}" is not an event marker — declare it via e.external()/e.internal()/e.direct()/e.hostInternal() with .doc(...)`);if(e===`direct`&&n===`controller`)throw Error(`event "${r}" is direct-audience — direct events are element-scoped (a controller's direct-mode consumer face is its handle); declare it e.external() or e.internal().`);if(e===`hostInternal`&&n===`controller`)throw Error(`event "${r}" is hostInternal-audience — host-internal events are element-scoped (they exist for a frame to reach the page's on.host reactions; a controller's own events already reach the host); declare it e.external() or e.internal().`);t.events[r]=e;let a=Hn(i);a!==void 0&&(t.eventDocs[r]=a);let o=Un(i);o!==void 0&&(t.eventAnalytics[r]=xr(`event "${r}"`,o))}}function xr(e,t){if(t.length===0)throw Error(`${e}: .analytics() needs at least one payload key — drop the call to keep the default (names + counts only).`);let n=new Set;for(let r of t){if(typeof r!=`string`||r.length===0)throw Error(`${e}: .analytics() keys must be non-empty strings (got ${JSON.stringify(r)}).`);if(n.has(r))throw Error(`${e}: .analytics() key "${r}" is listed twice.`);n.add(r),Sr(e,r)}try{he(t)}catch(t){throw Error(`${e}: ${t.message}`)}return[...t]}function Sr(e,t){for(let n of t.split(`.`))if(n.length>0&&Pr(n))throw Error(`${e}: .analytics() path "${t}" names the secret-shaped key "${n}" — allowlisted values are exported to the analytics pipeline, so secret-shaped keys are refused outright at every level (rename the field if it is genuinely public; ANALYTICS.md § Payloads).`)}function Cr(e,t,n={},r=`element`){let i=new Map;for(let t of e){let e=t.indexOf(`.`),n=e===-1?t:t.slice(0,e),r=i.get(n)??[];r.push(e===-1?``:t.slice(e+1)),i.set(n,r)}for(let[e,a]of i){let i=t[e];if(r===`controller`&&i===`controller`)throw Error(`prop "${e}": .analytics() is dead config on a controller's s.fromController option — the controller Mounted snapshot is the CREATE-OPTIONS bag (declared s.default values + the consumer's options) and a declared sub emits no Controller Mounted at all, so a parent-injected value never rides any mount event. Declare the opt-in where the value actually emits (the sub's own element props / event payloads), or make it an s.default option (ANALYTICS.md § Payloads).`);if(i===`direct`)throw Error(`prop "${e}
4": .analytics() is not available on p.direct — direct-only props are Serializable-EXEMPT (host-realm values, never wire data), so there is no mount value to export. Move the value to a wire-crossing source or drop the opt-in.`);if(i===`hostOnly`)throw Error(`prop "${e}": .analytics() is not available on s.hostOnly — host-consumed props never reach a frame (and may hold functions), so there is no mount-snapshot value to export. Use s.default for a consumer option whose value should ride the mount event.`);if(Pr(e))throw Error(`prop "${e}": .analytics() is refused on a secret-shaped name — allowlisted mount values are exported to the analytics pipeline (rename the prop if it is genuinely public; ANALYTICS.md § Payloads).`);for(let t of a)t!==``&&Sr(`prop "${e}"`,t);let o=wr(e,a);if(e in n&&n[e]!=null){let t=_e(n[e],o);if(t!==null)throw Error(`prop "${e}": .analytics() values ride exactly as declared — a leaf (a primitive, or an array of them) at every named path — but its declared default has ${t} (ANALYTICS.md § Payloads).`)}}return[...e]}function wr(e,t){if(t.length===1&&t[0]===``)return null;if(t.includes(``))throw Error(`prop "${e}": .analytics() names the prop both as a leaf and by its fields — declare it once, naming the fields to export.`);try{return he(t)}catch(t){throw Error(`prop "${e}": ${t.message}`)}}function Tr(e){for(let[t,n]of Object.entries(e)){let e=n;typeof e.analytics==`function`&&delete e.analytics;let r=e.__analytics;if(r!==void 0){if(delete e.__analytics,n.kind===`static`||n.kind===`host`)throw Error(`action "${t}": .analytics() is not available on a.${n.kind} — host-page action kinds are not instrumented (the consumer page never emits; ANALYTICS.md § topology). Move the flow to an instrumented kind or drop the allowlist.`);n.analytics=xr(`action "${t}"`,r)}}}function q(e){let t=H(e);return Object.assign(t,{analytics(...e){return t.__analytics=e,t}})}var Er={public:e=>q({kind:`public`,fn:e}),controllerOnly:e=>q({kind:`controllerOnly`,fn:e}),hostInternal:e=>q({kind:`hostInternal`,fn:e})},Dr=e=>H({fn:e}),Or=class{config;makeDef;declared=new Set;constructor(e,t){this.config=e,this.makeDef=t}singleShot(e){_r(this.declared,e,`element "${this.config.name}"`)}doc(e){return this.singleShot(`doc`),this.config.description=e,this}internal(){return this.config.internal=!0,this}props(e){this.singleShot(`props`);let t=e(Mn);K(Object.keys(t),mr,`element props`);let{sources:n,defaults:r,docs:i,analytics:a}=Wn(t);for(let[e,t]of Object.entries(n)){if(t===`hostOnly`)throw Error(`element prop "${e}" declares s.hostOnly — the host-consumed class exists on CONTROLLER props only (element props are delivered into the iframe; a host-consumed value could never reach the render). Hold host-side values in the controller's .hostState() and project what elements need via .fromHost.`);if(t===`embedDefault`){let{violations:t}=qn(r[e]);if(t.length>0)throw Error(`element prop "${e}" .embedDefault(...) value is not JSON-serializable (${t.join(`, `)}) — the baked embed value is recorded in the element metadata, so it must be a plain JSON value. Host-realm values (functions, stores, ReactNodes) belong on a plain p.direct<T>() prop.`)}}return this.config.propSources=n,this.config.propDefaults=r,this.config.propDocs=i,this.config.propAnalytics=Cr(a,n,r),this}state(e){return this.singleShot(`state`),this.config.stateInit=typeof e==`function`?e:()=>({...e}),this}events(e){return this.singleShot(`events`),br(e(jn),this.config,`element`),this}actions(e){this.singleShot(`actions`);let t=e(Er);return K(Object.keys(t),mr,`element handle`),vr(Object.keys(t),this.config.host),Tr(t),this.config.actions=t,this}host(e){this.singleShot(`host`);let t=e(Dr);return K(Object.keys(t),mr,`element handle`),vr(Object.keys(t),this.config.actions),this.config.host=t,this}contributes(e){this.singleShot(`contributes`);for(let[t,n]of Object.entries(e(Rn))){if(j(t))throw Error(`contribution point "${t}" on element "${this.config.name}" uses the reserved on[A-Z]… event-callback grammar — point names read as action moments ("beforeConfirmation"), never as callbacks; rename it.`);let e=zn(n);if(e===void 0)throw Error(`contribution point "${t}" is not a contribution marker — declare it via c.required<Fn>()/c.optional<Fn>() with .doc(...)`);this.config.contributions[t]={required:e.required},e.doc!==void 0&&(this.config.contributionDocs[t]=e.doc)}return this}anchors(...e){if(this.singleShot(`anchors`),e.length===0)throw Error(`element "${this.config.name}
4": .anchors() declares no names — list the anchor names, or omit the call.`);let t=new Set;for(let n of e){if(G(n,`anchor name`),t.has(n))throw Error(`element "${this.config.name}": anchor "${n}" is declared twice in .anchors().`);t.add(n)}return this.config.anchors=e,this}branded(){return this.singleShot(`branded`),this.config.branded=!0,this}modal(e,t){this.singleShot(`modal`);let n=t?.maxWidth;if(n!==void 0&&(typeof n!=`number`||!Number.isFinite(n)||n<=0))throw Error(`.modal(fn, { maxWidth: ${String(n)} }) — maxWidth must be a finite positive number of CSS pixels (e.g. 480); it is viewport-clamped at paint (min(<v>px, 100vw)), so declare the width you want on a large screen.`);return this.config.modalChrome=e,this.config.inline=t?.inline??!0,n!==void 0&&(this.config.modalMaxWidth=n),t?.autoFocus!==void 0&&(this.config.modalAutoFocus=t.autoFocus),this}loading(e,t){if(this.singleShot(`loading`),this.config.loading=e,t){let e=t.props===void 0?[]:Ar(this.config.name,t.props,`props`),n=t.parentProps===void 0?[]:Ar(this.config.name,t.parentProps,`parentProps`);if(e.length===0&&n.length===0)throw Error(`element "${this.config.name}": .loading(fn, opts) declares no shell props — list the consumer props (opts.props) and/or the parent-sourced props (opts.parentProps) the shell reads, or omit the options for the prop-blind shell.`);for(let t of n)if(e.includes(t))throw Error(`element "${this.config.name}": shell prop "${t}" is declared in BOTH props and parentProps — a shell prop has exactly one source; pick one.`);e.length&&(this.config.loadingProps=e),n.length&&(this.config.loadingParentProps=n)}return this}error(e){return this.singleShot(`error`),this.config.error=e,this}auth(e){return this.singleShot(`auth`),this.config.auth=e,this}demo(e){return this.singleShot(`demo`),this.config.demo=Dn(e),this}render(e){for(let e of this.config.loadingProps??[]){let t=this.config.propSources[e];if(t!=="default")throw Error(`element "${this.config.name}": shell prop "${e}" (.loading(fn, { props })) ${t?`is a ${t}-source prop`:`is not a declared prop`} — declared shell props must be p.default(...) consumer props (the host passes them at create; injected sources don't exist before boot).`+(t===`controller`?` A fromController prop whose value mirrors the DECLARING controller's create option belongs in opts.parentProps.`:``))}for(let e of this.config.loadingParentProps??[]){let t=this.config.propSources[e];if(t!==`controller`)throw Error(`element "${this.config.name}": parent-sourced shell prop "${e}" (.loading(fn, { parentProps })) ${t?`is a ${t}-source prop`:`is not a declared prop`} — parentProps keys must be p.fromController(...) props whose value resolves from the declaring controller's s.default(...) create option of the same name`+(t==="default"?` (a consumer prop belongs in opts.props)`:``)+`.`)}return this.config.render=e,this.makeDef(this.config)}},kr=/^[A-Za-z0-9_-]+$/;function Ar(e,t,n){if(!Array.isArray(t)||t.length===0)throw Error(`element "${e}": .loading(fn, { ${n} }) declares no props — list the ${n===`props`?`consumer`:`parent-sourced`} props the shell reads, or omit the list.`);let r=[...t].sort();for(let t=0;t<r.length;t++){let i=r[t];if(typeof i!=`string`||i.length===0)throw Error(`element "${e}": .loading(fn, { ${n} }) entries must be non-empty prop names.`);if(!kr.test(i))throw Error(`element "${e}": shell prop "${i}" is not a legal shell-prop name — declared names ride the canonical JSON variant key (the \`wsv\` fragment payload, the baked data-wsv attribute, and CSS attribute selectors) verbatim, so they must match ${String(kr)}. Rename the prop.`);if(i===r[t+1])throw Error(`element "${e}": shell prop "${i}" is declared twice in .loading(fn, { ${n} }).`);if(Pr(i))throw Error(`element "${e}": shell prop "${i}" looks secret-shaped — declared shell props ride the iframe URL FRAGMENT (base64url-encoded, which is encoding and NOT encryption: consumer-page-visible URL state); never parameterize the loading shell on a secret. If "${i}" is a public value, rename it.`)}return r}function jr(e,t){return new Or({name:e,description:``,internal:!1,propDefaults:{},propSources:{},propDocs:{},stateInit:()=>({}),events:{},eventDocs:{},eventAnalytics:{},propAnalytics:[],actions:{},host:{},contributions:{},contributionDocs:{}
4,inline:!0,anchors:[],render:()=>null},t)}var Mr=new Set([`token`,`key`,`secret`,`password`,`credential`,`credentials`,`apikey`]),Nr=new Set([`secret`,`password`,`credential`,`credentials`,`apikey`,`private`]);function Pr(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).toLowerCase().split(/[\s_-]+/).filter(Boolean);return Mr.has(t[t.length-1]??``)||t.some(e=>Nr.has(e))}var Fr=class{config;constructor(e){this.config={el:e,fromController:[],fromHost:[]}}fromController(e){return this.config.fromController.push(e),this}fromHost(e){return this.config.fromHost.push(e),this}many(){if(this.config.slot!==void 0)throw Error(`.many() cannot combine with .slot("${this.config.slot}") in v1 — an exclusive slot admits ONE live occupant; a collection child contradicts it.`);if(this.config.anchored)throw Error(`.many() cannot combine with .anchored(...) — an anchored child is a singleton frame beside its opener.`);if(this.config.required)throw Error(`.many() cannot combine with .required() — the reveal gate waits for ONE mount of the required child; a collection contradicts it.`);return this.config.many=!0,this}slot(e){if(this.config.many)throw Error(`.slot("${e}") cannot combine with .many() in v1 — an exclusive slot admits ONE live occupant; a collection child contradicts it.`);if(this.config.required)throw Error(`.slot("${e}") cannot combine with .required() — a slot's occupants ALTERNATE, a required child must ALWAYS be mounted; the two contradict.`);return Ir(this.config,e),this}required(){if(this.config.required)throw Error(`.required() is already declared — declarations are single-shot.`);if(this.config.many)throw Error(`.required() cannot combine with .many() — the reveal gate waits for ONE mount of the required child; a collection contradicts it.`);if(this.config.anchored)throw Error(`.required() cannot combine with .anchored(...) — an anchored child is controller-opened (never consumer-mounted), so nothing could satisfy the gate.`);if(this.config.slot!==void 0)throw Error(`.required() cannot combine with .slot("${this.config.slot}") — a slot's occupants ALTERNATE, a required child must ALWAYS be mounted; the two contradict.`);return this.config.required=!0,this}anchored(e,t,n){if(this.config.anchored)throw Error(`.anchored() is already declared ("${this.config.anchored.opener}
4" / "${this.config.anchored.anchor}") — a child binds at most one anchor.`);if(this.config.many)throw Error(`.anchored(...) cannot combine with .many() — an anchored child is a singleton frame beside its opener.`);if(this.config.required)throw Error(`.anchored(...) cannot combine with .required() — an anchored child is controller-opened (never consumer-mounted), so nothing could satisfy the gate.`);if(n?.placement!==void 0&&!sr.includes(n.placement))throw Error(`.anchored("${e}", "${t}", { placement: "${String(n.placement)}" }) — unknown placement; use one of ${sr.map(e=>`"${e}"`).join(` | `)}.`);if(n?.offset!==void 0&&(typeof n.offset!=`number`||!Number.isFinite(n.offset)))throw Error(`.anchored("${e}", "${t}", { offset: ${String(n.offset)} }) — offset must be a finite number of pixels (the gap along the placement's main axis).`);return this.config.anchored={opener:e,anchor:t,...n?.placement===void 0?{}:{placement:n.placement},...n?.offset===void 0?{}:{offset:n.offset}},this}};function Ir(e,t){if(e.slot!==void 0)throw Error(`.slot() is already declared ("${e.slot}") — a child claims at most one slot.`);G(t,`slot name`),e.slot=t}var Lr=class{config;constructor(e){this.config={controller:e,fromController:[]}}fromController(e){return this.config.fromController.push(e),this}slot(e){return Ir(this.config,e),this}};function Rr(e,t){let n=[];if(t.hasHostState&&n.push(`.hostState()`),Object.values(t.propSources).some(e=>e===`hostOnly`)&&n.push(`s.hostOnly(...) props`),Object.keys(t.hostReactions).length>0&&n.push(`on.host(...)`),Object.values(t.actions).some(e=>e.kind===`static`)&&n.push(`a.static(...)`),Object.values(t.actions).some(e=>e.kind===`host`)&&n.push(`a.host(...)`),Object.values(t.children).some(e=>e.fromHost.length>0)&&n.push(`.fromHost(...) child projections`),Object.values(t.children).some(e=>e.anchored)&&n.push(`.anchored(...) child declarations`),t.flowSurface&&n.push(`.flowSurface(...)`),n.length>0)throw Error(`sub-controller "${e}" ("${t.namespace}") declares host-half machinery (${n.join(`, `)}) — a nested controller runs controller-side only in v1 (SUB-CONTROLLERS.md); keep the host half on the declaring parent.`)}function zr(e){return typeof e.namespace==`string`}var Br={controller:e=>q({kind:`controller`,fn:e}),static:e=>q({kind:`static`,fn:e}),host:e=>q({kind:`host`,fn:e}),internal:e=>q({kind:`internal`,fn:e})},Vr=class{config;makeDef;declared=new Set;propsForm=`none`;constructor(e,t){this.config=e,this.makeDef=t}singleShot(e){_r(this.declared,e,`controller "${this.config.namespace}"`)}doc(e){return this.singleShot(`doc`),this.config.description=e,this}props(e){if(this.singleShot(`props`),this.propsForm=e?`fn`:`generic`,e){let t=e(Nn);K(Object.keys(t),fr,`controller props`);let{sources:n,defaults:r,docs:i,analytics:a}=Wn(t);for(let[e,t]of Object.entries(n))if(t!=="default"&&t!==`required`&&t!==`controller`&&t!==`hostOnly`&&t!==`direct`)throw Error(`controller prop "${e}" declares source "${t}" — controller props are s.default(v) / s.required<T>() (consumer-facing), s.fromController<T>() (parent-injected; SUB-CONTROLLERS.md), s.hostOnly<T>() (host-consumed, never delivered to a frame), or s.direct<T>() (direct-mode JSX only, never an embedded consumer option).`);this.config.propSources=n,this.config.propDefaults=r,this.config.propDocs=i,this.config.propAnalytics=Cr(a,n,r,`controller`)}return this}analytics(...e){if(this.singleShot(`analytics`),this.propsForm!==`generic`)throw Error(`controller "${this.config.namespace}": builder-level .analytics(...) chains only off the type-only .props<Shape>() escape hatch — declare .props<Shape>() first, and use the per-key .analytics() chain on the build-fn form (ANALYTICS.md § Payloads).`);return this.config.propAnalytics=xr(`controller "${this.config.namespace}" props`,e),this}state(e){return this.singleShot(`state`),this.config.stateInit=typeof e==`function`?e:()=>({...e}),this}hostState(e){return this.config.hasHostState=!0,this.singleShot(`hostState`),this.config.hostStateInit=typeof e==`function`?e:()=>({...e}),this}publicState(...e){return this.singleShot(`publicState`),this.config.publicStateKeys=[...new Set(e)],this}events(e){return this.singleShot(`events`),br(e(jn),this.config,`controller`),this}children(e){this.singleShot(`children`);let t=e(e=>zr(e)?new Lr(e):new Fr(e)),n=new Set;for(let[e,r]of Object.entries(t))if(G(e,`child key`),this.config.childOrder.push(e),r instanceof Lr){let t=r.config.controller;if(Rr(e,t.__config),t.__config===this.config)throw Error(`sub-controller "${e}": a controller cannot declare ITSELF as a child.`);if(Object.keys(t.__config.subControllers).length>0)throw Error(`sub-controller "${e}" ("${t.namespace}") declares its own sub-controllers — nesting is one level deep in v1 (SUB-CONTROLLERS.md).`);if(n.has(t.__config))throw Error(`sub-controller "${e}": controller "${t.namespace}" is already declared under another key — one key per sub-controller def in v1.`);n.add(t.__config),this.config.subControllers[e]=r.config}else this.config.children[e]=r.config;return this}actions(e){this.singleShot(`actions`);let t=e(Br);return K(Object.keys(t),gr,`handle surface`),Tr(t),this.config.actions=t,this}resources(e){this.singleShot(`resources`);let t=e(e=>{if(!ir(e))throw Error(`controller "${this.config.namespace}
4" .resources(): r(...) takes a Resource(name) def — got ${typeof e}.`);return{resource:e}});K(Object.keys(t),gr,`namespace surface`);let n={};for(let[e,r]of Object.entries(t)){if(G(e,`resource key`),!ir(r?.resource))throw Error(`controller "${this.config.namespace}" .resources(): r(...) takes a Resource(name) def — "${e}" carries ${typeof r?.resource}.`);n[e]=r.resource}return this.config.resources=n,this}auth(e){return this.singleShot(`auth`),this.config.auth=e,this}flowSurface(e,t){if(this.singleShot(`flowSurface`),typeof e!=`string`||e.length===0)throw Error(`controller "${this.config.namespace}": .flowSurface(flow) takes a non-empty flow name (the Sardine flow this surface reports as).`);return this.config.flowSurface={flow:e,...t?{customer:t}:{}},this}demo(e){return this.singleShot(`demo`),this.config.demo=On(e),this}on(e){return e(new Kr(this.config)),Wr(this.config),Gr(this.config),Hr(this.config),Ur(this.config),this.makeDef(this.config)}};function Hr(e){for(let[t,n]of Object.entries(e.children))if(n.required){if(n.el.__config.internal)throw Error(`controller "${e.namespace}" child "${t}": .required() needs a consumer-mountable element, but "${n.el.__config.name}" is .internal() — nothing a consumer mounts could ever satisfy the gate; drop one of the two.`);if(!n.el.__config.inline)throw Error(`controller "${e.namespace}" child "${t}": .required() needs an INLINE-mountable element, but "${n.el.__config.name}" is modal-only — a required co-mount must be able to stay mounted, and an overlay cannot; declare .modal(fn) without { inline: false }, or drop .required().`)}}function Ur(e){for(let t of Object.keys(e.resources??{})){let n=e.actions[t];if(n!==void 0&&n.kind===`static`)throw Error(`controller "${e.namespace}": "${t}" is declared as BOTH a resource and an a.static action — both install onto the namespace object (whop.${e.namespace}.${t}), so one would silently shadow the other; rename one.`);if(n!==void 0)throw Error(`controller "${e.namespace}": "${t}" is declared as BOTH a resource and an action — one consumer-facing name per surface member; rename one.`)}}function Wr(e){for(let[t,n]of Object.entries(e.children)){let r=n.anchored;if(!r)continue;let i=`controller "${e.namespace}" child "${t}"`;if(!n.el.__config.internal)throw Error(`${i}: .anchored(...) requires an .internal() element in v1 — the anchored frame has no consumer surface; mark "${n.el.__config.name}" .internal().`);if(n.el.__config.modalChrome)throw Error(`${i}: .anchored(...) cannot combine with a \`.modal()\` element — an internal child carries ONE ctx.open presentation; drop one of the two.`);if(r.opener===t)throw Error(`${i}: .anchored("${t}", …) anchors the child to ITSELF — name a sibling element child as the opener.`);let a=e.children[r.opener];if(!a){let n=Object.keys(e.children).filter(e=>e!==t);throw Error(`${i}: .anchored("${r.opener}", …) — "${r.opener}" is not a declared element child of "${e.namespace}"${Object.hasOwn(e.subControllers,r.opener)?` (it is a sub-controller — openers must be element children)`:``}; declared element children: ${n.length?n.join(`, `):`(none)`}.`)}if(a.many)throw Error(`${i}: opener "${r.opener}" is a .many() collection — an anchored frame binds ONE opener mount; use a singleton child.`);if(a.anchored)throw Error(`${i}: opener "${r.opener}" is itself anchored — anchored frames don't chain in v1; anchor both to the same consumer-mounted opener instead.`);if(a.el.__config.internal)throw Error(`${i}: opener "${r.opener}" is .internal() — the opener must be a consumer-mountable element (the anchored frame prewarms beside the consumer's mount).`);if(!a.el.__config.anchors.includes(r.anchor)){let e=a.el.__config.anchors;throw Error(`${i}: .anchored("${r.opener}", "${r.anchor}") — element "${a.el.__config.name}" declares no anchor "${r.anchor}"${e.length?` (declared: ${e.join(`, `)})`:` (it declares no .anchors() at all)`}; declare it via Element("${a.el.__config.name}").anchors("${r.anchor}").`)}}}function Gr(e){for(let[t,n]of Object.entries(e.reactions)){if(Object.hasOwn(n,V.dism
4issed)&&!e.children[t]?.anchored)throw Error(`on.controller("${t}", childEvents.dismissed): "${t}" is not an ANCHORED child of controller "${e.namespace}" — dismissal exists only for .anchored(...) children (modal/inline opens close through their own chrome/teardown).`);if(Object.hasOwn(n,V.destroyed)&&!e.children[t])throw Error(`on.controller("${t}", childEvents.destroyed): "${t}" is not a declared ELEMENT child of controller "${e.namespace}" — the implicit destroyed event covers element children only; a sub-controller's lifecycle is consumed through the sub's own events.`)}}var Kr=class{config;constructor(e){this.config=e}resolveChildKey(e,t,n){if(n===`host`){let n=typeof e==`string`?Object.hasOwn(this.config.subControllers,e)?[e]:[]:Object.entries(this.config.subControllers).filter(([,t])=>t.controller===e).map(([e])=>e);if(n.length)throw Error(`${t}: "${n.join(`, `)}" is a sub-controller — on.host() reactions never dispatch for sub events; consume them with on.controller(…) (either audience) or, for external events, the sub handle's own onX callbacks. on.host() targets element children's EXTERNAL or HOST-INTERNAL events only.`)}if(typeof e==`string`)return e;let r=[...Object.entries(this.config.children).filter(([,t])=>t.el===e).map(([e])=>e),...n===`controller`?Object.entries(this.config.subControllers).filter(([,t])=>t.controller===e).map(([e])=>e):[]];if(r.length===1)return r[0];let i=e,a=typeof i?.elementName==`string`?`element def "${i.elementName}"`:typeof i?.namespace==`string`?`controller def "${i.namespace}"`:`the given ${typeof e} value`;throw r.length===0?Error(`${t}: ${a} is not a declared child of controller "${this.config.namespace}" — declare it in .children() first, or pass the declared child key.`):Error(`${t}: ${a} is declared under ${r.length} keys (${r.join(`, `)}) — def-style registration is ambiguous; pass the specific child key.`)}controller(e,t,n){(this.config.reactions[this.resolveChildKey(e,`on.controller(…, ${qr(t)})`,`controller`)]??={})[t]=n}host(e,t,n){if(typeof t==`symbol`)throw Error(`on.host(…, ${qr(t)}): the implicit child events are controller-frame surface — the HOST already owns the destroy/dismiss edges (it initiates them), so a host reaction would be circular; consume ${qr(t)} with on.controller(…).`);(this.config.hostReactions[this.resolveChildKey(e,`on.host(…, "${t}")`,`host`)]??={})[t]=n}};function qr(e){return typeof e==`string`?`"${e}"`:e===V.destroyed?`childEvents.destroyed`:e===V.dismissed?`childEvents.dismissed`:String(e)}function Jr(e,t){if(G(e,`namespace`),lr.has(e))throw Error(`namespace ${JSON.stringify(e)} collides with the hosted static tree's top-level "${e}/" shared-asset dir (chunks/ and css/ sit beside the namespace dirs); pick a different namespace name.`);return new Vr({namespace:e,description:``,handleLifecycle:hr,stateInit:()=>({}),hostStateInit:()=>({}),propDefaults:{},propDocs:{},propSources:{},publicStateKeys:[],events:{},eventDocs:{},eventAnalytics:{},propAnalytics:[],childOrder:[],children:{},subControllers:{},resources:{},actions:{},reactions:{},hostReactions:{}},t)}var Yr=class{host;points=new Map;ordinal=0;constructor(e){this.host=e}declares(e){return e in this.host.contributions}register(e,t,n,r){if(!this.declares(e)){let t=Object.keys(this.host.contributions);throw Error(`element "${this.host.name}" declares no contribution point "${e}" — `+(t.length?`declared points: ${t.join(`, `)}.`:`declare it via .contributes((c) => ({ ${e}: c.required<...>().doc(...) })).`))}let i=this.points.get(e);i||(i=new Set,this.points.set(e,i));let a={provider:t,active:n,label:r||`provider #${++this.ordinal}`};return i.add(a),{setActive:e=>{a.active=e},unregister:()=>{i.delete(a)}}}invoke(e,t){let n=[...this.points.get(e)??[]].filter(e=>e.active);if(n.length>1)throw Error(`contribution "${e}" on this "${this.host.name}" instance has ${n.length} ACTIVE providers (${n.map(e=>e.label).join(`, `)}) — exactly one may be active at a time; drive the \`active\` flag from your selection state so switching tiles switches the provider.`);let r=n[0];if(!r){if(!this.host.contributions[e]?.required)return Promise.resolve(void 0);let t=this.points.get(e)?.size??0;throw Error(`contribution "${e}" on this "${this.host.name}" instance has no ACTIVE provider — `+(t?`${t} provider(s) are mounted but none is active;
4 flip one's \`active\` flag before invoking.`:`nothing is registered; mount a component that calls useContribution(...) first.`))}return Promise.resolve(r.provider(...t))}},Xr=(0,x.createContext)(null);function Zr(e){let t={};for(let n of Object.keys(e.host.contributions))t[n]=(...t)=>e.invoke(n,t);return t}function Qr(e,t,n,r=!0){let i=(0,x.useContext)(Xr),a=String(e.elementName??`def`);if(!i)throw Error(`useContribution(${a}, "${t}") must be called inside an element's render tree — no element instance is mounted above this component.`);if(e.__config!==i.host)throw a===i.host.name?Error(`useContribution(${a}, "${t}"): this def is a DIFFERENT element that happens to be named "${i.host.name}" (element names are only namespace-scoped) — pass the enclosing element's OWN def; the guard is an identity match, the useController(Def) precedent.`):Error(`useContribution(${a}, "${t}"): this component is mounted inside element "${i.host.name}" — pass the ENCLOSING element's def (contribution points are element-contained; a foreign def's points don't exist here).`);if(!i.declares(t)){let e=Object.keys(i.host.contributions);throw Error(`useContribution(${a}, "${t}"): the enclosing element "${i.host.name}" declares no such point`+(e.length?` — declared points: ${e.join(`, `)}.`:` — it declares no contributions at all; add .contributes((c) => ({ ${t}: c.required<...>().doc(...) })) to its builder chain.`))}let o=(0,x.useRef)(n);o.current=n;let s=(0,x.useRef)(r);s.current=r;let c=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=o.current.name||void 0,n=i.register(t,(...e)=>o.current(...e),s.current,e);return c.current=n,()=>{c.current=null,n.unregister()}},[i,t]),(0,x.useEffect)(()=>{c.current?.setActive(r)},[r])}function $r(e){return new Proxy({},{get:(t,n)=>typeof n==`string`?e()[n]:void 0,has:(t,n)=>typeof n==`string`&&n in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=Object.getOwnPropertyDescriptor(e(),n);return r?{...r,configurable:!0}:void 0}})}function ei(e,t){let n=e.hostStateInit($r(t),Pn),r={},i=[];for(let[e,t]of Object.entries(n)){let n=Fn(t);n?i.push({into:e,descriptor:n}):r[e]=t}return{seed:r,sources:i,wiredKeys:i.map(e=>e.into)}}function ti(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function ni(e){try{return ei(e,()=>({})).seed}catch{return{}}}function ri(e){return Object.keys(e.propSources).filter(t=>e.propSources[t]===`hostOnly`)}function ii(e,t){let n=ri(e);if(n.length===0)return t;let r={...t};for(let e of n)delete r[e];return r}var ai=`https://api.whop.com`,oi=`Whop-Private-Schema`,si={production:`https://api.whop.com`,sandbox:`https://sandbox-api.whop.com`};function ci(e){let t=e.environment;if(t===void 0||t===`production`)return si.production;if(t===`sandbox`)return si.sandbox;throw Error(`unknown environment ${JSON.stringify(t)} — expected "production" or "sandbox"`)}function li(e){typeof e!=`string`||!e||(ai=e.replace(/\/+$/,``).replace(/\/api\/v1$/,``))}function ui(){return ai}function di(e){li(e.apiBaseUrl??ci(e))}var fi=`x-whop-elements-origin`,pi;function mi(){return pi?{[fi]:pi}:{}}var hi=`x-whop-anonymous-id`,gi=/^[A-Za-z0-9-]{1,128}$/,_i=/^wuid_[A-Za-z0-9_-]{1,128}$/;function vi(e,t){return typeof e==`string`&&t.test(e)?e:void 0}var yi=()=>void 0;function bi(){let e=yi(),t=vi(e?.anonymousId,gi);if(!t)return{};let n=vi(e?.wuid,_i);return{[hi]:n?`${t},${n}`:t}}var xi=`public`;function Si(e){return e?{token:e}:{auth:!1}}function Ci(e){let t=e;return t?.status??t?.statusCode}function wi(e,t){let n=Ci(t);return n===401||n===403?!1:e<2}function J(e){let t=e?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):void 0;return new f({baseUrl:Di(),token:xi,...t,headers:Ti(t?.headers)})}function Ti(e){return{[oi]:`true`,...mi(),...y(),...bi(),...e}}var Ei=`/api/v1`;function Di(){return`${ui()}${Ei}`}function Oi(e,t){return ki(e,t)}function ki(e,...t){let n={...e.propDefaults};for(let e of t)for(let[t,r]of Object.entries(e))ur.has(t)||!j(t)&&r!==void 0&&(n[t]=r);return n}function Ai(e,t,...n){let r=e.loadingProps??[],i=e.loadingParentProps??[];if(r.length===0&&i.length===0)return;let a=ki(e,...n),o={};for(let e of r)o[e]=a[e];for(let e of i)o[e]=t?.[e];return o}function ji(e,t){let n=Oi(e,t),r={};for(let[t,i]of Object.entries(e.propSources))(i==="default"||i===`required`)&&(r[t]=n[t]);return r}function Mi(e,t){let n=null;for(let[r,i]of Object.entries(e.propSources))i!==`controller`||!(r in t)||(n??={...t},delete n[r]);return n??t}function Ni(e,t,n){let r=null;for(let[i,a]of Object.entries(e.propSources))!n.includes(a)||!(i in t)||(r??={...t},delete r[i]);return r??t}function Pi(e){let t=e.slotOf(e.key);if(t===void 0)return;let n=e.claimantKeys().filter(n=>e.slotOf(n)===t),r=n.find(t=>t!==e.key&&e.occupied(t));if(r)throw Error(`slot "${t}" is exclusive: "${r}" is mounted — mount exactly one of ${n.join(` | `)}.`)}function Fi(e,t){let n={};for(let r of e)Object.assign(n,r(t));return n}function Ii(e,t,n){let r=e[ce(t)];typeof r==`function`&&r(n)}function Li(e,t,n,r,i,a){let o=()=>Promise.resolve(e(t(),n,r));Promise.resolve().then(()=>a?a(o):o()).catch(e=>{console.error(`[whop elements] reaction failed`,e),i?.(e)})}var Ri=3e4,zi=3e4;function Bi(e){return Object.entries(e.children??{}).filter(([,e])=>e.required===!0).map(([e])=>e)}function Vi(e,t,n){let r=n.every(t=>typeof t==`string`||t.namespace===e)?`${n.map(e=>`"${typeof e==`string`?e:e.key}"`).join(`, `)} of controller "${e}"`:n.map(t=>typeof t==`string`?`"${t}" of controller "${e}"`:`"${t.key}" of controller "${t.namespace}"`).join(`, `);return Object.assign(Error(`element "${t}" was never revealed: required element(s) ${r} did not mount within ${zi}ms — mount them alongside it (a controller with a .required() child reveals its other elements only once every required child is mounted).`),{code:`REQUIRED_CHILD_MISSING`})}var Hi=class{waiters=new Set;settle=(e,t)=>
4{for(let n of this.waiters)n.key===e&&(n.instance===void 0||n.instance===t)&&n.woke()};abandon(e){for(let t of this.waiters)t.failed(typeof e==`string`?Error(e):e)}wait(e,t,n){return new Promise((r,i)=>{let a,o=e=>{clearTimeout(a),this.waiters.delete(s),e()},s={key:e,instance:t,woke:()=>o(()=>r(`settled`)),failed:e=>o(()=>i(e))};a=setTimeout(()=>o(()=>r(`expired`)),n),this.waiters.add(s)})}};function Ui(e,t){return t===void 0?`No mounted element "${e}"`:`No mounted element "${e}" instance "${t}"`}function Wi(e,t,n){if(n!==void 0)return e?.has(n)?{id:n}:{message:Ui(t,n)};let r=[...e?.keys()??[]];if(r.length===0)return{message:Ui(t)};if(r.length>1)throw Error(`Ambiguous element "${t}": ${r.length} live instances (${r.join(`, `)}) — target a single instance.`);return{id:r[0]}}async function Gi(e,t,n,r,i,a){let o=Date.now()+Ri;for(;;){let s=Wi(e(),t,n);if(s.id!==void 0)return s.id;if(!i(n))throw Y(s.message,r(n)?`CHILD_DESTROYED`:`CHILD_NOT_CREATED`);if(await a.wait(t,n,Math.max(0,o-Date.now()))===`expired`)throw Error(`${s.message} — it was still booting after ${Ri}ms (its register never arrived)`)}}function Y(e,t){return Object.assign(Error(e),{code:t})}function Ki(e,t){let n=t.getSdkOverride?.();if(n)return n;let r=e.auth;return J(typeof r==`function`?r({hostState:t.getWiredSlice?.()??{},props:t.getProps()}):r?.controller?.({state:t.getState(),props:t.getProps()}))}function qi(e,t){let n=e.auth;return J(typeof n==`function`?n({hostState:t.getWiredSlice?.()??{},props:ii(e,t.getProps())}):n?.host?.({state:t.getState(),props:t.getProps()}))}function Ji(e,t,n){if(!n)throw Error(`ctx.children.${e}.${t} is the page's liveness axis — read it in an a.host action or an on.host reaction, on the singleton or .many() collection handle; controller-frame and per-instance handles never carry it.`);return n[t](e)}function Yi(e,t,n,r){return new Proxy({},{get:(i,a)=>{if(!(typeof a!=`string`||a===`then`))return a===`state`?{get:()=>t.getState(e,n)}:a===`created`?t.created(e,n):a===`attached`||a===`visible`?Ji(e,a,r):r=>t.invoke(e,a,r,n)}})}function Xi(e,t,n,r){let i={};for(let[n,a]of Object.entries(e.children))i[n]=a.many?{ids:()=>t.ids(n),get:e=>Yi(n,t,e),get created(){return t.created(n)},get attached(){return Ji(n,`attached`,r)},get visible(){return Ji(n,`visible`,r)}}:Yi(n,t,void 0,r);for(let t of Object.keys(e.subControllers))i[t]=Yi(t,{ids:()=>[],created:e=>n?.created(e)??!1,invoke:async(e,t,r)=>{if(!n)throw Y(`No mounted sub-controller "${e}"`,`CHILD_NOT_CREATED`);return n.invoke(e,t,r)},getState:async e=>{if(!n)throw Y(`No mounted sub-controller "${e}"`,`CHILD_NOT_CREATED`);return n.getState(e)}});return i}function Zi(e,t,n){return r=>{let i=[...Object.entries(e.children).filter(([,e])=>e.slot===r),...Object.entries(e.subControllers).filter(([,e])=>e.slot===r)].map(([e])=>e);if(i.length===0){let t=new Set([...Object.values(e.children),...Object.values(e.subControllers)].map(e=>e.slot).filter(e=>e!==void 0));throw Error(`slotOccupant("${r}"): no declared child of controller "${e.namespace}" claims slot "${r}" — ${t.size?`declared slots: ${[...t].map(e=>`"${e}"`).join(`, `)}.`:`this controller declares no slots.`}`)}return i.find(r=>Object.hasOwn(e.subControllers,r)?n?.created(r)??!1:t.created(r))??null}}function Qi(e,t){if(Object.hasOwn(e.subControllers,t))throw Error(`ctx.open("${t}"): "${t}" is a sub-controller of "${e.namespace}" — ctx.open mounts ELEMENTS on demand; a sub-controller is composed by the consumer (or a composite), never opened.`);if(!Object.hasOwn(e.children,t))throw Error(`ctx.open("${t}"): not a declared child of controller "${e.namespace}"`)}function $i(e){return e===void 0||typeof e==`object`&&!!e}function ea(e){return e===null?`null`:typeof e}var ta=async()=>{throw Error(`ctx.open is not wired in this runtime`)};function na(e,t){return n=>{if(!Object.hasOwn(e.children,n))throw Error(`ctx.close("${n}"): not a declared child of controller "${e.namespace}"`);if(!e.children[n].anchored)throw Error(`ctx.close("${n}"): only ANCHORED children close through ctx.close — "${n}" declares no .anchored(...); a modal/inline open closes through its own chrome/teardown.`);
4if(!t)throw Error(`ctx.close is not wired in this runtime`);t(n)}}function ra(e,t){return t?async(n,r)=>{if(Qi(e,n),!$i(r))throw Error(`ctx.open("${n}"): input must be an object carrying the child's fromOpen props — got ${ea(r)}`);return t(n,r)}:ta}function ia(e,t){let n=ra(e,t);return async(e,t)=>{await n(e,t)}}function aa(e,t){let n=ra(e,t);return async(t,r)=>{let i=await n(t,r);if(!i)throw Error(`ctx.open("${t}") resolved no opened-child control — this runtime's open wiring predates the static open handle (framework bug)`);let a={};for(let n of Object.keys(e.children[t].el.__config.actions))a[n]=e=>i.call(n,e);return{closed:i.closed,close:()=>i.close(),actions:a}}}function oa(e,t,n,r,i,a,o,s,c){return{props:t.getProps(),state:t.getState(),setState:e=>t.setState(e),children:Xi(e,n,a),slotOccupant:Zi(e,n,a),open:ia(e,i),close:na(e,c),sdk:Ki(e,t),emit:(t,n)=>{e.events[t]===`external`?r(t,n):e.events[t]===`internal`&&o?.(t,n)},actions:sa(e,s)}}function sa(e,t){let n={};for(let[r,i]of Object.entries(e.actions))i.kind===`internal`&&(n[r]=e=>t?t(r,e):Promise.reject(Error(`internal action "${r}": the controller frame is not reachable from this runtime`)));return n}function ca(e,t){let n={};for(let r of e.publicStateKeys)r in t&&(n[r]=t[r]);return W(`controller "${e.namespace}" public state`,n)}function la(e,t,n,r,i){return{props:t.getProps(),hostState:t.getState(),sdk:qi(e,t),open:ia(e,n),close:na(e,i),actions:sa(e,r.invokeInternal),children:ua(e,r.childCreated,r.childAttached,r.childVisible),controllerState:()=>{if(e.publicStateKeys.length===0)throw Error(`controller "${e.namespace}" declares no .publicState(...) keys — declare the readable state slice on the controller before reading ctx.controllerState().`);if(!r.controllerState)throw Error(`controller "${e.namespace}" public state is not reachable from this runtime`);return r.controllerState()}}}function ua(e,t,n,r){let i={},a=(t,n)=>{throw Error(`controller "${e.namespace}" child liveness is not reachable from this runtime — ctx.children.${t}.${n} reads the page's mount registry, which this dispatch path does not carry.`)};for(let o of Object.keys(e.children))i[o]={get created(){return t?t(o):a(o,`created`)},get attached(){return n?n(o):a(o,`attached`)},get visible(){return r?r(o):a(o,`visible`)}};return i}function da(e,t,n,r){return{open:aa(e,n),close:na(e,r),sdk:qi(e,t)}}function fa(e,t,n,r,i,a){return{state:t.getState(),set:e=>t.set(e),props:t.getProps(),sdk:qi(e,t),children:Xi(e,i,void 0,a),emit:(t,i)=>{e.events[t]===`external`?n(t,i):e.events[t]===`internal`&&r?.(t,i)}}}var pa=30,ma=[];function X(e,t,n){ma.push({ts:Date.now(),category:e,message:t,...n?{data:n}:{}}),ma.length>pa&&(ma=ma.slice(-30))}function ha(){return ma}var ga=null;function _a(){return ga}function va(e){if(`instanceId`in e)throw Error('the "instanceId" option was removed — instance ids are always framework-minted. Keep the returned handle (vanilla) or the JSX element (react) to address a mount; authors read instance identity via reaction `instance.id` and `ctx.children.<key>.ids()`.')}function ya(e,t){return`${e}#${t}`}function ba(e,t){return`${e}#${t}`}var xa=(0,x.createContext)(null);function Sa({value:e,children:t}){return(0,x.createElement)(xa.Provider,{value:e},t)}function Ca(){let e=(0,x.useContext)(xa);if(!e)throw Error(`useElement() must be called inside an element's render (within <ElementCtxProvider>)`);return e}var wa=(0,x.createContext)(null);function Ta(e,t,n){let a=t?{extra:t}:void 0,o={..._a(),...n},s=ha();if(s.length===0&&Object.keys(o).length===0){i(e,a);return}r(t=>{o.namespace&&t.setTag(`elements.namespace`,o.namespace),o.element&&t.setTag(`elements.name`,o.element),o.mode&&t.setTag(`elements.mode`,o.mode),o.frame&&t.setTag(`elements.frame`,o.frame),o.phase&&t.setTag(`elements.phase`,o.phase),o.surface&&t.setTag(`elements.surface`,o.surface),(o.renderId||o.controllerId||o.hostOrigin)&&t.setContext(`elements`,{...o.renderId?{render_id:o.renderId}:{},...o.controllerId?{controller_id:o.controllerId}:{},...o.hostOrigin?{host_origin:o.hostOrigin}:{}});for(let e of s)t.addBreadcrumb({category:e.category,message:e.message,timestamp:e.ts/1e3,...e.data?{data:e.data}:{}});i(e,a)})}var Ea=class extends x.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){Ta(e,void 0,this.props.enrich),this.props.onError(e)}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}},Da=`1px solid var(--gray-a5)`,Oa={display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`var(--space-3)`,padding:`var(--space-3) var(--space-4)`,borderBottom:Da},ka={padding:`var(--space-4)`},Aa={display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:`var(--space-2)`,padding:`var(--space-3) var(--space-4)`,borderTop:Da},ja=`.whop-modal-close{position:absolute;top:var(--space-3);right:var(--space-4);display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;margin:0;border:0;border-radius:var(--radius-2,6px);background:transparent;color:var(--gray-a11,currentColor);cursor:pointer;transition:background 120ms ease}
4.whop-modal-close:hover{background:var(--gray-a3)}.whop-modal-close:focus-visible{outline:none;box-shadow:0 0 0 2px var(--color-focus-root,#3b82f6)}`,Ma={width:28,height:28,flex:`none`},Na=(0,x.createElement)(`svg`,{width:15,height:15,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":!0,focusable:!1},(0,x.createElement)(`path`,{d:`M3.75 3.75 L11.25 11.25 M11.25 3.75 L3.75 11.25`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`}));function Pa(e){let t=e.replace(/[-_]+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):`Dialog`}function Fa(e,t,n){let r=e.modalChrome(t),i=t.close,a=r.closeButton!==!1,o=r.bleed===!0;return(0,x.createElement)(`div`,{"data-element-modal":e.name,style:{position:`relative`}},a?(0,x.createElement)(`style`,null,ja):null,o?null:(0,x.createElement)(`div`,{"data-element-modal-header":``,style:Oa},(0,x.createElement)(`div`,{"data-element-modal-title":``},r.header??null),a?(0,x.createElement)(`span`,{"aria-hidden":!0,style:Ma}):null),(0,x.createElement)(`div`,{"data-element-modal-body":``,style:o?void 0:ka},n),r.footer==null?null:(0,x.createElement)(`div`,{"data-element-modal-footer":``,style:Aa},r.footer),a?(0,x.createElement)(`button`,{type:`button`,className:`whop-modal-close`,"aria-label":`Close`,onClick:()=>i?.()},Na):null)}var Z=(0,x.createContext)(null),Ia=(0,x.createContext)(!1),Q=(0,x.createContext)(null),La=(0,x.createContext)(null);function Ra(e){let t=(0,x.useContext)(Z);if(!t)throw Error(`useController(): no controller is mounted above this component — render it inside a <Controller> subtree (direct mode) or below the controller your composite element inlines (embed mode)`);let n=e?za(t,e):t.runtime,r=(0,x.useSyncExternalStore)(n.subscribe,n.getControllerState,n.getControllerState);return(0,x.useMemo)(()=>new Proxy({},{get:(e,t)=>{if(!(typeof t!=`string`||t===`then`))return t===`state`?r:e=>n.dispatch(t,e)}}),[n,r])}function za(e,t){let n=[];for(let r=e;r;r=r.parent){if(r.runtime.ownsDef(t))return r.runtime;n.push(r.runtime.namespace)}throw Error(`useController(${t.namespace}): no mounted <${t.namespace}> controller above this component — found: ${n.join(`, `)}`)}function Ba(e,t,n){let r=e instanceof Error?e:Error(String(e));if(r.sourceKey!==void 0&&r.code===n)return r;if(r.code!==void 0&&r.code!==n){let e=Error(r.message,{cause:r});return e.code=n,e.sourceKey=t,e}return r.code=n,r.sourceKey??=t,r}function Va(e,t){return{policy:e,gen:0,landed:!1,lastCadence:void 0,timer:void 0,inFlight:void 0,depsSeen:t,settleFirst:e.onFirstSettle}}function Ha(e){e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)}function Ua(e,t,n){t.signal.aborted||(e.timer=setTimeout(()=>void Wa(e,t),n))}async function Wa(e,t){let{policy:n}=e,r=e.gen;if(t.signal.aborted)return;e.inFlight?.abort();let i=new AbortController;e.inFlight=i;let a=()=>i.abort();t.signal.addEventListener(`abort`,a,{once:!0});try{let a=await n.run(i.signal);if(t.signal.aborted||i.signal.aborted||r!==e.gen)return;let o=n.interpret(a);e.landed=!0,t.set({[n.into]:o}),e.settleFirst?.(),e.settleFirst=void 0;try{e.lastCadence=n.cadence(a)}catch(r){t.report(r,n.into),e.lastCadence=void 0}e.lastCadence!==void 0&&Ua(e,t,e.lastCadence)}catch(a){if(t.signal.aborted||i.signal.aborted||r!==e.gen)return;if(!e.landed){n.reportFirstFailure&&t.report(a,n.into),e.settleFirst?.(a),e.settleFirst=void 0;return}t.report(a,n.into),n.retryOnLateFailure&&e.lastCadence!==void 0&&Ua(e,t,e.lastCadence)}finally{t.signal.removeEventListener(`abort`,a)}}function Ga(e,t,n){e.policy.deps.length===0||t.signal.aborted||Ka(e.policy.deps,n,e.depsSeen)&&(e.depsSeen=e.policy.deps.map(e=>n[e]),e.gen+=1,Ha(e),e.inFlight?.abort(),Wa(e,t))}function Ka(e,t,n){return!e.every((e,r)=>Object.is(t[e],n[r]))}function qa(e,t){let n=[],r=t.getProps();for(let i of e){let e=Va(i,i.deps.map(e=>r[e]));n.push(e),t.onCleanup(()=>{Ha(e),e.inFlight?.abort()}),Wa(e,t)}return{checkDeps:()=>{let e=t.getProps();for(let r of n)Ga(r,t,e)}}}var Ja=`CONTROLLER_SOURCE_FAILED`;function Ya(e,t){let n={},r=[];for(let[i,a]of Object.entries(t)){let t=Ln(a);if(!t){n[i]=a;continue}Xa(e,i,t),r.push({into:i,descriptor:t})}return{seed:n,sources:r}}function Xa(e,t,n){let r=`controller "${e.namespace}" state source "${t}"`;if(!Array.isArray(n.deps)||n.deps.length===0)throw Error(`${r}: deps are REQUIRED and must name at least one prop — a controller source re-runs ONLY when a declared prop changes (there is no cadence), so a deps-less source can never re-run. Pass the prop n
4ames it derives from, or seed a plain value instead.`);let i=Object.keys(e.propSources);if(i.length!==0)for(let t of n.deps){if(e.propSources[t]===`hostOnly`)throw Error(`${r}: dep "${t}" is an s.hostOnly<T>() prop — host-consumed props are never delivered to the controller frame, so this source could never observe it change. Derive from it on the host with .hostState((props, h) => …) instead.`);if(!Object.hasOwn(e.propSources,t))throw Error(`${r}: dep "${t}" is not a declared prop of this controller — deps name .props() keys (declared: ${i.join(`, `)||`none`}).`)}}function Za(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Qa(e,t){let n=!1,r={},i=()=>{let e=r;return r={},e},a=e=>{n?t.set(e):Object.assign(r,e)},o=(e,n)=>t.onError(Ba(e,n,Ja),n),s=[],c,l=(n,r)=>{let i=r(t.makeCtx(t.signal));if(Za(i))throw Error(`controller "${e.namespace}" state source "${n}": s.sync resolvers are SYNCHRONOUS and this one returned a Promise — use s.async(fn, deps) instead (its first resolve is awaited as part of the seed).`);return i},u=n=>{let{seed:r,sources:u}=Ya(e,n),d=t.getProps(),f=[];for(let e of u){let t=e.descriptor.fn;if(e.descriptor.__controllerSource===`async`){f.push(e);continue}try{r[e.into]=l(e.into,t)}catch(t){throw Ba(t,e.into,Ja)}s.push({into:e.into,fn:t,deps:e.descriptor.deps,seen:e.descriptor.deps.map(e=>d[e])})}if(f.length===0)return r;let p=[];return c=qa(f.map(e=>{let n={into:e.into,run:n=>Promise.resolve(e.descriptor.fn(t.makeCtx(n))),interpret:e=>e,cadence:()=>void 0,retryOnLateFailure:!1,reportFirstFailure:!1,deps:e.descriptor.deps};return p.push(new Promise((t,r)=>{n.onFirstSettle=n=>n===void 0?t():r(Ba(n,e.into,Ja))})),n}),{signal:t.signal,set:a,onCleanup:e=>t.signal.addEventListener(`abort`,e,{once:!0}),getProps:t.getProps,report:o}),Promise.all(p).then(()=>Object.assign(r,i()))},d=()=>{if(!n||t.signal.aborted)return;let e=t.getProps();for(let n of s)if(Ka(n.deps,e,n.seen)){n.seen=n.deps.map(t=>e[t]);try{t.set({[n.into]:l(n.into,n.fn)})}catch(e){o(e,n.into)}}c?.checkDeps()};return{seed:()=>{let n=e.stateInit(t.makeCtx(t.signal),In);return Za(n)?Promise.resolve(n).then(e=>u(e)):u(n)},arm:()=>{n=!0;let e=i();Object.keys(e).length>0&&t.set(e),d()},checkDeps:d}}var $a=`whop-nsure-sdk`;function eo(e){if(typeof window>`u`||window.__whopNsureInitialized||document.getElementById($a))return;let{sdkUrl:t,appId:n}=e,r=document.createElement(`script`),i=e=>{if(!(!window.nSureSDK||window.__whopNsureInitialized))try{window.nSureSDK.init({appId:n}),re(n,e||window.nSureSDK.getDeviceId()),window.__whopNsureInitialized=!0}catch{r.remove()}};window.nSureAsyncInit=i,r.id=$a,r.src=t,r.async=!0,r.onerror=()=>{r.remove(),window.nSureAsyncInit===i&&delete window.nSureAsyncInit},document.head.appendChild(r)}function to(e){try{eo(e)}catch{}}function no(e){typeof window>`u`||e!==`checkout`||ne(to)}var ro=class{onChange;loaded=!1;lastLoading=!0;mounted=new Set;ready=new Set;subscribers=new Set;constructor(e){this.onChange=e}markMounted(e){return this.mounted.add(e),this.recompute(),()=>{this.mounted.delete(e),this.ready.delete(e),this.recompute()}}setReady(e,t){t?this.ready.add(e):this.ready.delete(e),this.recompute()}sealIfEmpty(){this.loaded||this.mounted.size>0||(this.loaded=!0,this.recompute())}isLoading=()=>this.lastLoading;subscribe=e=>(this.subscribers.add(e),()=>{this.subscribers.delete(e)});recompute(){let e=!this.loaded&&(this.mounted.size===0||[...this.mounted].some(e=>!this.ready.has(e)));if(e||(this.loaded=!0),e!==this.lastLoading){this.lastLoading=e;for(let e of this.subscribers)e();this.onChange?.(e)}}},io=1e3,ao=`HOST_SOURCE_FAILED`;function oo(e,t){return W(`hostState source "${e}" data`,t?.data)}function so(e){let t=e?.refresh;return typeof t==`number`&&Number.isFinite(t)&&t>0?Math.max(io,t):void 0}function co(e,t){let n=t.onError??((e,t)=>console.error(`[whop elements] hostState source "${t}" failed`,e)),r=(e,t)=>n(Ba(e,t,ao),t),i=[],a=qa(e.map(e=>{let t={into:e.into,run:t=>Promise.resolve(e.descriptor.fn({signal:t})),interpret:t=>oo(e.into,t),cadence:so,retryOnLateFailure:!0,reportFirstFailure:!0,deps:e.descriptor.deps};return e.descriptor.__hostSource===`sync`&&i.push(new Promise((n,r)=>{t.onFirstSettle=t=>t===void 0?n():r(Ba(t,e.into,ao))})),t}),{signal:t.signal,set:t.set,onCleanup:t.onCleanup,getProps:t.getProps,report:r}),o=Promise.all(i).then(()=>void 0),s=i.length===0?`ok`:`pending`,c;return i.length>0&&o.then(()=>{s=`ok`},e=>{s=`failed`,c=e instanceof Error?e:Error(String(e))}),{gate:o,get gateState(){return s},get gateError(){return c},checkDeps:a.checkDeps}}function lo(e,t,n,r){let i=e.auth,a=J(typeof i==`function`?i({hostState:{},props:t}):i?.controller?.({state:{},props:t}));
4return{props:t,sdk:r?.sdk??a,signal:n}}function uo(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function fo(e,t,n,r){let i={phase:`pending`,error:void 0,settled:Promise.resolve()},a;try{a=e()}catch(e){return po(i,e,r)}return uo(a)?typeof window>`u`?(i.settled=new Promise(()=>{}),i):(i.settled=new Promise((e,o)=>{Promise.resolve(a).then(a=>{if(!t.aborted){n(a),i.phase=`ready`;try{r(null)}catch(e){Ta(e)}e()}},e=>{if(t.aborted)return;let n=e instanceof Error?e:Error(String(e));i.phase=`failed`,i.error=n;try{r(n)}catch(e){Ta(e)}o(n)})}),i.settled.catch(()=>{}),i):(n(a),i.phase=`ready`,r(null),i)}function po(e,t,n){let r=t instanceof Error?t:Error(String(t));return e.phase=`failed`,e.error=r,e.settled=Promise.reject(r),e.settled.catch(()=>{}),n(r),e}function mo(e,t){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.is(e[r],t[r]))return!1;return!0}var ho={},go=class{config;getConsumerProps;nest;capture=e=>Ta(e,void 0,{namespace:this.config.namespace,mode:`direct`});orchestratorState;hostState;listeners=new Set;elements=new Map;claims=new Map;defToKeys=new Map;instanceSeq=0;injectedCache=new Map;cleanups=new Set;abort=new AbortController;latch=new ro(e=>{let t=this.getConsumerProps().onLoadingChange;if(typeof t==`function`)try{t(e)}catch(e){this.capture(e),console.error(`[whop elements] onLoadingChange callback threw`,e)}});openImpl;closeImpl;onAnchorNode;opens=[];openSeq=0;subRuntimes=new Map;requiredChildren;seed;sources;seedReady=!1;hostSources;wiredKeys;hostPhase=`ready`;hostError;hostSourcesHandle;seedAbort=new AbortController;seedTeardown;sdkOverride;getSeedPhase=()=>this.seed.phase===`failed`||this.hostPhase===`failed`?`failed`:this.seed.phase===`pending`||this.hostPhase===`pending`?`pending`:`ready`;getSeedError=()=>this.seed.error??this.hostError;analytics;analyticsPrefix;otelAttributes;otelCreatedAt=Date.now();otelCauses=new wn;constructor(e,t,n,r){if(this.config=e,this.getConsumerProps=t,this.nest=r,this.analyticsPrefix=r?.analytics?.prefix??``,this.analytics=t().analytics===!1?Ze:r?.analytics?.scope??n?.analyticsScope??st({namespace:e.namespace}),e.flowSurface){let t=h()??p();t!==void 0&&(_(t),E({sessionKey:t,flow:e.flowSurface.flow}),n?.seed||no(e.flowSurface.flow))}this.otelAttributes=n?.otelAttributes??{namespace:e.namespace,mode:`direct`},this.orchestratorState={};let i=ei(e,()=>this.props());this.hostState=i.seed,this.hostSources=i.sources,this.wiredKeys=i.wiredKeys,i.sources.some(e=>e.descriptor.__hostSource===`sync`)&&(this.hostPhase=`pending`),this.requiredChildren=Bi(e),r?.subscribeParent&&this.cleanups.add(r.subscribeParent(()=>this.notify()));for(let[t,n]of Object.entries(e.children)){let e=n.el,r=this.defToKeys.get(e);r?r.push(t):this.defToKeys.set(e,[t])}this.sources=Qa(e,{signal:this.seedAbort.signal,set:e=>this.setOrchestratorState(e),getProps:()=>this.frameProps(),makeCtx:t=>lo(e,this.frameProps(),t,n?.seed),onError:(e,t)=>this.reportSourceFailure(e,t)}),this.seed=fo(()=>this.sources.seed(),this.seedAbort.signal,e=>{this.orchestratorState=e},t=>{if(t){this.capture(t),console.error(`[whop elements] controller "${e.namespace}" .state() seed failed — elements receive onError`,t),this.notify();return}this.seedReady=!0,this.sources.arm(),this.recomputeInjected(),this.notify(),this.syncFlowCustomer()}),this.openImpl=n?.createOpen?.(this)??this.openInternal,this.closeImpl=n?.createClose?.(this)??(e=>this.closeAnchored(e)),this.onAnchorNode=n?.createAnchorNode?.(this),this.sdkOverride=n?.seed?.sdk}startResolvers(){if(this.seedTeardown&&=(this.seedTeardown.cancelled=!0,void 0),this.hostSources.length){this.abort.abort(),this.abort=new AbortController;{let e=co(this.hostSources,{signal:this.abort.signal,set:e=>this.setHostState(e),onCleanup:e=>this.cleanups.add(e),getProps:()=>this.props()});this.hostSourcesHandle=e,this.hostSources.some(e=>e.descriptor.__hostSource===`sync`)&&(this.hostPhase=`pending`,this.hostError=void 0,this.notify()),e.gate.then(()=>{this.hostPhase=`ready`,this.notify()},e=>{let t=e instanceof Error?e:Error(String(e));this.capture(t),console.error(`[whop elements] controller "${this.config.namespace}" h.sync source failed — elements receive onError`,t),this.hostPhase=`failed`,this.hostError=t,this.notify()})}}}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.clear();for(let e of this.opens)this.closeOpen(e.id);let e={cancelled:!1};this.seedTeardown=e,queueMicrotask(()=>{e.cancelled||this.seedAbort.abort()})}openInternal=(e,t)=>(t=W(`ctx.open("${e}
4") input`,t),this.config.children[e]?.anchored?this.openAnchored(e,t):new Promise((n,r)=>{let i=++this.openSeq;this.opens=[...this.opens,{id:i,key:e,input:t,resolve:()=>n(this.openedControl(i,e,!1)),reject:r,anchored:!1,hidden:!1}],this.notify()}));getOpens=()=>this.opens;closeOpen(e,t){let n=this.opens.find(t=>t.id===e);n&&(n.reject(t??Error(`ctx.open("${n.key}"): the opened element was torn down before it became ready`)),this.anchoredReadyIds.delete(e),this.opens=this.opens.filter(e=>e!==n),this.settleConcluded(e),this.openMountInstances.delete(e),this.notify())}openConcludedWaiters=new Map;openMountInstances=new Map;noteOpenInstance(e,t){this.openMountInstances.set(e,t)}async invokeOpenedChild(e,t,n,r){return r=W(`element "${e}" action "${n}" input`,r),W(`element "${e}" action "${n}" result`,await(await this.registrationFor(e,t)).invoke(n,r))}openedControl(e,t,n){return{closed:this.concludedPromise(e),close:()=>n?this.closeAnchored(t):this.closeOpen(e),call:(n,r)=>this.invokeOpenedChild(t,this.openMountInstances.get(e),n,r)}}concludedPromise(e){let t=this.opens.find(t=>t.id===e);if(!t||t.hidden)return Promise.resolve();let n=this.openConcludedWaiters.get(e);return n||this.openConcludedWaiters.set(e,n=new Set),new Promise(e=>n.add(e))}settleConcluded(e){let t=this.openConcludedWaiters.get(e);if(t){this.openConcludedWaiters.delete(e);for(let e of t)e()}}anchoredReadyIds=new Set;anchoredWaiters=new Map;openAnchored(e,t){let n=this.opens.find(t=>t.key===e&&t.anchored);return n?(this.opens=this.opens.map(e=>e===n?{...e,input:t,hidden:!1}:e),this.notify(),this.anchoredReadyIds.has(n.id)?Promise.resolve(this.openedControl(n.id,e,!0)):new Promise((t,r)=>{let i=this.anchoredWaiters.get(n.id);i||this.anchoredWaiters.set(n.id,i=new Set),i.add({resolve:()=>t(this.openedControl(n.id,e,!0)),reject:r})})):new Promise((n,r)=>{let i=++this.openSeq,a=e=>{let t=this.anchoredWaiters.get(i);if(t){this.anchoredWaiters.delete(i);for(let n of t)e(n)}};this.opens=[...this.opens,{id:i,key:e,input:t,anchored:!0,hidden:!1,resolve:()=>{this.anchoredReadyIds.add(i),a(e=>e.resolve()),n(this.openedControl(i,e,!0))},reject:e=>{a(t=>t.reject(e)),r(e)}}],this.notify()})}closeAnchored(e){let t=this.opens.find(t=>t.key===e&&t.anchored);!t||t.hidden||(this.opens=this.opens.map(e=>e===t?{...e,hidden:!0}:e),this.notify(),this.anchoredReadyIds.has(t.id)||t.reject(Error(`ctx.open("${e}"): the anchored frame was hidden (closed or dismissed) before it finished opening`)),this.settleConcluded(t.id))}anchoredAnchorLost(e,t){if(this.anchoredReadyIds.has(e.id)){this.closeAnchored(e.key);return}this.closeOpen(e.id,t)}dismissAnchored(e){let t=this.opens.find(t=>t.key===e&&t.anchored);!t||t.hidden||(this.closeAnchored(e),this.dispatchDismissed(e))}dispatchDismissed(e){if(!this.seedReady)return;let t=this.config.reactions[e]?.[V.dismissed];t&&(X(`elements.reaction`,`${this.config.namespace}.${e}.dismissed`),this.dispatchTracedReaction(t,void 0,{id:e},{attributes:{child:e,event:`dismissed`}}))}anchorNodes=new Map;setAnchorNode(e,t,n){let r=this.anchorNodes.get(e);r||this.anchorNodes.set(e,r=new Map),n?r.set(t,n):r.delete(t),this.onAnchorNode?.(e,t,n),this.notify()}getAnchorNode(e,t){return this.anchorNodes.get(e)?.get(t)??null}props(){return ki(this.config,Mi(this.config,this.getConsumerProps()),this.nest?.getInjected()??{})}shellParentValues=()=>ji(this.config,this.getConsumerProps());frameProps(){return ii(this.config,this.props())}lastFramePropsViolations=null;wiredSlice(){return ti(this.hostState,this.wiredKeys)}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getInjected(e){return e?this.injectedCache.get(e)??ho:ho}getControllerState=()=>this.orchestratorState;recomputeInjected(){if(!this.seedReady)return!1;let e=[],t=!1;for(let[n,r]of Object.entries(this.config.subControllers)){let i=W(`projection into sub-controller "${n}"`,Fi(r.fromController,{state:this.orchestratorState,props:this.frameProps()})),a=this.injectedCache.get(n);(!a||!mo(a,i))&&(this.injectedCache.set(n,i),a?e.push(n):t=!0)}for(let[n,r]of Object.entries(this.config.children)){let i=W(`projection into element "${n}"`,{...Fi(r.fromHost,this.hostState),...Fi(r.fromController,{state:this.orchestratorState,props:this.frameProps()})}),a=this.injectedCache.get(n);(!a||!mo(a,i))&&(this.injectedCache.set(n,i),a?e.push(n):t=!0)}if(e.length===0)return t;let n=this.otelCauses.drain(`elements.commit`,this.otelAttributes);if(!n)return!0;for(let t of e)z(`elements.props.push`,{traceparent:n.traceparent,attributes:{...this.otelAttributes,key:t}}).end(),z(`elements.props.apply`,{traceparent:n.traceparent,attributes:{...this.otelAttributes,key:t}}).end();return n.end(),!0}notify(){for(let e of this.listeners)e()}setOrchestratorState(e,t){this.otelCauses.note(t),this.orchestratorState={...this.orchestratorState,...e},!this.recomputeInjected()&&this.seedReady&&this.otelCauses.clear(),this.notify(),this.syncFlowCustomer()}lastFlowCustomer;syncFlowCustomer(){if(!this.seedReady)return;let e=v(this.config.flowSurface,this.orchestratorState);if(e!==void 0){if(this.lastFlowCustomer===void 0&&e===null){this.lastFlowCustomer=null;return}e!==this.lastFlowCustomer&&(this.lastFlowCustomer=e,D(e??void 0))}}setHostState(e){this.hostState={...this.hostState,...e},this.recomputeInjected(),this.notify()}syncProps(){this.hostSourcesHandle?.checkDeps(),this.sources.checkDeps(),this.recomputeInjected(),this.notify()}reportSourceFailure(e,t){this.capture(e),console.error(`[whop elements] controller "${this.config.namespace}" state source "${t}" failed — keeping the last value`,e),Ii(this.getConsumerProps(),`error`,{message:e.message,...e.code===void 0?{}:{code:e.code},...e.sourceKey===void 0?{}:{sourceKey:e.sourceKey}})}get namespace(){return this.config.namespace}ownsDef(e){return e.__config===this.config}keysFor(e){return this.defToKeys.get(e)}keyForOwner(e,t){let n=this.defToKeys.get(e);if(t!==void 0){if(!n?.includes(t))throw Error(`childKey "${t}" does not bind element "${e.elementName}" — it is declared for ${n?`key(s) ${n.join(`, `)}`:`no child key`} of this controller.`);return t}if(n){if(n.length>1)throw Error(`Element "${e.elementName}" is bound to ${n.length} child keys (${n.join(`, `)}) — pass childKey="…" on the mount to pick the slot.`);return n[0]}}mintInstance(e){return ya(e,++this.instanceSeq)}subKeyFor(e){for(let[t,n]of Object.entries(this.config.subControllers))if(n.controller.__config===e.__config)return t}registerSubController(e,t){if(this.subRuntimes.has(e))throw Error(`Sub-controller "${e}" is already mounted — sub-controllers are singleton per handle.`);return this.assertSlotFree(e),this.subRuntimes.set(e,t),()=>{this.subRuntimes.get(e)===t&&(this.subRuntimes.delete(e),this.destroyedSubs.add(e))}}dispatchSubControllerEvent(e,t,n,r){n=W(`sub-controller "${e}" event "${t}"`,n);let i=this.config.reactions[e]?.[t];if(!i)return;X(`elements.reaction`,`${this.config.namespace}.${e}.${t}`);let a=Object.values(this.config.subControllers).length?this.config.subControllers[e]?.controller.__config:void 0;this.dispatchTracedReaction(i,n,{id:e},{traceparent:r,attributes:{child:e,event:t,...B(`payload`,n,a?.eventAnalytics?.[t])}})}dispatchTracedReaction(e,t,n,r){let i={};Li(e,()=>this.orchestratorCtx(i.span),t,n,this.capture,async e=>{let t=z(`elements.reaction`,{traceparent:r.traceparent,attributes:{...this.otelAttributes,...r.attributes}});i.span=t;try{let n=await t.run(e);return t.end(),n}catch(e){throw t.fail(e),t.end(),e}})}slotOf(e){return this.config.children[e]?.slot??this.config.subControllers[e]?.slot}
4assertSlotFree(e){Pi({key:e,slotOf:e=>this.slotOf(e),claimantKeys:()=>[...Object.keys(this.config.children),...Object.keys(this.config.subControllers)],occupied:e=>(this.elements.get(e)?.size??0)>0||(this.claims.get(e)?.size??0)>0||this.subRuntimes.has(e)})}registerElement(e,t,n){this.assertSlotFree(e);let r=this.elements.get(e);if(r||this.elements.set(e,r=new Map),r.has(t))throw Error(`Element "${e}" already has a live instance "${t}" — instance ids must be unique among live mounts.`);return r.set(t,n),this.bootWindow.settle(e,t),()=>{let r=this.elements.get(e);r?.get(t)===n&&(r.delete(t),this.destroyedInstances.add(t),r.size===0&&(this.elements.delete(e),this.destroyedKeys.add(e)),this.bootWindow.settle(e,t),this.dispatchDestroyed(e,t))}}dispatchDestroyed(e,t){let n=this.config.reactions[e]?.[V.destroyed];n&&(X(`elements.reaction`,`${this.config.namespace}.${e}.destroyed`),Li(n,()=>this.orchestratorCtx(),void 0,{id:t},this.capture))}bootWindow=new Hi;destroyedKeys=new Set;destroyedInstances=new Set;async registrationFor(e,t){let n=await Gi(()=>this.elements.get(e),e,t,t=>t===void 0?this.destroyedKeys.has(e):this.destroyedInstances.has(t),t=>t===void 0?(this.claims.get(e)?.size??0)>0:this.claims.get(e)?.has(t)??!1,this.bootWindow),r=this.elements.get(e)?.get(n);if(!r)throw Y(Ui(e,n),`CHILD_DESTROYED`);return r}isLoading=()=>this.latch.isLoading();subscribeLoading=e=>this.latch.subscribe(e);sealLoadingIfEmpty(){this.latch.sealIfEmpty()}markChildMounted(e,t){this.assertSlotFree(e);let n=this.claimChild(e,t),r=this.latch.markMounted(ba(e,t));return()=>{n(),r()}}claimChild(e,t){let n=this.claims.get(e);return n||this.claims.set(e,n=new Set),n.add(t),this.notify(),()=>{this.claims.get(e)?.delete(t),this.notify(),this.bootWindow.settle(e,t)}}setChildReady(e,t,n){this.latch.setReady(ba(e,t),n)}dispatchChildEvent(e,t,n,r,i){if(!e)return;r=W(`element "${e}" event "${n}"`,r);let a=this.config.reactions[e]?.[n],o=this.config.hostReactions[e]?.[n];if((a!==void 0||o!==void 0)&&X(`elements.reaction`,`${this.config.namespace}.${e}.${n}`),a){let o=this.config.children[e]?.el.__config;this.dispatchTracedReaction(a,r,{id:t},{traceparent:i,attributes:{child:e,instance:t,event:n,...B(`payload`,r,o?.eventAnalytics?.[n])}})}o&&Li(o,()=>this.hostReactionCtx(),r,{id:t},this.capture)}hostReactionCtx(){return fa(this.config,{getState:()=>this.hostState,set:e=>this.setHostState(e),getProps:()=>this.props(),getWiredSlice:()=>this.wiredSlice()},this.emitToConsumer,this.emitToParent,this.elementOps(),{attached:e=>this.elementCreated(e),visible:e=>this.elementCreated(e)})}subOps(e){return{created:e=>this.subRuntimes.has(e),invoke:async(t,n,r)=>this.subRegistrationFor(t).invoke(n,r,e?.traceparent),getState:async e=>W(`sub-controller "${e}" state read`,this.subRegistrationFor(e).getState())}}destroyedSubs=new Set;subRegistrationFor(e){let t=this.subRuntimes.get(e);if(!t)throw Y(`No mounted sub-controller "${e}"`,this.destroyedSubs.has(e)?`CHILD_DESTROYED`:`CHILD_NOT_CREATED`);return t}revealHeld=e=>this.config.children[e]?.required!==!0&&this.requiredChildren.some(e=>!this.elementCreated(e))||(this.nest?.parentRevealHeld?.()??!1);subtreeRevealHeld=()=>this.requiredChildren.some(e=>!this.elementCreated(e))||(this.nest?.parentRevealHeld?.()??!1);missingRequiredChildren=e=>[...this.config.children[e]?.required===!0?[]:this.requiredChildren.filter(e=>!this.elementCreated(e)).map(e=>({namespace:this.config.namespace,key:e})),...this.nest?.parentMissingRequired?.()??[]];subtreeMissingRequired=()=>[...this.requiredChildren.filter(e=>!this.elementCreated(e)).map(e=>({namespace:this.config.namespace,key:e})),...this.nest?.parentMissingRequired?.()??[]];elementCreated(e,t){return t===void 0?(this.elements.get(e)?.size??0)>0||(this.claims.get(e)?.size??0)>0:(this.elements.get(e)?.has(t)??!1)||(this.claims.get(e)?.has(t)??!1)}elementOps(e){return{ids:e=>[...this.elements.get(e)?.keys()??[]],created:(e,t)=>this.elementCreated(e,t),invoke:async(t,n,r,i)=>W(`element "${t}" action "${n}" result`,await(await this.registrationFor(t,i)).invoke(n,W(`element "${t}" action "${n}" input`,r),e?.traceparent)),getState:async(e,t)=>W(`element "${e}" state read`,await(await this.registrationFor(e,t)).getState())}}orchestratorCtx(e){return oa(this.config,{getState:()=>this.orchestratorState,setState:t=>this.setOrchestratorState(t,e?.traceparent),getProps:()=>this.frameProps(),getWiredSlice:()=>this.wiredSlice(),getSdkOverride:()=>this.sdkOverride},this.elementOps(e),(t,n)=>this.emitToConsumer(t,n,e?.traceparent),(t,n)=>e?.traceparent===void 0?this.openImpl(t,n):this.openImpl(t,n,e.traceparent),this.subOps(e),(t,n)=>this.emitToParent(t,n,e?.traceparent),(t,n)=>this.dispatchInternal(t,n,e?.traceparent),this.closeImpl)}emitToConsumer=(e,t,n)=>{t=W(`controller "${this.config.namespace}" event "${e}"`,t);let r=z(`elements.emit`,{traceparent:n,attributes:{...this.otelAttributes,event:e,audience:`external`,...B(`payload`,t,this.config.eventAnalytics?.[e])}});try{Ii(this.getConsumerProps(),e,t),this.nest?.emit(e,t,r.traceparent),r.end()}catch(e){throw r.fail(e),r.end(),e}this.analytics.track(`Elements Event Emitted`,{event:this.analyticsPrefix?`${this.analyticsPrefix}.${e}`:e,audience:`external`,payload_keys:F(t),payload:I(t,this.config.eventAnalytics?.[e])})};
4emitToParent=(e,t,n)=>{this.nest?.emit(e,t,n)};async dispatch(e,t,n){let r=this.config.actions[e];if(!r)throw Error(`Unknown action: ${e}`);if(r.kind===`internal`)throw Error(`Action "${e}" is internal — not part of the handle surface (reach it via a.host ctx.actions or intra-controller ctx.actions).`);if(r.kind===`static`)return await r.fn(da(this.config,{getState:()=>this.hostState,getProps:()=>this.props(),getWiredSlice:()=>this.wiredSlice()},this.openImpl,this.closeImpl),t);if(r.kind===`host`){let e=this.hostSourcesHandle;if(e?.gateState===`pending`)await e.gate;else if(e?.gateState===`failed`)throw e.gateError;return await r.fn(la(this.config,{getState:()=>this.hostState,getProps:()=>this.props(),getWiredSlice:()=>this.wiredSlice()},this.openImpl,{invokeInternal:(e,t)=>this.dispatchInternal(e,t),controllerState:()=>{if(!this.seedReady)throw Error(`controller "${this.config.namespace}" public state is not available yet — the pushed mirror arrives with the controller's first delivery (the .state() seed is pending/failed).`);return ca(this.config,this.orchestratorState)},childCreated:e=>this.elementCreated(e),childAttached:e=>this.elementCreated(e),childVisible:e=>this.elementCreated(e)},this.closeImpl),t)}return t=W(`controller "${this.config.namespace}" action "${e}" input`,t),await this.seed.settled,this.tracedDispatch(e,r,t,n,n=>this.trackDispatch(e,r,t,async()=>W(`controller "${this.config.namespace}" action "${e}" result`,await r.fn(this.orchestratorCtx(n),t))))}async tracedDispatch(e,t,n,r,i){let a=z(`elements.action`,{traceparent:r,attributes:{...this.otelAttributes,action:this.analyticsPrefix?`${this.analyticsPrefix}.${e}`:e,kind:t.kind,...B(`input`,n,t.analytics)}});try{let e=await a.run(()=>i(a));return a.end(),e}catch(e){throw a.fail(e),a.end(),e}}async trackDispatch(e,t,n,r){let i=Date.now(),a=r=>{X(`elements.action`,`${this.config.namespace}.${e}`,{ok:r,ms:Date.now()-i}),this.analytics.track(`Elements Action Called`,{action:this.analyticsPrefix?`${this.analyticsPrefix}.${e}`:e,kind:t.kind,ok:r,duration_ms:Date.now()-i,input_keys:F(n),input:I(n,t.analytics)})};try{let e=await r();return a(!0),e}catch(e){throw a(!1),e}}async dispatchInternal(e,t,n){let r=this.config.actions[e];if(!r||r.kind!==`internal`)throw Error(`"${e}" is not an internal action`);await this.seed.settled,t=W(`controller "${this.config.namespace}" action "${e}" input`,t);let i=z(`elements.action`,{traceparent:n,attributes:{...this.otelAttributes,action:this.analyticsPrefix?`${this.analyticsPrefix}.${e}`:e,kind:r.kind,...B(`input`,t,r.analytics)}});try{let n=await i.run(()=>this.trackDispatch(e,r,t,async()=>W(`controller "${this.config.namespace}" action "${e}" result`,await r.fn(this.orchestratorCtx(i),t))));return i.end(),n}catch(e){throw i.fail(e),i.end(),e}}},$=()=>()=>{},_o=Symbol.for(`whop.elements.loading`);function vo(e){return Object.freeze(Object.assign(e,{[_o]:!0}))}var yo=e=>typeof e==`function`&&e[_o]===!0;function bo(e,t){return vo(function(){if(!e.loading)throw Error(`Element "${e.name}" mounted ctx.Loading but declares no .loading() shell — declare .loading() to use ctx.Loading.`);return(0,x.createElement)(e.loading,t)})}function xo(e,t,n){let r=n(),i=(0,x.isValidElement)(r)&&yo(r.type)?r.props:void 0;if(!yo(r)&&i===void 0)return{node:r,isLoading:!1};if(!e.loading)throw Error(`Element "${e.name}" returned ctx.Loading but declares no .loading() shell — declare .loading() to use ctx.Loading.`);let a=i!==void 0&&i.children!=null;return i?.loading===!1?{node:i.children??null,isLoading:!1,latch:a}:{node:(0,x.createElement)(e.loading,t),isLoading:!0,hiddenChildren:i?.children??void 0,latch:a}}var So={position:`absolute`,top:0,left:0,width:`100%`,visibility:`hidden`,opacity:0,pointerEvents:`none`},Co={display:`contents`},wo={position:`relative`};function To(e,t,n,r=!1){let{node:i,isLoading:a,hiddenChildren:o,latch:s}=xo(e,t,n);r&&(a||(o=i),i=e.loading?(0,x.createElement)(e.loading,t):null,a=!0,s=!0),Eo(e.name,a&&!r);let c=(0,x.useRef)(!1);if(s&&(c.current=!0),!c.current)return{body:i,isLoading:a};let l=a,u=(0,x.createElement)(`div`,{style:l?So:Co,"aria-hidden":l?!0:void 0,ref:e=>{e&&(l?e.setAttribute(`inert`,``):e.removeAttribute(`inert`))}},l?o:i);return{body:(0,x.createElement)(`div`,{style:l?wo:Co},l?i:null,u),isLoading:a}}function Eo(e,t){(0,x.useEffect)(()=>{},[e,t])}function Do(e){try{if(e.top===e.self)return e.location.origin;let t=e.top?.location.origin;if(t)return t}catch{}return Oo(e)}function Oo(e){let t=e.location.ancestorOrigins,n=t&&t.length>0?t[t.length-1]:null;return n&&n!==`null`?n:null}l(se());var ko=(0,x.createContext)(null);function Ao(e,t,n){return J(e.auth?.embed?.({props:t,state:n}))}var jo={},Mo=[`controllerOrDirect`],No={host:``,top:null},Po=null;function Fo(){return typeof window>`u`?No:(Po??={host:window.location.origin,top:Do(window)},Po)}function Io(){return(0,x.useSyncExternalStore)($,Fo,()=>No)}function Lo(e){return jr(e,Bo)}function Ro(e,t,n,r,i){if(!e)return null;let a=i?i.chain:null,o=[],s=null;for(let n=e;n&&n!==a;n=n.parent){let e=n.runtime.keysFor(t);if(e){if(r===void 0||e.includes(r))return{runtime:n.runtime,key:n.runtime.keyForOwner(t,r)};s??=n.runtime}o.push(n.runtime.namespace)}if(s)return{runtime:s,key:s.keyForOwner(t,r)};if(o.length===0)return null;throw Error(`element "${n}" is not declared by any mounted controller above it (walked: ${o.join(`, `)}) — declare it as a child of one of them or move it outside their subtrees`+(i?` (the walk stopped at the body of element "${i.elementName}" — controllers outside a composer body never claim mounts inside it)`:``))}var zo=class{config;instance;live=new Map;bootWindow=new Hi;unmounted=!1;disconnectPending=!1;bootFailure;handle={};constructor(e,t,n){this.config=e,this.instance=t;for(let[t,r]of Object.entries(e.actions))r.kind===`public`||r.kind===`controllerOnly`&&n?this.handle[t]=e=>this.invoke(t,e):(r.kind===`controllerOnly`||r.kind===`hostInternal`)&&Object.defineProperty(this.handle,t,{enumerable:!1,value:()=>Promise.reject(Error(`Element "${e.name}" action "${t}" is not callable from the host`))})}
4mounted(){return this.arm(),()=>this.disconnect()}attach(e){return this.live.set(this.instance,e),this.arm(),this.bootWindow.settle(this.config.name,this.instance),()=>{this.live.get(this.instance)===e&&(this.live.delete(this.instance),this.disconnect())}}arm(){this.disconnectPending=!1,this.unmounted=!1,this.bootFailure=void 0}disconnect(){this.disconnectPending=!0,queueMicrotask(()=>{this.disconnectPending&&(this.disconnectPending=!1,this.unmounted=!0,this.bootWindow.settle(this.config.name,this.instance))})}bootFailed(e){this.unmounted||this.bootFailure||this.live.size>0||(this.bootFailure=e,this.bootWindow.abandon(this.refuseDeadBoot()))}refuseDeadBoot(){let e=Y(`${Ui(this.config.name,this.instance)} — its controller's boot failed`,`CHILD_DESTROYED`);return e.cause=this.bootFailure,e}async invoke(e,t){if(this.bootFailure)throw this.refuseDeadBoot();await Gi(()=>this.live,this.config.name,this.instance,()=>this.unmounted,()=>!this.unmounted,this.bootWindow);let n=this.live.get(this.instance);if(!n)throw Y(Ui(this.config.name,this.instance),`CHILD_DESTROYED`);return W(`element "${this.config.name}" action "${e}" result`,await n.invoke(e,W(`element "${this.config.name}" action "${e}" input`,t)))}};function Bo(e){let t=function(n){let r=(0,x.useContext)(Z),i=(0,x.useContext)(Ia),a=(0,x.useContext)(Q),o=typeof n.childKey==`string`?n.childKey:void 0,s=i?null:Ro(r,t,e.name,o,a),c=s?.runtime??null,l=s?.key;va(n);let u=(0,x.useRef)(null);!i&&u.current===null&&(u.current=c&&l?c.mintInstance(l):ya(e.name,0));let d=u.current,f=(0,x.useContext)(La);d!==null&&f?.note(d);let p=!i&&c!==null&&l!==void 0&&f===null,m=(0,x.useSyncExternalStore)(c?c.subscribe:$,()=>p?c.revealHeld(l):!1,()=>!1),h=(0,x.useRef)(!1);p&&!m&&(h.current=!0);let g=p&&m&&!h.current,[_,v]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(!g||_!==null)return;let e=setTimeout(()=>{v(Vi(c.namespace,l,c.missingRequiredChildren(l)))},zi);return()=>clearTimeout(e)},[g,_]);let y=(0,x.useRef)(null);i||(y.current??={v:Ai(e,e.loadingParentProps?.length?s?.runtime.shellParentValues():void 0,n)});let b=i?Ai(e,void 0,n):y.current.v,S=(0,x.useRef)(null);i||(S.current??=new zo(e,d,a!==null));let C=S.current;(0,x.useImperativeHandle)(n.ref,()=>C?C.handle:null,[C]),(0,x.useEffect)(()=>C?.mounted(),[C]),(0,x.useEffect)(()=>{if(!(!c||!l||d===null))return c.markChildMounted(l,d)},[c,l,d]);let w=()=>c?c.getSeedPhase():`ready`,T=(0,x.useSyncExternalStore)(c?c.subscribe:$,w,w),E=(0,x.useMemo)(()=>T===`failed`?c.getSeedError()??Error(`controller "${e.name}" .state() seed failed`):void 0,[T,c]);(0,x.useEffect)(()=>{E&&C?.bootFailed(E)},[C,E]);let D=(0,x.useMemo)(()=>({chain:r,elementName:e.name}),[r]),O=(0,x.useMemo)(()=>({...c?{namespace:c.namespace}:{},element:e.name,mode:`direct`}),[c]);return(0,x.createElement)(Q.Provider,{value:D},(0,x.createElement)(Ea,{enrich:O,onError:e=>{c&&l&&d!==null&&c.setChildReady(l,d,!0);let t=n.onError;if(typeof t!=`function`)return;let r=e;t({message:e.message,...r.code===void 0?{}:{code:r.code},...r.sourceKey===void 0?{}:{sourceKey:r.sourceKey}})},fallback:t=>e.error?e.error({error:t}):null,children:i?e.loading?(0,x.createElement)(e.loading,b):null:E?(0,x.createElement)(Vo,{error:E}):_?(0,x.createElement)(Vo,{error:_}):T===`pending`?e.loading?(0,x.createElement)(e.loading,b):null:(0,x.createElement)(x.Suspense,{fallback:e.loading?(0,x.createElement)(e.loading,b):null},(0,x.createElement)(Wo,{config:e,consumerProps:n,handle:c,handleKey:l,instance:d,shellProps:b,rail:C,enclosingBoundary:a,revealHeld:g}))}))};return Object.assign(t,{__config:e,elementName:e.name}),t}function Vo({error:e}){throw e}function Ho(e,t){return(0,x.isValidElement)(e)?(0,x.createElement)(Q.Provider,{value:t,key:e.key??void 0},e):Array.isArray(e)&&e.some(Uo)?e.map(e=>Ho(e,t)):e}function Uo(e){return(0,x.isValidElement)(e)||Array.isArray(e)&&e.some(Uo)}function Wo({config:e,consumerProps:t,handle:n,handleKey:r,instance:i,shellProps:a,rail:o,enclosingBoundary:s,revealHeld:c}){let l=()=>n?n.getInjected(r):jo,u=(0,x.useSyncExternalStore)(n?n.subscribe:$,l,l);(0,x.useRef)(null);let d=t;n&&(d=Ni(e,t,Mo)),(0,x.useRef)(null);let f=d,p=f;for(let[t,n]of Object.entries(e.propSources)){if(n!==`direct`||!(t in f))continue;let e=Ho(f[t],s);e!==f[t]&&(p===f&&(p={...f}),p[t]=e)}let m=ki(e,u,p),[h,g]=(0,x.useState)(()=>({...e.stateInit(m)})),_=(0,x.useRef)(h);_.current=h;let v=(0,x.useCallback)(e=>{g(t=>({...t,...e}))},[]),y=(0,x.useRef)({config:e,handle:n,key:r,instance:i,consumerProps:t});y.current={config:e,handle:n,key:r,instance:i,consumerProps:t};let S=(0,x.useRef)(null);if(S.current===null){let t=r??e.name,a=n?.analyticsPrefix?`${n.analyticsPrefix}.${t}`:t;S.current=(n?n.analytics:st({})).child({element:a,instance:i})}let C=S.current,w=(0,x.useRef)(null);w.current===null&&(w.current=I(m,e.propAnalytics));let T=(0,x.useRef)(!1),E=(0,x.useRef)(null);(0,x.useEffect)(()=>(E.current!==null&&(clearTimeout(E.current),E.current=null),T.current||(T.current=!0,C.track(`Elements Element Mounted`,{props:w.current??void 0})),()=>{E.current=setTimeout(()=>C.track(`Elements Element Unmounted`),0)}),[C]);let D=(0,x.useRef)(null);D.current===null&&(D.current=(e,t)=>
4{let n=y.current;t=W(`element "${n.config.name}" event "${e}"`,t);let r=n.config.events[e],i=z(`elements.emit`,{attributes:{...n.handle?.otelAttributes??{namespace:n.config.name,mode:`direct`},event:e,audience:r??`internal`,...B(`payload`,t,n.config.eventAnalytics?.[e])}});n.handle?.dispatchChildEvent(n.key,n.instance,e,t,i.traceparent),(r===`external`||r===`direct`)&&Ii(n.consumerProps,e,t),i.end(),C.track(`Elements Event Emitted`,{event:e,audience:r??`internal`,payload_keys:F(t),payload:I(t,n.config.eventAnalytics?.[e])})});let O=D.current,k=(0,x.useRef)(null);(k.current===null||k.current.host!==e)&&(k.current=new Yr(e));let A=k.current,ee=(0,x.useMemo)(()=>Zr(A),[A]),te={},ne={},re=Io(),ie=()=>({props:m,state:_.current,setState:v,sdk:Ao(e,m,_.current),origins:re,emit:O,contributions:ee});for(let[t,r]of Object.entries(e.actions)){let a=async(a,o)=>{let s=z(`elements.action`,{traceparent:o,attributes:{...n?.otelAttributes??{namespace:e.name,mode:`direct`},element:e.name,instance:i,action:t,kind:r.kind,...B(`input`,a,r.analytics)}}),c=Date.now(),l=e=>C.track(`Elements Action Called`,{action:t,kind:r.kind,ok:e,duration_ms:Date.now()-c,input_keys:F(a),input:I(a,r.analytics)});try{let e=await s.run(()=>r.fn(ie(),a));return l(!0),s.end(),e}catch(e){throw l(!1),s.fail(e),s.end(),e}};ne[t]=a,te[t]=e=>a(e)}let ae=(0,x.useRef)(ne);ae.current=ne,(0,x.useEffect)(()=>{let t={getState:()=>_.current,setState:v,invoke:async(t,n,r)=>{let i=ae.current[t];if(!i)throw Error(`Element "${e.name}" has no action "${t}"`);let a=Date.now();try{let o=await i(n,r);return X(`elements.rpc`,`${e.name}.${t}`,{ok:!0,ms:Date.now()-a}),o}catch(n){throw X(`elements.rpc`,`${e.name}.${t}`,{ok:!1,ms:Date.now()-a}),n}}},a=o.attach(t),s=n&&r?n.registerElement(r,i,t):void 0;return()=>{s?.(),a()}},[n,r,i,v,e.name,o]);let oe=(0,x.useContext)(ko),se=(0,x.useMemo)(()=>{let t={};for(let i of e.anchors)t[i]=n&&r?e=>n.setAnchorNode(r,i,e):()=>void 0;return t},[e,n,r]),j=(0,x.useMemo)(()=>bo(e,a),[e,a]),M={props:m,state:h,setState:v,actions:te,origins:re,emit:O,identify:C.identify,hasEventHandler:n=>e.events[n]===`external`&&typeof t[ce(n)]==`function`,anchors:se,Loading:j},le=e.auth?.embed?.({props:m,state:h}),ue=(0,x.useMemo)(()=>J(le),[JSON.stringify(le??null)]),de=(0,x.useContext)(wa)?.demoSdk??ue,fe=!!(oe&&e.modalChrome),pe=fe?{...M,close:oe.close}:M;return(0,x.createElement)(Xr.Provider,{value:A},(0,x.createElement)(Sa,{value:M},(0,x.createElement)(b,{client:de},(0,x.createElement)(Go,{config:e,shellProps:a,renderCtx:pe,isOverlay:fe,handle:n,handleKey:r,instance:i,revealHeld:c,onReady:typeof t.onReady==`function`?t.onReady:void 0}))))}function Go({config:e,shellProps:t,renderCtx:n,isOverlay:r,handle:i,handleKey:a,instance:o,revealHeld:s,onReady:c}){let{body:l,isLoading:u}=To(e,t,()=>e.render(n),s),d=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{u||d.current||(d.current=!0,c?.())},[u]),(0,x.useEffect)(()=>{if(!(!i||!a||u))return i.setChildReady(a,o,!0),()=>i.setChildReady(a,o,!1)},[i,a,o,u]),r?Fa(e,n,l):l}var Ko=e(n(),1),qo=`data-element-open`,Jo=`data-element-overlay`,Yo=`data-element-anchored`,Xo=(e,t)=>`${e}/${t}`,Zo=e=>`min(${e}px, 100vw)`;a();var Qo=(0,x.createContext)(e=>e),$o=null;function es(){return $o??=o(()=>import(`./index-BJYkNw1-.js`).then(t=>e(t.ml(),1)).then(e=>e,e=>{throw $o=null,e}),__vite__mapDeps([2,1,3,4,0,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,28
40,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374])),$o}var ts=null;function ns(){return ts??=o(()=>import(`./frosted-ui-IuunJNEA.js`).then(e=>e.D).then(e=>e.Dialog,e=>{throw ts=null,e}),__vite__mapDeps([0,1])),ts}function rs(e,t){let n=(0,x.useContext)(Z),r=(0,x.useRef)(void 0);r.current=t;let i=(0,x.useRef)(n);i.current=n;let a=(0,x.useContext)(Q),o=(0,x.useRef)(a);o.current=a;let s=(0,x.useContext)(Qo),c=(0,x.useRef)(s);c.current=s;let l=(0,x.useRef)(null),u=e,d=()=>{let e=l.current;e&&(e.wantOpen=!1,e.setOpen(!1))},f=()=>{let e=l.current;e&&(l.current=null,queueMicrotask(()=>{e.root?.unmount(),e.container.remove()}))};return(0,x.useEffect)(()=>()=>f(),[]),{open:()=>{if(l.current)return l.current.wantOpen=!0,l.current.setOpen(!0),Promise.resolve();let e=document.createElement(`div`);e.setAttribute(Jo,u.elementName),document.body.appendChild(e);let t={container:e,root:null,setOpen:()=>void 0,wantOpen:!0};l.current=t;let n=()=>{l.current=null,t.root?.unmount(),e.remove()};return Promise.all([ns(),es()]).then(([a,{createRoot:o}])=>{if(l.current!==t)return;if(!t.wantOpen){n();return}let s=o(e);t.root=s,s.render((0,x.createElement)(is,{Dialog:a,el:u,getProps:()=>r.current,getChain:()=>i.current,getProviders:()=>c.current,register:e=>{t.setOpen=e}}))},e=>{if(l.current!==t)return;n();let r=i.current?.runtime.namespace;throw Ta(e,void 0,{...r?{namespace:r}:{},element:u.elementName,mode:`direct`,frame:`modal`}),e})},close:d,destroy:f}}function is({Dialog:e,el:t,getProps:n,getChain:r,getBoundary:i,getProviders:a,register:o,onClose:s}){let[c,l]=(0,x.useState)(!0);o(l),(0,x.useEffect)(()=>{c||s?.()},[c,s]);let u=(0,x.createElement)(ko.Provider,{value:{close:()=>l(!1)}},(0,x.createElement)(t,n()??{})),d=r?.()??null,f=d?(0,x.createElement)(Z.Provider,{value:d},u):u,p=i?.()??null,m=p?(0,x.createElement)(Q.Provider,{value:p},f):f,h=a?.(),g=t.__config.modalMaxWidth;return(0,x.createElement)(e.Root,{open:c,onOpenChange:e=>l(e)},(0,x.createElement)(e.Content,{style:{padding:0,...g===void 0?{}:{maxWidth:Zo(g)}},"aria-label":Pa(t.elementName??``),...t.__config.modalAutoFocus===!1?{initialFocus:!1}:{}},h?h(m):m))}function as({runtime:e,config:t}){return(0,x.useSyncExternalStore)(e.subscribe,e.getOpens,e.getOpens).map(n=>(0,x.createElement)(n.anchored?us:ss,{key:n.id,runtime:e,config:t,entry:n}))}function os(e,t){return(0,x.useMemo)(()=>{let n=!1;return{note:r=>{n||(n=!0,e.noteOpenInstance(t,r))}}},[e,t])}function ss({runtime:e,config:t,entry:n}){let r=t.children[n.key];if(!r)throw Error(`ctx.open("${n.key}"): not a declared child of controller "${t.namespace}" — origination validation was bypassed`);let i=r.el,a=!!i.__config.modalChrome,[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=document.createElement(`div`);return e.setAttribute(qo,Xo(t.namespace,n.key)),document.body.appendChild(e),s(e),()=>e.remove()},[e,t,n]),(0,x.useEffect)(()=>{if(!a)return;let t=!0;return ns().then(e=>{t&&l(e)},r=>{t&&e.closeOpen(n.id,r instanceof Error?r:Error(String(r)))}),()=>{t=!1}},[a,e,n]);let u=(0,x.useMemo)(()=>({...n.input,childKey:n.key,onReady:()=>n.resolve(),onError:t=>e.closeOpen(n.id,Error(t.message))}),[e,n]),d=os(e,n.id);return o?a?c?(0,Ko.createPortal)((0,x.createElement)(La.Provider,{value:d},(0,x.createElement)(is,{Dialog:c,el:i,getProps:()=>u,register:()=>void 0,onClose:()=>e.closeOpen(n.id)})),o):null:(0,Ko.createPortal)((0,x.createElement)(La.Provider,{value:d},(0,x.createElement)(i,u)),o):null}function cs(e,t){if(t.settle)return;let n=e.ownerDocument,r=n.defaultView,i=()=>{n.removeEventListener(`click`,i,!0),n.removeEventListener(`pointercancel`,i,!0),n.removeEventListener(`pointerdown`,a,!0),r?.removeEventListener(`blur`,i),t.settle=null;let e=t.onSettle;t.onSettle=null,e?.()},a=t=>{t.composedPath().includes(e)||i()};n.addEventListener(`click`,i,!0),n.addEventListener(`pointercancel`,i,!0),n.addEventListener(`pointerdown`,a,!0),r?.addEventListener(`blur`,i),t.settle=i}var ls=new WeakMap;function us({runtime:e,config:t,entry:n}){let r=t.children[n.key];if(!r?.anchored)throw Error(`anchored open "${n.key}": not an anchored child of controller "${t.namespace}" — origination validation was bypassed`);let i=r.anchored,a=r.el,o=(0,x.useSyncExternalStore)(e.subscribe,()=>e.getAnchorNode(i.opener,i.anchor),()=>null),s=(0,x.useRef)(null),c=(0,x.useRef)({settle:null,onSettle:null});if(s.current===null){let e=document.createElement(`div`);e.setAttribute(Yo,Xo(t.namespace,n.key)),e.style.cssText=`position:absolute;z-index:2147483647;visibility:hidden;`,e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`pointerdown`,t=>{t.button>0||cs(e,c.current)}),s.current=e}let l=s.current;(0,x.useEffect)(()=>()=>{c.current.settle?.(),s.current?.remove()},[]);let[u,d]=(0,x.useState)(!1);(0,x.useEffect)(()=>{o||e.anchoredAnchorLost(n,Error(`ctx.open("${n.key}"): anchor "${i.anchor}" of opener "${i.opener}
4" has no attached node — is the opener mounted with ctx.anchors.${i.anchor} attached?`))},[o,e,n,i]),(0,x.useEffect)(()=>{if(!o)return;let e=o,t=e.ownerDocument,n=t.body,r=ls.get(n)??{count:0,installed:!1};r.count+=1,ls.set(n,r);let a=()=>{let e=getComputedStyle(n).position;(e===`static`||e===``)&&(n.style.position=`relative`,r.installed=!0)};n.appendChild(l);let s=i.placement??`bottom-start`,c=i.offset??0,u=s.slice(0,s.indexOf(`-`)),f=u===`bottom`||u===`top`,p=f&&s.endsWith(`-end`),m=u===`left`||p,h=u===`top`;l.style.transform=m||h?`translate(${m?`-100%`:`0px`}, ${h?`-100%`:`0px`})`:``;let g=``,_=()=>{a();let t=e.getBoundingClientRect(),r=n.getBoundingClientRect(),i=t.left-(r.left+n.clientLeft-n.scrollLeft),o=t.top-(r.top+n.clientTop-n.scrollTop),s=`${u===`right`?i+t.width+c:u===`left`?i-c:p?i+t.width:i}px`,d=`${u===`bottom`?o+t.height+c:u===`top`?o-c:o}px`,m=f?`${t.width}px`:``,h=`${s} ${d} ${m}`;h!==g&&(g=h,l.style.left=s,l.style.top=d,f&&(l.style.width=m))};_();let v=null;if(typeof ResizeObserver<`u`){v=new ResizeObserver(_);for(let t=e;t;t=t===n?null:t.parentElement)v.observe(t)}return t.addEventListener(`scroll`,_,{capture:!0,passive:!0}),d(!0),()=>{t.removeEventListener(`scroll`,_,{capture:!0}),v?.disconnect(),l.remove(),--r.count,r.count<=0&&r.installed&&(n.style.position=``,r.installed=!1)}},[o,t,n.key,l]),(0,x.useEffect)(()=>{let e=c.current;if(!n.hidden){l.style.visibility=`visible`;return}if(e.settle)return e.onSettle=()=>{l.style.visibility=`hidden`},()=>{e.onSettle=null};l.style.visibility=`hidden`},[l,n.hidden]),(0,x.useEffect)(()=>{if(n.hidden||!o)return;let t=t=>{let r=t.target;r instanceof Node&&(l.contains(r)||o.contains(r))||e.dismissAnchored(n.key)},r=()=>{setTimeout(()=>{document.activeElement instanceof HTMLIFrameElement&&e.dismissAnchored(n.key)},0)},i=t=>{t.key!==`Escape`||t.isComposing||(t.preventDefault(),t.stopPropagation(),e.dismissAnchored(n.key))};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,i,!0),window.addEventListener(`blur`,r),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,i,!0),window.removeEventListener(`blur`,r)}},[l,n.hidden,o,e,n.key]);let f=(0,x.useMemo)(()=>({...n.input,childKey:n.key,onReady:()=>n.resolve(),onError:t=>e.closeOpen(n.id,Error(t.message))}),[e,n]),p=os(e,n.id);return u?(0,Ko.createPortal)((0,x.createElement)(La.Provider,{value:p},(0,x.createElement)(a,f)),l):null}var ds={},fs=()=>!0,ps=()=>!1;function ms(){return(0,x.useSyncExternalStore)($,fs,ps)}function hs(e,t,n){for(let r=e;r;r=r.parent){if(r===n)return null;let e=r.runtime.subKeyFor(t);if(e!==void 0)return{runtime:r.runtime,key:e}}return null}var gs=(0,x.createContext)(void 0);
4function _s(e,t,n){return(0,x.createElement)(`div`,{style:e?wo:Co},e?t:null,(0,x.createElement)(`div`,{style:e?So:Co,"aria-hidden":e?!0:void 0,ref:t=>{t&&(e?t.setAttribute(`inert`,``):t.removeAttribute(`inert`))}},n))}function vs(e){return Jr(e,ys)}function ys(e){let t=function(n){let{children:r,fallback:i}=n,a=(0,x.useRef)(n);a.current=n;let o=ms(),s=(0,x.useContext)(Ia),c=(0,x.useRef)(!1);o||(c.current=!0);let l=(0,x.useContext)(gs),u=(0,x.useContext)(Z),d=(0,x.useContext)(Q),f=(0,x.useRef)(void 0);o&&!s&&f.current===void 0&&(f.current=hs(u,t,d?.chain));let p=f.current;(0,x.useSyncExternalStore)(p?p.runtime.subscribe:$,p?()=>p.runtime.getInjected(p.key):()=>ds,p?()=>p.runtime.getInjected(p.key):()=>ds);let m=()=>p?p.runtime.getSeedPhase():`ready`,h=(0,x.useSyncExternalStore)(p?p.runtime.subscribe:$,m,m),g=(0,x.useRef)(null);o&&!s&&g.current===null&&h!==`pending`&&(g.current=new go(e,()=>a.current,l,p?{getInjected:()=>p.runtime.getInjected(p.key),emit:(e,t,n)=>p.runtime.dispatchSubControllerEvent(p.key,e,t,n),analytics:{scope:p.runtime.analytics,prefix:p.runtime.analyticsPrefix?`${p.runtime.analyticsPrefix}.${p.key}`:p.key},parentRevealHeld:()=>p.runtime.subtreeRevealHeld(),parentMissingRequired:()=>p.runtime.subtreeMissingRequired(),subscribeParent:p.runtime.subscribe}:void 0));let _=g.current,v=(0,x.useRef)(null);p&&v.current===null&&(v.current=p.runtime.mintInstance(p.key)),(0,x.useEffect)(()=>{if(!(!p||!_))return p.runtime.registerSubController(p.key,{invoke:(e,t,n)=>_.dispatch(e,t,n),getState:()=>_.getControllerState()})},[_,p]),(0,x.useEffect)(()=>{if(p)return p.runtime.markChildMounted(p.key,v.current)},[_,p]),(0,x.useEffect)(()=>{if(!p||!_)return;let e=v.current,t=()=>p.runtime.setChildReady(p.key,e,!_.isLoading()),n=_.subscribeLoading(t);return t(),n},[_,p]);let y=(0,x.useMemo)(()=>_?{runtime:_,parent:u}:null,[_,u]);(0,x.useEffect)(()=>{if(_)return _.startResolvers(),_.sealLoadingIfEmpty(),()=>_.dispose()},[_]);let b=(0,x.useRef)(null),S=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!(!_||p))return S.current!==null&&(clearTimeout(S.current),S.current=null),b.current!==_&&(b.current=_,_.analytics.track(`Elements Controller Mounted`,{props:I({...e.propDefaults,...a.current},e.propAnalytics)}),z(`elements.create`,{startTime:_.otelCreatedAt,attributes:{..._.otelAttributes,...B(`props`,{...e.propDefaults,...a.current},e.propAnalytics)}}).end()),()=>{S.current=setTimeout(()=>_.analytics.track(`Elements Controller Unmounted`),0)}},[_]),(0,x.useEffect)(()=>{_?.syncProps()});let C=(0,x.useSyncExternalStore)(_?_.subscribeLoading:$,_?_.isLoading:()=>!0,_?_.isLoading:()=>!0)&&i!=null;return!o||c.current&&(!_||!y)?(0,x.createElement)(Z.Provider,{value:null},(0,x.createElement)(Ia.Provider,{value:!0},_s(C,i,r))):!_||!y?null:(0,x.createElement)(Z.Provider,{value:y},(0,x.createElement)(Ia.Provider,{value:!1},_s(C,i,r)),(0,x.createElement)(as,{runtime:_,config:e}))};Object.assign(t,{__config:e,namespace:e.namespace});for(let[n,r]of Object.entries(e.actions))r.kind===`static`&&(t[n]=t=>r.fn(da(e,{getState:()=>ni(e),getProps:()=>({})},async()=>{throw Error(`ctx.open is not available on the imperative def statics (no controller runtime) — dispatch through a mounted controller (useController) or a handle`)}),t));for(let[n,r]of Object.entries(e.resources??{}))t[n]={create:(e={})=>ar(r,e)};return t}var bs=`whop-`;function xs(e,t){return`${bs}${e}`}function Ss(e,t){return{__whopDemoCases:e,fallback:t}}function Cs(e,t){return{__whopDemoRequestField:e,fallback:t}}export{ie as C,D as E,te as S,k as T,Qr as _,Qo as a,ot as b,Do as c,Ca as d,Si as f,di as g,wi as h,vs as i,Z as l,Ci as m,Ss as n,rs as o,J as p,xs as r,Lo as s,Cs as t,Ra as u,rr as v,E as w,se as x,V as y};
5//# debugId=ed14330a-615d-594a-bb0f-a4ba2268cc0f

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.