"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["7199"],{8923:function(e,t,n){n.d(t,{$1:()=>p,Sn:()=>m,wg:()=>u});var o=n(7409),i=n(99282),r=n(16584),l=n(6400),a=n(30396),s=n(80569),d=n.n(s);let c=(0,l.createContext)({oauthAccessToken:null,isOAuthProvider:!1}),u=()=>(0,a.qp)(c);function p(e){let t=t=>{let{oauthAccessToken:n}=u();return(0,r.tZ)(e,(0,i._)((0,o._)({},t),{oauthAccessToken:n}))};return t.displayName="WithOAuthEmbed(".concat(e.displayName||e.name||"Component",")"),t}let m=()=>{let{oauthAccessToken:e}=u();return(0,a.Ye)(()=>{let t=t=>(e&&t.set("Authorization","Bearer ".concat(e)),t);return{get:e=>t(d().get(e)),post:e=>t(d().post(e)),put:e=>t(d().put(e)),delete:e=>t(d().delete(e)),patch:e=>t(d().patch(e))}},[e])}},41258:function(e,t,n){n.d(t,{AM:()=>et,L8:()=>j,LB:()=>q,eR:()=>G,lf:()=>Y,sA:()=>K});var o=n(27412),i=n(7409),r=n(99282),l=n(58865),a=n(16584),s=n(6400),d=n(98661),c=n(30396),u=n(94184),p=n.n(u),m=n(74691),h=n.n(m),g=n(14293),f=n.n(g),v=n(43174),y=n.n(v),_=n(80569),w=n.n(_),C=n(79094),S=n(57391),b=n(95441),Z=n(15597),R=n(46914),N=n(68833),E=n(95434),X=n(63648),k=n(65892),B=n(41990),T=n(56187),x=n(82011),I=n(68072),L=n(46638),P=n(12900),D=n(71068),M=n(15771),O=n(19081),A=n(50364),F=n(47929);function H(){let e=(0,l._)(["Comment by ",""]);return H=function(){return e},e}let J=Math.min(Math.ceil((h()(document.body.clientWidth,400,728)-140)/50),10);class z extends s.Component{componentDidMount(){this.setSelectedHighlight(),this.setReplyStateFromHash(),this.updateOverflows()}componentDidUpdate(e){var t,n;(null===(t=e.comment)||void 0===t?void 0:t.id)!==(null===(n=this.props.comment)||void 0===n?void 0:n.id)&&this.setSelectedHighlight(),e.replying!==this.props.replying&&this.props.replying&&this.startReply()}setReplyStateFromHash(){if(this.props.comment.deleted||"undefined"==typeof window||!window.location.hash)return;let e=/^#comment-(\d+)-reply$/.exec(window.location.hash);e&&Number(e[1])===this.props.comment.id&&(window.location.hash=window.location.hash.replace(/-reply$/,""),this.startReply())}async startReply(){this.props.onStartReply?this.props.onStartReply(this.props.comment):await new Promise(e=>this.setState({replying:!0},e))}onDateClick(e){var t;let[n,o]=e.target.href.split("?")[0].split("#");n===(null===(t=window.location.href.split("?")[0])||void 0===t?void 0:t.split("#")[0])&&o&&(e.preventDefault(),this.setState({hideAnchors:!0},()=>{window.location.hash="#".concat(o),this.setState({hideAnchors:!1})}))}updateOverflows(){let e=this.bodyRef.current;if(!e)return;let t=e.scrollHeight-e.clientHeight;t>0&&t<200?e.classList.add("expanded"):t>=200&&(e.classList.add("long"),e.setAttribute("data-hidden-height",t))}render(e,t){var n,o,l,s;let{user:d,comment:c,freeSignup:u,freeSignupEmail:m,pub:h,post:g,reaction_token:v,depth:y,collapseAtDepth:_,onChange:w,scrollRef:C,retainUserCollapseState:S,onStartReply:b,noHoverProfile:Z,onProfileClick:R,onShareComment:N,hideContextMenu:E,noRestack:D,updateCommentReacted:F,iString:z,iTemplate:W,hideShare:Y,contextMenuUseMobileBottomSheet:K}=e,{isSelected:j,replying:q,editing:G,hideAnchors:V,isCollapsed:$}=t,Q=h.community_enabled&&g&&"none"!==g.write_comment_permissions,{user_banned:et}=c;if(G&&d)return(0,a.tZ)(B._,{autoFocus:!0,user:d,freeSignup:u,freeSignupEmail:m,pub:h,post:g,commentBeingEdited:c,saveEdit:this.saveEdit,token:v,onCancel:()=>this.setState({editing:!1}),onSuccess:w?this.onSaveEditSuccess:null});let en=null===(n=(0,L.gz)(c))||void 0===n?void 0:n.name,eo=en?W(H(),en):z("Comment");return(0,a.BX)("div",{className:p()("comment",{selected:j,"post-reply":"reply"===c.type,collapsed:$}),children:[!V&&[(0,a.tZ)("div",{id:"comment-".concat(c.id),className:"comment-anchor"}),(0,a.tZ)("div",{id:"comment-".concat(c.id,"-reply"),className:"comment-anchor"})],(0,a.BX)(O.X2,{gap:12,paddingBottom:12,className:"comment-content",role:"article","aria-label":eo,children:[(0,a.tZ)(O.sg,{ref:this.headContainerRef,children:(0,a.tZ)(x.a,{comment:c,noHover:Z,onClick:R?()=>R(c):void 0})}),(0,a.BX)(O.sg,{flex:"grow",children:[(0,a.tZ)(T.J,{post:g,pub:h,comment:c,isCollapsed:$,toggleCollapse:()=>this.setCollapsed(!this.state.isCollapsed),onProfileClick:R,userBanned:null!=et&&et,userPendingApproval:c.status===A.ql.new_commenter_approval_required&&!!(null==d?void 0:d.is_admin),onChange:this.onChange,startEdit:()=>this.startEdit(),startReport:this.showReportModal,openBan:this.openBan,hideContextMenu:E,useMobileBottomSheet:K}),(0,a.tZ)(k.Z,{comment:c,bodyRef:this.bodyRef,expandToggleClicked:this.expandToggleClicked}),(0,a.tZ)(X.Z,{comment:c,pub:h,user:d,post:g,reaction_token:v,commentsEnabledForPost:Q,noRestack:D,onChange:this.onChange,startReply:()=>this.startReply(),updateCommentReacted:F,shareComment:N,hideShare:Y}),(0,a.tZ)(P.H,{expanded:q&&Q,clip:!1,children:(0,a.tZ)(U,{children:(0,a.tZ)(B._,{autoFocus:!0,user:d,freeSignup:u,freeSignupEmail:m,pub:h,post:g,parent:c,token:v,onCancel:()=>this.setState({replying:!1}),onSuccess:w?e=>{this.setState({replying:!1}),w((0,r._)((0,i._)({},c),{children:[e].concat(c.children)}))}:null,alwaysShowButtons:!0})})})]})]}),c.childrenSummary&&(0,a.tZ)("div",{className:"more-replies-container",children:(0,a.tZ)("a",{className:"more-replies",href:(0,L.aE)(g,c,h),children:c.childrenSummary})}),!c.childrenSummary&&!f()(y)&&y>=J&&!!(null===(o=c.children)||void 0===o?void 0:o.length)&&(0,a.tZ)(O.X2,{className:"more-replies-container",children:(0,a.tZ)(M.ZP,{size:"sm",priority:"secondary-outline",href:(0,L.aE)(g,c,h),children:z("Continue thread →")})}),!c.childrenSummary&&!f()(y)&&y0&&(0,a.tZ)(I.S,{onCollapse:()=>this.setCollapsed(!0)})]},c.id)}constructor(e,t){super(e,t),(0,o._)(this,"bodyRef",(0,s.createRef)()),(0,o._)(this,"headContainerRef",(0,s.createRef)()),(0,o._)(this,"openBan",()=>{this.props.commentActions.openBanDialog({comment:this.props.comment,onReply:()=>{this.startReply()}})}),(0,o._)(this,"setSelectedHighlight",()=>{let e=(0,L.Jr)()===this.props.comment.id;this.setState({isSelected:e})}),(0,o._)(this,"startEdit",()=>{this.setState({editing:!0})}),(0,o._)(this,"saveEdit",async e=>{if(this.state.editing)return{res:await w().patch("/api/v1/comment/".concat(this.props.comment.id)).send({body:e})}}),(0,o._)(this,"onSaveEditSuccess",e=>{var t,n;let{edited:o}=e;this.setState({editing:!1}),null===(t=(n=this.props).onChange)||void 0===t||t.call(n,(0,i._)({},this.props.comment,o))}),(0,o._)(this,"showReportModal",()=>{var e;let{pub:t,comment:n}=this.props;this.props.onReport({pub:t,canReportToAdmins:!!(null==t?void 0:t.moderation_enabled)&&!(null===(e=n.metadata)||void 0===e?void 0:e.is_author),onSubmit:async e=>{var o,l;let{reportCategory:a,reportedToSubstack:s,details:d}=e;await w().post("/api/v1/comment/".concat(n.id,"/report")).send({publication_id:null==t?void 0:t.id,details:d,reportCategory:a,reportedToSubstack:s}),null===(o=(l=this.props).onChange)||void 0===o||o.call(l,(0,r._)((0,i._)({},this.props.comment),{reported_by_user:!0}))}})}),(0,o._)(this,"expandToggleClicked",()=>{let e=this.bodyRef.current;e&&(e.classList.remove("long"),e.classList.add("expanded"),(0,N.j)(N.FP.COMMENT_EXPAND_TOGGLE_CLICKED,{hiddenHeight:e.getAttribute("data-hidden-height")}))}),(0,o._)(this,"onChange",e=>{this.props.onChange?this.props.onChange((0,i._)({},this.props.comment,e)):document.location.href=(0,L.Os)(this.props.post,this.props.pub)}),(0,o._)(this,"setComment",e=>{this.setState({comment:e})}),(0,o._)(this,"setCollapsed",e=>{var t,n;if(this.setState({isCollapsed:e}),e&&(null===(n=this.headContainerRef)||void 0===n?void 0:null===(t=n.current)||void 0===t?void 0:t.scrollIntoView)){let e=this.headContainerRef.current.getBoundingClientRect();e.top<0&&(document.documentElement.scrollTop+=e.top-80)}this.props.retainUserCollapseState&&(0,L.VS)(this.props.comment.id,e)}),this.state={editing:!1,replying:!1,hideAnchors:!1,isSelected:!1,isCollapsed:this.props.retainUserCollapseState&&(0,L.ei)(this.props.comment.id)}}}(0,o._)(z,"contextType",S.kx);let U=(0,D.zo)({display:"flex",flex:"grow",paddingTop:16}),W=(0,d.memo)((0,b.fz)(function(e){let t=(0,d.useContext)(en),n=(0,C.T)();return(0,a.tZ)(z,(0,r._)((0,i._)({},e),{commentActions:t,onReport:n}))}));z.displayName="Comment_Internal";let Y=5,K=1,j=16,q=50,G=200;function V(e){return e.reduce((e,t)=>e+1+V(t.children||[]),0)}let $=e=>{let{user:t,freeSignup:n,freeSignupEmail:o,pub:i,post:r,comments:l,reaction_token:s,depth:d,collapseAtDepth:u,onChange:m,pageSize:h,retainUserCollapseState:g,updateCommentReacted:f,parent:v,scrollRef:_,className:w,onStartReply:C,noHoverProfile:S,onProfileClick:N,hideContextMenu:E,noRestack:X,hideShare:k,contextMenuUseMobileBottomSheet:B}=e,T=h||j,[x,I]=(0,c.eJ)(!1),[L,P]=(0,c.eJ)(!1),[D,O]=(0,c.eJ)(T),[A,H]=(0,c.eJ)(-1),[J,z]=(0,c.eJ)(new Set(l.map(e=>{let{id:t}=e;return t}))),{iString:U,iPlural:Y}=(0,b.M1)();(0,c.d4)(()=>{A>=0&&window.scrollTo(window.scrollX,A)},[A]);let K=(0,Z.s)(),q=(0,R.z)(e=>{K.open({pub:i,post:r,commentId:e,comments:l,user:null!=t?t:void 0,utm_campaign:F.VX.commentListShareCta})});if(0===(l||[]).length)return null;let[G,$]=y()(null!=l?l:[],e=>{let{id:n,user_id:o}=e;return J.has(n)||o===(null==t?void 0:t.id)}),Q=G.slice(0,D);return(0,a.BX)("div",{className:p()("comment-list",w,{"has-new-comments":$.length>0}),children:[$.length>0&&(0,a.tZ)(M.zx,{size:"sm",priority:"secondary-outline",onClick:()=>{setTimeout(()=>{z(new Set(l.map(e=>{let{id:t}=e;return t}))),P(!1)},0),P(!0)},children:L?Y("loading 1 new reply","loading %1 new replies",V($)):Y("1 new reply","%1 new replies",V($))}),(0,a.tZ)("div",{className:"comment-list-items",children:Q.map(e=>(0,a.tZ)(W,{user:t,freeSignup:n,freeSignupEmail:o,pub:i,post:r,comment:e,parent:v,reaction_token:s,collapseAtDepth:u,depth:d||0,onChange:m,scrollRef:_,retainUserCollapseState:g,onStartReply:C,noHoverProfile:S,onShareComment:q,onProfileClick:N,hideContextMenu:E,noRestack:X,updateCommentReacted:f,hideShare:k,contextMenuUseMobileBottomSheet:B},e.id))}),G.length>Q.length&&(0,a.tZ)(M.zx,{size:"sm",priority:"secondary-outline",loading:x,onClick:()=>{H(window.scrollY),setTimeout(()=>{O(D+T),I(!1)},0),I(!0)},children:U("Load More")})]})};$.displayName="CommentList";let Q=(0,d.memo)($);Q.displayName="CommentList";let ee=Q;function et(e){let[t,n]=(0,c.eJ)(null),o=(0,d.useMemo)(()=>({openBanDialog:n}),[]);return(0,a.BX)(en.Provider,{value:o,children:[(0,a.tZ)(ee,(0,i._)({},e)),(0,a.tZ)(E.Gg,(0,r._)((0,i._)({},t),{onClose:()=>n(null),onBan:(t,n)=>{let{onChange:o}=e;o?o((0,r._)((0,i._)({},t),{user_banned:!0,bans:n.concat(t.bans)})):document.location.href=(0,L.Os)(e.post,e.pub)}}))]})}let en=(0,d.createContext)({openBanDialog:()=>void 0})},41990:function(e,t,n){n.d(t,{_:()=>z});var o=n(7409),i=n(99282),r=n(58865),l=n(16584),a=n(98661),s=n(30396),d=n(94184),c=n.n(d),u=n(80569),p=n.n(u),m=n(93666),h=n(18787),g=n(96726),f=n(42493),v=n(347),y=n(95441),_=n(8923),w=n(16451),C=n(68833),S=n(48980),b=n(98914),Z=n(52513),R=n(56187),N=n(46638),E=n(12900),X=n(15771),k=n(82402),B=n(19081),T=n(43570),x=n(58175),I=n(440),L=n(70379),P=n(37155),D=n(31377),M=n(60308),O=n(63651),A=n(84864),F=n(60648);function H(){let e=(0,r._)(["Only "," subscribers can comment on this post"]);return H=function(){return e},e}let J="commentInput",z=(0,a.forwardRef)((e,t)=>{let{commentBeingEdited:n,parent:r,post:a,autoFocus:d,formClassName:u,saveEdit:m,onCancel:h,onSuccess:g,user:f,freeSignup:w,freeSignupEmail:Z,pub:R,token:E,bannedFromNotes:X,alwaysShowButtons:k,mediaClipId:T}=e,{iString:x}=(0,y.M1)(),I=(0,L.pm)(),D=(0,_.Sn)(),{isOAuthProvider:H,oauthAccessToken:z}=(0,_.wg)(),[U,W]=(0,s.eJ)(!1),[Y,K]=(0,s.eJ)(null),[j,q]=(0,s.eJ)(!1),G=(0,s.Ye)(()=>{if("undefined"!=typeof localStorage){let e=JSON.parse(localStorage.getItem(J)||"{}");if(e.postId===a.id)return{value:e.value,alsoShareToNotes:!!e.alsoShareToNotes};localStorage.removeItem(J)}},[]),Q=(0,o._)({value:null==n?void 0:n.body,alsoShareToNotes:!1,loading:!1,error:null},G),[{value:ee,alsoShareToNotes:et,loading:en,error:eo},ei]=(0,s.eJ)(Q),er=e=>ei(t=>(0,i._)((0,o._)({},t),{value:e})),el=(0,s.sO)(null),ea=(0,s.sO)(null);(0,s.aP)(t,()=>({focus(){var e;null===(e=el.current)||void 0===e||e.focus()}}),[]),(0,s.d4)(()=>{if(d){var e;null===(e=el.current)||void 0===e||e.focus()}},[]);let es=!(null==f?void 0:f.name),ed=(0,s.sO)(),ec=async()=>{var e;(0,C.j)(C.FP.COMMENT_PAYWALL_SHOWN,{post_id:a.id,post_type:a.type,parent_id:null==r?void 0:r.id}),await (null===(e=ed.current)||void 0===e?void 0:e.open())},eu=(0,s.sO)(),ep=async()=>{(0,C.j)(C.FP.FINISH_MAGIC_LOGIN_MODAL_SHOWN,{post_id:a.id,post_type:a.type,parent_id:null==r?void 0:r.id});let e=eu.current;e&&(await ef(),await e.open())},em=(0,s.sO)(),eh=async()=>{var e;(0,C.j)(C.FP.PROFILE_UPDATER_SHOWN,{post_id:a.id,parent_id:null==r?void 0:r.id}),await (null===(e=em.current)||void 0===e?void 0:e.open())},eg=(0,s.sO)(!1),ef=async()=>{if(!f){console.error("cannot sendLoginEmail, user not defined");return}if(!eg.current){eg.current=!0;try{var e;let t=await (0,S.rd)("/api/v1/email-login",{method:"POST",json:{email:f.email,redirect:null===(e=document.location.href.split("?")[0])||void 0===e?void 0:e.split("#")[0]}});"optional"===t.verification_code&&(W(!0),t.onboarding_redirect&&K(t.onboarding_redirect))}catch(e){alert((0,b.zx)(e))}}},ev=()=>{localStorage.setItem(J,JSON.stringify({postId:a.id,value:ee,alsoShareToNotes:et}))},ey=async()=>{if(n){ei(e=>(0,i._)((0,o._)({},e),{loading:!0}));try{let e=await (null==m?void 0:m(ee));ew(e)}catch(e){ei(t=>(0,i._)((0,o._)({},t),{loading:!1,error:e}))}}else e_()},e_=async function(){var e;let{profileUpdated:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(en)return;if(!(0,A.canPostComments)(f,a,R).canReply){ev(),await ec(),await (0,P.g)(600),ei(e=>(0,i._)((0,o._)({},e),{error:x("Please sign in.")}));return}if(es&&!t){ev(),H?(q(!0),ei(e=>(0,i._)((0,o._)({},e),{loading:!1,error:x("Please set your profile name to comment.")}))):(q(!1),await eh(),await (0,P.g)(600),ei(e=>(0,i._)((0,o._)({},e),{error:x("Please update your profile.")})));return}ei(e=>(0,i._)((0,o._)({},e),{loading:!0}));let n={body:null===(e=el.current)||void 0===e?void 0:e.value,token:E};T&&(n.mediaClipId=T);try{let e;if(et){let t=await D.post("/api/v1/comment/attachment").send({type:"link",url:(0,M.uRy)(R,a)}),i=null==t?void 0:t.body;if(i){let t=(0,o._)({},n);t.attachmentIds=[i.id],e=await D.post("/api/v1/comment/feed").send(t)}else console.warn("Error creating attachment")}r&&(n.parent_id=r.id);let t=await D.post("/api/v1/post/".concat(a.id,"/comment")).send(n);if(localStorage.removeItem(J),!(null==f?void 0:f.profile_set_up_at)){let{body:{count:e}}=await p().get("/api/v1/user/profile_role_count");if(e>=2){let e=(0,M.n1t)("".concat((0,M.ZJn)(),"/profile/start"),{commentProfileFlow:!0,next:(0,N.aE)(a,t.body,R)});return(0,b.uX)(e),!1}}ew({notesComment:e,res:t})}catch(e){e.response&&403===e.response.statusCode&&(f&&f.is_magic?await ep():await ec()),ei(t=>(0,i._)((0,o._)({},t),{loading:!1,error:e}))}},ew=e=>{let{res:t,notesComment:n}=e;if(!1!==t){if(g&&!es){if(et&&n){let e=(0,O.Sgq)(n.body);I.popToast(t=>(0,l.tZ)(L.FN,(0,i._)((0,o._)({},t),{text:x("Shared to Notes"),cta:x("View Now"),href:e})))}er(""),g(t.body)}else{let e=(0,N.Os)(a,R);H?(0,b.uX)((0,N.fg)(a,R,null!=z?z:"")):window.location.pathname===e?window.location.reload():(0,b.uX)((0,N.Os)(a,R,et?{feedCommentUrl:(0,O.Sgq)(t.body)}:{}))}ei(e=>(0,i._)((0,o._)({},e),{loading:!1}))}};return(0,l.tZ)(v.h,{children:(0,l.BX)(B.hs,{"data-test-id":"comment-input",flex:"grow",className:c()({comment:n}),children:[(0,l.tZ)("form",{className:c()(F.Z.form,u),onSubmit:e=>{e.preventDefault(),ey()},ref:ea,children:(0,l.tZ)($,{user:f,commentBeingEdited:n,post:a,pub:R,value:ee,bodyInputRef:el,onInput:e=>{let t=e.currentTarget.value;if(!(0,A.canPostComments)(f,a,R).canReply){e.preventDefault(),ec();return}er(t)},onKeyDown:e=>{var t,n;if(null==f?void 0:f.is_magic){e&&e.preventDefault(),ep();return}if(!(0,A.canPostComments)(f,a,R).canReply){e.preventDefault(),ec();return}"Escape"===e.key&&(null===(t=el.current)||void 0===t?void 0:t.value.trim())===""?(null===(n=el.current)||void 0===n||n.blur(),null==h||h()):"Enter"===e.key&&e.metaKey&&ey()},bannedFromNotes:X,alsoShareToNotes:et,onShareToNotesChange:()=>ei(e=>(0,i._)((0,o._)({},e),{alsoShareToNotes:!et})),onCancel:()=>{h?h():er("")},error:eo,loading:en,alwaysShowButtons:k,isReplying:!!r,showProfileSetupLinkOnError:j})}),(0,l.tZ)(V,{user:f,freeSignup:w,freeSignupEmail:Z,pub:R,post:a,token:E,profileUpdaterRef:em,modalPaywallRef:ed,finishMagicLoginModalRef:eu,otpLoginEnabled:U,onboardingRedirect:Y,onProfileUpdaterSuccess:e=>"boolean"!=typeof e||!!(e&&e_({profileUpdated:e}))})]})})}),U=e=>{let{error:t,showProfileSetupLinkOnError:n}=e,{iString:o}=(0,y.M1)();if(!t)return null;let i="string"==typeof t?t:(0,b.zx)(t,"Something went wrong.");return(0,l.BX)(B.hs,{direction:"column",gap:4,children:[(0,l.tZ)(T.Vp,{priority:"secondary",theme:"error",flex:"auto",children:i}),n&&(0,l.tZ)(x.xv.B3,{children:(0,l.tZ)("a",{href:"".concat((0,M.ZJn)(),"/profile/edit"),target:"_blank",children:o("Set up profile")})})]})},W=e=>{let{alsoShareToNotes:t,onChange:n}=e,{iString:o}=(0,y.M1)();return(0,l.BX)(B.hs,{as:"label",gap:12,alignItems:"center",justifyContent:"center",children:[(0,l.tZ)(k.X,{name:"also_feed",checked:t,onChange:n}),(0,l.tZ)(x.xv.B3,{color:"secondary",children:o("Also share to Notes")})]})},Y=e=>{let{bodyInputRef:t,value:n,onInput:o,onKeyDown:i,iString:r,disabled:a}=e;return(0,l.tZ)(I.l,{ref:t,name:"body",placeholder:r("Write a comment..."),defaultRows:4,maxRows:24,value:n||"",onInput:o,onKeyDown:i,className:F.Z.input,disabled:a,"aria-label":r("Write a comment...")})},K=e=>{let{isEditing:t,isReplying:n,bannedFromNotes:o,alsoShareToNotes:i,onShareToNotesChange:r,onCancel:a,loading:s,disableSubmit:d}=e;return(0,l.BX)(B.X2,{alignItems:"center",justifyContent:"space-between",children:[!t&&!o&&(0,l.tZ)(W,{alsoShareToNotes:i,onChange:r}),(0,l.BX)(j,{children:[(0,l.tZ)(q,{onCancel:a}),(0,l.tZ)(G,{isEditing:t,isReplying:n,loading:s,disabled:d})]})]})},j=e=>{let{children:t}=e;return(0,l.tZ)(B.X2,{gap:8,justifyContent:"end",flex:"grow",children:t})},q=e=>{let{onCancel:t}=e,{iString:n}=(0,y.M1)();return(0,l.tZ)(X.zx,{priority:"secondary",onClick:t,children:n("Cancel")})},G=e=>{let{isEditing:t,isReplying:n,loading:o,disabled:i}=e,{iString:r}=(0,y.M1)();return(0,l.tZ)(X.zx,{priority:"primary",type:"submit",loading:o,disabled:i,children:r(t?"Save":n?"Reply":"Post")})},V=e=>{var t,n;let{user:o,freeSignup:i,freeSignupEmail:r,pub:a,post:s,token:d,profileUpdaterRef:c,modalPaywallRef:u,finishMagicLoginModalRef:p,otpLoginEnabled:v,onboardingRedirect:_,onProfileUpdaterSuccess:w}=e,{iString:C,iTemplate:S}=(0,y.M1)();return(0,l.BX)(g.h,{children:[(0,l.tZ)(f.EB,{ref:c,user:o,freeSignup:i,freeSignupEmail:r,optionalPhoto:!0,token:d,text:C("Save & Post Comment"),onBeforeClose:w}),(0,l.tZ)(h.sF,{ref:u,user:o,freeSignup:i,freeSignupEmail:r,publication:a,post:s,title:S(H(),(0,D.isFoundingAudience)(s.audience)?"founding":"paid"),reauthenticationTitle:C("To post a comment, please re-authenticate.")}),(0,l.BX)(m.p,{ref:p,className:"finish-magic-login-modal",children:[(0,l.tZ)("h4",{children:C("Check your email")}),(0,l.tZ)("p",{children:C("For your security, we need to re-authenticate you.")}),v?(0,l.BX)(l.HY,{children:[(0,l.BX)(x.xv,{as:"p",translated:!0,children:["Click the link we sent to ",I18N.p(null!==(t=null==o?void 0:o.email)&&void 0!==t?t:"")," or enter the code below."]}),(0,l.tZ)(Z.E,{email:null==o?void 0:o.email,redirect:_||document.location.href})]}):(0,l.BX)(x.xv,{as:"p",translated:!0,children:["Click the link we sent to ",I18N.p(null!==(n=null==o?void 0:o.email)&&void 0!==n?n:""),", or"," ",(0,l.tZ)("a",{href:(0,M.uXE)({for_pub:a.subdomain,with_password:!0}),native:!0,children:"click here to sign in"}),"."]})]})]})},$=e=>{let{user:t,commentBeingEdited:n,post:o,pub:i,value:r,bodyInputRef:a,onInput:s,onKeyDown:d,bannedFromNotes:c,alsoShareToNotes:u,onShareToNotesChange:p,onCancel:m,error:h,loading:g,alwaysShowButtons:f,isReplying:v,showProfileSetupLinkOnError:_}=e,{iString:C}=(0,y.M1)(),S=!(null==r?void 0:r.trim());return(0,l.BX)(l.HY,{children:[(0,l.tZ)(w.Zb,{size:32,user:t}),(0,l.BX)(B.tu,{flex:"grow",gap:8,children:[n&&(0,l.tZ)(R.J,{comment:n,post:o,pub:i,isCollapsed:!0,userBanned:!1,hideContextMenu:!0,onChange:()=>{},startEdit:()=>{},startReport:()=>{},openBan:()=>{}}),(0,l.tZ)(Y,{bodyInputRef:a,value:r,onInput:s,onKeyDown:d,iString:C,disabled:g}),(0,l.tZ)(U,{error:h,showProfileSetupLinkOnError:_}),(0,l.tZ)(E.H,{expanded:!S||!!f,clip:!1,children:(0,l.tZ)(K,{isReplying:v,isEditing:!!n,bannedFromNotes:c,alsoShareToNotes:u,onShareToNotesChange:p,onCancel:m,loading:g,disableSubmit:S})})]})]})}},1980:function(e,t,n){n.d(t,{l:()=>i});var o=n(16584);let i=()=>(0,o.BX)("div",{className:"comment-silhouette",children:[(0,o.tZ)("div",{className:"comment-silhouette-head"}),(0,o.BX)("div",{className:"comment-silhouette-content",children:[(0,o.tZ)("div",{className:"comment-silhouette-meta"}),(0,o.tZ)("div",{className:"comment-silhouette-body"}),(0,o.tZ)("div",{className:"comment-silhouette-actions"})]})]})},17172:function(e,t,n){n.d(t,{aZ:()=>r});var o=n(98661),i=n(41302);function r(e){let t=(0,o.useRef)({isDragging:!1,didDrag:!1,startX:0,startY:0,startTime:0,scrollLeft:0,velX:0,pointerId:0,momentumId:null,overscrollX:0}),{handleOverscroll:n,resetOverscroll:r}=function(e){let t=()=>(e.current&&i.Z.overscrollTransition&&(e.current.classList.add(i.Z.overscrollTransition),e.current.style.transform="",setTimeout(()=>{e.current&&i.Z.overscrollTransition&&e.current.classList.remove(i.Z.overscrollTransition)},200)),0);return{handleOverscroll:(e,n,o)=>{let r=e.scrollWidth-e.clientWidth,l=o;i.Z.overscrollTransition&&e.classList.remove(i.Z.overscrollTransition);let a=t=>{let n=-t/5;return e.style.transform="translateX(".concat(n,"px)"),n};return n<0?(e.scrollLeft=0,l=a(n)):n>r?(e.scrollLeft=r,l=a(n-r)):(l=0,t(),e.scrollLeft=n),l},resetOverscroll:t}}(e),l=()=>{null!==t.current.momentumId&&(cancelAnimationFrame(t.current.momentumId),t.current.momentumId=null)},a=()=>{l(),t.current.momentumId=requestAnimationFrame(s)},s=()=>{if(!e.current)return;let n=t.current;e.current.scrollLeft+=n.velX,n.velX*=.9,Math.abs(n.velX)>.5&&(n.momentumId=requestAnimationFrame(s))},d=()=>{let t=e.current;return!!t&&t.scrollWidth>t.clientWidth},c=n=>{let o=t.current;if(!o.isDragging||n.pointerId!==o.pointerId)return;window.removeEventListener("pointerup",c),window.removeEventListener("pointercancel",c),o.didDrag&&n.preventDefault(),o.isDragging=!1,o.overscrollX=r();let i=e.current;if(i&&(i.releasePointerCapture(n.pointerId),o.didDrag)){let e=e=>{e.preventDefault(),e.stopImmediatePropagation()};i.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>{i.removeEventListener("click",e,{capture:!0})},100),o.didDrag=!1}a()};return{props:{onPointerDown:n=>{if("mouse"!==n.pointerType||0!==n.button||n.ctrlKey||n.metaKey||n.shiftKey||n.altKey||!d()||!e.current)return;n.preventDefault();let o=t.current;o.isDragging=!0,o.didDrag=!1,o.startX=n.pageX,o.startY=n.pageY,o.startTime=Date.now(),o.scrollLeft=e.current.scrollLeft,o.pointerId=n.pointerId,l(),window.addEventListener("pointerup",c),window.addEventListener("pointercancel",c)},onPointerMove:o=>{let i=t.current;if(!i.isDragging||!e.current||o.pointerId!==i.pointerId||!d())return;o.preventDefault(),!i.didDrag&&function(e,t,n,o,i){let r=Math.abs(e-n),l=Math.abs(t-o),a=Date.now()-i;return r>2||l>2||a>50}(o.pageX,o.pageY,i.startX,i.startY,i.startTime)&&(e.current.setPointerCapture(o.pointerId),i.didDrag=!0);let r=o.pageX-i.startX,l=e.current.scrollLeft,a=i.scrollLeft-r;i.overscrollX=n(e.current,a,i.overscrollX),i.velX=e.current.scrollLeft-l},onLostPointerCapture:c},didDrag:()=>t.current.didDrag,hasOverflow:d}}}}]);