define(["jquery","knockout","pubsub","ccConstants","koValidate","notifier","CCi18n","storeKoExtensions","swmRestClient","spinner","pageLayout/product","ccRestClient","ccResourceLoader!global/OCS_BFService","navigation","ccLogger"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d){"use strict";var v,m="LOADED",g="LOADING",y={parent:"#cc-product-spinner",selector:"#cc-product-spinner-area"},b=!1,w=0,E=5,S="OCS_ADD_ITEM_SUCCESS",x=function(e){var t=e.indexOf("@");return t!=-1?!0:!1},T={validaRut:function(e){var t=e.replace(/\./g,""),n=t.split("-"),r=n[1],i=n[0];return r=="K"&&r.toLowerCase(),T.dv(i)==r?!0:!1},dv:function(e){var t=0,n=1;for(;e;e=Math.floor(e/10))n=(n+e%10*(9-t++%6))%11;return n?n-1:"k"}},N=function(e,t){return e.spaceNameFull()>t.spaceNameFull()?1:e.spaceNameFull()t.spaceNameFull()?1:e.spaceNameFull()800&&!r&&n.css({position:"fixed",display:"flex"}),e(this).scrollTop()<800&&r&&n.css({position:"static",display:"none"})}),e(window).on("show.bs.modal",function(t){e("#product-spincar .sts-spin #spincar360iframe").clone().appendTo("#product-spincar-modal .sts-spin")}),e.Topic(n.topicNames.UPDATE_LISTING_FOCUS).subscribe(function(e){i.skipTheContent(!0)}),i.showSecondaryShippingData=t.pureComputed(function(){return i.site().payShippingInSecondaryCurrency&&null!=i.site().exchangeRate()&&null!=i.site().siteSecondaryCurrency()}),e.Topic(n.topicNames.PAGE_READY).subscribe(function(e){var t={};if(e.parameters){var n=e.parameters.split("&");for(var r=0;r0&&i.itemQuantity.extend({max:{params:t,message:o.t("ns.OCS_productDetailsUsedCar:resources.quantityLessThanMsg",{quantity:t})}})}),i.itemQuantityInCart=function(e){var t=e.orderLimit?!1:!0;return i.cart().getItemQuantityInCart(i.cart().items(),e.id,e.childSKUs[0].repositoryId,t)},a.init(i.site().tenantId,i.isPreview(),i.locale()),i.fetchFacebookAppId(),i.shippingSurchargeMouseOver=function(t,n){e(".shippingSurchargePopover").off("click"),e(".shippingSurchargePopover").off("keydown");var r=new Object;r.trigger="manual",r.html=!0,r.title=t.translate("shippingSurchargePopupTitle")+"",r.content=t.translate("shippingSurchargePopupText"),e(".shippingSurchargePopover").popover(r),e(".shippingSurchargePopover").on("click",t.shippingSurchargeShowPopover),e(".shippingSurchargePopover").on("keydown",t.shippingSurchargeShowPopover)},i.shippingSurchargeShowPopover=function(t){if(t.type==="keydown"&&t.which!==r.KEY_CODE_ENTER)return;t.stopPropagation(),e(this).popover("show"),e("html").on("click",i.shippingSurchargeHidePopover),e("html").on("keydown",i.shippingSurchargeHidePopover),e(".shippingSurchargePopover").off("click"),e(".shippingSurchargePopover").off("keydown")},i.shippingSurchargeHidePopover=function(t){if(t.type==="keydown"&&t.which!==r.KEY_CODE_ESCAPE)return;e(".shippingSurchargePopover").popover("hide"),e(".shippingSurchargePopover").on("click",i.shippingSurchargeShowPopover),e(".shippingSurchargePopover").on("keydown",i.shippingSurchargeShowPopover),e("html").off("click"),e("html").off("keydown"),e(".shippingSurchargePopover").focus()},i.isAddToPurchaseListDisabled=t.computed(function(){return!i.validateAddToSpace()||i.disableAddToSpace()},i),i.viewportWidth(e(window).width()),i.product()&&(i.imgGroups(i.groupImages(i.product().thumbImageURLs())),i.mainImgUrl(i.product().primaryFullImageURL()));var s=function(){e("#cc-product-details :focusable").first().focus(),i.skipTheContent(!1)};s(),setTimeout(s,1),e(document).on("keyup","#widget_iduser",function(){var t=e("#widget_iduser");t=t.val().replace(/[.-]/g,"").replace(/^(\d{1,2})(\d{3})(\d{3})(\w{1})$/,"$1.$2.$3-$4"),e("#widget_iduser").val(t)}),i.tooltipCuota=t.computed(function(){var e=(new Date).getFullYear()-i.product().x_agno();if(e<=6)return e<=4?"Cuota calculada con Crédito Inteligente, Pie del 40%, 36 Cuotas + Cuota 37.":"Cuota calculada con Crédito Convencional, Pie del 50%, 48 Cuotas."},i),setTimeout(function(){i.checkAction()},1500),i.reservarButton.subscribe(function(e){h.utils.cache("RESERVA_ENABLED",e.toString())})},spinnerSpinCar:function(){f.create({parent:"#loadingSpinCar"})},lowerActivepgFinanciadoConvencional:t.observable(!1),lowerActivepgPrecioLista:t.observable(!1),lowerActivepgReservaWeb:t.observable(!1),lowerActivepgBonoMarca:t.observable(!1),populateHighlightProperties:function(){v.product().highlightProperties=t.observableArray(),v.product().highlightProperties(h.populateHighlightProperties(v.product(),"pdp"))},showHighlyViewed:function(e){return h.showHighlyViewed(e.creationDate(),e.x_views())},beforeAppear:function(i){var o=this;o.showProductSpincar(!1),o.showProductImage(!1);var u=(new Date).getFullYear()-o.product().x_agno();u<=6?(o.showFinancing(!0),e.Topic("OCC_SHOW_FINANCING").publish(!0)):(o.showFinancing(!1),e.Topic("OCC_SHOW_FINANCING").publish(!1)),o.sucursal(null),o.product().x_Ubicacion_Fisica()!="Pronto Disponible"&&h.ajax({url:h.utils.siteSetting("BF_middleware","urlMiddleware")+"/sucursales/findSucursal/byAddress",type:"GET",data:{direccion:o.product().x_Ubicacion_Fisica()},success:function(e){e.success==1?(console.log(e.data),o.sucursal(e.data)):console.error("No se encontró la data de sucursal",e)},fail:function(e){console.error("Erros buscando la sucursal",e)}}),setTimeout(function(){e(document).ready(function(){e("#formatkmauto").each(function(t,n){e(this).text(e(this).text().toString().replace(/\B(?=(\d{3})+(?!\d))/g,"."))})})},1e3),o.lowerActivepgFinanciadoConvencional(!1),o.lowerActivepgPrecioLista(!1),o.lowerActivepgBonoMarca(!1),o.reservarButton(!1),o.product().allPrices=t.observable();if(o.product&&o.product()){o.checkResponsiveFeatures(e(window).width()),this.backLinkActive(!0),!o.isPreview()&&!o.historyStack.length&&this.backLinkActive(!1),o.shippingSurcharge(null),o.secondaryCurrencyShippingSurcharge(null),o.activeImgIndex(0),o.firstTimeRender=!0,this.populateVariantOptions(o),o.product()&&o.imgGroups(o.groupImages(o.product().thumbImageURLs())),o.loaded(!0),this.itemQuantity(1),o.product()&&o.product().childSKUs().length==1&&(this.filtered(!1),this.filterOptionValues(null)),s.clearSuccess(this.WIDGET_ID),s.clearError(this.WIDGET_ID);var a=null;o.user().catalog&&(a=o.user().catalog.repositoryId),o.listPrice(o.product().listPrice()),o.salePrice(o.product().salePrice());if(o.product()){o.product().stockStatus.subscribe(function(t){o.product().stockStatus().stockStatus!==r.IN_STOCK&&o.product().stockStatus().stockStatus!==r.PREORDERABLE&&o.product().stockStatus().stockStatus!==r.BACKORDERABLE||o.product().stockStatus().orderableQuantity==undefined&&o.product().stockStatus().productSkuInventoryStatus==undefined?(o.ocs_button_reserva(!1),o.ocs_button_vendido(!0),o.stockAvailable(0),o.stockState(r.OUT_OF_STOCK),o.disableOptions(!0),o.stockStatus(!1)):(o.product().stockStatus().orderableQuantity?o.stockAvailable(o.product().stockStatus().orderableQuantity):o.stockAvailable(1),o.disableOptions(!1),o.stockStatus(!0),o.stockState(o.product().stockStatus().stockStatus),o.availabilityDate(o.product().stockStatus().availabilityDate),o.ocs_button_reserva(!0),o.ocs_button_vendido(!1)),o.showStockStatus(!0),o.reservarButton(!0),o.isVisibleReservarButton(!0),o.isVisibleVenderButton(!1),o.isVisibleCotizar(!0),o.showPrices(!0),o.stockAvailable()===0?o.reservarButton(!1):o.stockAvailable()===888?(o.reservarButton(!0),o.isVisibleReservarButton(!1),o.isVisibleVenderButton(!0),o.isVisibleCotizar(!1),o.showPrices(!1),o.showFinancing(!1),e.Topic("OCC_SHOW_FINANCING").publish(!1)):o.product().x_preStock()?o.reservarButton(!1):!o.product().x_preStock()});var f=o.product().childSKUs()[0];if(f){var l=f.repositoryId();this.variantOptionsArray().length>0&&(l=""),this.showStockStatus(!1),o.product().getAvailability(o.product().id(),l,a),o.product().getPrices(o.product().id(),l)}else o.stockStatus(!1),o.disableOptions(!0),o.showStockStatus(!0);this.priceRange(this.product().hasPriceRange),o.mainImgUrl(o.product().primaryFullImageURL()),e.Topic(n.topicNames.PRODUCT_VIEWED).publish(o.product()),e.Topic(n.topicNames.PRODUCT_PRICE_CHANGED).subscribe(function(){o.listPrice(o.product().listPrice()),o.salePrice(o.product().salePrice()),o.shippingSurcharge(o.product().shippingSurcharge()),o.secondaryCurrencyShippingSurcharge(o.product().secondaryCurrencyShippingSurcharge&&o.product().secondaryCurrencyShippingSurcharge()?o.product().secondaryCurrencyShippingSurcharge():null)})}}v.loadAllPrices(),v.product().allPrices.subscribe(function(e){v.lowerPrice()}),e.Topic(n.topicNames.USER_LOGOUT_SUBMIT).subscribe(function(e){localStorage.clear(),localStorage.removeItem("occsRecVisitorId"),localStorage.removeItem("occsRecSessionId"),localStorage.removeItem("redirectedToWebPayment"),localStorage.removeItem("occs_pricelistgroup_id-storefrontUI"),localStorage.removeItem("user"),location.reload()}),v.loadUrls(),o.product().x_spincar360()?h.ajax({url:h.CCConstants.urlMiddleware()+"/v1/spincar/data?patente="+o.product().x_patente().toLowerCase(),success:function(t){if(t&&t.hasOwnProperty("vehicles")&&t.vehicles.length>0)if(t.vehicles[0].hasOwnProperty("images")){var n=t.vehicles[0].images.map(function(e){return e.url});v.assignImagesToProduct(null,n),v.showProductSpincar(!0),v.showProductImage(!0);var r=''+"
";e("#product-spincar").html(r)}else v.showProductNoImage();else v.showProductNoImage()},fail:function(e){d.error("Error verificando imagenes de patente: "+e),v.showProductNoImage()}}):v.showProductNoImage(),e.Topic("ga_view_item.memory").publish(v.product().product)},showProductNoImage:function(){v.showProductImage(!0)},loadAllPrices:function(){h.getAllPrices(v.product(),"allPrices")},goBack:function(){return e(window).scrollTop(e(window).height()),window.history.go(-1),!1},cancelZoom:function(t){e(t).parent().removeClass("zoomContainer-CC")},populateVariantOptions:function(e){var t=e.productVariantOptions();if(t&&t!==null&&t.length>0){var n=[],r,i={},s,o,u;for(var a=0,f=e.productTypes().length;a0&&(t=e.items[0].x_spinCar,t&&(v.urlVideoReview("https://www.youtube.com/embed/"+t),v.showVideoReview(!0)))},i=function(e){console.error("Error on load product video & 360 view: ",e.message)};h.getProductsFromCategory(e,n,r,i)},productVariantModel:function(n,r,i,s,o){var u={},a={};u.optionDisplayName=n,u.parent=this,u.optionId=r,u.originalOptionValues=t.observableArray(i),u.actualOptionId=o;var f=t.observable(!0);i.length===1&&f(this.checkOptionValueWithSkus(r,i[0].value)),f()&&(u.optionCaption=s.translate("optionCaption",{optionName:n},!0)),u.selectedOptionValue=t.observable(),u.countVisibleOptions=t.computed(function(){var e=0;for(var t=0;t0?[]:s.product().product.thumbImageURLs,a.smallImageURLs=s.product().product.smallImageURLs.length==1&&s.product().product.smallImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.smallImageURLs,a.mediumImageURLs=s.product().product.mediumImageURLs.length==1&&s.product().product.mediumImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.mediumImageURLs,a.largeImageURLs=s.product().product.largeImageURLs.length==1&&s.product().product.largeImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.largeImageURLs,a.fullImageURLs=s.product().product.fullImageURLs.length==1&&s.product().product.fullImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.fullImageURLs,a.sourceImageURLs=s.product().product.sourceImageURLs.length==1&&s.product().product.sourceImageURLs[0].indexOf("/img/no-image.jpg")>0?[]:s.product().product.sourceImageURLs;var p=[];if(s.product().thumbImageURLs&&s.product().thumbImageURLs().length>0)for(var d=0;d0)for(var l=0;l0?!0:!1));for(var i in r)if(i==t){r[t]!="IN_STOCK"&&r[t]!="PREORDERABLE"&&r[t]!="BACKORDERABLE"||!n?(this.stockStatus(!1),this.stockAvailable(0),this.stockState("OUT_OF_STOCK")):(this.stockStatus(!0),this.stockState(r[t]),this.availabilityDate(this.getAvailabilityDate(t)),e===null?this.stockAvailable(1):this.stockAvailable(e.quantity));return}},refreshSkuData:function(e){this.refreshSkuPrice(e),this.refreshSkuStockStatus(e)},getAvailabilityDate:function(e){var t=null,n=this.product().stockStatus().productSkuInventoryDetails;for(var r in n){var i=n[r];if(i.catRefId===e){t=i.availabilityDate;break}}return t},getSelectedSkuOptions:function(e){var t=[],n;for(var r=0;r0){var t=this.variantOptionsArray();for(var n=0;n0&&this.itemQuantity()<=this.stockAvailable()},selectCarVersion:function(t){e.Topic("addRemoveCartComparator").publish(t.product())},validateAddToCart:function(){var t=this.allOptionsSelected()&&this.stockStatus()&&this.quantityIsValid()&&this.listPrice()!=null;return this.variantOptionsArray().length>0&&this.selectedSku()?t=t&&!this.selectedSku().configurable:t=t&&!this.product().isConfigurable(),t||e("#cc-prodDetailsAddToCart").attr("aria-disabled","true"),t},handleAddToCart:function(){v.user().loggedIn()?h.handleAddToCartAndRedirectToCheckout(this):e("#headerBFUserLogin").trigger("click")},getSpaces:function(e){var n=this,r=function(r){var i=[],s=[];if(r.response.code.indexOf("200")===0){var o=r.items;o.forEach(function(e,r){var o={spaceid:e.spaceId,spaceNameFull:t.observable(e.spaceName),spaceNameFormatted:t.computed(function(){return e.spaceName+" ("+e.creatorFirstName+" "+e.creatorLastName+")"},n),creatorid:e.creatorId,accessLevel:e.accessLevel,spaceOwnerFirstName:e.creatorFirstName,spaceOwnerLastName:e.creatorLastName};e.creatorId==a.apiuserid?i.push(o):s.push(o)}),i.sort(N),s.sort(C),n.user().myWishLists(i),n.user().joinedWishLists(s),n.spaceOptionsGrpMySpacesArr(i),n.spaceOptionsGrpJoinedSpacesArr(s);var u=[],f={label:n.translate("mySpacesGroupText"),children:t.observableArray(n.spaceOptionsGrpMySpacesArr())},l={label:n.translate("joinedSpacesGroupText"),children:t.observableArray(n.spaceOptionsGrpJoinedSpacesArr())},c=[],h={spaceid:"createnewspace",spaceNameFull:t.observable(n.translate("createNewSpaceOptText"))};c.push(h);var p={label:"",children:t.observableArray(c)};u.push(f),u.push(l),u.push(p),n.spaceOptionsArray(u),n.mySpaces(i),e&&e()}},i=function(e,t,n){};a.request("GET","/swm/rs/v1/sites/{siteid}/spaces","",r,i,{})},openAddToWishlistDropdownSelector:function(){var e=this;e.spaceOptionsArray().length===0&&e.getSpaces()},validateAddToSpace:function(){var t=!0;if(this.variantOptionsArray().length>0){var n=this.variantOptionsArray();for(var r=0;r0&&this.selectedSku()?t=t&&!this.selectedSku().configurable:t=t&&this.product()&&!this.product().isConfigurable();var o=this.itemQuantity();if(o.toString()!="")if(!o.toString().match(/^\d+$/)||Number(o)<0)return!1;var u=t&&this.product().childSKUs().length>0;return u||e("#cc-prodDetailsAddToSpace").attr("aria-disabled","true"),u},validateAndSetSelectedSku:function(e){var t=!0;if(this.variantOptionsArray().length>0){var n=this.variantOptionsArray();for(var r=0;r0&&(u.childSKUs=[this.selectedSku()]),u.productPrice=u.salePrice!=null?u.salePrice:u.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD).publishWith(u,[{message:"success"}])},addToSpaceSelectorClick:function(t){var r=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var i=this.getSelectedSkuOptions(r),o={selectedOptions:i},u=e.extend(!0,{},this.product().product,o);u.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(u.childSKUs=[this.selectedSku()]),u.productPrice=u.salePrice!=null?u.salePrice:u.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_SELECTOR_ADD).publishWith(u,[{message:"success"}])},addToSpaceSelect:function(t,r){var i=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var o=this.getSelectedSkuOptions(i),u={selectedOptions:o},a=e.extend(!0,{},this.product().product,u);a.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(a.childSKUs=[this.selectedSku()]),a.productPrice=a.salePrice!=null?a.salePrice:a.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD_TO_SELECTED_SPACE).publishWith(a,[r])},addToWishListSelected:function(t){if(v.user().loggedIn()){var t=this,r="";for(var i=0;i0&&(f.childSKUs=[this.selectedSku()]),f.productPrice=f.salePrice!=null?f.salePrice:f.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD_TO_SELECTED_SPACE).publishWith(f,[r])}else e("#headerBFUserLogin").trigger("click")},fetchFacebookAppId:function(){var e=this,t=r.EXTERNALDATA_PRODUCTION_FACEBOOK;e.isPreview()&&(t=r.EXTERNALDATA_PREVIEW_FACEBOOK),c.request(r.ENDPOINT_MERCHANT_GET_EXTERNALDATA,null,e.fetchFacebookAppIdSuccessHandler.bind(e),e.fetchFacebookAppIdErrorHandler.bind(e),t)},fetchFacebookAppIdSuccessHandler:function(e){var t=this;t.siteFbAppId(e.serviceData.applicationId)},fetchFacebookAppIdErrorHandler:function(e){logger.debug("Failed to get Facebook appId.",result)},shareProductFbClick:function(){var e=this,t=window.location.protocol,n=window.location.host,r="";window.siteBaseURLPath&&window.siteBaseURLPath!=="/"&&(r=window.siteBaseURLPath);var i=encodeURIComponent(t+"//"+n+r+e.product().route()),s=e.siteFbAppId(),o="https://www.facebook.com/sharer/sharer.php?app_id="+s+"&u="+i,u=window.open(o,"facebookWin","width=720, height=500");u&&u.focus()},shareProductEmailClick:function(){var e=this,t=[],n=window.location.protocol,r=window.location.host,i="";window.siteBaseURLPath&&window.siteBaseURLPath!=="/"&&(i=window.siteBaseURLPath);var s=n+"//"+r+i+e.product().route();t.push("mailto:?"),t.push("subject="),t.push(encodeURIComponent(e.translate("shareProductEmailSubject",{productName:e.product().displayName()}))),t.push("&body=");var o=[];o.push(e.translate("shareProductEmailBodyIntro",{productName:e.product().displayName()})),o.push("\n\n"),o.push(s),t.push(encodeURIComponent(o.join(""))),window.location.href=t.join("")},handleLoadEvents:function(t){t.toUpperCase()===g?(f.create(y),e("#cc-product-spinner").css("z-index",1)):t.toUpperCase()===m&&this.removeSpinner()},loadImage:function(){if(b){var t=e("#cc-image-viewer").html();t?this.loadViewer(this.handleLoadEvents.bind(this)):this.viewportWidth()>r.VIEWPORT_TABLET_UPPER_WIDTH?this.loadMagnifier():this.viewportWidth()>=r.VIEWPORT_TABLET_LOWER_WIDTH?this.loadZoom():this.loadCarouselZoom()}else w++978?this.isMobile(!1):e<=978&&this.isMobile(!0)},priceUnavailableText:function(){return o.t("ns.OCS_productDetailsUsedCar:resources.priceUnavailable")},isInDialog:function(){return e("#CC-prodDetails-addToCart").closest(".modal").length},getSelectedProducts:function(){if(!!this.validateAddToPurchaseList()){var t=this.variantOptionsArray(),n=this.getSelectedSkuOptions(t),r={selectedOptions:n},i=e.extend(!0,{},this.product().product,r);i.desiredQuantity=parseInt(this.itemQuantity(),10),this.variantOptionsArray().length>0&&(i.childSKUs=[this.selectedSku()]);var o={productId:i.id,catRefId:i.childSKUs[0].repositoryId,quantityDesired:i.desiredQuantity,displayName:i.displayName},u=[];return u.push(o),u}s.sendError(this.WIDGET_ID,this.translate("productAddError"))},validateAddToPurchaseList:function(){var e=!0;if(this.variantOptionsArray().length>0){var t=this.variantOptionsArray();for(var n=0;n0&&this.selectedSku()?e=e&&!this.selectedSku().configurable:e=e&&!this.product().isConfigurable();var i=this.itemQuantity();if(i.toString()!="")if(!i.toString().match(/^\d+$/)||Number(i)<0)return!1;var s=e&&this.product().childSKUs().length>0;return s},clickCotizarButton:function(t){var n=t;e.Topic("SendUsados").publish(n.product().product)},clickReservarButton:function(n){e.Topic("ga_add_to_cart.memory").publish(v.product().product),localStorage.clear();var n=n;h.utils.removeCache("actionType"),localStorage.setItem("flow_id",Date.now()),localStorage.setItem("ocs_product_id",n.product().id()),localStorage.setItem("ocw_product_x_patente",n.product().id()),localStorage.setItem("ocw_product_x_Ubicacion_Fisica",n.product().product.x_Ubicacion_Fisica),localStorage.setItem("ocw_product_x_modelo",n.product().product.x_modelo),localStorage.setItem("ocw_product_x_cilindrada",n.product().product.x_cilindrada),localStorage.setItem("ocw_product_x_kilometraje",n.product().product.x_kilometraje),localStorage.setItem("ocw_product_x_transmision",n.product().product.x_transmision),localStorage.setItem("ocw_product_x_marca",n.product().product.x_marca),localStorage.setItem("ocw_product_x_combustible",n.product().product.x_combustible),localStorage.setItem("ocw_product_x_color",n.product().product.x_color),localStorage.setItem("ocw_product_x_tipo",n.product().product.x_tipo),localStorage.setItem("ocw_product_x_agno",n.product().product.x_agno),localStorage.setItem("ocw_product_brand",n.product().product.x_marca),localStorage.setItem("cotiPrimaryLargeImageURL",n.product().product.primaryLargeImageURL),localStorage.setItem("cotiPrimarySmallImageURL",n.product().product.primarySmallImageURL),localStorage.setItem("modelo",n.product().x_modelo()),localStorage.setItem("version",n.product().x_version()),localStorage.setItem("patente",n.product().id()),localStorage.setItem("imagen",n.product().fullImageURLs()[0]),localStorage.setItem("agno",n.product().x_agno()),localStorage.setItem("kilometraje",n.product().x_kilometraje()),localStorage.setItem("combustible",n.product().x_combustible()),localStorage.setItem("transmision",n.product().x_transmision()),localStorage.setItem("pg_financiadoConvencional",n.product().allPrices().pg_financiadoConvencional),localStorage.setItem("montoDescuento",n.product().allPrices().montoDescuento),localStorage.setItem("pg_bonoDeMarca",n.product().allPrices().pg_bonoDeMarca),localStorage.setItem("pg_financiadoInteligenteBF",n.product().allPrices().pg_financiadoInteligenteBF),localStorage.setItem("pg_precioLista",n.product().allPrices().pg_precioLista);var r=Object.assign({},t.toJS(n.product()));r.variantOptionsArray&&r.variantOptionsArray.forEach(function(e){delete e.parent}),localStorage.setItem("x_product",JSON.stringify(r)),h.utils.cache("actionType","reserve"),p.goTo("/eleccion/"+n.product().id())},selectColorOption:function(t){e(".ocs-color-picker-option").removeClass("active"),e("#ocs-color-item-"+this.key.toLowerCase()).addClass("active"),t.selectedOption(this)},shareProductWhatsAppClick:function(){v.isMobile()?v.shareProductMobileWhatsapp():v.shareProductWebWhatsapp()},shareProductWebWhatsapp:function(){var e=v.product().route(),t=encodeURIComponent(v.product().displayName()),n=window.location.protocol,r=window.location.host,i=window.location.pathname,s=encodeURIComponent(n+"//"+r+i),o=encodeURIComponent(n+"//"+r+v.product().primaryLargeImageURL()),u=window.open("https://web.whatsapp.com://send?text="+s+"&description="+t+"&media="+o,"googlePlusWindow","width=720, height=500");u&&u.focus()},shareProductMobileWhatsapp:function(){var e=encodeURIComponent(v.product().displayName()),t=window.location.protocol,n=window.location.host,r=window.location.pathname,i=encodeURIComponent(t+"//"+n+r),s=encodeURIComponent(t+"//"+n+v.product().primaryLargeImageURL()),o=window.open("whatsapp://send?text="+i+"&description="+e+"&media="+s,"googlePlusWindow","width=720, height=500");o&&o.focus()},shareProductMobile:function(){navigator.share&&navigator.share({title:v.product().displayName(),text:"Mira este "+v.product().displayName()+" en Bruno Fritsch",url:window.location.href})},verSucursal:function(){h.goToLocations("autos-usados")},getPriceGroupName:function(e){var t;return e&&(t=h.pricesGropNames()[e]),t},lowerPrice:function(){var e=v.product().allPrices()[v.getPriceGroupName("financiadoConvencional")],t=v.product().allPrices()[v.getPriceGroupName("lista")],n=v.product().allPrices()[v.getPriceGroupName("bonoDeMarca")],r=v.product().allPrices()[v.getPriceGroupName("reservaWeb")];t>=8e6?v.autoenpagovis(!0):v.autoenpagovis(!1),e&&e Correos deben coincidir
'):T.validaRut(t)===!1?e("#widget_message_event").html(' Formato de RUT incorrecto
'):(localStorage.setItem("ocs_reserva_user",t),localStorage.setItem("ocs_reserva_email",n),e("#ocs-modal-validate").modal("hide"),p.goTo("/reserva-automovil")):e("#widget_message_event").html(' Falta información
')}else v.user_email()!=v.confirmation_user_email()?e("#widget_message_event").html(' Correos deben coincidir
'):x(v.user_email())===!1?e("#widget_message_event").html(' Formato de correo incorrecto
'):T.validaRut(v.cl_id())===!1?e("#widget_message_event").html(' Formato de RUT incorrecto
'):(localStorage.setItem("ocs_reserva_user",v.cl_id()),localStorage.setItem("ocs_reserva_email",v.user_email()),e("#ocs-modal-validate").modal("hide"),p.goTo("/reserva-automovil"))}}})