PageSourceSearch

https://qms-latam.web.app/chunk-VDMDM4NZ.js

js qms-latam.web.app collected 2026-10-03 12:35:27 UTC 17,405 bytes, 1 lines download raw bytes

1import{a as W}from"./chunk-GIVWUGBJ.js";import{a as j,b as A}from"./chunk-Q6M6YZ3M.js";import{d as K,i as H,k as J}from"./chunk-DWVJDDS7.js";import{a as V,b as L}from"./chunk-PFCMQEVF.js";import{a as q,b as G}from"./chunk-IDEAKGW5.js";import{d as z}from"./chunk-W6FX6UGG.js";import{X as F,Z as R,aa as $}from"./chunk-SLCKCR7G.js";import{h as k,i as E,j as T,n as D,q as N}from"./chunk-HR6GJLZI.js";import{Eb as g,Lc as S,Mb as l,Nc as I,Ob as C,Xb as o,Yb as r,Zb as B,bc as w,gc as _,hc as m,ia as y,lb as c,sa as x,ta as h,tc as a,uc as v,vc as b,xc as O,yb as P}from"./chunk-RYF6LHOX.js";function Q(d,t){if(d&1&&(o(0,"p",9),a(1),r()),d&2){let e=m();c(),O(" ",e.borradores.length," borrador",e.borradores.length!==1?"es":""," guardado",e.borradores.length!==1?"s":""," ")}}function X(d,t){d&1&&(o(0,"div",10),B(1,"mat-spinner",11),o(2,"p",12),a(3,"Buscando borradores..."),r()())}function Y(d,t){d&1&&(o(0,"div",13)(1,"div",14)(2,"mat-icon"),a(3,"inbox"),r()(),o(4,"p",15),a(5,"Sin borradores"),r(),o(6,"p",12),a(7,"No se encontraron borradores guardados localmente."),r()())}function Z(d,t){d&1&&(o(0,"mat-icon"),a(1,"assignment"),r())}function ee(d,t){d&1&&(o(0,"mat-icon"),a(1,"description"),r())}function te(d,t){if(d&1){let e=w();o(0,"div",20),_("click",function(){let i=x(e).$implicit,s=m(2);return h(s.seleccionarBorrador(i))}),o(1,"div",21),g(2,Z,2,0,"mat-icon",22)(3,ee,2,0,"mat-icon",22),r(),o(4,"div",23)(5,"span",24),a(6),r(),o(7,"div",25)(8,"span",26),a(9),r(),o(10,"span",27)(11,"mat-icon",28),a(12,"save"),r(),a(13," Local "),r(),o(14,"span",29),a(15),r()()(),o(16,"div",30)(17,"button",31),_("click",function(i){let s=x(e).$implicit;return m(2).cargarBorrador(s),h(i.stopPropagation())}),o(18,"mat-icon"),a(19,"restore"),r()(),o(20,"button",32),_("click",function(i){let s=x(e).$implicit,p=m(2);return h(p.eliminarBorrador(s,i))}),o(21,"mat-icon"),a(22,"delete_outline"),r()()()()}if(d&2){let e=t.$implicit,n=m(2);C("selected",(n.selectedBorrador==null?null:n.selectedBorrador.key)===e.key),c(2),l("ngIf",e.draftType==="plan"),c(),l("ngIf",e.draftType==="informe"),c(3),v(e.empresa),c(2),l("ngClass","badge-"+e.draftType),c(),b(" ",e.draftType==="plan"?"Plan":"Informe"," "),c(6),v(e.relativeTime)}}function ne(d,t){if(d&1&&(o(0,"div",37)(1,"span",38),a(2,"ID Auditor\xEDa"),r(),o(3,"span",45),a(4),r()()),d&2){let e=m(3);c(4),b("#",e.selectedBorrador.auditoriaId,"")}}function ie(d,t){if(d&1&&(o(0,"span",49)(1,"mat-icon",50),a(2,"check_circle"),r(),a(3),r()),d&2){let e=t.$implicit;c(3),b(" ",e," ")}}function oe(d,t){if(d&1&&(o(0,"div",46)(1,"span",38),a(2,"Secciones con cambios"),r(),o(3,"div",47),g(4,ie,4,1,"span",48),r()()),d&2){let e=m(3);c(4),l("ngForOf",e.selectedBorrador.sections)}}function re(d,t){d&1&&(o(0,"div",46)(1,"span",38),a(2,"Secciones"),r(),o(3,"span",51),a(4,"Sin informaci\xF3n de secciones"),r()())}function ae(d,t){if(d&1){let e=w();o(0,"div",33)(1,"div",34)(2,"div",35)(3,"mat-icon",36),a(4,"visibility"),r(),o(5,"span"),a(6,"Vista Previa"),r()(),o(7,"div",37)(8,"span",38),a(9,"Empresa"),r(),o(10,"span",39),a(11),r()(),o(12,"div",37)(13,"span",38),a(14,"Tipo"),r(),o(15,"span",39)(16,"span",26),a(17),r()()(),o(18,"div",37)(19,"span",38),a(20,"\xDAltima modificaci\xF3n"),r(),o(21,"span",39),a(22),S(23,"date"),r()(),g(24,ne,5,1,"div",40)(25,oe,5,1,"div",41)(26,re,5,0,"div",41),o(27,"div",42)(28,"button",43),_("click",function(){x(e);let i=m(2);return h(i.cargarBorrador(i.selectedBorrador))}),o(29,"mat-icon"),a(30,"restore"),r(),a(31," Restaurar Borrador "),r(),o(32,"button",44),_("click",function(i){x(e);let s=m(2);return h(s.eliminarBorrador(s.selectedBorrador,i))}),o(33,"mat-icon"),a(34,"delete_outline"),r(),a(35," Eliminar "),r()()()()}if(d&2){let e=m(2);c(11),v(e.selectedBorrador.empresa),c(5),l("ngClass","badge-"+e.selectedBorrador.draftType),c(),b(" ",e.selectedBorrador.draftType==="plan"?"Plan de Auditor\xEDa":"Informe de Auditor\xEDa"," "),c(5),v(e.selectedBorrador.fecha?I(23,7,e.selectedBorrador.fecha,"dd/MM/yyyy HH:mm"):"Fecha no disponible"),c(2),l("ngIf",e.selectedBorrador.auditoriaId&&e.selectedBorrador.auditoriaId!=="new"),c(),l("ngIf",e.selectedBorrador.sections&&e.selectedBorrador.sections.length>0),c(),l("ngIf",!e.selectedBorrador.sections||e.selectedBorrador.sections.length===0)}}function de(d,t){if(d&1&&(o(0,"div",16)(1,"div",17),g(2,te,23,8,"div",18),r(),g(3,ae,36,10,"div",19),r()),d&2){let e=m();c(),C("has-preview",e.selectedBorrador),c(),l("ngForOf",e.borradores),c(),l("ngIf",e.selectedBorrador)}}var U=class d{constructor(){this.dialogRef=y(K);this.snackBar=y(W);this.router=y(z);this.borradores=[];this.selectedBorrador=null;this.loading=!0}ngOnInit(){this.cargarBorradores()}cargarBorradores(){this.loading=!0,this.borradores=[];try{for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);if(e){if(e.startsWith("audit_plan_draft_"))try{let n=localStorage.getItem(e);if(!n)continue;let i=JSON.parse(n);if(!i||typeof i!="object")continue;let s=i.metadata?.fecha_creacion||i.timestamp||i.fecha||"",p=this.normalizeDate(s),f=i.metadata?.empresa_nombre||i.empresa_nombre||i.form?.empresa?.razon_social||(typeof i.form?.empresa=="string"?i.form.empresa:null)||"Plan de Auditor\xEDa",M=i.metadata?.auditoria_id||this.extractIdFromPlanKey(e)||"new",u=i.metadata?.sectionsWithChanges||[];(!u||u.length===0)&&(u=this.detectPlanSections(i)),this.borradores.push({key:e,empresa:f,fecha:p,auditoriaId:M,type:"Local",draftType:"plan",sections:u,data:i,relativeTime:this.getRelativeTime(p)})}catch(n){console.warn("Error al procesar borrador de plan:",e,n)}if(e.startsWith("informe_draft_")||e.startsWith("audit_draft_"))try{let n=localStorage.getItem(e);if(!n)continue;let i=JSON.parse(n);if(!i||typeof i!="object")continue;let s=e.replace("informe_draft_","").replace("audit_draft_",""),p=i.timestamp||i.fecha||i.metadata?.fecha_creacion||"",f=this.normalizeDate(p),M=this.detectInformeSections(i),u=i.empresa_nombre||i.metadata?.empresa_nombre||i.auditoria?.empresa?.razon_social||(s&&s!=="new"?`Auditor\xEDa #${s}`:"Informe de Auditor\xEDa");this.borradores.push({key:e,empresa:u,fecha:f,auditoriaId:s||"new",type:"Local",draftType:"informe",sections:M,data:i,relativeTime:this.getRelativeTime(f)})}catch(n){console.warn("Error al procesar borrador de informe:",e,n)}}}this.borradores.sort((t,e)=>{let n=t.fecha?new Date(t.fecha).getTime():0,i=e.fecha?new Date(e.fecha).getTime():0;return(isNaN(i)?0:i)-(isNaN(n)?0:n)})}catch(t){console.error("Error accediendo a localStorage de borradores:",t)}finally{this.loading=!1}}extractIdFromPlanKey(t){let e=t.replace("audit_plan_draft_","").split("_");return e.length>=2?e[1]:e[0]||"new"}detectPlanSections(t){let e=[],n=t.form||t;return(n.empresa||n.auditorLider)&&e.push("Informaci\xF3n General"),n.fechas?.length>
10&&e.push("Planificaci\xF3n/Fechas"),(t.normasSeleccionadas?.length>0||n.normas?.length>0)&&e.push("Normas/Requisitos"),t.actividadesPorDia&&Object.keys(t.actividadesPorDia).length>0&&e.push("Requisitos/Cronograma"),e}detectInformeSections(t){let e=[],n=t.form||t;return(n.no_conformidades_grupos?.length>0||n.no_conformidades?.length>0)&&e.push("No Conformidades"),n.oportunidades_mejora?.length>0&&e.push("Oportunidades de Mejora"),n.conformidades?.length>0&&e.push("Conformidades"),n.conclusiones?.length>0&&e.push("Conclusiones"),n.participantes?.length>0&&e.push("Participantes"),(n.imagenes_grupos?.length>0||n.imagenes?.length>0)&&e.push("Im\xE1genes"),t.sitios?.length>0&&e.push("Sitios/Servicios"),e}normalizeDate(t){if(!t)return"";try{if(typeof t=="number"){let e=new Date(t);return isNaN(e.getTime())?"":e.toISOString()}if(typeof t=="string"){if(/^\d{10,13}$/.test(t.trim())){let n=new Date(Number(t.trim()));return isNaN(n.getTime())?"":n.toISOString()}let e=new Date(t);return isNaN(e.getTime())?"":e.toISOString()}return""}catch{return""}}cargarBorrador(t){if(this.dialogRef.close(),t.draftType==="informe"){t.auditoriaId&&t.auditoriaId!=="new"&&t.auditoriaId!=="nuevo"&&this.router.navigate(["/profile/dashboard/auditorias/informe",t.auditoriaId],{state:{restoreDraft:!0,draftKey:t.key}});return}t.auditoriaId&&t.auditoriaId!=="new"&&t.auditoriaId!=="nuevo"&&t.auditoriaId!=="undefined"&&t.auditoriaId!=="null"?this.router.navigate(["/profile/dashboard/auditorias/plan",t.auditoriaId],{state:{restoreDraft:!0,draftKey:t.key}}):this.router.navigate(["/profile/dashboard/auditorias/plan/nuevo"],{state:{restoreDraft:!0,draftKey:t.key}})}eliminarBorrador(t,e){e.stopPropagation();let n=localStorage.getItem(t.key);localStorage.removeItem(t.key),this.selectedBorrador?.key===t.key&&(this.selectedBorrador=null),this.cargarBorradores(),this.snackBar.open(`Borrador "${t.empresa}" eliminado`,"Deshacer",{duration:5e3}).onAction().subscribe(()=>{n&&(localStorage.setItem(t.key,n),this.cargarBorradores(),this.snackBar.open("Borrador restaurado","OK",{duration:2e3}))})}seleccionarBorrador(t){this.selectedBorrador=this.selectedBorrador?.key===t.key?null:t}cerrar(){this.dialogRef.close()}getRelativeTime(t){if(!t)return"";try{let e;if(typeof t=="string"&&/^\d{10,13}$/.test(t.trim())?e=new Date(Number(t.trim())):e=new Date(t),isNaN(e.getTime()))return"";let i=new Date().getTime()-e.getTime();if(i<0)return"Justo ahora";let s=Math.floor(i/6e4),p=Math.floor(s/60),f=Math.floor(p/24);return s<1?"Justo ahora":s<60?`Hace ${s} min`:p<24?`Hace ${p} hr${p>1?"s":""}`:f<7?`Hace ${f} d\xEDa${f>1?"s":""}`:e.toLocaleDateString("es-ES",{day:"2-digit",month:"short"})}catch{return""}}static{this.\u0275fac=function(e){return new(e||d)}}static{this.\u0275cmp=P({type:d,selectors:[["app-borradores-modal"]],decls:16,vars:4,consts:[[1,"dialog-header"],[1,"header-content"],[1,"header-icon"],["class","header-subtitle",4,"ngIf"],["mat-icon-button","","matTooltip","Cerrar",1,"close-btn",3,"click"],[1,"dialog-body"],["class","state-container",4,"ngIf"],["class","state-container empty-state",4,"ngIf"],["class","borradores-layout",4,"ngIf"],[1,"header-subtitle"],[1,"state-container"],["diameter","36"],[1,"state-text"],[1,"state-container","empty-state"],[1,"empty-icon"],[1,"state-title"],[1,"borradores-layout"],[1,"list-col"],["class","draft-card",3,"selected","click",4,"ngFor","ngForOf"],["class","preview-col",4,"ngIf"],[1,"draft-card",3,"click"],[1,"draft-card-icon"],[4,"ngIf"],[1,"draft-card-body"],[1,"draft-empresa"],[1,"draft-meta"],[1,"draft-badge",3,"ngClass"],[1,"draft-badge","badge-local"],[1,"badge-icon"],[1,"draft-time"],[1,"draft-card-actions"],["mat-icon-button","","matTooltip","Re
1staurar Borrador",1,"action-restore",3,"click"],["mat-icon-button","","matTooltip","Eliminar Borrador",1,"action-delete",3,"click"],[1,"preview-col"],[1,"preview-panel"],[1,"preview-header"],[1,"preview-header-icon"],[1,"preview-field"],[1,"preview-label"],[1,"preview-value"],["class","preview-field",4,"ngIf"],["class","preview-sections",4,"ngIf"],[1,"preview-actions"],["mat-flat-button","","color","primary",1,"action-btn",3,"click"],["mat-stroked-button","","color","warn",1,"action-btn",3,"click"],[1,"preview-value","mono"],[1,"preview-sections"],[1,"section-chips"],["class","section-chip",4,"ngFor","ngForOf"],[1,"section-chip"],[1,"chip-icon"],[1,"preview-value","text-muted"]],template:function(e,n){e&1&&(o(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),a(4,"drafts"),r()(),o(5,"div")(6,"h2"),a(7,"Mis Borradores"),r(),g(8,Q,2,3,"p",3),r()(),o(9,"button",4),_("click",function(){return n.cerrar()}),o(10,"mat-icon"),a(11,"close"),r()()(),o(12,"mat-dialog-content",5),g(13,X,4,0,"div",6)(14,Y,8,0,"div",7)(15,de,4,4,"div",8),r()),e&2&&(c(8),l("ngIf",n.borradores.length>0),c(5),l("ngIf",n.loading),c(),l("ngIf",!n.loading&&n.borradores.length===0),c(),l("ngIf",!n.loading&&n.borradores.length>0))},dependencies:[N,k,E,T,D,J,H,$,R,F,L,V,G,q,A,j],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block}.dialog-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:20px 24px 12px}.header-content[_ngcontent-%COMP%]{display:flex;align-items:center;gap:14px}.header-icon[_ngcontent-%COMP%]{width:44px;height:44px;border-radius:12px;background:linear-gradient(135deg,#e0e7ff,#c7d2fe);display:flex;align-items:center;justify-content:center;color:#4f46e5}.header-icon[_ngcontent-%COMP%]   mat-icon[_ngcontent-%COMP%]{font-size:22px;width:22px;height:22px}.dialog-header[_ngcontent-%COMP%]   h2[_ngcontent-%COMP%]{margin:0;font-size:1.15rem;font-weight:700;color:#1e293b;line-height:1.3}.header-subtitle[_ngcontent-%COMP%]{margin:2px 0 0;font-size:.8rem;color:#94a3b8;font-weight:400}.close-btn[_ngcontent-%COMP%]{color:#94a3b8;transition:color .2s}.close-btn[_ngcontent-%COMP%]:hover{color:#475569}.dialog-body[_ngcontent-%COMP%]{padding:0 24px 20px;min-height:200px;max-height:65vh}.state-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 24px;gap:12px}.state-title[_ngcontent-%COMP%]{font-size:1rem;font-weight:600;color:#334155;margin:0}.state-text[_ngcontent-%COMP%]{font-size:.85rem;color:#94a3b8;margin:0;text-align:center}.empty-icon[_ngcontent-%COMP%]{width:60px;height:60px;border-radius:50%;background:#f1f5f9;display:flex;align-items:center;justify-content:center;margin-bottom:4px}.empty-icon[_ngcontent-%COMP%]   mat-icon[_ngcontent-%COMP%]{font-size:28px;width:28px;height:28px;color:#cbd5e1}.borradores-layout[_ngcontent-%COMP%]{display:flex;gap:16px;min-height:200px}.list-col[_ngcontent-%COMP%]{flex:1 1 100%;display:flex;flex-direction:column;gap:8px;overflow-y:auto;transition:flex .3s ease}.list-col.has-preview[_ngcontent-%COMP%]{flex:0 0 55%}.preview-col[_ngcontent-%COMP%]{flex:0 0 43%;animation:_ngcontent-%COMP%_slideIn .25s ease-out}.draft-card[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:10px;border:1.5px solid #e2e8f0;background:#fff;cursor:pointer;transition:all .2s ease}.draft-card[_ngcontent-%COMP%]:hover{border-color:#c7d2fe;background:#f8faff;box-shadow:0 1px 4px #4f46e50f}.draft-card.selected[_ngcontent-%COMP%]{border-color:#818cf8;background:#eef2ff;box-shadow:0 2px 8px #4f46e51a}.draft-card-icon[_ngcontent-%COMP%]{width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:#f1f5f9;color:#64748b;transition:all .2s}.draft-card-icon[_ngcontent-%COMP%]   mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.draft-card.selected[_ngcontent-%COMP%]   .draft-card-icon[_ngcontent-%COMP%]{background:#c7d2fe;color:#4338ca}.draft-card-body[_ngcontent-%COMP%]{flex:1;min-width:0}.draft-empresa[_ngcontent-%COMP%]{display:block;font-size:.88rem;font-weight:600;color:#1e293b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}.draft-meta[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;margin-top:4px;flex-wrap:wrap}.draft-badge[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:6px;font-size:.7rem;font-weight:600;letter-spacing:.02em;text-transform:uppercase;line-height:1.5}.badge-plan[_ngcontent-%COMP%]{background:#dbeafe;color:#1e40af}.badge-informe[_ngcontent-%COMP%]{background:#fef3c7;color:#92400e}.badge-local[_ngcontent-%COMP%]{background:#f1f5f9;color:#64748b}.badge-icon[_ngcontent-%COMP%]{font-size:12px;width:12px;height:12px}
1.draft-time[_ngcontent-%COMP%]{font-size:.72rem;color:#94a3b8}.draft-card-actions[_ngcontent-%COMP%]{display:flex;gap:2px;flex-shrink:0}.action-restore[_ngcontent-%COMP%]{color:#4f46e5!important}.action-restore[_ngcontent-%COMP%]:hover{background:#4f46e514!important}.action-delete[_ngcontent-%COMP%]{color:#94a3b8!important}.action-delete[_ngcontent-%COMP%]:hover{color:#ef4444!important;background:#ef444414!important}.preview-panel[_ngcontent-%COMP%]{background:#f8fafc;border:1px solid #e2e8f0;border-radius:12px;padding:18px;position:sticky;top:0}.preview-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;font-size:.78rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:#64748b;margin-bottom:16px;padding-bottom:10px;border-bottom:1px solid #e2e8f0}.preview-header-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px}.preview-field[_ngcontent-%COMP%]{margin-bottom:12px}.preview-label[_ngcontent-%COMP%]{display:block;font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em;color:#94a3b8;margin-bottom:3px}.preview-value[_ngcontent-%COMP%]{font-size:.85rem;color:#334155;font-weight:500}.preview-value.mono[_ngcontent-%COMP%]{font-family:SF Mono,Fira Code,monospace;color:#6366f1}.preview-value.text-muted[_ngcontent-%COMP%]{color:#cbd5e1;font-style:italic;font-weight:400}.preview-sections[_ngcontent-%COMP%]{margin-bottom:14px}.section-chips[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:5px;margin-top:6px}.section-chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;font-size:.8rem;color:#334155;padding:4px 0}.chip-icon[_ngcontent-%COMP%]{font-size:15px;width:15px;height:15px;color:#10b981}.preview-actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;margin-top:18px;padding-top:14px;border-top:1px solid #e2e8f0}.action-btn[_ngcontent-%COMP%]{width:100%;border-radius:8px}.action-btn[_ngcontent-%COMP%]   mat-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;margin-right:4px}@keyframes _ngcontent-%COMP%_slideIn{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}']})}};export{U as a};

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.