var e=Object.defineProperty,t=(t,o,a)=>(((t,o,a)=>{o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a})(t,"symbol"!=typeof o?o+"":o,a),a);import{j as o,r as a}from"./react-B_SyE9nW.js";import{o as r,n,b3 as s,N as i,b4 as l,m as d,l as c}from"./index-Flm6m8Wj.js";import{M as p,a as u,b as m,F as x,B as h}from"./FldCuisineType-Dosg4gG8.js";import{F as g}from"./FldText-DdvygvC5.js";import{D as j,M as f}from"./DownIco-uXp5N5Ip.js";import{I as b}from"./InputAdornment-BRv1yX3u.js";import{R as C,A as F,F as S,a as I,b as y,c as v}from"./FldIngredients-BEbwCHJL.js";import{F as A}from"./FldTextArea-DGnBCJc0.js";import{M,T,I as P,a as D}from"./index-C6Ujt1Uk.js";import{A as w}from"./BagIco-BQpC9Odt.js";import{G as B}from"./Grid-DM22V-x0.js";import{A as E,a as k,b as N}from"./AccordionSummary-E7XT5_-H.js";const O=r((function({onChange:e,...t}){return o.jsxs(g,{SelectProps:{IconComponent:j},label:n("calories"),select:!0,hiddenLabel:!1,required:!0,onInputChange:e,...t,sx:{"& .MuiSelect-select":{textAlign:"start"}},children:[o.jsx(f,{value:s.LOW,children:n("lowCalories")}),o.jsx(f,{value:s.MEDIUM,children:n("mediumCalories")}),o.jsx(f,{value:s.HIGH,children:n("highCalories")})]})}));const L=r((function({fieldState:e,...t}){return o.jsx(g,{onBlur:()=>{parseFloat(null==e?void 0:e.value)>0&&(null==e||e.onChange(parseFloat((null==e?void 0:e.value.replace(",","."))||0).toFixed(2)))},hiddenLabel:!1,ignoreStateChange:!0,fieldState:e,onInputChange:t=>{Number(parseFloat(t||"0").toFixed(2))>999||(/^[0-9]+([.,][0-9]*?)?$/.test(t)||""===t?null==e||e.onChange(t):null==e||e.setError(n("priceCharacter")))},placeholder:n("addPriceValue"),InputProps:{type:"text",inputProps:{min:0,step:.01,inputMode:"decimal",pattern:"[0-9]+([\\.][0-9]{1,2})?",lang:"en-US"},sx:{"& input":{textAlign:"end"}},startAdornment:o.jsx(b,{position:"start",sx:{height:"auto"},children:o.jsx(i,{children:"€"})})},...t})}));const z=a.createContext(new class extends p{constructor(){super(),t(this,"loadDataByFilter",(async e=>l.loadTagsByCategory({...e,category:"tipo-de-producto"})))}});const H=r((function({fieldState:e,limit:t}){const r=a.useContext(z);return a.useLayoutEffect((()=>{r.loadInitData()}),[]),o.jsx(u.Provider,{value:r,children:o.jsx(m,{limit:t,label:n("productType"),placeholder:n("selectOneOrMoreProduct"),fieldState:e})})})),G={width:"100%","&.MuiPaper-root":{border:"unset",margin:"10px 0"},"& .MuiTypography-root":{fontWeight:400,fontSize:"0.75rem"},"& .MuiAccordionSummary-root":{pr:0,pl:"14px"}},R={"&.MuiAccordionSummary-root":{minHeight:"fit-content!important"},"& .MuiAccordionSummary-content":{my:"0!important"}},q=parseInt("4"),K=parseInt("4"),U=parseInt("4"),V=parseInt("5");const W=r((function({onAddProduct:e}){const t=a.useContext(w),[r,s]=a.useState(!1);return a.useEffect((()=>{var e,o;t.hasError&&(null==(o=null==(e=document.getElementById("enj-add-product-modal"))?void 0:e.scrollIntoView)||o.call(e,{behavior:"smooth",block:"end"}),t.setHasError(!1))}),[t.hasError]),o.jsxs(M,{open:d.isAddProduct,onClose:()=>{t.clearForm(),c()},children:[o.jsx(T,{text:n(t.isFoodTab?"addFood":"addDrink"),margin:"0 0 15px",id:"enj-add-product-modal"}),o.jsxs(B,{container:!0,children:[o.jsx(A,{hiddenLabel:!1,fieldState:t.getName,label:n("name"),validateOnBlur:!0,required:!0,minRows:2,onInputChange:t.onNameChange,placeholder:n(t.isFoodTab?"productFoodName":"productDrinkName")}),o.jsxs(E,{expanded:r,sx:G,onChange:()=>s((e=>!e)),children:[o.jsx(k,{sx:R,expandIcon:o.jsx(P,{sx:{height:"20px",width:"20px"},children:r?o.jsx(C,{color:"disabled"}):o.jsx(F,{color:"disabled"})}),children:o.jsx(B,{children:o.jsx(D,{text:n("description"),weight:400,size:"minis",color:"gray",margin:"5px 0 0 0"})})}),o.jsx(N,{sx:{p:0},children:o.jsx(A,{fieldState:t.getDescription,label:n("description"),validateOnBlur:!0,minRows:4,onInputChange:t.onDescriptionChange,placeholder:n(t.isFoodTab?"descriptionFood":"descriptionDrink")})})]}),o.jsx(L,{fieldState:t.getPrice,label:n("price")}),t.isFoodTab?o.jsx(x,{limit:V,fieldState:t.getKitchen}):o.jsx(o.Fragment,{}),t.isFoodTab?o.jsx(S,{limit:U,fieldState:t.getFood}):o.jsx(I,{limit:K,fieldState:t.getDrink}),o.jsx(H,{limit:q,fieldState:t.getProduct}),o.jsx(y,{fieldState:t.getIngredient}),o.jsx(v,{fieldState:t.getAllergen}),o.jsx(O,{fieldState:t.getCalories,onChange:t.onChangeCalories}),o.jsx(h,{onClick:e,sx:{"&.MuiButton-root":{marginTop:"20px"}}})]})]})}));export{W as A,L as F,H as a,O as b,V as c,K as d,U as f,q as p};