(window.webpackJsonp=window.webpackJsonp||[]).push([[191],{370:function(e,t,r){"use strict";r.r(t);var o=r(0),n=r(2),l=(r(307),r(19),r(308),r(135),r(27),r(87),r(7)),c=r.n(l),d=r(4);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}var m={props:{rut:{type:String,required:!0},email:{type:String,required:!0},name:{type:String,required:!0}},data:e=>({coupon:null,lastCode:"",throttled:!1,throttleTimer:null,secondsUntilNextTry:0,form:e.$vform.make()}),computed:{couponIsValid(){return!(this.$attrs.error||this.form.errors.any()||this.throttled)},errorMessages(){return this.throttled?"Demasiados intentos, por favor espere ".concat(this.secondsUntilNextTry," segundos."):this.$attrs["error-messages"]||this.form.errors.first()},disabled(){return this.form.busy||this.$attrs.disabled||this.throttled},hint(){if(this.coupon&&"global"===this.coupon.scope)return 1===this.coupon.tipo?"".concat(this.coupon.valor,"% de descuento"):this.$toCurrency(this.coupon.valor)},config(){return function(e){for(var t=1;t"string"==typeof e&&e.trim());if(n)return n}return"string"==typeof(null==data?void 0:data.message)&&data.message.trim()?data.message:429===(null==e||null===(r=e.response)||void 0===r?void 0:r.status)?"Has realizado demasiados intentos. Espera unos segundos e inténtalo nuevamente.":"No fue posible validar el cupón en este momento. Inténtalo nuevamente."},handleInput(){var code=this.$attrs.value;!this.throttled&&code?code!==this.lastCode&&this.verifyCouponCode(code):this.coupon=null},handleThrottledResponse(e){this.lastCode="",this.throttled=!0,this.secondsUntilNextTry=parseInt(e.headers["retry-after"]),this.throttleTimer=setInterval(()=>{this.secondsUntilNextTry--,this.secondsUntilNextTry||(this.form.clear(),this.throttled=!1,clearInterval(this.throttleTimer),this.$nextTick(()=>this.focus()))},1e3)},focus(){this.$refs.input.focus()}}},f=m,v=r(1),component=Object(v.a)(f,function(){var e=this;return(0,e._self._c)("v-text-field",e._g(e._b({ref:"input",attrs:{hint:e.hint,"hide-details":"auto",disabled:e.disabled,loading:e.form.busy,error:!e.couponIsValid,"error-messages":e.errorMessages,"persistent-hint":Boolean(e.hint)},on:{blur:e.handleInput,keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),t.preventDefault(),e.handleInput.apply(null,arguments))}}},"v-text-field",e.config,!1),e.$listeners))},[],!1,null,null,null);t.default=component.exports}}]);