!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"substack@ee6f1f5"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1880d354-0af1-49d0-87a4-666d68f8d3b2",e._sentryDebugIdIdentifier="sentry-dbid-1880d354-0af1-49d0-87a4-666d68f8d3b2")}catch(e){}}();"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["10696"],{86839:function(e,t,n){n.d(t,{A:()=>a});let a={form:"form-MBPB6J"}},66572:function(e,t,n){n.d(t,{A:()=>Y});var a=n(79785),i=n(4006),r=n(17402),o=n(84605),l=n(92905),c=n(94729),s=n(12501),d=n(68349),u=n(35369),h=n(76977),p=n(79661),m=n(63136),f=n(39318);function g(){let e=(0,a._)(["You've confirmed your email change from ",". We've sent a confirmation email to ","."]);return g=function(){return e},e}function b(){let e=(0,a._)(["We've sent a confirmation email to "," to confirm changing your email to ",". Please check your inbox and click the confirmation link to proceed."]);return b=function(){return e},e}function v(){let e=(0,a._)(["An account under "," already exists. If you proceed, your subscriptions, publications, and other data will be transferred to that account."]);return v=function(){return e},e}function y(e){let{conflicts:t,iString:n}=e,a=t.filter(e=>"dual_paid"===e.type),r=t.filter(e=>"group_parent"===e.type);return(0,i.FD)("div",{style:{marginTop:16},children:[(0,i.Y)(m.EY.B3,{color:"error",children:(0,i.Y)("b",{children:n("This email change cannot be completed yet.")})}),(0,i.Y)(m.EY,{as:"p",translated:!0,children:"An account already exists with this email, and there are subscription conflicts that need to be resolved first:"}),a.length>0&&(0,i.FD)(i.FK,{children:[(0,i.Y)(m.EY,{as:"p",translated:!0,children:(0,i.Y)("b",{children:"Both accounts have a paid subscription to:"})}),(0,i.Y)("ul",{children:a.map((e,t)=>(0,i.Y)("li",{children:e.publicationName},t))}),(0,i.Y)(m.EY,{as:"p",translated:!0,children:"Cancel one of the duplicate paid subscriptions on either account, then try again."})]}),r.length>0&&(0,i.FD)(i.FK,{children:[(0,i.Y)(m.EY,{as:"p",translated:!0,children:(0,i.Y)("b",{children:"A group subscription exists for:"})}),(0,i.Y)("ul",{children:r.map((e,t)=>(0,i.Y)("li",{children:e.publicationName},t))}),(0,i.Y)(m.EY,{as:"p",translated:!0,children:"Transfer or cancel the group subscription before proceeding."})]})]})}let Y=(0,o.wr)(function(e){let{user:t,iString:n,iTemplate:a}=e,[o,Y]=(0,r.useState)(""),[_,w]=(0,r.useState)(""),[S,C]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[T,x]=(0,r.useState)(null),[E,D]=(0,r.useState)(null),[N,U]=(0,r.useState)(null),{isLoading:F,refetch:I}=(0,s.st)({pathname:"/api/v1/user/email_change/initiate",method:"POST",auto:!1,deps:[]}),{refetch:B}=(0,s.st)({pathname:"/api/v1/user/email_change/status",method:"GET",auto:!1,deps:[]}),{isLoading:O,refetch:P}=(0,s.st)({pathname:"/api/v1/user/email_change/cancel",method:"POST",auto:!1,deps:[]}),{trackInputFilled:z,trackSubmitPressed:R,trackError:j}=(0,l.a)("Change Email Form");(0,r.useEffect)(()=>{t?q():(0,d.V2)((0,f.a7q)({}))},[]);let q=(0,r.useCallback)(async()=>{let e=await B();e instanceof Error||(null==e?void 0:e.pending)&&A(e)},[B]);if(!t)return null;let G=async e=>{var t,a,i,r,l;e.preventDefault(),R(),C(null),D(null);let s={email:o};_&&(s.totp_token=_),N&&(s.confirm_merge=!0);let d=await I({json:s});if(d instanceof Error){j(d),d instanceof c.fk?C((null==(i=d.body)||null==(a=i.errors)||null==(t=a[0])?void 0:t.msg)||(null==(r=d.body)?void 0:r.error)||"Something went wrong"):C("Something went wrong");return}(null==d?void 0:d.mfa_required)?C(n("Please enter your authenticator code to continue.")):(null==d?void 0:d.status)==="conflicts"&&d.conflicts?D(d.conflicts):(null==d?void 0:d.status)==="merge_warning"?U(null!=(l=d.to_email)?l:o):(U(null),x(o),A({pending:!0,initiator_confirmed:!1,to_email:o}))},L=async()=>{await P(),A(null),x(null)},V=null==k?void 0:k.pending,K=T||(null==k?void 0:k.to_email);if(V){let e=null==k?void 0:k.initiator_confirmed;return(0,i.Y)("div",{id:"change-email-settings",className:"page account-settings",children:(0,i.FD)("div",{className:"container",children:[(0,i.Y)("h1",{children:n("Email change pending")}),e?(0,i.Y)("p",{children:a(g(),t.email,null!=K?K:"")}):(0,i.Y)("p",{children:a(b(),t.email,null!=K?K:"")}),(0,i.Y)(h.Ye,{alignItems:"center",gap:12,paddingTop:32,children:(0,i.Y)(u.$n,{priority:"secondary",onClick:L,disabled:O,loading:O,children:n("Cancel email change")})})]})})}return(0,i.Y)("div",{id:"change-email-settings",className:"page account-settings",children:(0,i.FD)("div",{className:"container",children:[(0,i.Y)("h1",{children:n("Change your email address")}),(0,i.FD)("p",{children:[(0,i.Y)("b",{children:n("This will change the email address on all of your Substack subscriptions.")})," ",n("Both your current and new email addresses must confirm before the change takes effect.")]}),(0,i.FD)("form",{className:"form",onSubmit:G,children:[(0,i.Y)(p.pd,{type:"email",name:"email",onChange:e=>Y(e.target.value),onBlur:z,value:o,disabled:F,placeholder:(null==t?void 0:t.email)||""}),t.has_mfa_enabled&&(0,i.Y)(p.pd,{type:"text",name:"totp_token",onChange:e=>w(e.target.value),value:_,disabled:F,placeholder:n("Authenticator code"),maxLength:6}),S&&(0,i.Y)("div",{className:"error",children:S}),E&&(0,i.Y)(y,{conflicts:E,iString:n}),N&&(0,i.FD)("div",{style:{marginTop:16},children:[(0,i.Y)("p",{children:a(v(),N)}),(0,i.FD)(m.EY,{as:"p",translated:!0,children:["This action is ",(0,i.Y)("b",{children:"irreversible"}),"."]})]}),(0,i.FD)(h.Ye,{alignItems:"center",gap:12,justifyContent:"end",paddingTop:32,children:[(0,i.Y)(u.$n,{priority:"destructive",type:"submit",disabled:!o||F,loading:F,children:N?n("Confirm Transfer"):n("Change Email")}),(0,i.Y)(u.$n,{priority:"secondary",onClick:()=>history.back(),children:n("Cancel")})]})]})]})})})},13950:function(e,t,n){n.d(t,{DH:()=>d,xF:()=>h});var a=n(4006),i=n(32485),r=n.n(i),o=n(17402),l=n(10996);n(4016);var c=n(6045);let s={header:String(c.A.headerTheme),footer:String(c.A.footerTheme),footer_secondary:String(c.A.footerSecondaryTheme),subscribe:String(c.A.subscribeTheme)};function d(e){let{prefix:t,children:n}=e;return t?(0,a.Y)(u.Provider,{value:t,children:(0,a.Y)("div",{className:r()(c.A.pubTheme,s[t]),children:n})}):(0,a.Y)(l.NP,{theme:c.A.pubTheme,children:n})}let u=(0,o.createContext)(null);function h(){let e=(0,o.useContext)(u);return{onOpen:o.default.useCallback(()=>{let t=document.getElementById("menu-portal");t&&e&&(t.className=r()(c.A.pubTheme,s[e]))},[e]),onClose:o.default.useCallback(()=>{let e=document.getElementById("menu-portal");e&&(e.className="")},[])}}},98747:function(e,t,n){n.d(t,{oY:()=>o,wX:()=>l});var a=n(4006),i=n(17402);let r=(0,i.createContext)({hasThemedBackground:!1});function o(){var e;return!!(null==(e=(0,i.useContext)(r))?void 0:e.hasThemedBackground)}function l(e){let{value:t,children:n}=e,o=(0,i.useMemo)(()=>t,Object.values(t));return(0,a.Y)(r.Provider,{value:o,children:n})}r.displayName="ThemeContext"},75051:function(e,t,n){n.d(t,{Y:()=>T});var a=n(69277),i=n(70408),r=n(4006),o=n(32485),l=n.n(o),c=n(45773),s=n(78834),d=n(70511),u=n(17402),h=n(78649),p=n(33764),m=n(93355),f=n(86500),g=n(12501),b=n(17028),v=n(62870),y=n(93812),Y=n(92563),_=n(29682),w=n(39318),S=n(49807),C=n(98949);let k={header:"header-LkrdOr",footer:"footer-EnTWMp",swatchContainer:"swatchContainer-aa9QGg",checkIconContainer:"checkIconContainer-OhnBup"};function A(e){var t,n,a,i,o,l;let{comment:c,imageShareAsset:s,aspectRatio:d}=e,{width:u,height:h}=(0,Y.S8)(d),{img:p,imgDownload:g,shareData:b,useNativeShare:y}=(0,m.Y)({shareTitle:"A note from ".concat(c.name),shareText:c.body,shareUrl:(0,S.M$q)("c-".concat(c.id)),imageUrl:null!=(t=null==s?void 0:s.composed_url)?t:"",imageDownloadUrl:null!=(o=null!=(i=(0,w.tbS)({noteId:"c-".concat(c.id),variant:null!=(n=null==s?void 0:s.variant)?n:"orange",type:"composed",aspectRatio:null!=(a=null==s?void 0:s.aspectRatio)?a:"stories"}))?i:null==s?void 0:s.composed_url)?o:"",imageUrlSameOrigin:null!=(l=null==s?void 0:s.composed_url)?l:""});async function _(){if((0,f.u4)(f.qY.NOTE_IMAGE_ASSET_DOWNLOADED,{comment_id:c.id,aspect_ratio:null==s?void 0:s.aspectRatio,source:"note-image-asset",interaction:"click"}),b)try{await navigator.share(b)}catch(e){}}return(0,r.Y)(v.Cs,{onClick:_,href:y?void 0:g,children:(0,r.FD)(v.OK,{size:h,aspectRatio:u/h,children:[!(0,C.Fr)()&&p&&(0,r.Y)(v.lh,{onClick:_,width:u}),(0,r.Y)(v.BB,{img:p})]})})}function T(e){var t,n,a;let{comment:i}=e,[o,l]=(0,u.useState)("stories"),[c,s]=(0,u.useState)("orange"),d=((e,t)=>{let{result:n,error:a}=(0,g.st)({pathname:"/api/v1/note/assets/c-".concat(e.id),query:{aspectRatio:t},deps:[e.id,t],auto:!0});return(0,u.useMemo)(()=>a?[]:n,[n,a])})(i,o),p=null==d?void 0:d.find(e=>e.aspectRatio===o&&e.variant===c),m=null!=(a=null==(n=i.attachments)||null==(t=n.find(e=>"image"===e.type))?void 0:t.imageUrl)?a:i.photo_url;return(0,r.Y)(h.Q,{children:(0,r.FD)(D,{children:[(0,r.Y)(b.az,{className:k.header,children:(0,r.Y)(N,{aspectRatio:o,setAspectRatio:l})}),(0,r.Y)(b.Ye,{justifyContent:"center",padding:12,children:(0,r.Y)(A,{aspectRatio:o,comment:i,imageShareAsset:p})}),(0,r.Y)(x,{selectedVariant:c,setSelectedVariant:s,photoUrl:m})]})})}function x(e){let{selectedVariant:t,setSelectedVariant:n,photoUrl:a}=e;return(0,r.Y)(b.fI,{gap:8,justifyContent:"center",children:_.ix.map(e=>(0,r.Y)(E,{variant:e,setSelectedVariant:n,isSelected:t===e,photoUrl:a},e))})}function E(e){let{variant:t,setSelectedVariant:n,isSelected:o,photoUrl:s}=e,d=(0,y.kE)({variant:t,width:32,height:32,backgroundImageSrc:s});return(0,r.FD)(b.az,{width:32,height:32,radius:"sm",cursor:"pointer",overflow:"hidden",sizing:"border-box",position:"relative",onClick:function(){n(t)},className:l()(k.swatchContainer,o&&k.selected),children:[(0,r.Y)(b.az,{className:k.checkIconContainer,children:o&&(0,r.Y)(c.A,{size:24})}),"css"===d.type?(0,r.Y)(b.az,{height:32,width:32,sizing:"border-box",style:d.style}):(0,r.Y)(p.o,{src:d.src,maxWidth:32,imageProps:(0,i._)((0,a._)({},d.imgProps),{height:32})})]})}let D=(0,b.I4)({display:"flex",direction:"column",alignItems:"center",overflow:"hidden",paddingBottom:20});function N(e){let{aspectRatio:t,setAspectRatio:n}=e;return(0,r.Y)(b.fI,{gap:8,borderBottom:"detail",padding:16,justifyContent:"center",children:_.yo.map(e=>(0,r.Y)(b.$n,{size:"sm",priority:t===e?"primary-mono":"secondary",onClick:()=>n(e),leading:"grid"===e?(0,r.Y)(s.A,{size:20}):(0,r.Y)(d.A,{size:20}),children:"grid"===e?"Grid":"Stories"},e))})}},93355:function(e,t,n){n.d(t,{Y:()=>l});var a=n(17402),i=n(95641),r=n(68349),o=n(98949);function l(e){let[t,n]=(0,a.useState)(""),[l,c]=(0,a.useState)(""),[s,d]=(0,a.useState)({}),[u,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(0,o.Fr)()&&navigator.share&&navigator.canShare(s)&&h(!0)},[s]),(0,a.useEffect)(()=>{!async function(){n("");let t=e.imageUrl;if((0,r.NN)(e.imageUrl,()=>{n(t),c(e.imageDownloadUrl)}),(0,o.Fr)()){var a,i;let n=await fetch(e.imageUrlSameOrigin||t),r=["instagram","instagram-stories"].includes(null!=(a=e.shareApp)?a:"");d({title:r?void 0:e.shareTitle,text:r?void 0:null!=(i=e.shareText)?i:void 0,files:[new File([await n.blob()],"image.png",{type:"image/png"})],url:r?void 0:e.shareUrl})}}()},[e.imageDownloadUrl,e.imageUrl,e.shareApp,e.shareText,e.shareTitle,e.shareUrl]);let{refetch:p}=(0,i.E)({method:"post",pathname:"/api/v1/press_kit/notification",body:{title:e.shareText,imageUrl:e.imageUrl,shareApp:e.shareApp},deps:[e.shareText,e.imageUrl,e.shareApp]});return{img:t,imgDownload:l,sendPushNotification:(0,a.useCallback)(async()=>{let e=await p();return!(e instanceof Error)&&e.success},[p]),shareData:s,useNativeShare:u}}},77256:function(e,t,n){n.d(t,{W:()=>c});var a=n(4006),i=n(17402),r=n(10697),o=n(37082),l=n(11510);function c(e){let{trigger:t,children:n,onOpen:c,onClose:s,disabled:d,side:u,align:h,matchReferenceWidth:p=!1,disableMobileBottomSheet:m=!1,portal:f=!0}=e,g=(0,l.Iu)(),[b,v]=(0,i.useState)(!1),y=()=>v(!1),Y=e=>{v(e),e?null==c||c():null==s||s()};return g&&!m?(0,a.Y)(r._,{trigger:t,disabled:d,open:b,close:y,onOpenChange:Y,children:n}):(0,a.Y)(o.T,{trigger:t,disabled:d,open:b,close:y,onOpenChange:Y,side:u,align:h,matchReferenceWidth:p,portal:f,children:n})}},87834:function(e,t,n){n.d(t,{c:()=>s});var a=n(69277),i=n(32641),r=n(4006),o=n(32485),l=n.n(o),c=n(76977);function s(e){var{className:t,padding:n=20}=e,o=(0,i._)(e,["className","padding"]);return(0,r.Y)(c.VP,(0,a._)({overflow:"auto",padding:n,className:l()("body-r_n7KA",t),"data-modal-role":"body"},o))}},62870:function(e,t,n){n.d(t,{BB:()=>y,Cs:()=>_,OK:()=>S,f3:()=>C,lh:()=>w,wj:()=>k});var a=n(69277),i=n(70408),r=n(4006),o=n(32485),l=n.n(o),c=n(48309),s=n(17402),d=n(84605),u=n(86500),h=n(35369),p=n(76977),m=n(57820),f=n(75303),g=n(39318),b=n(49807),v=n(84759);let y=(0,s.forwardRef)((e,t)=>{let{img:n}=e,[a,i]=(0,s.useState)(!1);return n?(0,r.FD)(r.FK,{children:[!a&&(0,r.Y)(Y,{}),(0,r.Y)("img",{src:n,className:l()(v.A.image,a&&v.A.loaded),ref:t,onLoad:()=>i(!0),style:{display:a?"block":"none"}})]}):(0,r.Y)(Y,{})});function Y(){return(0,r.Y)(p.VP,{alignItems:"center",justifyContent:"center",bg:"secondary",className:l()(v.A.image,v.A.loading),children:(0,r.Y)(m.y$,{})})}function _(e){let{children:t,onClick:n,href:a}=e,{iString:i}=(0,d.GO)();return(0,r.Y)(f.AE,{onClick:n,href:a,"aria-label":i("Download image"),download:!0,className:l()(v.A.link),target:"_blank",rel:"noreferrer",children:t})}function w(e){let{onClick:t,width:n,className:a}=e,{iString:i}=(0,d.GO)();return(0,r.Y)(p.VP,{style:{width:n},className:l()(v.A.overlay,a),animate:!0,position:"absolute",inset:0,alignItems:"center",justifyContent:"end",paddingBottom:12,children:(0,r.Y)(h.$n,{className:v.A.downloadButton,priority:"primary-mono",size:"sm",leading:(0,r.Y)(c.A,{size:20}),onClick:e=>{e.stopPropagation(),t()},children:i("Download")})})}function S(e){let{children:t,size:n=300,aspectRatio:a=1}=e;return(0,r.Y)(p.VP,{className:v.A.imageContainer,flex:"auto",position:"relative",cursor:"grab",style:{"--image-max-size":"".concat(n,"px"),"--aspect-ratio":a},children:t})}async function C(e){let{post_id:t,type:n,aspect_ratio:r,selection_id:o,source:l,auto_selected:c,shareData:s,eventName:d,additionalTrackingData:h={}}=e;if((0,u.u4)(u.qY[d],(0,i._)((0,a._)({post_id:t,type:n},r&&{aspect_ratio:r},o&&{selection_id:o},l&&{source:l},c&&{auto_selected:c},h),{interaction:"click"})),s)try{await navigator.share(s)}catch(e){}}function k(e){let{pub:t,post:n,selectionId:a,style:i}=e;return a?{shareTitle:"Share this post",shareText:n.title,shareUrl:(0,b.wu9)(t,n),imageDownloadUrl:(0,g.SAZ)(t,n,a,i),imageUrl:(0,g.SAZ)(t,n,a,i),imageUrlSameOrigin:(0,g.LJG)(t,n,a,i)}:{shareTitle:"Share this post",shareText:n.title,shareUrl:(0,b.wu9)(t,n),imageDownloadUrl:(0,g.fsB)(t,n,i),imageUrl:(0,g.fsB)(t,n,i),imageUrlSameOrigin:(0,g.OKG)(t,n,i)}}},26606:function(e,t,n){n.d(t,{i:()=>i});var a=n(94729);let i=e=>async t=>{let n="before";t({type:"conversation-request_initial",payload:{conversationId:e}});try{let i=await (0,a.x6)("/api/v1/messages/dm/".concat(e));t({type:"conversation-load_more",payload:{edge:n,cursor:null,page:i}})}catch(a){t({type:"conversation-request_error",payload:{conversationId:e,edge:n,cursor:null,error:a}})}}},14984:function(e,t,n){n.d(t,{fk:()=>d,tB:()=>u});var a=n(4006),i=n(50014),r=n.n(i),o=n(17402);n(46271);var l=n(17186);n(49807),n(84985);let c={surfaces:[],addSurface:()=>void 0},s=(0,o.createContext)(c);function d(){return(0,o.useContext)(s)}function u(e){let{user:t,children:n}=e,{surfaces:i,addSurface:d}=(e=>{let[t,n]=(0,o.useState)([]),a=(0,o.useMemo)(()=>e?"".concat("user-recent-surfaces","-").concat(e.id):"",[e]);(0,o.useEffect)(()=>{if(!e)return;let t=(0,l.xm)(a);n(null!=t?t:[])},[e,a]);let i=(0,o.useCallback)(e=>{var t;let i=null!=(t=(0,l.xm)(a))?t:[],o="visited-publication"===e.type?{type:e.type,publication:{id:e.publication.id,name:e.publication.name,base_url:e.publication.base_url,logo_url:e.publication.logo_url,custom_domain:e.publication.custom_domain,custom_domain_optional:e.publication.custom_domain_optional,subdomain:e.publication.subdomain,theme:e.publication.theme,theme_var_background_pop:e.publication.theme_var_background_pop,author_photo_url:e.publication.author_photo_url,author:e.publication.author,cover_photo_url:e.publication.cover_photo_url}}:{type:e.type,profile:{name:e.profile.name,id:e.profile.id,photo_url:e.profile.photo_url}},c=r()([o,...i],e=>"visited-publication"===e.type?"pub-".concat(e.publication.id):"profile-".concat(e.profile.id)).slice(0,10);n(c);try{(0,l.X3)(a,c)}catch(e){console.error("Failed to update local recent surfaces:",e)}},[a]);return e?{surfaces:t,addSurface:i}:c})(t);return(0,a.Y)(s.Provider,{value:{surfaces:i,addSurface:d},children:n})}}}]);