1import{jc as X,hH as h,gT as a,b6 as K,de as ee,y as _,am as te,ah as ae,bO as U,bQ as V,fm as F,z as W,em as z,bP as J,iU as se,j2 as re,iZ as ne,i_ as ie,j8 as le,bY as ce,d9 as de}from"./index-DfEzlclk.js";import{u as oe}from"./index-B38Q2-8f.js";import{D as xe,g as ue,b as me,e as pe}from"./drawer-Ch_49rYl.js";import{C as Q}from"./calendar-CYaAk85-.js";import{T as he}from"./TaxSection-pO2LBeHD.js";import{e as ge,c as Y,G as D,T as S,F as be,i as fe,d as je}from"./ArticleBits-CHmOHiF_.js";import{updateGeneralTab as Pe,saveNewGeneralTab as Ce}from"./utils-DZkElfdF.js";import{I as ve}from"./image-iB7Tob6A.js";import"./endOfMonth-CltHSOWp.js";import"./subDays-qKYcXrMN.js";import"./addDays-Bo6lmrjB.js";function ke({setFunctionParent:i,index:x,disabled:R}){const{t:g}=X(),[I,k]=h.useState(!1),[O,t]=h.useState(!1),[s,u]=h.useState(!1),[l,N]=h.useState("".replace(/-/g,"/")),[b,y]=h.useState("".replace(/-/g,"/")),w=f=>{N(f),t(!1)},A=f=>{y(f),u(!1)},B=()=>{!l||!b||(i(l,b,x),T())},T=()=>{t(!1),u(!1),N("".replace(/-/g,"/")),y("".replace(/-/g,"/")),k(!1)};return a.jsxs(xe,{open:I,onOpenChange:k,children:[a.jsxs(ue,{disabled:R,className:"flex h-[24px] items-center gap-x-1 rounded-xl bg-blancoBox2 px-2 text-xs font-medium text-grisHeading hover:bg-blancoBox2",children:[a.jsx(K,{className:"h-5 w-5",icon:ee}),a.jsx("span",{className:"truncate",children:g("Periodo")})]}),a.jsxs(me,{className:"h-[40%] px-0 pb-6",children:[a.jsxs("div",{className:"mt-0 flex items-center justify-between px-4",children:[a.jsx(_,{type:"button",variant:"ghost",className:"h-8 min-w-16 whitespace-normal rounded-xl px-2 font-roboto text-xs font-normal text-grisHeading",onClick:()=>T(),children:g("Cancelar")}),a.jsx("div",{className:"flex-1 break-words pl-3 text-center text-[14px] font-semibold leading-tight",children:g("Seleccionar Periodo")}),a.jsx(_,{type:"button",variant:"ghost",className:"h-8 min-w-16 whitespace-normal rounded-xl px-2 font-roboto text-xs font-normal text-primarioBotones hover:bg-blancoForms hover:text-primarioBotones",onClick:()=>B(),children:g("Aceptar")})]}),a.jsx(pe,{className:"flex items-center justify-center gap-0 border-b py-3"}),a.jsx(te,{className:"hidden"}),a.jsx(ae,{className:"hidden"}),a.jsxs("div",{className:"mt-4 flex flex-col gap-4 px-4",children:[a.jsxs("div",{className:"w-full",children:[a.jsx("p",{className:"mb-1 overflow-visible text-xs font-normal text-grisText",children:g("Inicio")}),a.jsxs(U,{open:O,onOpenChange:t,children:[a.jsx(V,{asChild:!0,children:a.jsxs(_,{variant:"outline",className:z("min-h-10 w-full justify-between overflow-hidden rounded-lg border border-grisDisabled bg-inherit px-3 font-roboto text-sm font-light text-grisHeading focus-visible:ring-primarioBotones",!l&&"text-muted-foreground"),children:[a.jsx("div",{className:"w-full truncate text-left",children:l?F(l,"PP"):a.jsx("span",{children:"MM/DD/YYYY"})}),a.jsx(W,{className:"ml-2 h-4 w-4 flex-shrink-0"})]})}),a.jsx(J,{className:"w-auto p-0",children:a.jsx(Q,{mode:"single",selected:l,onSelect:f=>w(f),initialFocus:!0})})]})]}),a.jsxs("div",{className:"w-full",children:[a.jsx("p",{className:"mb-1 overflow-visible text-xs font-normal text-grisText",children:g("Finalización")}),a.jsxs(U,{open:s,onOpenChange:u,children:[a.jsx(V,{asChild:!0,children:a.jsxs(_,{variant:"outline",className:z("min-h-10 w-full justify-between overflow-hidden rounded-lg border border-grisDisabled bg-inherit px-3 font-roboto text-sm font-light text-grisHeading focus-visible:ring-primarioBotones",!b&&"text-muted-foreground"),children:[a.jsx("div",{className:"w-full truncate text-left",children:b?F(b,"PP"):a.jsx("span",{children:"MM/DD/YYYY"})}),a.jsx(W,{className:"ml-2 h-4 w-4 flex-shrink-0"})]})}),a.jsx(J,{className:"w-auto p-0",children:a.jsx(Q,{mode:"single",selected:b,onSelect:f=>A(f),initialFocus:!0})})]})]})]})]})]})}function Be(){var M;const{t:i}=X(),x=se(),{isFree:R}=re(),g=ne(),I=ie(),k=x==null?void 0:x.taxes,O=le(),t=(M=x==null?void 0:x.servicesDetails)==null?void 0:M.data,[s,u]=h.useState({id:(t==null?void 0:t.id)||null,manufacturer:(t==null?void 0:t.manufacturer)||"",comments:(t==null?void 0:t.comments)||"",taxes:(t==null?void 0:t.taxes)||[],subject_to_tax:(t==null?void 0:t.subject_to_taxes)||!1,return:(t==null?void 0:t.return)||!1,returnfactory:(t==null?void 0:t.processes)||!1,status:(t==null?void 0:t.status)||!1,start:t.start?new Date(t.start):null,end:t.end?new Date(t.end):null,image:t.image||null,imageFile:null,taxes_destroy:[]}),[l,N]=h.useState({transferLocal:[],transferGeneral:[],passingLocal:[],passingGeneral:[]});h.useEffect(()=>{const r=k.data.filter(e=>e.type=="2"),n=k.data.filter(e=>e.type=="1"),o=n.filter(e=>e.category=="2"),m=n.filter(e=>e.category=="1"),j=r.filter(e=>e.category=="2"),P=r.filter(e=>e.category=="1"),C=o.map(e=>{const d=t==null?void 0:t.taxes.find(p=>p.tax_id==e.id);let c={isChecked:"0",rate:null,idPrincipal:null};return d&&(c={isChecked:"1",rate:e.rates.find(v=>v.id==d.rate.id),idPrincipal:d.id}),{...e,isChecked:c.isChecked,rate:c.rate,idPrincipal:c.idPrincipal}}),E=m.map(e=>{const d=t==null?void 0:t.taxes.find(p=>p.tax_id==e.id);let c={isChecked:"0",rate:null,idPrincipal:null};return d&&(c={isChecked:"1",rate:e.rates.find(v=>v.id==d.rate.id),idPrincipal:d.id}),{...e,isChecked:c.isChecked,rate:c.rate,idPrincipal:c.idPrincipal}}),G=j.map(e=>{const d=t==null?void 0:t.taxes.find(p=>p.tax_id==e.id);let c={isChecked:"0",rate:null,idPrincipal:null};return d&&(c={isChecked:"1",rate:e.rates.find(v=>v.id==d.rate.id),idPrincipal:d.id}),{...e,isChecked:c.isChecked,rate:c.rate,idPrincipal:c.idPrincipal}}),L=P.map(e=>{const d=t==null?void 0:t.taxes.find(p=>p.tax_id==e.id);let c={isChecked:"0",rate:null,idPrincipal:null};return d&&(c={isChecked:"1",rate:e.rates.find(v=>v.id==d.rate.id),idPrincipal:d.id}),{...e,isChecked:c.isChecked,rate:c.rate,idPrincipal:c.idPrincipal}});N({transferLocal:C,transferGeneral:E,passingLocal:G,passingGeneral:L})},[k]);const b=(r,n,o,m)=>{const j={...l,[r]:l[r].map(P=>P.id==m?{...P,[n]:o}:P)};N(j)},y=(r,n,o,m)=>{if(n!=="rate"){b(r,n,o,m);return}const j=(l[r]||[]).find(C=>C.id==m),P=((j==null?void 0:j.rates)||[]).find(C=>String(C.id)===String(o));b(r,"rate",P||null,m)};h.useEffect(()=>{const r=l.passingGeneral.filter(e=>e.isChecked=="1"&&(e==null?void 0:e.rate)).map(e=>({idPrincipal:e.idPrincipal,id:e.id,rate:e.rate,name:e.name})),n=l.passingLocal.filter(e=>e.isChecked=="1"&&(e==null?void 0:e.rate)).map(e=>({idPrincipal:e.idPrincipal,id:e.id,rate:e.rate,name:e.name})),o=l.transferGeneral.filter(e=>e.isChecked=="1"&&(e==null?void 0:e.rate)).map(e=>({idPrincipal:e.idPrincipal,id:e.id,rate:e.rate,name:e.name})),m=l.transferLocal.filter(e=>e.isChecked=="1"&&(e==null?void 0:e.rate)).map(e=>({idPrincipal:e.idPrincipal,id:e.id,rate:e.rate,name:e.name})),j=l.passingGeneral.filter(e=>
1e.isChecked=="0"&&e.idPrincipal!=null).map(e=>({id:e.idPrincipal})),P=l.passingLocal.filter(e=>e.isChecked=="0"&&e.idPrincipal!=null).map(e=>({id:e.idPrincipal})),C=l.transferGeneral.filter(e=>e.isChecked=="0"&&e.idPrincipal!=null).map(e=>({id:e.idPrincipal})),E=l.transferLocal.filter(e=>e.isChecked=="0"&&e.idPrincipal!=null).map(e=>({id:e.idPrincipal})),G={passingGeneral:r,passingLocal:n,transferGeneral:o,transferLocal:m},L=[...j,...P,...C,...E];u(e=>({...e,taxes:G,taxes_destroy:L}))},[l]);const w=h.useCallback(r=>{u(n=>({...n,[r]:!n[r]}))},[]),A=()=>{u(r=>({...r,start:null,end:null}))},B=(r,n)=>{u(o=>({...o,start:r,end:n}))},{getRootProps:T,getInputProps:f}=oe({accept:{"image/jpeg":[],"image/png":[]},onDrop:([r])=>{if(r){const n=URL.createObjectURL(r);u(o=>({...o,image:n,imageFile:r}))}}}),Z=()=>{u(r=>({...r,image:null}))},$=h.useCallback((r,n)=>{const o=n&&n.target?n.target.value:n;u(m=>({...m,[r]:o}))},[]),H=(t==null?void 0:t.taxes)&&(t==null?void 0:t.taxes.length)>0||(t==null?void 0:t.return)&&(t==null?void 0:t.return)!==null||(t==null?void 0:t.processes)&&(t==null?void 0:t.processes)!==null||(t==null?void 0:t.comments)&&(t==null?void 0:t.comments)!==null||(t==null?void 0:t.image)&&(t==null?void 0:t.image)!==null?"update_generalform":"create_generalform";function q(){const r=new FormData;let n;H!=="update_generalform"?n={service_id:s.id,subject_to_tax:s.subject_to_tax?"1":"0",taxes:s.taxes,return:s!=null&&s.return?"1":"0",processes:s!=null&&s.returnfactory?"1":"0",status:s!=null&&s.status?"1":"0",manufacturer:s==null?void 0:s.manufacturer,comments:s==null?void 0:s.comments}:n={service_id:s==null?void 0:s.id,subject_to_tax:s!=null&&s.subject_to_tax?"1":"0",taxes:s.taxes,taxes_destroy:s.taxes_destroy,return:s!=null&&s.return?"1":"0",processes:s!=null&&s.returnfactory?"1":"0",status:s!=null&&s.status?"1":"0",manufacturer:s==null?void 0:s.manufacturer,comments:s==null?void 0:s.comments},r.append("type_option",H),s.imageFile&&r.append("image",s.imageFile),r.append("info",JSON.stringify(n)),O(r,{method:"post",encType:"multipart/form-data"})}return a.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden bg-blancoBg dark:bg-surface",children:[a.jsx(ge,{title:i("Impuestos y opciones"),subtitle:(t==null?void 0:t.name)||i("Servicio"),onClose:()=>g(-1)}),a.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pt-0.5",children:[a.jsxs(Y,{children:[a.jsx(D,{children:i("Configuración")}),a.jsxs("div",{className:"flex flex-col gap-y-2 pb-3.5",children:[a.jsx(S,{label:i("Sujeto a impuesto"),hint:"Cobra IVA, IEPS o retenciones",checked:s.subject_to_tax,onChange:()=>w("subject_to_tax")}),a.jsx(S,{label:i("Disponible para devolución"),checked:s.return,onChange:()=>w("return")}),a.jsx(S,{label:i("Disponible para fabricar"),checked:s.returnfactory,onChange:()=>w("returnfactory")})]}),s.subject_to_tax&&a.jsxs(a.Fragment,{children:[a.jsx(D,{children:i("Impuestos")}),a.jsx(he,{options:l,onChange:y})]}),a.jsx(be,{label:i("Comentarios"),hint:"Notas internas sobre el servicio.",children:a.jsx("input",{className:fe,value:s.comments||"",onChange:r=>$("comments",r),placeholder:i("Escribe un comentarioâ¦")})})]}),a.jsxs(Y,{className:"mt-3",children:[a.jsx(D,{children:i("Estatus")}),a.jsxs("div",{className:"pb-3.5",children:[a.jsx(S,{label:s.status?i("Activo"):i("Inactivo"),hint:s.start&&s.end?i("Vigente del {{from}} al {{to}}",{from:F(s.start,"PP"),to:F(s.end,"PP")}):i("Sin periodo de vigencia"),checked:s.status,onChange:()=>w("status")}),a.jsx("div",{className:"mt-2.5 flex items-center gap-x-2",children:s.start&&s.end?a.jsx("button",{type:"button",onClick:A,className:"flex h-[30px] items-center rounded-[9px] bg-rose-50 px-3 font-dm text-[11.5px] font-bold text-deleteRed dark:bg-rose-500/15 dark:text-rose-300",children:i("Restablecer")}):a.jsx(ke,{setFunctionParent:B})})]})]}),a.jsxs(Y,{className:"mt-3",children:[a.jsx(D,{children:i("Imagen")}),a.jsx(ce,{active:R,feature:"La imagen del servicio",children:a.jsxs("div",{...T(),className:"cursor-pointer pb-3.5",children:[s.image?a.jsxs("div",{className:"relative overflow-hidden rounded-[15p
1x] bg-blancoForms",children:[a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),Z()},className:"absolute right-2.5 top-2.5 z-10 flex size-8 items-center justify-center rounded-full bg-softBlack/70",children:a.jsx(de,{className:"size-4 text-white",strokeWidth:2.4})}),a.jsx("img",{src:s.image||(t==null?void 0:t.image),alt:i("Imagen cargada"),className:"max-h-52 w-full object-contain"})]}):a.jsxs("div",{className:z("flex flex-col items-center justify-center gap-y-2 rounded-[15px] py-10","border-[1.5px] border-dashed border-blancoBox2"),children:[a.jsx(ve,{className:"size-7 text-slateGray/70",strokeWidth:1.5}),a.jsx("span",{className:"font-dm text-[12.5px] font-semibold text-slateGray",children:i("Agregar imagen")})]}),a.jsx("input",{...f(),name:"image",type:"file"})]})})]}),a.jsx("div",{className:"h-8"})]}),a.jsx(je,{onLater:()=>g(-1),onSave:q,saving:I.state!=="idle"})]})}async function Ee({request:i}){const x=await i.formData();switch(x.get("type_option")){case"create_generalform":await Ce(x);break;case"update_generalform":await Pe(x);break}return"1"}export{Ee as Action,Be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.