(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[70],{"+1Ww":function(e,t,a){"use strict";a.r(t);var n=a("mwIZ"),s=a.n(n),i=a("q1tI"),r=a.n(i),l=a("/MKj"),o=a("0ajJ"),c=a("XSU/"),h=a("2tEe"),d=a("VyNe"),m=a("c7k8"),p=a("b9ZJ"),u=a("wQVC"),g=a("3Z9Z"),f=a("LCzB"),b=a("4o57"),E=a("Le/y"),v=a("rzZ0");class y extends i.Component{constructor(...e){super(...e),this.cache=new m.c({defaultHeight:Object(u.f)(3),fixedWidth:!0,keyMapper:e=>s()(this,"props.notifications[".concat(e,"].NID"),e)}),this.clearCache=()=>{console.log("clear cache"),this.cache.clearAll()},this.rowRenderer=({index:e,style:t,key:a,parent:n})=>{const{notifications:s}=this.props,i=s[e]||{};return r.a.createElement(m.b,{cache:this.cache,columnIndex:0,key:a,parent:n,rowIndex:e},({measure:a})=>r.a.createElement(b.a,{style:t,notification:i,key:e,index:e,measure:a}))},this.noRowsRenderer=()=>{const{fetching:e,t:t}=this.props;return e?r.a.createElement("div",{className:"mh-5rem pb-4 pt-4 d-flex justify-content-center w-100 align-items-center"},r.a.createElement("i",{className:"fas fa-fw fa-spin fa-circle-notch fa-2x"})):r.a.createElement("div",{className:"mh-5rem pb-4 pt-4 d-flex justify-content-center opacity-50 w-100 align-items-center"},r.a.createElement("h4",null,r.a.createElement("span",null,t("notificationsNotFound"))))}}componentDidMount(){return!1}componentWillUnmount(){const e=+new Date;this.props.dispatch(Object(v.d)(e))}componentDidUpdate(e,t,a){this.props.notifications.length!==e.notifications.length&&this.clearCache()}render(){const{notifications:e,fetching:t,t:a}=this.props;return console.log(E.a,"storage wrapper"),r.a.createElement("div",null,r.a.createElement(c.a,{text:a("notifications.notifications")}),r.a.createElement(h.a,null,r.a.createElement(d.a,{className:"min-vh-25"},r.a.createElement(g.a,{className:"position-relative background-inherit"},r.a.createElement(m.f,{onResize:this.clearCache},({height:a,isScrolling:n,scrollTop:s,onChildScroll:i,registerChild:l})=>r.a.createElement(o.a,{itemRef:l,useFlexLayout:!1,striped:!0},r.a.createElement(p.List,{rowCount:e.length,width:window.innerWidth,rowRenderer:this.rowRenderer,scrollTop:s,data:e,autoHeight:!0,fetching:t,height:a,deferredMeasurementCache:this.cache,rowHeight:this.cache.rowHeight,isScrolling:n,onScroll:i,className:"w-100 overflow-auto",noRowsRenderer:this.noRowsRenderer})))))))}}y=Object(l.connect)((function(e){return{notifications:e.notificationCenter.notifications,fetching:e.notificationCenter.fetching,farm:e.location.farm}}))(y),t.default=Object(f.a)()(y)},"8V0/":function(e,t,a){"use strict";a.r(t);var n=a("Y+p1"),s=a.n(n),i=a("mwIZ"),r=a.n(i),l=a("q1tI"),o=a.n(l),c=a("XSU/"),h=a("/MKj"),d=a("2wEF"),m=a("2tEe"),p=a("17x9"),u=a.n(p),g=a("Z1LY"),f=a("IXwn"),b=a("uSQv"),E=a("9D2Z"),v=a("kG49"),y=a("sZ7W"),O=a("ANjH"),w=a("f0zD"),C=a("42VQ"),D=a("0faN"),j=a("+z6k"),k=a("vzZS"),S=a("RNJp"),I=a("g+Zn"),T=a("o6/V"),F=a("Ndvx"),P=a("0b+E"),N=a("VfnB"),x=a("zDJl"),M=a("/kok"),A=a("vSUv"),R=a.n(A),L=a("zck4"),W=a("q17X"),B=a("qx5e"),G=a("s506"),H=a("kCVf"),_=a("yuWL"),U=a("LCzB"),V=a("byFs"),q=a("wd/R"),z=a.n(q),Y=a("DWSH"),K=a("UZWR");class Z extends o.a.Component{constructor(e){super(e),this.state={selectedCages:[],event:void 0,showAlias:Object(W.getShowAliases)()},this.messageIDs=[],this.onDeviceChange=(e=this.props)=>{const{cages:t}=e;let a=this.state.selectedCages.slice(0);a.forEach(e=>{let n=t.find(t=>t.DevID===e.DevID);n?s()(e,n)||(a[a.findIndex(t=>t.DevID===e.DevID)]=n):a=a.filter(t=>t.DevID!==e.DevID)}),this.setState({selectedCages:a})},this.onCageSelected=e=>{let t=this.state.selectedCages.slice(0);t.filter(t=>t.DevID===e.DevID).length>0?t=t.filter(t=>t.DevID!==e.DevID):t.push(e),this.setState({selectedCages:t})},this.onButtonClick=e=>{this.setState({event:e})},this.onResetConfirmed=e=>{for(let t of this.state.selectedCages)Object(y.c)(t);e.handleHide()},this.onResetClick=()=>{let e=o.a.createElement("ul",null,this.state.selectedCages.map((e,t)=>o.a.createElement("li",{key:t},e.Name)));this.props.show(C.a,{text:this.props.t("farmView.cage.resetText"),title:this.props.t("farmView.cage.resetTitle"),confirmText:this.props.t("yes"),onConfirmed:this.onResetConfirmed,children:e})},this.onStopConfirmed=e=>{for(let t of this.state.selectedCages)Object(y.w)(t,0);e.handleHide()},this.onClearErrors=e=>{for(let t of this.state.selectedCages)Object(y.s)(t);e.handleHide()},this.onClearErrorsClick=()=>{let e=o.a.createElement("ul",null,this.state.selectedCages.map((e,t)=>o.a.createElement("li",{key:t},e.Name)));this.props.show(C.a,{text:this.props.t("farmView.cage.clearErrorsText"),title:this.props.t("farmView.cage.clearErrorsTitle"),confirmText:this.props.t("yes"),onConfirmed:this.onClearErrors,children:e})},this.onStopClick=()=>{let e=o.a.createElement("ul",null,this.state.selectedCages.map((e,t)=>o.a.createElement("li",{key:t},e.Name)));this.props.show(C.a,{text:this.props.t("farmView.cage.stopText"),title:this.props.t("farmView.cage.stopTitle"),confirmText:this.props.t("yes"),onConfirmed:this.onStopConfirmed,children:e})},this.onSetWorktypeClick=()=>{this.props.show(D.a,{})},this.onAddNewInsertion=()=>{this.props.show(j.a,{})},this.onEndCurrentInsertion=()=>{const{t:e}=this.props;this.props.show(C.a,{text:e("modals.chamberTransferModal.endInsertionText"),title:e("modals.chamberTransferModal.titleEndInsertion"),confirmText:e("yes"),onConfirmed:e=>{let t=[];for(let a of this.state.selectedCages)t.push(Object(Y.m)({DevID:a.DevID}));Promise.all(t).then(e=>{Object(Y.b)(e)}).catch(e=>{Object(Y.a)(e)}),e.handleHide()}})},this.onCageMarkerClick=()=>{this.props.show(I.a,{})},this.clearSelection=()=>{console.log("clear"),this.setState({selectedCages:[]})},this.onRightClick=(e,t)=>{this.setState({event:e,selectedCages:[t]})},this.sortDevices=(e,t)=>{let a=this.getName(e),n=this.getName(t);return a.localeCompare(n)},this.onEndInsertionSuccess=()=>{const{selectedCages:e}=this.state;let t=[];for(let a of e){let e=a.prepareBeanToSave();e.endLastInsertion(z.a.utc().endOf("day").toDate().getTime()),t.push(e)}Object(V.a)(t)},Object(W.isUsingFakeData)()&&(R.a.restore(),R.a.stub(M.a,"startSendingDeviceState").callsFake(L.b),R.a.stub(M.a,"createAndSendMessageObject").callsFake(L.a),R.a.stub(M.a,"sendRequestForAggregatedData").callsFake(()=>{}),this.timer=setInterval(()=>{Object(L.d)(this.props.cages)},5e3)),this.sendData(),P.a.modalview("farm/cage")}componentDidUpdate(e,t,a){this.props.cages.length!==e.cages.length&&this.sendData()}sendData(){M.a.removeFromInterval(this.messageIDs);let e=Object(N.r)(this.props.cages);if(e)for(let t of e.values())t[x.d.CAGE].length&&(this.messageIDs.push(M.a.startSendingDeviceState(t[x.d.CAGE],void 0,void 0,{keepAlive:!0})),M.a.sendRequestForAggregatedData(t[x.d.CAGE]))}UNSAFE_componentWillReceiveProps(e,t){s()(this.props.cages,e.cages)||this.onDeviceChange(e)}componentWillUnmount(){R.a.restore(),clearInterval(this.timer)}checkIfDisabled(){const{shadows:e}=this.props,{selectedCages:t}=this.state;let a=0;for(let n of t){e.get(n.DevID)||a++}return a===t.length}getName(e){const{Alias:t}=e,{showAlias:a}=this.state;if(a&&t)return t;let n=e.getLocation().map(e=>Object(H.k)(e)).join(", ");return n||"".concat(e.Address,"/").concat(e.Address.toString(16)," ").concat(Object(N.n)(e.Interface))}shouldDisableStartSettlement(){if(Object(W.isUsingFakeData)())return!0;const{selectedCages:e}=this.state,{settlements:t}=this.props;for(let a of e){let e=a.getLocation(),n=Object(H.j)(e[0]);if(!n)return!0;let s=t.find(e=>e.PlcmntID===n&&(!e.DtaEndTime||e.DtaEndTime>(new Date).getTime()));if(s){if(!a.Settings.Insertions)return!0;if(!!a.Settings.Insertions.find(e=>e.StartTime===s.DtaStartTime))return!0}}}shouldDisableEndSettlement(){if(Object(W.isUsingFakeData)())return!1;const{selectedCages:e}=this.state,{settlements:t}=this.props;for(let a of e){let e=a.getLocation(),n=Object(H.j)(e[0]);if(!n)return!0;let s=t.find(e=>e.PlcmntID===n&&!e.DtaEndTime);if(!s||!a.Settings.Insertions)return!0;if(!a.Settings.Insertions.find(e=>e.StartTime===s.DtaStartTime))return!0}}render(){const{selectedCages:e,event:t}=this.state,{cages:a,t:n,loading:s}=this.props;if(!a.length)return o.a.createElement(_.a,{isLoading:s,dataLength:a.length,noDataText:n("farmView.cage.cagesNotFound")});a.sort(this.sortDevices);let i=this.checkIfDisabled();return o.a.createElement(o.a.Fragment,null,a.map(t=>o.a.createElement(g.a,{cage:t,key:t.DevID,selected:e.filter(e=>e.DevID===t.DevID).length>0,onSelect:this.onCageSelected,onRightClick:this.onRightClick})),o.a.createElement(f.a,{fixed:!0},o.a.createElement(E.a,{event:t},o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-undo fa-fw"}),onClick:this.onResetClick,disabled:i},n("reset")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-stop fa-fw"}),onClick:this.onStopClick,disabled:i},n("stop")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-cog fa-fw"}),onClick:this.onSetWorktypeClick,disabled:i},n("farmView.cage.changeWorkType")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-arrow-up fa-fw"}),onClick:this.onAddNewInsertion,disabled:this.shouldDisableStartSettlement()},n("farmView.cage.newInsertion")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-stop-circle fa-fw"}),onClick:this.onEndCurrentInsertion,disabled:this.shouldDisableEndSettlement()},n("farmView.cage.endInsertion")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-highlighter"}),onClick:this.onCageMarkerClick,disabled:i},"Marker"),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-recycle"}),onClick:this.onClearErrorsClick,disabled:i},n("farmView.cage.clearErrors"))),o.a.createElement(k.a,{boxColor:"info"},n("farmView.cage.selectedCages",{count:e.length})),o.a.createElement(b.a,{buttonColor:"info",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),onClick:this.onButtonClick,disabled:0===e.length})),o.a.createElement(D.b,{cages:this.state.selectedCages}),o.a.createElement(j.b,{cages:this.state.selectedCages}),o.a.createElement(I.b,{cages:this.state.selectedCages}),o.a.createElement(S.b,null),o.a.createElement(T.b,null),o.a.createElement(F.b,null))}}Z.propTypes={cages:u.a.array.isRequired};let X=Object(h.connect)(e=>({shadows:e.shadows.shadows,loading:e.dataLoader.loading,settlements:Object(K.b)(e)}),e=>Object(O.b)({show:w.d},e))(Z);X=Object(U.a)()(X);var J=Object(B.a)({roles:[G.c._DEVICE_CAGE],showInfo:!0})(X),Q=a("4qC0"),$=a.n(Q),ee=a("EUHq"),te=a("LLWV"),ae=a("99/+");function ne(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function se(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class ie extends o.a.Component{constructor(...e){super(...e),this.state={event:null},this.openMenu=(e,{DevID:t}={})=>{const{onSelect:a}=this.props;$()(t)&&a(t),this.setState({event:e})}}componentDidMount(){this.props.clear()}componentWillUnmount(){this.props.clear()}render(){const{event:e}=this.state;return o.a.createElement("div",null,o.a.createElement(ee.a,{openMenu:this.openMenu}),o.a.createElement(te.a,{openMenu:this.openMenu,event:e}))}}ie=Object(h.connect)(null,e=>function(e){for(var t=1;te(Object(ae.b)("climates",!0,t))}))(ie);let re=Object(h.connect)()(ie);re=Object(U.a)()(re);var le=Object(B.a)({roles:[G.c._DEVICE_CLIMATE],showInfo:!0})(re),oe=a("+5lq"),ce=a("HfzF"),he=a("v9qu"),de=a("15cA"),me=a("2HEh"),pe=a("c5t2"),ue=a("A5yn"),ge=a("/S4a"),fe=a("4vr1"),be=a("JI6e"),Ee=a("3Z9Z"),ve=a("84Ez"),ye=a("mr+a"),Oe=a("T34T"),we=a("EyHs"),Ce=a("+V8T"),De=a("4Q+z"),je=a("WNbV"),ke=a("W/wb"),Se=a("ZkcS"),Ie=a("xi04"),Te=a("0Lmq"),Fe=a("40zH"),Pe=a("7y5B"),Ne=a("NpuV"),xe=a("sJAb");function Me(){return(Me=Object.assign||function(e){for(var t=1;t{console.log("daadasd",e),this.setState({viewType:e})},this.handleButtonOpen=e=>{this.setState({event:e})},this.getSettingsMap=()=>{const{feedingCurves:e,feedingForages:t,feedingSchedules:a}=this.props;return{curveMap:e.length?new Map([...e.map(e=>[e.SetID,e])]):new Map,forageMap:t.length?new Map([...t.map(e=>[e.SetID,e])]):new Map,scheduleMap:a.length?new Map([...a.map(e=>[e.SetID,e])]):new Map}};const{cookies:t,license:a}=this.props,n=Object(de.g)(this.props.buildings);this.state={data:n,event:null,viewType:a===G.b.BASIC?Re:+r()(t.get("dispenser-tab"),"viewType",Ae)},this.props.dispatch(Object(ue.a)()),Object(W.isUsingFakeData)()&&(this.timer=setInterval(()=>{Object(pe.e)()},3e4),R.a.restore(),R.a.stub(M.a,"startSendingFeedingState").callsFake(pe.b),R.a.stub(M.a,"startSendingFeedingStateRFID").callsFake(pe.f),R.a.stub(M.a,"createAndSendMessageObject").callsFake(pe.a)),P.a.modalview("farm/feeding")}UNSAFE_componentWillReceiveProps(e,t){const{buildings:a,animalsTime:n,loading:i}=this.props;n===e.animalsTime&&s()(a,e.buildings)&&i===e.loading||this.setState({data:Object(de.g)(e.buildings)})}componentWillUnmount(){clearInterval(this.timer),R.a.restore();const{cookies:e,dispatch:t}=this.props;e.set("dispenser-tab",{viewType:this.state.viewType},{path:"/",expires:z()().add(1,"year").toDate()}),t(Object(ue.a)())}render(){const{data:e,event:t,viewType:a}=this.state,{t:n,loading:s,license:i,selectedChamber:r}=this.props,l=e.map(e=>e.chamber),c=r?l.find(e=>e.CID===r):null,h=!!c&&!!c.IndividualFeeding&&!!a,d=!!c&&(!a||!c.IndividualFeeding);if(!e.length)return o.a.createElement(_.a,{isLoading:s,dataLength:e.length,noDataText:n("deviceRows.feeding.dispenserTab.noChambers")});const m=this.getSettingsMap(),p=Object(he.a)(),u=[{value:Re,name:n("deviceRows.feeding.dispenserTab.simple")},{value:Ae,name:n("advanced")}];return o.a.createElement(o.a.Fragment,null,i===G.b.EXTENDED&&o.a.createElement(be.a,{xs:12},o.a.createElement(Ee.a,{className:"mb-4 justify-content-center"},o.a.createElement(be.a,{xs:12,lg:6},o.a.createElement("label",{className:"text-center"},n("deviceRows.feeding.dispenserTab.view")),o.a.createElement(ge.a,{onChange:this.handleChangeViewType,value:a,options:u})))),e.map((e,t)=>o.a.createElement(oe.a,Me({viewType:a},e,m,{mobile:p,key:e.chamber.CID,index:t,setEvent:p?void 0:this.handleButtonOpen}))),o.a.createElement(ce.a,{chambers:l,isActive:d,event:t,onClick:this.handleButtonOpen}),o.a.createElement(fe.a,{chambers:l,isActive:h}),o.a.createElement(Oe.b,{chambers:l}),o.a.createElement(we.b,null),o.a.createElement(Ce.b,null),o.a.createElement(De.a,null),o.a.createElement(je.b,null),o.a.createElement(ke.b,null),o.a.createElement(Se.b,null),o.a.createElement(Ie.b,null),o.a.createElement(Te.b,null),o.a.createElement(Fe.b,null),o.a.createElement(Pe.b,null),o.a.createElement(Ne.b,null),o.a.createElement(xe.b,null))}}Le.defaultProps={disableSwipe:!0};let We=Object(h.connect)(e=>({buildings:e.farms.buildings,selectedChamber:e.feeding.selectedChamber,feedingCurves:Object(ye.c)(e),feedingSchedules:Object(ye.f)(e),feedingForages:Object(ye.d)(e),loading:e.dataLoader.loading,license:Object(ve.a)(e,{licenseName:G.a.DISPENSER}),animalsTime:e.animals.time}))(Le);We=Object(U.a)()(We);var Be=Object(me.a)(Object(B.a)({roles:[G.c._DEVICE_FEEDING],showInfo:!0})(We)),Ge=a("I8zd"),He=a("VyNe"),_e=a("i8MS"),Ue=a("aIXM"),Ve=a("pZsI"),qe=a("S5VY"),ze=a("c7k8"),Ye=a("b9ZJ"),Ke=a("WV92"),Ze=a("n9kV"),Xe=a("lCyo"),Je=a("0ajJ"),Qe=a("Ty5D"),$e=a("j0Y2"),et=a("cr+I"),tt=a.n(et),at=a("n7pt"),nt=a("CX8Q"),st=a("jpwK"),it=a("LZmG"),rt=a("wQVC"),lt=a("lo2F"),ot=a("XiQt"),ct=a("XzT5");const ht=null,dt=0,mt=1,pt=2,ut=3;class gt extends o.a.Component{constructor(e){super(e),this.clearStatus=()=>{this.setState({status:dt})},this.getAnimalKindMap=e=>{const t=new Map,{t:a}=e,{animalKind:n}=this.state;return Array.isArray(n)&&(n.forEach((e,a)=>{t.set(a,e)}),t.set("group",a("group")),t.set("techno",a("farms.tabs.inventoryTab.technoGroup"))),t},this.initializeAnimals=e=>{const{farm:t,dispatch:a}=e,n=_e.a.getAllAnimals(t,void 0,!0,!1),s=Ue.a.getAllGroups(t),i=Ve.a.getTechnologyGroups(t);a(Object(qe.b)(n,s,i,this.getAnimalKindMap(e)))},this.rowRenderer=({index:e,style:t,key:a,parent:n})=>{const{data:s}=this.props,i=s[e]||{};return o.a.createElement(ze.b,{cache:this.cache,columnIndex:0,key:a,parent:n,rowIndex:e},({measure:a})=>o.a.createElement(Ze.a,{style:t,measure:a,handleRowClick:this.handleRowClick,index:e,data:i}))},this.handleRowClick=(e,{extraData:t={}}={})=>{const{location:{pathname:a,search:n},history:s}=this.props;let i=new URLSearchParams(n);i.delete("documentsGroup"),i.delete("documentsAnimal"),i.delete("documentsRFID"),i.delete("documentsTechnoGroup"),e&&i.set(e.isGroup?e.isTechnoGroup?"documentsTechnoGroup":"documentsGroup":"documentsAnimal",e.id);for(let[r,l]of Object.entries(t))i.set(r,"".concat(l));Object.keys(t).length&&i.delete("location"),s.replace({pathname:a,search:i.toString()})},this.handleHide=()=>{this.handleRowClick(null)},this.getItemsMap=()=>{const{selectedItem:e,data:t}=this.props,a=[];return t.forEach(e=>{a.push({id:e.id,isGroup:!!e.isGroup,isTechnoGroup:!!e.isTechnoGroup}),r()(e,"animals",[]).forEach(e=>{a.push({id:e.id})})}),{ids:a,currentIndex:a.findIndex(t=>e&&[e.AnmID,e.AnmGrp,e.TGID].includes(t.id))}},this.handlePrev=(e=!1)=>{const{ids:t,currentIndex:a}=this.getItemsMap();return!!(~a&&a-1>=0&&t[a-1])&&(e&&this.handleRowClick(t[a-1]),!0)},this.handleNext=(e=!1)=>{const{ids:t,currentIndex:a}=this.getItemsMap();return console.log(t,a),!!(~a&&a+1<=t.length&&t[a+1])&&(e&&this.handleRowClick(t[a+1]),!0)},this.clearCache=()=>{console.log("clear cache"),this.cache.clearAll()},this.cache=new ze.c({defaultHeight:Object(rt.f)(7),fixedWidth:!0,keyMapper:e=>{const t=this.props.data[e]||{},a=r()(t,"animals.length",0);return"".concat(t.id).concat(a?"-"+a:"")}}),this.state={status:dt,loading:!0,animalKind:ct.a.t("animalKind",{returnObjects:!0})},this.props.dispatch(Object($e.b)()),P.a.modalview("farm/inventory")}componentWillUnmount(){this.props.dispatch(Object($e.b)())}getAnimalByQueryString(e){const{selectedItem:t,dispatch:a}=e;let n=ht,s={},i=tt.a.parse(e.location.search||"")||{};if(i.documentsAnimal||i.documentsGroup||i.documentsRFID||i.documentsTechnoGroup){if(i.documentsGroup){const e=Ue.a.findGroupByID(i.documentsGroup);if(e instanceof st.a)return a(Object($e.a)(e)),{status:dt,extraParams:{}};n=ut}if(i.documentsTechnoGroup){const e=Ve.a.getTechnoGroupByTGID(i.documentsTechnoGroup);if(e instanceof ot.a)return a(Object($e.a)(e)),{status:dt,extraParams:{}};n=ut}if(i.documentsAnimal){const e=_e.a.getAnimalById(i.documentsAnimal);if(e instanceof nt.a)return this.props.dispatch(Object($e.a)(e)),{status:dt,extraParams:{}};n=pt}if(i.documentsRFID){let t=_e.a.getAnimalsByRfid(i.documentsRFID,e.farm).filter(e=>e instanceof nt.a);if(0===t.length){n=pt;try{const e=at.a.getBoxBIDByRfid(i.documentsRFID);e&&(t=_e.a.getAllAnimalsForLocation(e,Ge.a.BOX,{joinEvents:!1}).filter(e=>e instanceof nt.a))}catch(r){}}if(1===t.length)return this.props.dispatch(Object($e.a)(t[0])),{status:dt,extraParams:{}};t.length>1&&(n=mt,s={search:'"RFID":"'.concat(i.documentsRFID,'"')})}this.handleRowClick(null,{extraData:s})}return t&&this.props.dispatch(Object($e.b)()),{status:n,extraParams:s}}componentDidMount(){this.initializeAnimals(this.props);const e=this.getAnimalByQueryString(this.props);null!==e.status&&this.setState({status:e.status}),this.setState({animalKind:ct.a.t("animalKind",{returnObjects:!0})})}UNSAFE_componentWillReceiveProps(e,t){if(s()(e.animalsTime,this.props.animalsTime)&&s()(e.technoTime,this.props.technoTime)&&s()(e.loading,this.props.loading)||this.initializeAnimals(e),!s()(e.location.search,this.props.location.search)){const t=this.getAnimalByQueryString(e);console.log(t,"new status"),null!==t.status&&this.setState({status:t.status})}}componentDidUpdate(e,t,a){e.data.length!==this.props.data.length&&Object(rt.k)()}render(){const{loading:e,data:t,inventorySize:a,t:n,showCollapsed:s}=this.props,{status:i}=this.state,r=e&&!t.length;return r?o.a.createElement(_.a,{isLoading:r,dataLength:t.length}):o.a.createElement(o.a.Fragment,null,o.a.createElement(He.a,null,o.a.createElement(lt.a,null)),o.a.createElement(He.a,{className:"mh-15rem overflow-visible"},!!i&&o.a.createElement(k.a,{className:"d-flex justify-content-between align-items-baseline",boxColor:"warning"},n("farms.tabs.inventoryTab.errorTypes.".concat(i)),o.a.createElement("i",{className:"fa fa-fw fa-times pointer",onClick:this.clearStatus})),o.a.createElement(Ee.a,{className:"background-inherit"},o.a.createElement(Xe.a,null),o.a.createElement(Je.a,{useFlexLayout:!1},o.a.createElement(ze.f,{onResize:this.clearCache},({height:e,isScrolling:i,scrollTop:r,onChildScroll:l})=>o.a.createElement(Ye.List,{rowCount:t.length,width:window.innerWidth,rowRenderer:this.rowRenderer,scrollTop:r,autoHeight:!0,height:e,data:t,deferredMeasurementCache:this.cache,rowHeight:this.cache.rowHeight,showCollapsed:s,isScrolling:i,onScroll:l,overscanRowCount:3,className:"w-100 overflow-auto",noRowsRenderer:()=>o.a.createElement("div",{className:"placeholder"},!t.length&&!!a&&n("farms.tabs.inventoryTab.noAnimalsWithConditions"),!t.length&&!a&&n("farms.tabs.inventoryTab.noAnimals"))}))),o.a.createElement(it.a,{handleNext:this.handleNext,handlePrev:this.handlePrev,handleHide:this.handleHide}))))}}gt.propTypes={loc:u.a.object.isRequired,level:u.a.oneOf([Ge.a.FARM,Ge.a.BUILDING,Ge.a.SECTOR,Ge.a.CHAMBER,Ge.a.BOX]).isRequired};let ft=Object(h.connect)(e=>({data:Object(Ke.b)(e),animalsTime:e.animals.time,technoTime:e.technologyGroup.time,farm:e.location.farm,loading:e.dataLoader.loading,inventorySize:e.inventory.size,showCollapsed:e.inventory.showCollapsed,selectedItem:e.animalDocuments.selectedItem}))(gt);gt=Object(B.a)({roles:[G.c._BREEDING],showInfo:!0})(ft),gt=Object(U.a)()(gt);var bt=Object(Qe.o)(gt),Et=a("gE24"),vt=a("FTWh");function yt(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function Ot(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class wt extends o.a.Component{constructor(...e){super(...e),this.state={event:null},this.openMenu=(e,{DevID:t}={})=>{const{onSelect:a}=this.props;$()(t)&&a(t),this.setState({event:e})}}componentDidMount(){this.props.clear()}componentWillUnmount(){this.props.clear()}render(){const{event:e}=this.state;return o.a.createElement("div",null,o.a.createElement(Et.a,{openMenu:this.openMenu}),o.a.createElement(vt.a,{openMenu:this.openMenu,event:e}))}}wt=Object(h.connect)(null,e=>function(e){for(var t=1;te(Object(ae.b)("siloses",!0,t))}))(wt);let Ct=Object(h.connect)()(wt);Ct=Object(U.a)()(Ct);var Dt=Object(B.a)({roles:[G.c._DEVICE_SILO],showInfo:!0})(Ct),jt=a("E+oP"),kt=a.n(jt),St=a("BkRI"),It=a.n(St);a("AL2E");class Tt extends o.a.Component{getClassName(){const{columns:e,className:t}=this.props;let a="header";return e&&(a+=" has-children"),t&&(a+=" "+t),a}render(){const{title:e,columns:t,spanClassName:a}=this.props;return o.a.createElement(o.a.Fragment,null,o.a.createElement("div",{className:this.getClassName(),style:t?{gridColumn:"span ".concat(t.length)}:{}},o.a.createElement("span",{className:a},e)),t&&t.map((e,t)=>o.a.createElement("div",{className:"header-child",key:t},e)))}}Tt.propTypes={title:u.a.string.isRequired,columns:u.a.arrayOf(u.a.node),className:u.a.string,spanClassName:u.a.string};var Ft=a("9YV1"),Pt=a("i8i4"),Nt=a.n(Pt);class xt extends o.a.Component{constructor(e){super(e),this.child=o.a.createRef()}getClassName(){const{className:e}=this.props;let t="child";return e&&(t+=" "+e),t}render(){const{text:e,isFullWidth:t,containerWidth:a}=this.props;let n=0,s=0,i=0,r=0;if(this.child.current&&t){let e=this.child.current.getBoundingClientRect();n=e.top+window.scrollY,s=e.left+1,i=a-1,r=e.height}return o.a.createElement("div",{className:this.getClassName(),ref:this.child},!t&&e,t&&Nt.a.createPortal(o.a.createElement("div",{className:"results-grid-full-width",style:{top:n,left:s,width:i,height:r}},e),document.getElementById("root")||document.createElement("div")))}}(xt=Object(h.connect)(e=>({}))(xt)).propTypes={text:u.a.node.isRequired,isFullWidth:u.a.bool,containerWidth:u.a.number,className:u.a.string};var Mt=a("2dKy"),At=a("2UNB"),Rt=a("P0Qa"),Lt=a("gLBR"),Wt=a("RFJ0"),Bt=a("udB/"),Gt=a("pxzG"),Ht=a("uUZO");class _t extends o.a.Component{constructor(e){super(e),this.onButtonClick=()=>{const{plan:e}=this.props;if(e){let t=e.clone();t.setPlan(this.state.year,this.state.plan.filter(e=>null!==e)),t.setPlan(this.state.year-1,this.state.planBefore.filter(e=>null!==e)),this.props.dispatch(Object(Lt.c)(t.prepareBeanToSave()))}else{let e=At.a.createSetting(Rt.a.YEARLY_PLANS,{Plans:[{Data:this.state.plan.filter(e=>null!==e),Year:this.state.year},{Data:this.state.planBefore.filter(e=>null!==e),Year:this.state.year-1}]});this.props.dispatch(Object(Lt.a)(e))}},this.scrollLeft=()=>{if(document){let e=document.getElementsByClassName("results-grid-column main")[0],t=document.getElementsByClassName("header-child")[0].clientWidth-8;e.scrollLeft=e.scrollLeft-t}},this.scrollRight=()=>{if(document){let e=document.getElementsByClassName("results-grid-column main")[0],t=document.getElementsByClassName("header-child")[0].clientWidth-8;e.scrollLeft=e.scrollLeft+t}},this.onYearChange=e=>{this.setState({year:e}),this.getData(e)};let t=[],a=Object(W.getFarmStart)(),n=0;for(z()(a).year()===z()().year()&&(n=a.isoWeek()-1);n<=z()().weeksInYear()-1;n++)t.push(n+1);this.state={weeks:t,planBefore:[],plan:[],loading:!0,year:z()().year(),animalsMap:this.initializeAnimalsMap()},this.left=o.a.createRef(),this.right=o.a.createRef(),this.container=o.a.createRef(),this.initializeAnimalsMap(),this.getData(z()().year())}initializeAnimalsMap(){const{farm:e}=this.props,t=_e.a.getAllSows(e,!0,!0),a=new Map;if(!kt()(t))for(const n of t){let e=Object(Ht.d)(n.events),t=kt()(n.events)?[]:n.events.sort((e,t)=>e.EvTime-t.EvTime);a.set(n.AnmID,{AnimalKind:n.AnimalKind,CycleTable:e.cycleTable,ResultTable:e.resultTable,Events:t,Animal:n})}return a}getData(e){const{animalsMap:t}=this.state;let a=[],n=[],s=Object(W.getFarmStart)();this.props.plan&&this.props.plan.SetData.Plans.map(t=>{t.Year===e&&(a=t.Data),t.Year===e-1&&(n=t.Data)}),this.props.dispatch(Object(Ft.a)(this.props.farm,It()(this.props.resultsGrid),a,n,s,1,e,t))}UNSAFE_componentWillReceiveProps(e,t){if(this.props.loading!==e.loading&&setTimeout(()=>{this.setState({loading:e.loading})},100),!s()(this.props.resultsGrid,e.resultsGrid)){let t=e.resultsGrid.map(e=>e.isFullWidth?null:e.before||0),a=e.resultsGrid.map(e=>e.isFullWidth?null:e.plan||0);this.setState({planBefore:t,plan:a})}s()(this.props.lang,e.lang)||this.getData(this.state.year)}onChange(e,t){let a=this.state.planBefore.slice(0);a[t]=+e,this.setState({planBefore:a})}onPlanChange(e,t){let a=this.state.plan.slice(0);a[t]=+e,this.setState({plan:a})}getYears(){let e=Object(W.getFarmStart)(),t=[];for(let a=z()(e).year();a<=z()().year();a++)t.push({name:a,value:a});return t}render(){const{resultsGrid:e,t:t}=this.props,{weeks:a,loading:n,planBefore:s,plan:i,year:r}=this.state;let l=0,c=0,h=0;this.container.current&&(h=this.container.current.clientWidth,c=this.container.current.clientWidth),this.left.current&&(l=this.left.current.clientWidth,c-=this.left.current.clientWidth),this.right.current&&(c-=this.right.current.clientWidth);let m=[];for(let o=0;oe.sum));return o.a.createElement("div",null,0===e.length?o.a.createElement("div",null,o.a.createElement(Bt.a,{isLoading:n})," ",o.a.createElement(d.a,null)):o.a.createElement("div",null,o.a.createElement(Bt.a,{isLoading:n}),o.a.createElement(Wt.a,{label:t("results.year"),options:this.getYears(),onChange:this.onYearChange,value:r,clearButton:!1}),o.a.createElement("div",{className:"results",ref:this.container,id:"results-grid"},o.a.createElement("div",{className:"results-grid-column left",ref:this.left},o.a.createElement("div",{className:"results-grid"},o.a.createElement(Tt,{title:t("designation"),className:"first-header"}),o.a.createElement(Tt,{title:t("unit")}),o.a.createElement(Tt,{title:t("results.plan"),columns:[r-1,r]}),e.map((e,a)=>o.a.createElement(o.a.Fragment,{key:a},o.a.createElement(xt,{text:t("".concat(e.name)),isFullWidth:e.isFullWidth,containerWidth:h,className:"results-name"}),o.a.createElement(xt,{text:t("".concat(e.unit)),containerWidth:h}),o.a.createElement(Mt.a,{type:"number",value:s[a],onChange:e=>this.onChange(e,a)}),o.a.createElement(Mt.a,{type:"number",value:i[a],onChange:e=>this.onPlanChange(e,a)}))))),o.a.createElement("div",{className:"results-grid-column main",style:{marginLeft:l,width:c}},o.a.createElement("div",{className:"results-grid"},o.a.createElement(Tt,{title:t("results.week"),columns:a,spanClassName:"fixed-header"}),e.map((e,t)=>a.map((a,n)=>o.a.createElement(xt,{text:e.isFullWidth?"-":e["week".concat(a)],key:"".concat(t,"_").concat(n),unit:Object(Gt.k)(p),valueType:e.valueType,className:e.revertClass?e["week".concat(a)]<=i[t]?"success":"error":e["week".concat(a)]o.a.createElement(o.a.Fragment,{key:t},o.a.createElement(xt,{unit:Object(Gt.k)(p),text:e.isFullWidth?"-":e.quarter1}),o.a.createElement(xt,{unit:Object(Gt.k)(p),valueType:e.valueType,text:e.isFullWidth?"-":e.quarter2}),o.a.createElement(xt,{unit:Object(Gt.k)(p),valueType:e.valueType,text:e.isFullWidth?"-":e.quarter3}),o.a.createElement(xt,{unit:Object(Gt.k)(p),valueType:e.valueType,text:e.isFullWidth?"-":e.quarter4}),o.a.createElement(xt,{unit:Object(Gt.k)(p),valueType:e.valueType,text:e.isFullWidth?"-":e.year}),o.a.createElement(xt,{unit:Object(Gt.k)(p),valueType:e.valueType,text:e.isFullWidth?"-":e.sum})))))),o.a.createElement(f.a,{fixed:!0,renderInPortal:!0},o.a.createElement(b.a,{buttonColor:"info",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-chevron-left"}),onClick:this.scrollLeft}),o.a.createElement(b.a,{buttonColor:"info",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-chevron-right"}),onClick:this.scrollRight}),o.a.createElement(b.a,{buttonColor:"success",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-save"}),onClick:this.onButtonClick}))))}}_t=Object(h.connect)(e=>({farm:e.location.farm,resultsGrid:e.grid.resultsGridData,loading:e.grid.loadingResultsGrid,plan:e.settings.plan,lang:e.language.lang.lang}))(_t);var Ut=_t=Object(U.a)()(_t),Vt=a("J2iB"),qt=a.n(Vt),zt=a("G7tO");class Yt extends o.a.Component{constructor(e){super(e),this.onNameChange=e=>{const{year:t}=this.state;this.setState({chartType:e,data:this.calculateData({props:this.props,value:e,year:t})})},this.onYearChange=e=>{this.setState({year:e}),this.calculateWorkerData(e)},this.onButtonClick=()=>{const{plan:e}=this.props;if(e){let t=e.clone();t.setPlan(this.state.year,this.state.plan.filter(e=>null!==e)),t.setPlan(this.state.year-1,this.state.planBefore.filter(e=>null!==e)),this.props.dispatch(Object(Lt.c)(t.prepareBeanToSave()))}else{let e=At.a.createSetting(Rt.a.YEARLY_PLANS,{Plans:[{Data:this.state.plan.filter(e=>null!==e),Year:this.state.year},{Data:this.state.planBefore.filter(e=>null!==e),Year:this.state.year-1}]});this.props.dispatch(Object(Lt.a)(e))}},this.state={planBefore:[],plan:[],year:z()().year(),chartType:void 0,loading:!1}}componentDidMount(){const{t:e}=this.props,{year:t}=this.state,a=e("planTypes.inseminatedRenovationSows");this.setState({chartType:a,data:this.calculateData({props:this.props,value:a,year:t})})}calculateWorkerData(e){let t=[],a=[],n=Object(W.getFarmStart)();this.props.plan&&this.props.plan.SetData.Plans.map(n=>{n.Year===e&&(t=n.Data),n.Year===e-1&&(a=n.Data)}),this.props.dispatch(Object(Ft.a)(this.props.farm,It()(this.props.resultsGrid),t,a,n,1,e))}UNSAFE_componentWillReceiveProps(e,t){if(this.props.loading!==e.loading&&setTimeout(()=>{this.setState({loading:e.loading})},100),this.props.lang!==e.lang&&this.calculateWorkerData(this.state.year),!s()(this.props.resultsGrid,e.resultsGrid)&&e.resultsGrid.length>0){let t=e.resultsGrid.map(e=>e.isFullWidth?null:e.before||0),a=e.resultsGrid.map(e=>e.isFullWidth?null:e.plan||0);const n=e.t(e.resultsGrid[0].name),{year:s}=this.state;this.setState({chartType:n,planBefore:t,plan:a,data:this.calculateData({props:e,value:n,year:s})})}}calculateData({props:e,value:t,year:a}){const{resultsGrid:n,t:s}=e;let i=[];if(0!==n.length)for(let r=0;rs(e.name)===t);i.push({amount:qt()(e)?0:e["week"+(r+1)],week:r+1})}return i}getYears(){let e=[];for(let t=Object(W.getFarmStart)().year();t<=z()().year();t++)e.push({name:t,value:t});return e}getResultsOptions(){const{resultsGrid:e,t:t}=this.props,a=[];for(let n=0;n({farm:e.location.farm,resultsGrid:e.grid.resultsGridData,loading:e.grid.loadingResultsGrid,plan:e.settings.plan,lang:e.language.lang.lang}))(Yt);var Kt=Yt=Object(U.a)()(Yt);class Zt extends o.a.Component{constructor(e){super(e),this.onSwitchView=e=>{this.setState({viewType:e})},this.state={viewType:1},P.a.modalview("farm/results")}render(){let e;const{viewType:t}=this.state,{t:a}=this.props,n=[{name:a("table"),value:1},{name:a("chart"),value:2}];return e=1===t?o.a.createElement(Ut,null):o.a.createElement(Kt,null),o.a.createElement(He.a,null,o.a.createElement(ge.a,{onChange:this.onSwitchView,value:t,options:n}),e)}}Zt=Object(U.a)()(Zt);var Xt=Object(B.a)({roles:[G.c._BREEDING],showInfo:!0})(Zt),Jt=a("qMm6"),Qt=a("AAik"),$t=(a("qfHk"),a("HGzA"));class ea extends l.Component{render(){const{value:e}=this.props;return e!==$t.a.DONE?null:o.a.createElement("i",{className:"fas fa-check success"})}}var ta=ea,aa=a("FivL"),na=a("ZVfr"),sa=a("0IDN");class ia extends l.Component{constructor(...e){super(...e),this.onClick=()=>{this.props.onMobileClick(this.props.object)}}render(){const{object:{Status:e,Title:t,Priority:a,EstimatedTime:n,AssignTo:s},employeeFormatter:i,t:r}=this.props;return o.a.createElement("div",{className:"task-item-mobile",onClick:this.onClick},e===$t.a.DONE&&o.a.createElement("div",{className:"task-done"},o.a.createElement("i",{className:"fas fa-check success"})),o.a.createElement("div",null,o.a.createElement("h4",null,t),o.a.createElement("div",null,r("eventGrid.operator"),": ",i(s)),o.a.createElement("div",null,r("priority"),": ",Object(na.a)(a)),o.a.createElement("div",null,r("estimatedTime"),": ",n,"h")),o.a.createElement("i",{className:"fas fa-chevron-right"}))}}var ra=Object(U.a)()(ia),la=a("ViHu"),oa=a("1aAG"),ca=a("7xGa"),ha=(a("zWej"),a("S8cm")),da=a("zTlQ"),ma=a("KYPV"),pa=a("Ze2Y");var ua=a("mzFT");class ga extends l.Component{constructor(...e){super(...e),this.state={top:0,left:0},this.container=o.a.createRef(),this.onOutsideClick=e=>{this.container.current&&!this.container.current.contains(e.target)&&this.props.onHide()}}static getDerivedStateFromProps(e,t){if(e.event){let a=e.event.clientY,n=e.event.clientX;if(a!==t.top||n!==t.left)return{top:a,left:n}}return null}componentDidMount(){document.addEventListener("mousedown",this.onOutsideClick)}componentWillUnmount(){document.removeEventListener("mousedown",this.onOutsideClick)}onChange(e,t){this.props.setFieldValue(t,e)}renderForm(e=!1){const{t:t,values:a,handleSubmit:n}=this.props,{top:s,left:i}=this.state;return o.a.createElement("form",{style:e?null:{top:s,left:i},ref:this.container,onSubmit:n,className:"task-filter".concat(e?" mobile":"")},o.a.createElement(He.a,null,o.a.createElement("h6",null,"Filtry"),o.a.createElement("div",{className:"filter-group"},o.a.createElement(ha.a,{label:t("toDo"),checked:a.todo,onChange:e=>this.onChange(e,"todo")}),o.a.createElement(ha.a,{label:t("taskDone"),checked:a.done,onChange:e=>this.onChange(e,"done")})),o.a.createElement(da.a,{label:t("task"),type:"text",value:a.Title,onChange:e=>this.onChange(e,"Title")}),o.a.createElement(Wt.a,{label:t("eventGrid.operator"),options:[],value:a.AssignTo,onChange:e=>this.onChange(e,"AssignTo")}),o.a.createElement("label",null,t("priority")),o.a.createElement("div",{className:"filter-group"},o.a.createElement(b.a,{onClick:()=>this.onChange(1===a.Priority?null:1,"Priority"),buttonColor:1===a.Priority?"success":"",type:"button"},t("morning")),o.a.createElement(b.a,{onClick:()=>this.onChange(2===a.Priority?null:2,"Priority"),buttonColor:2===a.Priority?"success":"",type:"button"},t("noon")),o.a.createElement(b.a,{onClick:()=>this.onChange(3===a.Priority?null:3,"Priority"),buttonColor:3===a.Priority?"success":"",type:"button"},t("afternoon"))),o.a.createElement("label",null,t("estimatedTime")),o.a.createElement("div",{className:"filter-group"},o.a.createElement(b.a,{onClick:()=>this.onChange(.5===a.EstimatedTime?null:.5,"EstimatedTime"),buttonColor:.5===a.EstimatedTime?"success":"",type:"button"},"0,5h"),o.a.createElement(b.a,{onClick:()=>this.onChange(1===a.EstimatedTime?null:1,"EstimatedTime"),buttonColor:1===a.EstimatedTime?"success":"",type:"button"},"1h"),o.a.createElement(b.a,{onClick:()=>this.onChange(2===a.EstimatedTime?null:2,"EstimatedTime"),buttonColor:2===a.EstimatedTime?"success":"",type:"button"},"2h"),o.a.createElement(b.a,{onClick:()=>this.onChange(4===a.EstimatedTime?null:3,"EstimatedTime"),buttonColor:4===a.EstimatedTime?"success":"",type:"button"},"3h")),!e&&o.a.createElement("div",{className:"filter-save"},o.a.createElement(b.a,{buttonColor:"success"},t("filterGrid.filter")))),e&&o.a.createElement("div",{className:"filter-save mobile"},o.a.createElement(b.a,{buttonColor:"success"},t("filterGrid.filter"))))}render(){const{event:e,t:t}=this.props;return Object(he.a)()?o.a.createElement(ua.a,{name:t("grid.filterOoo"),show:!!e,className:"filter-view-container"},this.renderForm(!0)):Nt.a.createPortal(o.a.createElement(ca.a,{in:!!e,mountOnEnter:!0,unmountOnExit:!0},this.renderForm()),document.getElementById("root"))}}ga.propTypes={show:u.a.bool,onHide:u.a.func.isRequired};var fa=Object(O.d)(Object(U.a)(),Object(h.connect)((function(e){return{farm:e.location.farm}})),Object(ma.c)({mapPropsToValues:()=>({todo:!0}),handleSubmit:function(e,t){const a={};(e.todo||e.done)&&(a.Status={$or:[]},e.todo&&a.Status.$or.push($t.a.OPENED),e.done&&a.Status.$or.push($t.a.DONE)),e.hasOwnProperty("Title")&&e.Title.length>0&&(a.Title={$regex:e.Title}),e.hasOwnProperty("AssignTo")&&(a.AssignTo=e.AssignTo),e.hasOwnProperty("Priority")&&null!==e.Priority&&(a.Priority=e.Priority),e.hasOwnProperty("EstimatedTime")&&null!==e.EstimatedTime&&(a.EstimatedTime=e.EstimatedTime),t.props.dispatch(Object(pa.c)(a)),t.props.onHide()}}))(ga),ba=a("xpEm"),Ea=a("Imit");function va(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function ya(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Oa extends l.Component{constructor(...e){super(...e),this.state={date:z()().format(z.a.HTML5_FMT.DATE),showDrawer:!1,showAddDrawer:!1,showFilter:null},this.timeValueFormatter=e=>e+"h",this.onRowClick=e=>{this.props.dispatch(Object(pa.d)(e)),this.props.show(aa.a)},this.onChangeDate=e=>{this.props.dispatch(Object(pa.a)(e))},this.onAddClick=()=>{Object(he.a)()?(this.props.dispatch(Object(pa.d)(null)),this.onMobileAddClick()):this.props.show(sa.a)},this.onMobileAddClick=()=>{this.setState({showAddDrawer:!0})},this.onMobileClick=e=>{this.props.dispatch(Object(pa.d)(e)),this.setState({showDrawer:!0})},this.onHideMobileModal=()=>{this.setState({showDrawer:!1})},this.onHideMobileAdd=()=>{this.setState({showAddDrawer:!1})},this.onFilterButtonClick=e=>{this.setState({showFilter:e})},this.onHideFilters=()=>{this.setState({showFilter:null})},this.employeeFormatter=e=>{const{employees:t}=this.props;let a=t.find(t=>t.LocalUserID===e);if(a)return a.userName}}componentDidMount(){this.props.dispatch(Object(pa.b)(+z.a.utc(this.state.date)))}render(){const{showDrawer:e,showAddDrawer:t,showFilter:a}=this.state,{t:n,tasks:s,filters:i,loading:r,date:l}=this.props,c=[{headerClassName:"index",itemClassName:"index",field:"Status",component:o.a.createElement(ta,null)},{name:n("task"),field:"Title",headerClassName:"task-cell",itemClassName:"task-cell"},{name:n("eventGrid.operator"),field:"AssignTo",valueFormatter:this.employeeFormatter},{name:n("priority"),field:"Priority",valueFormatter:na.a},{name:n("estimatedTime"),field:"EstimatedTime",valueFormatter:this.timeValueFormatter},{headerClassName:"index",itemClassName:"index",component:()=>o.a.createElement("i",{className:"fas fa-chevron-right"})}];let h=Object(he.a)();return o.a.createElement(He.a,{className:"task-list"},o.a.createElement(Bt.a,{isLoading:r}),o.a.createElement("h4",{className:"align-items-baseline"},o.a.createElement("i",{className:"fas fa-tasks mr-1"}),n("tasksToDo")),o.a.createElement("div",{className:"task-list-controllers"},o.a.createElement(Mt.a,{type:"date",value:l,onChange:this.onChangeDate}),o.a.createElement(b.a,{buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-filter"}),onClick:this.onFilterButtonClick}),o.a.createElement(fa,{event:a,onHide:this.onHideFilters})),o.a.createElement(Qt.a,{data:s.filter(Object(ba.a)(i)),headers:c,showPagination:!h,smallPagination:!0,onRowClick:this.onRowClick,paginationItems:5,mobileRow:o.a.createElement(ra,{onMobileClick:this.onMobileClick,employeeFormatter:this.employeeFormatter})}),o.a.createElement(f.a,{fixed:h,className:"justify-content-end"},o.a.createElement(b.a,{icon:o.a.createElement("i",{className:"fas fa-plus"}),buttonStyle:h?"round":"bordered",onClick:this.onAddClick,buttonColor:h?"success":""},n("addTask"))),o.a.createElement(aa.b,null),o.a.createElement(sa.b,null),o.a.createElement(la.a,{show:e,onHide:this.onHideMobileModal,onEditClick:this.onMobileAddClick}),o.a.createElement(oa.a,{show:t,onHide:this.onHideMobileAdd}))}}var wa=Object(O.d)(Object(U.a)(),Object(h.connect)((function(e){return{farm:e.location.farm,tasks:Object(Ea.e)(e),filters:Object(Ea.c)(e),loading:Object(Ea.d)(e),date:Object(Ea.b)(e),employees:e.user.employees}}),(function(e){return function(e){for(var t=1;t{this.setState({mapType:"devices"})},this.handleBuildingsClick=()=>{this.setState({mapType:"buildings"})},this.getIndex=()=>{const{selectedLevel:e=0}=this.state,{levels:t=[]}=this.props;return t.findIndex(t=>+t.name===+e)},this.setIndex=(e=0)=>{const{levels:t=[]}=this.props;t[e]&&this.setState({selectedLevel:+t[e].name})},this.goUp=()=>{const e=this.getIndex();this.setIndex(e+1)},this.goDown=()=>{const e=this.getIndex();this.setIndex(e-1)};const{devices:t}=this.props;this.state={mapType:t.length?"devices":"buildings"},P.a.modalview("farm/general")}render(){const{mapType:e,selectedLevel:t=0,event:a}=this.state,{t:n,levels:s,farm:i,devices:r}=this.props;if(!s.length)return o.a.createElement("div",null,o.a.createElement(k.a,{boxColor:"warning"},n("farms.tabs.mapTab.mapNotFound")," ",o.a.createElement(ja.a,{href:"/".concat(i,"/settings/buildings/map"),bolded:!0},n("here"))," ",n("farms.tabs.mapTab.toAddIt")));const l=this.getIndex();return o.a.createElement("div",null,!!r.length&&o.a.createElement(E.a,{event:a},o.a.createElement(v.a,{onClick:this.handleBuildingsClick},n("chambers")),o.a.createElement(v.a,{onClick:this.handleDevicesClick},n("farms.tabs.mapTab.devices"))),o.a.createElement(f.a,{fixed:!0,renderInPortal:!0},o.a.createElement(k.a,null,n("level")," ",t),o.a.createElement(o.a.Fragment,null,s.length>1&&o.a.createElement(o.a.Fragment,null,o.a.createElement(b.a,{type:"button",icon:o.a.createElement("i",{className:"fas fa-arrow-up"}),disabled:l+1>=s.length,onClick:this.goUp,buttonColor:"info",buttonStyle:"round"}),o.a.createElement(b.a,{type:"button",icon:o.a.createElement("i",{className:"fas fa-arrow-down"}),disabled:l<=0,onClick:this.goDown,buttonColor:"info",buttonStyle:"round"})),!!r.length&&o.a.createElement(b.a,{type:"button",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),onClick:e=>this.setState({event:e}),buttonColor:"info",buttonStyle:"round"}))),"devices"===e&&o.a.createElement(Ia.a,{selectedLevel:t}),"buildings"===e&&o.a.createElement(Ta.a,{selectedLevel:t}))}}Fa=Object(Qe.o)(Fa),Fa=Object(h.connect)((function(){return function(e){const t=Object(Sa.c)();return{farm:e.location.farm,levels:Object(ka.a)(e),devices:t(e,{DevType:[x.d.SCALE,x.d.CLIMATE]})}}}))(Fa);var Pa=Object(U.a)()(Fa),Na=a("kAUZ"),xa=a("zpA0"),Ma=a("op23"),Aa=a("bST7"),Ra=a("AsBE");function La(){return(La=Object.assign||function(e){for(var t=1;t{const{selected:t}=this.state;let a=t.slice(0);const n=a.findIndex(t=>t.DevID===e.DevID);-1===n?a.push(e):a.splice(n,1),this.setState({selected:a})},this.onMenuOpen=e=>{this.setState({event:e})},this.clearPolling=()=>{M.a.removeFromInterval(this.devicePolling),this.devicePolling=[]},this.startPolling=()=>{const{waterFlowMeters:e}=this.props;this.clearPolling();let t=Object(N.r)(e);if(t)for(let a of t.values())a[x.d.WATER_FLOW_METER].length&&(this.devicePolling.push(M.a.startSendingDeviceState(a[x.d.WATER_FLOW_METER])),M.a.sendRequestForAggregatedData(a[x.d.WATER_FLOW_METER]))},this.checkSelected=(e,t)=>!!~e.findIndex(e=>e.DevID===t),this.openModal=(e,t={})=>{const{show:a}=this.props;a(e,function(e){for(var t=1;t{this.openModal(xa.a)},this.onSettlementModalOpen=e=>{this.openModal(Ma.a,{chamberId:e})},this.onTransferModalOpen=e=>{this.openModal(Aa.a,{chamberId:e})},this.getSettlement=e=>{const{selected:t}=this.state,{settlements:a,fetched:n}=this.props;if(1===t.length){const s=r()(e.get(t[0].DevID),"CID");if(s){let e=at.a.getLocationByID(s);return e&&e.BgID?{state:K.a.NO_SHOW}:{CID:s,state:Object(K.e)(a.find(e=>e.PlcmntID===s),n)}}}return{state:K.a.NO_SHOW}},this.devicePolling=[],this.state={selected:[],event:null},Object(W.isUsingFakeData)()&&(R.a.restore(),R.a.stub(M.a,"startSendingDeviceState").callsFake(Ra.b),R.a.stub(M.a,"createAndSendMessageObject").callsFake(Ra.a),R.a.stub(M.a,"sendRequestForAggregatedData").callsFake(()=>{}),this.timer=setInterval(()=>{Object(Ra.c)(this.props.waterFlowMeters)},5e3))}componentDidMount(){this.startPolling()}componentWillUnmount(){R.a.restore(),this.clearPolling(),clearInterval(this.timer)}componentDidUpdate(e,t,a){const{waterFlowMeters:n}=this.props;n.length!==e.waterFlowMeters.length&&this.startPolling()}render(){const{waterFlowMeters:e,t:t,loading:a,buildings:n}=this.props,{event:s,selected:i}=this.state,r=Object(N.j)(n,e),{state:l,CID:c}=this.getSettlement(r),h=[{icon:"fas fa-cog fa-fw",action:this.onAlarmsModalOpen,name:t("deviceRows.waterFlowMeter.waterTab.alarms")},{icon:"fas fa-sign-in fa-rotate-270 fa-fw",action:()=>this.onSettlementModalOpen(c),name:t("settlement"),hide:l!==K.a.SHOW_SETTLEMENT},{icon:"fas fa-sign-out fa-rotate-270 fa-fw",action:()=>this.onTransferModalOpen(c),name:t("transfer"),hide:l!==K.a.SHOW_SEPARATION}];return e.length?o.a.createElement(o.a.Fragment,null,e.map((e,t)=>o.a.createElement(Na.a,La({},r.get(e.DevID)||{},{device:e,key:t,selected:this.checkSelected(i,e.DevID),onSelect:this.onSelect,onMenuOpen:this.onMenuOpen}))),o.a.createElement(f.a,{fixed:!0},o.a.createElement(E.a,{event:s},h.map((e,t)=>e.hide?null:o.a.createElement(v.a,{key:t,icon:o.a.createElement("i",{className:e.icon}),onClick:e.action},e.name))),o.a.createElement(k.a,{boxColor:"info"},ct.a.t("deviceRows.waterFlowMeter.waterTab.selected",{count:i.length})),o.a.createElement(b.a,{buttonStyle:"round",buttonColor:"info",type:"button",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),disabled:0===i.length,onClick:this.onMenuOpen})),o.a.createElement(xa.b,null),o.a.createElement(Ma.b,null),o.a.createElement(Aa.b,null)):o.a.createElement(_.a,{isLoading:a,dataLength:e.length,noDataText:t("deviceRows.waterFlowMeter.waterTab.waterFlowMetersNotFound")})}}Ga.propTypes={waterFlowMeters:u.a.shape({DevID:u.a.object.isRequired,GatewayID:u.a.object.isRequired}).isRequired},Ga=Object(h.connect)(null,e=>Object(O.b)({show:w.d},e))(Ga);let Ha=Object(h.connect)(e=>({loading:e.dataLoader.loading,buildings:e.farms.buildings,settlements:Object(K.b)(e),fetched:e.settlement.fetchedSettlement}))(Ga);Ha=Object(U.a)()(Ha);var _a=Object(B.a)({roles:[G.c._DEVICE_COUNTER],showInfo:!0})(Ha),Ua=a("yWPN"),Va=a("wT+U");function qa(){return(qa=Object.assign||function(e){for(var t=1;t{const{selected:t}=this.state;let a=t.slice(0);const n=a.findIndex(t=>t.DevID===e.DevID);-1===n?a.push(e):a.splice(n,1),this.setState({selected:a})},this.onMenuOpen=e=>{this.setState({event:e})},this.clearPolling=()=>{M.a.removeFromInterval(this.devicePolling),this.devicePolling=[]},this.startPolling=()=>{const{electricityFlowMeters:e}=this.props;this.clearPolling();let t=Object(N.r)(e);if(t)for(let a of t.values())a[x.d.ELECTRICITY_FLOW_METER].length&&(this.devicePolling.push(M.a.startSendingDeviceState(a[x.d.ELECTRICITY_FLOW_METER])),M.a.sendRequestForAggregatedData(a[x.d.ELECTRICITY_FLOW_METER]))},this.checkSelected=(e,t)=>!!~e.findIndex(e=>e.DevID===t),this.openModal=(e,t={})=>{const{show:a}=this.props;a(e,function(e){for(var t=1;t{this.openModal(Ma.a,{chamberId:e})},this.onTransferModalOpen=e=>{this.openModal(Aa.a,{chamberId:e})},this.getSettlement=e=>{const{selected:t}=this.state,{settlements:a,fetched:n}=this.props;if(1===t.length){const s=r()(e.get(t[0].DevID),"CID");if(s){let e=at.a.getLocationByID(s);return e&&e.BgID?{state:K.a.NO_SHOW}:{CID:s,state:Object(K.e)(a.find(e=>e.PlcmntID===s),n)}}}return{state:K.a.NO_SHOW}},this.devicePolling=[],this.state={selected:[],event:null},Object(W.isUsingFakeData)()&&(R.a.restore(),R.a.stub(M.a,"startSendingDeviceState").callsFake(Va.b),R.a.stub(M.a,"createAndSendMessageObject").callsFake(Va.a),R.a.stub(M.a,"sendRequestForAggregatedData").callsFake(()=>{}),this.timer=setInterval(()=>{Object(Va.c)(this.props.electricityFlowMeters)},5e3))}componentDidMount(){this.startPolling()}componentWillUnmount(){R.a.restore(),this.clearPolling(),clearInterval(this.timer)}componentDidUpdate(e,t,a){const{electricityFlowMeters:n}=this.props;n.length!==e.electricityFlowMeters.length&&this.startPolling()}render(){const{t:e,electricityFlowMeters:t,loading:a,buildings:n}=this.props,{event:s,selected:i}=this.state,r=Object(N.j)(n,t),{state:l,CID:c}=this.getSettlement(r),h=[{icon:"fas fa-sign-in fa-rotate-270 fa-fw",action:()=>this.onSettlementModalOpen(c),name:e("settlement"),hide:l!==K.a.SHOW_SETTLEMENT},{icon:"fas fa-sign-out fa-rotate-270 fa-fw",action:()=>this.onTransferModalOpen(c),name:e("transfer"),hide:l!==K.a.SHOW_SEPARATION}];return t.length?o.a.createElement(o.a.Fragment,null,t.map((e,t)=>o.a.createElement(Ua.a,qa({},r.get(e.DevID)||{},{device:e,key:t,selected:this.checkSelected(i,e.DevID),onSelect:this.onSelect,onMenuOpen:this.onMenuOpen}))),o.a.createElement(f.a,{fixed:!0},o.a.createElement(E.a,{event:s},h.map((e,t)=>e.hide?null:o.a.createElement(v.a,{key:t,icon:o.a.createElement("i",{className:e.icon}),onClick:e.action},e.name))),o.a.createElement(k.a,{boxColor:"info"},e("deviceRows.electricityFlowMeter.electricityTab.selected",{count:i.length})),o.a.createElement(b.a,{buttonStyle:"round",buttonColor:"info",type:"button",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),disabled:0===i.length,onClick:this.onMenuOpen})),o.a.createElement(Ma.b,null),o.a.createElement(Aa.b,null)):o.a.createElement(_.a,{isLoading:a,dataLength:t.length,noDataText:e("deviceRows.electricityFlowMeter.electricityTab.electricityFlowMetersNotFound")})}}Ka.propTypes={waterFlowMeters:u.a.shape({DevID:u.a.object.isRequired,GatewayID:u.a.object.isRequired}).isRequired},Ka=Object(h.connect)(null,e=>Object(O.b)({show:w.d},e))(Ka);let Za=Object(h.connect)(e=>({loading:e.dataLoader.loading,buildings:e.farms.buildings,settlements:Object(K.b)(e),fetched:e.settlement.fetchedSettlement}))(Ka);Za=Object(B.a)({roles:[G.c._DEVICE_COUNTER],showInfo:!0})(Za);var Xa=Object(U.a)()(Za),Ja=a("rIlU"),Qa=a("M6XY"),$a=a("lwfn"),en=a("S3n2");function tn(){return(tn=Object.assign||function(e){for(var t=1;t{const{selected:t}=this.state;let a=t.slice(0);const n=a.findIndex(t=>t.DevID===e.DevID);-1===n?a.push(e):a.splice(n,1),this.setState({selected:a})},this.onMenuOpen=(e,t)=>{r()(t,"DevType")===x.d.CHAIN_FEEDING?this.setState({selected:[t],event:e}):this.setState({event:e})},this.clearPolling=()=>{M.a.removeFromInterval(this.devicePolling),this.devicePolling=[]},this.startPolling=()=>{const{chainFeeding:e}=this.props;this.clearPolling();let t=Object(N.r)(e);if(t)for(let a of t.values())a[x.d.CHAIN_FEEDING].length&&(this.devicePolling.push(M.a.startSendingDeviceState(a[x.d.CHAIN_FEEDING])),M.a.sendRequestForAggregatedData(a[x.d.CHAIN_FEEDING]))},this.checkSelected=(e,t)=>!!~e.findIndex(e=>e.DevID===t),this.openModal=(e,t={})=>{const{show:a}=this.props;a(e,function(e){for(var t=1;t{this.openModal(Qa.a)},this.onStartChainModalOpen=()=>{const{show:e,t:t}=this.props,{selected:a}=this.state;e("confirm-modal",{title:t("deviceRows.chainFeeding.chainFeedingTab.startMotor"),text:t("deviceRows.chainFeeding.chainFeedingTab.startMotorText"),confirmText:t("start"),onConfirmed:e=>{a.forEach(e=>{Object($a.e)(e)}),e.handleHide()}})},this.onStopChainModalOpen=()=>{const{show:e,t:t}=this.props,{selected:a}=this.state;e("confirm-modal",{title:t("deviceRows.chainFeeding.chainFeedingTab.stopMotor"),text:t("deviceRows.chainFeeding.chainFeedingTab.stopMotorText"),confirmText:t("stop"),onConfirmed:e=>{a.forEach(e=>{Object($a.f)(e)}),e.handleHide()}})},this.devicePolling=[],this.state={selected:[],event:null},Object(W.isUsingFakeData)()&&(R.a.restore(),R.a.stub(M.a,"startSendingDeviceState").callsFake(en.c),R.a.stub(M.a,"createAndSendMessageObject").callsFake(en.b),R.a.stub(M.a,"sendRequestForAggregatedData").callsFake(()=>{}),this.timer=setInterval(()=>{Object(en.d)(this.props.chainFeeding)},en.a))}componentDidMount(){this.startPolling()}componentWillUnmount(){this.clearPolling(),clearInterval(this.timer),Object(W.isUsingFakeData)()&&R.a.restore()}componentDidUpdate(e,t,a){const{chainFeeding:n}=this.props;n.length!==e.chainFeeding.length&&this.startPolling()}render(){const{chainFeeding:e,t:t,loading:a,buildings:n}=this.props,{event:s,selected:i}=this.state,r=Object(N.j)(n,e),l=[{icon:"fas fa-cog fa-fw",action:this.onConfigurationModalOpen,name:t("configuarion")},{icon:"fas fa-play fa-fw",action:this.onStartChainModalOpen,name:t("deviceRows.chainFeeding.chainFeedingTab.startMotor")},{icon:"fas fa-stop fa-fw",action:this.onStopChainModalOpen,name:t("deviceRows.chainFeeding.chainFeedingTab.stopMotor")}];return e.length?o.a.createElement(o.a.Fragment,null,e.map((e,t)=>o.a.createElement(Ja.a,tn({},r.get(e.DevID)||{},{device:e,key:t,selected:this.checkSelected(i,e.DevID),onSelect:this.onSelect,onMenuOpen:this.onMenuOpen}))),o.a.createElement(f.a,{fixed:!0},o.a.createElement(E.a,{event:s},l.map((e,t)=>e.hide?null:o.a.createElement(v.a,{key:t,icon:o.a.createElement("i",{className:e.icon}),onClick:e.action},e.name))),o.a.createElement(k.a,{boxColor:"info"},t("deviceRows.chainFeeding.chainFeedingTab.selected",{count:i.length})),o.a.createElement(b.a,{buttonStyle:"round",buttonColor:"info",type:"button",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),disabled:0===i.length,onClick:this.onMenuOpen})),o.a.createElement(Qa.b,null)):o.a.createElement(_.a,{isLoading:a,dataLength:e.length,noDataText:t("deviceRows.chainFeeding.chainFeedingTab.chainFeedingNotFound")})}}sn.propTypes={chainFeeding:u.a.shape({DevID:u.a.object.isRequired,GatewayID:u.a.object.isRequired}).isRequired},sn=Object(h.connect)(null,e=>Object(O.b)({show:w.d},e))(sn);let rn=Object(h.connect)(e=>({loading:e.dataLoader.loading,buildings:e.farms.buildings}))(sn);rn=Object(U.a)()(rn);var ln=Object(B.a)({roles:[G.c._DEVICE_CHAIN],showInfo:!0})(rn),on=a("YDFS"),cn=a("fxKK"),hn=a("iWju"),dn=a("MYfV"),mn=a("BvFm"),pn=a("Ke8t");function un(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function gn(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class fn extends l.Component{constructor(e){super(e),this.onButtonClick=e=>{this.setState({event:e})},this.onSelect=e=>{let t=this.state.selectedPigletScales.slice(0);t.filter(t=>t.DevID===e.DevID).length>0?t=t.filter(t=>t.DevID!==e.DevID):t.push(e),this.setState({selectedPigletScales:t})},this.onRightClick=(e,t)=>{this.setState({event:e,selectedPigletScales:[t]})},this.onNewSettlementClick=()=>{this.props.show(hn.a,{scales:this.state.selectedPigletScales})},this.onEndSettlementClick=()=>{const{t:e}=this.props;this.props.show(C.a,{text:e("modals.chamberTransferModal.endInsertionText"),title:e("modals.chamberTransferModal.titleEndInsertion"),confirmText:e("yes"),onConfirmed:e=>{let t=[];for(let a of this.state.selectedPigletScales)t.push(Object(Y.m)({DevID:a.DevID}));Promise.all(t).then(e=>{Object(Y.b)(e)}).catch(e=>{Object(Y.a)(e)}),e.handleHide()}})},this.onSettingsClick=()=>{this.props.show(dn.a,{scales:this.state.selectedPigletScales})},this.state={selectedPigletScales:[],event:null}}checkIfDisableStart(){const{selectedPigletScales:e}=this.state,{settlements:t}=this.props;for(let a of e){let e=a.getLocation();if(0===e.length)return!0;let n=Object(H.j)(e[0]);if(!n)return!0;let s=t.find(e=>e.PlcmntID===n&&(!e.DtaEndTime||e.DtaEndTime>(new Date).getTime()));if(s){if(!a.Settings.Insertions)return!0;if(!!a.Settings.Insertions.find(e=>e.StartTime===s.DtaStartTime))return!0}}return!1}checkIfDisableEnd(){const{selectedPigletScales:e}=this.state,{settlements:t}=this.props;for(let a of e){let e=a.getLocation();if(0===e.length)return!0;let n=Object(H.j)(e[0]);if(!n)return!0;let s=t.find(e=>e.PlcmntID===n&&!e.DtaEndTime);if(!s||!a.Settings.Insertions)return!0;if(!a.Settings.Insertions.find(e=>e.StartTime===s.DtaStartTime))return!0}return!1}render(){const{selectedPigletScales:e,event:t}=this.state,{scales:a,t:n,loading:s}=this.props;return a.length?o.a.createElement(o.a.Fragment,null,a.map(t=>o.a.createElement(cn.a,{scale:t,key:t.DevID,selected:e.filter(e=>e.DevID===t.DevID).length>0,onSelect:this.onSelect,onRightClick:this.onRightClick})),o.a.createElement(f.a,{fixed:!0},o.a.createElement(E.a,{event:t},o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-arrow-up fa-fw"}),onClick:this.onNewSettlementClick,disabled:this.checkIfDisableStart()},n("settlement")),o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-stop-circle fa-fw"}),onClick:this.onEndSettlementClick,disabled:this.checkIfDisableEnd()},n("transfer")),Object(mn.i)()&&o.a.createElement(v.a,{icon:o.a.createElement("i",{className:"fas fa-cog fa-fw"}),onClick:this.onSettingsClick},n("settings.settings"))),o.a.createElement(k.a,{boxColor:"info"},n("farmView.pigletScale.selectedPigletScales",{count:e.length})),o.a.createElement(b.a,{buttonColor:"info",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-ellipsis-v"}),onClick:this.onButtonClick,disabled:0===e.length})),o.a.createElement(hn.b,null),o.a.createElement(dn.b,null)):o.a.createElement(_.a,{dataLength:a.length,isLoading:s,noDataText:n("farmView.pigletScale.pigletScalesNotFound")})}}fn.propTypes={scales:u.a.arrayOf(u.a.instanceOf(on.a)).isRequired};var bn,En=Object(O.d)(Object(B.a)({roles:[pn.DEVICE_PIGLET_CAGE],showInfo:!0}),Object(U.a)(),Object(h.connect)((function(e){return{farm:e.location.farm,settlements:e.settlement.settlement}}),(function(e){return function(e){for(var t=1;t({user:e.user.user,farms:e.farms.farms,farm:e.location.farm,devices:e.farmDevices.devices,blockSwipeFeeding:!!e.feeding.feeding.size,dataLoaderLoading:e.dataLoader.loading,lang:e.language.lang.lang,licPackages:Object(ve.b)(e)}))(bn=class e extends o.a.Component{constructor(t){super(t),this.onTabChange=e=>{const{tabs:t}=this.state,{farm:a,history:n}=this.props;n.push("/".concat(a,"/farm/").concat(r()(t[e],"key")))},this.state=yn({tab:0},e.getData(t)),this.props.match.params.viewType||this.onTabChange(0)}static getData(e){const t=[{key:"general",namePath:ct.a.t("general"),packageKeys:[G.a.ALARM],packageLevels:[G.b.BASIC]},{key:"inventory",namePath:ct.a.t("inventory"),packageKeys:[G.a.SOW,G.a.PORKER],packageLevels:[G.b.BASIC,G.b.BASIC]},{key:"feeding",namePath:ct.a.t("feeding"),packageKeys:[G.a.DISPENSER,G.a.DISPENSER_5G],packageLevels:[G.b.BASIC,G.b.BASIC]},{key:"climate",namePath:ct.a.t("climate"),packageKeys:[G.a.CLIMATE],packageLevels:[G.b.BASIC]},{key:"cage",namePath:ct.a.t("cage"),packageKeys:[G.a.CAGE],packageLevels:[G.b.BASIC]},{key:"weights",namePath:ct.a.t("weights"),packageKeys:[G.a.SMALL_CAGE],packageLevels:[G.b.BASIC]},{key:"silo",namePath:ct.a.t("siloses"),packageKeys:[G.a.SILO],packageLevels:[G.b.BASIC]},{key:"water",namePath:ct.a.t("water"),packageKeys:[G.a.COUNTER],packageLevels:[G.b.BASIC]},{key:"electricity",namePath:ct.a.t("electricity"),packageKeys:[G.a.COUNTER],packageLevels:[G.b.BASIC]},{key:"chainFeeding",namePath:ct.a.t("chainFeeding"),packageKeys:[G.a.CHAIN],packageLevels:[G.b.BASIC]},{key:"map",namePath:ct.a.t("map"),packageKeys:[G.a.ADMINISTRATION],packageLevels:[G.b.BASIC]},{key:"results",namePath:ct.a.t("results.results"),packageKeys:[G.a.SOW,G.a.PORKER],packageLevels:[G.b.BASIC,G.b.BASIC]}],a=e.farms.find(t=>t.FarmID===e.match.params.FarmID),n=e.devices,s=t.filter(t=>{const{key:a}=t;return"results"===a?!Object(he.a)()&&Object(mn.k)(e.licPackages,t.packageKeys,t.packageLevels):Object(mn.k)(e.licPackages,t.packageKeys,t.packageLevels)}),i=e.match.params.viewType;let l=s.findIndex(e=>e.key===i);-1===l&&(l=0);const o=r()(s[l],"key","");return{index:l,redirect:i!==o,viewType:o,tabs:s,licPackages:e.licPackages,farm:a,devices:n,FarmID:e.match.params.FarmID}}static getDerivedStateFromProps(t,a){return s()(t.lang,a.lang)&&t.match.params.viewType===a.viewType&&t.match.params.FarmID===a.FarmID&&s()(t.devices,a.devices)&&s()(t.licPackages,a.licPackages)?null:yn({},e.getData(t))}componentDidMount(){const{redirect:e,viewType:t}=this.state;if(e){const{farm:e,history:a}=this.props;a.replace("/".concat(e,"/farm/").concat(t))}}componentDidUpdate(e,t,a){const{redirect:n,viewType:s}=this.state;if(t.redirect!==n&&n){const{farm:e,history:t}=this.props;t.replace("/".concat(e,"/farm/").concat(s))}}componentWillUnmount(){R.a.restore()}render(){const{farm:e,devices:t,tabs:a,viewType:n,index:s}=this.state,{t:i}=this.props,r=a.map(e=>({name:i(e.namePath)}));if(console.log(r),!e)return o.a.createElement(d.a,null);const l=[],h=[],p=[],u=[],g=[],f=[];t.forEach(e=>{switch(e.DevType){case x.d.SCALE:l.push(e);break;case x.d.CAGE:h.push(e);break;case x.d.WATER_FLOW_METER:p.push(e);break;case x.d.ELECTRICITY_FLOW_METER:u.push(e);break;case x.d.CHAIN_FEEDING:g.push(e);break;case x.d.SMALL_CAGE:f.push(e)}});const b=Object(N.m)(l);return o.a.createElement("div",null,o.a.createElement(c.a,{text:e.FarmName,tabs:r,onTabChange:this.onTabChange,active:s}),o.a.createElement(m.a,{addPaddingForButtons:!["general","map"].includes(n)},"general"===n&&o.a.createElement(Da,{key:"general"}),"inventory"===n&&o.a.createElement(bt,{key:"inventory",loc:e,level:Ge.a.FARM}),"feeding"===n&&o.a.createElement(Be,{key:"feeding",dataKey:[]}),"climate"===n&&o.a.createElement(le,{key:"climate"}),"cage"===n&&o.a.createElement(J,{key:"cage",cages:h}),"weights"===n&&o.a.createElement(En,{key:"weights",scales:f}),"silo"===n&&o.a.createElement(Dt,{key:"silo",siloses:b}),"water"===n&&o.a.createElement(_a,{key:"water",waterFlowMeters:p}),"electricity"===n&&o.a.createElement(Xa,{key:"electricity",electricityFlowMeters:u}),"chainFeeding"===n&&o.a.createElement(ln,{key:"chainFeeding",chainFeeding:g}),"map"===n&&o.a.createElement(Pa,{key:"map"}),"results"===n&&o.a.createElement(Xt,{key:"results"})))}})||bn;t.default=Object(U.a)()(wn)},AL2E:function(e,t,a){},qMm6:function(e,t,a){"use strict";var n=a("mwIZ"),s=a.n(n),i=a("q1tI"),r=a.n(i),l=a("/MKj"),o=a("VyNe"),c=a("t/ex"),h=a("AF5L"),d=a("zDJl"),m=a("U4jM"),p=a("FZxm"),u=a("udB/"),g=a("mzFT"),f=a("UGc4"),b=a("0pzG"),E=a("gu+X"),v=a("zM5D"),y=a("v9qu"),O=a("TLA/"),w=a("LCzB"),C=a("q17X"),D=a("vSUv"),j=a.n(D),k=a("YNSP"),S=a("XzT5"),I=a("tbNj");const T={DevType:d.d.GATEWAY,showExpired:!1};const F=[3,9];class P extends i.Component{constructor(e){super(e),this.onExpand=e=>{this.setState({alarmData:e,show:!0})},this.onHide=()=>{this.setState({show:!1})},this.placeRenderer=e=>{const{t:t}=this.props;switch(e.length){case 0:return t("missingLocation");case 1:return r.a.createElement("span",{title:e[0].join(" - ")},e[0].join(" - "));default:return r.a.createElement("span",{title:e.map(e=>e.join(" - ")).join("\n")},S.a.t("farms.tabs.generalTab.manyLocationsX",{count:e.length}))}},this.errorRenderer=(e,t)=>{const{_passThrough:{other:a=[]}}=t;return a.length>1?S.a.t("farms.tabs.generalTab.manyAlertsX",{count:a.length}):S.a.t(e.key,e.params)},e.dispatch(Object(m.b)()),this.state={alarmData:null,show:!1}}componentDidUpdate(e,t,a){const{gateways:n}=this.props;e.gateways.length!==n.length&&this.getData(this.props)}componentDidMount(){Object(C.isUsingFakeData)()&&(j.a.restore(),j.a.stub(P.prototype,"getData").callsFake(k.a)),this.getData(this.props),this.interval=setInterval(()=>{this.getData(this.props)},12e4)}componentWillUnmount(){Object(C.isUsingFakeData)()&&j.a.restore(),clearInterval(this.interval)}getData(e,{limit:t=500}={}){if(!Object(C.isUsingFakeData)()){const{gateways:a,dispatch:n}=e;a.forEach(e=>{n(Object(m.c)(e.GatewayID,!0)),Object(h.h)(e,{limit:t},{onSuccess:t=>{n(Object(m.a)(e.GatewayID,s()(t,"CAnsw.alarms",{})))},onFailure:()=>{n(Object(m.c)(e.GatewayID,!1))},onSend:()=>{n(Object(m.c)(e.GatewayID,!0))}})})}}render(){const{data:e,fetching:t,t:a,gateways:n,fetched:s}=this.props,i=t,{show:l,alarmData:h}=this.state,d=r.a.createElement(O.a,{alarm:h}),m=Object(y.a)(),p=!e.length&&i,w=!!e.length&&i;return n.length?r.a.createElement(o.a,{className:e.length?"w-100 d-flex flex-column":"mh-15rem w-100 d-flex flex-column"},r.a.createElement("h4",{className:"align-items-baseline"},r.a.createElement("i",{className:"fas fa-bell-exclamation mr-1"}),a("alarms")," ",w&&r.a.createElement("i",{className:"fas fa-spin fa-circle-notch ml-1"})),r.a.createElement("div",{className:"position-relative h-100"},!!n.length&&r.a.createElement(r.a.Fragment,null,r.a.createElement(u.a,{isLoading:p,bgInherit:!0,type:"component"}),r.a.createElement(c.a,{loading:i,mobile:m,onExpand:this.onExpand,data:e,sizing:F,options:{subtitle:{rtl:!0,renderer:this.placeRenderer},text:{bold:!0,renderer:this.errorRenderer}},pageSize:10,maxPages:Math.ceil(e.length/10)})),!e.length&&!i&&r.a.createElement("p",{className:"d-flex align-items-center justify-content-center text-center opacity-75 h-100"},a(s?"farms.tabs.generalTab.noAlarmsFound":"farms.tabs.generalTab.errorLoadingData"),r.a.createElement("i",{className:"fas ml-1 fa-".concat(s?"smile success":"exclamation-triangle warning")}))),m&&r.a.createElement(g.a,{name:a("farms.tabs.generalTab.alertDetails"),show:l,onHide:this.onHide},r.a.createElement(o.a,null,d)),!m&&r.a.createElement(v.a,{onHide:this.onHide,show:l,size:"lg"},r.a.createElement(f.b,{title:a("farms.tabs.generalTab.alertDetails"),onCloseClick:this.onHide}),r.a.createElement(b.a,null,d),r.a.createElement(E.a,{hasConfirmButton:!1,confirmText:a("close"),onCloseClick:this.onHide}))):null}}P=Object(l.connect)((function(){return function(e){const t=Object(I.c)();return{data:Object(p.a)(e,T),gateways:t(e,T),fetching:Object(p.c)(e,null),fetched:Object(p.b)(e,null),dataLoaderActive:e.dataLoader.loading}}}))(P),t.a=Object(w.a)()(P)},qfHk:function(e,t,a){},zWej:function(e,t,a){}}]); //# sourceMappingURL=main~a8481488.8dcebd92.chunk.js.map