var NineYi;(function(n){var t;(function(n){var t;(function(n){var t;(function(n){n[n.Day=0]="Day";n[n.Hour=1]="Hour";n[n.Minute=2]="Minute";n[n.Second=3]="Second"})(t=n.ClockTypeEnum||(n.ClockTypeEnum={}))})(t=n.Models||(n.Models={}))})(t=n.Mall||(n.Mall={}))})(NineYi||(NineYi={})),function(n){var t;(function(n){var t;(function(t){t.clockStrategy={Day:function(n){return Math.floor(n/864e5)},Hour:function(n){return Math.floor(n%864e5/36e5)},Minute:function(n){return Math.floor(n%36e5/6e4)},Second:function(n){return Math.floor(n%6e4/1e3)},ClockCount:function(i,r){return r&&r>0?t.clockStrategy[n.Models.ClockTypeEnum[i]](r):-1}};t.clockHtmlStrategy={Day:function(n){return n.toString()},Hour:function(n){return n.toString()},Minute:function(n){return n.toString()},Second:function(n){return n.toString()},CreateClockElement:function(i,r,u,f){var e="",o;return r>=0?(o=t.clockHtmlStrategy[n.Models.ClockTypeEnum[i]](r,f).split(""),o.forEach(function(n){e+='<span class="clock-box">'+(f&&o.length===1?"0"+n:n)+"<\/span>"})):e=u?"":f?"00":"0",e}};var i=function(){function i(t,i,r){var u=this;this.$log=t;this.$timeout=i;this.$sce=r;this.restrict="EA";this.replace=!0;this.scope={EndDate:"=nsClockEndDate",ClockCondition:"=?nsClockCondition",ClockClass:"=?nsClockClass",ClockIsClosed:"&nsClockIsClosed",HideWhenTimesUp:"=?nsClockHideWhenTimesUp",IsTwoDigit:"=?nsIsTwoDigit",IsFullCountDown:"=?nsIsFullCountDown",ClockId:"=?nsClockId"};this.templateUrl="/V2/TypeScripts/Components/ns-clock/clock.html";this.link=function(t){var i,r,f;t.isFirstTime=!0;t.IsHide=!1;angular.isUndefined(t.HideWhenTimesUp)&&(t.HideWhenTimesUp=!0);angular.isUndefined(t.IsTwoDigit)&&(t.IsTwoDigit=!1);angular.isUndefined(t.IsFullCountDown)&&(t.IsFullCountDown=!1);angular.isUndefined(t.ClockId)&&(t.ClockId="");i=function(n,i){t.$emit("CountDownComplete",{id:n,isHide:i})};r=function(){requestAnimationFrame(function(){u.$timeout(function(){var n=u.DiffCount(t.EndDate);t.ClockData=u.CreateClock(n,t.ClockCondition,t.HideWhenTimesUp,t.IsTwoDigit);n>0?r():(angular.isFunction(t.ClockIsClosed)&&t.ClockIsClosed({EndDate:t.EndDate}),i(t.ClockId,t.HideWhenTimesUp))},t.isFirstTime?0:1e3)})};t.ClockCondition&&t.ClockCondition.length!==0?t.ClockCondition.sort(function(n,t){return n.Tick-t.Tick}):t.ClockCondition=t.IsFullCountDown?[{Tick:Number.MAX_VALUE,Format:[n.Models.ClockTypeEnum.Day,n.Models.ClockTypeEnum.Hour,n.Models.ClockTypeEnum.Minute,n.Models.ClockTypeEnum.Second]}]:[{Tick:6e4,Format:[n.Models.ClockTypeEnum.Second]},{Tick:36e5,Format:[n.Models.ClockTypeEnum.Minute,n.Models.ClockTypeEnum.Second]},{Tick:108e5,Format:[n.Models.ClockTypeEnum.Hour,n.Models.ClockTypeEnum.Minute,n.Models.ClockTypeEnum.Second]},{Tick:864e5,Format:[n.Models.ClockTypeEnum.Hour]},{Tick:2592e5,Format:[n.Models.ClockTypeEnum.Day]}];t.EndDate&&t.EndDate!==""||(t.IsHide=!0,i(t.ClockId,t.HideWhenTimesUp));f=u.DiffCount(t.EndDate);f>0&&f<t.ClockCondition[t.ClockCondition.length-1].Tick?(r(),t.IsHide=!1,t.isFirstTime=!1):(t.IsHide=!0,i(t.ClockId,t.HideWhenTimesUp),t.ClockData=u.InitClockData(t.HideWhenTimesUp,t.IsTwoDigit))}}return i.factory=function(){var n=function(n,t,r){return new i(n,t,r)};return n.$inject=["$log","$timeout","$sce"],n},i.prototype.DiffCount=function(n){try{if(isNaN(new Date(n).getTime()))return-1;var t=new Date(n).getTime()-(new Date).getTime();return t<0?-1:t}catch(i){return this.$log.log("傳入參數EndDate無法轉為Date:"+n),-1}},i.prototype.CreateClock=function(i,r,u,f){var s=this,e=this.InitClockData(u,f),o=r.filter(function(n){return i<=n.Tick})[0];return o&&o.Format.forEach(function(r){var o=t.clockStrategy.ClockCount(r,i),h=t.clockHtmlStrategy.CreateClockElement(r,o,u,f);e[n.Models.ClockTypeEnum[r]]=s.$sce.trustAsHtml(h)}),e},i.prototype.InitClockData=function(n,t){var i=n?"":t?"00":"0";return{Day:i,Hour:i,Minute:i,Second:i}},i}();t.ClockDirective=i;angular.module("NineYi.Mall.Directives").directive("nsClock",i.factory())})(t=n.Directives||(n.Directives={}))})(t=n.Mall||(n.Mall={}))}(NineYi||(NineYi={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w){this.config=n;this.$scope=t;this.$window=i;this.$translate=r;this.ShopId=u;this.Name=f;this.GoogleAnalyticsUtility=e;this.TrackingUtility=o;this.LineAdUtility=s;this.CookieUtility=h;this.UrlUtility=c;this.ShoppingCartUtility=l;this.backInStockUtility=a;this.AppVersionUtility=v;this.DeviceValue=y;this.PageValue=p;this.DialogUtility=w;this.activityUrl=location.href;this.Title=document.title;this.SetCommonCookie("fr",this.config.cookieExpireTimeForFR);this.SetCommonCookie("fr2",this.config.cookieExpireTimeForFR);this.SetCommonCookie("act",this.config.cookieExpireTimeForACT);this.TrackingUtility.trackLead({eventCategory:"activity",eventName:this.Name});this.$scope.$on("CountDownComplete",function(n,t){if(!!t.id&&t.isHide){var i=document.getElementById(t.id);i.style.display="none"}});this.CheckBackInStockStatus()}return n.prototype.shareOnFacebook=function(){var n,t;this.ShopId=this.ShopId==""?"0":this.ShopId;this.activityUrl=this.activityUrl.replace(/\/V2\/Activity/i,"/ref/"+this.ShopId+"/Activity")+"&official=true";n="&Source=Social&Medium=FacebookShare&Name=Ppage";this.activityUrl=this.activityUrl+n;this.Title&&(this.activityUrl+="&t="+encodeURIComponent(this.Title));t="https://www.facebook.com/share.php?u="+encodeURIComponent(this.activityUrl);this.TrackingUtility.trackSelectContent({contentType:"",name:"",linkUrl:"",id:"",adobeContentInfo:{eventInfo:{socialShareService:"Facebook"},eventMessage:"socialShareClick",exclude:"GA4"}});window.open(t)},n.prototype.shareLineLink=function(){var n,t,i;this.ShopId=this.ShopId==""?"0":this.ShopId;this.activityUrl=this.activityUrl.replace(/\/V2\/Activity/i,"/ref/"+this.ShopId+"/Activity")+"&official=true";n="&Source=Social&Medium=FacebookShare&Name=Ppage";this.activityUrl=this.activityUrl+n;t="https://line.naver.jp/R/msg/text/?";i=t+this.activityUrl;this.TrackingUtility.trackSelectContent({contentType:"",name:"",linkUrl:"",id:"",adobeContentInfo:{eventInfo:{socialShareService:"Line"},eventMessage:"socialShareClick",exclude:"GA4"}});window.open(i)},n.prototype.TrackEvent=function(n,t,i,r){this.GoogleAnalyticsUtility.TrackEvent(n,t,i,r)},n.prototype.SetCommonCookie=function(n,t){var i,r;document.location.hostname.match(/service.91app/)||(i=this.UrlUtility.GetQuerystring(n),i&&(this.CookieUtility.AddCookie("trace-"+n,i),r=this.CookieUtility.SetCookieExpireTime("trace-"+n,t),this.CookieUtility.AddCookie("trace-"+n+"-expires",r),this.CookieUtility.SetCookieExpireTime("trace-"+n+"-expires",t)))},n.prototype.CheckBackInStockStatus=function(){var n=this;this.AppVersionUtility.IsFromApp()||this.backInStockUtility.CheckBackInStockStatus(function(t){var i=t.salePageId;n.ShoppingCartUtility.AddToCart(i,n.ShopId,null).then(function(t){if(t){n.DialogUtility.Toast(t,n.DialogUtility.ToastModeEnum.Warning,750);return}n.DialogUtility.Toast(n.$translate.instant("frontend.typescripts.components.success_add"),n.DialogUtility.ToastModeEnum.Success,750)})})},n.prototype.AddToCart=function(n){var t=this,r=parseInt(n),i;if(this.AppVersionUtility.IsFromApp()){i=this.AppVersionUtility.GetOSandVersion();i.MajorNumber>=3||i.MajorNumber>=2&&i.MinorNumber>=24?this.$window.location.href="/V2/ActivityAddToCart?salePageId="+r:this.OldVersionAppRedirect(i.OS,r);return}this.ShoppingCartUtility.AddToCart(r,this.ShopId,null,null,null,!0).then(function(n){if(n){t.DialogUtility.Toast(n,t.DialogUtility.ToastModeEnum.Warning,750);return}t.DialogUtility.Toast(t.$translate.instant("frontend.typescripts.components.success_add"),t.DialogUtility.ToastModeEnum.Success,750)})},n.prototype.OldVersionAppRedirect=function(n,t){if(n.toLowerCase()==="ios"){var i=document.createElement("a");i.href="/SalePage/Index/"+t;i.click()}else n.toLowerCase()==="android"&&(this.$window.location.href="/SalePage/Index/"+t)},n.$inject=["Mall.Config","$scope","$window","$translate","ShopId","Name","GoogleAnalyticsUtility","TrackingUtility","LineAdUtility","CookieUtility","UrlUtility","ShoppingCartUtility","BackInStockUtility","AppVersionUtility","DeviceValue","PageValue","DialogUtility"],n}();n.ActivityController=t;angular.module("NineYi.Mall.Controllers").controller("ActivityController",t)})(t=n.Controllers||(n.Controllers={}))})(t=n.Mall||(n.Mall={}))}(NineYi||(NineYi={}))