"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[9838],{9838:(e,t,s)=>{s.r(t),s.d(t,{default:()=>g});var i,n=s(62688),a=s.n(n),o=(s(43813),s(4290),s(42689)),r=s.n(o),d=s(97023),l=s.n(d),m=s(14778),u=s(14696),c=s(65664),h=s(58290),p=s(78451),f=s(36397),D=s(19513),y=s(85873);function _(e,t,s){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var s=t.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const g=(0,m.injectIntl)((i=class extends l().PureComponent{constructor(e){super(e),_(this,"handleKeyDown",(e=>{(0,D.e)(e,p.Ay.KeyCodes.ESCAPE)&&this.props.onExited()})),_(this,"formatDate",(e=>(0,f.KH)(e,this.props.intl.formatMessage))),_(this,"getText",(()=>({modalHeaderText:l().createElement(m.FormattedMessage,{id:"dnd_custom_time_picker_modal.defaultMsg",defaultMessage:"Disable notifications until"}),confirmButtonText:l().createElement(m.FormattedMessage,{id:"dnd_custom_time_picker_modal.submitButton",defaultMessage:"Disable Notifications"})}))),_(this,"handleConfirm",(async()=>{const e=this.state.selectedDateTime.toDate();e<new Date||(await this.props.actions.setStatus({user_id:this.props.userId,status:p._w.DND,dnd_end_time:(0,f.Id)(e),manual:!0,last_activity_at:(0,f.Id)(this.props.currentDate)}),this.props.onExited())})),_(this,"handleDateTimeChange",(e=>{this.setState({selectedDateTime:e})}));const{currentDate:t}=this.props;let s=r()(t);23===t.getHours()&&t.getMinutes()>20&&(s=s.add(1,"day").startOf("day").add(9,"hours")),this.state={selectedDateTime:s}}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}render(){const{modalHeaderText:e,confirmButtonText:t}=this.getText(),{selectedDateTime:s}=this.state;return l().createElement(c.default,{theme:this.props.theme},l().createElement(u.zW,{compassDesign:!0,ariaLabel:(0,y.Vw)({id:"dnd_custom_time_picker_modal.defaultMsg",defaultMessage:"Disable notifications until"}),onExited:this.props.onExited,modalHeaderText:e,confirmButtonText:t,handleConfirm:this.handleConfirm,handleEnterKeyPress:this.handleConfirm,id:"dndCustomTimePickerModal",className:"DndModal modal-overflow",tabIndex:-1,keyboardEscape:!0,enforceFocus:!1},l().createElement("div",{className:"DndModal__content"},l().createElement(h.Ay,{time:s,handleChange:this.handleDateTimeChange,timezone:this.props.locale,relativeDate:!0}))))}},_(i,"propTypes",{onExited:a().func.isRequired,userId:a().string.isRequired,currentDate:a().instanceOf(Date).isRequired,locale:a().string.isRequired,actions:a().shape({setStatus:a().func.isRequired}).isRequired}),i))}}]);
//# sourceMappingURL=9838.acd6ecce585ca59a79fd.js.map