!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]="186b6464-0c0b-59e7-a5d6-eb5e7f8276e1")}catch(e){}}(); import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{u as ue,a as me,r as i}from"./index-DwaoyV61.js";import{z as U}from"./index-zIQsbCyv.js";import{c as y}from"./index-Bc72ctNv.js";import{u as pe,B as fe,b as D,g as B,D as he,i as ge,a as w,C as be}from"./types-B2R9qSlm.js";import{u as _e,a as xe,L as ve}from"./local_storage-DRhS2b1Z.js";import{u as ye}from"./useToast-B6f2NDmM.js";import{S as we}from"./StatusInputs-1bAxfxmQ.js";import{u as je}from"./useTranslation-CqXWvxCZ.js";import{c as Ne}from"./components-DhFN5rxT.js";const q={ariel:"font-ariel",bitter:"font-bitter",courier:"font-courier",didot:"font-didot",garamond:"font-garamond",georgia:"font-georgia",helvetica:"font-helvetica",lora:"font-lora","lucida-console":"font-lucida-console",merriweather:"font-merriweather",monaco:"font-monaco","helvetica-neue-condensed-black":"font-helvetica-neue-condensed-black","space-grotesk":"font-space-grotesk",montserrat:"font-montserrat","open-sans":"font-open_sans",palatino:"font-palatino","playfair-display":"font-playfair-display",poppins:"font-poppins",roboto:"font-roboto","times-new-roman":"font-times-new-roman","trebuchet-ms":"font-trebuchet-ms",verdana:"font-verdana"},Se=({visitToken:l,referralId:j,boostAffiliateRecommendingPublicationId:n})=>e.jsx(be,{fallback:null,children:()=>e.jsxs(e.Fragment,{children:[e.jsx("input",{hidden:!0,name:"ref",value:j||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"bhba",value:n||"",onChange:()=>null}),e.jsx("input",{hidden:!0,name:"visit_token",value:l||"",onChange:()=>null})]})}),De=({type:l=w.NONE,cta:j,publication:n,onEmailChange:T,onSuccess:I,isCustomLPTheme:k=!1,placeholderText:L,fontFamily:u,backgroundColor:m,textColor:E,autoFocus:M=!1,premiumOfferId:G,buttonPlacement:$=D.INLINE})=>{const{t:s}=je(),P=ue(),{setCookie:z,cookies:K,visitToken:N,referralId:p,currentPath:J,postId:c}=_e(),V=pe(K[fe]||void 0),{pathname:R}=me(),[S,W]=xe(),O=i.useRef(null),f=$===D.BOTTOM,[h,H]=i.useState(!1),[d,Q]=i.useState({signupUrl:"",anonymousUserId:"",sendableId:"",sendableType:""});i.useEffect(()=>{typeof window>"u"||Q({signupUrl:window.location.href,anonymousUserId:B(),sendableId:c??"",sendableType:c?"post":""})},[c]);const g=Ne(),a=g.data,A=g.state==="submitting",b=n.web_template.signup_flow.filter(({enabled:r})=>r),o=b[0],C=b.length>0&&b?.[0]?.managed_type!=="custom",X=!!o&&!o.full_url.startsWith(n.url),Y=l===w.POPUP,Z=l===w.GATED,ee=l===w.FORM,_=Y||Z||ee,te=i.useMemo(()=>{if(_)return R;if(o){const r=o.href.split("?"),x=r[0],t=r[1]||"",v=new URLSearchParams(t);return v.set("email",S),`${x}?${v.toString()}`}return"/"},[o,R,S,_]),re=j||n.cta_text,{double_opt_required:se,has_referral_program:ne,private:ae,require_subscriber_approval:oe}=n,ie=!!(se||ne&&p);ye(a?.toast),i.useEffect(()=>{if(a?.toast?.status==="success"&&(z({name:"email_capture_disabled",value:"true",days:30}),O?.current?.reset()),a?.dataLayerEvent&&he.pushEvent(a.dataLayerEvent),!_&&a?.redirectTo&&C){const r={startedAt:new Date().toISOString(),currentIndex:0,nextIndex:1,redirects:b};localStorage.setItem(ve.SIGNUP_REDIRECTS,JSON.stringify(r))}!_&&a?.redirectTo&&(o&&X?setTimeout(()=>{if(ge(navigator.userAgent))try{window.location=a?.redirectTo}catch{window.location=a?.redirectTo}else window.open(a?.redirectTo,"_blank"),P("/")},1e3):P(a?.redirectTo)),a?.redirectTo&&I&&I()},[a]);const le=()=>n.require_subscriber_approval?s("notifications.subscribe.require_approval"):n.double_opt_required?s("notifications.subscribe.confirm"):s("notifications.subscribe.subscribed"),ce=(r,x)=>{if(r.preventDefault(),n?.enable_signup_confirmation&&!h){U.error("Accept ToU & Privacy Policy.");return}const t=new FormData(r.currentTarget),v=t.get("visit_token"),de=t.get("ref"),F=S?.trim();if(t.set("is_js_enabled","true"),t.set("accepted_tos",String(h)),t.set("email",F),!F){U.error("Please enter a valid email address");return}!v&&N&&t.set("visit_token",N),!de&&p&&t.set("ref",p),x&&t.set("premium_offer_id",x),typeof window<"u"&&(t.set("nectar_signup_url",window.location.href),t.set("nectar_anonymous_user_id",B()),c&&(t.set("nectar_sendable_id",c),t.set("nectar_sendable_type","post"))),g.submit(t,{method:"post",action:"/create"})};return ae&&!oe?null:e.jsx("div",{className:"flex flex-col items-center w-full space-y-4",children:e.jsxs(g.Form,{ref:O,method:"post",action:"/create",className:"w-full bg-transparent group rounded-wt",onSubmit:r=>ce(r,G),children:[e.jsx(Se,{visitToken:N,referralId:p,boostAffiliateRecommendingPublicationId:V}),e.jsx("input",{name:"redirect_path",type:"hidden",value:te}),e.jsx("input",{name:"sent_from_orchid",type:"hidden",value:"true"}),e.jsx("input",{name:"nectar_signup_url",type:"hidden",value:d.signupUrl}),e.jsx("input",{name:"nectar_anonymous_user_id",type:"hidden",value:d.anonymousUserId}),d.sendableId?e.jsxs(e.Fragment,{children:[e.jsx("input",{name:"nectar_sendable_id",type:"hidden",value:d.sendableId}),e.jsx("input",{name:"nectar_sendable_type",type:"hidden",value:d.sendableType})]}):null,e.jsx("input",{name:"fallback_path",type:"hidden",value:J}),e.jsx("input",{name:"double_opt",type:"hidden",value:ie.toString()}),e.jsx("input",{name:"trigger_redirect",type:"hidden",value:C.toString()}),e.jsx(we,{name:"subscribe",successMessage:le(),errorMessage:s("errors.default")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:y("w-full sm:mx-auto sm:flex",f?"flex flex-col items-center space-y-4":""),children:[e.jsx("div",{className:"w-full",children:e.jsx("input",{type:"email",name:"email",autoComplete:"email",autoFocus:M,required:!0,style:{...m&&{borderColor:m}},className:y(u?q[u]:"wt-button-font",k?"border-lp-main-signup-bg-color focus:border-lp-main-signup-bg-color":"border-wt-primary focus:border-wt-primary",f?"":"sm:rounded-r-none","block w-full rounded border-2 bg-white px-5 py-3 text-lg font-light text-black placeholder-gray-400 shadow-none placeholder:text-lg focus:outline-none"),onChange:r=>{W(r.target.value),T&&T(r.target.value)},placeholder:L||s("subscribe.email_placeholder")||""})}),e.jsx("div",{className:y("mt-2 sm:mt-0",f?"w-full":""),children:e.jsx("input",{type:"submit",value:A?`${s("shared.actions.submitting")}...`:re,style:{...m&&{backgroundColor:m},...E&&{color:E}},className:y(u?q[u]:"wt-button-font",k?"text-lp-main-signup-cta-color bg-lp-main-signup-bg-color text-lp-main-signup-text-color":"bg-wt-primary text-wt-text-on-primary",f?"":"sm:rounded-l-none","block h-full w-full cursor-pointer rounded border border-transparent px-5 py-3 !text-lg font-medium transition duration-200 sm:px-10 sm:text-base"),disabled:A})})]}),n?.enable_signup_confirmation&&e.jsxs("div",{className:"flex flex-row mt-3 space-x-2",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 border-gray-300 rounded text-lp-main-signup-cta-color focus:ring-indigo-500",checked:h,onClick:()=>H(!h)}),!n?.terms_of_service||n?.terms_of_service.length===0?e.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[s("shared.cta.gdpr_signup_consent")," ",e.jsx("a",{href:"https://www.beehiiv.com/tou",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:s("footer.terms_of_use")})," ",s("shared.cta.and")," ",e.jsx("a",{href:"https://www.beehiiv.com/privacy",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:s("footer.privacy_policy")}),"."]}):e.jsxs("p",{className:"text-xs font-medium text-gray-900",children:[s("shared.cta.gdpr_signup_consent")," ",s("shared.cta.sign_up")," ",e.jsx("a",{href:"/tos",target:"_blank",className:"underline underline-offset-1 hover:opacity-80",rel:"noreferrer",children:s("meta.titles.tos")}),"."]})]})]})]})})};export{De as C}; //# sourceMappingURL=CreateAction-By7UFb-3.js.map //# debugId=186b6464-0c0b-59e7-a5d6-eb5e7f8276e1