1import{j as e,g8 as V,dO as W,H as r,eo as X,jg as Z,o as E,r as x,je as _,F as y,B as L,U as c,p as ee,q as te,s as oe,aD as se,a4 as ne,ac as ie,d as re,G as U,aS as R,aM as ae,ji as $,aT as ce,aU as le,c as K,aq as de,aV as me,ae as T,b9 as he}from"./index-B-8CDiEL.js";import{r as w,V as pe,R as ue}from"./InfoBar-index-DialLV9J.js";import{B as fe}from"./Badge-index-BwHdlqvF.js";import{S as ge}from"./SmartTime-index-D7lZYwc0.js";import{T as Ce}from"./TextArea-index-bubeXjOX.js";import{L as we}from"./LanguageSelection-index-Dn3Syu0G.js";import{u as xe,b as ve,P as ke}from"./IconLock-Cid9l6sy.js";const be=s=>e.jsxs(V,{viewBox:"0 0 24 24",...s,children:[e.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v1.91l.01.01L1 14c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z"})]}),je=s=>e.jsxs(V,{viewBox:"0 0 24 24",...s,children:[e.jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z"})]}),Se=({theme:s,isActive:o,isDislike:t})=>o?t?s.colors.textNegative:s.colors.textHighlighted:s.colors.textSecondary,Re=r.button.withConfig({componentId:"sc-c3defa2a-0"})(["",";padding:0.3125rem 0;color:",";transition:0.2s ease color;margin:0 0.5rem;:hover{color:",";}"],Z,Se,({theme:s})=>s.colors.textPrimary),Ie=r(fe).withConfig({componentId:"sc-c3defa2a-1"})(["font-size:",";"],({theme:s})=>s.fontSizes.small),F=E({like:{id:"app.RatingButton.like",defaultMessage:"Like",description:"Shown when the user hovers over an inactive like rating"},dislike:{id:"app.RatingButton.dislike",defaultMessage:"Dislike",description:"Shown when the user hovers over an inactive dislike rating"},removeRating:{id:"app.RatingButton.removeRating",defaultMessage:"Remove rating",description:"Shown when the user hovers over an active rating"}}),Me=(s,o)=>s?F.removeRating:o?F.dislike:F.like,Be=({intl:s,count:o=0,isActive:t=!1,isDislike:n=!1,onClick:i})=>e.jsxs(Re,{type:"button",title:s.formatMessage(Me(t,n)),isActive:t,isDislike:n,onClick:i,children:[n?e.jsx(be,{}):e.jsx(je,{}),e.jsx(Ie,{children:e.jsx(X,{value:o})})]}),N=W(Be),Fe=r.form.withConfig({componentId:"sc-4cb70fc3-0"})(["margin:0 -0.25rem;"]),ye=r(y).withConfig({componentId:"sc-4cb70fc3-1"})(["text-align:end;margin:1rem -0.2rem;margin-bottom:2rem;"]),q=E({leaveConfirmation:{id:"app.CommentForm.leaveConfirmation",defaultMessage:"Your comment has not yet been submitted. Are you sure you want to leave?",description:"Prompt shown when a user wants to leave the page will a comment form is open"},textPlaceholder:{id:"app.CommentForm.textPlaceholder",defaultMessage:"Write a comment and tell the world about your opinion!",description:"Placeholder for the text input"}});class Le extends x.PureComponent{constructor(){super(...arguments),this.state={isOpen:!1,text:""},this.onTextChange=o=>{this.setState({text:o.target.value}),this.updateBackup(o.target.value)},this.onTextFocus=()=>{if(!this.props.viewer){w();return}this.setState({isOpen:!0})},this.onTextBlur=()=>{this.state.text||this.clearBackup()},this.onSelectLanguage=o=>{this.setState({language:o})},this.onCancelClick=o=>{o.preventDefault(),this.setState({isOpen:!1,text:""}),this.props.onCancel&&this.props.onCancel(),this.clearBackup()},this.onSubmit=o=>{if(o.preventDefault(),!this.props.viewer){w();return}const{text:t}=this.state,n=this.state.language||this.props.language;!t||!n||(this.props.onSubmit&&this.props.onSubmit({text:t,langCode:n.code,langName:n.nativeName||n.name}),this.setState({isOpen:!1,text:""}),this.clearBackup())}}getBackup(){const{backupId:o}=this.props;try{const t=sessionStorage.getItem(`commentBackup:${o}`);if(o&&t)return t}catch{}return null}updateBackup(o){const{backupId:t}=this.props;if(t)try{sessionStorage.setItem(`commentBackup:${t}`,o)}catch{}}clearBackup(){const{backupId:o}=this.props;if(o)try{sessionStorage.removeItem(`commentBackup:${o}
1`)}catch{}}componentDidMount(){const o=this.getBackup();o?this.setState({text:o,isOpen:!0}):this.setState({text:this.props.defaultText})}render(){const{intl:o,isEdit:t}=this.props,n=this.props.isOpen||this.state.isOpen,i=!!this.state.text&&!!this.state.text.trim(),l=this.state.language||this.props.language;return e.jsxs(Fe,{onSubmit:this.onSubmit,children:[e.jsx(_,{when:i,message:o.formatMessage(q.leaveConfirmation)}),e.jsx(y,{children:e.jsx(Ce,{dir:"auto",placeholder:o.formatMessage(q.textPlaceholder),required:!0,expand:n,autoFocus:this.props.autoFocus,value:this.state.text,onChange:this.onTextChange,onFocus:this.onTextFocus,onBlur:this.onTextBlur})}),e.jsx(y,{hidden:!n,children:e.jsx(we,{noMargin:!0,showSelectedLangs:!0,selectedLangs:l?[l]:void 0,onSelect:this.onSelectLanguage})}),e.jsxs(ye,{hidden:!n,children:[e.jsx(L,{onClick:this.onCancelClick,children:e.jsx(c,{id:"app.CommentForm.cancel",defaultMessage:"Cancel",description:"Cancel button label for the comment form"})}),e.jsxs(L,{type:"submit",primary:!0,disabled:!i||!l,children:[!t&&e.jsx(c,{id:"app.CommentForm.post",defaultMessage:"Post comment",description:"Submit button label when creating a new comment"}),t&&e.jsx(c,{id:"app.CommentForm.save",defaultMessage:"Save comment",description:"Submit button label when editing a comment"})]})]})]})}}const Ee=W(Le),Te=r.div.withConfig({componentId:"sc-6cba1c84-0"})(["width:100%;overflow-x:auto;margin-top:1rem;padding:0.25rem 0;",";"],s=>{const o=[];return s.withStartShadow&&o.push("inset 11px 0px 8px -10px rgba(0, 0, 0, 0.5)"),s.withEndShadow&&o.push("inset -11px 0px 8px -10px rgba(0, 0, 0, 0.5)"),o.length?`box-shadow: ${o.join(",")}`:""});class Ae extends x.PureComponent{constructor(){super(...arguments),this.state={withStartShadow:!1,withEndShadow:!1},this.update=()=>{const o=this.container.scrollLeft,t=o+this.container.offsetWidth,n=this.container.scrollWidth;this.setState({withStartShadow:o>0,withEndShadow:t<n})},this.refContainer=o=>{this.container=o}}componentDidMount(){this.update(),window.addEventListener("resize",this.update)}componentWillUnmount(){window.removeEventListener("resize",this.update)}render(){return e.jsx(Te,{...this.props,...this.state,onScroll:this.update,ref:this.refContainer})}}const p=E({userIsBlocked:{id:"app.Comment.userBlocked",defaultMessage:"Author has been blocked"},blockComment:{id:"app.Comment.blockComment",defaultMessage:"Block Comment"},blockAuthor:{id:"app.Comment.blockAuthor",defaultMessage:"Block Author"},confirmBlock:{id:"app.Comment.confirmBlock",defaultMessage:"Confirm Block"},blockAuthorConfirmation:{id:"app.Comment.blockAuthorConfirmation",defaultMessage:"Are you sure that you want to block this author?"},blockCommentConfirmation:{id:"app.Comment.blockCommentConfirmation",defaultMessage:"Are you sure that you want to block this comment?"}}),Oe=({ownerId:s,comment:o,deleteComment:t})=>{const{formatMessage:n}=ee(),i=te(),{graphqlError:l,error:u,success:j}=oe(),v=se(),f=xe(),m=ne(),[g,k]=x.useState(!1),I=x.useCallback(async()=>{g||!await v(n(p.confirmBlock),e.jsx(e.Fragment,{children:e.jsx(b,{children:n(p.blockCommentConfirmation)})}),n(ie.block))||!m.current||(k(!0),await t(o.id),m.current&&k(!1))},[v,n,t,o.id,m,g]),[S,{loading:h}]=re(ve,{onCompleted:()=>j(n(p.userIsBlocked)),onError:a=>l(a)}),M=x.useCallback(async()=>{if(!h)try{const a=await f("block",e.jsxs(e.Fragment,{children:[e.jsx(b,{children:n(p.blockAuthorConfirmation)}),e.jsx(b,{children:e.jsx("a",{href:i.toUser(o.owner.id),target:"_blank",rel:"noopener noreferrer",children:o.owner.name})})]}));if(h||!m.current)return;await S({variables:{userId:s,reason:a}})}catch(a){if(a instanceof ke)return;if(a instanceof Error){u(a.message);return}throw a}},[f,n,i,o.owner.id,o.owner.name,S,s,h,u,m]);return e.jsxs(e.Fragment,{children:[e.jsx(d,{negative:!0,onClick:()=>{I()},disabled:g,title:g?n(U.loading):"",children:n(p.blockComment)}),e.jsx(d,{negative:!0,onClick:()=>{M()},disabled:h||o.owner.role===R.BLOCKED,title:h?n(U.loading):o.owner.role===R.BLOCKED?n(p.userIsBlocked):"",children:n(p.blockAuthor)})]})},De=r.div.withConfig({componentId:"sc-711b01df-0"})(["display:flex;margin-top:1rem;padding:0.75rem;border-radius:0.125rem;background:",";"],({theme:s,even:o})=>o?s.colors.backgroundPrimary:s.colors.backgroundSecondary),Pe=r.div.withConfig({componentId:"sc-711b01df-1"})(["flex-grow:0;flex-shrink:0;display:none;",";@media (min-width:35rem){display:block;}"],T("0.75rem")),ze=r.div.withConfig({componentId:"sc-711b01df-2"})(["flex:1;max-width:100%;"]),He=r.div.withConfig({componentId:"sc-711b01df-3"})(["display:flex;flex-wrap:wrap;font-size:",";line-height:1.25;"],({theme:s})=>s.fontSizes.small),Ue=r(K).withConfig({componentId:"sc-711b01df-4"})(["color:",";font-weight:bold;text-decoration:none;",";"],({theme:s})=>s.colors.textPrimary,T("0.5rem")),$e=r(ge).withConfig({componentId:"sc-711b01df-5"})(["color:",";"],({theme:s})=>s.colors.textSecondary),b=r.p.withConfig({componentId:"sc-711b01df-6"})(["margin:0.5rem 0;line-height:1.25;"]),Ne=r.section.withConfig({componentId:"sc-711b01df-7"})(["display:flex;> :first-child{",";}> :last-child{",";}"],he(0),T(0)),qe=r.div.withConfig({componentId:"sc-711b01df-8"})(["width:0.25rem;height:0;"]),d=r(L).withConfig({componentId:"sc-711b01df-9"})(["background:transparent;margin:0 0.25rem;color:",";font-size:",";:hover{color:",";}"],({theme:s})=>s.colors.textSecondary,({theme:s})=>s.fontSizes.small,({theme:s})=>s.colors.textPrimary),G=(s,o)=>s.filter(t=>t.parentId===o).map(t=>({...t,children:G(s,t.id)}));class A extends x.PureComponent{constructor(){super(...arguments),this.state={showResponseForm:!1,showEditForm:!1,showReportForm:!1,showReportStatus:!1,showRemovalConfirmation:!1},this.onEditClick=()=>{this.setState({showEditForm:!0,showRemovalConfirmation:!1})},this.onRemoveClick=()=>{this.setState({showRemovalConfirmation:!0})},this.onConfirmRemovalClick=()=>{const{deleteComment:o,comment:t}=this.props;o(t.id)},this.onCancelRemovalClick=()=>{this.setState({showRemovalConfirmation:!1})},this.onRespondClick=()=>
1{if(!this.props.viewer){w();return}this.setState({showResponseForm:!0,showRemovalConfirmation:!1})},this.onReportClick=()=>{if(!this.props.viewer){w();return}this.setState({showReportForm:!0})},this.onLikeClick=()=>{if(!this.props.viewer){w();return}const{comment:o,updateOrCreateRating:t,deleteRating:n}=this.props;o.viewerHasLiked?n(o.id):t(o.id,$.LIKE)},this.onDislikeClick=()=>{if(!this.props.viewer){w();return}const{comment:o,updateOrCreateRating:t,deleteRating:n}=this.props;o.viewerHasDisliked?n(o.id):t(o.id,$.DISLIKE)},this.onFormCancel=()=>{this.setState({showResponseForm:!1,showEditForm:!1,showReportForm:!1})},this.onFormSubmit=({text:o,langCode:t,langName:n})=>{const{comment:i,updateComment:l,createComment:u}=this.props;this.state.showEditForm?l(i,{commentId:i.id,payload:o,langCode:t,langName:n}):u({threadId:i.threadId,parentId:i.id,payload:o,langCode:t,langName:n}),this.setState({showResponseForm:!1,showEditForm:!1})},this.onReportSubmit=async({acceptedPrivacyPolicy:o,reason:t})=>{const{comment:n,reportComment:i}=this.props;await i(o,n.id,t),this.setState({showReportForm:!1,showReportStatus:!0})}}render(){const{linker:o,comment:t,comments:n,viewer:i,even:l=!1,smallAvatar:u=!1,allowReplies:j=!0,defaultCommentLanguage:v,onSeek:f,createComment:m,updateComment:g,deleteComment:k,reportComment:I,updateOrCreateRating:S,deleteRating:h}=this.props,M=u?"2rem":"3rem",a=t.owner.avatar,O=t.owner.avatarHigh,{showResponseForm:D,showEditForm:C,showReportForm:P,showReportStatus:Y,showRemovalConfirmation:B}=this.state,J=D||C||P,z=ce(t.langCode),Q=le(z);return e.jsxs(De,{even:l,children:[e.jsx(Pe,{children:e.jsx(K,{to:o.toUser(t.owner.id),rel:"author",children:e.jsx(de,{alt:t.owner.name,size:M,src:a?a.href:void 0,srcHighRes:O?O.href:void 0})})}),e.jsxs(ze,{children:[e.jsxs(He,{children:[e.jsx(Ue,{dir:"auto",to:o.toUser(t.owner.id),rel:"author",children:t.owner.name}),e.jsx($e,{time:t.created})]}),e.jsx(b,{dir:"auto",hidden:C,children:t.removed?e.jsx("em",{children:e.jsx(c,{id:"app.Comment.textRemoved",defaultMessage:"This comment has been removed.",description:"Text that will be shown for removed comments"})}):e.jsx("bdi",{lang:z,dir:Q,children:f?e.jsx(pe,{onSeek:f,children:t.payload}):t.payload})}),Y&&e.jsx(b,{children:e.jsx("em",{children:e.jsx(c,{id:"app.Comment.reportSent",defaultMessage:"Your report has been submitted. We will get back to you once we have investigated the comment.",description:"Text that will be shown after a report for a comment has been submitted"})})}),e.jsx(Ae,{children:e.jsxs(Ne,{hidden:J||t.removed,children:[j&&e.jsx(d,{onClick:this.onRespondClick,children:e.jsx(c,{id:"app.Comment.respond",defaultMessage:"Respond",description:"Label for respond to comment button"})}),t.viewerIsOwner&&e.jsx(d,{onClick:this.onEditClick,children:e.jsx(c,{id:"app.Comment.edit",defaultMessage:"Edit",description:"Label for edit comment button"})}),(j||t.viewerIsOwner)&&e.jsx(qe,{}),!t.removed&&e.jsx(N,{onClick:this.onLikeClick,count:t.likeCount,isActive:t.viewerHasLiked}),!t.removed&&e.jsx(N,{onClick:this.onDislikeClick,count:t.dislikeCount,isActive:t.viewerHasDisliked,isDislike:!0}),e.jsx(me,{}),t.viewerIsOwner&&!t.removed&&!B&&e.jsx(d,{negative:!0,onClick:this.onRemoveClick,children:e.jsx(c,{id:"app.Comment.remove",defaultMessage:"Remove",description:"Label for remove comment button"})}),B&&e.jsx(d,{negative:!0,onClick:this.onConfirmRemovalClick,children:e.jsx(c,{id:"app.Comment.confirmRemoval",defaultMessage:"Confirm removal",description:"Label for confirmation button when a removal is requested"})}),B&&e.jsx(d,{onClick:this.onCancelRemovalClick,children:e.jsx(c,{id:"app.Comment.cancelRemoval",defaultMessage:"Cancel",description:"Label for cancel button when a removal is requested"})}),!t.viewerIsOwner&&!t.removed&&i?.role!==R.ADMINISTRATOR&&e.jsx(d,{negative:!0,onClick:this.onReportClick,children:e.jsx(c,{id:"app.Comment.report",defaultMessage:"Report",description:"Label for report comment button"})}),i?.role===R.ADMINISTRATOR&&!t.removed&&!t.viewerIsOwner&&e.jsx(Oe,{ownerId:t.owner.id,comment:t,deleteComment:k})]})}),(D||C)&&e.jsx(Ee,{viewer:i,backupId:t.id,defaultText:C?t.payload:"",language:C?{code:t.langCode,name:t.langName,fallbacks:[]}:v,autoFocus:!0,isOpen:!0,isEdit:C,onCancel:this.onFormCancel,onSubmit:this.onFormSubmit}),P&&e.jsx(ue,{onCancel:this.onFormCancel,onSubmit:this.onReportSubmit}),G(n,t.id).map(H=>e.jsx(A,{linker:o,comment:H,comments:n,viewer:i,even:!l,smallAvatar:!0,allowReplies:!1,defaultCommentLanguage:v,onSeek:f,createComment:m,updateComment:g,deleteComment:k,reportComment:I,updateOrCreateRating:S,deleteRating:h},H.id))]})]})}}const Xe=ae(A);export{Ee as C,b as T,Xe as a};
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.