(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[9],{"+bso":function(e,t,a){"use strict";a.d(t,"b",(function(){return p}));var n=a("q1tI"),r=a.n(n),i=a("vzZS"),s=(a("q/KM"),a("VyNe")),o=a("zTlQ"),l=a("3Z9Z"),c=a("JI6e"),m=a("uSQv"),u=a("ANjH"),h=a("Ty5D"),d=a("kiXb");function p(){let e="";return e=a("tjUo").bugsnagClient,e}class b extends n.Component{constructor(e){super(e),this.forceRedirectToHomePage=()=>{try{this.props.history.push("/"),setTimeout(()=>window.location.reload(),250)}catch(e){}},this.reportBugSubmit=()=>{console.log(this.props,this.state.message);let e=p();e&&(e.notify(new Error("Bug submit form"),{severity:"warn",metaData:{feedback:{userMessage:this.state.message,message:this.props.error?this.props.error.message:"",stack:this.props.error?this.props.error.stack:"",info:this.props.info}}}),this.setState({reportSent:!0,message:""}))},this.state={message:""}}render(){const{reportSent:e,message:t}=this.state;return r.a.createElement("div",{className:"fallback-error col-12"},r.a.createElement(l.a,{bsPrefix:"row h-100 justify-content-center align-items-center w-100 mx-auto"},r.a.createElement(c.a,{lg:6},r.a.createElement(s.a,null,r.a.createElement("h4",{className:"align-items-center"},r.a.createElement("i",{className:"fas fa-fw fa-exclamation-triangle"})," ",d.a.t("fallbackErrorView.appCrashed")),r.a.createElement("p",null,d.a.t("fallbackErrorView.appCrashedLong")," ",r.a.createElement(m.a,{type:"button",className:"redirect-button",onClick:this.forceRedirectToHomePage},d.a.t("clickHere"))," ",d.a.t("fallbackErrorView.appCrashedLong2")),e&&r.a.createElement(i.a,{boxColor:"info"},d.a.t("fallbackErrorView.reportSent")),!e&&r.a.createElement(r.a.Fragment,null,r.a.createElement(o.a,{value:t,onChange:e=>this.setState({message:e}),type:"textarea",label:d.a.t("fallbackErrorView.lastActions")}),r.a.createElement(m.a,{type:"button",buttonStyle:t?"":"text",disabled:!t,className:"float-right",buttonColor:"primary",onClick:this.reportBugSubmit},d.a.t("send")))))))}}t.a=Object(u.d)(h.o)(b)},"/051":function(e,t,a){},"14XZ":function(e,t,a){"use strict";a.r(t),a.d(t,"HelpView",(function(){return f}));var n=a("q1tI"),r=a.n(n),i=a("qx5e"),s=a("s506"),o=a("XSU/"),l=a("3Z9Z"),c=a("g9Zw"),m=a("2tEe"),u=a("2JXq"),h=a("OomU"),d=a("1KXW"),p=a("jP9d"),b=a("LCzB");class f extends r.a.Component{render(){return r.a.createElement("div",null,r.a.createElement(o.a,{text:this.props.t("help")}),r.a.createElement(m.a,null,r.a.createElement(l.a,{className:"card-container"},r.a.createElement(c.a,{title:this.props.t("color"),icon:d.a,modal:u.a}),r.a.createElement(c.a,{title:this.props.t("contact"),icon:p.a,modal:h.a})),r.a.createElement(u.b,null),r.a.createElement(h.b,null)))}}f=Object(i.a)({roles:[s.c._GENERAL_READ],showComponent:!0})(f),t.default=Object(b.a)()(f)},"3UCo":function(e,t,a){"use strict";a.r(t);var n=a("mwIZ"),r=a.n(n),i=a("q1tI"),s=a.n(i),o=a("/MKj"),l=a("0ajJ"),c=a("98E9"),m=a("XSU/"),u=a("JRww"),h=a("2tEe"),d=a("VyNe"),p=a("eWv+"),b=a("pDHb"),f=a("NK1v"),g=a("tnGu"),E=a("fe8b"),v=a("c7k8"),O=a("b9ZJ"),y=a("wQVC"),D=a("3Z9Z"),w=a("LCzB"),j=a("/KDD");class C extends i.Component{constructor(...e){super(...e),this.cache=new v.c({defaultHeight:Object(y.f)(3),fixedWidth:!0,keyMapper:e=>r()(this,"props.logs[".concat(e,"].log.LogID"),e)}),this.clearCache=()=>{console.log("clear cache"),this.cache.clearAll()},this.rowRenderer=({index:e,style:t,key:a,parent:n})=>{const{logs:r}=this.props,i=r[e]||{};return s.a.createElement(v.b,{cache:this.cache,columnIndex:0,key:a,parent:n,rowIndex:e},({measure:a})=>s.a.createElement(c.a,{style:t,log:i,key:e,index:e,measure:a}))},this.noRowsRenderer=()=>{const{fetching:e,t:t}=this.props;return e?s.a.createElement("div",{className:"mh-5rem pb-4 pt-4 d-flex justify-content-center w-100 align-items-center"},s.a.createElement("i",{className:"fas fa-fw fa-spin fa-circle-notch fa-2x"})):s.a.createElement("div",{className:"mh-5rem pb-4 pt-4 d-flex justify-content-center opacity-50 w-100 align-items-center"},s.a.createElement("h4",null,s.a.createElement("span",null,t("logsNotFound"))))}}componentDidMount(){const{dispatch:e}=this.props;e(Object(b.b)())}componentDidUpdate(e,t,a){this.props.logs.lengths.a.createElement(l.a,{itemRef:o,useFlexLayout:!1,striped:!0},s.a.createElement(g.a,{index:-1}),s.a.createElement(O.List,{rowCount:e.length,width:window.innerWidth,rowRenderer:this.rowRenderer,scrollTop:r,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}),!!e.length&&s.a.createElement(E.a,{index:e.length})))))))}}C=Object(o.connect)((function(e){return{logs:Object(p.c)(e),fetching:e.logs.fetching}}))(C),t.default=Object(w.a)()(C)},"7PUi":function(e,t,a){},"9fWS":function(e,t,a){"use strict";a.r(t),a.d(t,"FarmChooserView",(function(){return z})),a.d(t,"_FarmChooserView",(function(){return _}));var n,r=a("sEfC"),i=a.n(r),s=a("q1tI"),o=a.n(s),l=a("/MKj"),c=a("3Z9Z"),m=a("JI6e"),u=a("jQw+"),h=a("Ty5D"),d=a("6uZD"),p=a("ZRKa"),b=a("XSU/"),f=a("2tEe"),g=a("4ltZ"),E=a("s506"),v=a("BvFm"),O=a("uuQq"),y=a("EE6H"),D=a("rzZ0"),w=a("IXwn"),j=a("uSQv"),C=a("Akpi"),F=a("/kok"),I=a("85nz"),A=a("JFDi"),S=a("qx5e"),R=a("vzZS"),N=a("i8MS"),P=a("pBTy"),k=a("LCzB"),x=a("U4G4"),M=a("v9qu"),T=a("WFNR"),B=a("0MVo"),V=a("JsV9"),L=a("ANjH"),G=a("f0zD");function W(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 U(e){for(var t=1;t({farms:e.farms.farms,user:e.user.user,userAttributes:e.user.attributes,snsEndpoint:e.sns.endpointArn,endpoint:e.settings.endpointArn,FarmData:e.user.user.FarmData}))(n=class extends o.a.Component{constructor(e){super(e),this.setFarms=i()(async(e,t,a)=>{await this.setState({farms:Object(T.a)(Object(T.b)(e,t),a)})},200),this.logout=()=>{Object(A.b)()},this.onFarmClick=async e=>{Object(I.b)(e)?(F.a.clearSubscriptions(),F.a.clearQueue(),this.state.isService&&(this.props.dispatch(Object(O.a)(e.ClientID,e.FarmID)),this.props.user.ClientID!==e.ClientID?(await y.f.loadDatabase("".concat(this.props.userAttributes.sub,"_").concat(e.ClientID)),this.props.dispatch({type:"CLEAR_DICTIONARY"})):this.props.dispatch(Object(C.f)(e.ClientID))),N.a.getAllAnimalsForLocation.cache.clear(),this.props.dispatch({type:"CHANGE_FARM",payload:e.FarmID}),this.props.dispatch({type:"SHOW_NAVIGATION"}),this.props.dispatch(Object(d.d)(e.FarmID)),this.props.user.ClientID!==e.ClientID&&this.state.isService||F.a.subscribeAllTopics(),this.props.dispatch(Object(D.c)(e.FarmID)),this.props.dispatch({type:"LIST_ALL_SETTINGS",payload:p.a.getAllSettings(e.FarmID),meta:{user:this.props.user}}),this.props.dispatch(Object(g.d)(e.FarmID)),this.props.history.push("/")):Object(v.h)()&&this.redirect("/farmSettings/billing/farm/".concat(e.FarmID,"/renew"))},this.redirect=(e="/",t=!1)=>{const{history:a}=this.props;a.push({pathname:e,state:{forceFetch:t}})},this.redirectToFarmSettings=e=>{const{user:t,dispatch:a}=this.props,n=Object(v.i)();let r=!1;if(e.length>0&&Array.isArray(e)){const{FarmID:i,ClientID:s}=e[0];n&&t.ClientID!==s&&(r=!0,a(Object(O.a)(s,i)))}const i=Object(v.h)()||n||Object(v.f)()?"/farmSettings/users":"/";return this.redirect(i,r)},this.onEditAlias=(e,t)=>{this.props.show(V.a,{ClientID:e,Alias:t})},this.state={search:"",farms:[],isService:Object(v.i)()}}componentDidMount(){const{search:e}=this.state,{user:t,farms:a,FarmData:n}=this.props;F.a.clearSubscriptions(),F.a.clearQueue(),this.setState({farms:Object(T.a)(Object(T.b)(a,t),e)}),this.props.dispatch({type:"HIDE_SIDE_NAVIGATION"}),this.props.dispatch({type:"CHANGE_FARM"}),this.props.dispatch({type:"GET_FARMS",payload:n})}componentWillUnmount(){this.props.dispatch({type:"SHOW_NAVIGATION"})}componentDidUpdate(e,t,a){const{search:n}=this.state,{farms:r,user:i}=this.props;t.search===n&&r===this.state.farms||this.setFarms(r,i,n)}render(){const{t:e}=this.props,{farms:t}=this.state,a=Object(v.h)()||Object(v.g)(),n=Object(v.i)(),r=Object(v.b)()||n,i=Object(M.a)();return o.a.createElement("div",null,o.a.createElement(b.a,{text:e("farmChooser.header")}),o.a.createElement(w.a,{fixed:!0,className:"farm-chooser-buttons"},o.a.createElement(j.a,{buttonColor:"secondary",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-power-off"}),onClick:this.logout}),a&&!i&&o.a.createElement(j.a,{buttonColor:"success",buttonStyle:"round",icon:o.a.createElement("i",{className:"fas fa-cogs"}),disabled:!r,onClick:this.redirectToFarmSettings.bind(this,t)})),o.a.createElement(f.a,{addPaddingForButtons:!0},0===t.length&&o.a.createElement(R.a,{boxColor:"warning"},e("farmChooser.noFarms")),t.length>0&&!n&&o.a.createElement(o.a.Fragment,null,o.a.createElement(c.a,{className:"farm-container pt-3"},!n&&t.map((e,t)=>o.a.createElement(u.a,{isService:!1,farm:e,onClick:this.onFarmClick.bind(this,e),key:t})))),n&&o.a.createElement(o.a.Fragment,null,o.a.createElement(x.a,{className:"mb-2",value:this.state.search,onChange:e=>this.setState({search:e})}),[...t.entries()].map(([e,{name:t,farms:a}],r)=>o.a.createElement(c.a,{key:e,className:"farm-container",index:r},o.a.createElement(m.a,{md:12,className:"farm-row mb-3 pt-1 pb-1"},o.a.createElement(c.a,null,o.a.createElement(m.a,{xs:12,className:"d-flex align-items-center justify-content-center"},!i&&n&&o.a.createElement(j.a,{buttonStyle:"text",buttonColor:"success",className:"round mr-2",icon:o.a.createElement("i",{className:"fas fa-cogs"}),onClick:this.redirectToFarmSettings.bind(this,a)}),t,!!n&&o.a.createElement(j.a,{buttonStyle:"text",buttonColor:"success",className:"round ml-2",icon:o.a.createElement("i",{className:"fas fa-pen"}),onClick:()=>this.onEditAlias(e,t)})),o.a.createElement(m.a,{xs:12,className:"d-flex align-items-center justify-content-center"},o.a.createElement("small",{className:"pointer",onClick:()=>Object(B.a)(e)},"(",e,")")))),a.map((t,a)=>o.a.createElement(u.a,{farm:t,isService:!0,search:this.state.search,onClick:this.onFarmClick.bind(this,U({},t,{ClientID:e})),key:t.FarmID}))))),o.a.createElement(V.b,null)),o.a.createElement(P.a,null))}})||n;const _=z;z=Object(l.connect)(null,e=>Object(L.b)({show:G.d},e))(z),z=Object(S.a)({roles:[E.c._GENERAL_READ],showComponent:!0})(z),z=Object(h.o)(z),t.default=Object(k.a)()(z)},"C+OZ":function(e,t,a){},DV4J:function(e,t,a){},EYNM:function(e,t,a){},LQwS:function(e,t,a){"use strict";a.r(t);var n=a("q1tI"),r=a.n(n),i=(a("ozwV"),a("Ty5D")),s=a("s506"),o=a("aG8S"),l=a("Y+p1"),c=a.n(l),m=a("mwIZ"),u=a.n(m),h=a("XSU/"),d=a("VyNe"),p=a("2tEe"),b=(a("C+OZ"),a("wd/R")),f=a.n(b),g=a("/MKj"),E=a("JZab"),v=a("AAik"),O=a("uSQv"),y=a("udB/"),D=a("i7k/"),w=a("4H+U"),j=a("v9qu"),C=a("ANjH"),F=a("f0zD"),I=a("Akpi"),A=a("42VQ"),S=a("/U+v"),R=a("JFDi"),N=a("LCzB"),P=a("3Z9Z"),k=a("JI6e"),x=a("TAe8"),M=(a("nWo0"),a("ANfW")),T=a("AM6L"),B=a("q+9f"),V=a("BvFm"),L=a("CuyV");function G(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 W(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const U="Active",q="Canceled";class z extends r.a.Component{constructor(...e){super(...e),this.onCancelSubscriptionClick=()=>{const{farm:e,sub:t,attributes:a,t:n,dispatch:r,show:i}=this.props;i(A.a,{title:n("farmSettings.billingFarmView.cancel"),text:n("farmSettings.billingFarmView.cancelText",{name:e.FarmName}),onConfirmed:e=>{Object(B.a)(t.id).then(t=>{Object(B.c)(t),r(Object(E.a)("","","",a.sub,!0)),e.handleHide()}).catch(e=>{Object(B.b)(e)})}})},this.onRenewClick=()=>{const{farm:e,history:t}=this.props;t.replace("/farmSettings/billing/farm/".concat(e.FarmID,"/renew"))},this.onEditSubscriptionFarmClick=()=>{const{history:e,farm:{FarmID:t}}=this.props;e.replace("/farmSettings/billing/farm/".concat(t,"/edit"))},this.getButtonsBasedOnSubscriptionStatus=e=>{const t=u()(e,"sub.status",q),{t:a}=e,n=Object(V.i)(),i=t===U?r.a.createElement(O.a,{onClick:this.onCancelSubscriptionClick,buttonStyle:"round",disabled:n,icon:r.a.createElement("i",{className:"fas fa-trash"}),buttonColor:"error"}):r.a.createElement(O.a,{onClick:this.onRenewClick,buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-redo"}),buttonColor:"info",disabled:n});return r.a.createElement("div",{className:"billing-subscription-buttons"},r.a.createElement(L.a,{tooltipContent:this.getContent()||a("billingExpandInfo.".concat(t===U?"cancelSubscription":"editSubscription")),placement:"auto"},r.a.createElement("div",null,i)),r.a.createElement(L.a,{tooltipContent:this.getContent()||a("billingExpandInfo.editSubscription"),placement:"auto"},r.a.createElement("div",null,r.a.createElement(O.a,{buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-pencil-alt"}),onClick:this.onEditSubscriptionFarmClick,disabled:n}))))},this.getPlanType=e=>{const{modules:t,t:a}=this.props;return(u()(t,"addOns.".concat(e,".extended"))?a("subscriptions.plans.extended"):a("subscriptions.plans.basic")).toUpperCase()},this.getAnimalsAmount=e=>{const{modules:t}=this.props;switch(u()(t,"addOns.BreedingModule[".concat(e,"].size"),0)){case T.RangeTypes.large:return"\u221e";case T.RangeTypes.medium:return T.AnimalRanges.maxMedium;case T.RangeTypes.small:return T.AnimalRanges.maxSmall;case T.RangeTypes.micro:default:return T.AnimalRanges.maxMicro}},this.getContent=()=>{const e=Object(V.i)(),{t:t}=this.props;if(e)return r.a.createElement("span",null,r.a.createElement("i",{className:"fas fa-ban mr-1"}),t("noServiceAccess"))}}render(){const{modules:e,t:t}=this.props;if(e){const a=u()(e,"addOns.DevicesModule.siloses",{}),n=u()(e,"addOns.DevicesModule.climates",{}),i=u()(e,"addOns.DevicesModule.cages",{}),s=u()(e,"addOns.DevicesModule.dispensers",{}),o=u()(e,"addOns.DevicesModule.dispensers5G",{}),l=u()(e,"addOns.DevicesModule.meters",{}),c=u()(e,"addOns.DevicesModule.smallCages",{}),m=u()(e,"addOns.DevicesModule.alarms",{}),h=u()(e,"addOns.DevicesModule.chains",{}),d=u()(e,"addOns.AdministrationModule"),p=u()(e,"addOns.BreedingModule.sows.left"),b=this.getAnimalsAmount("sows"),f=[{percentage:"\u221e"===b?0:+parseFloat(100*(b-p)/b).toFixed(2),text:"-/".concat(b),title:t("animalTypes.0"),planType:this.getPlanType("BreedingModule.sows"),isDisabled:!u()(e,"addOns.BreedingModule.sows.size")},{percentage:0,text:"-/\u221e",title:t("animalTypes.3"),planType:this.getPlanType("BreedingModule.porkers"),isDisabled:!u()(e,"addOns.BreedingModule.porkers.size")}],g=[{percentage:+parseFloat(100*(a.amount-a.left)/a.amount).toFixed(2),text:"".concat(a.amount-a.left,"/").concat(a.amount),title:t("siloses").toLowerCase(),planType:this.getPlanType("DevicesModule.siloses"),isDisabled:!a.amount},{percentage:+parseFloat(100*(n.amount-n.left)/n.amount).toFixed(2),text:"".concat(n.amount-n.left,"/").concat(n.amount),title:t("climates").toLowerCase(),planType:this.getPlanType("DevicesModule.climates"),isDisabled:!n.amount},{percentage:+parseFloat(100*(i.amount-i.left)/i.amount).toFixed(2),text:"".concat(i.amount-i.left,"/").concat(i.amount),title:t("cages").toLowerCase(),planType:this.getPlanType("DevicesModule.cages"),isDisabled:!i.amount},{percentage:+parseFloat(100*(s.amount-s.left)/s.amount).toFixed(2),text:"".concat(s.amount-s.left,"/").concat(s.amount),title:t("dispensers").toLowerCase(),planType:this.getPlanType("DevicesModule.dispensers"),isDisabled:!s.amount},{percentage:+parseFloat(100*(o.amount-o.left)/o.amount).toFixed(2),text:"".concat(o.amount-o.left,"/").concat(o.amount),title:t("dispensers5G").toLowerCase(),planType:this.getPlanType("DevicesModule.dispensers5G"),isDisabled:!o.amount},{percentage:+parseFloat(100*(l.amount-l.left)/l.amount).toFixed(2),text:"".concat(l.amount-l.left,"/").concat(l.amount),title:t("meters").toLowerCase(),planType:this.getPlanType("DevicesModule.meters"),isDisabled:!l.amount},{percentage:+parseFloat(100*(c.amount-c.left)/c.amount).toFixed(2),text:"".concat(c.amount-c.left,"/").concat(c.amount),title:t("weights").toLowerCase(),planType:this.getPlanType("DevicesModule.smallCages"),isDisabled:!c.amount},{percentage:+parseFloat(100*(m.amount-m.left)/m.amount).toFixed(2),text:"".concat(m.amount-m.left,"/").concat(m.amount),title:t("alarms").toLowerCase(),planType:this.getPlanType("DevicesModule.alarms"),isDisabled:!m.amount},{percentage:+parseFloat(100*(h.amount-h.left)/h.amount).toFixed(2),text:"".concat(h.amount-h.left,"/").concat(h.amount),title:t("chains").toLowerCase(),planType:this.getPlanType("DevicesModule.chains"),isDisabled:!h.amount}],E=[{percentage:+parseFloat(100*(d.managersAmount-d.managersLeft)/d.managersAmount).toFixed(2),text:"".concat(d.managersAmount-d.managersLeft,"/").concat(d.managersAmount),title:t("managersAcc").toLowerCase(),isDisabled:!d.managersAmount},{percentage:+parseFloat(100*(d.operatorsAmount-d.operatorsLeft)/d.operatorsAmount).toFixed(2),text:"".concat(d.operatorsAmount-d.operatorsLeft,"/").concat(d.operatorsAmount),title:t("operatorsAcc").toLowerCase(),isDisabled:!d.operatorsAmount},{percentage:+parseFloat(100*(d.techAdviceAmount-d.techAdviceLeft)/d.techAdviceAmount).toFixed(2),text:"".concat(d.techAdviceAmount-d.techAdviceLeft,"/").concat(d.techAdviceAmount),title:t("techAdvice").toLowerCase(),isDisabled:!d.techAdviceAmount},{percentage:+parseFloat(100*(d.techSupportAmount-d.techSupportLeft)/d.techSupportAmount).toFixed(2),text:"".concat(d.techSupportAmount-d.techSupportLeft,"/").concat(d.techSupportAmount),title:t("techSupport").toLowerCase(),isDisabled:!d.techSupportAmount}];return r.a.createElement("div",{className:"billing-expand-info-container"},r.a.createElement(P.a,{className:"w-100 justify-content-between ml-0 mr-0 mt-3"},r.a.createElement("div",{className:"plan-info"},r.a.createElement("b",null,t("breeding"))),this.getButtonsBasedOnSubscriptionStatus(this.props)),r.a.createElement(P.a,{className:"w-100 justify-content-center ml-0 mr-0 mb-3"},f.map((e,t)=>r.a.createElement(k.a,{className:"d-flex justify-content-center"},r.a.createElement("div",{key:t,className:"circular-item-container ".concat(e.isDisabled?"disabled":"")},r.a.createElement(x.a,{percentage:e.percentage,monoColor:!0,color:"success",text:e.text}),r.a.createElement("p",null,e.title),r.a.createElement("p",null,e.planType))))),r.a.createElement(P.a,{className:"w-100 justify-content-between ml-0 mr-0 mb-3"},r.a.createElement("div",{className:"plan-info"},r.a.createElement("b",null,t("devices")))),r.a.createElement(P.a,{className:"w-100 justify-content-center ml-0 mr-0 mb-3"},g.map((e,t)=>r.a.createElement(k.a,{className:"d-flex justify-content-center"},r.a.createElement("div",{key:t,className:"circular-item-container ".concat(e.isDisabled?"disabled":"")},r.a.createElement(x.a,{percentage:e.percentage,monoColor:!0,color:"success",text:e.text}),r.a.createElement("p",null,e.title),r.a.createElement("p",null,e.planType))))),r.a.createElement(P.a,{className:"w-100 justify-content-between ml-0 mr-0 mb-3"},r.a.createElement("div",{className:"plan-info"},r.a.createElement("b",null,t("administration")))),r.a.createElement(P.a,{className:"w-100 justify-content-center ml-0 mr-0 mb-3"},E.map((e,t)=>r.a.createElement(k.a,{className:"d-flex justify-content-center"},r.a.createElement("div",{key:t,className:"circular-item-container ".concat(e.isDisabled?"disabled":"")},r.a.createElement(x.a,{percentage:e.percentage,monoColor:!0,color:"success",text:e.text}),r.a.createElement("p",null,e.title))))))}return null}}var _=Object(C.d)(Object(N.a)(),Object(g.connect)((function(e,t){return{attributes:e.user.attributes,modules:Object(M.a)(e,{selectedFarm:t.farm})}}),(function(e){return function(e){for(var t=1;t{const{subs:e}=this.state;if(e.length>0){const t=e.map(e=>f()(u()(e,"sub.nextBillingDate")).toDate().getTime());return f()(Math.min.apply(null,t))}},this.onHistoryButtonClick=()=>{const{forceFetch:e}=this.state,{history:t}=this.props;t.replace({pathname:"/farmSettings/billing/history",state:{forceFetch:e}})},this.sortPrice=(e,t,a,n,r,i)=>{let s=r.split(" ")[0],o=i.split(" ")[0];return Object(D.a)(e,t,a,n,s,o)},this.onAddNewFarmClick=()=>{const{history:e}=this.props;e.replace("/farmSettings/subscription/add")},this.statusValueFormatter=e=>{const{t:t}=this.props;return t("subscriptions.grid.".concat(e))},this.terminateAccount=()=>{const{t:e,user:t,subscriptions:a,paymentMethods:n,show:r,dispatch:i}=this.props;let s=a.filter(e=>"Expired"!==e.status&&"Canceled"!==e.status).map(e=>e.id),o=n.map(e=>e.token);r(A.a,{title:e("farmSettings.billingView.terminateAccountTitle"),text:e("farmSettings.billingView.terminateAccountText"),onConfirmed:e=>{i(Object(E.h)({clientID:t.ClientID,localUserID:t.LocalUserID,subs:s,pays:o})),e.handleHide()}})},this.showAddBillingModal=()=>{const{show:e,t:t}=this.props;e(H.a,{title:t("paymentMethods")})},this.getAdminSubscription=()=>{const{subscriptions:e,user:{ClientID:t}}=this.props;return e.find(e=>e.id.slice(0,-20)===t)},this.getContent=()=>{const e=Object(V.i)(),{t:t}=this.props;if(e)return r.a.createElement("span",null,r.a.createElement("i",{className:"fas fa-ban mr-1"}),t("noServiceAccess"))};const{attributes:{sub:t,email:a,name:n,phone:i},location:{state:s},dispatch:o}=this.props;this.state={subs:X.getData(this.props),loading:!0,edit:!1,forceFetch:u()(s,"forceFetch",!1)},X.getData(this.props),o(Object(I.g)(t,!1,()=>Object(E.a)(a,n,i,t,this.state.forceFetch)))}static getData(e){const{user:{FarmData:t},subscriptions:a}=e;return t.map(e=>{const t=a.find(t=>t.id===e.SubID);return{farm:e,sub:t}}).filter(e=>e.farm&&e.sub)}static getPrice(e){return[...e.reduce((e,t)=>{let a=t.price.split(" "),n=+a[0],r=a[1],i=e.get(r)||0;return i+=n,e.set(r,i),e},new Map).entries()].map(([e,t])=>"".concat(t," ").concat(e))}componentDidUpdate(e,t,a){const{subscriptions:n,fetching:r}=this.props;c()(e.subscriptions,n)||this.setState({subs:X.getData(this.props)}),e.fetching!==r&&this.setState({loading:r})}getNextBill(e){const{subs:t}=this.state;let a=[];return e&&(a=t.map(e=>e.sub).filter(t=>t.nextBillingDate===e.format("YYYY-MM-DD"))),X.getPrice(a)}getDuePayment(){const{subs:e}=this.state;let t=e.map(e=>e.sub).filter(e=>f()(e.nextBillingDate).toDate().getTime()r.a.createElement("i",{className:"fas fa-angle-down pointer"}),headerClassName:"index",itemClassName:"index"}],s=this.getAdminSubscription();let o=this.getNextPaymentDay(),l=this.getNextBill(o),c=this.getDuePayment();return r.a.createElement("div",{className:"billing"},r.a.createElement(h.a,{text:e("changeSubscription")}),r.a.createElement(p.a,{addPaddingForButtons:!0},r.a.createElement(y.a,{isLoading:n,style:Object(j.a)()?{position:"fixed"}:null}),r.a.createElement(d.a,null,r.a.createElement("div",{className:"billing-info"},r.a.createElement("div",{className:"billing-info-item"},l.length>0?l.join(", "):"-",r.a.createElement("small",null,e("nextPayment"))),r.a.createElement("div",{className:"billing-info-item"},o?o.format("DD.MM.YYYY"):"-",r.a.createElement("small",null,e("farmSettings.billingView.nextPaymentDate"))),r.a.createElement("div",{className:"billing-info-item"},c.length>0?c.join(", "):"-",r.a.createElement("small",null,e("farmSettings.billingView.duePayments"))),r.a.createElement("div",{className:"billing-info-item"},r.a.createElement(L.a,{tooltipContent:this.getContent()||e("farmSettings.billingView.terminateAccount")},r.a.createElement("div",{className:"billing-button"},r.a.createElement(O.a,{buttonStyle:"rectangle",icon:r.a.createElement("i",{className:"fas fa-trash"}),buttonColor:"error",disabled:t,onClick:this.terminateAccount},e("farmSettings.billingView.terminateAccount"))))))),s&&r.a.createElement(d.a,{className:"billing-admin"},r.a.createElement("h4",{className:"d-flex justify-content-between"},e("farmSettings.billingView.admin")),r.a.createElement("div",{className:"billing-info"},r.a.createElement("div",{className:"billing-info-item"},s?s.price:"-",r.a.createElement("small",null,e("sum"))),r.a.createElement("div",{className:"billing-info-item"},s?f()(s.nextBillingDate).format("DD.MM.YYYY"):"-",r.a.createElement("small",null,e("nextPayment"))))),r.a.createElement(d.a,{className:"billing-subscriptions"},r.a.createElement("div",{className:"billing-subscriptions-header"},r.a.createElement("h4",null,e("farmSettings.billingView.yourSubs")),r.a.createElement("div",{className:"farms-buttons"},r.a.createElement(L.a,{tooltipContent:e("farmSettings.billingView.paymentHistory"),placement:"auto"},r.a.createElement("div",{className:"billing-button"},r.a.createElement(O.a,{buttonStyle:Object(j.a)()?"round":"rectangle",icon:r.a.createElement("i",{className:"fas fa-history"}),buttonColor:"info",onClick:this.onHistoryButtonClick},Object(j.a)()?"":e("farmSettings.billingView.paymentHistory")))),r.a.createElement(L.a,{tooltipContent:this.getContent()||e("addNew")},r.a.createElement("div",{className:"billing-button"},r.a.createElement(O.a,{buttonStyle:Object(j.a)()?"round":"rectangle",icon:r.a.createElement("i",{className:"fas fa-plus"}),buttonColor:"success",disabled:t,onClick:this.onAddNewFarmClick},Object(j.a)()?"":e("addNew")))))),r.a.createElement(v.a,{data:a,headers:i,shouldIndex:!0,isExpanded:!0,component:r.a.createElement(_,null)})),r.a.createElement(d.a,{className:"payment-methods"},r.a.createElement("div",{className:"payment-header"},r.a.createElement("h4",null,e("paymentMethods")),r.a.createElement(L.a,{tooltipContent:this.getContent()||e("addNew")},r.a.createElement("div",{className:"billing-button"},r.a.createElement(O.a,{buttonStyle:Object(j.a)()?"round":"rectangle",icon:r.a.createElement("i",{className:"fas fa-plus"}),buttonColor:"success",disabled:t,onClick:this.showAddBillingModal},Object(j.a)()?"":e("addNew"))))),r.a.createElement(w.a,null))),r.a.createElement(S.b,{handleHide:F.b,counter:10,action:R.b,title:e("modals.logoutModal.title"),text:"modals.logoutModal.text",confirmButtonText:e("logout")}),r.a.createElement(H.b,{title:e("paymentMethods")}))}}var Q=Object(C.d)(Object(N.a)(),Object(K.a)({roles:[Y.BILLING]}),Object(g.connect)((function(e){return{attributes:e.user.attributes,subscriptions:e.braintree.subscriptionList,paymentMethods:e.braintree.paymentMethodList,user:e.user.user,fetching:e.braintree.fetching}}),(function(e){return function(e){for(var t=1;t{const{history:e}=this.props;e.replace("/farmSettings/billing")};const{attributes:t,location:{state:a}}=this.props,n=u()(a,"forceFetch",!1);this.state={loading:!0},this.props.dispatch(Object(E.b)(t.sub,n))}componentDidUpdate(e,t,a){const{fetching:n}=this.props;e.fetching!==n&&this.setState({loading:n})}render(){const{t:e}=this.props,{loading:t}=this.state;return r.a.createElement("div",{className:"billing"},r.a.createElement(y.a,{isLoading:t,style:Object(j.a)()?{position:"fixed"}:null}),r.a.createElement(h.a,{text:r.a.createElement(r.a.Fragment,null,r.a.createElement("span",null,r.a.createElement("i",{className:"fas fa-arrow-left pointer",onClick:this.onBackClick})),"\xa0",e("farmSettings.billingHistoryView.title"))}),r.a.createElement(p.a,null,r.a.createElement(d.a,null,r.a.createElement($.a,null))))}}ee=Object(g.connect)(e=>({attributes:e.user.attributes,fetching:e.braintree.fetching}))(ee);var te=Object(N.a)()(ee),ae=a("hLpH"),ne=a("E+oP"),re=a.n(ne),ie=a("wQmL"),se=a("d/v1"),oe=a("pJVQ"),le=a("tDQA"),ce=a("4huo"),me=a("PoRY"),ue=a("6szu"),he=a("F2x4"),de=a("+PoS");function pe(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 be(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var fe=a("26mJ"),ge=a("6uZD"),Ee=(a("kD9f"),a("CjPc")),ve=a("4ltZ"),Oe=a("IXwn");function ye(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 De(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const we="settings-users-add";class je extends r.a.Component{constructor(e){super(e),this.getOptions=e=>{const{t:t}=e;return{userTypeOptions:[{name:t("operator"),value:"U"},{name:t("newSettings.users.addUserView.farmAdminUser"),value:"F"}]}},this.onChange=(e,t)=>{this.props.dispatch(Object(ge.d)(t))},this.state=function(e){for(var t=1;t0&&e.farms[0].FarmID&&re()(a)&&t(Object(ve.c)(e.farms[0].FarmID))}componentDidMount(){const{FarmData:e}=this.props;this.props.dispatch({type:"GET_FARMS",payload:e})}onButtonClick(e){const{dispatch:t,change:a}=this.props;a("farm",e),t(Object(ve.c)(e))}render(){const{handleSubmit:e,t:t,farms:a,selectedFarm:n,selectedUserType:i,submitFailed:s,submitting:o}=this.props,{userTypeOptions:l}=this.state,c=a.find(e=>e.FarmID===n);return r.a.createElement("div",null,r.a.createElement(h.a,{text:t("newSettings.users.addUserView.header")}),r.a.createElement(p.a,{addPaddingForButtons:!0},r.a.createElement(d.a,{className:we},r.a.createElement("form",{onSubmit:e},r.a.createElement(P.a,{className:"justify-content-center"},r.a.createElement(k.a,{lg:6},r.a.createElement(se.a,{name:"userLogin",id:"userLogin",required:!0,type:"text",component:fe.a,label:t("login.login")}),r.a.createElement(se.a,{name:"email",id:"email",required:!0,type:"email",component:fe.a,label:t("email2")}),r.a.createElement(se.a,{name:"address",id:"address",type:"text",component:fe.a,label:t("newSettings.users.addUserView.address")}),r.a.createElement(se.a,{name:"userName",id:"userName",required:!0,type:"text",component:fe.a,label:t("nameAndSurrname")}),r.a.createElement(se.a,{id:"userType",name:"userType",required:!0,component:ce.b,label:t("newSettings.users.addUserView.userType"),options:l}),r.a.createElement(se.a,{name:"phone",id:"phone",type:"tel",component:fe.a,label:t("newSettings.users.addUserView.phone")}))),r.a.createElement("hr",null),r.a.createElement("h4",{className:"mb-2"},t("newSettings.users.addUserView.farmPrivilege",{name:u()(c,"FarmName","")})),a.length>0&&r.a.createElement(P.a,{className:Object(j.a)()?"permissions-mobile":"permissions"},r.a.createElement(k.a,{xl:4,id:"Col1",className:"d-flex flex-column align-items-xl-end "},a.map((e,t)=>r.a.createElement(O.a,{buttonStyle:"text",buttonColor:n===e.FarmID?"success":"",key:t,type:"button",onClick:()=>this.onButtonClick(e.FarmID)},e.FarmName))),r.a.createElement(k.a,{xl:6,className:"d-flex justify-content-lg-start"},r.a.createElement(se.a,{name:"roles",id:"roles",required:!0,component:Ee.a,label:t("roles"),farm:n,selectedUserType:i}))),a.length<=0&&r.a.createElement("label",{className:"d-flex justify-content-center"},"-- ",t("farms.farmItem.notfound")," --"),r.a.createElement(Oe.a,{fixed:!0,renderInPortal:!1},s||a.length<=0&&r.a.createElement(L.a,{tooltipContent:"Prosz\u0119 uzupe\u0142ni\u0107 wymagane pola oraz nada\u0107 uprawnienie przynajmniej dla jednej fermy!",type:"error"},r.a.createElement("i",{className:"fas fa-exclamation-circle error"})),r.a.createElement(O.a,{buttonColor:"success",buttonStyle:"round",disabled:a.length<=0,icon:r.a.createElement("i",{className:"fas fa-save"}),isLoading:!!o}))))),r.a.createElement(he.b,null))}}je=Object(oe.a)({form:we,onSubmit:function(e,t,a){const{show:n,farms:r}=a,{roles:i}=e;if(!(i[0].LocalRights.length>1))return Object(ue.a)(function(e){for(var t=1;t{Object(ue.c)(e),t(Object(de.a)("/farmSettings/users"))}).catch(e=>{Object(ue.b)(e)});{const t=r.filter(e=>i[0].LocalRights.find(t=>t.FarmID===e.FarmID));n(he.a,{farms:t,userValues:e})}},validate:function(e,t){const a={},{email:n,farm:r,userName:i,userLogin:s,userType:o,roles:l}=e,{t:c}=t;re()(l)&&(a.roles=c("required")),n||(a.email=c("required")),r||(a.farm=c("required")),i||(a.userName=c("required")),s||(a.userLogin=c("required")),o||(a.userType=c("required"));let m=Object(me.a)(e.phone||"");return e.phone&&(e.phone&&"+"!==e.phone.charAt(0)?a.phone=c("errors.phoneNumberError"):m&&m.isValid()||(a.phone=c("errors.phoneError"))),a}})(je);const Ce=Object(le.a)(we);let Fe=Object(g.connect)(e=>({farm:e.location.farm,farms:e.farms.farms,selectedFarm:Ce(e,"farm"),selectedUserType:Ce(e,"userType"),buildings:e.farms.buildings,FarmData:e.user.user.FarmData}),e=>Object(C.b)({show:F.d},e))(je);je=Object(K.a)({roles:[s.c._USER_MANAGE],showComponent:!0})(Fe);var Ie=Object(N.a)()(je),Ae=a("44Ds"),Se=a.n(Ae),Re=a("17x9"),Ne=a.n(Re),Pe=(a("X9FV"),a("9jj8")),ke=a("ZXlx"),xe=a("vYJ8"),Me=a("9GTB");class Te extends n.Component{constructor(e){super(e),this.renderItem=e=>r.a.createElement("span",null,r.a.createElement("div",null,this.getValue(e)),r.a.createElement("div",null,r.a.createElement("small",null,e.name))),this.onClick=()=>{this.setState(e=>({show:!e.show}))},this.rolesFormatter=e=>r.a.createElement("div",{className:"role-box"},r.a.createElement("div",{className:"role-names"},e.slice(0,5).map(e=>r.a.createElement("p",{className:"".concat(e.hasRole?"success":"error")},e.text))),r.a.createElement("div",{className:"role-names"},e.slice(5,10).map(e=>r.a.createElement("p",{className:"".concat(e.hasRole?"success":"error")},e.text))),r.a.createElement("div",{className:"role-names"},e.slice(10,15).map(e=>r.a.createElement("p",{className:"".concat(e.hasRole?"success":"error")},e.text))));const{farms:t,user:{roles:a}}=this.props;this.state={show:!1,privileges:t.map(e=>({farm:e,userRoles:Object(V.j)(a,e.FarmID)}))}}getValue({field:e,valueFormatter:t}){const{user:a,searchText:n}=this.props;let i=u()(a,e);return r.a.createElement(ke.a,{text:i,searchText:n})}render(){const{user:{userName:e,userType:t},headers:a,buttons:n,t:i,searchText:s}=this.props,{show:o,privileges:l}=this.state,c=[{name:i("newSettings.users.changeRolesView.farm"),field:"farm.FarmName"},{name:i("newSettings.users.changeRolesView.roles"),field:"userRoles",component:({value:e})=>this.rolesFormatter(e),colWidth:4}];return r.a.createElement("div",{className:"user-item"},r.a.createElement(Pe.a,{onClick:this.onClick},r.a.createElement("span",null,r.a.createElement("div",null,r.a.createElement("strong",null,r.a.createElement(ke.a,{text:e,searchText:s}))),r.a.createElement("div",null,r.a.createElement("small",null,i("newSettings.users.changeRolesView.userTypes.".concat(t))))),a.map(e=>this.renderItem(e)),n&&r.a.createElement("div",{className:"user-buttons"},n(this.props))),r.a.createElement(xe.a,{in:o},r.a.createElement("div",null,r.a.createElement(v.a,{data:l,headers:c,shouldIndex:!0}))))}}Te.propTypes={user:Ne.a.object.isRequired,headers:Ne.a.array.isRequired,buttons:Ne.a.func},Te=Object(g.connect)((e,t)=>({farms:Object(Me.d)(e,{selectedUser:t.user})}))(Te);var Be=Object(N.a)()(Te),Ve=a("0ajJ"),Le=a("U4G4"),Ge=a("1j/Y"),We=a("wd8a");class Ue extends r.a.Component{constructor(e){super(e),this.filteredEmployees=Se()((e,t)=>{if(""===t.trim())return e;const a=[1,.8,.6,.4];let n=e=>[e.userName||"",e.phoneNumber||"",e.email||"",e.address||""];return(e||[]).filter(e=>n(e).join(" ").toLowerCase().includes(t.toLowerCase())).sort((e,r)=>{let i=0,s=0,o=n(e),l=n(r);for(let n=0;nJSON.stringify(e)),this.props.dispatch(Object(I.f)()),this.state={search:""}}render(){const{search:e}=this.state,{addtionalHeaders:t,buttons:a,fetchingEmployees:n,t:i,user:s,employees:o,farms:l}=this.props;let c=this.filteredEmployees(o,e).filter(e=>e.LocalUserID!==s.LocalUserID);return u()(s,"userType",We.MANAGER)!==We.OWNER&&(c=c.filter(e=>e.userType!==We.OWNER)),r.a.createElement(d.a,null,r.a.createElement(Le.a,{placeholder:i("newSettings.users.chooseUsers.findUser"),className:"mb-2",value:e,onChange:e=>this.setState({search:e})}),r.a.createElement(P.a,{style:{minHeight:"5rem"}},r.a.createElement(y.a,{isLoading:n}),r.a.createElement(Ve.a,{property:"farmName"},!n&&c.length>0&&c.map(n=>{const s=u()(l.find(e=>e.FarmID===n.FarmID),"FarmName",i("grid.rest"));return r.a.createElement(Be,{farmName:s,searchText:e,user:n,headers:t,buttons:a})}),!n&&!c.length&&r.a.createElement("p",{className:"empty-list"},r.a.createElement("i",null,"- ",i("newSettings.users.chooseUsers.noEmployeesFound")," -")))))}}var qe=Object(C.d)(Object(N.a)(),Object(g.connect)((function(e){return{employees:e.user.employees,user:e.user.user,fetchingEmployees:e.user.fetchingEmployees,farms:e.farms.farms}})),Object(K.a)({roles:[Y.USER_MANAGE]}))(Ue),ze=a("/QEX"),_e=a("B/gD"),Ye=a("OwcS"),He=a("RTKB"),Ke=a("XzT5");class Ze extends r.a.Component{constructor(e){super(e),this.openModal=(e,t)=>{console.log(t),t.stopPropagation();const{show:a}=this.props;a(ze.a,{employee:e})},this.onUnblockUserClick=e=>{const{show:t,t:a}=this.props;t("confirm-modal",{title:a("newSettings.users.changeRolesView.confirmOperation"),text:Ke.a.t("newSettings.users.changeRolesView.confirmUnlock",{name:e.userName}),confirmText:a("yes"),onConfirmed:t=>{this.props.dispatch(Object(I.d)(this.props.ClientID,!0,e.sub,e.login,()=>{this.props.dispatch(Object(I.g)(this.props.attributes.sub,!1)),this.props.dispatch(Object(I.f)(this.props.ClientID))})),t.handleHide()}})},this.onBlockUserClick=e=>{const{show:t,t:a}=this.props;t("confirm-modal",{title:a("newSettings.users.changeRolesView.confirmOperation"),text:Ke.a.t("newSettings.users.changeRolesView.confirmLock",{name:e.userName}),confirmText:a("yes"),onConfirmed:t=>{this.props.dispatch(Object(I.d)(this.props.ClientID,!1,e.sub,e.login,()=>{this.props.dispatch(Object(I.g)(this.props.attributes.sub,!1)),this.props.dispatch(Object(I.f)(this.props.ClientID))})),t.handleHide()}})},this.onDeleteUserClick=(e,t)=>{e.stopPropagation();const{show:a,dispatch:n}=this.props;a("confirm-modal",{title:Ke.a.t("newSettings.users.changeRolesView.confirmOperation"),text:Ke.a.t("newSettings.users.changeRolesView.confirmDeletion",{name:t.userName}),confirmText:Ke.a.t("yes"),onConfirmed:e=>{n(Object(I.c)(t.LocalUserID)),e.handleHide()}})},this.onAddUserClick=()=>{this.props.history.push("/farmSettings/users/add")},this.onSwitchClick=(e,t)=>{e.stopPropagation(),t.user.enable?this.onBlockUserClick(t.user):this.onUnblockUserClick(t.user)},this.state={activeStep:1,employee:null},this.props.dispatch(Object(I.g)(e.attributes.sub,!1))}shouldDisableSwitch(e){const{user:{userType:t,enable:a}}=e;if(!a){const{user:{LicPackages:e}}=this.props;if(e){let a=e.sort((e,t)=>t.DtaModTime-e.DtaModTime).find(e=>"ADMIN"===e.Type);if(a){if(t===We.MANAGER)return 0===a.AccManagersLeft;if(t===We.USER)return 0===a.AccOperatorsLeft}}}return!1}render(){if(!Object(V.h)()&&!Object(V.g)()&&!Object(V.i)())return r.a.createElement(He.a,null);const{t:e}=this.props,t=[{name:e("phoneNumber"),field:"phoneNumber",valueFormatter:e=>e},{name:e("email"),field:"email",valueFormatter:e=>e},{name:e("adres"),field:"address",valueFormatter:e=>e}];return r.a.createElement("div",null,r.a.createElement(h.a,{text:e("users")}),r.a.createElement(p.a,{addPaddingForButtons:!0},r.a.createElement(qe,{addtionalHeaders:t,buttons:t=>[r.a.createElement("div",null,r.a.createElement(O.a,{type:"button",onClick:e=>this.onDeleteUserClick(e,t.user),buttonStyle:"round",buttonColor:"error",title:e("newSettings.users.changeRolesView.deleteUser"),icon:r.a.createElement("i",{className:"fas fa-trash"})})),r.a.createElement("div",null,r.a.createElement(O.a,{type:"button",id:"editButton",onClick:e=>this.openModal(t.user,e),buttonStyle:"round",title:e("newSettings.users.changeRolesView.editUser"),icon:r.a.createElement("i",{className:"fas fa-user-edit"})})),r.a.createElement("div",null,r.a.createElement(_e.a,{additionalClass:"user-switch",label:e("newSettings.users.changeRolesView.disableAccount"),value:t.user.enable,onDivClick:e=>this.onSwitchClick(e,t),id:Object(Ye.a)(),title:e("newSettings.users.changeRolesView.disableDescription"),disabled:this.shouldDisableSwitch(t)}))]}),r.a.createElement(ze.b,null),Object(V.h)()&&r.a.createElement(Oe.a,{fixed:!0},r.a.createElement(O.a,{buttonStyle:"round",buttonColor:"success",icon:r.a.createElement("i",{className:"fas fa-user-plus"}),onClick:this.onAddUserClick}))))}}Ze=Object(g.connect)(e=>({farm:e.location.farm,attributes:e.user.attributes,user:e.user.user}))(Ze);let Je=Object(g.connect)(null,e=>Object(C.b)({show:F.d},e))(Ze);var Xe=Object(N.a)()(Je),Qe=a("vAb9"),$e=a("PbGg"),et=a("HIda"),tt=a("XM6k"),at=(a("fp2G"),a("lAGl")),nt=a("tLYN"),rt=a("gNnm"),it=a("gMJi");const st=Object(le.a)("billing-edit-farm");class ot extends r.a.Component{constructor(e){super(e),this.getFarmName=e=>u()(e,"subscriptionData.subscription.farmName"),this.amountValueParser=e=>parseInt(e),this.onSowSizeChange=(e,t,a)=>{const{dispatch:n,subscriptionData:{addOns:r}}=this.props,{breedingFailed:i}=this.state;n(Object(ie.a)("billing-edit-farm","BreedingModule.sows.size",+a.target.value));const s=e=>{let t;switch(e){case T.RangeTypes.small:t=T.AnimalRanges.maxSmall;break;case T.RangeTypes.medium:t=T.AnimalRanges.maxMedium;break;case T.RangeTypes.large:t=T.AnimalRanges.maxLarge;break;default:t=T.AnimalRanges.maxMicro}return t},o=s(u()(r,"BreedingModule.sows.size"))-u()(r,"BreedingModule.sows.left");o>s(+a.target.value)?this.setState({breedingFailed:!0,breedingMessage:o}):!0===i&&this.setState({breedingFailed:!1})},this.onSwitchChange=e=>{const t=u()(event,"target.id","").split(/(?=[A-Z])/).map(e=>e.toLowerCase()),{dispatch:a}=this.props;if(t.length>0)if("show"===t[0])"breeding"===t[1]?a(Object(ie.a)("billing-edit-farm","BreedingModule",{sowsEnabled:e,porkersEnabled:e,sows:{size:+e,extended:!1},porkers:{size:+e,extended:!1}})):"devices"===t[1]?a(Object(ie.a)("billing-edit-farm","DevicesModule",{silosesEnabled:e,climatesEnabled:e,cagesEnabled:e,dispensersEnabled:e,dispensers5GEnabled:e,metersEnabled:e,smallCagesEnabled:e,chainsEnabled:e,alarmsEnabled:e,siloses:{extended:!1,amount:+e},climates:{extended:!1,amount:+e},cages:{extended:!1,amount:+e},dispensers:{extended:!1,amount:+e},dispensers5G:{amount:+e},meters:{extended:!1,amount:+e},smallCages:{extended:!1,amount:+e},alarms:{extended:!1,amount:+e},chains:{extended:!1,amount:+e}})):"administration"===t[1]&&a(Object(ie.a)("billing-edit-farm","AdministrationModule",{managersAmount:+e,operatorsAmount:+e,techAdviceAmount:+e,techSupportAmount:+e}));else if("sows"===t[0]||"porkers"===t[0]){const n={size:+e,extended:!1};a(Object(ie.a)("billing-edit-farm","BreedingModule[".concat(t[0],"]"),n))}else{const n={amount:+e,extended:!1};"dispensers5G"===t[0]&&delete n.extended,a(Object(ie.a)("billing-edit-farm","DevicesModule[".concat(t[0],"]"),n))}},this.getSwitchOptions=()=>{const{t:e}=this.props;return[{name:e("basic"),value:!1},{name:e("advanced"),value:!0}]};const{dispatch:t,customer:a,userData:{email:n,name:r,phone:i,sub:s},subscriptionData:{addOns:o}}=e;a||t(Object(E.a)(n,r,i,s,!0));const l=u()(o,"BreedingModule.sows.size"),c=u()(o,"BreedingModule.porkers.size"),m=u()(o,"DevicesModule.siloses.amount"),h=u()(o,"DevicesModule.climates.amount"),d=u()(o,"DevicesModule.cages.amount"),p=u()(o,"DevicesModule.dispensers.amount"),b=u()(o,"DevicesModule.dispensers5G.amount"),f=u()(o,"DevicesModule.meters.amount"),g=u()(o,"DevicesModule.smallCages.amount"),v=u()(o,"DevicesModule.alarms.amount"),O=u()(o,"DevicesModule.chains.amount"),y=u()(o,"AdministrationModule.managersAmount"),D=u()(o,"AdministrationModule.operatorsAmount"),w=u()(o,"AdministrationModule.techAdviceAmount"),j=u()(o,"AdministrationModule.techSupportAmount"),C={showBreeding:(()=>{const e=u()(o,"BreedingModule");for(const t in e)if(u()(e,"[".concat(t,"].size"),0)>0)return!0;return!1})(),showDevices:(()=>{const e=u()(o,"DevicesModule");for(const t in e)if(u()(e,"[".concat(t,"].amount"),0)>0)return!0;return!1})(),showAdministration:(()=>{const e=u()(o,"AdministrationModule");for(const t in e)if(t.endsWith("Amount")&&u()(e,"[".concat(t,"]"),0)>0)return!0;return!1})(),BreedingModule:{sowsEnabled:!!l,porkersEnabled:!!c,sows:{extended:u()(o,"BreedingModule.sows.extended"),size:l},porkers:{extended:u()(o,"BreedingModule.porkers.extended"),size:c}},DevicesModule:{silosesEnabled:!!m,climatesEnabled:!!h,cagesEnabled:!!d,dispensersEnabled:!!p,dispensers5GEnabled:!!b,metersEnabled:!!f,smallCagesEnabled:!!g,chainsEnabled:!!O,alarmsEnabled:!!v,siloses:{extended:u()(o,"DevicesModule.siloses.extended",!1),amount:m},climates:{extended:u()(o,"DevicesModule.climates.extended",!1),amount:h},cages:{extended:u()(o,"DevicesModule.cages.extended",!1),amount:d},dispensers:{extended:u()(o,"DevicesModule.dispensers.extended",!1),amount:p},dispensers5G:{amount:b},meters:{extended:u()(o,"DevicesModule.meters.extended",!1),amount:f},smallCages:{extended:u()(o,"DevicesModule.smallCages.extended",!1),amount:g},alarms:{extended:u()(o,"DevicesModule.alarms.extended",!1),amount:v},chains:{extended:u()(o,"DevicesModule.chains.extended",!1),amount:O}},AdministrationModule:{managersAmount:y,operatorsAmount:D,techAdviceAmount:w,techSupportAmount:j}};t(Object(ie.c)("billing-edit-farm",C)),this.state={breedingFailed:!1,breedingMessage:""}}render(){const{handleSubmit:e,showBreeding:t,showDevices:a,showAdministration:n,sowsSize:i,silosesEnabled:s,climatesEnabled:o,cagesEnabled:l,dispensersEnabled:c,dispensers5GEnabled:m,metersEnabled:u,smallCagesEnabled:b,chainsEnabled:f,alarmsEnabled:g,t:E,dirty:v,submitting:y,sowsEnabled:D,porkersEnabled:w}=this.props,{breedingFailed:j,breedingMessage:C}=this.state,F=this.getSwitchOptions();return r.a.createElement("div",{className:"billing-edit-farm-container"},r.a.createElement(h.a,{text:E("billingEditFarm.title",{name:this.getFarmName(this.props)})}),r.a.createElement(p.a,{addPaddingForButtons:!0},r.a.createElement(d.a,null,r.a.createElement("form",{onSubmit:e},r.a.createElement(P.a,{className:"mb-4"},r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"showBreeding",id:"showBreeding",init:!0,onChange:this.onSwitchChange,component:tt.a,label:r.a.createElement("h5",null,E("breeding"))}))),t&&r.a.createElement(et.a,{name:"BreedingModule",className:"breeding-section"},r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"sowsEnabled",id:"sowsEnabled",component:tt.a,label:E("animalTypes.0"),onChange:this.onSwitchChange})),D&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2,className:"align-items-center"},r.a.createElement(rt.a,{onChange:this.onSowSizeChange,checked:1===i,label:E("addons.animalsRanges",{range:"".concat(T.AnimalRanges.minSmall,"-").concat(T.AnimalRanges.maxSmall)}),name:"sows.size",value:1})),r.a.createElement(k.a,{md:2,className:"align-items-center"},r.a.createElement(rt.a,{onChange:this.onSowSizeChange,checked:2===i,label:E("addons.animalsRanges",{range:"".concat(T.AnimalRanges.minMedium,"-").concat(T.AnimalRanges.maxMedium)}),name:"sows.size",value:2})),r.a.createElement(k.a,{md:2,className:"align-items-center"},r.a.createElement(rt.a,{onChange:this.onSowSizeChange,checked:3===i,label:E("addons.animalsRanges",{range:"> ".concat(T.AnimalRanges.minLarge-1)}),name:"sows.size",value:3})),r.a.createElement(k.a,null,r.a.createElement(se.a,{name:"sows.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"porkersEnabled",id:"porkersEnabled",component:tt.a,label:E("animalTypes.3"),onChange:this.onSwitchChange})),w&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,null,r.a.createElement(se.a,{name:"porkers.extended",options:F,component:nt.a}))))),r.a.createElement("hr",null),r.a.createElement(P.a,{className:"mb-4"},r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"showDevices",id:"showDevices",component:tt.a,onChange:this.onSwitchChange,init:!0,label:r.a.createElement("h5",null,E("devices"))}))),a&&r.a.createElement(et.a,{name:"DevicesModule",className:"devices-section"},r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"silosesEnabled",id:"silosesEnabled",component:tt.a,label:E("siloses"),onChange:this.onSwitchChange})),s&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"siloses.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"siloses.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"climatesEnabled",id:"climatesEnabled",component:tt.a,label:E("climates"),onChange:this.onSwitchChange})),o&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"climates.amount",component:at.a,placeholder:E("amount"),type:"number",parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"climates.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"cagesEnabled",id:"cagesEnabled",component:tt.a,label:E("cages"),onChange:this.onSwitchChange})),l&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"cages.amount",component:at.a,placeholder:E("amount"),type:"number",parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"cages.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"dispensersEnabled",id:"dispensersEnabled",component:tt.a,label:E("dispensers"),onChange:this.onSwitchChange})),c&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"dispensers.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"dispensers.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"dispensers5GEnabled",id:"dispensers5GEnabled",component:tt.a,label:E("dispensers5G"),onChange:this.onSwitchChange})),m&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"dispensers5G.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"metersEnabled",id:"metersEnabled",component:tt.a,label:E("meters"),onChange:this.onSwitchChange})),u&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"meters.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"meters.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"smallCagesEnabled",id:"smallCagesEnabled",component:tt.a,label:E("weights"),onChange:this.onSwitchChange})),b&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"smallCages.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"smallCages.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"chainsEnabled",id:"chainsEnabled",component:tt.a,label:E("chains"),onChange:this.onSwitchChange})),f&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"chains.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"chains.extended",options:F,component:nt.a})))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"alarmsEnabled",id:"alarmsEnabled",component:tt.a,label:E("alarms"),onChange:this.onSwitchChange})),g&&r.a.createElement(r.a.Fragment,null,r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"alarms.amount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})),r.a.createElement(k.a,{md:8},r.a.createElement(se.a,{name:"alarms.extended",options:F,component:nt.a}))))),r.a.createElement("hr",null),r.a.createElement(P.a,{className:"mb-4"},r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"showAdministration",id:"showAdministration",init:!0,onChange:this.onSwitchChange,component:tt.a,label:r.a.createElement("h5",null,E("administration"))}))),n&&r.a.createElement(et.a,{name:"AdministrationModule",className:"administration-section"},r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement("label",null,E("managersAcc"))),r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"managersAmount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser}))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement("label",null,E("operatorsAcc"))),r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"operatorsAmount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser}))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement("label",null,E("techAdvice"))),r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"techAdviceAmount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser}))),r.a.createElement(P.a,null,r.a.createElement(k.a,{md:2},r.a.createElement("label",null,E("techSupport"))),r.a.createElement(k.a,{md:2},r.a.createElement(se.a,{name:"techSupportAmount",component:at.a,type:"number",placeholder:E("amount"),parse:this.amountValueParser})))),r.a.createElement(Oe.a,{fixed:!0,renderInPortal:!1},j&&r.a.createElement(L.a,{tooltipContent:E("errors.tooMuchInUseBreeding",{used:C}),type:"error"},r.a.createElement("i",{className:"fas fa-exclamation-circle error"})),r.a.createElement(O.a,{buttonStyle:"round",buttonColor:"success",icon:r.a.createElement("i",{className:"fas fa-save"}),disabled:!v||j,isLoading:y}))))))}}var lt=Object(C.d)(Object(N.a)(),Object(g.connect)((function(e,t){const{match:{params:{FarmID:a}}}=t;return{user:e.user.user,dirty:Object($e.a)("billing-edit-farm")(e),customer:e.braintree.customer,userData:e.user.attributes,subscriptionData:Object(M.b)(e,{farmID:a}),showBreeding:st(e,"showBreeding"),showDevices:st(e,"showDevices"),showAdministration:st(e,"showAdministration"),sowsSize:st(e,"BreedingModule.sows.size"),sowsEnabled:st(e,"BreedingModule.sowsEnabled"),porkersEnabled:st(e,"BreedingModule.porkersEnabled"),silosesEnabled:st(e,"DevicesModule.silosesEnabled"),climatesEnabled:st(e,"DevicesModule.climatesEnabled"),cagesEnabled:st(e,"DevicesModule.cagesEnabled"),dispensersEnabled:st(e,"DevicesModule.dispensersEnabled"),dispensers5GEnabled:st(e,"DevicesModule.dispensers5GEnabled"),metersEnabled:st(e,"DevicesModule.metersEnabled"),smallCagesEnabled:st(e,"DevicesModule.smallCagesEnabled"),chainsEnabled:st(e,"DevicesModule.chainsEnabled"),alarmsEnabled:st(e,"DevicesModule.alarmsEnabled")}})),Object(oe.a)({form:"billing-edit-farm",onSubmit:function(e,t,a){const{AdministrationModule:n,BreedingModule:{sows:r,porkers:i},DevicesModule:{siloses:s,climates:o,cages:l,dispensers:c,dispensers5G:m,meters:u,smallCages:h,alarms:d,chains:p}}=e,{user:{ClientID:b},match:{params:{FarmID:f}},subscriptionData:{subscription:g},history:E}=a,v={BreedingModule:{sows:r,porkers:i},DevicesModule:{siloses:s,climates:o,cages:l,dispensers:c,dispensers5G:m,meters:u,smallCages:h,alarms:d,chains:p},AdministrationModule:n};return Object(it.a)(v,f,b,g.id).then(e=>{Object(it.c)(e),E.replace({pathname:"/farmSettings/billing",state:{forceFetch:!0}})}).catch(e=>{Object(it.b)(e)})},validate:function(e,t){const a={AdministrationModule:{},DevicesModule:{siloses:{},climates:{},cages:{},dispensers:{},dispensers5G:{},meters:{},smallCages:{},chains:{},alarms:{}}},{t:n,subscriptionData:{addOns:r}}=t,{AdministrationModule:{managersAmount:i,operatorsAmount:s,techAdviceAmount:o,techSupportAmount:l}={},DevicesModule:{siloses:c,climates:m,cages:h,dispensers:d,dispensers5G:p,meters:b,smallCages:f,chains:g,alarms:E}={}}=e;i||(a.AdministrationModule.managersAmount=n("required"));const v=u()(r,"AdministrationModule.managersAmount")-u()(r,"AdministrationModule.managersLeft");v>i&&(a.AdministrationModule.managersAmount=n("errors.tooMuchInUse",{used:v})),s||(a.AdministrationModule.operatorsAmount=n("required"));const O=u()(r,"AdministrationModule.operatorsAmount")-u()(r,"AdministrationModule.operatorsLeft");O>s&&(a.AdministrationModule.operatorsAmount=n("errors.tooMuchInUse",{used:O})),o||(a.AdministrationModule.techAdviceAmount=n("required"));const y=u()(r,"AdministrationModule.techAdviceAmount")-u()(r,"AdministrationModule.techAdviceLeft");y>o&&(a.AdministrationModule.techAdviceAmount=n("errors.tooMuchInUse",{used:y})),l||(a.AdministrationModule.techSupportAmount=n("required"));const D=u()(r,"AdministrationModule.techSupportAmount")-u()(r,"AdministrationModule.techSupportLeft");D>l&&(a.AdministrationModule.techSupportAmount=n("errors.tooMuchInUse",{used:D})),u()(c,"amount")||(a.DevicesModule.siloses.amount=n("required"));const w=u()(r,"DevicesModule.siloses.amount")-u()(r,"DevicesModule.siloses.left");w>u()(c,"amount")&&(a.DevicesModule.siloses.amount=n("errors.tooMuchInUse",{used:w})),u()(m,"amount")||(a.DevicesModule.climates.amount=n("required"));const j=u()(r,"DevicesModule.climates.amount")-u()(r,"DevicesModule.climates.left");j>u()(m,"amount")&&(a.DevicesModule.climates.amount=n("errors.tooMuchInUse",{used:j})),u()(h,"amount")||(a.DevicesModule.cages.amount=n("required"));const C=u()(r,"DevicesModule.cages.amount")-u()(r,"DevicesModule.cages.left");C>u()(h,"amount")&&(a.DevicesModule.cages.amount=n("errors.tooMuchInUse",{used:C})),u()(d,"amount")||(a.DevicesModule.dispensers.amount=n("required"));const F=u()(r,"DevicesModule.dispensers.amount")-u()(r,"DevicesModule.dispensers.left");F>u()(d,"amount")&&(a.DevicesModule.dispensers.amount=n("errors.tooMuchInUse",{used:F})),u()(p,"amount")||(a.DevicesModule.dispensers5G.amount=n("required"));const I=u()(r,"DevicesModule.dispensers5G.amount")-u()(r,"DevicesModule.dispensers5G.left");I>u()(p,"amount")&&(a.DevicesModule.dispensers5G.amount=n("errors.tooMuchInUse",{used:I})),u()(b,"amount")||(a.DevicesModule.meters.amount=n("required"));const A=u()(r,"DevicesModule.meters.amount")-u()(r,"DevicesModule.meters.left");A>u()(b,"amount")&&(a.DevicesModule.meters.amount=n("errors.tooMuchInUse",{used:A})),u()(f,"amount")||(a.DevicesModule.smallCages.amount=n("required"));const S=u()(r,"DevicesModule.smallCages.amount")-u()(r,"DevicesModule.smallCages.left");S>u()(f,"amount")&&(a.DevicesModule.smallCages.amount=n("errors.tooMuchInUse",{used:S})),u()(g,"amount")||(a.DevicesModule.chains.amount=n("required"));const R=u()(r,"DevicesModule.chains.amount")-u()(r,"DevicesModule.chains.left");R>u()(g,"amount")&&(a.DevicesModule.chains.amount=n("errors.tooMuchInUse",{used:R})),u()(E,"amount")||(a.DevicesModule.alarms.amount=n("required"));const N=u()(r,"DevicesModule.alarms.amount")-u()(r,"DevicesModule.alarms.left");return N>u()(E,"amount")&&(a.DevicesModule.alarms.amount=n("errors.tooMuchInUse",{used:N})),a}}))(ot);class ct extends r.a.Component{render(){if(!Object(V.h)()&&!Object(V.g)()&&!Object(V.i)())return r.a.createElement(He.a,null);const{t:e,location:t}=this.props,a=[{icon:"fas fa-user-cog",locations:["users"],href:"/farmSettings/users",name:e("users"),roles:[s.c._USER_MANAGE]},{icon:"fas fa-dollar-sign",locations:["billing"],href:"/farmSettings/billing",name:e("billing"),roles:[s.c._BILLING],hide:!1}];return r.a.createElement("div",{className:Object(j.a)()?"farm-settings mobile":"farm-settings"},r.a.createElement(o.a,{menuItems:a,showPing:!1}),r.a.createElement("div",{className:"farm-settings-main"},r.a.createElement(i.g,{location:t},r.a.createElement(i.d,{path:"/farmSettings/billing",render:e=>r.a.createElement(Q,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/billing/farm/:FarmID/edit",render:e=>r.a.createElement(lt,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/billing/farm/:FarmID/renew",render:e=>r.a.createElement(ae.a,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/billing/history",render:e=>r.a.createElement(te,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/subscription/add",render:e=>r.a.createElement(ae.a,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/users",render:e=>r.a.createElement(Xe,e),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/users/add",render:()=>r.a.createElement(Ie,null),exact:!0}),r.a.createElement(i.d,{path:"/farmSettings/admin/renew",render:()=>r.a.createElement(p.a,null," ",r.a.createElement(Qe.default,null))}))))}}t.default=Object(N.a)()(ct)},VdWs:function(e,t,a){"use strict";var n=a("q1tI"),r=a.n(n),i=a("uSQv"),s=a("/MKj"),o=a("ANjH"),l=a("f0zD"),c=a("42VQ"),m=a("JZab"),u=a("BDYJ"),h=a("17x9"),d=a.n(h),p=a("9D2Z"),b=a("kG49"),f=a("CuyV"),g=a("LCzB"),E=a("XzT5"),v=a("BvFm");function O(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 y(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class D extends r.a.Component{constructor(...e){super(...e),this.onMakeDefaultClick=()=>{const{value:e,attributes:t,t:a}=this.props;this.props.show(c.a,{title:a("farmSettings.billingPaymentButtons.defaultTitle"),text:E.a.t("farmSettings.billingPaymentButtons.defaultText",{type:e.maskedNumber}),onConfirmed:a=>{this.props.dispatch(Object(m.c)(e.token,{options:{makeDefault:!0}},t.sub)),a.handleHide()}})},this.onRemoveClick=()=>{const{value:e,t:t,dispatch:a,attributes:n}=this.props;this.props.show(c.a,{title:t("farmSettings.billingPaymentButtons.deleteTitle"),text:E.a.t("farmSettings.billingPaymentButtons.deleteText",{type:e.maskedNumber}),onConfirmed:t=>{Object(u.a)(e.token).then(e=>{Object(u.c)(e),a(Object(m.a)("","","",n.sub,!0)),t.handleHide()}).catch(e=>{Object(u.b)(e)})}})},this.getContent=()=>{const e=Object(v.i)(),{t:t}=this.props;if(e)return r.a.createElement("span",null,r.a.createElement("i",{className:"fas fa-ban mr-1"}),t("noServiceAccess"))}}render(){const{showAsMenu:e,event:t,t:a}=this.props,n=Object(v.i)();return e?r.a.createElement(p.a,{event:t},r.a.createElement(b.a,{icon:r.a.createElement("i",{className:"fas fa-pencil-alt fa-fw"}),onClick:this.onEditClick},a("edit")),r.a.createElement(b.a,{icon:r.a.createElement("i",{className:"fas fa-credit-card fa-fw"}),onClick:this.onMakeDefaultClick,disabled:this.props.value.data.default},a("farmSettings.billingPaymentButtons.makeDefault")),r.a.createElement(b.a,{icon:r.a.createElement("i",{className:"fas fa-trash fa-fw"}),onClick:this.onRemoveClick,disabled:this.props.value.data.default},a("delete"))):r.a.createElement("div",{className:"billing-payment-buttons"},r.a.createElement(f.a,{tooltipContent:this.getContent()||a("farmSettings.billingPaymentButtons.makeDefault")},r.a.createElement("div",null,r.a.createElement(i.a,{buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-credit-card"}),onClick:this.onMakeDefaultClick,disabled:this.props.value.data.default||n,buttonColor:"info"}))),r.a.createElement(f.a,{tooltipContent:this.getContent()||a("delete")},r.a.createElement("div",null,r.a.createElement(i.a,{buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-trash"}),buttonColor:"error",onClick:this.onRemoveClick,disabled:this.props.value.data.default||n}))))}}D.propTypes={showAsMenu:d.a.bool,event:d.a.object},t.a=Object(o.d)(Object(g.a)(),Object(s.connect)((function(e){return{attributes:e.user.attributes}}),(function(e){return function(e){for(var t=1;t2100?l.a.t("transactions.errors.".concat(2101)):l.a.t("transactions.errors.".concat(e))}render(){const{value:{status:e},t:t}=this.props;return r.a.createElement("div",null,"submitted_for_settlement"===e&&r.a.createElement(s.a,{tooltipContent:t("transactions.errors.submittedForSettlement"),type:"info"},r.a.createElement("i",{className:"fas fa-clock"})),"settled"===e&&r.a.createElement("i",{className:"fas fa-check"}),"settled"!==e&&"submitted_for_settlement"!==e&&r.a.createElement(s.a,{tooltipContent:this.getError(),type:"error"},r.a.createElement("i",{className:"fas fa-times"})))}}c=Object(o.a)()(c),c=Object(i.connect)(e=>({}))(c),t.a=c},ahsf:function(e,t,a){"use strict";a.d(t,"a",(function(){return i}));var n=a("q1tI"),r=a.n(n);class i extends r.a.Component{render(){return r.a.createElement("div",null,r.a.createElement("span",null,r.a.createElement("i",{className:"fas fa-download"})," ","pobierz"))}}},chaV:function(e,t,a){},cuAX:function(e,t,a){},eCHg:function(e,t,a){},eiNd:function(e,t,a){"use strict";a.r(t),a.d(t,"LastScannedRFIDView",(function(){return w}));var n=a("mwIZ"),r=a.n(n),i=a("q1tI"),s=a.n(i),o=a("XSU/"),l=a("2tEe"),c=a("/MKj"),m=a("AAik"),u=a("VyNe"),h=a("10H7"),d=(a("mZs5"),a("wd/R")),p=a.n(d),b=a("pxzG"),f=a("eASP"),g=a("64Zf"),E=a("6/k7"),v=a("LCzB");class O extends s.a.Component{render(){console.log(this.props);const{object:{date:e,animal:{AnmNo1:t},RFID:a,type:n},getType:r,getData:i,object:o,t:l}=this.props;return s.a.createElement("div",{className:"mobile-rfid-row"},s.a.createElement("div",{className:"font-weight-bold"},l("lastScannedRFID.animalNo"),": ",t),s.a.createElement("div",null,l("date"),": ",p()(e).format("DD.MM.YYYY HH:mm")),s.a.createElement("div",null,l("rfidNumber"),": ",a),s.a.createElement("div",null,l("lastScannedRFID.eventData"),": ",r(n)),i({value:o}))}}var y=Object(v.a)()(O),D=a("XzT5");class w extends s.a.Component{constructor(...e){super(...e),this.dateValueConverter=e=>p()(e).format("DD.MM.YYYY HH:mm"),this.typeValueFormatter=e=>{const{t:t}=this.props;switch(e){case"documents":return t("lastScannedRFID.documents");case"feeding":return t("lastScannedRFID.feeding");case h.b.ACTIVE_NIPPLES:return t("lastScannedRFID.activeNipples");case h.b.INSEMINATION:return t("lastScannedRFID.insemination");case h.b.TRANSFER:return t("lastScannedRFID.transfer");case h.b.WEIGHTING:return t("lastScannedRFID.weighting");case h.b.SELL:return t("lastScannedRFID.sell");case h.b.FALL:return t("lastScannedRFID.fall");case h.b.FALL_PIGLETS:return t("lastScannedRFID.fallPiglets");case h.b.GRAFTING:return t("lastScannedRFID.grafting");case h.b.MOMMY:return t("lastScannedRFID.mommy");case h.b.NO_PREGNANCY:return t("lastScannedRFID.noPregnancy");case h.b.PARTURITION:return t("lastScannedRFID.parturition");case h.b.SELECTION:return t("lastScannedRFID.selection");case h.b.SEPARATION:return t("lastScannedRFID.separation1");case h.b.SEPARATION_TO_MOMMY:return t("lastScannedRFID.separation2");case h.b.TREATMENT:return t("scheduleOfTreatment");case h.b.USG:return t("lastScannedRFID.usg");default:return e}},this.getDataComponent=e=>{const{t:t}=this.props;switch(console.log(e),e.value.type){case h.b.ACTIVE_NIPPLES:return s.a.createElement("div",null,t("activeNipplesAmount"),": ",e.value.data.activeNipples);case h.b.FALL:return s.a.createElement("div",null,s.a.createElement("div",null,t("reason"),": ",this.getFallReason(e.value.data.reason)),s.a.createElement("div",null,t("weight"),": ",+e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)));case h.b.FALL_PIGLETS:return s.a.createElement("div",null,s.a.createElement("div",null,t("reason"),": ",this.getFallReason(e.value.data.reason)),s.a.createElement("div",null,t("weight"),": ",+e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)),s.a.createElement("div",null,t("pigletsAmount"),": ",+e.value.data.pigletsCount));case h.b.GRAFTING:return s.a.createElement("div",null,s.a.createElement("div",null,t("medicine"),": ",this.getMedicine(e.value.data.medicine)),s.a.createElement("div",null,t("reason"),": ",e.value.data.reason),s.a.createElement("div",null,t("weight"),": ",e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)),s.a.createElement("div",null,t("graftingType"),": ",e.value.data.graftingType),e.value.data.graftingType!==g.a.GRAFTING&&s.a.createElement(s.a.Fragment,null,s.a.createElement("div",null,t("lastScannedRFID.startDay"),": ",e.value.data.startDate),s.a.createElement("div",null,t("lastScannedRFID.endDay"),": ",e.value.data.endDate)));case h.b.INSEMINATION:return s.a.createElement("div",null,t("boar"),": ",e.value.data.boar.AnmNo1);case h.b.MOMMY:return s.a.createElement("div",null,t("pigletsAmount"),": ",e.value.data.pigletsCount);case h.b.NO_PREGNANCY:return s.a.createElement("div",null,t("reason"),": ",this.getNoPregnancyReason(e.value.data.reason));case h.b.PARTURITION:return s.a.createElement("div",null,s.a.createElement("div",null,t("alive"),": ",e.value.data.alive),s.a.createElement("div",null,t("dead"),": ",e.value.data.dead),s.a.createElement("div",null,t("mummies"),": ",e.value.data.mummy));case h.b.SELECTION:return s.a.createElement("div",null,t("reason"),": ",this.getSelectionReason(e.value.data.reason));case h.b.SELL:return s.a.createElement("div",null,s.a.createElement("div",null,t("client"),": ",this.getClient(e.value.data.client)),s.a.createElement("div",null,D.a.t("lastScannedRFID.priceFor",{unit:Object(b.l)("weight",f.a.MEDIUM)}),": ",e.value.data.price||"-"),s.a.createElement("div",null,t("weight"),": ",e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)));case h.b.SEPARATION_TO_MOMMY:return s.a.createElement("div",null,s.a.createElement("div",null,t("weight"),": ",e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)),s.a.createElement("div",null,t("pigletsAmount"),": ",e.value.data.pigletsCount));case h.b.SEPARATION:return s.a.createElement("div",null,e.value.data.addToExistingGroup&&s.a.createElement(s.a.Fragment,null,t("lastScannedRFID.assignToExistingGroup"),": ",e.value.data.existingGroup.AnmNo1),!e.value.data.addToExistingGroup&&s.a.createElement(s.a.Fragment,null,e.value.data.createNewGroup&&s.a.createElement(s.a.Fragment,null,s.a.createElement("div",null,t("newGroupNumber"),": ",e.value.data.newGroupNumber)),!e.value.data.createNewGroup&&s.a.createElement(s.a.Fragment,null,s.a.createElement("div",null,t("lastScannedRFID.group"),": ",e.value.data.selectedGroup.AnmNo1)),s.a.createElement("div",null,t("separationTo"),": ",e.value.data.separationTo.CName)));case h.b.TRANSFER:return s.a.createElement("div",null,s.a.createElement("div",null,t("transferTo"),": ",r()(e.value.data.location.object,e.value.data.location.name)),e.value.data.stand&&s.a.createElement("div",null,t("standing"),": ",e.value.data.stand.BoxesName),e.value.data.curve&&s.a.createElement(s.a.Fragment,null,s.a.createElement("div",null,t("feedingCurve"),": ",e.value.data.curve.SetData.Name),s.a.createElement("div",null,[E.e.MIXED_PARTURITION,E.e.BEFORE_PARTURITION].includes(e.value.data.curve.SetData.Type)?t("plannedParturitionDay"):t("lastScannedRFID.curveStart"),": ",p()(e.value.data.curveDate).format("DD.MM.YYYY"))));case h.b.TREATMENT:return s.a.createElement("div",null,e.value.data.treatment.map((e,a)=>s.a.createElement("div",null,s.a.createElement("div",null,a+1,". ",t("medicines"),": ",e.medicines.map(e=>e.WData.Name).join(", ")),s.a.createElement("div",null,t("lastScannedRFID.days"),": ",e.days.map(e=>e.format("DD.MM.YYYY")).join(", ")))));case h.b.USG:return s.a.createElement("div",null,t("lastScannedRFID.pregnancy"),": ",s.a.createElement("i",{className:e.value.data.pregnant?"fas fa-check":"fas fa-times"}));case h.b.WEIGHTING:return s.a.createElement("div",null,s.a.createElement("div",null,t("reason"),": ",this.getWeightingReason(e.value.data.reason)),s.a.createElement("div",null,t("weight"),": ",e.value.data.weight," ",Object(b.l)("weight",f.a.MEDIUM)));default:return null}}}getFallReason(e){const{fallReasons:{WData:t},lang:a}=this.props;let n=t[a].find(t=>t.ID===e);if(n)return n.Value}getMedicine(e){const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e);if(a)return a.Value}getNoPregnancyReason(e){const{noPregnancyReason:{WData:t},lang:a}=this.props;let n=t[a].find(t=>t.ID===e);if(n)return n.Value}getSelectionReason(e){const{selectionReasons:{WData:t},lang:a}=this.props;let n=t[a].find(t=>t.ID===e);if(n)return n.Value}getClient(e){const{clients:{WData:t},lang:a}=this.props;let n=t[a].find(t=>t.ID===e);if(n)return n.Value}getWeightingReason(e){const{weighting:{WData:t},lang:a}=this.props;let n=t[a].find(t=>t.ID===e);if(n)return n.Value}render(){const{rfidScanned:e,t:t}=this.props,a=[{name:t("date"),field:"date",valueFormatter:this.dateValueConverter},{name:t("lastScannedRFID.animalNo"),field:"animal.AnmNo1"},{name:t("rfidNumber"),field:"RFID"},{name:t("lastScannedRFID.type"),field:"type",valueFormatter:this.typeValueFormatter},{name:t("lastScannedRFID.eventData"),component:this.getDataComponent}];return s.a.createElement("div",{className:"last-scanned-rfid"},s.a.createElement(o.a,{text:t("lastScannedRFID.title")}),s.a.createElement(l.a,null,s.a.createElement(u.a,null,s.a.createElement(m.a,{data:e,headers:a,mobileRow:s.a.createElement(y,{getData:this.getDataComponent,getType:this.typeValueFormatter})}))))}}w=Object(c.connect)(e=>({rfidScanned:e.rfid.rfidScanned,fallReasons:e.dictionary.fallReasons,lang:e.language.lang.lang,medicines:e.dictionary.medicine,noPregnancyReason:e.dictionary.noPreganancy,selectionReasons:e.dictionary.selectionReason,clients:e.dictionary.clients,weighting:e.dictionary.weighting}))(w);t.default=Object(v.a)()(w)},fp2G:function(e,t,a){},kD9f:function(e,t,a){},mZs5:function(e,t,a){},nWo0:function(e,t,a){},ozwV:function(e,t,a){},pXhI:function(e,t,a){"use strict";a.r(t),a.d(t,"EventChooserView",(function(){return Gn}));var n=a("q1tI"),r=a.n(n),i=a("XSU/"),s=a("2tEe"),o=(a("eCHg"),a("/MKj")),l=a("Ty5D"),c=a("J2iB"),m=a.n(c),u=a("Y+p1"),h=a.n(u),d=a("IXwn"),p=a("tkTQ"),b=a("uSQv"),f=a("QWcO"),g=a("ujxO"),E=a("PRyg"),v=a("17x9"),O=a.n(v),y=(a("7PUi"),a("10H7")),D=a("GQws"),w=a("v9qu"),j=a("ANjH"),C=a("LCzB"),F=a("wd/R"),I=a.n(F),A=a("n7pt"),S=a("kCVf"),R=a("BUlv");class N extends r.a.Component{constructor(e){super(e),this.sortByCategory=()=>{const{options:e}=this.props;let t=[],a=[],n=[],r=[],i=[],s=[];e.map(e=>{switch(e.category){case y.a.GRAFTING:a=[...a,e];break;case y.a.PROCREATION:n=[...n,e];break;case y.a.PARTURITION:r=[...r,e];break;case y.a.FALL:i=[...i,e];break;case y.a.SELL:s=[...s,e];break;default:t=[...t,e]}}),this.setState({overall:t,sell:s,fall:i,parturition:r,procreation:n,grafting:a})},this.onClick=e=>{const{farm:t}=this.props;this.props.history.push("/".concat(t,"/eventChooser/").concat(e))},this.getDraftTooltip=e=>{const{t:t}=this.props;return r.a.createElement(r.a.Fragment,null,r.a.createElement("div",null,t("foundDrafts")),e.map((e,t)=>r.a.createElement("div",{key:t},this.getDraftName(e))))},this.state={overall:[],grafting:[],procreation:[],parturition:[],fall:[],sell:[]}}componentDidMount(){this.sortByCategory()}componentDidUpdate(e,t,a){const{options:n}=this.props;n!==e.options&&this.sortByCategory()}styleToMobile(){return Object(w.a)()?"fetura-event-picker-mobile":"fetura-event-picker"}getDraftName(e){const{t:t}=this.props;if(e.formName.includes("Insert")){let a=e.formName.split("_"),n=A.a.getLocationByID(a[1]);return I()(e.time).format("DD.MM.YYYY")+" - "+Object(S.k)(n)+" - "+t("animalKind.".concat(a[2]))}if(e.formName.includes("transfer")||e.formName.includes(R.a.SEPARATION_TO_PORKHOUSE)){let t=e.formName.split("_"),a=A.a.getLocationByID(t[1]);return I()(e.time).format("DD.MM.YYYY")+" - "+Object(S.k)(a)}return I()(e.time).format("DD.MM.YYYY")}render(){const{required:e,label:t,t:a}=this.props,{sell:n,fall:i,parturition:s,procreation:o,grafting:l,overall:c}=this.state;return r.a.createElement(r.a.Fragment,null,t&&r.a.createElement("label",null,t,e&&r.a.createElement("sup",null,"*")),r.a.createElement("div",{className:this.styleToMobile()},r.a.createElement(r.a.Fragment,null,r.a.createElement("div",{className:"top-column"},r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("general")),c&&c.length>0&&r.a.createElement("div",{className:"menuItemBox"}," ",r.a.createElement(D.a,{value:null,options:c,onChange:this.onClick,showLabels:!0,itemsInRow:4,getDraftTooltip:this.getDraftTooltip}))),r.a.createElement("span",{className:"vl"}),r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("treatment")),l&&l.length>0&&r.a.createElement("div",{className:"menuItemBox"}," ",r.a.createElement(D.a,{value:null,options:l,onChange:this.onClick,showLabels:!0,itemsInRow:4}))),r.a.createElement("span",{className:"vl"}),r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("menu.procreation")),o&&o.length>0&&r.a.createElement("div",{className:"menuItemBox"}," ",r.a.createElement(D.a,{value:null,options:o,onChange:this.onClick,showLabels:!0,itemsInRow:4})))),r.a.createElement("div",{className:"bottom-column"},r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("menu.parturition")),s&&s.length>0&&r.a.createElement("div",{className:"menuItemBox"},r.a.createElement(D.a,{value:null,options:s,onChange:this.onClick,showLabels:!0,itemsInRow:4,getDraftTooltip:this.getDraftTooltip}))),r.a.createElement("span",{className:"vl"}),r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("menu.fall")),i&&i.length>0&&r.a.createElement("div",{className:"menuItemBox"}," ",r.a.createElement(D.a,{value:null,options:i,onChange:this.onClick,showLabels:!0,itemsInRow:4}))),r.a.createElement("span",{className:"vl"}),r.a.createElement("div",{className:"menuBox"},r.a.createElement("h1",null,a("sale")),n&&n.length>0&&r.a.createElement("div",{className:"menuItemBox"},r.a.createElement(D.a,{value:null,options:n,onChange:this.onClick,showLabels:!0,itemsInRow:4})))))))}}N.propTypes={options:O.a.arrayOf(O.a.shape({value:O.a.oneOf([O.a.string,O.a.number,O.a.object]).isRequired,svgPath:O.a.string,label:O.a.string,disabled:O.a.bool})),onClick:O.a.func},N.defaultProps={optionsInSingleRow:4,showLabels:!1,onChange:()=>{},itemsInRow:5};var P=Object(j.d)(Object(C.a)(),Object(o.connect)(e=>({farm:e.location.farm})),l.o)(N);class k extends r.a.Component{constructor(e){super(e),this.onChangeAnimalType=e=>{this.setState({animalType:e})},this.renderAnimalButton=e=>{const{t:t}=this.props,a=Object.keys(p.a).filter(t=>p.a[t]===e)[0].toLowerCase().replace("_","");return r.a.createElement(b.a,{onClick:()=>this.onChangeAnimalType(e),selected:this.state.animalType===e,type:"button"},t("events.animalKindChooser.".concat(a)))},this.state={animalType:null}}shouldComponentUpdate(e,t,a){return!h()(e,this.props)||!h()(t,this.state)}render(){const{animalType:e}=this.state,{t:t}=this.props,a=Object(E.getEventsList)(t).filter(t=>m()(e)||t.eligibleAnimal.includes(e)),n=r.a.createElement(r.a.Fragment,null,r.a.createElement(b.a,{onClick:()=>this.onChangeAnimalType(null),selected:m()(this.state.animalType),type:"button"},t("all")),Object.values(p.a).map(e=>![p.a.PIG].includes(e)&&this.renderAnimalButton(e)));return r.a.createElement("div",{className:"events"},r.a.createElement(f.a,null,({windowWidth:e})=>e>=g.a.SM?r.a.createElement(d.a,{className:"w-100 d-flex justify-content-center"},n):n),r.a.createElement(P,{options:a}))}}k=Object(C.a)()(k);var x=a("VyNe"),M=a("i8MS"),T=a("bHJJ"),B=a("hw2D"),V=a("zk5+"),L=a("sJUw"),G=(a("chaV"),a("f0zD")),W=a("42VQ"),U=a("91lk");function q(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 z(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class _ extends r.a.Component{constructor(...e){super(...e),this.state={nextLocation:null},this.tableInput=r.a.createRef(),this.showPromptModal=e=>{if(e.state&&e.state.ignoreModal)return!0;const{t:t}=this.props;return this.props.show(W.a,{title:t("newSettings.translate.edit.notSaved"),text:t("eventChooser.notSavedText"),confirmText:t("save"),closeText:t("cancel"),optionalButtons:r.a.createElement(b.a,{buttonColor:"error",onClick:()=>this.onNotSaveClick(e)},t("doNotSave")),onConfirmed:()=>this.onSaveClick(e)}),!1},this.resetForm=()=>{this.props.resetForm(this.props.formikReset),this.tableInput.current.setFilters(this.props.initialFilters||{date:I()()})},this.onSubmitClick=()=>{const{handleSubmit:e,errors:{data:t},t:a}=this.props;let n=this.props.values.data.slice(0);if(t){let r=t.reduce((e,t,a)=>(Object.keys(t).length>0&&e.push(a),e),[]);this.props.show(W.a,{text:a("eventChooser.validationErrorsText",{amount:r.length}),title:a("eventChooser.validationErrors"),confirmText:a("yes"),closeText:a("cancel"),onConfirmed:t=>{const{current:{props:{columns:a}}}=this.tableInput;for(let e of r){a.filter(t=>n[e].hasOwnProperty(t.key)&&(t.editable||!t.hasOwnProperty("editable"))).forEach(t=>{delete n[e][t.key]})}this.props.onChange("data",n),setTimeout(()=>{this.hasAnyValues()?e():this.tableInput.current.setFilters(this.props.initialFilters||{date:I()()})},100),t.handleHide()}})}else e()}}componentDidMount(){this.props.getApi&&this.props.getApi({resetForm:this.resetForm,tableInput:this.tableInput.current})}componentDidUpdate(e,t,a){this.state.nextLocation&&0===this.props.values.data.length&&(this.setState({nextLocation:null}),this.props.history.push(this.state.nextLocation))}leaveComponentAfterPrompt(e){this.setState({nextLocation:e},()=>{this.props.onChange("data",[]),this.props.hide(W.a)})}onNotSaveClick(e){this.leaveComponentAfterPrompt(e)}onSaveClick(e){U.a.insertFormData(this.props.formName,this.props.values),this.leaveComponentAfterPrompt(e)}hasAnyValues(){const{values:{data:e},ignoreFields:t,customIsEmpty:a}=this.props;if(e)for(let n of e)if(a){if(!a(n))return!0}else if(!Object(V.w)(n,t))return!0;return!1}render(){const{columns:e,onFiltersChange:t,initialFilters:a,values:n,onChange:i,errors:s,hasNext:o,disableAddingNewRow:c,isSubmitting:m,onDataChange:u,getDisabledRows:h}=this.props;let p=this.hasAnyValues();return r.a.createElement("div",{className:"form-for-events"},r.a.createElement(L.a,{columns:e,shouldIndex:!0,onFiltersChange:t,initialFilters:a||{date:I()()},onChange:i,ref:this.tableInput,value:n.data,errors:s.data,disableAddingNewRow:c,onDataChange:u,getDisabledRows:h}),r.a.createElement(d.a,{fixed:!0,renderInPortal:!1},r.a.createElement(b.a,{buttonColor:"error",buttonStyle:"round",icon:r.a.createElement("i",{className:"fas fa-trash"}),type:"button",onClick:this.resetForm}),r.a.createElement(b.a,{buttonColor:"success",buttonStyle:"round",onClick:this.onSubmitClick,icon:o?r.a.createElement("i",{className:"fas fa-arrow-right"}):m?r.a.createElement("i",{className:"fas fa-circle-notch fa-spin"}):r.a.createElement("i",{className:"fas fa-check"}),disabled:m||!p})),r.a.createElement(l.b,{when:p,message:this.showPromptModal}))}}_.propTypes={handleSubmit:O.a.func.isRequired,columns:O.a.array.isRequired,formName:O.a.string.isRequired,onFiltersChange:O.a.func,onDataChange:O.a.func,initialFilters:O.a.object,hasNext:O.a.bool,disableAddingNewRow:O.a.bool,isSubmitting:O.a.bool,ignoreFields:O.a.arrayOf(O.a.string),getApi:O.a.func,customIsEmpty:O.a.func,getDisabledRows:O.a.func},_.defaultProps={ignoreFields:[]};var Y=Object(j.d)(Object(o.connect)(null,(function(e){return function(e){for(var t=1;t{const{boars:a}=this.state,{t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a,onChange:t,placeholder:n("boar")})},this.onFiltersChange=(e,t,a)=>{if(e.hasOwnProperty("animal")){const{animal:n}=e;if(!h()(n,a.animal))if(n){let e=M.a.getAllAnimalsForLocation(n,X.a.CHAMBER,{joinEvents:!1}).filter(e=>e.AnimalKind===p.a.SOW||e.AnimalKind===p.a.RENOVATION_SOW).slice(0);e.sort((e,t)=>e.AnmNo1&&e.AnmNo1.localeCompare(t.AnmNo1)),t=t.map(()=>({animal:e.shift()||null}));for(let a of e)t.push({animal:a})}else t=t.map(e=>function(e){for(var t=1;t{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);if(t.animal){let a=M.a.getAllAnimalsForLocation(t.animal,X.a.CHAMBER,{joinEvents:!1}).filter(e=>e.AnimalKind===p.a.SOW||e.AnimalKind===p.a.RENOVATION_SOW).slice(0);Object(V.A)(a,e)||this.api.tableInput.removeFilter("animal")}this.setState({sows:Object(V.k)(Object(V.r)(a,n))})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.boar||(t.boar=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,boar:i}=a;e&&t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r,boarID:i.AnmID})}return Object(K.a)(t).then(e=>{Object(K.c)(e),this.api.resetForm()}).catch(e=>{console.error(e),Object(K.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.matingsFormatter=({value:e,onChange:t})=>{const{chambers:a}=this.state,{t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a,onChange:t,placeholder:n("listOfMatings")})},this.setFormRef=e=>{this.form=e},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.r)(e),a=M.a.getAllAnimals(e,p.a.BOAR,!1,!1),n=A.a.getAllChambersForSTypeWithLocation(J.a.MATING,this.props.farm);this.setState({sows:Object(V.k)(t),boars:Object(V.k)(a),initialData:Object(V.m)(te),chambers:n.map(e=>({name:M.a.getAnimalLocationsByPlcmntID(e.CID,{nameDeep:3})[0].name,value:e}))})}render(){console.log(this);const{sows:e,boars:t,initialData:a}=this.state,{t:n}=this.props,i=[{name:Z.a.t("animalNumber"),key:"animal",editor:r.a.forwardRef((t,a)=>r.a.createElement(T.a,Q({ref:a},t,{options:e}))),formatter:V.c,filterRenderer:this.matingsFormatter,disableAutoInsert:!0,disableDragAndDrop:!0,clearRowOnRemove:!0},{name:n("boar"),key:"boar",editor:r.a.forwardRef((e,a)=>r.a.createElement(T.a,Q({ref:a},e,{options:t}))),formatter:V.c,filterRenderer:this.boarSelect},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:a},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:te,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var ne=Object(j.d)(Object(o.connect)((function(e){return{farm:e.location.farm}})),Object(C.a)())(ae),re=(a("Yofv"),a("U62w"));function ie(){return(ie=Object.assign||function(e){for(var t=1;t{const{usgStates:a}=this.state,{t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a,onChange:t,placeholder:n("testResult")})},this.onFiltersChange=(e,t,a)=>{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("result")){const{result:n}=e;t=Object(V.t)(n,"result",t,a.result)}return t},this.usgResultFormatter=({column:{key:e},row:t})=>{const{t:a}=this.props;switch(t[e]){case y.d.NEGATIVE:return r.a.createElement("span",{className:"usg-result"},a("events.usgEvent.negative")," ",r.a.createElement("i",{className:"fas fa-times fa-fw"}));case y.d.POSITIVE:return r.a.createElement("span",{className:"usg-result"},a("events.usgEvent.positive")," ",r.a.createElement("i",{className:"fas fa-check fa-fw"}));case y.d.REPEAT:return r.a.createElement("span",{className:"usg-result"},a("events.usgEvent.toRepeat")," ",r.a.createElement("i",{className:"fas fa-redo fa-fw"}));default:return""}},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.result)&&(t.result=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,result:i}=a;e&&t.push({AnmID:e.AnmID,EvTime:+n,Comment:r,Pregnant:i})}return Object(re.a)(t).then(e=>{Object(re.c)(e),this.api.resetForm()}).catch(e=>{Object(re.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(se)})}render(){const{sows:e,usgStates:t,initialData:a}=this.state,{t:n}=this.props,i=[Object(V.b)(e),{name:n("testResult"),key:"result",editor:r.a.forwardRef((e,a)=>r.a.createElement(T.a,ie({},e,{options:t,ref:a}))),formatter:this.usgResultFormatter,filterRenderer:this.resultSelect},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:a},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:se,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,isSubmitting:o}))}}var le=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(oe),ce=a("lKVh");function me(){return(me=Object.assign||function(e){for(var t=1;t{const{noPregnancyReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{noPregnancyReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.onFiltersChange=(e,t,a)=>{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.reason||(t.reason=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,reason:i}=a;e&&t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r,Reason:i})}return Object(ce.a)(t).then(e=>{Object(ce.c)(e),this.api.resetForm()}).catch(e=>{Object(ce.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(ue)})}render(){const{sows:e,initialData:t}=this.state,{noPregnancyReasons:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,me({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:ue,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var de=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,noPregnancyReasons:e.dictionary.noPreganancy.WData[e.language.lang.lang]}})))(he),pe=a("y3qy"),be=a("pxzG"),fe=a("eASP"),ge=a("pKOT"),Ee=a("17UY"),ve=a("q17X"),Oe=a("7EKC");function ye(){return(ye=Object.assign||function(e){for(var t=1;t{if(e){let t=this.getParturitionDate(e);if(t)return{date:t}}return{}},this.onFiltersChange=(e,t,a)=>{if(e.hasOwnProperty("animal")){const{animal:n}=e,{animal:r}=a;h()(n,r)||(t=Object(V.B)(n,t,{onRowChange:this.onRowChange}))}if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("piglets")){const{piglets:n}=e;t=Object(V.t)(n,"piglets",t,a.piglets)}if(e.hasOwnProperty("dead")){const{dead:n}=e;t=Object(V.t)(n,"dead",t,a.dead)}if(e.hasOwnProperty("mummy")){const{mummy:n}=e;t=Object(V.t)(n,"mummy",t,a.mummy)}if(e.hasOwnProperty("temperature")){const{temperature:n}=e;t=Object(V.t)(n,"temperature",t,a.temperature)}if(e.hasOwnProperty("falls")){const{falls:n}=e;t=Object(V.t)(n,"falls",t,a.falls)}if(e.hasOwnProperty("difficulty")){const{difficulty:n}=e;t=Object(V.t)(n,"difficulty",t,a.difficulty)}return t=Object(V.v)(e,t,a.operator),t=Object(V.s)(e,t,a.comment)},this.difficultyFormatter=({column:{key:e},row:t})=>{const{t:a}=this.props;switch(t[e]){case y.c.LOW:return a("low");case y.c.MEDIUM:return a("medium");case y.c.HARD:return a("hard");default:return""}},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averagePigletWeightShort")})},this.pigletsFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("alive"),allowFloat:!1})},this.deadFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("dead"),allowFloat:!1})},this.mummyFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("mummies"),allowFloat:!1})},this.temperatureFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("newSettings.dispenserNRF.temperature.title")})},this.fallsFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("menu.fall"),allowFloat:!1})},this.difficultyFilter=({value:e,onChange:t})=>{const{parturitionDifficulties:a}=this.state,{t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a,onChange:t,placeholder:n("difficulty")})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.weight)&&(t.weight=n("required")),m()(e.piglets)?t.piglets=n("required"):+e.piglets<0&&(t.piglets=n("errors.noLessOrEq0")),m()(e.dead)?t.dead=n("required"):+e.dead<0&&(t.dead=n("errors.lessVal",{count:0})),m()(e.mummy)?t.mummy=n("required"):+e.mummy<0&&(t.mummy=n("errors.lessVal",{count:0})),0===+e.piglets&&0===+e.dead&&0===+e.mummy&&(t.piglets=n("errors.atLeastMusBeGreaterThan0"),t.dead=n("errors.atLeastMusBeGreaterThan0"),t.mummy=n("errors.atLeastMusBeGreaterThan0")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,dead:i,piglets:s,mummy:o,weight:l,temperature:c,falls:m,difficulty:u}=a;console.log(l),e&&t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r,DeadCnt:+i,HealthyCnt:+s,MummyCnt:+o,Weight:Object(be.i)(parseFloat(l),{fromUnit:fe.a.MEDIUM})*+s,Temperature:c,Falls:m,Type:u})}return Object(ge.a)(t).then(e=>{Object(ge.c)(e),this.api.resetForm()}).catch(e=>{Object(ge.b)(e)})},this.onAnimalChange=e=>{if(e.animal){let t=this.getParturitionDate(e.animal);t&&(e.date=t)}return e},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(De)})}getParturitionDate(e){let t=Ee.a.getAllEvents4Animal(e.AnmID).filter(e=>e.EvCode===y.b.INSEMINATION).sort((e,t)=>t.EvTime-e.EvTime)[0];if(t){let e=Object(ve.getTimeFromInseminationToPartuition)();return I()(t.EvTime).add(e,"days")}return null}render(){const{sows:e,initialData:t,parturitionDifficulties:a}=this.state,{t:n}=this.props,i=[Object(V.b)(e,this.onAnimalChange),{name:n("averagePigletWeightShort"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},{name:n("alive"),key:"piglets",filterRenderer:this.pigletsFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("dead"),key:"dead",filterRenderer:this.deadFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("mummies"),key:"mummy",filterRenderer:this.mummyFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("newSettings.dispenserNRF.temperature.title"),key:"temperature",filterRenderer:this.temperatureFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e)))},{name:n("menu.fall"),key:"falls",filterRenderer:this.fallsFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ye({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("difficulty"),key:"difficulty",filterRenderer:this.difficultyFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,ye({},e,{options:a,ref:t}))),formatter:this.difficultyFormatter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:De,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,isSubmitting:o}))}}var je=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(we),Ce=a("P/G1"),Fe=a.n(Ce),Ie=a("E+oP"),Ae=a.n(Ie),Se=a("BbMY"),Re=a("erjJ");class Ne extends n.Component{constructor(...e){super(...e),this.onClickStep=e=>{const{farm:t}=this.props;switch(e){case 1:this.props.history.push("/".concat(t,"/eventChooser"));break;case 2:this.props.history.push("/".concat(t,"/eventChooser/locationChooser/separationToPigletHouse"));break;default:return}}}render(){const{activeStep:e,t:t}=this.props;return r.a.createElement(Se.a,{activeStep:e,onClickStep:this.onClickStep},r.a.createElement(Re.a,{label:t("events.stepper.selectEventType")}),r.a.createElement(Re.a,{label:t("events.stepper.chooseLocation")}),r.a.createElement(Re.a,{label:t("events.stepper.insertEventData")}))}}Ne.propTypes={activeStep:O.a.number.isRequired};var Pe=Object(j.d)(Object(C.a)(),l.o,Object(o.connect)((function(e){return{farm:e.location.farm}})))(Ne),ke=a("V//l"),xe=a("aIXM"),Me=a("txkB"),Te=a("WlsQ"),Be=a("vzPY");function Ve(){return(Ve=Object.assign||function(e){for(var t=1;t{if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date,this.blockInputWhenNoAnimal)}if(t=Object(V.v)(e,t,a.operator,this.blockInputWhenNoAnimal),t=Object(V.s)(e,t,a.comment,this.blockInputWhenNoAnimal),e.hasOwnProperty("piglets")){const{piglets:n}=e;t=Object(V.t)(n,"piglets",t,a.piglets,this.blockInputWhenNoAnimal)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight,this.blockInputWhenNoAnimal)}if(e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1,this.blockInputWhenNoAnimal)}return t=this.insertLocation(e,t),t=this.insertGroup(e,t)},this.pigletsFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("pigletsAmount"),allowFloat:!1})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averagePigletWeightShort")})},this.groupFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("groupNumber")})},this.anmNo1Filter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("animalNumberShort")})},this.locationFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(Me.a,{value:e,onChange:t,options:this.state.buildings,placeholder:a("location")})},this.locationFormatter=({column:{key:e},row:t})=>t[e]?r.a.createElement(Be.a,{value:t[e].BoxesName}):null,this.allLocationFormatter=({column:{key:e},row:t})=>t[e]?Object(S.k)(t[e].object):null,this.groupFormatter=({column:{key:e},row:t})=>{let a=t[e];return a?"object"===typeof a?a.GrNo1:a:null},this.anmNo1Formatter=({column:{key:e},row:t})=>{let a=t[e];return a?"object"===typeof a?a.AnmNo1:a:null},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;let r=!1;return a&&(t.data=a.map(e=>{const t={};if(e.animal){if(m()(e.piglets))t.piglets=n("required");else if(e.piglets<1)t.piglets=n("errors.noLess",{number:1});else if(e.date){let a=Ee.a.getPigBalanceForASow(e.animal,e.date);a{const{group:t}=e;return this.blockInputWhenNoAnimal(e)&&!(t&&"object"===typeof t)},this.blockInputWhenNoAnimal=({animal:e})=>!!e,this.onLocationChange=(e,t,a)=>(e.location?(e.group=Ue.getGroupByLocation(Object(S.j)(e.location.object))||a.group||null,e.AnmNo1=this.getAnimalByLocation(Object(S.j)(e.location.object))):(e.group=a.group||null,e.AnmNo1=null),e),this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,piglets:i,weight:s,location:o,AnmNo1:l,group:c}=a;e&&t.push({AnmID:e.AnmID,piglets:+i,weight:Object(be.i)(s,{fromUnit:fe.a.MEDIUM}),separateTo:Object(S.j)(o.object),addToAnimal:"object"===typeof l?l.AnmID:void 0,newAnimalNumber:"string"===typeof l?l:void 0,addToGroup:"object"===typeof c?c.AnmGrp:void 0,newGroupNumber:"string"===typeof c?c:void 0,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),EvTime:+n,Comment:r})}return Object(Te.a)(t).then(e=>{Object(Te.c)(e),this.api.resetForm()}).catch(e=>{Object(Te.b)(e)})},this.resetForm=e=>{e(),this.setState(Ge({},this.getInitialData()))},this.getApi=e=>{this.api=e},this.getDisabledRows=(e,t,a)=>{let n=[];for(let r=t;r<=a;r++)this.blockInputWhenNoAnimal(e[r])||n.push(r);return n},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}static getGroupByLocation(e){let t=M.a.getAllAnimalsByPlcmntID(e,{joinEvents:!1});for(let a of t){let e=xe.a.getGroupWithAnimal(a.AnmID,a.FarmID)[0];if(e)return e}return null}componentDidMount(){this.setState(Ge({},this.getInitialData()))}getInitialData(){const{match:{params:{locationID:e}}}=this.props;let t=U.a.getSavedData(this.formName),a=A.a.getLocationByID(e);if(a.Boxes){let e=a.Boxes.map(e=>{let a=M.a.getAllAnimalsByPlcmntID(e.BID,{joinEvents:!1})[0];if(a){let n=Ee.a.getPigBalanceForASow(a,(new Date).getTime()),r=t?t.data.data.find(e=>e.animal&&e.animal.AnmID===a.AnmID):{};return Ge({box:e,animal:a,piglets:n,weight:8,date:I()()},r||{})}return{box:e}});this.setState({initialData:e,hasBoxes:!0})}else{let a=M.a.getAllAnimalsByPlcmntID(e,{joinEvents:!1}).filter(e=>e.AnimalKind===p.a.SOW).map(e=>{let a=t?t.data.data.find(t=>t.animal&&t.animal.AnmID===e.AnmID):{},n=Ee.a.getPigBalanceForASow(e,(new Date).getTime());return Ge({animal:e,piglets:n,date:I()(),weight:8},a||{})});this.setState({initialData:a,hasBoxes:!1})}}insertGroup(e,t){if(e.hasOwnProperty("group")){const{group:a}=e;t=a?t.map(e=>{if(!Fe()(e).every(Ae.a)){return Ge({},e,{group:e.location&&Ue.getGroupByLocation(Object(S.j)(e.location.object))||a})}return{}}):t.map(e=>Ge({},e,{group:this.isGroupEditable(e)?null:e.group}))}return t}insertLocation(e,t){if(e.hasOwnProperty("location")){const{location:a}=e;t=a?t.map(e=>{if(!Fe()(e).every(Ae.a)){let t=Ue.getGroupByLocation(Object(S.j)(a.object)),n=this.blockInputWhenNoAnimal(e),r=this.getAnimalByLocation(Object(S.j)(a.object));return Ge({},e,{location:n?a:null,group:n?t:e.group&&"string"===typeof e.group?e.group:null,AnmNo1:n?r:null})}return{}}):t.map(e=>Ge({},e,{location:null,group:null}))}return t}getAnimalByLocation(e){return M.a.getAllAnimalsByPlcmntID(e,{joinEvents:!1}).filter(e=>e.AnimalKind===p.a.PIGLET)[0]}render(){const{initialData:e,hasBoxes:t}=this.state,{farm:a,t:n}=this.props;let i=[];return t&&i.push({name:n("standing"),key:"box",formatter:this.locationFormatter,editable:!1}),i.push({name:n("animalNumber"),key:"animal",formatter:V.c,editable:!1},{name:n("pigletsAmount"),key:"piglets",filterRenderer:this.pigletsFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({type:"number",ref:t},e,{allowFloat:!1}))),editable:this.blockInputWhenNoAnimal},{name:n("averagePigletWeightShort"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),editable:this.blockInputWhenNoAnimal,formatter:this.weightFormatter},{name:n("location"),key:"location",filterRenderer:this.locationFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(ke.a,Ve({type:"number",ref:t},e,{showStands:!1,farm:a}))),formatter:this.allLocationFormatter,editable:this.blockInputWhenNoAnimal,onChange:this.onLocationChange},{name:n("groupNumber"),key:"group",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({},e,{ref:t,type:"object"}))),formatter:this.groupFormatter,filterRenderer:this.groupFilter,editable:this.blockInputWhenNoAnimal},{name:n("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({},e,{ref:t,type:"text"}))),formatter:this.anmNo1Formatter,filterRenderer:this.anmNo1Filter,editable:this.isGroupEditable},{name:n("date"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.blockInputWhenNoAnimal},{name:n("operator"),key:"operator",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Ve({},e,{options:Object(V.n)(),ref:t}))),formatter:V.z,filterRenderer:V.y,editable:this.blockInputWhenNoAnimal},{name:n("comment"),key:"comment",filterRenderer:V.g,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ve({type:"text",ref:t},e))),editable:this.blockInputWhenNoAnimal}),r.a.createElement("div",null,r.a.createElement(Pe,{activeStep:3}),r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e},enableReinitialize:!0},({values:e,errors:a,setFieldValue:n,handleSubmit:s,handleReset:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:s,columns:i,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:n,errors:a,ignoreFields:t?["box"]:[],resetForm:this.resetForm,initialFilters:{date:I()(),weight:8},disableAddingNewRow:!0,isSubmitting:l,formikReset:o,getApi:this.getApi,getDisabledRows:this.getDisabledRows})))}}var qe=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(Ue),ze=a("CuyV");a("cuAX");class _e extends n.Component{render(){const{column:{name:e},t:t}=this.props;return r.a.createElement("div",{className:"animal-state-header"},e,r.a.createElement(ze.a,{tooltipContent:t("sowStatus")},r.a.createElement("i",{className:"fas fa-question-circle"})))}}var Ye=Object(C.a)()(_e),He=a("u5mR");class Ke extends n.Component{render(){const{column:{name:e},separatedToMommy:t,t:a}=this.props;return r.a.createElement("div",{className:"animal-state-header"},e,r.a.createElement(ze.a,{tooltipContent:a("pigletsSeparatedToMommy",{count:t})},r.a.createElement("i",{className:"fas fa-question-circle"})))}}var Ze=Object(C.a)()(Ke);function Je(){return(Je=Object.assign||function(e){for(var t=1;t{if(e.hasOwnProperty("animal")){const{animal:n}=e,{animal:r}=a;h()(n,r)||(t=Object(V.B)(n,t,{onRowChange:e=>{if(e){return{animalState:{piglets:Ee.a.getPigBalanceForASowInCurrentCycle(e),activeNipples:Ee.a.getActiveNipplesInCurrentCycle(e)}}}return{}}}))}if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date)}if(t=Object(V.v)(e,t,a.operator),t=Object(V.s)(e,t,a.comment),e.hasOwnProperty("get")){const{get:n}=e;t=Object(V.t)(n,"get",t,a.get)}if(e.hasOwnProperty("add")){const{add:n}=e;t=Object(V.t)(n,"add",t,a.add)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.onAnimalChange=(e,t)=>{let{animal:a}=e;if(void 0===a&&(a=t.animal),a){let t=Ee.a.getPigBalanceForASowInCurrentCycle(a),n=Ee.a.getActiveNipplesInCurrentCycle(a);e.animalState={piglets:t,activeNipples:n}}return e},this.animalStateValueFormatter=({column:{key:e},row:t})=>{const{t:a}=this.props;let n=t[e];if(n){let e="- / -";return void 0!==n.piglets&&(e=e.replace("-",n.piglets)),"number"===typeof n.activeNipples&&(e=e.replace(new RegExp("-$"),n.activeNipples)),r.a.createElement("div",{className:"animal-state-header"},e,!m()(t.add)&&void 0!==n.piglets&&"number"===typeof n.activeNipples&&n.piglets+ +t.add>n.activeNipples&&r.a.createElement(ze.a,{tooltipContent:a("activeNipplesExceeded",{current:n.piglets+ +t.add,activeNipples:n.activeNipples}),type:"warning"},r.a.createElement("i",{className:"fas fa-exclamation-triangle warning"})))}return null},this.getFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("taken"),allowFloat:!1})},this.addFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("added"),allowFloat:!1})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averagePigletWeightShort")})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;if(a){let e=this.state.separatedToMommy,r=0;for(let t of a)m()(t.get)||(e+=+t.get),m()(t.add)||(r+=+t.add);t.data=Object(V.C)(a,t=>{const a={};return m()(t.weight)&&(a.weight=n("required")),m()(t.get)&&m()(t.add)&&(a.get=n("required"),a.add=n("required")),!m()(t.get)&&+t.get<=0?a.get=n("errors.lessVal",{count:1}):t.animalState&&t.animalState.piglets<+t.get&&(a.get=n("errors.maxAnimalsValue",{amount:t.animalState.piglets})),!m()(t.add)&&+t.add<=0?a.add=n("errors.lessVal",{count:1}):!m()(t.add)&&e{let a=[];for(let n of e.data){const{animal:e,date:t,comment:r,get:i,add:s,weight:o}=n;e&&a.push({AnmID:e.AnmID,EvTime:+t,GrID:Object(E.getGrIDByAnimal)(e,+t,!1),Comment:r,Piglets:i,Weight:Object(be.i)(o,{fromUnit:fe.a.MEDIUM}),PigletsAdded:s})}return Object(He.a)(a).then(e=>{Object(He.c)(e),this.api.resetForm()}).catch(e=>{Object(He.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(Xe)})}initializeValues(){let e=U.a.getSavedData(Xe);if(e){for(let t of e.data.data)if(t.animal){let e=Ee.a.getPigBalanceForASowInCurrentCycle(t.animal),a=Ee.a.getActiveNipplesInCurrentCycle(t.animal);t.animalState={piglets:e,activeNipples:a}}return e.data.data}return new Array(Object(V.d)()).fill({})}render(){const{sows:e,initialData:t,separatedToMommy:a}=this.state,{t:n}=this.props,i=[Object(V.b)(e,this.onAnimalChange),{name:n("status"),key:"animalState",editable:!1,headerRenderer:e=>r.a.createElement(Ye,e),formatter:this.animalStateValueFormatter},{name:n("taken"),key:"get",filterRenderer:this.getFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Je({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("added"),key:"add",filterRenderer:this.addFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Je({type:"number",ref:t},e,{allowFloat:!1}))),headerRenderer:e=>r.a.createElement(Ze,Je({},e,{separatedToMommy:a}))},{name:n("averagePigletWeightShort"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Je({type:"number",ref:t},e)))},{name:n("date"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Je({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,onChange:this.onAnimalChange},V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:Xe,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,isSubmitting:o}))}}var $e=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(Qe),et=a("r8wt"),tt=a("uZGJ");function at(){return(at=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}if(e.hasOwnProperty("medicine")){const{medicine:n}=e;t=Object(V.t)(n,"medicine",t,a.medicine)}if(e.hasOwnProperty("dateTo")){const{dateTo:n}=e;t=Object(V.t)(n,"dateTo",t,a.dateTo,this.isEditableDateTo)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("weight")})},this.reasonFormatter=({column:{key:e},row:t})=>{const{graftingReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{graftingReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.isEditableDateTo=({medicine:e})=>{const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e);return!!a&&(a.WData.Type===et.b.FORAGE||a.WData.Type===et.b.DOSATRON)},this.medicineFormatter=({column:{key:e},row:t})=>{const{medicines:a}=this.props;let n=t[e],r=a.find(e=>e.WordID===n);return r?r.WData.Name:null},this.medicineFilter=({value:e,onChange:t})=>{const{medicines:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.WData.Name,value:e.WordID})),onChange:t,placeholder:n("medicine")})},this.onMedicineChange=e=>{const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e.medicine);return a&&a.WData.Type!==et.b.FORAGE&&a.WData.Type!==et.b.DOSATRON&&(e.dateTo=null),e},this.validate=e=>{const t={},{data:a}=e,{t:n,medicines:r}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};if(m()(e.weight)&&(t.weight=n("required")),e.reason||(t.reason=n("required")),e.medicine){let a=r.find(t=>t.WordID===e.medicine);!a||a.WData.Type!==et.b.FORAGE&&a.WData.Type!==et.b.DOSATRON||e.dateTo||(t.dateTo=n("required"))}else t.medicine=n("required");return t},[],!0)),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];const{medicines:a}=this.props;for(let n of e.data){const{animal:e,date:r,comment:i,medicine:s,dateTo:o,reason:l,weight:c}=n;let m=a.find(e=>e.WordID===s);e&&t.push({AnmID:e.AnmID,EvTime:+r,GrID:Object(E.getGrIDByAnimal)(e,+r,!1),Comment:i,Medicine:s,Reason:l,Weight:Object(be.i)(+c,{fromUnit:fe.a.MEDIUM}),TreatmentType:m.WData.Type,StartTime:+r,EndTime:+o||void 0,AnmCnt:e.AnmCnt})}return Object(tt.a)(t).then(e=>{Object(tt.c)(e),this.api.resetForm()}).catch(e=>{Object(tt.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(nt)})}render(){const{animals:e,initialData:t}=this.state,{graftingReasons:a,medicines:n,t:i}=this.props,s=[Object(V.b)(e),{name:i("weight"),key:"weight",filterRenderer:this.weightFilter,formatter:this.weightFormatter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,at({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)})))},{name:i("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,at({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},{name:i("medicine"),key:"medicine",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,at({},e,{options:n.map(e=>({name:e.WData.Name,value:e.WordID})),ref:t}))),formatter:this.medicineFormatter,filterRenderer:this.medicineFilter,onChange:this.onMedicineChange},{name:i("dateDateFrom"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,at({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j},{name:i("to"),key:"dateTo",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,at({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isEditableDateTo},V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:i,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:s,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:nt,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:i,initialFilters:{date:I()(),dateTo:I()()},isSubmitting:o,getApi:this.getApi}))}}var it=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,medicines:e.dictionary.medicine,graftingReasons:e.dictionary.graftingReason.WData[e.language.lang.lang]}})))(rt),st=(a("DV4J"),a("Nkcp"));function ot(){return(ot=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("medicine")){const{medicine:n}=e;t=Object(V.t)(n,"medicine",t,a.medicine)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}if(e.hasOwnProperty("dateTo")){const{dateTo:n}=e;t=Object(V.t)(n,"dateTo",t,a.dateTo,this.isEditableDateTo)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.medicine||(t.medicine=n("required")),e.reason||(t.reason=n("required")),e.dateTo||(t.dateTo=n("required")),t},[],!0)),void 0===t.data&&delete t.data,t},this.medicineFormatter=({column:{key:e},row:t})=>{const{medicines:a}=this.props;let n=t[e],r=a.find(e=>e.WordID===n);return r?r.WData.Name:null},this.reasonFormatter=({column:{key:e},row:t})=>{const{graftingReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.medicineFilter=({value:e,onChange:t})=>{const{medicines:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.WData.Name,value:e.WordID})),onChange:t,placeholder:n("medicine")})},this.reasonFilter=({value:e,onChange:t})=>{const{graftingReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,medicine:i,dateTo:s,reason:o}=a;if(e){let a=s.startOf("day").diff(n.clone().startOf("day"),"days")+1,l=[];for(let e=0;e{Object(st.c)(e),this.api.resetForm()}).catch(e=>{Object(st.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(lt)})}render(){const{animals:e,initialData:t}=this.state,{medicines:a,graftingReasons:n,t:i}=this.props,s=[Object(V.b)(e),{name:i("medicine"),key:"medicine",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,ot({},e,{options:a.map(e=>({name:e.WData.Name,value:e.WordID})),ref:t}))),formatter:this.medicineFormatter,filterRenderer:this.medicineFilter},{name:i("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,ot({},e,{options:n.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},{name:i("dateFrom"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ot({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j},{name:i("dateTo"),key:"dateTo",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ot({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j},V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:i,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:s,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:lt,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:i,getApi:this.getApi,isSubmitting:o}))}}var mt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,medicines:e.dictionary.medicine,graftingReasons:e.dictionary.graftingReason.WData[e.language.lang.lang]}})))(ct),ut=a("T891");function ht(){return(ht=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("piglets")){const{piglets:n}=e;t=Object(V.t)(n,"piglets",t,a.piglets)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averagePigletWeight")})},this.pigletsFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("pigletsAmount"),allowFloat:!1})},this.reasonFormatter=({column:{key:e},row:t})=>{const{fallReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{fallReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};if(m()(e.weight)&&(t.weight=n("required")),m()(e.piglets))t.piglets=n("required");else if(+e.piglets<=0)t.piglets=n("errors.noLessOrEq0");else if(e.animal&&e.date){let a=Ee.a.getPigBalanceForASow(e.animal,+e.date);a{let t=[];for(let a of e.data){const{animal:e,piglets:n,date:r,comment:i,weight:s,reason:o}=a;e&&t.push({AnmID:e.AnmID,EvTime:+r,GrID:Object(E.getGrIDByAnimal)(e,+r,!1),Comment:i,Piglets:n,Weight:Object(be.i)(s,{fromUnit:fe.a.MEDIUM}),Reason:o,PlcmntID:Array.isArray(e.PlcmntID)?e.PlcmntID[0].PlcmntID:e.PlcmntID})}return Object(ut.a)(t).then(e=>{Object(ut.c)(e),this.api.resetForm()}).catch(e=>{Object(ut.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(dt)})}render(){const{sows:e,initialData:t}=this.state,{fallReasons:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("pigletsAmount"),key:"piglets",filterRenderer:this.pigletsFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ht({type:"number",ref:t},e,{allowFloat:!1})))},{name:n("averagePigletWeight"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ht({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},{name:n("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,ht({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:dt,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var bt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,fallReasons:e.dictionary.fallReasons.WData[e.language.lang.lang]}})))(pt);a("EYNM");class ft extends n.Component{constructor(...e){super(...e),this.onClickStep=e=>{const{farm:t}=this.props;switch(e){case 1:this.props.history.push("/".concat(t,"/eventChooser"));break;case 2:this.props.history.push("/".concat(t,"/eventChooser/locationChooser/transfer"));break;case 3:this.props.onThirdStepClick();break;default:return}}}render(){const{activeStep:e,t:t,hasFeeding:a}=this.props;return r.a.createElement(Se.a,{activeStep:e,onClickStep:this.onClickStep},r.a.createElement(Re.a,{label:t("events.stepper.selectEventType")}),r.a.createElement(Re.a,{label:t("events.stepper.chooseLocation")}),r.a.createElement(Re.a,{label:t("events.stepper.insertEventData")}),r.a.createElement(Re.a,{label:t("events.stepper.feedingParameters"),disabled:!a}))}}ft.propTypes={activeStep:O.a.number.isRequired,onThirdStepClick:O.a.func.isRequired,hasFeeding:O.a.bool},ft.defaultProps={hasFeeding:!0};var gt=Object(j.d)(Object(C.a)(),l.o,Object(o.connect)((function(e){return{farm:e.location.farm}})))(ft),Et=a("2wEF"),vt=a("kCmh"),Ot=a("zDJl");a("/051");class yt extends n.Component{render(){const{row:{stand:e,animalInStand:t},t:a}=this.props;return r.a.createElement("div",{className:"transfer-stand"},r.a.createElement(ze.a,{tooltipContent:e.BoxesName},r.a.createElement("div",null,e.BoxesName)),t&&r.a.createElement(ze.a,{tooltipContent:a("standOccupied",{animalNumber:t.AnmNo1})},r.a.createElement("i",{className:"fas fa-exclamation-circle"})))}}var Dt=Object(C.a)()(yt),wt=a("15cA"),jt=a("9PNC");function Ct(e,t){let a=M.a.getAllAnimalsByPlcmntID(e,{joinEvents:!1})[0],n=A.a.getTreeByLocationID(e);return a?{AnmID:a.AnmID,transferTo:n.chamber.CID,DevIDsNewPlcmnt:Ft(n.chamber.CID),DevIDsOldPlcmnt:Ft(e),GrID:Object(E.getGrIDByAnimal)(a,t,!1)}:null}function Ft(e){return vt.a.getDevicesInPlcmntID(e,{showDevicesInChildren:!1}).map(e=>({DevID:e.DevID,GwID:e.GatewayID}))}function It(e,t,a){const{showBoxes:n,match:{params:{locationID:r}}}=t;let i=[];for(let s of e.data){const{animal:e,date:t,comment:a,stand:o,amount:l,newGrpNumber:c,curve:m,day:u,doseCorrection:h,plannedBirth:d,inseminationDay:p}=s;if(e){let s={AnmID:e.AnmID,EvTime:+t,GrID:Object(E.getGrIDByAnimal)(e,+t,!1),Comment:a,transferTo:n?o.BID:r,amount:l||1,stand:n,animalInStand:n?Ct(o.BID,+t):null,DevIDsNewPlcmnt:Ft(n?o.BID:r),DevIDsOldPlcmnt:Ft(Array.isArray(e.PlcmntID)?e.PlcmntID[0].PlcmntID:e.PlcmntID),newAnmNo1:c,clearFeeding:!0};if(m){let e=Object(wt.m)({curve:m,curveDay:u,repetitionDate:+d||+p,doseCorrection:h},Ot.d.DISPENSER_NRF);s.feeding={curveNumber:e.curveNr,curveStart:e.startTime,doseCorrection:e.percentCorrection}}i.push(s)}}return Object(jt.a)(i).then(e=>{Object(jt.c)(e),a.resetForm(),t.onSubmit()}).catch(e=>{Object(jt.b)(e)})}function At(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 St(e){for(var t=1;t{let t=Object.keys(e).filter(t=>e[t]);return e.animalInStand?2!==t.length:1!==t.length},this.onFiltersChange=(e,t,a)=>{if(e.hasOwnProperty("animal")){const{animal:n}=e,{animal:r}=a;if(!h()(n,r))if(n){let e=n.AnmList.filter(e=>!n.Rmvd.includes(e)).map(e=>M.a.getAnimalById(e,{joinEvents:!1})).filter(e=>e);e.sort((e,t)=>e.AnmNo1&&e.AnmNo1.localeCompare(t.AnmNo1)),t=t.map(t=>{let a=e.shift();return{stand:t.stand,animal:a||null,animalInStand:t.animalInStand}})}else t=t.map(e=>St({},e,{animal:null}))}if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date,this.checkIfOnlyStand)}return t=Object(V.v)(e,t,a.operator,this.checkIfOnlyStand),t=Object(V.s)(e,t,a.comment,this.checkIfOnlyStand)},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.standFormatter=e=>r.a.createElement(Dt,e),this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.animalInStand&&e.animal&&e.animalInStand.AnmID===e.animal.AnmID&&(t.animal=n("errors.alreadyInLocation")),t},["stand","device","animalInStand"])),void 0===t.data&&delete t.data,t},this.submit=(e,t)=>{if(!this.props.hasFeeding)return It(e,St({},this.props,{showBoxes:!0}),this.api);{let t=e.data.map(e=>{if(e.animal){return St({},e,{dispenser:vt.a.getDevicesInPlcmntID(e.stand.BID).filter(e=>[Ot.d.DISPENSER,Ot.d.DISPENSER_NRF].includes(e.DevType))[0]})}return null});t=t.filter(e=>!!e),this.props.onSubmit({data:t})}},this.resetForm=e=>{e(),this.setState({initialData:this.getInitialData()})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:this.getInitialData()})}getInitialData(){const{placement:e,initialData:t}=this.props;let a=t;if(a){let t=e.Boxes.map(e=>({stand:e,animalInStand:M.a.getAllAnimalsByPlcmntID(e.BID,{joinEvents:!1})[0]}));a.data=t.map(e=>{let t=a.data.find(t=>t.stand.BID===e.stand.BID);return t?St({},t,{animalInStand:e.animalInStand}):e})}else{let t=U.a.getSavedData(this.formName);if(t){a=t.data;let n=e.Boxes.map(e=>({stand:e,animalInStand:M.a.getAllAnimalsByPlcmntID(e.BID,{joinEvents:!1})[0]}));a.data=n.map(e=>{let t=a.data.find(t=>t.stand.BID===e.stand.BID);return t?St({},t,{animalInStand:e.animalInStand}):e})}else a={data:e.Boxes.map(e=>({stand:e,animalInStand:M.a.getAllAnimalsByPlcmntID(e.BID,{joinEvents:!1})[0]}))}}return a}render(){const{animals:e,initialData:t}=this.state,{t:a,hasFeeding:n}=this.props,i=[{name:a("standing"),key:"stand",editable:!1,formatter:this.standFormatter,noClearing:!0},Object(V.b)(e),V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:t,enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:s,handleReset:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:s,columns:i,onFiltersChange:this.onFiltersChange,disableAddingNewRow:!0,onDataChange:this.onDataChange,formName:this.formName,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:o,hasNext:n,getApi:this.getApi,ignoreFields:["stand","device","animalInStand"],isSubmitting:l}))}}Nt.propTypes={placement:O.a.object.isRequired,onSubmit:O.a.func.isRequired,initialData:O.a.shape({data:O.a.array}),hasFeeding:O.a.bool};var Pt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})),l.o)(Nt);function kt(){return(kt=Object.assign||function(e){for(var t=1;tt=Object(V.u)(e,t,a),this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.animal&&(e.animal.AnmCnt>1&&m()(e.amount)&&(t.amount=n("required")),e.amount&&e.amount>e.animal.AnmCnt&&(t.amount=n("errors.maxAnimalsValue",{amount:e.animal.AnmCnt})),e.amount{if(!this.props.hasFeeding)return It(e,function(e){for(var t=1;te.animal?e:null);t=t.filter(e=>!!e),this.props.onSubmit({data:t})}},this.amountFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("animalCount"),allowFloat:!1})},this.newGrpNumberFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("newSubgroupNumber")})},this.isAmountEditable=({animal:e})=>!e||1!==e.AnmCnt,this.isNewGrpNumberEditable=e=>{const{animal:t,amount:a}=e;return this.isAmountEditable(e)&&t&&t.AnmCnt>a},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e,initialData:t}=this.props;let a=Object(V.l)(e),n=t;if(n){let e=Object(V.m)(this.formName);for(let t=n.data.length;tr.a.createElement(Oe.a,kt({type:"number",ref:t},e,{allowFloat:!1}))),editable:this.isAmountEditable},{name:a("newSubgroupNumber"),key:"newGrpNumber",filterRenderer:this.newGrpNumberFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,kt({type:"number",ref:t},e))),editable:this.isNewGrpNumberEditable},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:t,enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:s,handleReset:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:s,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:this.formName,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:o,hasNext:n,getApi:this.getApi,isSubmitting:l}))}}Tt.propTypes={placement:O.a.object.isRequired,onSubmit:O.a.func.isRequired,initialData:O.a.shape({data:O.a.array}),hasFeeding:O.a.bool};var Bt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})),l.o)(Tt),Vt=a("JELi"),Lt=a.n(Vt),Gt=a("mr+a"),Wt=a("6/k7");function Ut(){return(Ut=Object.assign||function(e){for(var t=1;t{if(e.hasOwnProperty("curve")){const{curve:n}=e;t=Object(V.t)(n,"curve",t,a.curve,this.isFieldEditable)}if(e.hasOwnProperty("day")){const{day:n}=e;t=Object(V.t)(n,"day",t,a.day,this.isCurveDayEditable)}if(e.hasOwnProperty("doseCorrection")){const{doseCorrection:n}=e;t=Object(V.t)(n,"doseCorrection",t,a.doseCorrection,this.isFieldEditable)}if(e.hasOwnProperty("plannedBirth")){const{plannedBirth:n}=e;t=Object(V.t)(n,"plannedBirth",t,a.plannedBirth,this.isPlannedBirthEditable)}if(e.hasOwnProperty("inseminationDay")){const{inseminationDay:n}=e;t=Object(V.t)(n,"inseminationDay",t,a.inseminationDay,this.isPlannedBirthEditable)}return t},this.standFormatter=({column:{key:e},row:t})=>t[e]?r.a.createElement(Be.a,{value:t[e].BoxesName}):null,this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props,{sectorType:r}=this.state;return a&&(t.data=Object(V.C)(a,e=>{const t={};return this.isFieldEditable(e)&&(e.curve?e.curve.SetData.Type===Wt.b.INDIVIDUAL?m()(e.day)&&(t.day=n("required")):r===J.a.DELIVERY?m()(e.plannedBirth)&&(t.plannedBirth=n("required")):r===J.a.SOWS&&m()(e.inseminationDay)&&(t.inseminationDay=n("required")):t.curve=n("required"),m()(e.doseCorrection)&&(t.doseCorrection=n("required"))),t},["stand","device","animalInStand"])),void 0===t.data&&delete t.data,t},this.curveFormatter=({column:{key:e},row:t})=>t[e]?t[e].SetData.Name:null,this.doseCorrectionFormatter=({column:{key:e},row:t})=>{let a=t[e];return m()(a)?null:a+"%"},this.curveFilter=({value:e,onChange:t})=>{const{curves:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.SetData.Name,value:e})),onChange:t,placeholder:n("feedingCurve")})},this.dayFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("curveDay")})},this.doseCorrectionFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(B.a,{value:e,options:[-25,-20,-15,-10,-5,0,5,10,15,20,25].map(e=>({name:e+"%",value:e})),onChange:t,placeholder:a("doseCorrection")})},this.submit=e=>It(e,this.props,this.api),this.isFieldEditable=({stand:e})=>{const{showBoxes:t,match:{params:{locationID:a}}}=this.props;let n=a;return t&&(n=e.BID),vt.a.getDevicesInPlcmntID(n,{showDevicesInChildren:!1}).filter(e=>e.DevType===Ot.d.DISPENSER||e.DevType===Ot.d.DISPENSER_NRF).length>0},this.resetForm=e=>{e(),this.setState({initialData:this.getInitialData(!1).initialData})},this.isCurveDayEditable=e=>this.isFieldEditable(e)&&e.curve&&e.curve.SetData.Type===Wt.b.INDIVIDUAL,this.isPlannedBirthEditable=e=>this.isFieldEditable(e)&&e.curve&&e.curve.SetData.Type!==Wt.b.INDIVIDUAL,this.getApi=e=>{this.api=e},this.customIsEmpty=e=>{},this.state=function(e){for(var t=1;t[Ot.d.DISPENSER,Ot.d.DISPENSER_NRF].includes(e.DevType));for(let t of a.data.slice(0)){const{dispenser:a,animal:o}=t;if(r?!!a:e.length>0){let e=A.a.getTreeByLocationID(Array.isArray(o.PlcmntID)?o.PlcmntID[0].PlcmntID:o.PlcmntID);if((e.sector?e.sector.SType:null)!==s){let e=null;if(s===J.a.MATING)t.day=1,e=Object(ve.getDefaultCurve)("Mating");else if(s===J.a.SOWS){let a=this.getInseminationTime(o);a&&(t.inseminationDay=I()(a.EvTime)),e=Object(ve.getDefaultCurve)("Sows")}else if(s===J.a.DELIVERY){let a=this.getPlannedParturitionTime(o);a&&(t.plannedBirth=I()(a)),e=Object(ve.getDefaultCurve)("Delivery")}else t.day=1,e=Object(ve.getDefaultCurve)("Other");t.curve=n.find(t=>t.SetID===e),o.feedParam&&(t.doseCorrection=o.feedParam.percentCorrection)}else if(o.feedParam)if(t.curve=n.find(e=>e.SetData.Index===o.feedParam.curveNr),t.doseCorrection=o.feedParam.percentCorrection,i.sector.SType===J.a.DELIVERY){let e=this.getPlannedParturitionTime(o);e&&(t.plannedBirth=I()(e))}else if(i.sector.SType===J.a.SOWS){let e=this.getInseminationTime(o);e&&(t.inseminationDay=I()(e.EvTime))}else o.feedParam.startTime&&(t.day=I()().startOf("day").diff(o.feedParam.startTime,"days")+1)}}}return{sectorType:s,initialData:{data:o}}}getInseminationTime(e){let t=Ee.a.getAllEvents4Animal(e.AnmID),a=Lt()(t,e=>e.EvCode===y.b.PARTURITION);return t=t.slice(a),Object(E.getFirstInseminationInCycle)(t)}getPlannedParturitionTime(e){let t=Ee.a.getAllEvents4Animal(e.AnmID),a=Lt()(t,e=>e.EvCode===y.b.PARTURITION);return t=t.slice(a),Object(E.getPlannedParturition)(t)}getDaysField(){const{t:e}=this.props,{sectorType:t}=this.state;return t===J.a.DELIVERY?[{name:e("curveDay"),key:"day",filterRenderer:this.dayFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ut({type:"number",ref:t},e))),editable:this.isCurveDayEditable},{name:e("plannedBirth"),key:"plannedBirth",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ut({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isPlannedBirthEditable}]:t===J.a.SOWS?[{name:e("curveDay"),key:"day",filterRenderer:this.dayFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ut({type:"number",ref:t},e))),editable:this.isCurveDayEditable},{name:e("insemination"),key:"inseminationDay",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ut({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isPlannedBirthEditable}]:[{name:e("curveDay"),key:"day",filterRenderer:this.dayFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ut({type:"number",ref:t},e))),editable:this.isFieldEditable}]}render(){const{initialData:e}=this.state,{curves:t,showBoxes:a,t:n}=this.props;let i=[];return a&&i.push({name:n("standing"),key:"stand",editable:!1,formatter:this.standFormatter}),i.push({name:n("animalNumber"),key:"animal",formatter:V.c,editable:!1},{name:n("feedingCurve"),key:"curve",editor:r.a.forwardRef((e,a)=>r.a.createElement(T.a,Ut({},e,{options:t.map(e=>({name:e.SetData.Name,value:e})),ref:a}))),formatter:this.curveFormatter,filterRenderer:this.curveFilter,editable:this.isFieldEditable},...this.getDaysField(),{name:n("doseCorrection"),key:"doseCorrection",filterRenderer:this.doseCorrectionFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Ut({},e,{options:[-25,-20,-15,-10,-5,0,5,10,15,20,25].map(e=>({name:e+"%",value:e})),ref:t}))),editable:this.isFieldEditable,formatter:this.doseCorrectionFormatter}),r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:e},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,ignoreFields:["stand","device","animalInStand"],initialFilters:{},disableAddingNewRow:!0,isSubmitting:o,getApi:this.getApi}))}}var Yt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e,t){let a=A.a.getTreeByLocationID(Object(S.j)(t.location));return a.sector.SType===J.a.MATING?{curves:Object(Gt.c)(e).filter(e=>e.SetData.Type===Wt.b.MATING&&Object(wt.f)(e)===Wt.a.BOTH||e.SetData.Type===Wt.b.INDIVIDUAL)}:a.sector.SType===J.a.SOWS?{curves:Object(Gt.c)(e).filter(e=>e.SetData.Type===Wt.b.MATING&&(Object(wt.f)(e)===Wt.a.BOTH||Object(wt.f)(e)===Wt.a.AFTER))}:a.sector.SType===J.a.DELIVERY?{curves:Object(Gt.c)(e).filter(e=>e.SetData.Type===Wt.b.PARTURITION||e.SetData.Type===Wt.b.INDIVIDUAL)}:{curves:Object(Gt.c)(e).filter(e=>e.SetData.Type===Wt.b.INDIVIDUAL)}})),l.o)(_t);class Ht extends r.a.Component{constructor(e){super(e),this.state={location:null,transferData:null,initialData:null,hasFeeding:!1},this.onSubmitTransferData=e=>{this.setState({transferData:e})},this.onThirdStepClick=()=>{this.setState({transferData:null,initialData:this.state.transferData})},this.onSubmitSuccess=()=>{const{farm:e}=this.props;this.props.history.push({pathname:"/".concat(e,"/eventChooser/locationChooser/transfer"),state:{ignoreModal:!0}})};const{match:{params:{locationID:t}}}=this.props;let a=A.a.getLocationByID(t);a&&!a.CID&&(a=null),this.state.location=a,this.state.hasFeeding=this.locationHasFeeding()}locationHasFeeding(){const{match:{params:{locationID:e}}}=this.props;return vt.a.getDevicesInPlcmntID(e).filter(e=>[Ot.d.DISPENSER,Ot.d.DISPENSER_NRF].includes(e.DevType)).length>0}render(){const{location:e,transferData:t,initialData:a,hasFeeding:n}=this.state;if(!e)return r.a.createElement(Et.a,null);const{t:i}=this.props;return r.a.createElement("div",{className:"transfer"},r.a.createElement(gt,{activeStep:t?4:3,onThirdStepClick:this.onThirdStepClick,hasFeeding:n}),r.a.createElement("h5",null,i("location"),": ",Object(S.k)(e)),!t&&r.a.createElement(r.a.Fragment,null,e.Boxes&&r.a.createElement(Pt,{placement:e,onSubmit:n?this.onSubmitTransferData:this.onSubmitSuccess,initialData:a,hasFeeding:n}),!e.Boxes&&r.a.createElement(Bt,{placement:e,onSubmit:n?this.onSubmitTransferData:this.onSubmitSuccess,initialData:a,hasFeeding:n})),t&&r.a.createElement(Yt,{transferData:t,showBoxes:!!e.Boxes,location:e,onSubmit:this.onSubmitSuccess}))}}var Kt=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(Ht),Zt=a("ptb0");function Jt(){return(Jt=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}if(e.hasOwnProperty("amount")){const{amount:n}=e;t=Object(V.t)(n,"amount",t,a.amount,this.isAmountEditable)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("avgPieceWeight")})},this.amountFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("animalCount"),allowFloat:!1})},this.reasonFormatter=({column:{key:e},row:t})=>{const{fallReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{fallReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.validate=e=>{console.log("validate",e);const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.weight)&&(t.weight=n("required")),e.reason||(t.reason=n("required")),e.animal&&1!==e.animal.AnmCnt&&m()(e.amount)&&(t.amount=n("required")),t})),void 0===t.data&&delete t.data,t},this.isAmountEditable=({animal:e})=>!e||1!==e.AnmCnt,this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,reason:i,weight:s,amount:o}=a;if(e){let a=vt.a.getDevicesInPlcmntID(e.PlcmntID,{showDevicesInChildren:!1});t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r,amount:o||1,devices:a.map(e=>({DevID:e.DevID,GrID:e.GatewayID})),clearFeeding:!0,Weight:Object(be.i)(s,{fromUnit:fe.a.MEDIUM}),Reason:i})}}return Object(Zt.a)(t).then(e=>{Object(Zt.c)(e),this.api.resetForm()}).catch(e=>{Object(Zt.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(Xt)})}render(){const{animals:e,initialData:t}=this.state,{fallReasons:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("animalCount"),key:"amount",filterRenderer:this.amountFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Jt({type:"number",ref:t},e,{allowFloat:!1}))),editable:this.isAmountEditable},{name:n("avgPieceWeight"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Jt({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},{name:n("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Jt({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:Xt,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var $t=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,fallReasons:e.dictionary.fallReasons.WData[e.language.lang.lang]}})))(Qt),ea=a("SZ9y");function ta(){return(ta=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("client")){const{client:n}=e;t=Object(V.t)(n,"client",t,a.client)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price)}if(e.hasOwnProperty("hcw")){const{hcw:n}=e;t=Object(V.t)(n,"hcw",t,a.hcw)}if(e.hasOwnProperty("amount")){const{amount:n}=e;t=Object(V.t)(n,"amount",t,a.amount,this.isAmountEditable)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("avgPieceWeight")})},this.clientFormatter=({column:{key:e},row:t})=>{const{clients:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.clientFilter=({value:e,onChange:t})=>{const{clients:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("buyer")})},this.priceFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("priceFor",{unit:Object(be.l)("weight",fe.a.MEDIUM)})})},this.hcwFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("hotWeight")})},this.amountFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("animalCount"),allowFloat:!1})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.weight)&&(t.weight=n("required")),e.client||(t.client=n("required")),m()(e.price)&&(t.price=n("required")),m()(e.hcw)&&(t.hcw=n("required")),e.animal&&1!==e.animal.AnmCnt&&m()(e.amount)&&(t.amount=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r,weight:i,client:s,hcw:o,price:l,amount:c}=a;if(e){let a=vt.a.getDevicesInPlcmntID(e.PlcmntID,{showDevicesInChildren:!1});t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r,amount:c||1,devices:a.map(e=>({DevID:e.DevID,GwID:e.GatewayID})),clearFeeding:!0,Weight:Object(be.i)(i,{fromUnit:fe.a.MEDIUM}),Buyer:s,Price:l,Hcw:o})}}return Object(ea.a)(t).then(e=>{Object(ea.c)(e),this.api.resetForm()}).catch(e=>{Object(ea.b)(e)})},this.isAmountEditable=({animal:e})=>!e||1!==e.AnmCnt,this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(aa)})}render(){const{animals:e,initialData:t}=this.state,{clients:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("animalCount"),key:"amount",filterRenderer:this.amountFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ta({type:"number",ref:t},e,{allowFloat:!1}))),editable:this.isAmountEditable},{name:n("avgPieceWeight"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ta({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},{name:n("buyer"),key:"client",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,ta({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.clientFormatter,filterRenderer:this.clientFilter},{name:n("priceFor",{unit:Object(be.l)("weight",fe.a.MEDIUM)}),key:"price",filterRenderer:this.priceFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ta({type:"number",ref:t},e)))},{name:n("hotWeight"),key:"hcw",filterRenderer:this.hcwFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ta({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:aa,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,isSubmitting:o}))}}var ra=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,medicines:e.dictionary.medicine,clients:e.dictionary.clients.WData[e.language.lang.lang]}})))(na),ia=a("4Rw3");function sa(){return(sa=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.reasonFormatter=({column:{key:e},row:t})=>{const{selectionReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{selectionReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return e.reason||(t.reason=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=(e,t)=>{let a=[];for(let n of e.data){const{animal:e,date:t,comment:r,reason:i}=n;e&&a.push({AnmID:e.AnmID,EvTime:+t,GrID:Object(E.getGrIDByAnimal)(e,+t,!1),Comment:r,Reason:i,PlcmntID:Array.isArray(e.PlcmntID)?e.PlcmntID[0].PlcmntID:e.PlcmntID})}return Object(ia.a)(a).then(e=>{Object(ia.b)(e),this.api.resetForm()}).catch(e=>{Object(ea.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(oa)})}render(){const{animals:e,initialData:t}=this.state,{selectionReasons:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,sa({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:oa,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var ca=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,selectionReasons:e.dictionary.selectionReason.WData[e.language.lang.lang]}})))(la),ma=a("M64W"),ua=a("v8cL"),ha=a("iaPM"),da=a("+AL/"),pa=a("STTX"),ba=a("B6Rp"),fa=a("1+PD");class ga extends n.Component{constructor(...e){super(...e),this.onClickStep=e=>{const{farm:t}=this.props;switch(e){case 1:this.props.history.push("/".concat(t,"/eventChooser"));break;case 2:this.props.history.push("/".concat(t,"/eventChooser/animalKind/insertion"));break;case 3:const{match:{params:{locationID:e,animalKind:a}}}=this.props;let n=A.a.getLocationByID(e);this.props.history.push("/".concat(t,"/eventChooser/locationChooser/insertion?sectors=").concat(!n.Boxes,"&redirect=/").concat(a));break;default:return}}}render(){const{activeStep:e,t:t}=this.props;return r.a.createElement(Se.a,{activeStep:e,onClickStep:this.onClickStep},r.a.createElement(Re.a,{label:t("events.stepper.selectEventType")}),r.a.createElement(Re.a,{label:t("events.stepper.selectAnimalType")}),r.a.createElement(Re.a,{label:t("events.stepper.chooseLocation")}),r.a.createElement(Re.a,{label:t("events.stepper.insertAnimalData")}))}}ga.propTypes={activeStep:O.a.number.isRequired};var Ea=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})),l.o)(ga);class va extends r.a.Component{constructor(...e){super(...e),this.onClick=e=>{const{farm:t,match:{params:{nextEvent:a}}}=this.props;let n=[p.a.PORKER,p.a.PIGLET].includes(e);this.props.history.push("/".concat(t,"/eventChooser/locationChooser/").concat(a,"?sectors=").concat(n,"&redirect=/").concat(e))}}render(){return r.a.createElement("div",null,r.a.createElement(Ea,{activeStep:2}),r.a.createElement(D.a,{value:null,options:[{label:this.props.t("events.animalKindChooser.renovationsow"),value:p.a.RENOVATION_SOW,svgPath:pa.a},{label:this.props.t("events.animalKindChooser.sow"),value:p.a.SOW,svgPath:ma.a},{label:this.props.t("events.animalKindChooser.porker"),value:-p.a.PORKER,svgPath:ba.a},{label:this.props.t("events.animalKindChooser.porkerGroup"),value:p.a.PORKER,svgPath:ha.a},{label:this.props.t("events.animalKindChooser.boar"),value:p.a.BOAR,svgPath:ua.a},{label:this.props.t("events.animalKindChooser.piglet"),value:-p.a.PIGLET,svgPath:fa.a},{label:this.props.t("events.animalKindChooser.pigletGroup"),value:p.a.PIGLET,svgPath:da.a}],onChange:e=>this.onClick(e),showLabels:!0,itemsInRow:4}))}}va.propTypes={onNextStep:O.a.func};var Oa=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(va),ya=a("7e/R"),Da=a("LldF");const wa={};function ja(e){if(wa[e])return wa[e];let t=vt.a.getDevicesInPlcmntID(e,{showDevicesInChildren:!1}).map(e=>({DevID:e.DevID,GwID:e.GatewayID}));return wa[e]=t,t}function Ca(e,t,a){const n=[],{match:{params:{locationID:r,animalKind:i}},farm:s}=a;for(let o of e.data){const{AnmNo1:e,AnmNo2:t,RFID:a,weight:s,provider:l,price:c,race:m,cycles:u,lastSeparation:h,birthDate:d,group:p,box:b,occupied:f}=o;if(e&&!f){let o={AnmNo2:t,RFID:a?Object(ya.a)(a+""):void 0,Weight:s?Object(be.i)(+s,{fromUnit:fe.a.MEDIUM}):void 0,Provider:l,Price:c?+c:void 0,Race:m,DtaBrthTime:d?+d:void 0},f={AnmNo1:e,AnmCnt:1,PlcmntID:b?b.BID:r,AnimalKind:+i,Cycle:u?+u:void 0,LastSeparation:h?+h.startOf("day"):void 0,additionalData:o,devices:ja(b?b.BID:r)};p&&("object"===typeof p?f.addToGroup=p.AnmGrp:f.newGroupNumber=p),n.push(f)}}return Object(Da.a)(n).then(e=>{Object(Da.c)(e),t.resetForm(),a.history.push("/".concat(s,"/eventChooser/animalKind/insertion"))}).catch(e=>{Object(Da.b)(e)})}function Fa(){return(Fa=Object.assign||function(e){for(var t=1;t{if(e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1,this.insertDataPredicate)}if(e.hasOwnProperty("AnmNo2")){const{AnmNo2:n}=e;t=Object(V.t)(n,"AnmNo2",t,a.AnmNo2,this.insertDataPredicate)}if(e.hasOwnProperty("RFID")){const{RFID:n}=e;t=Object(V.t)(n,"RFID",t,a.RFID,this.insertDataPredicate)}if(e.hasOwnProperty("birthDate")){const{birthDate:n}=e;t=Object(V.t)(n,"birthDate",t,a.birthDate,this.insertDataPredicate)}if(e.hasOwnProperty("location")){const{location:n}=e;t=Object(V.t)(n,"location",t,a.location,this.insertDataPredicate)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight,this.insertDataPredicate)}if(e.hasOwnProperty("provider")){const{provider:n}=e;t=Object(V.t)(n,"provider",t,a.provider,this.insertDataPredicate)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price,this.insertDataPredicate)}if(e.hasOwnProperty("race")){const{race:n}=e;t=Object(V.t)(n,"race",t,a.race,this.insertDataPredicate)}if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date,this.insertDataPredicate)}return t},this.validate=e=>{const t={},{data:a}=e,{t:n,farm:r}=this.props;let i=!1;return a&&(t.data=a.map((e,t)=>{const s={};if(!e.occupied&&!Object(V.w)(e,["box"])){if(e.AnmNo1?M.a.checkIfAnimalExistOnFarm(e.AnmNo1,r)?s.AnmNo1=n("errors.exist"):a.find((a,n)=>a.AnmNo1===e.AnmNo1&&t!==n)&&(s.AnmNo1=n("errors.duplicate")):s.AnmNo1=n("required"),e.RFID){const i=Object(ya.a)(e.RFID+"");M.a.checkIfHaveRFID(i,r)?s.RFID=n("errors.exist"):a.find((a,n)=>a.RFID===e.RFID&&t!==n)&&(s.RFID=n("errors.duplicate"))}e.date||(s.date=n("required"))}return Ae()(s)||(i=!0),s})),i||delete t.data,t},this.anmNo1Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Nr zwierz\u0119cia"}),this.anmNo2Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Alter. nr zwierz."}),this.RFIDFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"RFID"}),this.weightFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Waga"}),this.priceFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Cena"}),this.supplierFilter=({value:e,onChange:t})=>{const{suppliers:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Dostawca"})},this.raceFilter=({value:e,onChange:t})=>{const{races:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Rasa"})},this.supplierFormatter=({column:{key:e},row:t})=>{const{suppliers:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.raceFormatter=({column:{key:e},row:t})=>{const{races:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.boxFormatter=({column:{key:e},row:t})=>{let a=t[e];return a?r.a.createElement(Be.a,{value:a.BoxesName}):null},this.submit=e=>Ca(e,this.api,this.props),this.resetForm=e=>{e(),this.setState({initialData:this.getInitialData(!1).initialData})},this.isRowEditable=({occupied:e})=>!e,this.insertDataPredicate=e=>this.isRowEditable(e)&&!Object(V.w)(e,["box"]),this.getApi=e=>{this.api=e},this.customIsEmpty=e=>!!e.occupied||Object(V.w)(e,["box"]),this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){this.setState(Aa({},this.getInitialData()))}getInitialData(e=!0){const{match:{params:{locationID:t}}}=this.props;let a=A.a.getLocationByID(t);if(a.Boxes){let e=U.a.getSavedData(this.formName);return{initialData:a.Boxes.map(t=>{let a=M.a.getAllAnimalsByPlcmntID(t.BID,{joinEvents:!1})[0];if(a)return{box:t,occupied:!0,AnmNo1:a.AnmNo1,AnmNo2:a.AnmNo2,RFID:a.RFID,birthDate:a.DtaBrthTime,weight:a.Weight,price:a.Price,race:a.Race,provider:a.SupplierID};{let a=e?e.data.data.find(e=>e.box.BID===t.BID):{};return Aa({box:t},a||{})}}),hasBoxes:!0}}return e?{initialData:Object(V.m)(this.formName),hasBoxes:!1}:{initialData:new Array(Object(V.d)()).fill({}),hasBoxes:!1}}render(){const{initialData:e,hasBoxes:t}=this.state,{suppliers:a,races:n,t:i}=this.props,s=[];return t&&s.push({name:i("standing"),key:"box",editable:!1,formatter:this.boxFormatter}),s.push({name:i("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo1Filter,editable:this.isRowEditable},{name:i("alternativeAnimalNumberShort"),key:"AnmNo2",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo2Filter,editable:this.isRowEditable},{name:i("rfid"),key:"RFID",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"number"}))),filterRenderer:this.RFIDFilter,editable:this.isRowEditable},{name:i("birthDate"),key:"birthDate",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isRowEditable},{name:i("weight"),key:"weight",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"number",unit:Object(be.l)("weight",fe.a.MEDIUM)}))),filterRenderer:this.weightFilter,editable:this.isRowEditable,formatter:this.weightFormatter},{name:i("supplier"),key:"provider",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Fa({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.supplierFormatter,filterRenderer:this.supplierFilter,editable:this.isRowEditable},{name:i("price"),key:"price",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"number"}))),filterRenderer:this.priceFilter,editable:this.isRowEditable},{name:i("race"),key:"race",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Fa({},e,{options:n.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.raceFormatter,filterRenderer:this.raceFilter,editable:this.isRowEditable},{name:Z.a.t("date"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Fa({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isRowEditable}),r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e},enableReinitialize:!0},({values:e,errors:a,setFieldValue:n,handleSubmit:i,handleReset:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:i,columns:s,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:n,errors:a,resetForm:this.resetForm,formikReset:o,ignoreFields:t?["box","occupied"]:[],isSubmitting:l,disableAddingNewRow:t,getApi:this.getApi,customIsEmpty:this.customIsEmpty}))}}var Na=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,races:e.dictionary.race.WData[e.language.lang.lang],suppliers:e.dictionary.suppliers.WData[e.language.lang.lang]}})),l.o)(Ra),Pa=a("mwIZ"),ka=a.n(Pa);class xa extends n.Component{render(){const{column:{name:e},t:t}=this.props;return r.a.createElement("div",null,e,r.a.createElement(ze.a,{tooltipContent:t("cycleAmountInfo")},r.a.createElement("i",{className:"fas fa-question-circle"})))}}var Ma=Object(C.a)()(xa),Ta=a("PrG/");function Ba(){return(Ba=Object.assign||function(e){for(var t=1;t{if(e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1,this.insertDataPredicate)}if(e.hasOwnProperty("AnmNo2")){const{AnmNo2:n}=e;t=Object(V.t)(n,"AnmNo2",t,a.AnmNo2,this.insertDataPredicate)}if(e.hasOwnProperty("RFID")){const{RFID:n}=e;t=Object(V.t)(n,"RFID",t,a.RFID,this.insertDataPredicate)}if(e.hasOwnProperty("birthDate")){const{birthDate:n}=e;t=Object(V.t)(n,"birthDate",t,a.birthDate,this.insertDataPredicate)}if(e.hasOwnProperty("location")){const{location:n}=e;t=Object(V.t)(n,"location",t,a.location,this.insertDataPredicate)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight,this.insertDataPredicate)}if(e.hasOwnProperty("provider")){const{provider:n}=e;t=Object(V.t)(n,"provider",t,a.provider,this.insertDataPredicate)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price,this.insertDataPredicate)}if(e.hasOwnProperty("race")){const{race:n}=e;t=Object(V.t)(n,"race",t,a.race,this.insertDataPredicate)}if(e.hasOwnProperty("cycles")){const{cycles:n}=e;t=Object(V.t)(n,"cycles",t,a.cycles,this.insertDataPredicate)}if(e.hasOwnProperty("lastSeparation")){const{lastSeparation:n}=e;t=Object(V.t)(n,"lastSeparation",t,a.lastSeparation,this.insertDataPredicate)}if(e.hasOwnProperty("date")){const{date:n}=e;t=Object(V.t)(n,"date",t,a.date,this.insertDataPredicate)}return t},this.validate=e=>{const t={},{data:a}=e,{t:n,farm:r}=this.props;let i=!1;return a&&(t.data=a.map((e,t)=>{const s={};if(!e.occupied&&!Object(V.w)(e,["box"])&&(e.AnmNo1?M.a.checkIfAnimalExistOnFarm(e.AnmNo1,r)?s.AnmNo1=n("errors.exist"):a.find((a,n)=>a.AnmNo1===e.AnmNo1&&t!==n)&&(s.AnmNo1=n("errors.duplicate")):s.AnmNo1=n("required"),m()(e.cycles)?s.cycles=n("required"):+e.cycles<=0&&(s.cycles=n("errors.noLess",{number:1})),e.lastSeparation||(s.lastSeparation=n("required")),e.date||(s.date=n("required")),e.RFID)){const i=Object(ya.a)(e.RFID+"");M.a.checkIfHaveRFID(i,r)?s.RFID=n("errors.exist"):a.find((a,n)=>a.RFID===e.RFID&&t!==n)&&(s.RFID=n("errors.duplicate"))}return Ae()(s)||(i=!0),s})),i||delete t.data,t},this.anmNo1Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Nr zwierz\u0119cia"}),this.anmNo2Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Alter. nr zwierz."}),this.RFIDFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"RFID",allowFloat:!1}),this.weightFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Waga"}),this.priceFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Cena"}),this.supplierFilter=({value:e,onChange:t})=>{const{suppliers:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Dostawca"})},this.raceFilter=({value:e,onChange:t})=>{const{races:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Rasa"})},this.cyclesFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Liczba cykli",allowFloat:!1}),this.supplierFormatter=({column:{key:e},row:t})=>{const{suppliers:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.raceFormatter=({column:{key:e},row:t})=>{const{races:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.submit=(e,t)=>Ca(e,this.api,this.props),this.resetForm=e=>{e(),this.setState({initialData:this.getInitialData(!1).initialData})},this.boxFormatter=({column:{key:e},row:t})=>{let a=t[e];return a?r.a.createElement(Be.a,{value:a.BoxesName}):null},this.isRowEditable=({occupied:e})=>!e,this.insertDataPredicate=e=>this.isRowEditable(e)&&!Object(V.w)(e,["box"]),this.getApi=e=>{this.api=e},this.customIsEmpty=e=>!!e.occupied||Object(V.w)(e,["box"])}componentDidMount(){this.setState(La({},this.getInitialData()))}getInitialData(e=!0){const{match:{params:{locationID:t}}}=this.props;let a=A.a.getLocationByID(t);if(a.Boxes){let e=U.a.getSavedData(this.formName);return{initialData:a.Boxes.map(t=>{let a=M.a.getAllAnimalsByPlcmntID(t.BID,{joinEvents:!0})[0];if(console.log("ANIMAL ON SECTOR =>",a),a){let e=this.getCycleData(a);return{box:t,occupied:!0,AnmNo1:a.AnmNo1,AnmNo2:a.AnmNo2,RFID:a.RFID,birthDate:a.DtaBrthTime,cycles:e.cycles,lastSeparation:e.lastSeparation,weight:a.Weight,provider:a.SupplierID,price:a.Price,race:a.Race}}{let a=e?e.data.data.find(e=>e.box.BID===t.BID):{};return La({box:t},a||{})}}),hasBoxes:!0}}return e?{initialData:Object(V.m)(this.formName),hasBoxes:!1}:{initialData:new Array(Object(V.d)()).fill({}),hasBoxes:!1}}getCycleData(e){let t,a;const n=ka()(e,"events",[]).find(e=>e.EvCode===Ta.SOW_CYCLES);return n&&(t=ka()(n,"EvData.Cycles"),a=ka()(n,"EvData.LastSeparation")),{cycles:t,lastSeparation:a}}render(){const{initialData:e,hasBoxes:t}=this.state,{suppliers:a,races:n,t:i}=this.props,s=[];return t&&s.push({name:i("standing"),key:"box",editable:!1,formatter:this.boxFormatter}),s.push({name:i("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo1Filter,editable:this.isRowEditable},{name:i("alternativeAnimalNumberShort"),key:"AnmNo2",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo2Filter,editable:this.isRowEditable},{name:i("rfid"),key:"RFID",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"number",allowFloat:!1}))),filterRenderer:this.RFIDFilter,editable:this.isRowEditable},{name:i("birthDate"),key:"birthDate",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isRowEditable},{name:i("cycleAmount"),key:"cycles",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"number",allowFloat:!1}))),filterRenderer:this.cyclesFilter,headerRenderer:e=>r.a.createElement(Ma,e),editable:this.isRowEditable},{name:i("lastSeparationDateShort"),key:"lastSeparation",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isRowEditable},{name:i("weight"),key:"weight",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"number"}))),filterRenderer:this.weightFilter,editable:this.isRowEditable},{name:i("supplier"),key:"provider",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Ba({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.supplierFormatter,filterRenderer:this.supplierFilter,editable:this.isRowEditable},{name:i("price"),key:"price",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"number"}))),filterRenderer:this.priceFilter,editable:this.isRowEditable},{name:i("race"),key:"race",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Ba({},e,{options:n.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.raceFormatter,filterRenderer:this.raceFilter,editable:this.isRowEditable},{name:Z.a.t("date"),key:"date",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ba({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j,editable:this.isRowEditable}),r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e},enableReinitialize:!0},({values:e,errors:a,setFieldValue:n,handleSubmit:i,handleReset:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:i,columns:s,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:n,errors:a,resetForm:this.resetForm,formikReset:o,disableAddingNewRow:t,getApi:this.getApi,ignoreFields:t?["box","animalInStand"]:[],isSubmitting:l,customIsEmpty:this.customIsEmpty}))}}var Ua=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,races:e.dictionary.race.WData[e.language.lang.lang],suppliers:e.dictionary.suppliers.WData[e.language.lang.lang]}})),l.o)(Wa);function qa(){return(qa=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1)}if(e.hasOwnProperty("RFID")){const{RFID:n}=e;t=Object(V.t)(n,"RFID",t,a.RFID)}if(e.hasOwnProperty("birthDate")){const{birthDate:n}=e;t=Object(V.t)(n,"birthDate",t,a.birthDate)}if(e.hasOwnProperty("group")){const{group:n}=e;t=Object(V.t)(n,"group",t,a.group)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("provider")){const{provider:n}=e;t=Object(V.t)(n,"provider",t,a.provider)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price)}if(e.hasOwnProperty("race")){const{race:n}=e;t=Object(V.t)(n,"race",t,a.race)}return t},this.validate=e=>{const t={},{data:a}=e,{t:n,farm:r}=this.props,{hasGroup:i}=this.state;let s=!1;return a&&(t.data=a.map((e,t)=>{const o={};if(!Object(V.w)(e)){if(i||e.group||(o.group=n("required")),e.AnmNo1?M.a.checkIfAnimalExistOnFarm(e.AnmNo1,r)?o.AnmNo1=n("errors.exist"):a.find((a,n)=>a.AnmNo1===e.AnmNo1&&t!==n)&&(o.AnmNo1=n("errors.duplicate")):o.AnmNo1=n("required"),e.RFID){const i=Object(ya.a)(e.RFID+"");M.a.checkIfHaveRFID(i,r)?o.RFID=n("errors.exist"):a.find((a,n)=>a.RFID===e.RFID&&t!==n)&&(o.RFID=n("errors.duplicate"))}else o.RFID=n("required");e.date||(o.date=n("required"))}return Ae()(o)||(s=!0),o})),s||delete t.data,t},this.anmNo1Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Nr zwierz\u0119cia"}),this.groupFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Numer grupy"}),this.RFIDFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"RFID"}),this.weightFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Waga"}),this.priceFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Cena"}),this.supplierFilter=({value:e,onChange:t})=>{const{suppliers:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Dostawca"})},this.raceFilter=({value:e,onChange:t})=>{const{races:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Rasa"})},this.supplierFormatter=({column:{key:e},row:t})=>{const{suppliers:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.raceFormatter=({column:{key:e},row:t})=>{const{races:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.groupFormatter=({column:{key:e},row:t})=>{let a=t[e];return a?"object"===typeof a?a.GrNo1:a:null},this.submit=(e,t)=>{let a=e.data.slice(0);return this.state.hasGroup&&(a=a.map(e=>function(e){for(var t=1;t{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}getGroup(){const{match:{params:{locationID:e}}}=this.props;let t=M.a.getAllAnimalsByPlcmntID(e,{joinEvents:!1});for(let a of t){let e=xe.a.getGroupWithAnimal(a.AnmID,a.FarmID)[0];if(e)return e}return null}componentDidMount(){let e=xe.a.getAllGroups(this.props.farm);this.setState({initialData:Object(V.m)(this.formName),groups:e})}render(){const{initialData:e,hasGroup:t}=this.state,{suppliers:a,races:n,t:i}=this.props;let s=[];return t||s.push({name:i("groupNumber"),key:"group",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"text"}))),formatter:this.groupFormatter,editable:!1,filterRenderer:this.groupFilter,insertEvenIfNotEditable:!0}),s.push({name:i("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo1Filter},{name:i("rfid"),key:"RFID",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"number"}))),filterRenderer:this.RFIDFilter},{name:i("weight"),key:"weight",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"number",unit:Object(be.l)("weight",fe.a.MEDIUM)}))),filterRenderer:this.weightFilter,formatter:this.weightFormatter},{name:i("birthDate"),key:"birthDate",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j},{name:i("supplier"),key:"provider",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,qa({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.supplierFormatter,filterRenderer:this.supplierFilter},{name:i("events.insertionEvent.invoice"),key:"price",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,qa({},e,{ref:t,type:"number"}))),filterRenderer:this.priceFilter},{name:i("race"),key:"race",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,qa({},e,{options:n.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.raceFormatter,filterRenderer:this.raceFilter},V.h),r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e,currentGroup:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:i,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:s,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:a,errors:t,resetForm:this.resetForm,resetFormik:i,getApi:this.getApi,isSubmitting:o}))}}var Ha=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,races:e.dictionary.race.WData[e.language.lang.lang],suppliers:e.dictionary.suppliers.WData[e.language.lang.lang]}})),l.o)(Ya);function Ka(){return(Ka=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1)}if(e.hasOwnProperty("birthDate")){const{birthDate:n}=e;t=Object(V.t)(n,"birthDate",t,a.birthDate)}if(e.hasOwnProperty("amount")){const{amount:n}=e;t=Object(V.t)(n,"amount",t,a.amount)}if(e.hasOwnProperty("group")){const{group:n}=e;t=Object(V.t)(n,"group",t,a.group,this.isGroupEditable)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("provider")){const{provider:n}=e;t=Object(V.t)(n,"provider",t,a.provider)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price)}if(e.hasOwnProperty("race")){const{race:n}=e;t=Object(V.t)(n,"race",t,a.race)}return t},this.validate=e=>{const t={},{data:a}=e,{t:n,farm:r}=this.props;let i=!1;return a&&(t.data=a.map((e,t)=>{const s={};return Object(V.w)(e,["chamber"])||(e.AnmNo1?M.a.checkIfAnimalExistOnFarm(e.AnmNo1,r)?s.AnmNo1=n("errors.exist"):a.find((a,n)=>a.AnmNo1===e.AnmNo1&&t!==n)&&(s.AnmNo1=n("errors.duplicate")):s.AnmNo1=n("required"),e.group||(s.group=n("required")),m()(e.amount)&&(s.amount=n("required")),e.date||(s.date=n("required"))),Ae()(s)||(i=!0),s})),i||delete t.data,t},this.anmNo1Filter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Nr zwierz\u0119cia"}),this.amountFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:"Ilo\u015b\u0107",allowFloat:!1}),this.groupFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Numer grupy"}),this.weightFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"\u015ar. waga szt."}),this.priceFilter=({value:e,onChange:t})=>r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:"Cena"}),this.supplierFilter=({value:e,onChange:t})=>{const{suppliers:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Dostawca"})},this.raceFilter=({value:e,onChange:t})=>{const{races:a}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:"Rasa"})},this.supplierFormatter=({column:{key:e},row:t})=>{const{suppliers:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.raceFormatter=({column:{key:e},row:t})=>{const{races:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.groupFormatter=({column:{key:e},row:t})=>{let a=t[e];return a?"object"===typeof a?a.GrNo1:a:null},this.locationFormatter=({column:{key:e},row:t})=>t[e]?Object(S.k)(t[e]):null,this.isGroupEditable=({group:e})=>!(e&&"object"===typeof e),this.submit=(e,{resetForm:t})=>{const a=[],{match:{params:{animalKind:n}},farm:r}=this.props;for(let i of e.data){const{chamber:e,AnmNo1:t,amount:r,weight:s,provider:o,price:l,race:c,birthDate:m,group:u}=i;if(t){let i=vt.a.getDevicesInPlcmntID(e.CID,{showDevicesInChildren:!1}).map(e=>({DevID:e.DevID,GwID:e.GatewayID})),h={Weight:s?Object(be.i)(+s,{fromUnit:fe.a.MEDIUM}):void 0,Provider:o,Price:l?+l:void 0,Race:c,DtaBrthTime:m?+m:void 0},d={AnmNo1:t,AnmCnt:+r,PlcmntID:e.CID,AnimalKind:+n,additionalData:h,devices:i};"object"===typeof u?d.addToGroup=u.AnmGrp:d.newGroupNumber=u,a.push(d)}}return Object(Da.a)(a).then(e=>{Object(Da.c)(e),this.props.history.push("/".concat(r,"/eventChooser/animalKind/insertion"))}).catch(e=>{Object(Da.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{match:{params:{locationID:e}}}=this.props;let t=A.a.getLocationByID(e).Chambers.map(e=>{let t=M.a.getAllAnimalsByPlcmntID(e.CID,{joinEvents:!1}),a=null;for(let n of t){let e=xe.a.getGroupWithAnimal(n.AnmID,n.FarmID)[0];if(e){a=e;break}}return{chamber:e,group:a}});this.setState({initialData:t})}render(){const{initialData:e}=this.state,{suppliers:t,races:a,t:n}=this.props,i=[{name:n("pigPen"),key:"chamber",formatter:this.locationFormatter,editable:!1},{name:n("groupNumber"),key:"group",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"text"}))),formatter:this.groupFormatter,groupFilter:this.groupFilter,editable:this.isGroupEditable},{name:n("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo1Filter},{name:n("amount"),key:"amount",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"number",allowFloat:!1}))),filterRenderer:this.amountFilter},{name:n("birthDate"),key:"birthDate",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"date"}))),formatter:V.i,filterRenderer:V.j},{name:n("averageWeightShort"),key:"weight",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"number",unit:Object(be.l)("weight",fe.a.MEDIUM)}))),filterRenderer:this.weightFilter,formatter:this.weightFormatter},{name:n("supplier"),key:"provider",editor:r.a.forwardRef((e,a)=>r.a.createElement(T.a,Ka({},e,{options:t.map(e=>({name:e.Value,value:e.ID})),ref:a}))),formatter:this.supplierFormatter,filterRenderer:this.supplierFilter},{name:n("events.insertionEvent.invoice"),key:"price",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,Ka({},e,{ref:t,type:"number"}))),filterRenderer:this.priceFilter},{name:n("race"),key:"race",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,Ka({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.raceFormatter,filterRenderer:this.raceFilter},V.h];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,formName:this.formName,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,disableAddingNewRow:!0,isSubmitting:o}))}}var Ja=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,races:e.dictionary.race.WData[e.language.lang.lang],suppliers:e.dictionary.suppliers.WData[e.language.lang.lang]}})),l.o)(Za);class Xa extends r.a.Component{render(){const{match:{params:{animalKind:e}}}=this.props;return r.a.createElement("div",null,r.a.createElement(Ea,{activeStep:4}),(+e===p.a.RENOVATION_SOW||+e===p.a.BOAR)&&r.a.createElement(Na,null),+e===p.a.SOW&&r.a.createElement(Ua,null),(+e===-p.a.PORKER||+e===-p.a.PIGLET)&&r.a.createElement(Ha,null),(+e===p.a.PORKER||+e===p.a.PIGLET)&&r.a.createElement(Ja,null))}}var Qa=Object(j.d)(Object(C.a)())(Xa),$a=a("qx5e"),en=a("s506"),tn=a("5tUy");function an(){return(an=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({animals:Object(V.k)(Object(V.l)(a,n))})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averageWeight")})},this.reasonFormatter=({column:{key:e},row:t})=>{const{weightingReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{weightingReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null,this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.weight)&&(t.weight=n("required")),e.reason||(t.reason=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=(e,{resetForm:t})=>{let a=[];for(let n of e.data){const{animal:e,date:t,comment:r,weight:i,reason:s}=n;e&&a.push({AnmID:e.AnmID,EvTime:+t,GrID:Object(E.getGrIDByAnimal)(e,+t,!1),Comment:r,Weight:Object(be.i)(i,{fromUnit:fe.a.MEDIUM}),Reason:s,Plcmnt:Array.isArray(e.PlcmntID)?e.PlcmntID[0].PlcmntID:e.PlcmntID,AnmCnt:e.AnmCnt})}return Object(tn.a)(a).then(e=>{Object(tn.c)(e),this.api.resetForm()}).catch(e=>{Object(tn.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.l)(e);this.setState({animals:Object(V.k)(t),initialData:Object(V.m)(nn)})}render(){const{animals:e,initialData:t}=this.state,{weightingReasons:a,t:n}=this.props,i=[Object(V.b)(e),{name:n("averageWeight"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,an({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.weightFormatter},{name:n("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,an({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:nn,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,getApi:this.getApi,isSubmitting:o}))}}var sn=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,weightingReasons:e.dictionary.weighting.WData[e.language.lang.lang]}})))(rn),on=a("VVij");function ln(){return(ln=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("activeNipples")){const{activeNipples:n}=e;t=Object(V.t)(n,"activeNipples",t,a.activeNipples)}return t},this.onDataChange=(e,t)=>{console.log(e,t);const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.activeNipplesFilterRenderer=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("activeNipples"),allowFloat:!1})},this.validate=e=>{const t={},{data:a}=e,{t:n}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};return m()(e.activeNipples)&&(t.activeNipples=n("required")),t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,activeNipples:n,date:r,comment:i}=a;e&&t.push({AnmID:e.AnmID,Nipples:n,EvTime:+r,GrID:Object(E.getGrIDByAnimal)(e,+r,!1),Comment:i})}return Object(on.a)(t).then(e=>{Object(on.c)(e),this.api.resetForm()}).catch(e=>{Object(on.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.q)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(cn)})}render(){const{sows:e,initialData:t}=this.state,{t:a}=this.props,n=[Object(V.b)(e),{name:a("activeNipples"),key:"activeNipples",filterRenderer:this.activeNipplesFilterRenderer,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,ln({type:"number",ref:t},e,{allowFloat:!1})))},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:i,handleReset:s,isValid:o,isSubmitting:l})=>r.a.createElement(Y,{handleSubmit:i,columns:n,onFiltersChange:this.onFiltersChange,isValid:o,onDataChange:this.onDataChange,formName:cn,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:l,getApi:this.getApi}))}}var un=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(mn),hn=a("wxLp");function dn(){return(dn=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("AnmNo1")){const{AnmNo1:n}=e;t=Object(V.t)(n,"AnmNo1",t,a.AnmNo1)}if(e.hasOwnProperty("AnmNo2")){const{AnmNo2:n}=e;t=Object(V.t)(n,"AnmNo2",t,a.AnmNo2)}if(e.hasOwnProperty("RFID")){const{RFID:n}=e;t=Object(V.t)(n,"RFID",t,a.RFID)}if(e.hasOwnProperty("group")){const{group:n}=e;t=Object(V.t)(n,"group",t,a.group)}if(e.hasOwnProperty("location")){const{location:n}=e;t=Object(V.t)(n,"location",t,a.location)}if(e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("price")){const{price:n}=e;t=Object(V.t)(n,"price",t,a.price)}return t},this.validate=e=>{const t={},{data:a}=e,{t:n,farm:r}=this.props;if(a){let e=!1;return t.data=a.map((t,i)=>{let s={};if(!Object(V.w)(t)){if(t.operator||(s.operator=Z.a.t("required")),t.AnmNo1?M.a.checkIfAnimalExistOnFarm(t.AnmNo1,r)?s.AnmNo1=n("errors.exist"):a.find((e,a)=>e.AnmNo1===t.AnmNo1&&i!==a)&&(s.AnmNo1=n("errors.duplicate")):s.AnmNo1=n("required"),t.RFID){const e=Object(ya.a)(t.RFID+"");M.a.checkIfHaveRFID(e,r)?s.RFID=n("errors.exist"):a.find((e,a)=>e.RFID===t.RFID&&i!==a)&&(s.RFID=n("errors.duplicate"))}t.group||(s.group=n("required")),t.location||(s.location=n("required")),m()(t.weight)&&(s.weight=n("required")),s=function(e){for(var t=1;t{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("animalNumberShort")})},this.anmNo2Filter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("alternativeAnimalNumberShort")})},this.RFIDFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("rfid")})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("weight")})},this.priceFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"text",placeholder:a("price")})},this.groupFilter=({value:e,onChange:t})=>{const{porkers:a}=this.state,{t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a,onChange:t,placeholder:n("groupNumber")})},this.locationFilter=({value:e,onChange:t})=>{const{buildings:a}=this.state,{t:n}=this.props;return r.a.createElement(Me.a,{options:a,onChange:t,value:e,placeholder:n("location")})},this.locationFormatter=({column:{key:e},row:t})=>t[e]?Object(S.k)(t[e].object):null,this.submit=e=>{let t={};for(let n of e.data){const{AnmNo1:e,group:a,date:r,comment:i,RFID:s,AnmNo2:o,weight:l,price:c,location:m}=n;if(console.log(n),e){let n=t[a.AnmID+"_"+ +r]||{AnmID:a.AnmID,EvTime:+r,GrID:Object(E.getGrIDByAnimal)(a,+r,!1),Comment:i,newAnimals:[]};n.newAnimals.push({RFID:s,AnmNo1:e,AnmNo2:o,Weight:Object(be.i)(l,{fromUnit:fe.a.MEDIUM}),Price:c,PlcmntID:Object(S.j)(m.object)}),t[a.AnmID+"_"+ +r]=n}}let a=[];for(let n in t)a.push(t[n]);return Object(hn.a)(a).then(e=>{Object(hn.c)(e),this.api.resetForm()}).catch(e=>{Object(hn.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e},this.weightFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null}componentDidMount(){const{farm:e}=this.props;let t=Object(V.p)(e);this.setState({porkers:Object(V.k)(t),initialData:Object(V.m)(fn)})}render(){const{initialData:e,porkers:t}=this.state,{farm:a,t:n}=this.props,i=[{name:n("animalNumberShort"),key:"AnmNo1",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,dn({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo1Filter},{name:n("alternativeAnimalNumberShort"),key:"AnmNo2",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,dn({},e,{ref:t,type:"text"}))),filterRenderer:this.anmNo2Filter},{name:n("rfid"),key:"RFID",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,dn({},e,{ref:t,type:"number"}))),filterRenderer:this.RFIDFilter},{name:n("takeFromGroupShort"),key:"group",editor:r.a.forwardRef((e,a)=>r.a.createElement(T.a,dn({},e,{options:t,ref:a}))),formatter:V.c,filterRenderer:this.groupFilter},{name:n("location"),key:"location",editor:r.a.forwardRef((e,t)=>r.a.createElement(ke.a,dn({},e,{ref:t,farm:a,showStands:!1}))),filterRenderer:this.locationFilter,formatter:this.locationFormatter},{name:n("weight"),key:"weight",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,dn({},e,{ref:t,type:"number",unit:Object(be.l)("weight",fe.a.MEDIUM)}))),filterRenderer:this.weightFilter,formatter:this.weightFormatter},{name:n("price"),key:"price",editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,dn({},e,{ref:t,type:"number"}))),filterRenderer:this.priceFilter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:e},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:i,onFiltersChange:this.onFiltersChange,formName:fn,values:e,onChange:a,errors:t,resetForm:this.resetForm,isSubmitting:o,formikReset:s,getApi:this.getApi}))}}var En=Object(j.d)(Object(o.connect)((function(e){return{farm:e.location.farm}})),Object(C.a)())(gn),vn=a("n90m");function On(){return(On=Object.assign||function(e){for(var t=1;t{if(t=Object(V.u)(e,t,a),e.hasOwnProperty("weight")){const{weight:n}=e;t=Object(V.t)(n,"weight",t,a.weight)}if(e.hasOwnProperty("reason")){const{reason:n}=e;t=Object(V.t)(n,"reason",t,a.reason)}if(e.hasOwnProperty("piglets")){const{piglets:n}=e;t=Object(V.t)(n,"piglets",t,a.piglets)}if(e.hasOwnProperty("medicine")){const{medicine:n}=e;t=Object(V.t)(n,"medicine",t,a.medicine)}if(e.hasOwnProperty("forageAmount")){const{forageAmount:n}=e;t=Object(V.t)(n,"forageAmount",t,a.forageAmount,this.isForageAmountEditable)}return t},this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.q)(a,n))})},this.reasonFormatter=({column:{key:e},row:t})=>{const{graftingReasons:a}=this.props;let n=t[e],r=a.find(e=>e.ID===n);return r?r.Value:null},this.reasonFilter=({value:e,onChange:t})=>{const{graftingReasons:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.Value,value:e.ID})),onChange:t,placeholder:n("reason")})},this.medicineFormatter=({column:{key:e},row:t})=>{const{medicines:a}=this.props;let n=t[e],r=a.find(e=>e.WordID===n);return r?r.WData.Name:null},this.forageFormatter=({column:{key:e},row:t})=>t[e]?t[e]+Object(be.l)("weight",fe.a.MEDIUM):null,this.medicineFilter=({value:e,onChange:t})=>{const{medicines:a,t:n}=this.props;return r.a.createElement(B.a,{value:e,options:a.map(e=>({name:e.WData.Name,value:e.WordID})),onChange:t,placeholder:n("medicine")})},this.weightFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("averagePigletWeight")})},this.pigletsFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("pigletsAmount"),allowFloat:!1})},this.forageAmountFilter=({value:e,onChange:t})=>{const{t:a}=this.props;return r.a.createElement(pe.a,{value:e,onChange:t,type:"number",placeholder:a("forageAmount")})},this.onMedicineChange=e=>{const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e.medicine);return a&&a.WData.Type!==et.b.FORAGE&&a.WData.Type!==et.b.DOSATRON&&(e.dateTo=null),e},this.isEditableDateTo=({medicine:e})=>{const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e);return!!a&&(a.WData.Type===et.b.FORAGE||a.WData.Type===et.b.DOSATRON)},this.validate=e=>{const t={},{data:a}=e,{t:n,medicines:r}=this.props;return a&&(t.data=Object(V.C)(a,e=>{const t={};if(m()(e.weight)&&(t.weight=n("required")),m()(e.piglets)&&(t.piglets=n("required")),e.reason||(t.reason=n("required")),e.medicine){let a=r.find(t=>t.WordID===e.medicine);a&&a.WData.Type===et.b.FORAGE&&m()(e.forageAmount)&&(t.forageAmount=n("required"))}else t.medicine=n("required");return t})),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];const{medicines:a}=this.props;for(let n of e.data){const{animal:e,date:r,comment:i,medicine:s,weight:o,piglets:l,forageAmount:c}=n;if(e){let n=a.find(e=>e.WordID===s);t.push({AnmID:e.AnmID,EvTime:+r,GrID:Object(E.getGrIDByAnimal)(e,+r,!1),Comment:i,Medicine:s,Weight:Object(be.i)(o,{fromUnit:fe.a.MEDIUM}),TreatmentType:n.WData.Type,AnmCnt:1,PiCnt:l,ForageAmount:n.WData.Type===et.b.FORAGE?c:void 0})}}return Object(vn.a)(t).then(e=>{Object(vn.c)(e),this.api.resetForm()}).catch(e=>{Object(vn.b)(e)})},this.isForageAmountEditable=({medicine:e})=>{if(e){const{medicines:t}=this.props;let a=t.find(t=>t.WordID===e);return a&&a.WData.Type===et.b.FORAGE}return!0},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.o)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(yn)})}render(){const{sows:e,initialData:t}=this.state,{graftingReasons:a,medicines:n,t:i}=this.props,s=[Object(V.b)(e),{name:i("averagePigletWeight"),key:"weight",filterRenderer:this.weightFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,On({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),formatter:this.forageFormatter},{name:i("pigletsAmount"),key:"piglets",filterRenderer:this.pigletsFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,On({type:"number",ref:t},e,{allowFloat:!1})))},{name:i("reason"),key:"reason",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,On({},e,{options:a.map(e=>({name:e.Value,value:e.ID})),ref:t}))),formatter:this.reasonFormatter,filterRenderer:this.reasonFilter},{name:i("medicine"),key:"medicine",editor:r.a.forwardRef((e,t)=>r.a.createElement(T.a,On({},e,{options:n.map(e=>({name:e.WData.Name,value:e.WordID})),ref:t}))),formatter:this.medicineFormatter,filterRenderer:this.medicineFilter,onChange:this.onMedicineChange},{name:i("forageAmount"),key:"forageAmount",filterRenderer:this.forageAmountFilter,editor:r.a.forwardRef((e,t)=>r.a.createElement(Oe.a,On({type:"number",ref:t},e,{unit:Object(be.l)("weight",fe.a.MEDIUM)}))),editable:this.isForageAmountEditable,formatter:this.forageFormatter},V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:a,handleSubmit:n,handleReset:i,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:n,columns:s,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:yn,values:e,onChange:a,errors:t,resetForm:this.resetForm,formikReset:i,getApi:this.getApi,isSubmitting:o}))}}var wn=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm,medicines:e.dictionary.medicine,graftingReasons:e.dictionary.graftingReason.WData[e.language.lang.lang]}})))(Dn),jn=a("UVNL");const Cn=R.a.HEAT;class Fn extends n.Component{constructor(...e){super(...e),this.state={sows:[],initialData:[]},this.onFiltersChange=(e,t,a)=>t=Object(V.u)(e,t,a),this.onDataChange=(e,t)=>{const{farm:a}=this.props;let n=[];for(let r of e)r.animal&&n.push(r.animal);t.animal&&!Object(V.e)(t.animal,e)&&this.api.tableInput.removeFilter("animal"),this.setState({sows:Object(V.k)(Object(V.r)(a,n))})},this.validate=e=>{const t={},{data:a}=e;return a&&(t.data=Object(V.C)(a,e=>({}))),void 0===t.data&&delete t.data,t},this.submit=e=>{let t=[];for(let a of e.data){const{animal:e,date:n,comment:r}=a;e&&t.push({AnmID:e.AnmID,EvTime:+n,GrID:Object(E.getGrIDByAnimal)(e,+n,!1),Comment:r})}return Object(jn.a)(t).then(e=>{Object(jn.c)(e),this.api.resetForm()}).catch(e=>{Object(jn.b)(e)})},this.resetForm=e=>{e(),this.setState({initialData:new Array(Object(V.d)()).fill({})})},this.getApi=e=>{this.api=e}}componentDidMount(){const{farm:e}=this.props;let t=Object(V.r)(e);this.setState({sows:Object(V.k)(t),initialData:Object(V.m)(Cn)})}render(){const{sows:e,initialData:t}=this.state,a=[Object(V.b)(e),V.h,V.x,V.f];return r.a.createElement(H.a,{onSubmit:this.submit,validate:this.validate,initialValues:{data:t},enableReinitialize:!0},({values:e,errors:t,setFieldValue:n,handleSubmit:i,handleReset:s,isSubmitting:o})=>r.a.createElement(Y,{handleSubmit:i,columns:a,onFiltersChange:this.onFiltersChange,onDataChange:this.onDataChange,formName:Cn,values:e,onChange:n,errors:t,resetForm:this.resetForm,formikReset:s,isSubmitting:o,getApi:this.getApi}))}}var In=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(Fn),An=a("ZRKa"),Sn=a("lijG"),Rn=a("dmgJ"),Nn=a("vzZS"),Pn=(a("uuRS"),a("cr+I")),kn=a.n(Pn),xn=a("3Z9Z"),Mn=a("JI6e"),Tn=a("RFJ0");class Bn extends n.Component{constructor(...e){super(...e),this.state={farmMap:An.a.getFarmMap(this.props.farm),level:0,chambers:A.a.getAllChambers(this.props.farm).map(e=>({name:M.a.getAnimalLocationsByPlcmntID(e.CID,{nameDeep:3})[0].name,value:e})),sectors:A.a.getAllSectorsForFarm(this.props.farm).map(e=>({name:M.a.getAnimalLocationsByPlcmntID(e.SID,{nameDeep:2})[0].name,value:e})),selectValue:null},this.goUp=()=>{this.setState(e=>({level:e.level+1}))},this.goDown=()=>{this.setState(e=>({level:e.level-1}))},this.onLocationClick=e=>{if(console.log(e),e.placement){const{location:{search:t},match:{params:{nextEvent:a}},farm:n}=this.props;let r=kn.a.parse(t);r.sectors="true"===r.sectors;let i="/".concat(n,"/eventChooser/").concat(a,"/").concat(e.placement.id);r.redirect&&(i+=r.redirect),(r.sectors&&e.placement.level===X.a.SECTOR||e.placement.level===X.a.CHAMBER)&&this.props.history.push(i)}},this.onChange=e=>{this.setState({selectValue:e})},this.onAcceptClick=()=>{const{selectValue:e}=this.state,{location:{search:t},match:{params:{nextEvent:a}},farm:n}=this.props;let r=kn.a.parse(t);r.sectors="true"===r.sectors;let i="/".concat(n,"/eventChooser/").concat(a,"/").concat(r.sectors?e.SID:e.CID);r.redirect&&(i+=r.redirect),this.props.history.push(i)}}hasManyLevels(){const{farmMap:e}=this.state;return Object.keys(e.SetData.Levels).length>1}getMinLevel(){const{farmMap:e}=this.state;let t=Object.keys(e.SetData.Levels).map(e=>+e);return Math.min(...t)}getMaxLevel(){const{farmMap:e}=this.state;let t=Object.keys(e.SetData.Levels).map(e=>+e);return Math.max(...t)}render(){const{farmMap:e,level:t,chambers:a,sectors:n,selectValue:i}=this.state,{t:s,match:{params:{nextEvent:o}},location:{search:l}}=this.props;let c=kn.a.parse(l);return c.sectors="true"===c.sectors,r.a.createElement("div",{className:"location-chooser"},"transfer"===o&&r.a.createElement(gt,{activeStep:2}),"insertion"===o&&r.a.createElement(Ea,{activeStep:3}),"separationToPigletHouse"===o&&r.a.createElement(Pe,{activeStep:2}),e&&r.a.createElement("div",{className:"farm-map-container"},r.a.createElement(Sn.a,{farmMap:Object(Rn.a)(e.SetData.Levels[t]),key:t,onElementClick:this.onLocationClick,showOnly:c.sectors?"sectors":null,calculateHeight:!1}),this.hasManyLevels()&&r.a.createElement(d.a,{fixed:!0,renderInPortal:!1},r.a.createElement(Nn.a,null,s("farms.tabs.mapTab.level")," ",t),r.a.createElement(b.a,{type:"button",icon:r.a.createElement("i",{className:"fas fa-arrow-up"}),disabled:t===this.getMaxLevel(),buttonColor:"info",buttonStyle:"round",onClick:this.goUp}),r.a.createElement(b.a,{type:"button",icon:r.a.createElement("i",{className:"fas fa-arrow-down"}),disabled:t===this.getMinLevel(),buttonColor:"info",buttonStyle:"round",onClick:this.goDown}))),!e&&r.a.createElement(r.a.Fragment,null,r.a.createElement(xn.a,{className:"justify-content-center"},r.a.createElement(Mn.a,{md:8},r.a.createElement(Tn.a,{label:c.sectors?s("newSettings.buildings.sector"):s("newSettings.buildings.chamber"),options:c.sectors?n:a,onChange:this.onChange,value:i}))),r.a.createElement(d.a,{fixed:!0,renderInPortal:!1},r.a.createElement(b.a,{icon:r.a.createElement("i",{className:"fas fa-check"}),disabled:!i,buttonColor:"success",buttonStyle:"round",onClick:this.onAcceptClick}))))}}var Vn,Ln=Object(j.d)(Object(C.a)(),Object(o.connect)((function(e){return{farm:e.location.farm}})))(Bn);let Gn=Object(o.connect)(e=>({farm:e.location.farm,animalKinds:e.language.langDynamic.animalKind}))(Vn=class extends r.a.Component{getTitle(){const{t:e,location:{pathname:t}}=this.props;let a=e("setEvent"),n=t.split("/");if(n[3]){let t=n[3];"locationChooser"!==t&&"animalKind"!==t||(t=n[4]),"insertion"===t&&n[5]?a+=" - "+e(t)+"(".concat(e("animalKind."+Math.abs(+n[5])),")"):a+=" - "+e(t)}return a}render(){return r.a.createElement("div",{className:"event-chooser"},r.a.createElement(i.a,{text:this.getTitle()}),r.a.createElement(s.a,{addPaddingForButtons:!0},r.a.createElement(x.a,null,r.a.createElement(l.g,null,r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/animalKind/:nextEvent"),render:e=>r.a.createElement(Oa,e)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/insertion/:locationID/:animalKind"),render:e=>r.a.createElement(Qa,e)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/insemination"),render:()=>r.a.createElement(ne,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/usg"),render:()=>r.a.createElement(le,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/noPregnancy"),render:()=>r.a.createElement(de,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/parturition"),render:()=>r.a.createElement(je,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/separationToPigletHouse/:locationID"),render:e=>r.a.createElement(qe,e)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/separationToMommy"),render:()=>r.a.createElement($e,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/grafting"),render:()=>r.a.createElement(it,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/scheduleOfTreatment"),render:()=>r.a.createElement(mt,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/fallPiglets"),render:()=>r.a.createElement(bt,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/transfer/:locationID"),render:e=>r.a.createElement(Kt,e)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/fall"),render:()=>r.a.createElement($t,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/sale"),render:()=>r.a.createElement(ra,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/selection"),render:()=>r.a.createElement(ca,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/weighting"),render:()=>r.a.createElement(sn,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/activeNipples"),render:()=>r.a.createElement(un,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/reclassify"),render:()=>r.a.createElement(En,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/pigletsTreatment"),render:()=>r.a.createElement(wn,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/heat"),render:()=>r.a.createElement(In,null)}),r.a.createElement(l.d,{path:"/".concat(this.props.farm,"/eventChooser/locationChooser/:nextEvent"),render:e=>r.a.createElement(Ln,e)}),r.a.createElement(l.d,{render:()=>r.a.createElement(k,null)})))))}})||Vn;t.default=Object(j.d)(l.o,Object($a.a)({roles:[en.c._BREEDING],showComponent:!0}),Object(C.a)())(Gn)},"q/KM":function(e,t,a){},tgc7:function(e,t,a){"use strict";var n=a("mwIZ"),r=a.n(n),i=a("q1tI"),s=a.n(i),o=a("17x9"),l=a.n(o),c=a("wQmL"),m=a("/MKj"),u=a("2dKy"),h=a("wd/R"),d=a.n(h),p=a("LCzB");function b(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 f(e){for(var t=1;t{const{fields:e}=this.state,{form:t,field:a}=this.props;if(e.startDate&&e.endDate&&"endDate"===a||"startDate"===a){let a=d()(r()(t,"".concat(Object.keys(t)[Object.keys(t).length-1],".values.multiValues"),[]).startDate),n=d()(r()(t,"".concat(Object.keys(t)[Object.keys(t).length-1],".values.multiValues"),[]).endDate);e.numberOfDays=n.diff(a,"days")+1}if(e.numberOfDays&&e.startDate&&"numberOfDays"===a||"startDate"===a){let a=d()(r()(t,"".concat(Object.keys(t)[Object.keys(t).length-1],".values.multiValues"),[]).startDate).clone().add(+r()(t,"".concat(Object.keys(t)[Object.keys(t).length-1],".values.multiValues"),[]).numberOfDays-1,"days");e.endDate=a.format("YYYY-MM-DD")}},this.onChange=e=>{const{field:t,form:a}=this.props,{fields:n}=this.state;n[t]=e,this.props.dispatch(Object(c.a)("".concat(Object.keys(a)[Object.keys(a).length-1]),"multiValues",n))};const{form:t,type:a}=this.props;this.state={fields:r()(t,"".concat(Object.keys(t)[Object.keys(t).length-1],".values.multiValues"),[])};const{fields:n}=this.state;["date","datetime-local"].includes(a)&&(n.startDate="date"===a?d()().format("YYYY-MM-DD"):d()().format("YYYY-MM-DDTHH:mm")),this.props.dispatch(Object(c.a)("".concat(Object.keys(t)[Object.keys(t).length-1]),"multiValues",n))}onChangeAll(){const{form:e}=this.props,{fields:t}=this.state;this.calculateDate();for(let a=0;a({form:e.form}))(E)).propTypes={unit:l.a.string,field:l.a.string.isRequired},E.defaultProps={unit:null},t.a=Object(p.a)()(E)},uuRS:function(e,t,a){},vC5F:function(e,t,a){"use strict";a.d(t,"a",(function(){return i}));var n=a("q1tI"),r=a.n(n);class i extends r.a.Component{render(){const{value:e}=this.props;return r.a.createElement(r.a.Fragment,null,r.a.createElement("img",{src:e,alt:"cardType"}))}}}}]); //# sourceMappingURL=main~1336c15f.01e4ab9e.chunk.js.map