import{X as D,j as e,c as I,M as h,S as j,a4 as R,ab as A,a6 as T,a9 as f,aq as P}from"./vendor-mui-CBBEb17G.js";import{a as l}from"./vendor-react-BBazpZul.js";import{h0 as w,dR as B,fS as s,J as g,v as K,h1 as F,h2 as G,aX as O,x as Q,ce as x,b3 as p,bd as U,bx as X}from"./index-IP_FWtso.js";const J=({onClose:y,onSubmit:v,selectedValue:c})=>{const{setTeethSelected:N,teethSelected:d,checkedTop:n,checkedBottom:r}=w(),S=B(),b=D(S.breakpoints.up("md")),[a,E]=l.useState(s.PERMANENT),[i,m]=l.useState([]),M=()=>n&&r?{id:p(),location:x.ALL,type:a}:n?{id:p(),location:x.TOP,type:a}:r?{id:p(),location:x.BUTTOM,type:a}:d,u=()=>{N(void 0),y()},k=()=>{if(!i.length){g.info("دندانی انتخاب نشده است");return}v(i),u()};l.useEffect(()=>{if(!d&&!n&&!r)return;const o=M();if(i.some(t=>t.location===o.location&&t.number===o.number)){g.info("این دندان قبلا انتخاب شده است");return}m(t=>[...t,o])},[d,n,r]),l.useEffect(()=>{c&&m(c)},[c]);const C=[{title:"شماره دندان",key:"location",dataIndex:"location",align:"center",render:(o,t)=>U({location:t.location,toothNumber:t.number})},{title:"حذف",key:"id",dataIndex:"id",align:"center",width:50,render:o=>e.jsx(X,{color:"error",onClick:()=>m(t=>t.filter(L=>L.id!=o))})}];return e.jsxs(K,{title:"انتخاب دندان ها",maxWidth:"md",onClose:u,children:[e.jsx(I,{style:{paddingBottom:0},children:e.jsxs(h,{container:!0,spacing:1,className:"relative",children:[e.jsx(h,{item:!0,xs:12,md:6,children:e.jsxs(j,{gap:1,alignItems:"center",children:[e.jsx(R,{className:"!pt-4",children:e.jsxs(A,{"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:a,onChange:o=>E(+o.target.value),row:!0,children:[e.jsx(T,{value:s.PERMANENT,control:e.jsx(f,{}),label:"دائمی"}),e.jsx(T,{value:s.MILK,control:e.jsx(f,{}),label:"شیری"})]})}),e.jsxs(j,{alignItems:"center",paddingY:2,children:[a===s.PERMANENT?e.jsx(F,{}):null,a===s.MILK?e.jsx(G,{}):null]})]})}),e.jsx(P,{orientation:b?"vertical":"horizontal",className:b?"absolute top-0 bottom-0 left-[50%]":"!w-full m-2"}),e.jsx(h,{item:!0,xs:12,md:6,children:e.jsx(O,{columns:C,data:i,rowKey:"id"})})]})}),e.jsx(Q,{style:{paddingBottom:"15px"},onClose:u,onSubmit:k})]})};export{J as S};
