import{d as e}from"./objectSpread2-DtFdQpqy.js";import{a as t,n}from"./preload-helper-EQ20WQt-.js";import{c as r,l as i,o as a}from"./prop-types-DdDwMzX7.js";import{U as o,ct as s,pt as c}from"./poll-UAe1CGVf.js";import{Eo as l,Kt as u}from"./time-C7shVqCd.js";import{B as d,un as f}from"./status_quoted-CRoil4HW.js";import{t as p}from"./callout-uaDfPFxy.js";import{t as m}from"./comment-BCQg9aNe.js";var h=e(t()),g=n(),_=r({close:{id:`lightbox.close`,defaultMessage:`Close`}}),v=({onClose:e})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`h3`,{className:`report-dialog-modal__title`,children:(0,g.jsx)(a,{id:`report.thanks.title_actionable`,defaultMessage:`Thanks for reporting, we'll look into this.`})}),(0,g.jsx)(`div`,{className:`flex-spacer`}),(0,g.jsx)(`div`,{className:`report-dialog-modal__actions`,children:(0,g.jsx)(f,{onClick:e,children:(0,g.jsx)(a,{id:`report.close`,defaultMessage:`Done`})})})]}),y=({collection:e,onClose:t})=>{let n=i(),r=l(),{id:f,name:y,account_id:b}=e,x=o(b);(0,h.useEffect)(()=>{r(u())},[r]);let[S,C]=(0,h.useState)(`idle`),[w,T]=(0,h.useState)(`comment`),[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)([]),A=(0,h.useCallback)((e,t)=>{k(t?t=>[...t,e]:t=>t.filter(t=>t!==e))},[]),j=(0,h.useCallback)(()=>{C(`submitting`),r(d({account_id:b,status_ids:[],collection_ids:[f],forward_to_domains:O,comment:E,forward:O.length>0,category:`spam`},()=>{C(`submitted`),T(`thanks`)},()=>{C(`error`)}))},[b,E,r,f,O]);if(!x)return null;let M=x.get(`acct`).split(`@`)[1],N=!!M,P;switch(w){case`comment`:P=(0,g.jsx)(m,{modalTitle:(0,g.jsx)(a,{id:`report.collection_comment`,defaultMessage:`Why do you want to report this collection?`}),submitError:S===`error`&&(0,g.jsx)(p,{variant:`error`,title:(0,g.jsx)(a,{id:`report.submission_error`,defaultMessage:`Report could not be submitted`}),children:(0,g.jsx)(a,{id:`report.submission_error_details`,defaultMessage:`Please check your network connection and try again later.`})}),onSubmit:j,isSubmitting:S===`submitting`,isRemote:N,comment:E,domain:M,onChangeComment:D,statusIds:[],selectedDomains:O,onToggleDomain:A});break;case`thanks`:P=(0,g.jsx)(v,{onClose:t})}return(0,g.jsxs)(`div`,{className:`modal-root__modal report-dialog-modal`,children:[(0,g.jsxs)(`div`,{className:`report-modal__target`,children:[(0,g.jsx)(s,{className:`report-modal__close`,title:n.formatMessage(_.close),icon:`times`,iconComponent:c,onClick:t}),(0,g.jsx)(a,{id:`report.target`,defaultMessage:`Report {target}`,values:{target:(0,g.jsx)(`strong`,{children:y})}})]}),(0,g.jsx)(`div`,{className:`report-dialog-modal__container`,children:P})]})};export{y as ReportCollectionModal};
//# sourceMappingURL=report_collection_modal-BlXd6sYL.js.map