import{j as e,ah as Yu,ai as Cu,aj as hu,al as m,ak as v,ag as d6,bi as C6,T as S,B as x,aa as z,i as mu,I as ju,b0 as h6,an as p6,ao as _u,b4 as xu,ap as Fu,a3 as y6,d as bu,b2 as v6,b3 as Gu}from"./mui-vendor-CkIVaoQP.js";import{r as C}from"./react-vendor-CmFgShSM.js";import{g2 as g6,L as N,j as R,h as w,A as ru,u as yu,v as uu,N as Su,c as au,G as y,S as I,M as F,fF as A6,g3 as _6,b as P,C as M,fH as u6,O as eu,r as e6,fl as x6,p as k,X as b,W as Ku}from"./index-Cr86_nOs.js";import{a as lu,u as tu,f as Uu}from"./redux-vendor-B7uoacJt.js";import{R as pu}from"./ResponsiveTable-Dua7tTwQ.js";import{I as F6,f as b6}from"./toBase64-CmPKyXM7.js";import{a as Xu,s as j6}from"./slaughter-get-provinces-BB3SydOH.js";import{C as S6}from"./CarPelak-Ddy5J5I5.js";import{d as f6}from"./Tune-m0V6JHJm.js";import{d as E6}from"./EditOutlined-C6DCII3T.js";import{d as B6}from"./DeleteOutlineOutlined-O-wCemP7.js";import{S as Qu}from"./ShowImage-Dm1ejH7Y.js";import{R as w6,a as T6}from"./index.esm-Bu7XMDZU.js";import{C as Ju}from"./ChechClearanceCode-DnhDxgMz.js";import{d as I6}from"./Delete-CTUmuli-.js";function L6(u){return new D6(u)}class D6{constructor(l){this.type="lazy",this.__isYupSchema__=!0,this.__inputType=void 0,this.__outputType=void 0,this._resolve=(a,n={})=>{let o=this.builder(a,n);if(!g6(o))throw new TypeError("lazy() functions must return a valid schema");return o.resolve(n)},this.builder=l}resolve(l){return this._resolve(l.value,l)}cast(l,a){return this._resolve(l,a).cast(l,a)}validate(l,a,n){return this._resolve(l,a).validate(l,a,n)}validateSync(l,a){return this._resolve(l,a).validateSync(l,a)}validateAt(l,a,n){return this._resolve(a,n).validateAt(l,a,n)}validateSyncAt(l,a,n){return this._resolve(a,n).validateSyncAt(l,a,n)}describe(){return null}isValid(l,a){return this._resolve(l,a).isValid(l,a)}isValidSync(l,a){return this._resolve(l,a).isValidSync(l,a)}}const r6=lu("SLAUGHTER_DELETE_INVENTORY_FREE_BAR_SERVICE",async(u,{dispatch:l})=>{l(N());try{const{data:a,status:n}=await R.delete("kill_house_free_bar/0/?key="+u);return l(w()),{data:a,status:n}}catch(a){return l(w()),{error:a.response.data.result}}}),fu=lu("SLAUGHTER_EDIT_FREE_SALE_SERVICE",async(u,{dispatch:l})=>{l(N());try{const{data:a,status:n}=await R.put("kill_house_free_bar/0/",u);return l(w()),{data:a,status:n}}catch(a){return l(w()),{error:a.response.data.result}}}),W6=lu("SLAUGHTER_SUBMIT_FREE_SALE_SERVICE",async(u,{dispatch:l})=>{l(N());try{const{data:a,status:n}=await R.post("kill_house_free_bar/",u);return l(w()),{data:a,status:n}}catch(a){return l(w()),{error:a.response.data.result}}}),$6=au().shape({poultry_name:F().required("نام مرغدار الزامی است"),poultry_mobile:F().required("شماره موبایل مرغدار الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:F().required("استان الزامی است"),city:F().required("شهر الزامی است"),clearance_code:F().required("کد قرنطینه الزامی است"),quantity:P().required("تعداد الزامی است").min(1,"تعداد باید بیشتر از 0 باشد"),live_weight:P().required("وزن الزامی است").min(.01,"وزن باید بیشتر از 0 باشد"),bar_image:F().required("عکس بار الزامی است")}),R6=au().shape({poultry_name:F().required("نام مرغدار الزامی است"),poultry_mobile:F().required("شماره موبایل مرغدار الزامی است").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),province:F().required("استان الزامی است"),city:F().required("شهر الزامی است"),clearance_code:F().required("کد قرنطینه الزامی است"),bar_image:F().required("عکس بار الزامی است"),number_of_carcasses:P().required("حجم لاشه الزامی است").min(1,"حجم لاشه باید بیشتر از 0 باشد"),weight_of_carcasses:P().required("وزن لاشه الزامی است").min(.01,"وزن باید بیشتر از 0 باشد")}),N6=au().shape({driverName:F(),driverMobile:F().min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد")}),a6=({formik:u,cities:l,provinces:a,isEdit:n,item:o})=>e.jsxs(e.Fragment,{children:[e.jsx(m,{fullWidth:!0,disablePortal:!0,id:"province",options:a.map(i=>({id:i.name,label:i.name})),value:u.values.province?{id:u.values.province,label:u.values.province}:null,onChange:(i,s)=>{u.setFieldValue("province",s?s.id:""),u.setFieldValue("city","")},renderInput:i=>e.jsx(v,{...i,label:"استان را انتخاب کنید",error:u.touched.province&&!!u.errors.province,helperText:u.touched.province&&u.errors.province})}),n&&e.jsxs(S,{variant:"caption",color:"error",children:["استان: ",u.values.province]}),e.jsx(m,{fullWidth:!0,disablePortal:!0,id:"city",disabled:!u.values.province,options:l.map(i=>({id:i.name,label:i.name})),value:u.values.city?{id:u.values.city,label:u.values.city}:null,onChange:(i,s)=>{u.setFieldValue("city",s?s.id:"")},renderInput:i=>e.jsx(v,{...i,label:"شهر را انتخاب کنید",error:u.touched.city&&!!u.errors.city,helperText:u.touched.city&&u.errors.city})}),n&&e.jsxs(S,{variant:"caption",color:"error",children:["شهر: ",u.values.city]})]}),P6=({formik:u,cities:l,provinces:a,isEdit:n,item:o})=>e.jsxs(e.Fragment,{children:[e.jsx(v,{id:"poultry_name",name:"poultry_name",label:"نام مرغدار",value:u.values.poultry_name,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_name&&!!u.errors.poultry_name,helperText:u.touched.poultry_name&&u.errors.poultry_name}),e.jsx(v,{id:"poultry_mobile",name:"poultry_mobile",label:"تلفن مرغداری",value:u.values.poultry_mobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_mobile&&!!u.errors.poultry_mobile,helperText:u.touched.poultry_mobile&&u.errors.poultry_mobile}),e.jsx(a6,{formik:u,cities:l,provinces:a,isEdit:n,item:o}),e.jsx(v,{id:"clearance_code",name:"clearance_code",label:"کد قرنطینه",disabled:n&&(o==null?void 0:o.registerType)==="automatic",value:u.values.clearance_code,onChange:i=>u.setFieldValue("clearance_code",i.target.value.toUpperCase()),onBlur:u.handleBlur,error:u.touched.clearance_code&&!!u.errors.clearance_code,helperText:u.touched.clearance_code&&u.errors.clearance_code}),e.jsx(v,{id:"quantity",name:"quantity",label:"حجم زنده",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"قطعه"})},value:u.values.quantity,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.quantity&&!!u.errors.quantity,helperText:u.touched.quantity&&u.errors.quantity}),e.jsx(v,{id:"live_weight",name:"live_weight",label:"وزن بار زنده",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"کیلوگرم"})},value:u.values.live_weight,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.live_weight&&!!u.errors.live_weight,helperText:u.touched.live_weight&&u.errors.live_weight})]}),O6=({formik:u,cities:l,provinces:a,isEdit:n,item:o})=>e.jsxs(e.Fragment,{children:[e.jsx(v,{id:"poultry_name",name:"poultry_name",label:"نام فروشنده",value:u.values.poultry_name,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_name&&!!u.errors.poultry_name,helperText:u.touched.poultry_name&&u.errors.poultry_name}),e.jsx(v,{id:"poultry_mobile",name:"poultry_mobile",label:"تلفن فروشنده",value:u.values.poultry_mobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.poultry_mobile&&!!u.errors.poultry_mobile,helperText:u.touched.poultry_mobile&&u.errors.poultry_mobile}),e.jsx(a6,{formik:u,cities:l,provinces:a,isEdit:n,item:o}),e.jsx(v,{id:"clearance_code",name:"clearance_code",label:"کد قرنطینه",value:u.values.clearance_code,onChange:i=>u.setFieldValue("clearance_code",i.target.value.toUpperCase()),onBlur:u.handleBlur,error:u.touched.clearance_code&&!!u.errors.clearance_code,helperText:u.touched.clearance_code&&u.errors.clearance_code}),e.jsx(v,{id:"weight_of_carcasses",name:"weight_of_carcasses",label:"وزن لاشه",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"کیلوگرم"})},value:u.values.weight_of_carcasses,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.weight_of_carcasses&&!!u.errors.weight_of_carcasses,helperText:u.touched.weight_of_carcasses&&u.errors.weight_of_carcasses}),e.jsx(v,{id:"number_of_carcasses",name:"number_of_carcasses",label:"حجم تقریبی لاشه",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"قطعه"})},value:u.values.number_of_carcasses,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.number_of_carcasses&&!!u.errors.number_of_carcasses,helperText:u.touched.number_of_carcasses&&u.errors.number_of_carcasses})]}),q6=({formikDriver:u,driverPelak:l,setDriverPelak:a})=>e.jsxs(e.Fragment,{children:[e.jsx(S6,{width:"100%",handleChange:(n,o,i,s)=>{a([n,o,i,s])}}),e.jsx(v,{label:"نام و نام خانوادگی راننده",name:"driverName",value:u.values.driverName,onChange:u.handleChange,error:u.touched.driverName&&!!u.errors.driverName,helperText:u.touched.driverName&&u.errors.driverName,fullWidth:!0}),e.jsx(v,{label:"تلفن راننده",name:"driverMobile",value:u.values.driverMobile,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.driverMobile&&!!u.errors.driverMobile,helperText:u.touched.driverMobile&&u.errors.driverMobile,fullWidth:!0})]}),l6=({item:u,updateTable:l})=>{const a=tu(),[n]=C.useContext(ru),[o,i]=C.useState(u?(u==null?void 0:u.buyType)==="live"?"alive":"carcasses":"alive"),[s,f]=C.useState("today"),[_,A]=C.useState(null),[O,L]=C.useState(null),[H,j]=C.useState([]),[W,vu]=C.useState([]),[nu,V]=C.useState([]),[g,su]=C.useState([]),[c,gu]=C.useState([]),[ou,D]=C.useState([]),h=yu({initialValues:{buyType:u?(u==null?void 0:u.buyType)==="live"?"alive":"carcasses":"alive",poultry_name:u?u.poultryName:"",poultry_mobile:u?u.poultryMobile:"",province:u?u.province:"",city:u?u.city:"",clearance_code:u?u.barClearanceCode:"",quantity:u?u.quantity:"",live_weight:u?u.liveWeight:"",bar_image:u?" ":"",number_of_carcasses:u?u.numberOfCarcasses:"",weight_of_carcasses:u?u.weightOfCarcasses:""},validationSchema:L6(t=>t.buyType==="alive"?$6:R6),onSubmit:async t=>{try{const p={driver_name:T.values.driverName,driver_mobile:T.values.driverMobile,poultry_name:t.poultry_name,poultry_mobile:t.poultry_mobile,province:t.province,city:t.city,...t.clearance_code!==(u==null?void 0:u.barClearanceCode)&&{bar_clearance_code:t.clearance_code},bar_image:t.bar_image,killer_key:O||null,date:s==="today"?uu(new Date).format("YYYY-MM-DD"):uu(new Date).add(1,"days").format("YYYY-MM-DD"),buy_type:t.buyType==="alive"?"live":"carcass",product_key:_==null?void 0:_.key,car:ou.join(" "),...t.buyType==="alive"?{quantity:Number(t.quantity),live_weight:Number(t.live_weight)}:{number_of_carcasses:t.number_of_carcasses,weight_of_carcasses:t.weight_of_carcasses}},q=u?await a(fu({...p,key:u.key})):await a(W6(p));q.payload.error?n({vertical:"top",horizontal:"center",msg:q.payload.error,severity:"error"}):(a(Su({right:!1,bottom:!1,content:null})),l(),n({vertical:"top",horizontal:"center",msg:u?"اطلاعات با موفقیت ویرایش شد":"اطلاعات خرید شما با موفقیت ثبت شد",severity:"success"}))}catch{n({vertical:"top",horizontal:"center",msg:"خطا در ارسال اطلاعات",severity:"error"})}},validateOnMount:!0}),T=yu({initialValues:{driverName:(u==null?void 0:u.driverName)||"",driverMobile:(u==null?void 0:u.driverMobile)||""},validationSchema:N6}),cu=t=>{i(t.target.value),h.setFieldValue("buyType",t.target.value)},iu=t=>{f(t.target.value)},Au=t=>{var p;t[0]&&h.setFieldValue("bar_image",b6((p=t[0])==null?void 0:p.data_url)),gu(t)};return C.useEffect(()=>{(async()=>{try{const[p,q,du]=await Promise.all([a(A6()),a(_6()),a(j6())]);if(j(p.payload.data||[]),vu(q.payload.data||[]),V(du.payload.data||[]),u!=null&&u.province){const $=await a(Xu(u.province));su($.payload.data||[])}}catch(p){console.error(p)}})()},[a,u]),C.useEffect(()=>{h.values.province&&a(Xu(h.values.province)).then(t=>{su(t.payload.data||[])})},[h.values.province,a]),e.jsx(y,{container:!0,direction:"column",justifyContent:"center",gap:2,children:(u==null?void 0:u.registerType)!=="automatic"?e.jsxs(y,{container:!0,direction:"column",justifyContent:"center",gap:2,children:[e.jsxs(Yu,{value:o,onChange:cu,row:!0,"aria-labelledby":"buy-type-radio-group",name:"buy-type-radio-group",children:[e.jsx(Cu,{disabled:!!u,value:"alive",control:e.jsx(hu,{}),label:"مرغ زنده"}),e.jsx(Cu,{disabled:!!u,value:"carcasses",control:e.jsx(hu,{}),label:"لاشه"})]}),!u&&e.jsx(y,{xs:12,container:!0,gap:2,children:e.jsx(m,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"product-select",options:H.map(t=>({data:t,label:t.name})),onChange:(t,p)=>A(p==null?void 0:p.data),renderInput:t=>e.jsx(v,{fullWidth:!0,...t,label:"انتخاب محصول"})})}),!!W.length&&e.jsx(m,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"killer-select",options:W.map(t=>({data:t.key,label:`${t.name} (${t==null?void 0:t.phone})`})),onChange:(t,p)=>L(p==null?void 0:p.data),renderInput:t=>e.jsx(v,{fullWidth:!0,...t,label:"انتخاب کشتارکن (اختیاری)"})}),e.jsxs("form",{onSubmit:h.handleSubmit,style:{display:"flex",flexDirection:"column",gap:I.LARGE},children:[o==="alive"?e.jsx(P6,{formik:h,cities:g,provinces:nu,isEdit:!!u,item:u}):e.jsx(O6,{formik:h,cities:g,provinces:nu,isEdit:!!u,item:u}),e.jsx(q6,{formikDriver:T,driverPelak:ou,setDriverPelak:D}),o==="alive"&&e.jsxs(d6,{children:[e.jsx(C6,{id:"inventory-date-radio-group",children:"تاریخ ورود به انبار"}),e.jsxs(Yu,{value:s,onChange:iu,row:!0,"aria-labelledby":"inventory-date-radio-group",name:"inventory-date-radio-group",children:[e.jsx(Cu,{value:"today",control:e.jsx(hu,{}),label:"امروز"}),e.jsx(Cu,{value:"tomorrow",control:e.jsx(hu,{}),label:"فردا"})]})]}),e.jsx(F6,{onChange:Au,images:c,maxNumber:1,title:"تصویر بار"}),h.touched.bar_image&&!!h.errors.bar_image&&e.jsx(S,{color:"error",children:"ثبت تصویر بار الزامی است"}),e.jsx(x,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",disabled:!h.isValid,children:"ثبت"})]})]}):e.jsxs(y,{container:!0,direction:"column",justifyContent:"center",gap:2,children:[e.jsx(m,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"killer-select-automatic",options:W.map(t=>({data:t.key,label:`${t.name} (${t==null?void 0:t.phone})`})),onChange:(t,p)=>L(p==null?void 0:p.data),renderInput:t=>e.jsx(v,{fullWidth:!0,...t,label:"انتخاب کشتارکن (اختیاری)"})}),e.jsx(v,{id:"quantity",name:"quantity",disabled:(u==null?void 0:u.registerType)==="automatic",label:"حجم زنده",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"قطعه"})},value:h.values.quantity,onChange:h.handleChange,onBlur:h.handleBlur,error:h.touched.quantity&&!!h.errors.quantity,helperText:h.touched.quantity&&h.errors.quantity}),e.jsx(v,{id:"live_weight",name:"live_weight",disabled:(u==null?void 0:u.registerType)==="automatic",label:"وزن بار زنده",InputProps:{endAdornment:e.jsx(z,{position:"end",children:"کیلوگرم"})},value:h.values.live_weight,onChange:h.handleChange,onBlur:h.handleBlur,error:h.touched.live_weight&&!!h.errors.live_weight,helperText:h.touched.live_weight&&h.errors.live_weight}),e.jsx(x,{onClick:h.handleSubmit,type:"button",fullWidth:!0,variant:"contained",color:"primary",disabled:!h.isValid,children:"ثبت"})]})})},M6=({item:u,updateTable:l})=>{var _;const[a,n]=C.useState("0"),[o]=C.useContext(ru),i=tu(),s=yu({initialValues:{realNumber:u.numberOfCarcasses?u.numberOfCarcasses:"",realWeight:u.weightOfCarcasses?u.weightOfCarcasses:""},validationSchema:au({realNumber:P().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!"),realWeight:P().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!")})});C.useEffect(()=>{let A=(u==null?void 0:u.liveWeight)-s.values.realWeight;A<(u==null?void 0:u.liveWeight)?n((A/(u==null?void 0:u.liveWeight)*100).toPrecision(4)):n(0),s.setFieldValue("realNumber",Math.round(s.values.realWeight/1.5))},[s.values.realWeight]);const f=()=>{i(eu({title:"عملیات با موفقیت انجام شد",content:e.jsx(e.Fragment,{children:e.jsxs(y,{container:!0,gap:I.SMALL,justifyContent:"center",children:[e.jsx(S,{variant:"body2",color:"secondary",children:"جهت ویرایش میتوانید حداکثر تا پایان امروز یا قبل از اولین تخصیص اقدام کنید."}),e.jsx(x,{variant:"outlined",onClick:()=>{i(M())},children:"متوجه شدم"})]})})}))};return C.useEffect(()=>{s.validateForm()},[]),e.jsx(e.Fragment,{children:e.jsxs(y,{xs:12,container:!0,spacing:I.SMALL,alignItems:"center",justifyContent:"center",children:[e.jsxs(y,{container:!0,xs:12,gap:I.TINY,children:[e.jsx(y,{container:!0,xs:12,gap:I.SMALL,justifyContent:"center",children:e.jsxs(S,{color:"primary",variant:"body2",children:["وزن بار زنده: ",(_=u==null?void 0:u.liveWeight)==null?void 0:_.toLocaleString()," کیلوگرم"]})}),e.jsx(v,{fullWidth:!0,id:"realWeight",size:"small",label:"وزن لاشه",variant:"outlined",value:s.values.realWeight,error:s.touched.realWeight?!!s.errors.realWeight:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.realWeight&&s.errors.realWeight?s.errors.realWeight:null}),e.jsx(v,{fullWidth:!0,id:"realNumber",size:"small",label:"حجم لاشه",variant:"outlined",value:s.values.realNumber,error:s.touched.realNumber?!!s.errors.realNumber:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.realNumber&&s.errors.realNumber?s.errors.realNumber:null})]}),e.jsxs(y,{container:!0,xs:12,gap:4,alignItems:"center",mt:2,justifyContent:"space-between",children:[e.jsxs(y,{children:[e.jsxs(S,{variant:"body1",color:"primary",children:["افت: ",a>0?a:0,"%"]}),(a>30||a<20)&&e.jsx(S,{variant:"body2",color:"error",children:"درصد افت باید بین 20 تا 30 درصد باشد!"})]}),e.jsx(y,{children:e.jsx(x,{disabled:!s.isValid||a>30||a<20,size:"small",variant:"outlined",onClick:()=>{i(N()),i(fu({key:u==null?void 0:u.key,number_of_carcasses:Number(s.values.realNumber),weight_of_carcasses:Number(s.values.realWeight),ware_house:!0,weight_loss:parseFloat(a)})).then(A=>{A.payload.error?o({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(i(M()),l(1),f(),i(u6()))})},children:"ثبت"})})]})]})})};var Eu={},V6=mu;Object.defineProperty(Eu,"__esModule",{value:!0});var t6=Eu.default=void 0,z6=V6(e6()),Zu=e;t6=Eu.default=(0,z6.default)([(0,Zu.jsx)("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),(0,Zu.jsx)("path",{d:"M9 12h6v2H9z"},"1")],"Inventory2Outlined");const ku=({item:u,updateTable:l,barState:a,type:n})=>{const o=tu(),[i,s]=C.useState(null),f=W=>{s(W.currentTarget)},_=()=>{s(null)},A=!!i,O=A?"popover":void 0,L=()=>(u==null?void 0:u.buyType)==="live"?!u.weightOfCarcasses&&!a:!1,H=()=>n==="carcass"||(u==null?void 0:u.buyType)!=="live"?!0:!a&&!u.weightOfCarcasses,j=(u==null?void 0:u.registerType)==="automatic"?!1:u.weightOfCarcasses&&!a&&(u==null?void 0:u.buyType)==="live";return e.jsxs("div",{children:[e.jsx(ju,{disabled:j,"aria-describedby":O,variant:"contained",color:"primary",onClick:f,children:e.jsx(f6,{})}),e.jsx(h6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:O,open:A,anchorEl:i,onClose:_,children:e.jsxs(p6,{sx:{p:1},children:[(L()||(u==null?void 0:u.registerType)==="automatic")&&e.jsx(_u,{disablePadding:!0,children:e.jsxs(xu,{sx:{color:"primary.main"},onClick:()=>{_(),o(Su({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ویرایش بار آزاد",content:e.jsx(l6,{item:u,updateTable:l})}))},children:[e.jsx(Fu,{sx:{minWidth:36,color:"inherit"},children:e.jsx(E6,{fontSize:"small"})}),e.jsx(S,{variant:"body2",children:"ویرایش"})]})}),a&&(u==null?void 0:u.registerType)==="manual"&&e.jsx(_u,{disablePadding:!0,children:e.jsxs(xu,{sx:{color:"success.main"},onClick:()=>{_(),o(eu({title:"ثبت اطلاعات لاشه ورودی به انبار",content:e.jsx(M6,{item:u,updateTable:l,IsEdit:a==="entered"})}))},children:[e.jsx(Fu,{sx:{minWidth:36,color:"inherit"},children:e.jsx(t6,{fontSize:"small"})}),e.jsx(S,{variant:"body2",children:a==="entered"?"ویرایش":"ورود به انبار"})]})}),H()&&(u==null?void 0:u.registerType)!=="automatic"&&e.jsx(_u,{disablePadding:!0,children:e.jsxs(xu,{sx:{color:"error.main"},onClick:()=>{_(),o(r6(u.key)).then(()=>{l(),o(u6())})},children:[e.jsx(Fu,{sx:{minWidth:36,color:"inherit"},children:e.jsx(B6,{fontSize:"small"})}),e.jsx(S,{variant:"body2",color:"inherit",children:"حذف"})]})})]})})]})},H6=au({weight:P().positive("عدد مثبت وارد کنید"),amount:P().positive("عدد مثبت وارد کنید")}),Y6=({item:u,updateTable:l})=>{const a=tu(),[n]=C.useContext(ru),o=yu({initialValues:{weight:"",amount:""},validationSchema:H6}),i=s=>{a(fu({key:u==null?void 0:u.key,kill_house_vet_state:s,kill_house_vet_quantity:parseInt(o.values.amount),kill_house_vet_weight:parseInt(o.values.weight)})).then(f=>{a(M()),l(1),f.payload.error?n({vertical:"top",horizontal:"center",msg:f.payload.error,severity:"error"}):n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})};return e.jsxs(y6,{container:!0,gap:I.SMALL,justifyContent:"center",children:[e.jsx(v,{fullWidth:!0,id:"amount",name:"amount",label:"حجم",value:o.values.amount,onChange:o.handleChange,error:o.touched.amount&&!!o.errors.amount,helperText:o.touched.amount&&o.errors.amount}),e.jsx(v,{fullWidth:!0,id:"weight",name:"weight",label:"وزن",value:o.values.weight,onChange:o.handleChange,error:o.touched.weight&&!!o.errors.weight,helperText:o.touched.weight&&o.errors.weight}),e.jsx(x,{variant:"contained",disabled:!o.isValid,onClick:()=>{i("accepted")},children:"تایید"}),e.jsx(x,{color:"error",variant:"outlined",onClick:()=>{i("rejected")},disabled:!o.isValid,children:"رد"})]})},G6=lu("VET_FARM_GET_OUT_PROVINCE_DASHBOARD",async(u,{dispatch:l})=>{l(N());const{data:a,status:n}=await R.get("dashboard_kill_house_free_bar",{params:{...u}});return l(w()),{data:a,status:n}}),K6=lu("SLAUGHTER_EDIT_RETURN_ENTERED_FREE_BAR_SERVICE",async(u,{dispatch:l})=>{l(N());try{const{data:a,status:n}=await R.put("kill_house_free_bar/0/",u);return l(w()),{data:a,status:n}}catch(a){return l(w()),{error:a.response.data.result}}});var Bu={},U6=mu;Object.defineProperty(Bu,"__esModule",{value:!0});var n6=Bu.default=void 0,X6=U6(e6()),Q6=e;n6=Bu.default=(0,X6.default)((0,Q6.jsx)("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo");const d0=({isBarManagemen:u})=>{var Tu,Iu,Lu,Du,Wu,$u,Ru,Nu,Pu,Ou,qu,Mu,Vu;const[l,a]=C.useState(0),[n,o]=C.useState([]),[i,s]=C.useState([]),[f,_]=C.useState(0),[A,O]=C.useState(10),[L,H]=C.useState(""),[j,W]=C.useState(1),[vu,nu]=C.useState([]),[V]=C.useContext(ru),g=tu(),su=Uu(d=>d.userSlice.userProfile.key),[c,gu]=C.useState([]),ou=(d,E)=>{a(E)},[,,D,h,T,cu]=C.useContext(ru),iu=()=>{g(G6({date1:D,date2:T,search:"filter",role:b(),value:L,type:l===0?"live":"carcass"})).then(d=>{gu(d.payload.data)})};C.useEffect(()=>{const d=uu(new Date).format("YYYY-MM-DD");h(d),cu(d)},[]);const Au=d=>{H(d.target.value)},{inventorySelectedKillHouse:t}=Uu(d=>d.slaughterSlice);C.useEffect(()=>{g(x6())},[]);const p=async d=>{g(N());const E=await R.get(`kill_house_free_bar/?type=${l===0?"live":"carcass"}&search=filter&value=${L}&role=${b()}&date1=${D}&date2=${T}&page=${d}&page_size=${A}&date_type=buy`);iu(),g(w()),s(E.data.results),_(E.data.count)},q=d=>{p(d),W(d)},du=d=>{O(d),W(1)},$=()=>{p(j!==0?j:1)};C.useEffect(()=>{p(1)},[]),C.useEffect(()=>{const d=i==null?void 0:i.map((r,B)=>{var Y,G,K,U,X,Q,J,Z;return[j===1?B+1:B+A*(j-1)+1,(r==null?void 0:r.registerType)==="automatic"?"سیستمی":"دستی",(r==null?void 0:r.barCode)||"-",k(r.createDate),`${(Y=r==null?void 0:r.killHouse)==null?void 0:Y.name} (${(U=(K=(G=r==null?void 0:r.killHouse)==null?void 0:G.killHouseOperator)==null?void 0:K.user)==null?void 0:U.mobile})`,r!=null&&r.exclusiveKiller?`${(X=r==null?void 0:r.exclusiveKiller)==null?void 0:X.name} (${(Z=(J=(Q=r==null?void 0:r.exclusiveKiller)==null?void 0:Q.killHouseOperator)==null?void 0:J.user)==null?void 0:Z.mobile})`:"-",r.buyType==="live"?"مرغ زنده":"لاشه",r.poultryName,`${r.province}/${r.city}`,e.jsx(Ju,{clearanceCode:r==null?void 0:r.barClearanceCode},r==null?void 0:r.key),r.car||"-",(r==null?void 0:r.driverName)||"-",(r==null?void 0:r.driverMobile)||"-",k(r.date),r.numberOfCarcasses.toLocaleString(),r.weightOfCarcasses.toLocaleString(),e.jsx(Qu,{src:r.barImage},B),e.jsx(e.Fragment,{children:b()==="KillHouse"?e.jsx(ku,{item:r,inventoryKey:r==null?void 0:r.key,updateTable:$},r.key):e.jsx(x,{variant:"outlined",disabled:(r==null?void 0:r.killHouseVetState)!=="pending",size:"small",onClick:()=>{g(eu({title:"تایید / رد",content:e.jsx(Y6,{item:r,updateTable:$})}))},children:"تایید / رد"})})]});nu(d);const E=r=>b()==="AdminX"||b()==="SuperAdmin"?[e.jsx(bu,{title:"بازگشت بار",placement:"top",disableHoverListener:!(r!=null&&r.weightOfCarcasses&&(r==null?void 0:r.enteredMessage)==="ورود به انبار مجازی"),children:e.jsx("span",{children:e.jsx(ju,{color:"primary",size:"small",disabled:!(r!=null&&r.weightOfCarcasses&&(r==null?void 0:r.enteredMessage)==="ورود به انبار مجازی"),onClick:()=>{g(eu({title:"بازگشت بار",content:e.jsxs(y,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:[e.jsx(S,{variant:"body2",color:"red",children:"آیا از بازگشت بار از انبار اطمینان دارید؟"}),e.jsxs(y,{container:!0,xs:12,mt:2,justifyContent:"center",alignItems:"center",spacing:2,children:[e.jsx(y,{item:!0,xs:6,children:e.jsx(x,{onClick:()=>{g(K6({key:r.key,return_entered_bar:!0})).then(B=>{B.payload.error?V({vertical:"top",horizontal:"center",msg:B.payload.error,severity:"error"}):(V({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),$(),g(M()))})},variant:"contained",color:"error",fullWidth:!0,children:"تایید"})}),e.jsx(y,{item:!0,xs:6,children:e.jsx(x,{variant:"contained",color:"primary",fullWidth:!0,onClick:()=>g(M()),children:"لغو"})})]})]})}))},children:e.jsx(n6,{fontSize:"small"})})})},r)]:[],i6=i==null?void 0:i.map((r,B)=>{var Y,G,K,U,X,Q,J,Z,zu;return[j===1?B+1:B+A*(j-1)+1,(r==null?void 0:r.registerType)==="automatic"?"سیستمی":"دستی",(r==null?void 0:r.barCode)||"-",k(r.createDate),k(r.registerDate)||"-",`${(Y=r==null?void 0:r.killHouse)==null?void 0:Y.name} (${(U=(K=(G=r==null?void 0:r.killHouse)==null?void 0:G.killHouseOperator)==null?void 0:K.user)==null?void 0:U.mobile})`,r!=null&&r.exclusiveKiller?`${(X=r==null?void 0:r.exclusiveKiller)==null?void 0:X.name} (${(Z=(J=(Q=r==null?void 0:r.exclusiveKiller)==null?void 0:Q.killHouseOperator)==null?void 0:J.user)==null?void 0:Z.mobile})`:"-",r.buyType==="live"?"مرغ زنده":"لاشه",r.poultryName,`${r.province}/${r.city}`,e.jsx(Ju,{bar_key:r==null?void 0:r.key,register_type:r==null?void 0:r.registerType,clearanceCode:r==null?void 0:r.barClearanceCode},B),r.car||"-",(r==null?void 0:r.driverName)||"-",(r==null?void 0:r.driverMobile)||"-",r.quantity.toLocaleString(),r.liveWeight.toLocaleString(),k(r.date),r.numberOfCarcasses.toLocaleString(),r.weightOfCarcasses.toLocaleString(),(zu=r==null?void 0:r.poultry)==null?void 0:zu.age,r.weightOfCarcasses?"ورود به انبار":"در انتظار ورود به انبار",e.jsx(Qu,{src:r.barImage},B),...E(r),e.jsx(e.Fragment,{children:b()==="KillHouse"?e.jsx(ku,{item:r,inventoryKey:r==null?void 0:r.key,updateTable:$},r.key):u&&b()==="AdminX"&&e.jsx(bu,{title:"حذف بار",placement:"top",children:e.jsx(ju,{color:"error",size:"small",onClick:()=>{g(eu({title:"حذف بار",content:e.jsxs(y,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:[e.jsx(S,{variant:"body2",color:"red",children:"آیا از حذف بار اطمینان دارید؟"}),e.jsxs(y,{container:!0,xs:12,mt:2,justifyContent:"center",alignItems:"center",spacing:2,children:[e.jsx(y,{item:!0,xs:6,children:e.jsx(x,{onClick:()=>{g(r6(r.key)).then(Hu=>{Hu.payload.error?V({vertical:"top",horizontal:"center",msg:Hu.payload.error,severity:"error"}):(V({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),$(),g(M()))})},variant:"contained",color:"error",fullWidth:!0,children:"تایید"})}),e.jsx(y,{item:!0,xs:6,children:e.jsx(x,{variant:"contained",color:"primary",fullWidth:!0,onClick:()=>g(M()),children:"لغو"})})]})]})}))},children:e.jsx(I6,{fontSize:"small"})})})})]});o(i6)},[i]),C.useEffect(()=>{p(1)},[D,T,A,l]);const wu=async d=>{d.preventDefault(),g(N());try{const E=await R.get(`kill_house_free_bar/?type=${l===0?"live":"carcass"}&role=${b()}&search=filter&value=${L}&date1=${D}&date2=${T}&page=1&page_size=${A}&date_type=buy`);s(E.data.results),_(E.data.count),iu(),g(w())}catch(E){console.error("Error fetching data:",E)}},s6=()=>{let d=[];return u&&b()==="AdminX"?d=["حذف"]:u?d=[]:d=["عملیات"],d},o6=()=>b()==="AdminX"||b()==="SuperAdmin"?["بازگشت از انبار"]:[],c6=e.jsx(pu,{data:n,columns:["ردیف","نوع بار","کد بار","تاریخ خرید","تاریخ ثبت در سامانه","خریدار","کشتارکن","محصول","فروشنده","استان/شهر","کدقرنطینه","پلاک ماشین","نام راننده","تلفن راننده","حجم زنده","وزن زنده (کیلوگرم)","تاریخ ورود به انبار","حجم لاشه","وزن لاشه (کیلوگرم)","سن مرغ","وضعیت","بارنامه",...o6(),...s6()],handlePageChange:q,totalRows:f,page:j,perPage:A,handlePerRowsChange:du,title:"بار زنده خرید خارج استان"});return e.jsxs(y,{container:!0,direction:"column",flexWrap:"nowrap",mt:I.SMALL,xs:12,children:[e.jsx(y,{container:!0,justifyContent:"center",alignItems:"center",my:I.SMALL,children:e.jsxs(v6,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:l,onChange:ou,children:[e.jsx(Gu,{label:"زنده"}),e.jsx(Gu,{label:"لاشه"})]})}),e.jsxs(y,{container:!0,mt:I.MEDIUM,alignItems:"center",justifyContent:"center",gap:2,children:[e.jsx("form",{onSubmit:wu,children:e.jsxs(y,{container:!0,alignItems:"center",gap:I.SMALL,children:[b()==="KillHouse"&&!u&&t&&e.jsx(x,{variant:"contained",onClick:()=>{g(Su({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ثبت اطلاعات خرید",content:e.jsx(l6,{selectedDate:D,updateTable:$})}))},children:"ثبت اطلاعات خرید"}),e.jsx(v,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:Au}),e.jsx(x,{type:"submit",onClick:wu,endIcon:e.jsx(w6,{}),children:"جستجو"}),e.jsx(y,{children:e.jsx(Ku,{label:"از تاریخ",id:"date",renderInput:d=>e.jsx(v,{style:{width:"160px"},...d}),value:D,onChange:d=>{h(uu(d).format("YYYY-MM-DD"))}})}),e.jsx(y,{children:e.jsx(Ku,{label:"تا تاریخ",id:"date",renderInput:d=>e.jsx(v,{style:{width:"160px"},...d}),value:T,onChange:d=>{cu(uu(d).format("YYYY-MM-DD"))}})}),e.jsx(bu,{title:"خروجی اکسل",children:e.jsx(x,{color:"success",onClick:()=>{const d=`${R.defaults.baseURL}kill_house_free_bar_excel/?role=${b()}&key=${su}&date1=${D}&date2=${T}&type=${l===0?"live":"carcass"}&search=filter&value=${L}&date_type=buy`;window.location.href=d},children:e.jsx(T6,{size:32})})})]})}),e.jsx(y,{container:!0,mt:2,mb:4,isDashboard:!0,children:l===0?e.jsx(pu,{noPagination:!0,columns:["تعداد کل بارهای زنده","حجم کل بارهای زنده","وزن کل بارهای زنده","تعداد کل بارها وارد شده به انبار","حجم کل بارهای زنده وارد شده به انبار","وزن کل بارهای زنده وارد شده به انبار","وزن لاشه بارهای وارد شده به انبار","تعداد کل بارها وارد نشده به انبار","حجم کل بارهای زنده وارد نشده به انبار","وزن کل بارهای زنده وارد نشده به انبار"],data:[[(Tu=c==null?void 0:c.totalBars)==null?void 0:Tu.toLocaleString(),(Iu=c==null?void 0:c.totalBarsQuantity)==null?void 0:Iu.toLocaleString(),(Lu=c==null?void 0:c.totalBarsLiveWeight)==null?void 0:Lu.toLocaleString(),(Du=c==null?void 0:c.enteredTotalBars)==null?void 0:Du.toLocaleString(),(Wu=c==null?void 0:c.enteredTotalBarsQuantity)==null?void 0:Wu.toLocaleString(),($u=c==null?void 0:c.enteredTotalBarsLiveWeight)==null?void 0:$u.toLocaleString(),(Ru=c==null?void 0:c.enteredTotalBarsWeightOfCarcasses)==null?void 0:Ru.toLocaleString(),(Nu=c==null?void 0:c.notEnteredTotalBars)==null?void 0:Nu.toLocaleString(),(Pu=c==null?void 0:c.notEnteredTotalBarsQuantity)==null?void 0:Pu.toLocaleString(),(Ou=c==null?void 0:c.notEnteredTotalBarsLiveWeight)==null?void 0:Ou.toLocaleString()]],customColors:[{name:"وزن لاشه بارهای وارد شده به انبار",color:"green"}],title:"خلاصه اطلاعات"}):e.jsx(pu,{noPagination:!0,isDashboard:!0,columns:["تعداد کل بارها","حجم لاشه","وزن لاشه"],data:[[(qu=c==null?void 0:c.totalBars)==null?void 0:qu.toLocaleString(),(Mu=c==null?void 0:c.totalBarsNumberOfCarcasses)==null?void 0:Mu.toLocaleString(),(Vu=c==null?void 0:c.totalBarsWeightOfCarcasses)==null?void 0:Vu.toLocaleString()]],title:"خلاصه اطلاعات"})}),l===0?e.jsx(e.Fragment,{children:c6}):e.jsx(pu,{data:vu,columns:u?["ردیف","نوع بار","کد بار","تاریخ خرید","خریدار","کشتارکن","محصول","فروشنده","استان/شهر","کدقرنطینه","پلاک ماشین","نام راننده","تلفن راننده","تاریخ ورود به انبار","حجم لاشه","وزن لاشه (کیلوگرم)","بارنامه"]:["ردیف","نوع بار","کد بار","تاریخ خرید","خریدار","کشتارکن","محصول","فروشنده","استان/شهر","کدقرنطینه","پلاک ماشین","نام راننده","تلفن راننده","تاریخ ورود به انبار","حجم لاشه","وزن لاشه (کیلوگرم)","بارنامه","عملیات"],handlePageChange:q,totalRows:f,page:j,perPage:A,handlePerRowsChange:du,title:"بار لاشه خرید خارج استان"})]})]})};export{d0 as S,l6 as a,M6 as b,Y6 as c,ku as d,r6 as s,G6 as v};