var e=function(exports){function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({});import{ButtonWithLoading as t,Button_default as n,C as r,CircularProgress_default as i,ErrorModal$1 as a,Grid_default as o,L as s,MenuItem_default as c,MesfModal as l,Paper_default as u,TextField_default as d,__toESM as f,axiosInstance as p,createSlice as m,createStyles as h,format as g,getError$1 as _,init_redux_toolkit_esm as v,isEmpty_default as y,jsx as b,jsxs as x,makeStyles_default as S,n as C,require_build as w,require_react as T}from"./index-hCP7Trns.js";v();const E={message:``,response:``,error:null,isResponseLoading:!1},D=m({name:`broker`,initialState:E,reducers:{setMessage(e,t){e.message=t.payload},setResponse(e,t){e.response=t.payload},setIsResponseLoading(e,t){e.isResponseLoading=t.payload},setError(e,t){e.error=t.payload}}}),{setMessage:O,setResponse:k,setIsResponseLoading:A,setError:j}=D.actions;var M=f(T()),N=f(w());const P=(0,M.createContext)({state:D.getInitialState(),actions:D.actions}),F=()=>(0,M.useContext)(P),I=({children:e})=>{let[t,n]=(0,N.useComplexState)({initialState:D.getInitialState(),reducers:D.caseReducers});return b(P.Provider,{value:{state:t,actions:n},children:e})};function L({onCopy:e}){let[t,r]=(0,M.useState)(g(new Date,`yyyy-MM-dd HH:mm:ss`)),[i,a]=(0,M.useState)(`CAS1`),[s,l]=(0,M.useState)(`08`),[u,f]=(0,M.useState)(`333123`),[p,m]=(0,M.useState)(`StopperRodOpen`),[h,_]=(0,M.useState)(`2023123`),[v,y]=(0,M.useState)(`4`),S=()=>{navigator.clipboard.writeText(w),e(w)},C;try{C=g(new Date(t),`yyMMddHHmmss`)}catch{C=``}let w=`<LadleTrackMessage>
    <Header>
      <Sender>Level2</Sender>
      <Receiver>REFBroker</Receiver>
      <TimeSent>${C}</TimeSent>
      <Location>${i}</Location>
      <ComponentName>${s}</ComponentName>
      <HeatNo>${u}</HeatNo>
      <Event>${p}</Event>
      <EventTime>${C}</EventTime>
    </Header>
    <Data>
      <Name>SequenceName</Name>
      <Value>${h}</Value>
      <Time>${C}</Time>
      <Comment></Comment>
      <Originator>Level2</Originator>
    </Data>
    <Data>
      <Name>TundishCarNumber</Name>
      <Value>${v}</Value>
      <Time>${C}</Time>
      <Comment></Comment>
      <Originator>Level2</Originator>
    </Data>
  </LadleTrackMessage>`;return x(o,{container:!0,spacing:2,children:[x(o,{item:!0,container:!0,xs:12,md:6,children:[b(o,{item:!0,xs:12,md:6,children:b(d,{label:`Time Sent`,type:`datetime-local`,value:t,onChange:e=>r(e.target.value),fullWidth:!0})}),b(o,{item:!0,xs:12,md:6,children:x(d,{label:`Location`,select:!0,value:i,onChange:e=>a(e.target.value),fullWidth:!0,children:[b(c,{value:`CAS1`,children:`CAS1`}),b(c,{value:`CAS2`,children:`CAS2`})]})}),b(o,{item:!0,xs:12,md:6,children:b(d,{label:`Component Name`,select:!0,value:s,onChange:e=>l(e.target.value),fullWidth:!0,children:[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`].map(e=>b(c,{value:e,children:e},e))})}),b(o,{item:!0,xs:12,md:6,children:b(d,{label:`Heat No`,value:u,onChange:e=>f(e.target.value),fullWidth:!0})}),b(o,{item:!0,xs:12,md:6,children:x(d,{label:`Event`,select:!0,value:p,onChange:e=>m(e.target.value),fullWidth:!0,children:[b(c,{value:`StopperRodOpen`,children:`StopperRodOpen`}),b(c,{value:`StopperRodClose`,children:`StopperRodClose`})]})}),b(o,{item:!0,xs:12,md:6,children:b(d,{label:`Sequence Name`,value:h,onChange:e=>_(e.target.value),fullWidth:!0})}),b(o,{item:!0,xs:12,md:6,children:b(d,{label:`Tundish Car Number`,value:v,onChange:e=>y(e.target.value),fullWidth:!0})})]}),x(o,{item:!0,container:!0,xs:12,md:6,children:[b(o,{item:!0,xs:12,children:b(d,{multiline:!0,rows:20,value:w,fullWidth:!0,InputProps:{readOnly:!0}})}),b(o,{item:!0,xs:12,children:b(n,{variant:`contained`,color:`primary`,onClick:S,children:`Copy to Clipboard`})})]})]})}var R=L,z=class{constructor(){e.defineProperty(this,`axios`,void 0),this.axios=p,this.submitMessage=this.submitMessage.bind(this)}async submitMessage(e){try{let t=await this.axios.post(`Broker/message`,{message:e});return t.data.success?{ok:!0,data:t.data.result}:{ok:!1,message:t.data.result||_(t.data)}}catch(e){return{ok:!1,message:_(e)}}}};const{submitMessage:B}=new z,V=S(e=>h({errorTextfield:{"& .MuiOutlinedInput-root.Mui-disabled .MuiOutlinedInput-notchedOutline":{borderColor:`red`},"& .MuiInputBase-root.Mui-disabled":{color:`black`},"& .MuiFormLabel-root":{color:`red`}},successTextField:{"& .MuiOutlinedInput-root.Mui-disabled .MuiOutlinedInput-notchedOutline":{borderColor:`green`},"& .MuiInputBase-root.Mui-disabled":{color:`rgba(0, 0, 0, 0.87)`},"& .MuiFormLabel-root":{color:`green`}}})),H=e=>{let[c,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(``),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(!1),{state:{message:S,response:w},actions:T}=F(),E=V(),D=e=>{f(``);let t=e.target.value;T.setMessage(t)},O=async()=>{v(!0);try{let e=await B(S);e.ok?(m(E.successTextField),C(e.data.result,{icon:b(s,{})})):(m(E.errorTextfield),C(`An error was found!`,{icon:b(r,{})})),T.setResponse(e.data||e.message)}catch(e){console.log(e)}v(!1)},k=y(S);return x(u,{style:{padding:`16px`},children:[x(o,{container:!0,spacing:1,children:[x(o,{xs:12,item:!0,children:[b(n,{onClick:()=>g(!0),children:`Open Message Generator`}),b(l,{maxWidth:`md`,handleClose:()=>g(!1),open:h,children:b(l.Content,{children:b(u,{children:b(R,{onCopy:e=>{T.setMessage(e),g(!1)}})})})})]}),x(o,{xs:12,item:!0,container:!0,spacing:1,children:[b(o,{item:!0,xs:6,children:b(d,{multiline:!0,size:`small`,variant:`outlined`,fullWidth:!0,minRows:15,onChange:D,value:S,label:`XML Message`})}),x(o,{item:!0,xs:6,style:{position:`relative`},children:[b(d,{multiline:!0,size:`small`,variant:`outlined`,disabled:!0,className:_?``:p,fullWidth:!0,minRows:26,value:w,label:`Response text`}),_&&b(`div`,{style:{position:`absolute`,top:`50%`,right:`50%`,transform:`translate(-50%,-50%)`},children:b(i,{})})]})]}),b(o,{item:!0,xs:12,children:b(t,{isLoading:_,onClick:O,fullWidth:!0,variant:`contained`,color:`primary`,children:`Send`})})]}),b(a,{error:c,onHide:()=>f(``)})]})},U=()=>b(I,{children:b(H,{})});export{U as BrokerPage};
//# sourceMappingURL=broker-B5cxdYNl.js.map