File: /var/www/web.enelar.com.co/dist/browser/chunk-H4EFCT42.js
import{a as Oe,b as $e}from"./chunk-HWZY4DAM.js";import{a as Le,b as Pe,d as Ve,e as je,f as q}from"./chunk-73QXNGVV.js";import{a as Be,b as Ne,c as We,d as Ae}from"./chunk-2DV2IJZ3.js";import{a as fe,b as Ce}from"./chunk-ECOWRDHS.js";import"./chunk-Q6P2AG2Q.js";import{a as he,b as H}from"./chunk-UGKVLYDY.js";import"./chunk-4T6JHK7T.js";import"./chunk-ZELQV63M.js";import{b as ge}from"./chunk-NOX4BB7Y.js";import{a as Fe,b as ke}from"./chunk-FN4BVT7F.js";import{a as Re,b as De}from"./chunk-IZBGWZHV.js";import"./chunk-MEI5P7PY.js";import{a as ce,b as de}from"./chunk-M2XGXZBH.js";import"./chunk-YZB5RIY6.js";import{a as D}from"./chunk-FWIIQLPA.js";import{a as f}from"./chunk-J5MNQ3LA.js";import{b as _e,i as be,k as ve,l as Te,m as ye,n as we,o as Se,p as Ie,q as xe,r as Ee,t as Me}from"./chunk-3PWCL6RG.js";import"./chunk-O3VRXXRR.js";import{a as ie,b as oe}from"./chunk-ZUNNDRPI.js";import"./chunk-KDH6VC4N.js";import{b as re,d as O,f as se,g as ae,i as ne,j as le,k as pe,l as me,n as ue,o as U,p as G}from"./chunk-FB5LCIVC.js";import"./chunk-RP3BBTTB.js";import{A as z,d as R,e as W,n as A,z as $}from"./chunk-VJI6KQJL.js";import{A as B,Ab as ee,C as x,D as E,Fa as T,Ha as K,I as C,Ia as Q,J as h,Ja as L,Ka as P,La as N,Nb as te,Oa as V,Q as v,Y as p,Z as _,h as y,ha as k,ja as l,ma as J,nb as X,pa as s,qa as n,ra as g,va as w,vb as M,wa as m,x as j,xa as c,y as I,yb as Y}from"./chunk-MDSVL5BJ.js";import"./chunk-ODN5LVDJ.js";var b=class r{static fromApiToDomain(t){return{data:Array.isArray(t.data)?t.data.map(a=>r.dataMapper(a)):r.dataMapper(t.data),message:t.message,totalRecords:t.totalRecords,rows:t.rows}}static dataMapper(t){return{_id:t._id,nombre:t.nombre,posicion:t.posicion,imagen:t.imagen,url:t.url,activo:t.activo}}static fromDomainToApi(t){return{_id:t._id,nombre:t.nombre,posicion:t.posicion,imagen:t.imagen,url:t.url,activo:t.activo}}};var ze=(()=>{let t=class t{constructor(e){this.http=e}addCarousel(e){return this.http.post(`${f.apiDevWeb}carousel`,e).pipe(y(b.fromApiToDomain))}getCarousels(e,i){let o=new Y().set("page",e.toString()).set("pageSize",i.toString());return this.http.get(`${f.apiDevWeb}carousel`,{params:o}).pipe(y(b.fromApiToDomain))}getCarousel(e){return this.http.get(`${f.apiDevWeb}carousel/${e}`).pipe(y(b.fromApiToDomain))}updateCarousel(e,i){let o=b.fromDomainToApi(e);return this.http.put(`${f.apiDevWeb}carousel/${i}`,o).pipe(y(b.fromApiToDomain))}deleteOneCarousel(e){return this.http.delete(`${f.apiDevWeb}carousel/${e}`).pipe(y(b.fromApiToDomain))}deleteMultiCarousels(e){return this.http.post(`${f.apiDevWeb}carousel/eliminar-varios`,e).pipe(y(b.fromApiToDomain))}cambiarPosicion(e,i){return this.http.put(`${f.apiDevWeb}carousel/cambiar-posicion/${e}`,{tipo:i})}};t.\u0275fac=function(i){return new(i||t)(B(ee))},t.\u0275prov=j({token:t,factory:t.\u0275fac,providedIn:"root"});let r=t;return r})();var F=(()=>{let t=class t{constructor(e){this.carouselService=e}addCarousel(e){return this.carouselService.addCarousel(e)}getCarousels(e,i){return this.carouselService.getCarousels(e,i)}getCarousel(e){return this.carouselService.getCarousel(e)}updateCarousel(e,i){return this.carouselService.updateCarousel(e,i)}deleteOneCarousel(e){return this.carouselService.deleteOneCarousel(e)}deleteMultiCarousels(e){return this.carouselService.deleteMultiCarousels(e)}cambiarPosicion(e,i){return this.carouselService.cambiarPosicion(e,i)}};t.\u0275fac=function(i){return new(i||t)(B(ze))},t.\u0275prov=j({token:t,factory:t.\u0275fac,providedIn:"root"});let r=t;return r})();var tt=()=>({width:"60vw"}),it=()=>({width:"25vw"});function ot(r,t){if(r&1&&g(0,"app-title-dialog",17),r&2){let a=c();l("title",a.isEdit?"Editar carousel":"Crear carousel")}}function rt(r,t){if(r&1){let a=w();s(0,"div",9)(1,"app-upload-one-file",18,0),m("fileChanged",function(i){C(a);let o=c();return h(o.onFileChanged(i))})("imageFile",function(i){C(a);let o=c();return h(o.uploadedFile=i)}),n()()}r&2&&(p(),l("showFile",!0))}var Ge=(()=>{let t=class t{set getCarousel(e){e!=null&&(this.idCarousel=e._id,this.formulario.patchValue(e),this.display=!0,this.isEdit=!0)}set getSelectedCarousels(e){this.selectedCarousels=e}constructor(e,i,o,d){this.formBuilder=e,this.carouselRepositoryImpl=i,this.confirmationService=o,this.manageResponse=d,this.getCarousels=new v,this.setIsEdit=new v,this.idCarousel=null,this.display=!1,this.isLoading=!1,this.isLoadingDelete=!1,this.isEdit=!1}ngOnInit(){this.crearFormulario()}crearFormulario(){this.formulario=this.formBuilder.group({url:["",[O.required,O.maxLength(120)]],imagen:["",O.required]})}showDialog(){this.display=!this.display,this.isEdit&&(this.setIsEdit.emit(),this.isEdit=!1,this.formulario.reset())}guardar(){let e=this.formulario.value;this.isLoading=!0;let i=new FormData;i.append("url",e.url),this.archivoSubido&&i.append("imagen",this.archivoSubido,this.archivoSubido.name),this.isEdit?this.carouselRepositoryImpl.updateCarousel(e,this.idCarousel).subscribe({next:o=>{this.manageResponse.success(o),this.isLoading=!1,this.getCarousels.emit(),this.showDialog()},error:o=>{this.manageResponse.error(o),this.isLoading=!1}}):this.carouselRepositoryImpl.addCarousel(i).subscribe({next:o=>{this.manageResponse.success(o),this.isLoading=!1,this.formulario.reset(),this.getCarousels.emit()},error:o=>{this.manageResponse.error(o),this.isLoading=!1}})}eliminarVarios(){this.confirmationService.confirm({message:"Estas seguro de eliminar los elmentos?",accept:()=>{this.isLoadingDelete=!0;let e=this.selectedCarousels.map(function(i){return{_id:i._id}});this.carouselRepositoryImpl.deleteMultiCarousels(e).subscribe({next:i=>{this.manageResponse.success(i),this.isLoadingDelete=!1,this.getCarousels.emit()},error:i=>{this.manageResponse.error(i),this.isLoadingDelete=!1}})},reject:e=>{switch(e){case R.REJECT:this.manageResponse.eventReject;break;case R.CANCEL:this.manageResponse.eventCancel;break}}})}onFileChanged(e){e?(this.archivoSubido=e,this.formulario.patchValue({imagen:e.name})):(this.archivoSubido=null,this.formulario.patchValue({imagen:null}))}};t.\u0275fac=function(i){return new(i||t)(_(me),_(F),_(W),_(D))},t.\u0275cmp=x({type:t,selectors:[["app-modal-form-carousel"]],inputs:{getCarousel:"getCarousel",getSelectedCarousels:"getSelectedCarousels"},outputs:{getCarousels:"getCarousels",setIsEdit:"setIsEdit"},decls:20,vars:16,consts:[["appUploadOneFile",""],[1,"p-toolbar-group-left"],["label","Crear","icon","pi pi-plus","styleClass","p-button-success mr-2",3,"click"],["icon","pi pi-trash","styleClass","p-button-danger",3,"click","loading","disabled"],[3,"visibleChange","visible"],["pTemplate","header"],[3,"submit","formGroup"],[1,"grid","p-fluid"],["class","field col-12 md:col-12",4,"ngIf"],[1,"field","col-12","md:col-12"],["for","float-input-invalid"],["formControlName","url","placeholder","Digite el url del Carousel","type","text","pInputText",""],["campo","url","length","120",3,"formulario"],[1,"flex","flex-row-reverse","flex-wrap"],["icon","pi pi-check","type","submit","styleClass","p-button-success",3,"loading","label","disabled"],["icon","pi pi-times","label","Cancelar","styleClass","p-button-danger mr-2",3,"click"],["rejectButtonStyleClass","p-button-text","acceptLabel","Si",3,"baseZIndex"],[3,"title"],["titulo","Seleciona la imagen que quieres subir como portada","descripcion","La imagen no puede pesar mas de 3 MB","accept","image/*","icon","pi-image",3,"fileChanged","imageFile","showFile"]],template:function(i,o){i&1&&(s(0,"p-toolbar")(1,"div",1)(2,"p-button",2),m("click",function(){return o.showDialog()}),n(),s(3,"p-button",3),m("click",function(){return o.eliminarVarios()}),n()()(),s(4,"p-dialog",4),N("visibleChange",function(u){return P(o.display,u)||(o.display=u),u}),k(5,ot,1,1,"ng-template",5),s(6,"form",6),m("submit",function(){return o.guardar()}),s(7,"div",7),k(8,rt,3,1,"div",8),n(),s(9,"div",7)(10,"div",9)(11,"label",10),T(12,"Url"),n(),g(13,"input",11)(14,"app-validations-input",12),n()(),g(15,"p-divider"),s(16,"div",13),g(17,"p-button",14),s(18,"p-button",15),m("click",function(){return o.display=!1}),n()()()(),g(19,"p-confirmDialog",16)),i&2&&(p(3),l("loading",o.isLoadingDelete)("disabled",!o.selectedCarousels||!o.selectedCarousels.length),p(),J(V(14,tt)),L("visible",o.display),p(2),l("formGroup",o.formulario),p(2),l("ngIf",!o.isEdit),p(6),l("formulario",o.formulario),p(3),l("loading",o.isLoading)("label",o.isLoading?"Guardando...":"Guardar")("disabled",!o.formulario.valid),p(2),J(V(15,it)),l("baseZIndex",1e4))},dependencies:[X,ne,re,se,ae,le,pe,Le,A,$,Re,U,je,Fe,ce,Oe,he]});let r=t;return r})();var at=()=>[5,10,20,30];function nt(r,t){if(r&1){let a=w();s(0,"div",5)(1,"h5",6),T(2,"Lista de carousels"),n(),s(3,"span",7),g(4,"i",8),s(5,"input",9),m("input",function(i){C(a);let o=c();return h(o.dt.filterGlobal(i.target.value,"contains"))}),n()()()}}function lt(r,t){if(r&1){let a=w();s(0,"tr")(1,"th",10)(2,"p-tableHeaderCheckbox",11),m("click",function(){C(a);let i=c();return h(i.getSelectCarousels())}),n()(),s(3,"th",12),T(4,"Imagen"),g(5,"p-sortIcon",13),n(),s(6,"th",14),T(7,"Url"),g(8,"p-sortIcon",15),n(),g(9,"th",16),n()}}function pt(r,t){if(r&1){let a=w();s(0,"tr")(1,"td")(2,"p-tableCheckbox",17),m("click",function(){C(a);let i=c();return h(i.getSelectCarousels())}),n()(),s(3,"td"),g(4,"p-image",18),n(),s(5,"td"),T(6),n(),s(7,"td")(8,"p-button",19),m("click",function(){let i=C(a).$implicit,o=c();return h(o.getIdCarousel(i._id))}),n(),s(9,"p-button",20),m("click",function(){let i=C(a).$implicit,o=c();return h(o.eliminar(i._id))}),n(),s(10,"p-button",21),m("click",function(){let i=C(a).$implicit,o=c();return h(o.onCambiarPosicion(i._id,!0))}),n(),s(11,"p-button",22),m("click",function(){let i=C(a).$implicit,o=c();return h(o.onCambiarPosicion(i._id,!1))}),n()()()}if(r&2){let a=t.$implicit,e=c();p(2),l("value",a),p(2),l("src",e.getUrlImg(a.imagen.path))("preview",!0),p(2),Q(" ",e.index," ",a.url,""),p(2),l("loading",e.isLoading),p(),l("loading",e.isLoading),p(),l("loading",e.isLoading)("disabled",e.disableCambiarPosicionUp(a._id)),p(),l("loading",e.isLoading)("disabled",e.disableCambiarPosicionDown(a._id))}}function mt(r,t){if(r&1){let a=w();s(0,"p-paginator",23),m("onPageChange",function(i){C(a);let o=c();return h(o.paginate(i))}),n(),s(1,"div",24),T(2),n()}if(r&2){let a=c();l("rows",a.rows)("totalRecords",a.totalRecords)("rowsPerPageOptions",V(4,at)),p(2),K(" En total son ",a.totalRecords," registros ")}}var He=(()=>{let t=class t{set getLoadingTable(e){this.isLoadingTable=e}constructor(e,i,o){this.carouselRepository=e,this.confirmationService=i,this.manageResponse=o,this.carousels=[],this.setIdCarousel=new v,this.getCarousels=new v,this.setPaginate=new v,this.setSelectedCarousels=new v,this.selectedCarousels=[],this.globalFilterFields=["fechaCarousel"],this.isLoading=!1,this.isLoadingTable=!1,this.first=0,this.rows=f.pageSize}paginate(e){this.setPaginate.emit(e)}getIdCarousel(e){this.setIdCarousel.emit(e)}getSelectCarousels(){this.setSelectedCarousels.emit(this.selectedCarousels)}eliminar(e){this.confirmationService.confirm({message:"Estas seguro de eliminar el elemento?",accept:()=>{this.isLoading=!0,this.carouselRepository.deleteOneCarousel(e).subscribe({next:i=>{this.manageResponse.success(i),this.isLoading=!1,this.getCarousels.emit()},error:i=>{this.manageResponse.error(i),this.isLoading=!1}})},reject:i=>{switch(i){case R.REJECT:this.manageResponse.eventReject();break;case R.CANCEL:this.manageResponse.eventCancel();break}}})}getUrlImg(e){return`${f.apiDevWebStorage}${e}`}onCambiarPosicion(e,i){this.isLoading=!0,this.carouselRepository.cambiarPosicion(e,i).subscribe({next:o=>{this.manageResponse.success(o),this.getCarousels.emit(),this.isLoading=!1},error:o=>{this.manageResponse.error(o),this.isLoading=!1}})}disableCambiarPosicionUp(e){return this.carousels.findIndex(o=>o._id==e)==0}disableCambiarPosicionDown(e){return this.carousels.findIndex(o=>o._id==e)==this.carousels.length-1}};t.\u0275fac=function(i){return new(i||t)(_(F),_(W),_(D))},t.\u0275cmp=x({type:t,selectors:[["app-table-carousel"]],inputs:{carousels:"carousels",totalRecords:"totalRecords",getLoadingTable:"getLoadingTable"},outputs:{setIdCarousel:"setIdCarousel",getCarousels:"getCarousels",setPaginate:"setPaginate",setSelectedCarousels:"setSelectedCarousels"},decls:5,vars:7,consts:[["dataKey","_id",3,"firstChange","selectionChange","value","rows","first","globalFilterFields","showCurrentPageReport","loading","selection"],["pTemplate","caption"],["pTemplate","header"],["pTemplate","body"],["pTemplate","summary"],[1,"flex","align-items-center","justify-content-between"],[1,"m-0"],[1,"p-input-icon-left"],[1,"pi","pi-search"],["pInputText","","type","text","placeholder","Buscar...",3,"input"],[2,"width","4rem"],[3,"click"],["pSortableColumn","imgen"],["field","imgen"],["pSortableColumn","url"],["field","url"],["width","126px"],[3,"click","value"],["alt","imagne","imageClass","image-border","width","190",3,"src","preview"],["icon","pi pi-pencil","styleClass","p-button-info mr-2","pTooltip","Editar","tooltipPosition","top",3,"click","loading"],["icon","pi pi-trash","styleClass","p-button-danger mr-2","pTooltip","Eliminar","tooltipPosition","top",3,"click","loading"],["icon","pi pi-angle-up","styleClass","p-button-secondary mr-2 mt-2","pTooltip","Subir","tooltipPosition","top",3,"click","loading","disabled"],["icon","pi pi-angle-down","styleClass","p-button-secondary mr-2","pTooltip","Bajar","tooltipPosition","top",3,"click","loading","disabled"],[3,"onPageChange","rows","totalRecords","rowsPerPageOptions"],[1,"flex","align-items-center","justify-content-between","mt-3"]],template:function(i,o){i&1&&(s(0,"p-table",0),N("firstChange",function(u){return P(o.first,u)||(o.first=u),u})("selectionChange",function(u){return P(o.selectedCarousels,u)||(o.selectedCarousels=u),u}),k(1,nt,6,0,"ng-template",1)(2,lt,10,0,"ng-template",2)(3,pt,12,11,"ng-template",3)(4,mt,3,5,"ng-template",4),n()),i&2&&(l("value",o.carousels)("rows",o.rows),L("first",o.first),l("globalFilterFields",o.globalFilterFields)("showCurrentPageReport",!0)("loading",o.isLoadingTable),L("selection",o.selectedCarousels))},dependencies:[we,A,Se,Ie,xe,Ee,U,$,Te,ie,fe]});let r=t;return r})();var qe=(()=>{let t=class t{constructor(e,i){this.carouselRepository=e,this.manageResponse=i,this.isEdit=!1,this.page=f.page,this.pageSize=f.pageSize,this.loadingTable=!1}ngOnInit(){this.getCarousels(),this.inizialize()}inizialize(){this.items=[{label:"Gesti\xF3n"},{label:"Carousels"}],this.home={icon:"pi pi-home",routerLink:"/"}}getCarousels(){this.loadingTable=!0,this.carouselRepository.getCarousels(this.page,this.pageSize).subscribe({next:e=>{this.carousels=e.data,this.totalRecords=e.totalRecords,this.loadingTable=!1},error:e=>{this.manageResponse.error(e),this.loadingTable=!1}})}getIdCarousel(e){this.isEdit=!0,this.getCarousel(e)}getSelectedCarousels(e){this.selectedCarousels=e}getCarousel(e){this.carouselRepository.getCarousel(e).subscribe({next:i=>{this.carousel=i.data},error:i=>{this.manageResponse.error(i)}})}paginate(e){this.page=e.page+1,this.pageSize=e.rows,this.getCarousels()}};t.\u0275fac=function(i){return new(i||t)(_(F),_(D))},t.\u0275cmp=x({type:t,selectors:[["app-carousel"]],decls:6,vars:7,consts:[[3,"model","home"],[1,"card","mt-5","p-3"],[3,"getCarousels","setIsEdit","getCarousel","getSelectedCarousels"],[1,"mt-3"],[3,"setIdCarousel","setSelectedCarousels","getCarousels","setPaginate","carousels","totalRecords","getLoadingTable"]],template:function(i,o){i&1&&(g(0,"p-toast")(1,"p-breadcrumb",0),s(2,"div",1)(3,"app-modal-form-carousel",2),m("getCarousels",function(){return o.getCarousels()})("setIsEdit",function(){return o.isEdit=!1}),n(),s(4,"div",3)(5,"app-table-carousel",4),m("setIdCarousel",function(u){return o.getIdCarousel(u)})("setSelectedCarousels",function(u){return o.getSelectedCarousels(u)})("getCarousels",function(){return o.getCarousels()})("setPaginate",function(u){return o.paginate(u)}),n()()()),i&2&&(p(),l("model",o.items)("home",o.home),p(2),l("getCarousel",o.carousel)("getSelectedCarousels",o.selectedCarousels),p(2),l("carousels",o.carousels)("totalRecords",o.totalRecords)("getLoadingTable",o.loadingTable))},dependencies:[Ge,He,Be,We]});let r=t;return r})();var ct=[{path:"",component:qe}],Je=te.forChild(ct);var Ze=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=E({type:t}),t.\u0275inj=I({imports:[M,ue,Pe,z,De,G,be,_e,ve,Ve,q,ke,de,$e,H]});let r=t;return r})();var Ke=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=E({type:t}),t.\u0275inj=I({imports:[M,Me,G,z,q,ye,oe,Ce]});let r=t;return r})();var ji=(()=>{let t=class t{};t.\u0275fac=function(i){return new(i||t)},t.\u0275mod=E({type:t}),t.\u0275inj=I({imports:[M,Je,Ze,Ke,ge,Ne,Ae,H]});let r=t;return r})();export{ji as CarouselModule};