function definirSRCImagenes(a=".rckta-loading-imagen"){$(a).each(function(){$(this).attr("src",$(this).data("src")).removeClass("rckta-loading-imagen")})}function mostrarProductoPlaceholder(a){$(".producto-carrousel-item-preload-"+a).fadeOut(0),$(".producto-carrousel-item-imagen-"+a).fadeIn(100)}function mostrarCompraRapida(a,o,r){if($(".rckta-producto-compra-rapida-tallas-global").html(""),$(".rckta-producto-compra-rapida-guia-tallas-global").html(``),$(".rckta-compra-rapida-overlay").fadeIn(100),1==o&&$(".rckta-producto-compra-rapida-tallas-global").html(``),2==o){let t="";(variaciones=$(`.rckta-producto-compra-rapida-${a}`).data("variaciones")).hay_variaciones&&(variaciones.variaciones.forEach(function(a){t+=``}),$(".rckta-producto-compra-rapida-tallas-global").html(t))}$(".rckta-producto-compra-rapida-global").show("slide",{direction:"down"},300)}function aumentarUnidadesProductoVR(a){let o=$("#inputUnidadesProductoVR");parseInt(o.val());let r=parseInt(o.val())+a;if(ro.data("max"))return!1;o.val(r)}function obtenerVistaPreviaProductoAsociarEventos(){$(".rckta-producto-informacion-talla-seleccionable.activo").on("click",function(){$(".rckta-producto-informacion-talla-seleccionable.activo").removeClass("seleccionado"),$(this).addClass("seleccionado"),$(".rckta-producto-informacion-pago input,.rckta-producto-informacion-pago button").attr("disabled",!1)})}function agregarCarritoVRConstruirRecienAgregado(a){$(".imagen-recien-agregado").attr("src",a.img),$(".nombre-producto-recien").html(a.nombre_producto),$(".ref-recien-agregado").html(`Ref. ${a.sku}`),$(".precio-recien-agregado").html(`$ ${a.precio} COP`),$("#cantidadesAgregar").val(1),$(".cant-manual-producto").html(1)}function agregarCarritoVRConstruirFaltanteEnvio(a){let o=a.envioEstandar,r=a.precioTotalSin,t=o-(r-a.total_carrito_excluir_standard);r-a.total_carrito_excluir_standard>=o?($(".falta-recien-texto").html(`AHORA TU ENV\xcdO STANDARD ES GRATIS TERMINA EL PROCESO Y ESPERA TU COMPRA`),$(".falta-recien-agregado").removeClass("backgroundGris").removeClass("backgroundGrisClaro").addClass("bor-1-black").addClass("backgroundVerdeClaro")):r-a.total_carrito_excluir_standard>=o/2&&r-a.total_carrito_excluir_standardFALTAN $${number_format(t,0)} M\xc1SPARA QUE EL ENV\xcdO STANDARD SEA GRATIS`),$(".falta-recien-agregado").removeClass("backgroundVerdeClaro").removeClass("backgroundGrisClaro").removeClass("bor-1-black").addClass("backgroundGris")):($(".falta-recien-texto").html(`FALTAN $${number_format(t,0)} M\xc1SPARA QUE EL ENV\xcdO STANDARD SEA GRATIS`),$(".falta-recien-agregado").removeClass("backgroundVerdeClaro").removeClass("backgroundGris").removeClass("bor-1-black").addClass("backgroundGrisClaro"))}function agregarCarritoComponente(a){agregarCarritoAnywhere(a,1)}function agregarCarritoAnywhere(a,o){bloquearFullPagina(),$.post("/functions/carrito_nw/agregar_producto_compra_rapida?noshow",{id_producto:a,cantidad:o},function(r){if(!r.exito)return desbloquearFullPagina(),addToast("",r.notificacion,"error");agregarCarritoVRConstruirRecienAgregado(r),agregarCarritoVRConstruirFaltanteEnvio(r),r.cantidad<=0&&$(".rckta-producto-compra-rapida-talla-"+a).addClass("agotada").attr("disabled",!0),$("#modalVistaRapidaProducto").modal("hide"),991>$(window).width()&&$(".rckta-compra-rapida-overlay").click(),open_modal("#modal_recien_agregado"),desbloquearFullPagina(),"undefined"!=typeof isPrServer&&isPrServer&&addCartPixelAnywhere(r.id_producto,o,r.precio,r.nombre_producto,r.img),setTimeout(()=>{clearModals()},2e3)},"json").done(function(){obtenerCarrito()}).fail(function(a){desbloquearFullPagina(),console.log(a)})}function addCartPixelAnywhere(a,o,r,t,c){fbq("track","AddToCart",{content_ids:a,content_type:"product",value:r,currency:"COP",content_name:t,content_image:c,num_items:o})}function agregarCarritoVR(){let a=$(".rckta-producto-informacion-talla-seleccionable.activo.seleccionado:first").data("producto");if(!a)return!1;let o=$("#inputUnidadesProductoVR"),r=parseInt(o.val());if(ro.data("max"))return addToast("Error","No se seleccion\xf3 una cantidad v\xe1lida de unidades","error");agregarCarritoAnywhere(a,r)}function obtenerVistaPreviaProducto(a){bloquearFullPagina(),$.get(`/functions/producto_nw/obtener_vista_previa?noshow&id_producto=${a}`,function(a){$(".rckta-vista-rapida-producto-contenedor").html(a)}).done(function(){definirSRCImagenes(".rckta-loading-imagen-vp"),$("#modalVistaRapidaProducto").modal("show")}).done(function(){obtenerVistaPreviaProductoAsociarEventos(),$(".rckta-producto-galeria").owlCarousel({loop:!1,margin:0,nav:!0,dots:!1,autoplay:!1,responsive:{0:{items:1}},navText:['arrow_back','arrow_forward']}),tippy(".rckta-producto-informacion-talla.activo.agotandose",{content:"\xdaltimas unidades",theme:"orange",allowHTML:!0,placement:"top",interactive:!0})}).done(function(){setTimeout(()=>{desbloquearFullPagina()},500)}).fail(function(){desbloquearFullPagina()})}function obtenerTipoPantallaResolucion(){return $(window).width()>991?1:$(window).width()>768?2:3}function mostrarGuiaRapidaTallas(a){bloquearFullPagina(),$.getJSON(`/functions/producto_nw/obtener_guia_tallas?noshow&id_producto=${a}&tipo_pantalla=${obtenerTipoPantallaResolucion()}`,function(a){if(!a.resultado)return addToast("Error",a.notificacion,"error");$("#contenedorImagenGuiaTallas").html(``)}).done(function(){$("#modalGuiaTallaPrevia").modal("show")}).done(function(){desbloquearFullPagina()}).fail(function(){desbloquearFullPagina()})}function cerrarGuiaTallas(){$("#modalGuiaTallaPrevia").modal("hide")}function construirComponenteProductoCI(a){return a.esta_agotado?`
AGOTADO
`:parseInt(a.id_categoria_intencion)?`
${a.nombre_corto_ci}
`:""}function construirComponenteProductoVariaciones(a){if(1==a.tipo_producto)return``;if(!a.variaciones.hay_variaciones)return'';let o="";return a.variaciones.variaciones.forEach(function(a){o+=``}),o}function construirComponenteProductoImagenes(a,o){let r="";return a.imagenes.forEach((t,c)=>{r+=` `}),r}function construirComponenteProductoPrecio(a){let{precio:o}=a;return(infoPrecio={tiene_descuento:!1,texto_descuento:"",texto_precio:'SIN PRECIO',clase_especial:""},o.tiene_precio&&(infoPrecio={tiene_descuento:o.tiene_descuento,texto_descuento:o.tiene_descuento?`
-${number_format(100-100*o.precio_descuento_iva/o.precio_iva,0)}%
`:"",texto_precio:o.tiene_descuento?`$${number_format(o.precio_iva,0)}$${number_format(o.precio_descuento_iva,0)}`:`$${number_format(o.precio_iva,0)}`,clase_especial:""},1==a.tiene_precio_variacion&&2==a.tipo_producto))?construirComponenteProductoPrecioVariaciones(o,a.variaciones,infoPrecio):infoPrecio}function construirComponenteProductoPrecioVariaciones(a,o,r){if(!o.hay_variaciones)return r;let t=o.variaciones.filter(a=>a.precio.tiene_precio).map(a=>a.precio.precio_iva).sort((a,o)=>a-o),c=o.variaciones.filter(a=>a.precio.tiene_descuento&&a.precio.precio_descuento_iva>0).map(a=>a.precio.precio_descuento_iva).sort((a,o)=>a-o);if(!t.length)return r;let i=`$${number_format(t[0],0)}${t.length>1?` - $${number_format(t[t.length-1],0)}`:""}`;if(!c.length)return{tiene_descuento:!1,texto_descuento:"",texto_precio:`${i}`,clase_especial:"rckta-producto-principal-precio-variable"};let e=number_format(100-100*c[0]/t[0],0),n=`${i}$${number_format(c[0],0)}${c.length>1?` - $${number_format(c[c.length-1],0)}`:""}`;return{tiene_descuento:!0,texto_descuento:`
-${e}%
`,texto_precio:n,clase_especial:"rckta-producto-principal-precio-variable"}}function construirComponenteProducto(a,o){return precio=construirComponenteProductoPrecio(a),`
${precio.texto_descuento} ${construirComponenteProductoCI(a)}
COMPRA
R\xc1PIDA
${construirComponenteProductoVariaciones(a)}

${a.nombre_producto}

${1==a.tipo_producto&&a.cantidad||2==a.tipo_producto?` add `:""}

${precio.texto_precio}

`}function obtenerListadoProductosInicializarCarouseles(){casouseles=[],$(".rckta-producto-principal-carrousel").off("mouseenter").off("mouseleave"),$(".rckta-producto-principal-carrousel").each(function(a,o){carouseles.push($(this).owlCarousel({loop:!1,margin:1,nav:!0,dots:!1,autoplay:!1,lazyLoad:!0,animateOut:"fadeOut",smartSpeed:200,responsive:{0:{items:1}},navText:['chevron_left','chevron_right']}))}),$(window).width()>991&&($(".rckta-producto-principal-carrousel").mouseenter(function(){$(this).owlCarousel().trigger("next.owl.carousel",[200])}),$(".rckta-producto-principal-carrousel").mouseleave(function(){$(this).owlCarousel().trigger("to.owl.carousel",[0,200])}))}$(function(){$(".rckta-compra-rapida-overlay").on("click",function(){$(".rckta-producto-compra-rapida").fadeOut(200),$(".rckta-compra-rapida-overlay").fadeOut(100)})});