(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[31],{hJZc:function(e,t,a){"use strict";var s,n=a("Y+p1"),i=a.n(n),m=a("q1tI"),r=a.n(m),o=a("wd/R"),c=a.n(o),l=(a("f0Wu"),a("/MKj")),p=a("AF5L"),h=a("kCmh"),u=a("zDJl"),f=a("17x9"),d=a.n(f),E=a("ui7M"),D=a("q17X");let I=Object(l.connect)(e=>({user:e.user.user,farmID:e.location.farm,delay:e.time.piDelay,devices:e.farmDevices.devices}))(s=class extends m.Component{constructor(e){super(e);const{delay:t}=e;this.tick=this.tick.bind(this),this.onFarmChange=this.onFarmChange.bind(this),this.requestGatewayTime=this.requestGatewayTime.bind(this),this.state={date:c()().subtract(t||0,"ms"),sameTimezone:!0}}requestGatewayTime(e){if(!Object(D.isUsingFakeData)()){const{farmID:t,dispatch:a}=e;if(a({type:"ZERO_PI_TIME"}),t){let e=h.a.getDevicesByAttributes({FarmID:t,DevType:u.d.GATEWAY})[0];e&&(a({type:"GET_PI_TIME_REQUEST",payload:+c()()}),Object(p.k)(e,e=>{a({type:"GET_PI_TIME_RESPONSE",payload:e.CAnsw.time})},()=>a({type:"ZERO_PI_TIME"})))}}}componentDidMount(){this.timerID=setInterval(()=>this.tick(),1e3),Object(D.isUsingFakeData)()||this.requestGatewayTime(this.props),this.onFarmChange(this.props)}UNSAFE_componentWillReceiveProps(e,t){const{devices:a,farmID:s}=this.props;i()(a,e.devices)&&i()(s,e.farmID)||this.requestGatewayTime(e),i()(s,e.farmID)||this.onFarmChange(e)}componentWillUnmount(){clearInterval(this.timerID)}onFarmChange(e){const{farmID:t}=e;let a=c.a.tz.guess(!0),s=Object(E.a)(t);c.a.defaultFormat="DD.MM.YY HH:mm",c.a.defaultFormatUtc="DD.MM.YY HH:mm",c.a.tz.setDefault(s),this.setState({sameTimezone:s===a})}tick(){const{delay:e}=this.props;this.setState({date:c()().subtract(e||0,"ms")})}render(){const{sameTimezone:e,date:t}=this.state,{format:a,customComponent:s}=this.props;return s?r.a.createElement(s,{time:+t}):r.a.createElement("time",null,e&&r.a.createElement(r.a.Fragment,null,r.a.createElement("strong",null,t.format(a))),!e&&r.a.createElement(r.a.Fragment,null,r.a.createElement("i",{className:"fas fa-fw fa-home"})," ",r.a.createElement("strong",null,t.format(a))," ",r.a.createElement("br",null),r.a.createElement("i",{className:"fas fa-fw fa-map-marker"})," ",c.a.tz(t,c.a.tz.guess(!0)).format(a)))}})||s;I.propTypes={format:d.a.string,customComponent:d.a.oneOf([d.a.node,d.a.func])},I.defaultProps={format:"HH:mm:ss"},t.a=I}}]); //# sourceMappingURL=main~4a947964.9d2882fb.chunk.js.map