(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{1137:function(e,t,s){"use strict";s.r(t),s.d(t,"default",(function(){return b}));var a,o=s(0),i=s(1),r=s.n(i),l=s(8),d=s(4),c=s(7),n=s.n(c);const p=Object(d.f)({other:{id:"report.categories.other",defaultMessage:"Other"},spam:{id:"report.categories.spam",defaultMessage:"Spam"},violation:{id:"report.categories.violation",defaultMessage:"Content violates one or more server rules"}});class h extends r.a.PureComponent{constructor(){super(...arguments),this.handleClick=()=>{const{id:e,disabled:t,onSelect:s}=this.props;t||s(e)}}render(){const{id:e,text:t,disabled:s,selected:a,children:i}=this.props;return Object(o.a)("div",{tabIndex:"0",role:"button",className:n()("report-reason-selector__category",{selected:a,disabled:s}),onClick:this.handleClick},void 0,a&&Object(o.a)("input",{type:"hidden",name:"report[category]",value:e}),Object(o.a)("div",{className:"report-reason-selector__category__label"},void 0,Object(o.a)("span",{className:n()("poll__input",{active:a,disabled:s})}),t),a&&i&&Object(o.a)("div",{className:"report-reason-selector__category__rules"},void 0,i))}}class u extends r.a.PureComponent{constructor(){super(...arguments),this.handleClick=()=>{const{id:e,disabled:t,onToggle:s}=this.props;t||s(e)}}render(){const{id:e,text:t,disabled:s,selected:a}=this.props;return Object(o.a)("div",{tabIndex:"0",role:"button",className:n()("report-reason-selector__rule",{selected:a,disabled:s}),onClick:this.handleClick},void 0,Object(o.a)("span",{className:n()("poll__input",{checkbox:!0,active:a,disabled:s})}),a&&Object(o.a)("input",{type:"hidden",name:"report[rule_ids][]",value:e}),t)}}let b=Object(d.g)(a=class extends r.a.PureComponent{constructor(){super(...arguments),this.state={category:this.props.category,rule_ids:this.props.rule_ids||[],rules:[]},this._save=()=>{const{id:e,disabled:t}=this.props,{category:s,rule_ids:a}=this.state;t||Object(l.a)().put("/api/v1/admin/reports/"+e,{category:s,rule_ids:a}).catch((e=>{console.error(e)}))},this.handleSelect=e=>{this.setState({category:e},(()=>this._save()))},this.handleToggle=e=>{const{rule_ids:t}=this.state;t.includes(e)?this.setState({rule_ids:t.filter((t=>t!==e))},(()=>this._save())):this.setState({rule_ids:[...t,e]},(()=>this._save()))}}componentDidMount(){Object(l.a)().get("/api/v1/instance").then((e=>{this.setState({rules:e.data.rules})})).catch((e=>{console.error(e)}))}render(){const{disabled:e,intl:t}=this.props,{rules:s,category:a,rule_ids:i}=this.state;return Object(o.a)("div",{className:"report-reason-selector"},void 0,Object(o.a)(h,{id:"other",text:t.formatMessage(p.other),selected:"other"===a,onSelect:this.handleSelect,disabled:e}),Object(o.a)(h,{id:"spam",text:t.formatMessage(p.spam),selected:"spam"===a,onSelect:this.handleSelect,disabled:e}),Object(o.a)(h,{id:"violation",text:t.formatMessage(p.violation),selected:"violation"===a,onSelect:this.handleSelect,disabled:e},void 0,s.map((t=>Object(o.a)(u,{id:t.id,text:t.text,selected:i.includes(t.id),onToggle:this.handleToggle,disabled:e},t.id)))))}})||a}}]);
//# sourceMappingURL=4-3249cb8bc5bf0e8816f9.chunk.js.map