import{jasu,Iasfu,b0asl6,BasO,akasN,alashu,agasZu,ahasXu,aiasU,ajasJ,aaasJu,Tasu6,dast6,aXasr6,b2asa6,b3asKu,basn6}from"./mui-vendor-CkIVaoQP.js";import{rasa,jase6,uasc6}from"./react-vendor-CmFgShSM.js";import{Lasdu,jasK,XasI,hasCu,AasSu,Gasg,OasAu,fFasd6,casC6,Masgu,baspu,uasi6,vasm,Wasju,CasFu,fHash6,pasg6,Sasyu,dhasp6,fGasx6,jGasA6,jHasj6}from"./index-N50kY0pn.js";import{RasQ}from"./ResponsiveTable-C_snJsEO.js";import{aaso6,uasD,fasQu}from"./redux-vendor-B7uoacJt.js";import{RasF6,aasy6}from"./index.esm-Bu7XMDZU.js";import{dass6}from"./Tune-DIGF0Mp6.js";import{basf6,easS6,casv6,sasw6,aask6}from"./slaughter-get-guilds-for-allocate-vpZQhgy1.js";import{Sasb6,sas_6}from"./SlaughterAllocateToGuild-BMcPjvXI.js";import{Nasxu}from"./NumberFormatCustom-DwWPj40N.js";import{IasE6,fasT6}from"./toBase64-7xJ86bMI.js";import{aas$6}from"./province-policy-upload-image-D2EGPJ2q.js";import{BasH6}from"./BackButton-jnQBD0Yv.js";import{dasP6}from"./Visibility-DkUmeXW5.js";import"./FilterAlt-CF131fPn.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./iconBase-BEJYyZsk.js";import"./LabelField-Mkfcpni4.js";import"./PublishedWithChanges-BW1Hr5gq.js";import"./Delete-CiVJBR3T.js";constB6=o6("SLAUGHTER_GET_MORGUE_DASHBOARD",async(x,{dispatch:l})=>{l(du());const{data:y,status:C}=awaitK.get("total-cold-house-dashboard-roles/",{params:{role:I()}});returnl(Cu()),{data:y,status:C}}),L6=o6("SLAUGHTER_GET_MORGUES",async(x,{dispatch:l})=>{l(du());const{data:y,status:C}=awaitK.get("kill-house-cold-houses/",{params:{role:I()}});returnl(Cu()),{data:y,status:C}}),G6=({fetchApiData:x,item:l,fetchData:y,updateTable:C,priceInfo:E,remainWeight:f})=>{const[A,w]=a.useState(null),h=v=>{w(v.currentTarget)},t=()=>{w(null)},n=!!A,S=n?"popover":void0,[k]=a.useContext(Su),p=D();returnu.jsxs(g,{container:!0,children:[u.jsx(fu,{disabled:l==null?void0:l.registrationCode,"aria-describedby":S,variant:"contained",color:"primary",onClick:h,children:u.jsx(s6,{})}),u.jsx(l6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:S,open:n,anchorEl:A,onClose:t,children:u.jsx("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:u.jsxs(g,{container:!0,direction:"column",gap:1,children:[u.jsx(O,{variant:"outlined",onClick:()=>{t(),p(Au({title:"ویرایش تخصیص",content:u.jsx(b6,{updateTable:y,fetchApiData:x,sellerType:"ColdHouse",sellType:"exclusive",coldHouseItemKey:l==null?void0:l.key,priceInfo:E,editData:l,remainWeight:f})}))},children:"ویرایش"}),u.jsx(O,{size:"small",disabled:l==null?void0:l.registrationCode,variant:"outlined",color:"error",onClick:()=>{t(),p(f6({steward_allocation_key:l.key})).then(v=>{v.error?k({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(x(1),y(),C(),k({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"حذف"})]})})})]})},R6=({item:x,key:l,sellerType:y,fetchData:C,buyerType:E,allocationType:f,sellType:A,updateTable:w,fetchApiData:h,editData:t,priceInfo:n,coldHouseKey:S,coldHouseItemKey:k,remainWeight:p,killHouseAllocation:v})=>{varX;consti=D(),[$,b]=a.useState([]),[B,L]=a.useState([]),[M,G]=a.useState([]),[W,j]=a.useState(null),[Y]=a.useContext(Su),[_,iu]=a.useState(n!=null&&n.active?"true":"false"),[uu,eu]=a.useState(t!=null&&t.image?[{data_url:t.image}]:[]),[R,ou]=a.useState("own"),[su,lu]=a.useState(1),[d,e]=a.useState(!1),tu=o=>{ou(o.target.value),V({key:"",item:"",buyerType:"",allocationType:""})},z=o=>{iu(o.target.value),o.target.value==="false"&&s.setFieldValue("price","")},[c,V]=a.useState({key:l,item:x,buyerType:E,allocationType:f});a.useEffect(()=>{I()==="Steward"&&ou("free")},[]),a.useEffect(()=>{i($6()).then(o=>{varr;(r=o.payload)!=null&&r.data&&lu(o.payload.data.killHouseAllocation)}),t||(i(d6()).then(o=>{b(o.payload.data)}),x||(R==="cold"&&i(S6()).then(o=>{G(o.payload.data)}),i(v6({free:R==="free"})).then(o=