var __gh = require("react").createElement, __gf = require("react").Fragment; var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{table:"prevencion__permisos_trabajo"},{table:"prevencion__buques"},{table:"prevencion__empresas"},{table:"prevencion__jefes_buque"},{table:"prevencion__trabajadores"},{table:"prevencion__categorias_trabajo"},{table:"prevencion__tipos_trabajo"},{table:"prevencion__zonas_buque"},{table:"prevencion__checklist_items"},{table:"prevencion__firmas_permiso"},{table:"rrhh__empleados"},{table:"rrhh__puestos"},{table:"rrhh__departamentos"}];var import_react=require("react");function PermisosDeTrabajo({gufi}){let[vista,setVista]=(0,import_react.useState)("lista"),[permisoId,setPermisoId]=(0,import_react.useState)(null),[filtroEstado,setFiltroEstado]=(0,import_react.useState)(""),[filtroBuque,setFiltroBuque]=(0,import_react.useState)(""),{data:permisosData}=gufi.useData("prevencion__permisos_trabajo",{limit:200,sort:"fecha",order:"DESC"}),{data:buquesData}=gufi.useData("prevencion__buques",{limit:500}),{data:empresasData}=gufi.useData("prevencion__empresas",{limit:500}),{data:tiposData}=gufi.useData("prevencion__tipos_trabajo",{limit:500}),{data:categoriasData}=gufi.useData("prevencion__categorias_trabajo",{limit:500}),{data:firmasData}=gufi.useData("prevencion__firmas_permiso",{limit:1e3}),{data:zonasData}=gufi.useData("prevencion__zonas_buque",{limit:500}),buqueNombre=id=>buquesData?.find(b=>b.id===id)?.nombre||"",empresaNombre=id=>empresasData?.find(e=>e.id===id)?.nombre||"",tipoNombre=id=>tiposData?.find(t=>t.id===id)?.nombre||"",zonaNombre=id=>zonasData?.find(z=>z.id===id)?.nombre||"",permisosFiltrados=(0,import_react.useMemo)(()=>permisosData?permisosData.filter(p=>!(filtroEstado&&p.estado!==filtroEstado||filtroBuque&&String(p.buque)!==filtroBuque)):[],[permisosData,filtroEstado,filtroBuque]);return vista==="crear"?__gh(FormularioPermiso,{gufi,buquesData,empresasData,tiposData,categoriasData,zonasData,onVolver:()=>setVista("lista"),onGuardado:id=>{setPermisoId(id),setVista("detalle")}}):vista==="detalle"&&permisoId?__gh(DetallePermiso,{gufi,permisoId,buquesData,empresasData,tiposData,categoriasData,zonasData,onVolver:()=>setVista("lista"),onNuevo:()=>{setPermisoId(null),setVista("crear")}}):__gh("div",{className:"min-h-screen bg-gray-50","data-gufi-src":"page.tsx:64"},__gh("div",{className:"max-w-5xl mx-auto px-4 py-4 md:py-6","data-gufi-src":"page.tsx:65"},__gh("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 mb-4","data-gufi-src":"page.tsx:66"},__gh("h1",{className:"text-xl md:text-2xl font-bold text-slate-900","data-gufi-src":"page.tsx:67"},"Permisos de trabajo"),__gh("button",{onClick:()=>setVista("crear"),className:"bg-blue-900 text-white px-4 py-2.5 rounded-lg text-sm font-semibold shadow hover:bg-blue-800 active:scale-95 transition","data-gufi-src":"page.tsx:68"},"+ Nuevo permiso")),__gh("div",{className:"flex flex-col sm:flex-row gap-2 mb-4","data-gufi-src":"page.tsx:76"},__gh("select",{className:"border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white",value:filtroEstado,onChange:e=>setFiltroEstado(e.target.value),"data-gufi-src":"page.tsx:77"},__gh("option",{value:"","data-gufi-src":"page.tsx:82"},"Todos los estados"),__gh("option",{value:"Borrador","data-gufi-src":"page.tsx:83"},"Borrador"),__gh("option",{value:"En revisi\xF3n","data-gufi-src":"page.tsx:84"},"En revisi\xF3n"),__gh("option",{value:"V\xE1lido","data-gufi-src":"page.tsx:85"},"V\xE1lido"),__gh("option",{value:"Finalizado","data-gufi-src":"page.tsx:86"},"Finalizado"),__gh("option",{value:"Cancelado","data-gufi-src":"page.tsx:87"},"Cancelado")),__gh("select",{className:"border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white",value:filtroBuque,onChange:e=>setFiltroBuque(e.target.value),"data-gufi-src":"page.tsx:89"},__gh("option",{value:"","data-gufi-src":"page.tsx:94"},"Todos los buques"),buquesData?.map(b=>__gh("option",{key:b.id,value:String(b.id),"data-gufi-src":"page.tsx:96"},b.nombre)))),__gh("div",{className:"grid gap-3","data-gufi-src":"page.tsx:101"},permisosFiltrados.map(p=>{let firmasPermiso=firmasData?.filter(f=>f.permiso===p.id)||[],faltaProduccion=!p.firma_produccion,faltaPRL=!p.firma_prl;return __gh("div",{key:p.id,onClick:()=>{setPermisoId(p.id),setVista("detalle")},className:"bg-white rounded-xl border border-gray-200 p-4 shadow-sm cursor-pointer hover:shadow-md transition","data-gufi-src":"page.tsx:107"},__gh("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2","data-gufi-src":"page.tsx:112"},__gh("div",{"data-gufi-src":"page.tsx:113"},__gh("div",{className:"flex items-center gap-2","data-gufi-src":"page.tsx:114"},__gh("span",{className:"text-xs font-bold uppercase tracking-wide text-blue-900 bg-blue-50 px-2 py-0.5 rounded","data-gufi-src":"page.tsx:115"},p.estado),__gh("span",{className:"text-xs text-gray-500","data-gufi-src":"page.tsx:118"},p.numero_permiso)),__gh("div",{className:"mt-1 font-semibold text-slate-800 text-base","data-gufi-src":"page.tsx:120"},buqueNombre(p.buque)," \u2014 ",tipoNombre(p.tipo_trabajo)),__gh("div",{className:"text-sm text-gray-600 mt-0.5","data-gufi-src":"page.tsx:123"},empresaNombre(p.empresa)," \xB7 ",p.fecha," \xB7 ",p.hora_inicio?.slice(0,5),"-",p.hora_fin?.slice(0,5))),__gh("div",{className:"flex items-center gap-2 text-xs","data-gufi-src":"page.tsx:127"},p.nivel_riesgo&&__gh("span",{className:`px-2 py-1 rounded font-medium ${p.nivel_riesgo==="Muy alto"?"bg-red-100 text-red-700":p.nivel_riesgo==="Alto"?"bg-orange-100 text-orange-700":p.nivel_riesgo==="Medio"?"bg-yellow-100 text-yellow-700":"bg-green-100 text-green-700"}`,"data-gufi-src":"page.tsx:129"},p.nivel_riesgo),p.espacio_confinado&&__gh("span",{className:"bg-purple-100 text-purple-700 px-2 py-1 rounded font-medium","data-gufi-src":"page.tsx:139"},"Confinado"))),__gh("div",{className:"mt-2 flex flex-wrap gap-2 text-xs text-gray-500","data-gufi-src":"page.tsx:143"},faltaProduccion&&__gh("span",{className:"bg-gray-100 px-2 py-0.5 rounded","data-gufi-src":"page.tsx:144"},"\u23F3 Falta firma Producci\xF3n"),faltaPRL&&__gh("span",{className:"bg-gray-100 px-2 py-0.5 rounded","data-gufi-src":"page.tsx:145"},"\u23F3 Falta firma PRL"),!faltaProduccion&&!faltaPRL&&__gh("span",{className:"bg-green-50 text-green-700 px-2 py-0.5 rounded","data-gufi-src":"page.tsx:147"},"\u2713 Firmado"),__gh("span",{className:"ml-auto","data-gufi-src":"page.tsx:149"},firmasPermiso.length," firmas")))}),permisosFiltrados.length===0&&__gh("div",{className:"text-center text-gray-400 py-10 text-sm","data-gufi-src":"page.tsx:155"},"No hay permisos. Crea el primero con el bot\xF3n de arriba."))))}function FormularioPermiso({gufi,buquesData,empresasData,tiposData,categoriasData,zonasData,onVolver,onGuardado}){let[step,setStep]=(0,import_react.useState)(1),[guardando,setGuardando]=(0,import_react.useState)(!1),[form,setForm]=(0,import_react.useState)({numero_permiso:`PT-${new Date().toISOString().slice(2,10).replace(/-/g,"")}-001`,buque:"",zona_buque:"",empresa:"",responsable_empresa:"",descripcion_trabajo:"",fecha:new Date().toISOString().slice(0,10),hora_inicio:"08:00",hora_fin:"16:00",tipo_trabajo:"",trabajo_en_altura:!1,trabajo_en_caliente:!1,incluye_trabajos_de_corte:!1,trabajo_sala_maquinas:!1,espacio_confinado:!1,tipo_espacio_confinado:"",gas_free:"",medicion_lie:"",medicion_co:"",medicion_o2:"",medicion_h2s:"",explosimetro_condiciones:!1,fecha_proxima_revision_explosimetro:"",control_atmosfera_respirable:!1,control_atmosfera_libre_gas:!1,control_atmosfera_toxicos:!1,control_atmosfera_inflamables:!1,control_atmosfera_corrosivos:!1,estado:"Borrador"}),tipoSeleccionado=tiposData?.find(t=>String(t.id)===String(form.tipo_trabajo)),update=(k,v)=>setForm(f=>({...f,[k]:v})),guardar=async()=>{setGuardando(!0);try{let riesgo=tipoSeleccionado?.riesgo_predeterminado||"Bajo";form.espacio_confinado&&form.trabajo_en_caliente?riesgo="Muy alto":form.trabajo_en_caliente||form.espacio_confinado?riesgo="Alto":form.trabajo_en_altura&&(riesgo="Medio");let payload={...form,nivel_riesgo:riesgo};form.buque&&(payload.buque=Number(form.buque)),form.empresa&&(payload.empresa=Number(form.empresa)),form.tipo_trabajo&&(payload.tipo_trabajo=Number(form.tipo_trabajo)),form.zona_buque&&(payload.zona_buque=Number(form.zona_buque));let res=await gufi.create("prevencion__permisos_trabajo",payload);res?.id&&onGuardado(res.id)}finally{setGuardando(!1)}},steps=["Datos del permiso","Evaluaci\xF3n y riesgos","Espacio confinado","Resumen"];return __gh("div",{className:"min-h-screen bg-gray-50 pb-20","data-gufi-src":"page.tsx:211"},__gh("div",{className:"max-w-3xl mx-auto px-4 py-4","data-gufi-src":"page.tsx:212"},__gh("div",{className:"flex items-center gap-2 mb-4","data-gufi-src":"page.tsx:213"},__gh("button",{onClick:onVolver,className:"text-sm text-gray-600 hover:text-gray-900","data-gufi-src":"page.tsx:214"},"\u2190 Volver")),__gh("div",{className:"flex gap-1 overflow-x-auto pb-2","data-gufi-src":"page.tsx:216"},steps.map((s,i)=>__gh("button",{key:i,onClick:()=>setStep(i+1),className:`flex-1 min-w-[80px] text-xs py-2 rounded-lg font-medium transition ${step===i+1?"bg-blue-900 text-white":"bg-white text-gray-600 border"}`,"data-gufi-src":"page.tsx:218"},i+1,". ",s))),step===1&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:228"},__gh("h2",{className:"font-semibold text-slate-800","data-gufi-src":"page.tsx:229"},"Datos del permiso"),__gh("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3","data-gufi-src":"page.tsx:230"},__gh(Field,{label:"N\xBA permiso",value:form.numero_permiso,onChange:v=>update("numero_permiso",v)}),__gh(Select,{label:"Buque",value:form.buque,onChange:v=>update("buque",v),options:buquesData?.map(b=>({value:String(b.id),label:b.nombre}))||[]}),__gh(Select,{label:"Zona del buque",value:form.zona_buque,onChange:v=>update("zona_buque",v),options:zonasData?.map(z=>({value:String(z.id),label:z.nombre}))||[]}),__gh(Select,{label:"Empresa / Subcontrata",value:form.empresa,onChange:v=>update("empresa",v),options:empresasData?.map(e=>({value:String(e.id),label:e.nombre}))||[]}),__gh(Field,{label:"Responsable empresa",value:form.responsable_empresa,onChange:v=>update("responsable_empresa",v)}),__gh(Field,{label:"Fecha",type:"date",value:form.fecha,onChange:v=>update("fecha",v)}),__gh(Field,{label:"Hora inicio",type:"time",value:form.hora_inicio,onChange:v=>update("hora_inicio",v)}),__gh(Field,{label:"Hora fin",type:"time",value:form.hora_fin,onChange:v=>update("hora_fin",v)}),__gh("div",{className:"sm:col-span-2","data-gufi-src":"page.tsx:242"},__gh(Select,{label:"Tipo de trabajo",value:form.tipo_trabajo,onChange:v=>update("tipo_trabajo",v),options:tiposData?.map(t=>{let cat=categoriasData?.find(c=>c.id===t.categoria)?.nombre||"";return{value:String(t.id),label:`${cat?cat+" \u2014 ":""}${t.nombre}`}})||[]})),__gh("div",{className:"sm:col-span-2","data-gufi-src":"page.tsx:249"},__gh("label",{className:"block text-sm font-medium text-gray-700 mb-1","data-gufi-src":"page.tsx:250"},"Descripci\xF3n del trabajo"),__gh("textarea",{className:"w-full border rounded-lg px-3 py-2 text-sm",rows:3,value:form.descripcion_trabajo,onChange:e=>update("descripcion_trabajo",e.target.value),"data-gufi-src":"page.tsx:251"}))),__gh("div",{className:"flex flex-wrap gap-3 pt-2","data-gufi-src":"page.tsx:255"},__gh(Checkbox,{label:"Trabajo en altura",checked:form.trabajo_en_altura,onChange:v=>update("trabajo_en_altura",v)}),__gh(Checkbox,{label:"Trabajo en caliente",checked:form.trabajo_en_caliente,onChange:v=>update("trabajo_en_caliente",v)}),__gh(Checkbox,{label:"Incluye trabajos de corte",checked:form.incluye_trabajos_de_corte,onChange:v=>update("incluye_trabajos_de_corte",v)}),__gh(Checkbox,{label:"Sala de m\xE1quinas",checked:form.trabajo_sala_maquinas,onChange:v=>update("trabajo_sala_maquinas",v)})),__gh("div",{className:"flex justify-end pt-2","data-gufi-src":"page.tsx:261"},__gh("button",{onClick:()=>setStep(2),className:"bg-blue-900 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:262"},"Siguiente \u2192"))),step===2&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:268"},__gh("h2",{className:"font-semibold text-slate-800","data-gufi-src":"page.tsx:269"},"Evaluaci\xF3n de riesgos"),__gh("div",{className:`inline-block px-3 py-1 rounded text-sm font-bold ${form.trabajo_en_caliente&&form.espacio_confinado?"bg-red-100 text-red-700":form.trabajo_en_caliente||form.espacio_confinado?"bg-orange-100 text-orange-700":form.trabajo_en_altura?"bg-yellow-100 text-yellow-700":"bg-green-100 text-green-700"}`,"data-gufi-src":"page.tsx:270"},"Nivel de riesgo: ",form.trabajo_en_caliente&&form.espacio_confinado?"Muy alto":form.trabajo_en_caliente||form.espacio_confinado?"Alto":form.trabajo_en_altura?"Medio":"Bajo"),__gh("div",{className:"text-sm text-gray-700 space-y-1","data-gufi-src":"page.tsx:284"},__gh("p",{className:"font-semibold","data-gufi-src":"page.tsx:285"},"Normas obligatorias:"),__gh("ul",{className:"list-disc pl-5 space-y-1","data-gufi-src":"page.tsx:286"},__gh("li",{"data-gufi-src":"page.tsx:287"},"Comprobar la zona de trabajo antes de empezar."),__gh("li",{"data-gufi-src":"page.tsx:288"},"No ampliar la obra sin revisi\xF3n previa del departamento de PRL."),__gh("li",{"data-gufi-src":"page.tsx:289"},"No tocar ni manipular tanques de gasoil ni de aceite."),__gh("li",{"data-gufi-src":"page.tsx:290"},"El permiso solo vale para la zona, el trabajo y la fecha indicados."),__gh("li",{"data-gufi-src":"page.tsx:291"},"Orden, limpieza y EPI."),__gh("li",{"data-gufi-src":"page.tsx:292"},"Ante cualquier cambio o incidente, parar y avisar a PRL."),form.incluye_trabajos_de_corte&&__gh("li",{"data-gufi-src":"page.tsx:293"},__gh("strong",{"data-gufi-src":"page.tsx:293"},"Si hay corte:")," realizar antes los cuatro taladros."),(form.incluye_trabajos_de_corte||form.trabajo_en_caliente)&&__gh("li",{"data-gufi-src":"page.tsx:294"},__gh("strong",{"data-gufi-src":"page.tsx:294"},"Si hay corte o trabajo en caliente:")," retirar cables, forros e iluminarias si estorban."),form.trabajo_sala_maquinas&&__gh("li",{"data-gufi-src":"page.tsx:295"},__gh("strong",{"data-gufi-src":"page.tsx:295"},"Sala de m\xE1quinas:")," la sentina tiene que estar limpia antes de empezar."))),__gh("div",{className:"flex justify-between pt-2","data-gufi-src":"page.tsx:298"},__gh("button",{onClick:()=>setStep(1),className:"text-sm text-gray-600","data-gufi-src":"page.tsx:299"},"\u2190 Anterior"),__gh("button",{onClick:()=>setStep(3),className:"bg-blue-900 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:300"},"Siguiente \u2192"))),step===3&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:306"},__gh("h2",{className:"font-semibold text-slate-800","data-gufi-src":"page.tsx:307"},"Espacio confinado"),__gh("div",{className:"flex gap-4","data-gufi-src":"page.tsx:308"},__gh("label",{className:"flex items-center gap-2 text-sm","data-gufi-src":"page.tsx:309"},__gh("input",{type:"radio",name:"confinado",checked:form.espacio_confinado,onChange:()=>update("espacio_confinado",!0),"data-gufi-src":"page.tsx:310"})," S\xED"),__gh("label",{className:"flex items-center gap-2 text-sm","data-gufi-src":"page.tsx:312"},__gh("input",{type:"radio",name:"confinado",checked:!form.espacio_confinado,onChange:()=>update("espacio_confinado",!1),"data-gufi-src":"page.tsx:313"})," No")),form.espacio_confinado&&__gh("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3","data-gufi-src":"page.tsx:317"},__gh(Select,{label:"Tipo de espacio",value:form.tipo_espacio_confinado,onChange:v=>update("tipo_espacio_confinado",v),options:["Tanque de agua dulce/lastre","Gasoil","Aceite","Aguas grises","S\xE9ptico/aguas negras","Doble fondo","Pique","Cofferdam","Sentina","Otro"].map(x=>({value:x,label:x}))}),__gh(Select,{label:"Gas free",value:form.gas_free,onChange:v=>update("gas_free",v),options:[{value:"S\xED",label:"S\xED"},{value:"No",label:"No"}]}),__gh(Field,{label:"LIE (%)",type:"number",value:form.medicion_lie,onChange:v=>update("medicion_lie",v)}),__gh(Field,{label:"CO (ppm)",type:"number",value:form.medicion_co,onChange:v=>update("medicion_co",v)}),__gh(Field,{label:"O\u2082 (%)",type:"number",value:form.medicion_o2,onChange:v=>update("medicion_o2",v)}),__gh(Field,{label:"H\u2082S (ppm)",type:"number",value:form.medicion_h2s,onChange:v=>update("medicion_h2s",v)}),__gh(Field,{label:"Pr\xF3xima revisi\xF3n explos\xEDmetro",type:"date",value:form.fecha_proxima_revision_explosimetro,onChange:v=>update("fecha_proxima_revision_explosimetro",v)}),__gh("div",{className:"sm:col-span-2 flex flex-wrap gap-3","data-gufi-src":"page.tsx:327"},__gh(Checkbox,{label:"Explos\xEDmetro en condiciones",checked:form.explosimetro_condiciones,onChange:v=>update("explosimetro_condiciones",v)}),__gh(Checkbox,{label:"Atm\xF3sfera respirable",checked:form.control_atmosfera_respirable,onChange:v=>update("control_atmosfera_respirable",v)}),__gh(Checkbox,{label:"Libre de gas",checked:form.control_atmosfera_libre_gas,onChange:v=>update("control_atmosfera_libre_gas",v)}),__gh(Checkbox,{label:"Sin t\xF3xicos",checked:form.control_atmosfera_toxicos,onChange:v=>update("control_atmosfera_toxicos",v)}),__gh(Checkbox,{label:"Sin inflamables",checked:form.control_atmosfera_inflamables,onChange:v=>update("control_atmosfera_inflamables",v)}),__gh(Checkbox,{label:"Sin corrosivos",checked:form.control_atmosfera_corrosivos,onChange:v=>update("control_atmosfera_corrosivos",v)})),form.gas_free==="No"&&__gh("div",{className:"sm:col-span-2 bg-red-50 text-red-700 px-3 py-2 rounded text-sm font-semibold","data-gufi-src":"page.tsx:336"},"\u26A0\uFE0F Gas free en NO \u2014 revisar condiciones antes de autorizar.")),__gh("div",{className:"flex justify-between pt-2","data-gufi-src":"page.tsx:342"},__gh("button",{onClick:()=>setStep(2),className:"text-sm text-gray-600","data-gufi-src":"page.tsx:343"},"\u2190 Anterior"),__gh("button",{onClick:()=>setStep(4),className:"bg-blue-900 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:344"},"Siguiente \u2192"))),step===4&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:350"},__gh("h2",{className:"font-semibold text-slate-800","data-gufi-src":"page.tsx:351"},"Resumen y guardar"),__gh("div",{className:"text-sm text-gray-700 space-y-1","data-gufi-src":"page.tsx:352"},__gh("p",{"data-gufi-src":"page.tsx:353"},__gh("strong",{"data-gufi-src":"page.tsx:353"},"Buque:")," ",buquesData?.find(b=>String(b.id)===String(form.buque))?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:354"},__gh("strong",{"data-gufi-src":"page.tsx:354"},"Zona:")," ",zonasData?.find(z=>String(z.id)===String(form.zona_buque))?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:355"},__gh("strong",{"data-gufi-src":"page.tsx:355"},"Empresa:")," ",empresasData?.find(e=>String(e.id)===String(form.empresa))?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:356"},__gh("strong",{"data-gufi-src":"page.tsx:356"},"Fecha:")," ",form.fecha," \xB7 ",form.hora_inicio?.slice(0,5),"-",form.hora_fin?.slice(0,5)),__gh("p",{"data-gufi-src":"page.tsx:357"},__gh("strong",{"data-gufi-src":"page.tsx:357"},"Tipo:")," ",tipoSeleccionado?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:358"},__gh("strong",{"data-gufi-src":"page.tsx:358"},"Confinado:")," ",form.espacio_confinado?"S\xED":"No")),__gh("div",{className:"flex justify-between pt-2","data-gufi-src":"page.tsx:360"},__gh("button",{onClick:()=>setStep(3),className:"text-sm text-gray-600","data-gufi-src":"page.tsx:361"},"\u2190 Anterior"),__gh("button",{onClick:guardar,disabled:guardando,className:"bg-green-700 text-white px-5 py-2.5 rounded-lg text-sm font-semibold shadow hover:bg-green-800 disabled:opacity-50","data-gufi-src":"page.tsx:362"},guardando?"Guardando\u2026":"Guardar permiso")))))}function DetallePermiso({gufi,permisoId,buquesData,empresasData,tiposData,categoriasData,zonasData,onVolver,onNuevo}){let{data:permisosDet}=gufi.useData("prevencion__permisos_trabajo",{filter:`id=${permisoId}`}),permiso=permisosDet?.[0],{data:firmasDet}=gufi.useData("prevencion__firmas_permiso",{filter:`permiso=${permisoId}`}),firmasPermiso=firmasDet||[],[tab,setTab]=(0,import_react.useState)("datos"),[modoInforme,setModoInforme]=(0,import_react.useState)(!1);if(!permiso)return __gh("div",{className:"p-6 text-gray-500","data-gufi-src":"page.tsx:382"},"Cargando\u2026");let buque=buquesData?.find(b=>b.id===permiso.buque),empresa=empresasData?.find(e=>e.id===permiso.empresa),tipo=tiposData?.find(t=>t.id===permiso.tipo_trabajo),zona=zonasData?.find(z=>z.id===permiso.zona_buque);return modoInforme?__gh(InformePermiso,{permiso,buque,empresa,tipo,zona,firmas:firmasPermiso,onCerrar:()=>setModoInforme(!1),onNuevo}):__gh("div",{className:"min-h-screen bg-gray-50 pb-20","data-gufi-src":"page.tsx:405"},__gh("div",{className:"max-w-3xl mx-auto px-4 py-4","data-gufi-src":"page.tsx:406"},__gh("div",{className:"flex items-center justify-between mb-3","data-gufi-src":"page.tsx:407"},__gh("button",{onClick:onVolver,className:"text-sm text-gray-600 hover:text-gray-900","data-gufi-src":"page.tsx:408"},"\u2190 Volver al listado"),__gh("button",{onClick:()=>setModoInforme(!0),className:"text-sm bg-white border px-3 py-1.5 rounded-lg text-blue-900 font-medium hover:bg-gray-50","data-gufi-src":"page.tsx:409"},"\u{1F4C4} Ver informe")),__gh("div",{className:"bg-white rounded-xl border p-4 mb-3","data-gufi-src":"page.tsx:414"},__gh("div",{className:"flex items-center gap-2 mb-2","data-gufi-src":"page.tsx:415"},__gh("span",{className:`text-xs font-bold uppercase tracking-wide px-2 py-0.5 rounded ${permiso.estado==="V\xE1lido"?"bg-green-100 text-green-700":permiso.estado==="Finalizado"?"bg-gray-100 text-gray-700":permiso.estado==="Cancelado"?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700"}`,"data-gufi-src":"page.tsx:416"},permiso.estado),__gh("span",{className:"text-xs text-gray-500","data-gufi-src":"page.tsx:422"},permiso.numero_permiso)),__gh("h1",{className:"text-lg font-bold text-slate-900","data-gufi-src":"page.tsx:424"},buque?.nombre," \u2014 ",tipo?.nombre),__gh("p",{className:"text-sm text-gray-600","data-gufi-src":"page.tsx:425"},empresa?.nombre," \xB7 ",permiso.fecha," \xB7 ",permiso.hora_inicio?.slice(0,5),"-",permiso.hora_fin?.slice(0,5))),__gh("div",{className:"flex gap-1 overflow-x-auto pb-2 mb-3","data-gufi-src":"page.tsx:428"},[{k:"datos",l:"Datos"},{k:"riesgos",l:"Riesgos"},{k:"confinado",l:"Confinado"},{k:"firmas",l:"Firmas"},{k:"finalizar",l:"Finalizar"}].map(t=>__gh("button",{key:t.k,onClick:()=>setTab(t.k),className:`flex-1 min-w-[70px] text-xs py-2 rounded-lg font-medium transition ${tab===t.k?"bg-blue-900 text-white":"bg-white text-gray-600 border"}`,"data-gufi-src":"page.tsx:436"},t.l))),tab==="datos"&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-2 text-sm","data-gufi-src":"page.tsx:444"},__gh("p",{"data-gufi-src":"page.tsx:445"},__gh("strong",{"data-gufi-src":"page.tsx:445"},"Zona:")," ",zona?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:446"},__gh("strong",{"data-gufi-src":"page.tsx:446"},"Responsable empresa:")," ",permiso.responsable_empresa),__gh("p",{"data-gufi-src":"page.tsx:447"},__gh("strong",{"data-gufi-src":"page.tsx:447"},"Descripci\xF3n:")," ",permiso.descripcion_trabajo),__gh("div",{className:"flex flex-wrap gap-2 pt-2","data-gufi-src":"page.tsx:448"},permiso.trabajo_en_altura&&__gh("span",{className:"bg-yellow-50 text-yellow-700 px-2 py-0.5 rounded text-xs","data-gufi-src":"page.tsx:449"},"Altura"),permiso.trabajo_en_caliente&&__gh("span",{className:"bg-orange-50 text-orange-700 px-2 py-0.5 rounded text-xs","data-gufi-src":"page.tsx:450"},"Caliente"),permiso.incluye_trabajos_de_corte&&__gh("span",{className:"bg-red-50 text-red-700 px-2 py-0.5 rounded text-xs","data-gufi-src":"page.tsx:451"},"Corte"),permiso.trabajo_sala_maquinas&&__gh("span",{className:"bg-blue-50 text-blue-700 px-2 py-0.5 rounded text-xs","data-gufi-src":"page.tsx:452"},"Sala m\xE1quinas"))),tab==="riesgos"&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3 text-sm","data-gufi-src":"page.tsx:458"},__gh("div",{className:`inline-block px-3 py-1 rounded font-bold ${permiso.nivel_riesgo==="Muy alto"?"bg-red-100 text-red-700":permiso.nivel_riesgo==="Alto"?"bg-orange-100 text-orange-700":permiso.nivel_riesgo==="Medio"?"bg-yellow-100 text-yellow-700":"bg-green-100 text-green-700"}`,"data-gufi-src":"page.tsx:459"},"Riesgo: ",permiso.nivel_riesgo),__gh("ul",{className:"list-disc pl-5 space-y-1 text-gray-700","data-gufi-src":"page.tsx:465"},__gh("li",{"data-gufi-src":"page.tsx:466"},"Comprobar la zona de trabajo antes de empezar."),__gh("li",{"data-gufi-src":"page.tsx:467"},"No ampliar la obra sin revisi\xF3n previa de PRL."),__gh("li",{"data-gufi-src":"page.tsx:468"},"No tocar ni manipular tanques de gasoil ni de aceite."),__gh("li",{"data-gufi-src":"page.tsx:469"},"El permiso solo vale para la zona, trabajo y fecha indicados."),__gh("li",{"data-gufi-src":"page.tsx:470"},"Orden, limpieza y EPI."),__gh("li",{"data-gufi-src":"page.tsx:471"},"Ante cualquier cambio o incidente, parar y avisar a PRL."),permiso.incluye_trabajos_de_corte&&__gh("li",{"data-gufi-src":"page.tsx:472"},__gh("strong",{"data-gufi-src":"page.tsx:472"},"Corte:")," realizar antes los cuatro taladros."),(permiso.incluye_trabajos_de_corte||permiso.trabajo_en_caliente)&&__gh("li",{"data-gufi-src":"page.tsx:473"},__gh("strong",{"data-gufi-src":"page.tsx:473"},"Corte/caliente:")," retirar cables, forros e iluminarias si estorban."),permiso.trabajo_sala_maquinas&&__gh("li",{"data-gufi-src":"page.tsx:474"},__gh("strong",{"data-gufi-src":"page.tsx:474"},"Sala m\xE1quinas:")," sentina limpia antes de empezar."))),tab==="confinado"&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-2 text-sm","data-gufi-src":"page.tsx:480"},permiso.espacio_confinado?__gh(__gf,null,__gh("p",{"data-gufi-src":"page.tsx:483"},__gh("strong",{"data-gufi-src":"page.tsx:483"},"Tipo:")," ",permiso.tipo_espacio_confinado),__gh("p",{"data-gufi-src":"page.tsx:484"},__gh("strong",{"data-gufi-src":"page.tsx:484"},"Gas free:")," ",permiso.gas_free),__gh("div",{className:"grid grid-cols-2 gap-2","data-gufi-src":"page.tsx:485"},__gh("div",{className:`p-2 rounded ${(permiso.medicion_lie||0)<10?"bg-green-50":"bg-red-50"}`,"data-gufi-src":"page.tsx:486"},"LIE: ",permiso.medicion_lie,"% ",(permiso.medicion_lie||0)>=10&&__gh("span",{className:"text-red-600 font-bold","data-gufi-src":"page.tsx:487"},"NO entrar")),__gh("div",{className:`p-2 rounded ${(permiso.medicion_co||0)<25?"bg-green-50":"bg-red-50"}`,"data-gufi-src":"page.tsx:489"},"CO: ",permiso.medicion_co," ppm ",(permiso.medicion_co||0)>=25&&__gh("span",{className:"text-red-600 font-bold","data-gufi-src":"page.tsx:490"},"NO entrar")),__gh("div",{className:`p-2 rounded ${(permiso.medicion_o2||0)>=20.9&&(permiso.medicion_o2||0)<=23.5?"bg-green-50":"bg-red-50"}`,"data-gufi-src":"page.tsx:492"},"O\u2082: ",permiso.medicion_o2,"% ",((permiso.medicion_o2||0)<20.9||(permiso.medicion_o2||0)>23.5)&&__gh("span",{className:"text-red-600 font-bold","data-gufi-src":"page.tsx:493"},"NO entrar")),__gh("div",{className:`p-2 rounded ${(permiso.medicion_h2s||0)<10?"bg-green-50":"bg-red-50"}`,"data-gufi-src":"page.tsx:495"},"H\u2082S: ",permiso.medicion_h2s," ppm ",(permiso.medicion_h2s||0)>=10&&__gh("span",{className:"text-red-600 font-bold","data-gufi-src":"page.tsx:496"},"NO entrar"))),permiso.gas_free==="No"&&__gh("div",{className:"bg-red-50 text-red-700 px-3 py-2 rounded font-semibold","data-gufi-src":"page.tsx:500"},"\u26A0\uFE0F Gas free en NO")):__gh("p",{className:"text-gray-500","data-gufi-src":"page.tsx:504"},"No aplica espacio confinado.")),tab==="firmas"&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:510"},__gh(FirmasPanel,{gufi,permisoId,firmas:firmasPermiso,permiso})),tab==="finalizar"&&__gh("div",{className:"bg-white rounded-xl border p-4 space-y-3","data-gufi-src":"page.tsx:516"},__gh("h3",{className:"font-semibold text-slate-800","data-gufi-src":"page.tsx:517"},"Finalizaci\xF3n del trabajo"),__gh("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3","data-gufi-src":"page.tsx:518"},__gh(Field,{label:"Hora de finalizaci\xF3n",type:"time",value:permiso.hora_finalizacion||"",onChange:v=>gufi.update("prevencion__permisos_trabajo",permiso.id,{hora_finalizacion:v})})),__gh("div",{"data-gufi-src":"page.tsx:522"},__gh("label",{className:"block text-sm font-medium text-gray-700 mb-1","data-gufi-src":"page.tsx:523"},"Observaciones"),__gh("textarea",{className:"w-full border rounded-lg px-3 py-2 text-sm",rows:3,value:permiso.observaciones_finalizacion||"",onChange:e=>gufi.update("prevencion__permisos_trabajo",permiso.id,{observaciones_finalizacion:e.target.value}),"data-gufi-src":"page.tsx:524"})),__gh("div",{className:"flex gap-2 pt-2","data-gufi-src":"page.tsx:528"},__gh("button",{onClick:()=>gufi.update("prevencion__permisos_trabajo",permiso.id,{estado:"Finalizado"}),className:"bg-green-700 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:529"},"Marcar como finalizado"),__gh("button",{onClick:()=>gufi.update("prevencion__permisos_trabajo",permiso.id,{estado:"Cancelado"}),className:"bg-red-700 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:531"},"Cancelar permiso")))))}function InformePermiso({permiso,buque,empresa,tipo,zona,firmas,onCerrar,onNuevo}){let imprimir=()=>window.print(),firmasPorTipo=tf=>firmas.filter(f=>f.tipo_firma===tf);return __gh("div",{className:"min-h-screen bg-white","data-gufi-src":"page.tsx:547"},__gh("div",{className:"max-w-3xl mx-auto px-6 py-8","data-gufi-src":"page.tsx:548"},__gh("div",{className:"print:hidden flex flex-wrap gap-2 mb-6","data-gufi-src":"page.tsx:550"},__gh("button",{onClick:imprimir,className:"bg-blue-900 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:551"},"\u{1F5A8}\uFE0F Imprimir"),__gh("button",{onClick:imprimir,className:"bg-blue-800 text-white px-4 py-2 rounded-lg text-sm font-semibold","data-gufi-src":"page.tsx:552"},"\u2B07\uFE0F Descargar PDF"),__gh("button",{onClick:onCerrar,className:"bg-white border px-4 py-2 rounded-lg text-sm font-medium text-gray-700","data-gufi-src":"page.tsx:553"},"\u2190 Volver al permiso"),__gh("button",{onClick:onNuevo,className:"bg-green-700 text-white px-4 py-2 rounded-lg text-sm font-semibold ml-auto","data-gufi-src":"page.tsx:554"},"+ Nuevo permiso")),__gh("div",{className:"flex items-center justify-between border-b pb-4 mb-6","data-gufi-src":"page.tsx:558"},__gh("div",{"data-gufi-src":"page.tsx:559"},__gh("div",{className:"text-2xl font-bold text-blue-900","data-gufi-src":"page.tsx:560"},"PREVENCI\xD3N"),__gh("div",{className:"text-sm text-gray-500","data-gufi-src":"page.tsx:561"},"Permisos de trabajo")),__gh("div",{className:"h-16 w-32 bg-gray-100 border-2 border-dashed border-gray-300 flex items-center justify-center text-xs text-gray-400 rounded","data-gufi-src":"page.tsx:563"},"LOGO")),__gh("h1",{className:"text-xl font-bold text-slate-900 mb-1","data-gufi-src":"page.tsx:568"},"Informe de Permiso de Trabajo"),__gh("p",{className:"text-sm text-gray-500 mb-6","data-gufi-src":"page.tsx:569"},permiso.numero_permiso," \xB7 ",permiso.fecha),__gh("div",{className:`inline-block px-3 py-1 rounded text-sm font-bold mb-6 ${permiso.estado==="V\xE1lido"?"bg-green-100 text-green-700":permiso.estado==="Finalizado"?"bg-gray-100 text-gray-700":permiso.estado==="Cancelado"?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700"}`,"data-gufi-src":"page.tsx:572"},"ESTADO: ",permiso.estado),__gh("div",{className:"space-y-6 text-sm","data-gufi-src":"page.tsx:581"},__gh("section",{"data-gufi-src":"page.tsx:582"},__gh("h2",{className:"text-base font-bold text-slate-800 border-b pb-1 mb-2","data-gufi-src":"page.tsx:583"},"1. Datos del permiso"),__gh("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-y-2 gap-x-4","data-gufi-src":"page.tsx:584"},__gh("p",{"data-gufi-src":"page.tsx:585"},__gh("strong",{"data-gufi-src":"page.tsx:585"},"Buque:")," ",buque?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:586"},__gh("strong",{"data-gufi-src":"page.tsx:586"},"Zona:")," ",zona?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:587"},__gh("strong",{"data-gufi-src":"page.tsx:587"},"Empresa:")," ",empresa?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:588"},__gh("strong",{"data-gufi-src":"page.tsx:588"},"Responsable:")," ",permiso.responsable_empresa),__gh("p",{"data-gufi-src":"page.tsx:589"},__gh("strong",{"data-gufi-src":"page.tsx:589"},"Fecha:")," ",permiso.fecha),__gh("p",{"data-gufi-src":"page.tsx:590"},__gh("strong",{"data-gufi-src":"page.tsx:590"},"Horario:")," ",permiso.hora_inicio?.slice(0,5)," - ",permiso.hora_fin?.slice(0,5)),__gh("p",{"data-gufi-src":"page.tsx:591"},__gh("strong",{"data-gufi-src":"page.tsx:591"},"Tipo de trabajo:")," ",tipo?.nombre||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:592"},__gh("strong",{"data-gufi-src":"page.tsx:592"},"Nivel de riesgo:")," ",permiso.nivel_riesgo)),__gh("p",{className:"mt-2","data-gufi-src":"page.tsx:594"},__gh("strong",{"data-gufi-src":"page.tsx:594"},"Descripci\xF3n:")," ",permiso.descripcion_trabajo),__gh("div",{className:"flex flex-wrap gap-2 mt-2","data-gufi-src":"page.tsx:595"},permiso.trabajo_en_altura&&__gh("span",{className:"bg-yellow-50 text-yellow-700 px-2 py-0.5 rounded text-xs border","data-gufi-src":"page.tsx:596"},"Altura"),permiso.trabajo_en_caliente&&__gh("span",{className:"bg-orange-50 text-orange-700 px-2 py-0.5 rounded text-xs border","data-gufi-src":"page.tsx:597"},"Caliente"),permiso.incluye_trabajos_de_corte&&__gh("span",{className:"bg-red-50 text-red-700 px-2 py-0.5 rounded text-xs border","data-gufi-src":"page.tsx:598"},"Corte"),permiso.trabajo_sala_maquinas&&__gh("span",{className:"bg-blue-50 text-blue-700 px-2 py-0.5 rounded text-xs border","data-gufi-src":"page.tsx:599"},"Sala m\xE1quinas"),permiso.espacio_confinado&&__gh("span",{className:"bg-purple-50 text-purple-700 px-2 py-0.5 rounded text-xs border","data-gufi-src":"page.tsx:600"},"Confinado"))),__gh("section",{"data-gufi-src":"page.tsx:604"},__gh("h2",{className:"text-base font-bold text-slate-800 border-b pb-1 mb-2","data-gufi-src":"page.tsx:605"},"2. Evaluaci\xF3n de riesgos y normas obligatorias"),__gh("ul",{className:"list-disc pl-5 space-y-1 text-gray-700","data-gufi-src":"page.tsx:606"},__gh("li",{"data-gufi-src":"page.tsx:607"},"Comprobar la zona de trabajo antes de empezar."),__gh("li",{"data-gufi-src":"page.tsx:608"},"No ampliar la obra sin revisi\xF3n previa de PRL."),__gh("li",{"data-gufi-src":"page.tsx:609"},"No tocar ni manipular tanques de gasoil ni de aceite."),__gh("li",{"data-gufi-src":"page.tsx:610"},"El permiso solo vale para la zona, trabajo y fecha indicados."),__gh("li",{"data-gufi-src":"page.tsx:611"},"Orden, limpieza y EPI."),__gh("li",{"data-gufi-src":"page.tsx:612"},"Ante cualquier cambio o incidente, parar y avisar a PRL."),permiso.incluye_trabajos_de_corte&&__gh("li",{"data-gufi-src":"page.tsx:613"},__gh("strong",{"data-gufi-src":"page.tsx:613"},"Si hay corte:")," realizar antes los cuatro taladros."),(permiso.incluye_trabajos_de_corte||permiso.trabajo_en_caliente)&&__gh("li",{"data-gufi-src":"page.tsx:614"},__gh("strong",{"data-gufi-src":"page.tsx:614"},"Corte/caliente:")," retirar cables, forros e iluminarias si estorban."),permiso.trabajo_sala_maquinas&&__gh("li",{"data-gufi-src":"page.tsx:615"},__gh("strong",{"data-gufi-src":"page.tsx:615"},"Sala m\xE1quinas:")," sentina limpia antes de empezar."))),permiso.espacio_confinado&&__gh("section",{"data-gufi-src":"page.tsx:620"},__gh("h2",{className:"text-base font-bold text-slate-800 border-b pb-1 mb-2","data-gufi-src":"page.tsx:621"},"3. Espacio confinado"),__gh("div",{className:"grid grid-cols-2 gap-2 text-sm","data-gufi-src":"page.tsx:622"},__gh("p",{"data-gufi-src":"page.tsx:623"},__gh("strong",{"data-gufi-src":"page.tsx:623"},"Tipo:")," ",permiso.tipo_espacio_confinado),__gh("p",{"data-gufi-src":"page.tsx:624"},__gh("strong",{"data-gufi-src":"page.tsx:624"},"Gas free:")," ",permiso.gas_free),__gh("p",{"data-gufi-src":"page.tsx:625"},"LIE: ",permiso.medicion_lie,"%"),__gh("p",{"data-gufi-src":"page.tsx:626"},"CO: ",permiso.medicion_co," ppm"),__gh("p",{"data-gufi-src":"page.tsx:627"},"O\u2082: ",permiso.medicion_o2,"%"),__gh("p",{"data-gufi-src":"page.tsx:628"},"H\u2082S: ",permiso.medicion_h2s," ppm")),permiso.gas_free==="No"&&__gh("div",{className:"mt-2 bg-red-50 text-red-700 px-3 py-2 rounded font-semibold text-sm","data-gufi-src":"page.tsx:631"},"\u26A0\uFE0F Gas free en NO")),__gh("section",{"data-gufi-src":"page.tsx:636"},__gh("h2",{className:"text-base font-bold text-slate-800 border-b pb-1 mb-2","data-gufi-src":"page.tsx:637"},permiso.espacio_confinado?"4":"3",". Firmas y autorizaciones"),__gh("div",{className:"grid gap-3","data-gufi-src":"page.tsx:638"},["Jefe de buque","Responsable subcontrata","Recurso preventivo","Vigilante de fuego","Trabajador","Responsable PRL"].map(tf=>{let fs=firmasPorTipo(tf);return __gh("div",{key:tf,className:"border rounded-lg p-3","data-gufi-src":"page.tsx:642"},__gh("div",{className:"font-semibold text-slate-700 text-sm mb-1","data-gufi-src":"page.tsx:643"},tf),fs.length===0&&__gh("span",{className:"text-xs text-gray-400","data-gufi-src":"page.tsx:644"},"Pendiente"),fs.map((f,i)=>__gh("div",{key:i,className:"flex justify-between text-sm py-1 border-t","data-gufi-src":"page.tsx:646"},__gh("span",{"data-gufi-src":"page.tsx:647"},f.nombre," ",f.puesto&&`(${f.puesto})`),__gh("span",{className:"text-green-600 text-xs","data-gufi-src":"page.tsx:648"},"\u2713 ",f.fecha_firma))))}))),permiso.estado==="Finalizado"&&__gh("section",{"data-gufi-src":"page.tsx:658"},__gh("h2",{className:"text-base font-bold text-slate-800 border-b pb-1 mb-2","data-gufi-src":"page.tsx:659"},"Finalizaci\xF3n"),__gh("p",{"data-gufi-src":"page.tsx:660"},__gh("strong",{"data-gufi-src":"page.tsx:660"},"Hora de finalizaci\xF3n:")," ",permiso.hora_finalizacion?.slice(0,5)||"\u2014"),__gh("p",{"data-gufi-src":"page.tsx:661"},__gh("strong",{"data-gufi-src":"page.tsx:661"},"Observaciones:")," ",permiso.observaciones_finalizacion||"\u2014"))),__gh("div",{className:"mt-10 pt-4 border-t text-center text-xs text-gray-400 print:hidden","data-gufi-src":"page.tsx:666"},"Documento generado desde Gufi \xB7 PREVENCI\xD3N")))}function FirmasPanel({gufi,permisoId,firmas,permiso}){let[tipo,setTipo]=(0,import_react.useState)("Trabajador"),[nombre,setNombre]=(0,import_react.useState)(""),[puesto,setPuesto]=(0,import_react.useState)(""),addFirma=async()=>{nombre&&(await gufi.create("prevencion__firmas_permiso",{permiso:permisoId,tipo_firma:tipo,nombre,puesto,acepto:!0,fecha_firma:new Date().toISOString().slice(0,10)}),setNombre(""),setPuesto(""))},tiposFirma=["Jefe de buque","Responsable subcontrata","Recurso preventivo","Vigilante de fuego","Trabajador","Responsable PRL"];return __gh("div",{className:"space-y-3","data-gufi-src":"page.tsx:696"},__gh("div",{className:"space-y-2","data-gufi-src":"page.tsx:697"},tiposFirma.map(tf=>{let fs=firmas.filter(f=>f.tipo_firma===tf);return __gh("div",{key:tf,className:"border rounded-lg p-3","data-gufi-src":"page.tsx:701"},__gh("div",{className:"flex items-center justify-between mb-1","data-gufi-src":"page.tsx:702"},__gh("span",{className:"text-sm font-semibold text-slate-700","data-gufi-src":"page.tsx:703"},tf),__gh("span",{className:"text-xs text-gray-500","data-gufi-src":"page.tsx:704"},fs.length," firma",fs.length!==1?"s":"")),fs.map((f,i)=>__gh("div",{key:i,className:"flex items-center justify-between text-sm py-1 border-t","data-gufi-src":"page.tsx:707"},__gh("span",{"data-gufi-src":"page.tsx:708"},f.nombre," ",f.puesto&&`(${f.puesto})`),__gh("span",{className:"text-green-600 text-xs font-medium","data-gufi-src":"page.tsx:709"},"\u2713 ",f.fecha_firma))))})),__gh("div",{className:"bg-gray-50 rounded-lg p-3 space-y-2","data-gufi-src":"page.tsx:717"},__gh("p",{className:"text-xs font-semibold text-gray-600 uppercase","data-gufi-src":"page.tsx:718"},"A\xF1adir firma"),__gh("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2","data-gufi-src":"page.tsx:719"},__gh("select",{className:"border rounded-lg px-2 py-1.5 text-sm",value:tipo,onChange:e=>setTipo(e.target.value),"data-gufi-src":"page.tsx:720"},tiposFirma.map(t=>__gh("option",{key:t,value:t,"data-gufi-src":"page.tsx:721"},t))),__gh("input",{className:"border rounded-lg px-2 py-1.5 text-sm",placeholder:"Nombre",value:nombre,onChange:e=>setNombre(e.target.value),"data-gufi-src":"page.tsx:723"}),__gh("input",{className:"border rounded-lg px-2 py-1.5 text-sm",placeholder:"Puesto",value:puesto,onChange:e=>setPuesto(e.target.value),"data-gufi-src":"page.tsx:724"})),__gh("button",{onClick:addFirma,className:"bg-blue-900 text-white px-3 py-1.5 rounded text-sm font-medium","data-gufi-src":"page.tsx:726"},"A\xF1adir firma")),permiso.estado!=="V\xE1lido"&&__gh("button",{onClick:()=>{if(!firmas.some(f=>f.tipo_firma==="Responsable subcontrata"||f.tipo_firma==="Jefe de buque")){alert("Falta firma de Producci\xF3n");return}gufi.update("prevencion__permisos_trabajo",permiso.id,{estado:"V\xE1lido"})},className:"w-full bg-green-700 text-white py-2.5 rounded-lg text-sm font-semibold shadow hover:bg-green-800","data-gufi-src":"page.tsx:730"},"Activar permiso (firma PRL)"))}function Field({label,type="text",value,onChange}){return __gh("div",{"data-gufi-src":"page.tsx:747"},__gh("label",{className:"block text-sm font-medium text-gray-700 mb-1","data-gufi-src":"page.tsx:748"},label),__gh("input",{type,className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-900",value,onChange:e=>onChange(e.target.value),"data-gufi-src":"page.tsx:749"}))}function Select({label,value,onChange,options}){return __gh("div",{"data-gufi-src":"page.tsx:761"},__gh("label",{className:"block text-sm font-medium text-gray-700 mb-1","data-gufi-src":"page.tsx:762"},label),__gh("select",{className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-blue-900",value,onChange:e=>onChange(e.target.value),"data-gufi-src":"page.tsx:763"},__gh("option",{value:"","data-gufi-src":"page.tsx:768"},"Selecciona\u2026"),options.map((o,i)=>__gh("option",{key:i,value:o.value,"data-gufi-src":"page.tsx:770"},o.label))))}function Checkbox({label,checked,onChange}){return __gh("label",{className:"flex items-center gap-2 text-sm text-gray-700 cursor-pointer select-none","data-gufi-src":"page.tsx:779"},__gh("input",{type:"checkbox",checked,onChange:e=>onChange(e.target.checked),className:"w-4 h-4 rounded border-gray-300 text-blue-900 focus:ring-blue-900","data-gufi-src":"page.tsx:780"}),label)}var featureConfig={dataSources,meta:{name:"Permisos de trabajo",version:"1.0.0"}};var stdin_default=PermisosDeTrabajo;