(function(){var a;a=angular.module("session",["ngCookies"]),a.factory("session",["$cookieStore","$cookies","$log",function(a,b,c){var d;return d="__qcss",this.getAll=function(){var e;return e=b.get(d),(null==e||"object"!=typeof e)&&(c.debug("init cookie session"),e={},a.put(d,e,{secure:!0})),e},this.put=function(b,c){var e;return e=this.getAll(),e[b]=c,a.put(d,e,{secure:!0})},this.get=function(a){return this.getAll()[a]},this.remove=function(b){var c;return c=this.getAll(),delete c[b],a.put(d,c,{secure:!0})},this.clear=function(){return a.remove(d)},this}])}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;j=[{value:"en",name:"English",en_name:"English",currency:"USD"},{value:"zh_TW",name:"繁體中文",en_name:"Traditional Chinese",currency:"TWD"},{value:"zh",name:"简体中文",en_name:"Simplified Chinese",currency:"USD"},{value:"cs",name:"Czech",en_name:"Czech",currency:"USD"},{value:"da",name:"Dansk",en_name:"Danish",currency:"USD"},{value:"de",name:"Deutsch",en_name:"German",currency:"USD"},{value:"es",name:"Español",en_name:"Spanish",currency:"USD"},{value:"fr",name:"Français",en_name:"French",currency:"USD"},{value:"it",name:"Italiano",en_name:"Italian",currency:"USD"},{value:"ja",name:"日本語",en_name:"Japanese",currency:"USD"},{value:"ko",name:"한국",en_name:"Korean",currency:"USD"},{value:"no",name:"Norsk",en_name:"Norwegian",currency:"USD"},{value:"pl",name:"Polski",en_name:"Polish",currency:"USD"},{value:"ru",name:"Русский",en_name:"Russian",currency:"USD"},{value:"fi",name:"Suomi",en_name:"Finnish",currency:"USD"},{value:"sv",name:"Svenska",en_name:"Swedish",currency:"USD"},{value:"nl",name:"Nederlands",en_name:"Dutch",currency:"USD"},{value:"tr",name:"Turk dili",en_name:"Turkish",currency:"USD"},{value:"th",name:"ไทย",en_name:"Thai",currency:"USD"},{value:"pt",name:"Português",en_name:"Portuguese",currency:"USD"},{value:"hu",name:"Magyar",en_name:"Hungarian",currency:"USD"},{value:"el",name:"Ελληνικά",en_name:"Greek",currency:"USD"},{value:"ro",name:"Român",en_name:"Romanian",currency:"USD"}],a={en:"http://www.qnap.com/en/index.php?lang=en&sn=829",zh_TW:"http://www.qnap.com/cht/index.php?lang=zh-tw&sn=123",zh:"https://www.qnap.com.cn/",de:"http://www.qnap.com/de/index.php?lang=de&sn=374",es:"http://www.qnap.com/es/index.php?lang=es&sn=420",fr:"http://www.qnap.com/fr/index.php?lang=fr&sn=460",it:"http://www.qnap.com/it/index.php?lang=it&sn=499",nl:"http://www.qnap.com/nl/index.php?lang=nl&sn=538",pt:"http://www.qnap.com/pt/index.php?lang=pt&sn=578",ru:"http://qnap.ru/about",ja:"http://www.qnap.com/jp/index.php?lang=jp&sn=706",ko:"http://www.qnap.com/kr/index.php?lang=kr&sn=751"},e=[{name:"Afghanistan",country_code:"AF",code:"93"},{name:"Albania",country_code:"AL",code:"355"},{name:"Algeria",country_code:"DZ",code:"213"},{name:"Andorra",country_code:"AD",code:"376"},{name:"Angola",country_code:"AO",code:"244"},{name:"Antarctica",country_code:"AQ",code:"672"},{name:"Argentina",country_code:"AR",code:"54"},{name:"Armenia",country_code:"AM",code:"374"},{name:"Aruba",country_code:"AW",code:"297"},{name:"Ascension Island",country_code:"AC",code:"247"},{name:"Australia",country_code:"AU",code:"61"},{name:"Austria",country_code:"AT",code:"43"},{name:"Azerbaijan",country_code:"AZ",code:"994"},{name:"Bahamas",country_code:"BS",code:"1 242"},{name:"Bahrain",country_code:"BH",code:"973"},{name:"Bangladesh",country_code:"BD",code:"880"},{name:"Belarus",country_code:"BY",code:"375"},{name:"Belgium",country_code:"BE",code:"32"},{name:"Belize",country_code:"BZ",code:"501"},{name:"Benin",country_code:"BJ",code:"229"},{name:"Bhutan",country_code:"BT",code:"975"},{name:"Bolivia, Plurinational State Of",country_code:"BO",code:"591"},{name:"Bonaire, Saint Eustatius And Saba",country_code:"BQ",code:"599"},{name:"Bosnia & Herzegovina",country_code:"BA",code:"387"},{name:"Botswana",country_code:"BW",code:"267"},{name:"Brazil",country_code:"BR",code:"55"},{name:"British Indian Ocean Territory",country_code:"IO",code:"246"},{name:"Brunei Darussalam",country_code:"BN",code:"673"},{name:"Bulgaria",country_code:"BG",code:"359"},{name:"Burkina Faso",country_code:"BF",code:"226"},{name:"Burundi",country_code:"BI",code:"257"},{name:"Cambodia",country_code:"KH",code:"855"},{name:"Cameroon",country_code:"CM",code:"237"},{name:"Canada",country_code:"CA",code:"1"},{name:"Cape Verde",country_code:"CV",code:"238"},{name:"Central African Republic",country_code:"CF",code:"236"},{name:"Chad",country_code:"TD",code:"235"},{name:"Chile",country_code:"CL",code:"56"},{name:"China",country_code:"CN",code:"86"},{name:"Christmas Island",country_code:"CX",code:"61"},{name:"Cocos (Keeling) Islands",country_code:"CC",code:"61"},{name:"Colombia",country_code:"CO",code:"57"},{name:"Comoros",country_code:"KM",code:"269"},{name:"Cook Islands",country_code:"CK",code:"682"},{name:"Costa Rica",country_code:"CR",code:"506"},{name:"Cote d'Ivoire",country_code:"CI",code:"225"},{name:"Croatia",country_code:"HR",code:"385"},{name:"Cuba",country_code:"CU",code:"53"},{name:"Curacao",country_code:"CW",code:"599"},{name:"Cyprus",country_code:"CY",code:"357"},{name:"Czech Republic",country_code:"CZ",code:"420"},{name:"Democratic Republic Of Congo",country_code:"CD",code:"243"},{name:"Denmark",country_code:"DK",code:"45"},{name:"Djibouti",country_code:"DJ",code:"253"},{name:"East Timor",country_code:"TL",code:"670"},{name:"Ecuador",country_code:"EC",code:"593"},{name:"Egypt",country_code:"EG",code:"20"},{name:"El Salvador",country_code:"SV",code:"503"},{name:"Equatorial Guinea",country_code:"GQ",code:"240"},{name:"Eritrea",country_code:"ER",code:"291"},{name:"Estonia",country_code:"EE",code:"372"},{name:"Ethiopia",country_code:"ET",code:"251"},{name:"European Union",country_code:"EU",code:"388"},{name:"Falkland Islands",country_code:"FK",code:"500"},{name:"Faroe Islands",country_code:"FO",code:"298"},{name:"Fiji",country_code:"FJ",code:"679"},{name:"Finland",country_code:"FI",code:"358"},{name:"France",country_code:"FR",code:"33"},{name:"France, Metropolitan",country_code:"FX",code:"241"},{name:"French Guiana",country_code:"GF",code:"44"},{name:"French Polynesia",country_code:"PF",code:"689"},{name:"Gabon",country_code:"GA",code:"44"},{name:"Gambia",country_code:"GM",code:"220"},{name:"Georgia",country_code:"GE",code:"594"},{name:"Germany",country_code:"DE",code:"49"},{name:"Ghana",country_code:"GH",code:"233"},{name:"Gibraltar",country_code:"GI",code:"350"},{name:"Greece",country_code:"GR",code:"30"},{name:"Greenland",country_code:"GL",code:"299"},{name:"Grenada",country_code:"GD",code:"995"},{name:"Guadeloupe",country_code:"GP",code:"590"},{name:"Guatemala",country_code:"GT",code:"502"},{name:"Guinea",country_code:"GN",code:"224"},{name:"Guinea-bissau",country_code:"GW",code:"245"},{name:"Guyana",country_code:"GY",code:"592"},{name:"Haiti",country_code:"HT",code:"509"},{name:"Honduras",country_code:"HN",code:"504"},{name:"Hong Kong",country_code:"HK",code:"852"},{name:"Hungary",country_code:"HU",code:"36"},{name:"Iceland",country_code:"IS",code:"354"},{name:"India",country_code:"IN",code:"91"},{name:"Indonesia",country_code:"ID",code:"62"},{name:"Iran, Islamic Republic Of",country_code:"IR",code:"98"},{name:"Iraq",country_code:"IQ",code:"964"},{name:"Ireland",country_code:"IE",code:"353"},{name:"Isle Of Man",country_code:"IM",code:"44"},{name:"Israel",country_code:"IL",code:"972"},{name:"Italy",country_code:"IT",code:"39"},{name:"Jamaica",country_code:"JM",code:"1 876"},{name:"Japan",country_code:"JP",code:"81"},{name:"Jersey",country_code:"JE",code:"44"},{name:"Jordan",country_code:"JO",code:"962"},{name:"Kazakhstan",country_code:"KZ",code:"7"},{name:"Kenya",country_code:"KE",code:"254"},{name:"Kiribati",country_code:"KI",code:"686"},{name:"Korea, Democratic People's Republic Of",country_code:"KP",code:"850"},{name:"Korea, Republic Of",country_code:"KR",code:"82"},{name:"Kuwait",country_code:"KW",code:"965"},{name:"Kyrgyzstan",country_code:"KG",code:"996"},{name:"Lao People's Democratic Republic",country_code:"LA",code:"856"},{name:"Latvia",country_code:"LV",code:"371"},{name:"Lebanon",country_code:"LB",code:"961"},{name:"Lesotho",country_code:"LS",code:"266"},{name:"Liberia",country_code:"LR",code:"231"},{name:"Libya",country_code:"LY",code:"218"},{name:"Liechtenstein",country_code:"LI",code:"423"},{name:"Lithuania",country_code:"LT",code:"370"},{name:"Luxembourg",country_code:"LU",code:"352"},{name:"Macao",country_code:"MO",code:"853"},{name:"Macedonia, The Former Yugoslav Republic Of",country_code:"MK",code:"389"},{name:"Madagascar",country_code:"MG",code:"261"},{name:"Malawi",country_code:"MW",code:"265"},{name:"Malaysia",country_code:"MY",code:"60"},{name:"Maldives",country_code:"MV",code:"960"},{name:"Mali",country_code:"ML",code:"223"},{name:"Malta",country_code:"MT",code:"356"},{name:"Marshall Islands",country_code:"MH",code:"692"},{name:"Martinique",country_code:"MQ",code:"596"},{name:"Mauritania",country_code:"MR",code:"222"},{name:"Mauritius",country_code:"MU",code:"230"},{name:"Mayotte",country_code:"YT",code:"262"},{name:"Mexico",country_code:"MX",code:"52"},{name:"Micronesia, Federated States Of",country_code:"FM",code:"691"},{name:"Moldova",country_code:"MD",code:"373"},{name:"Monaco",country_code:"MC",code:"377"},{name:"Mongolia",country_code:"MN",code:"976"},{name:"Montenegro",country_code:"ME",code:"382"},{name:"Montserrat",country_code:"MS",code:"1 664"},{name:"Morocco",country_code:"MA",code:"212"},{name:"Mozambique",country_code:"MZ",code:"258"},{name:"Myanmar",country_code:"MM",code:"95"},{name:"Namibia",country_code:"NA",code:"264"},{name:"Nauru",country_code:"NR",code:"674"},{name:"Nepal",country_code:"NP",code:"977"},{name:"Netherlands",country_code:"NL",code:"31"},{name:"New Caledonia",country_code:"NC",code:"687"},{name:"New Zealand",country_code:"NZ",code:"64"},{name:"Nicaragua",country_code:"NI",code:"505"},{name:"Niger",country_code:"NE",code:"227"},{name:"Nigeria",country_code:"NG",code:"234"},{name:"Niue",country_code:"NU",code:"683"},{name:"Norfolk Island",country_code:"NF",code:"672"},{name:"Northern Mariana Islands",country_code:"MP",code:"1 670"},{name:"Norway",country_code:"NO",code:"47"},{name:"Oman",country_code:"OM",code:"968"},{name:"Pakistan",country_code:"PK",code:"92"},{name:"Palau",country_code:"PW",code:"680"},{name:"Palestinian Territory, Occupied",country_code:"PS",code:"970"},{name:"Panama",country_code:"PA",code:"507"},{name:"Papua New Guinea",country_code:"PG",code:"675"},{name:"Paraguay",country_code:"PY",code:"595"},{name:"Peru",country_code:"PE",code:"51"},{name:"Philippines",country_code:"PH",code:"63"},{name:"Poland",country_code:"PL",code:"48"},{name:"Portugal",country_code:"PT",code:"351"},{name:"Puerto Rico",country_code:"PR",code:"1 787"},{name:"Qatar",country_code:"QA",code:"974"},{name:"Republic Of Congo",country_code:"CG",code:"242"},{name:"Reunion",country_code:"RE",code:"262"},{name:"Romania",country_code:"RO",code:"40"},{name:"Russian Federation",country_code:"RU",code:"7"},{name:"Rwanda",country_code:"RW",code:"250"},{name:"Saint Barthélemy",country_code:"BL",code:"590"},{name:"Saint Helena, Ascension And Tristan Da Cunha",country_code:"SH",code:"290"},{name:"Saint Martin",country_code:"MF",code:"590"},{name:"Saint Pierre And Miquelon",country_code:"PM",code:"508"},{name:"Samoa",country_code:"WS",code:"685"},{name:"San Marino",country_code:"SM",code:"378"},{name:"Sao Tome And Principe",country_code:"ST",code:"239"},{name:"Saudi Arabia",country_code:"SA",code:"966"},{name:"Senegal",country_code:"SN",code:"221"},{name:"Serbia",country_code:"RS",code:"381"},{name:"Seychelles",country_code:"SC",code:"248"},{name:"Sierra Leone",country_code:"SL",code:"232"},{name:"Singapore",country_code:"SG",code:"65"},{name:"Slovakia",country_code:"SK",code:"421"},{name:"Slovenia",country_code:"SI",code:"386"},{name:"Solomon Islands",country_code:"SB",code:"677"},{name:"Somalia",country_code:"SO",code:"252"},{name:"South Africa",country_code:"ZA",code:"27"},{name:"Spain",country_code:"ES",code:"34"},{name:"Sri Lanka",country_code:"LK",code:"94"},{name:"Sudan",country_code:"SD",code:"249"},{name:"Suriname",country_code:"SR",code:"597"},{name:"Svalbard And Jan Mayen",country_code:"SJ",code:"47"},{name:"Swaziland",country_code:"SZ",code:"268"},{name:"Sweden",country_code:"SE",code:"46"},{name:"Switzerland",country_code:"CH",code:"41"},{name:"Syrian Arab Republic",country_code:"SY",code:"963"},{name:"Taiwan",country_code:"TW",code:"886"},{name:"Tajikistan",country_code:"TJ",code:"992"},{name:"Tanzania, United Republic Of",country_code:"TZ",code:"255"},{name:"Thailand",country_code:"TH",code:"66"},{name:"Togo",country_code:"TG",code:"228"},{name:"Tokelau",country_code:"TK",code:"690"},{name:"Tonga",country_code:"TO",code:"676"},{name:"Tristan de Cunha",country_code:"TA",code:"290"},{name:"Tunisia",country_code:"TN",code:"216"},{name:"Turkey",country_code:"TR",code:"90"},{name:"Turkmenistan",country_code:"TM",code:"993"},{name:"Tuvalu",country_code:"TV",code:"688"},{name:"Uganda",country_code:"UG",code:"256"},{name:"Ukraine",country_code:"UA",code:"380"},{name:"United Arab Emirates",country_code:"AE",code:"971"},{name:"United Kingdom",country_code:"UK",code:"44"},{name:"United States",country_code:"US",code:"1"},{name:"Uruguay",country_code:"UY",code:"598"},{name:"Uzbekistan",country_code:"UZ",code:"998"},{name:"Vanuatu",country_code:"VU",code:"678"},{name:"Vatican City State",country_code:"VA",code:"379"},{name:"Venezuela, Bolivarian Republic Of",country_code:"VE",code:"58"},{name:"Viet Nam",country_code:"VN",code:"84"},{name:"Wallis And Futuna",country_code:"WF",code:"681"},{name:"Western Sahara",country_code:"EH",code:"212"},{name:"Yemen",country_code:"YE",code:"967"},{name:"Zambia",country_code:"ZM",code:"260"},{name:"Zimbabwe",country_code:"ZW",code:"263"}],k=[{name:"臺北市"},{name:"新北市"},{name:"桃園市"},{name:"臺中市"},{name:"台南市"},{name:"高雄市"},{name:"基隆市"},{name:"新竹市"},{name:"嘉義市"},{name:"新竹縣"},{name:"苗栗縣"},{name:"彰化縣"},{name:"南投縣"},{name:"雲林縣"},{name:"嘉義縣"},{name:"屏東縣"},{name:"宜蘭縣"},{name:"花蓮縣"},{name:"臺東縣"},{name:"澎湖縣"},{name:"金門縣"},{name:"連江縣"}],i={en:"en_US",zh_TW:"zh_TW",zh:"zh_CN",cs:"en_US",de:"de_DE",es:"en_US",fr:"fr_FR",it:"it_IT",ja:"ja_JP",ko:"ko_KR",no:"no_NO",pl:"pl_PL",ru:"ru_RU",fi:"en_US",sv:"en_US",nl:"nl_NL",tr:"en_US",th:"th_TH",pt:"pt_PT",hu:"en_US",el:"en_US",ro:"en_US"},f=50,g=50,h=100,l=50,b=200,m=20,d=50,c=QCONFIG.image_css_url.replace("license",""),n=angular.module("common",["ui.bootstrap","ngCookies","session","LocalStorageModule"]),n.config(["$logProvider",function(a){var b;return b="undefined"!=typeof QCONFIG&&null!==QCONFIG?QCONFIG.debug:void 0,null==b&&(b=!0),a.debugEnabled(b)}]),n.run(["$rootScope","$cookies","$window","$log","$location","$modal","$timeout","apiService","messageService","session","localStorageService",function(n,q,t,u,v,x,y,z,A,B,C){var D,E,F,G,H;return QCONFIG.china_site&&(D=v.absUrl(),-1===D.indexOf("/receive_auth")&&(null!=r("lang")?(q.put("lang","zh",{expires:o(),path:"/",secure:!0}),"zh"!==r("lang")&&(G="lang="+r("lang"),D=D.replace(G,"lang=zh"),t.location.href=D)):null!=q.get("lang")&&"zh"===q.get("lang")?u.debug("no redirect"):(q.put("lang","zh",{expires:o(),path:"/",secure:!0}),F=new URL(D),E=F.protocol+"//"+F.hostname+F.pathname,null!=F.search&&F.search.length>1?E=E+F.search+"&lang=zh":E+="?lang=zh",t.location.href=E))),n.CDN_PATH=c,n.countries=e,n.taiwan_city=k,n.SUPPORTED_LANGUAGES=j,n.PAYPAL_MAPPING=i,n.now_year=QCONFIG.year,n.first_name_max_length=f,n.last_name_max_length=g,n.organization_max_length=h,n.vat_id_max_length=l,n.address_max_length=b,n.zip_code_max_length=m,n.city_max_length=d,n.functional_cookie=["summary_view_mode","lang","__qcss","is_mobile_device","DEV_","QA_","SESSION_ID","ALPHA_","fbsr_","fbm_","_xsrf","G_","DEV_"],n.analytic_cookie=["mtc_id","mtc_sid","mautic_device_id","mautic_referer_id","mautic_session_id","_gid","_hj","_ga"],n.screen_mask=!1,n.full_page_loading=!1,n.show_remind_old_license_store=QCONFIG.show_remind_old_license_store,n.is_sign_in=null!=q.get("access_token"),u.debug("$location.host()",v.host()),n.current_view=v.path(),n.current_lang=p(),n.mobile_device_reg=/^\/{1}[0-9A-Z.\-+]{7}$/,n.natural_person_reg=/^[A-Z]{2}[0-9]{14}$/,n.user_profile=null,n.is_zh="zh"===n.current_lang,G=$("#footer_word").text(),n.footer_word=G.replace("2013-2014",QCONFIG.year),n.mobile_menu_word=A.getText("page_name_my_license"),n.mobile_menu_icon="icon-my-license.svg",null!=q.get("cookie_setting")?n.cookie_setting=JSON.parse(q.get("cookie_setting")):n.cookie_setting={functional:!0,analytic:!0},H=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(e=Object.keys(q.getAll()),u.debug("document.cookie before:",document.cookie),b=QCONFIG.auth_path.split("//")[1],g=[b,"."+QCONFIG.license_shop_domain,".qnap.com","."+b],h=0,k=e.length;k>h;h++)for(d=e[h],i=0,l=a.length;l>i;i++)if(c=a[i],-1!==d.indexOf(c)){for(document.cookie=d+"=;expires=Thu, 01 Jan 1990 00:00:01 GMT;path=/;",j=0,m=g.length;m>j;j++)f=g[j],document.cookie=d+"=;expires=Thu, 01 Jan 1990 00:00:01 GMT;path=/;domain="+f;u.debug("cookie_key:",d)}return u.debug("delete after:",document.cookie)},n.checkCookieSettings=function(){u.debug("do checkCookieSettings:",n.cookie_setting),n.cookie_setting.analytic||H(n.analytic_cookie),n.cookie_setting.functional||H(n.functional_cookie)},n.goToQnap=function(){t.open("http://www.qnap.com/","_blank")},n.checkVAT=function(a){var b,c,d,e,f,g;if(d="00000000,11111111",g=/^\d{8}$/,g.test(a)===!1||-1!==d.indexOf(a))return!1;for(f=[1,2,1,2,1,2,4,1],e=0,b=function(a){var b,c;return b=a%10,c=(a-b)/10,b+c},c=0;cparseFloat(c)&&(d.exceed=!0),d},n.setView=function(a,b){return u.debug("setView:",a),null!=b?v.search(b):v.search({}),v.path(a),n.current_view=a},n.showPageLoading=function(){return n.full_page_loading=!0},n.hidePageLoading=function(){return n.full_page_loading=!1},n.showDialogLoading=function(a){return u.debug("showDialogLoading",a),n.$broadcast("evt_show_dialog_loading",a)},n.hideDialogLoading=function(){return n.$broadcast("evt_hide_dialog_loading")},n.showScreenMask=function(){return u.debug("showScreenMask"),n.screen_mask=!0},n.hideScreenMask=function(){return n.screen_mask=!1},n.cancelOrder=function(a,b){return null==b&&(b=null),u.debug("do cancelOrder"),z.cancelOrder(a).then(function(a){return u.debug("cancelOrder",a),null!=b?(u.debug("do callback success"),b()):void 0},function(a){return u.debug("checkTradeInfo error",a),null!=b?(u.debug("do callback error"),b()):void 0})},n.showSignInDialog=function(){var a,b;return a=n.$new(!0),a.signin_url=QCONFIG.auth_path+"/v2/mobilesignin",b=x.open({templateUrl:w("/partials/dialog/sign_in_dialog.mak?cacheSlayer="+(new Date).getTime()),backdrop:"static",scope:a}),b.result.then(function(a){return u.debug("result",a)})},n.signin=function(a){var b,c,d,e,f;return b=function(a){return a.toString(CryptoJS.enc.Base64).replace(/\=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e=s(32),q.put("code_verifier",e,{expires:o()}),c=b(CryptoJS.SHA256(e)),d="S256",f=new URI(QCONFIG.auth_path+"/oauth/auth"),f.setQuery("lang",p()),f.setQuery("response_type","code"),f.setQuery("code_challenge",c),f.setQuery("code_challenge_method",d),f.setQuery("client_id",QCONFIG.client_id),f.setQuery("redirect_uri",QCONFIG.redirect_uri),u.debug("location.url",v.url()),a?f.setQuery("state",a):f.setQuery("state","/#"+v.url()),u.debug("signin_url",f.href()),t.location.href=f.href()},n.signup=function(){return n.gotoAuthCenter("/signup")},n.signout=function(){var a;return C.clearAll(),q.remove("access_token"),q.remove("refresh_token"),q.remove("user_id"),q.remove("code_verifier"),B.clear(),a=new URI(QCONFIG.auth_path+"/signout"),a.setQuery("app_id",QCONFIG.client_id),a.setQuery("redirect_uri",QCONFIG.redirect_uri),t.location.href=a.href()},n.logout=function(){return q.remove("access_token"),q.remove("refresh_token"),q.remove("code_verifier"),q.remove("user_id"),B.clear(),t.location.href="/"},n.gotoAuthCenter=function(a,b){var c,d,e;return null==a&&(a=""),e=new URI(QCONFIG.auth_path+a),null!=q.get("not_notice_site_ip_check")&&e.setQuery("not_notice","yes"),e.setQuery("app_id",QCONFIG.client_id),e.setQuery("lang",p()),e.setQuery("redirect_uri",QCONFIG.license_shop_path+"/receive_auth"),c=new URI,d="/"!==c.path()?"/":c.href(),e.setQuery("state",d),u.debug("gotoAuthCenter",e.href()),b?t.open(e):t.location.href=e.href()},n.gotoInternalUrl=function(a,b){a=w(a),b?t.open(a):t.location.href=a},n.gotoCMS=function(a,b){var c,d;c=QCONFIG.cms_url+"/"+a.replace(/^\//,""),d=new URI(c),d=w(d.href()),b?t.open(d):t.location.href=d},n.gotoStatus=function(a,b){var c,d;c=QCONFIG.status_url+"/"+a.replace(/^\//,""),d=new URI(c),d=w(d.href()),b?t.open(d):t.location.href=d},n.gotoAboutUs=function(){var b;b=a[p()],b||(b=a.en),t.open(b)},n.onRootMousedown=function(a){return n.$broadcast("evt_root_mousedown",arguments)},n.onRootClick=function(a){return n.$broadcast("evt_root_click",arguments)},n.checkNetWork=function(){var a;return a=navigator.onLine},n.checkEmailIsVerified=function(a){return null!=a.emails&&a.emails.length>0&&a.emails[0].is_verified===!0?!0:!1},n.checkInvoiceData=function(a){var b;switch(b=function(a){return a.first_name="",a.last_name="",a.organization="",a.vat_id="",a.address="",a.zip="",a.city="",a},u.debug("checkInvoiceData billing_info.invoice_type",a.invoice_type),a.invoice_type){case"donation":a=b(a),a.invoice_carrier="donation",a.invoice_carrier_number=a.xca_org.code;break;case"invoice_carrier":a=b(a),a.invoice_carrier=a.save_type.value,a.invoice_carrier_number=a.save_type_code;break;default:a.invoice_carrier=null,a.invoice_carrier_number=null}return a},n.localizedUrl=w,$(document).keydown(function(a){return 27===a.keyCode?n.hideScreenMask():void 0})}]),n.service("messageService",function(){return this.getText=function(a,b,c){var d,e;if(c||"object"!=typeof b||(c=b,b=null),e=$("#message_"+a).text()||b||a,null!=c)for(d in c)e=e.replace("{"+d+"}",c[d]);return e},this.getHtml=function(a,b,c,d){var e,f,g;if("object"==typeof b&&angular.isFunction(c)&&(d=c,c=b,b=null),c||"object"!=typeof b||(c=b,b=null),f=angular.isFunction(d)?d($("#message_"+a).clone()):$("#message_"+a).html(),g=f||b||a,null!=c)for(e in c)g=g.replace("{"+e+"}",c[e]);return g},this}),n.service("utilities",["$window","$log",function(a,b){var c,d;return d=[[1099511627776,"TB"],[1073741824,"GB"],[1048576,"MB"],[1024,"KB"]],c=["TWD","HUF","JPY"],this.FILE_NAME_PATTERN=new RegExp('^[^/|\\\\?<>*"]+$'),this.checkPayPalDecimalAmounts=function(a,d){var e,f,g;for(f=0,g=c.length;g>f;f++)if(e=c[f],d.toUpperCase()===e){a=Math.floor(a);break}return b.debug("checkPayPalDecimalAmounts",a),a},this.checkFileName=function(a){return a.length<=0?"error_filename_empty":a.length>253?"error_filename_too_long":this.FILE_NAME_PATTERN.test(a)?void 0:"error_filename_invalid"},this.getReadableFileSize=function(a){var b,c,e;for(c=0;c=d[c][0]||c===d.length-1){b=d[c][0],e=d[c][1];break}c++}return(Math.round(100*a/b)/100).toString()+e},this.localizedDateTime=function(a,b){var c;return null==b&&(b="YYYY-MM-DD HH:mm:ss"),c=moment().zone(),moment.utc(a).zone(c).format(b)},this.moneyDisplayType=function(a){var b,c,d,e;for(a=a.toString(),d=a.match(/e\+(\d+)$/),b=0,a=a.replace(/e.+$/,""),d&&(b=Number(d[1])),e=a.split("."),e.length>=2&&b&&(e.length>b?(e[0]+=e[1].slice(0,b-1),e[1]=e[1].slice(b-1,e[1].length-1)):(e[0]+=e[1]+"0".repeat(b-e.length),e[1]="")),e[0]=e[0].split(""),c=e[0].length;(c-=3)>0;)e[0].splice(c,0,",");return"$"+e[0].join("")+(e[1]?"."+e[1]:"")},this.resolvePath=function(){var a,b,c,d,e;for(b=[],d=0,e=arguments.length;e>d;d++)a=arguments[d],null!=a?b.push(a.trim()):b.push("");return c=b.join("/"),c="/"+c,c=c.replace(/[\/]+/g,"/"),c.length>1&&"/"===c.slice(-1)&&(c=c.slice(0,-1)),c},this.getParentPath=function(a){var b;return null==a&&(a="/"),"/"===!a[0]&&(a="/"+a),"/"===a?null:(b=a.split("/"),2===b.length?"/":b.slice(0,b.length-1).join("/"))},this.goTopPath=function(a){var b;return null==a&&(a="/"),"/"===!a[0]&&(a="/"+a),b=a.split("/"),b.length>1?"/"+b[1]:"/"},this.openWindow=function(b,c,d){var e,f;return(null==c||0>=c)&&(c=640),(null==d||0>=d)&&(d=480),f=(screen.height-d)/2,e=(screen.width-c)/2,a.open(b,"myQNAPcloud","status=1,resizable=1,scrollbars=1,location=0,titlebar=0,toolbar=0,menubar=0,width="+c+",height="+d+",left="+e+",top="+f)},this.isEmail=function(a){var b;return b=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,b.test(a)},this.getQueryParam=r,this}]),n.filter("moment",["utilities",function(a){return function(b,c){return b?(null==c&&(c="YYYY-MM-DD HH:mm:ss"),a.localizedDateTime(b,c)):""}}]),n.filter("money",["utilities",function(a){return function(b){return b?a.moneyDisplayType(b):""}}]),window.console&&window.console.log||(window.console={log:function(){}}),Array.prototype.remove=function(){var a,b,c,d,e;for(d=void 0,b=arguments,a=b.length,c=void 0,e=[];a&&this.length;)d=b[--a],e.push(function(){var a;for(a=[];-1!==(c=this.indexOf(d));)a.push(this.splice(c,1));return a}.call(this));return e},s=function(a){var b,c,d,e;for(e="",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c=b.length,d=0;a>d;)e+=b.charAt(Math.floor(Math.random()*c)),d++;return e},r=function(a){var b;return b=(new URI).query(!0),b[a]},window.getQueryParam=r,x=function(a,b){var c,d,e,f;if(f=a.split("?"),f.length>=2){for(e=encodeURIComponent(b)+"=",d=f[1].split(/[&;]/g),c=d.length;c-->0;)-1!==d[c].lastIndexOf(e,0)&&d.splice(c,1);return a=f[0]+(d.length>0?"?"+d.join("&"):"")}return a},window.removeQueryParameter=x,o=function(){var a,b;return b=new Date,a=new Date(b.getFullYear()+50,b.getMonth(),b.getDate())},window.getCookieExpireDate=o,p=function(){var a,b,c,d,e,f,g,h,i,k;for(f="lang=",d=null,b=document.cookie.split(";"),g=0,i=b.length;i>g;g++){for(a=b[g];" "===a.charAt(0);)a=a.substring(1);if(0===a.indexOf(f)){d=a.substring(f.length,a.length);break}}for(d||(d=navigator.language||navigator.userLanguage,d="zh-TW"===d?"zh_TW":d.substring(0,2)),c=!1,h=0,k=j.length;k>h;h++)if(e=j[h],d===e.value){c=!0;break}return c||(d="en"),document.cookie="lang="+d+"; secure; path=/; expires="+o(),d?d.replace("-","_"):void 0},window.getCurrentLang=p,q=function(){return(new URI).path()},window.getCurrentPath=q,y=function(a,b,c){var d,e;return d=new Blob([a],c),e=new File([d],b,c)},window.stringToFileBinaryData=y,w=function(a,b){return a=new URI(a),b||(b=p()),a.href()},window.localizedUrl=w,String.prototype.startsWith=function(a){return this.substr(0,a.length)===a},String.prototype.splice=function(a,b,c){return this.slice(0,a)+c+this.slice(a+Math.abs(b))},t=function(a){var b;return b=/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?\s*/,b.test(a)},window.isUrlIPV6=t,v=["common"],u=function(a){return a?a.length?v=v.concat(a):v.push(a):void 0},window.loadModule=u,$(function(){return window.console&&console.log&&console.log("angularjs bootstrap",v),angular.bootstrap(document,v)})}.call(this),function(){var a,b;b=null,a=angular.module("profile",["common","api_service","ngCookies"]),a.run(["$rootScope","$log","$cookies","apiService","alertService",function(a,c,d,e,f){return a.is_sign_in&&null!=d.get("access_token")?(c.debug("Fetching user profile"),b=e.getProfile().then(function(b){return c.debug("Get user profile",b),a.user_profile=b.result},function(a){return c.error("Fail to get user profile",a),f.error(a)})):void 0}]),a.service("profileService",function(){return this.getProfile=function(){return b},this})}.call(this),function(){var a;a=angular.module("ui",["common","api_service"]),a.directive("onErrorSrc",function(){return{link:function(a,b,c){return b.bind("error",function(){return c.src!==c.onErrorSrc?c.$set("src",c.onErrorSrc):void 0})}}}),a.directive("resizeContent",["$window",function(a){return function(b,c,d,e){var f;f=function(){var b;b=d.resizeContent,c.css("height",$(a).height()-b)},$(a).resize(function(){f()}),f()}}]),a.directive("placeholder",["$window",function(a){return function(a,b,c,d){$(b).placeholder()}}]),a.directive("blurOnEnter",["$parse",function(a){return function(a,b,c){return b.bind("keydown",function(a){return 13===a.which?b.blur():void 0})}}]),a.filter("rawHtml",["$sce",function(a){return function(b){return a.trustAsHtml(b)}}]),a.directive("retype",function(){return{require:"ngModel",link:function(a,b,c,d){var e,f;e=function(b){var c,e;return c=a[f],e=!c||b===c,d.$setValidity("retype",e),b},f=c.retype,a.$watch(f,function(){return e(d.$viewValue)}),d.$parsers.unshift(function(a){return e(a)}),e(d.$viewValue)}}}),a.directive("allows",function(){return function(a,b,c,d){var e,f;e=c.allows,f=[13,8,0],e&&$(b).keypress(function(a){var b,c,d;if(b=!1,f.indexOf)b=f.indexOf(a.which)>=0;else for(d=0;d=0)})}}),a.directive("birthday",function(){return{templateUrl:localizedUrl("/partials/birthday.html"),replace:!0,restrict:"E",require:"ngModel",link:function(a,b,c,d){var e;e=function(){var b,e,f,g,h,i;e={},f=void 0===a.year||void 0===a.month||void 0===a.date,g=void 0,d.$setValidity("required",!f),f||(b=moment([a.year,a.month-1,a.date]),i=""+b.year()+"/"+(b.month()+1)+"/"+b.date()==""+a.year+"/"+a.month+"/"+a.date,d.$setValidity("valid",i),i&&(g=b)),h=d.$viewValue,d.$setViewValue(g),g!==h&&c.ngChange&&a.$eval(c.ngChange)},d.$render=function(){var b;b=d.$viewValue,b?(a.year=null!=b.year?b.year():null,a.month=null!=b.month?b.month()+1:null,a.date=null!=b.date?b.date():null):(a.year=null,a.month=null,a.date=null)},a.$watch("year",e),a.$watch("month",e),a.$watch("date",e)}}}),a.directive("emailAutoComplete",function(){return{restrict:"A",link:function(a,b,c,d){var e;return e={suggClass:"eac-sugg",domains:["yahoo.com","hotmail.com","gmail.com","me.com","aol.com","mac.com","live.com","comcast.net","googlemail.com","msn.com","hotmail.co.uk","yahoo.co.uk","facebook.com","verizon.net","sbcglobal.net","att.net","gmx.com","outlook.com","icloud.com","163.com","126.com","189.cn","sina.com","sina.cn","qq.com","aliyun.com","china.com","sohu.com","excite.co.jp","mail.goo.ne.jp","goo.jp","yandex.com","mail.ru","qip.ru ","naver.com","daum.net","hanmail.net","nate.com"]},b.emailautocomplete(e)}}}),a.directive("numbersOnly",function(){return{require:"ngModel",link:function(a,b,c,d){return d.$parsers.push(function(a){var b;return void 0===a?0:(b=a.replace(/[^0-9]/g,""),b!==a&&(d.$setViewValue(b), d.$render()),b)})}}}),a.directive("numbersEnOnly",function(){return{require:"ngModel",link:function(a,b,c,d){return d.$parsers.push(function(a){var b;return void 0===a?0:(b=a.replace(/[^0-9A-Za-z-]/g,""),b!==a&&(d.$setViewValue(b),d.$render()),b)})}}}),a.directive("onFinishRender",["$timeout",function(a){return{restrict:"A",link:function(b,c,d){return b.$last===!0?a(function(){return b.$emit(d.onFinishRender)}):void 0}}}]),a.directive("qTooltip",["$compile","$timeout","$parse","$document","$position","$interpolate",function(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p;return h={trigger:"mouseenter",placement:"top",animation:!0,popupDelay:0},p={mouseenter:{show:"mouseenter",hide:"mouseleave"},click:{show:"click",hide:"click"},focus:{show:"focus",hide:"blur"}},j=function(a){return null==a&&(a=k.trigger),p[a]},l="qTooltip",k=angular.extend({},h),n=f.startSymbol(),i=f.endSymbol(),g="ng-bind",m=function(a){var b;return b='
'},o=m(g),{restrict:"EA",scope:!0,link:function(f,h,i){var n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E;return g=f.$eval(i.qTooltipHtml)?"ng-bind-html":"ng-bind",o=m(g),B=a(o)(f),C=void 0,x=void 0,p=angular.isDefined(k.appendToBody)?k.appendToBody:!0,D=j(void 0),s=!1,r=angular.isDefined(i[l+"Enable"]),v=!1,f.tt_isOpen=!1,A=function(){f.tt_isOpen?u():z()},z=function(){(!r||f.$eval(i[l+"Enable"]))&&(f.tt_popupDelay?x=b(y,f.tt_popupDelay):f.$apply(y))},u=function(){f.$apply(function(){t()})},y=function(){var a,c,g,j;if(a=void 0,j=void 0,c=void 0,g=void 0,f.tt_content&&!f.tt_disabled){switch(C&&b.cancel(C),B.css({top:0,left:0,display:"block","z-index":9999}),p?d.find("body").append(B):h.after(B),a=p?e.offset(h):e.position(h),v=f.$eval(i[l+"Wrap"]),v?(B.css({"word-break":"break-all"}),B.find(".tooltip-inner").css({"white-space":"pre-wrap","max-width":"400px"})):B.find(".tooltip-inner").css({"white-space":"pre","max-width":"none"}),j=B.prop("offsetWidth"),c=B.prop("offsetHeight"),f.tt_placement){case"bottom-left":g={top:a.top+a.height,left:a.left+a.width-j};break;case"bottom-right":g={top:a.top+a.height,left:a.left};break;case"top-left":g={top:a.top-c,left:a.left+a.width-j};break;case"top-right":g={top:a.top-c,left:a.left};break;case"right":g={top:a.top+a.height/2-c/2,left:a.left+a.width};break;case"bottom":g={top:a.top+a.height,left:a.left+a.width/2-j/2};break;case"left":g={top:a.top+a.height/2-c/2,left:a.left-j};break;default:g={top:a.top-c,left:a.left+a.width/2-j/2}}g.top+="px",g.left+="px",B.css(g),null!=f.tt_menaul?"true"===f.tt_menaul&&(f.tt_isOpen=!0):f.tt_isOpen=!0}},t=function(){f.tt_isOpen=!1,b.cancel(x),f.tt_animation?C=b(function(){null!=B&&B.remove()},500):B.remove()},i.$observe(l,function(a){f.tt_content=a,!a&&f.tt_isOpen&&t()}),i.$observe(l+"Title",function(a){f.tt_title=a}),i.$observe(l+"Placement",function(a){f.tt_placement=angular.isDefined(a)?a:k.placement}),i.$observe(l+"PopupDelay",function(a){var b;b=parseInt(a,10),f.tt_popupDelay=isNaN(b)?k.popupDelay:b}),i.$observe(l+"Manual",function(a){f.tt_menaul=a}),i.$observe(l+"UserControl",function(a){return"true"===a?b(y,0):t()}),i.$observe(l+"Disabled",function(a){return f.tt_disabled="true"===a?!0:!1}),E=function(){s&&null!=D&&(h.unbind(D.show,z),h.unbind(D.hide,u))},f.$watch(i.qTooltipTrigger,function(a){E(),D=j(a),D&&(D.show===D.hide?h.bind(D.show,A):(h.bind(D.show,z),h.bind(D.hide,u)),s=!0)}),n=f.$eval(i[l+"Animation"]),f.tt_animation=angular.isDefined(n)?!!n:k.animation,i.$observe(l+"AppendToBody",function(a){p=angular.isDefined(a)?c(a)(f):p}),v=f.$eval(i[l+"Wrap"]),p&&f.$on("$locationChangeSuccess",q=function(){f.tt_isOpen&&t()}),f.$on("$destroy",w=function(){b.cancel(C),b.cancel(x),E(),B.remove(),B.unbind(),B=null})}}}]),a.filter("rawHtml",["$sce",function(a){return function(b){return a.trustAsHtml(b)}}]),a.directive("showHtmlContent",["$compile",function(a){return{scope:!0,link:function(b,c,d){return d.$observe("template",function(d){var e;return e=a("
"+d+"
")(b),c.html(""),c.append(e)})}}}]),a.directive("setFocusOn",["$timeout",function(a){return{link:function(b,c,d){return b.$watch(d.setFocusOn,function(e){return e?a(function(){return b.$eval(d.setFocusOn)?c.focus():void 0},0,!1):void 0})}}}]),a.directive("jScrollPane",["$window","$timeout","$log",function(a,b,c){return{restrict:"A",link:function(d,e,f){var g,h,i;return i=e,g=!1,i.jScrollPane({hideFocus:!0,contentWidth:5,mouseWheelSpeed:50}),h=function(){var a,b;return b=i.data("jsp"),b?(b.reinitialise(),a=i.find(".jspPane"),a.css({width:"100%"})):void 0},angular.element(a).resize(h),f.scrollResetEvent&&d.$on(f.scrollResetEvent,function(){return b(h)}),f.scrollToBottom?i.bind("jsp-scroll-y",function(a,b,e,h){var i;return i=g,g=h,h&&!i?(c.debug("scroll to bottom, run",f.scrollToBottom),d.$apply(f.scrollToBottom)):void 0}):void 0}}}]),a.directive("keyCodeInput",["messageService","apiService","$log",function(a,b,c){var d,e,f,g,h;return d=function(a,b){var c,d,e,f,g;for(d=!1,c=0,f=0,g=a.length;g>f;f++)if(e=a[f],e.license_key===b.license_key&&c++,2===c){d=!0;break}return d},h=function(a,b,c,d,e,f){var g,h,i;return g="L",h=!1,i=b+c+d+e+f,h=a===g?0===i%7:0===i%8},f=function(a){var b,c;for(c=0,b=0;bl;l++)e=i[l],g=f(e),k.push(g);j=a}else{for(b=0;5>b;)d=5*b,e=a.substr(d,5),g=f(e),k.push(g),j=j+"-"+e,b++;j=j.substr(1)}return c=h(a.substr(0,1),k[0],k[1],k[2],k[3],k[4]),c?j:!1}return!1},g=function(a){var b,c,d;for(d="",c="abcdefghijklmnopqrstuvwxyz",b=0;a>b;)d+=c.charAt(Math.floor(Math.random()*c.length)),b++;return d},{templateUrl:localizedUrl("/partials/directive/key_code_input.mak"),restrict:"E",scope:{list:"=",verified:"=",limit:"="},link:function(f,h,i,j){var k;k=!1,f.random_id=g(2),c.debug("scope.list",f.list),f.handleLicenseKey=function(a,b,d,e){var g,h;if(e.license_key="",1===b&&null!=a){if(25===a.length)return e.license_key_1=a.substr(0,5),e.license_key_2=a.substr(5,5),e.license_key_3=a.substr(10,5),e.license_key_4=a.substr(15,5),e.license_key_5=a.substr(20,5),e.license_key=e.license_key_1+"-"+e.license_key_2+"-"+e.license_key_3+"-"+e.license_key_4+"-"+e.license_key_5,g="input_"+e.index+"_"+f.random_id+"5",$("#"+g).focus();if(29===a.length)return h=a.split("-"),5===h.length?(e.license_key_1=h[0],e.license_key_2=h[1],e.license_key_3=h[2],e.license_key_4=h[3],e.license_key_5=h[4],e.license_key=e.license_key_1+"-"+e.license_key_2+"-"+e.license_key_3+"-"+e.license_key_4+"-"+e.license_key_5,g="input_"+e.index+"_"+f.random_id+"5",$("#"+g).focus()):!1;if(a.length>5&&(e.license_key_1=a.substr(0,5)),e.license_key=e.license_key_1+"-"+e.license_key_2+"-"+e.license_key_3+"-"+e.license_key_4+"-"+e.license_key_5,5===e.license_key_1.length)return g="input_"+e.index+"_"+f.random_id+(b+1).toString(),c.debug("next_id 1:",g),$("#"+g).focus()}else if(e.license_key=e.license_key_1+"-"+e.license_key_2+"-"+e.license_key_3+"-"+e.license_key_4+"-"+e.license_key_5,null!=a&&5===a.length&&5!==b&&(g="input_"+e.index+"_"+f.random_id+(b+1).toString(),$("#"+g).focus()),null!=e.license_key&&29===e.license_key.length){if(!k)return f.verify(e)}else if(null!=e.product_info)return e.product_info=null,f.verified=!1},f.paste=function(a,b){var d;return d=a.clipboardData.items[0],d.getAsString(function(a){return c.debug("paste data",a),f.handleLicenseKey(a,1,!0,b)})},f.checkLicenseKeyList=function(){var a,b,c,d,e,g;if(f.verified=!0,f.list.length>1){for(e=f.list,g=[],a=c=0,d=e.length;d>c;a=++c){if(b=e[a],a!==f.list.length-1&&!b.product_info){f.verified=!1;break}if(b.is_error){f.verified=!1;break}g.push(void 0)}return g}return f.verified=!1,null!=f.list[0].product_info?f.verified=!0:void 0},f.remove=function(a){return f.list.length>1?(f.list.remove(a),f.checkLicenseKeyList()):void 0},f.addEmptyObj=function(){var a;return a={is_error:!1,error_msg:"",license_key:"",index:f.list[f.list.length-1].index+1,license_key_1:"",license_key_2:"",license_key_3:"",license_key_4:"",license_key_5:"",activate_status:null},f.list.push(a)},f.verify=function(g){var h,i,j;return f.list.length>0&&(i=d(f.list,g))?(g.is_error=!0,f.verified=!1,void(g.error_msg=a.getText("product_key_duplicate"))):(j=e(g.license_key),h="add_license_key_error_",j?(g.is_error=!1,j=j.toUpperCase(),g.product_key=j,k=!0,b.getLicenseInfoForProductKey(j).then(function(a){return c.debug("getLicenseInfoForProductKey response",a),k=!1,g.product_info=a.result,f.list.lengthF;F++)if(s=H[F],s.value===k.get("user_currency").toUpperCase()){a.user_currency=s;break}return b.china_site=QCONFIG.china_site,b.show_side_nav=!1,b.user_agree_to_save=!1,b.user_email_isverified=!1,b.route_list=["/my_license","/license_product_inner_list","/license_device_inner_list","/license_inner"],b.landing_page_inner_title=l.getText("landing_page_inner_title","",{software_store:''+l.getText("software_store")+""}),b.order_new_store_transaction=l.getText("order_new_store_transaction","",{software_store:''+l.getText("software_store")+""}),A=function(){var a,b;return b=new Date,a=new Date(b.getFullYear(),b.getMonth(),b.getDate(),b.getHours()+24),k.put("not_notice_site_ip_check",!0,{path:"/",expires:a,secure:!0})},r=function(){var d;return a.is_sign_in?(d=c.search(),o.getProfile().then(function(b){return g.debug("checkAccountStatusDo:",b),a.user_profile=b,"undefined"!=typeof mt&&null!==mt&&b.result.emails.length>0?mt("send","pageview",{email:b.result.emails[0].email,firstname:b.result.first_name}):void 0}),-1===$.inArray(c.path(),b.route_list)?a.setView("/my_license",d):void 0):(a.current_view=null,a.hidePageLoading())},x=function(){var e,f,h;return g.debug("$rootScope.current_view",a.current_view),QCONFIG.china_site?(e="https://www.qnap.com.cn/zh-cn/privacy-notice/qid",h="https://www.qnap.com.cn/zh-cn/before_buy/con_show.php?op=showone&cid=15"):(h="https://www.qnap.com/en/before_buy/con_show.php?op=showone&cid=15",e="https://www.qnap.com/en/privacy-notice/qid"),f={privacy_policy:''+l.getText("privacy_policy")+""},b.save_cookie_msg=l.getText("save_cookie_msg","",f),a.checkIpMeetTheSite(),$(window).bind("resize",function(){return $(window).width()>600&&b.show_side_nav===!0?(b.show_side_nav=!1,b.$apply()):void 0}),b.web_sites=q[b.lang]||q["default"],b.web_china_sites=q.zh,b.user_agree_to_save=k.get("user_agree_to_save")?!0:!1,"/license_product"===c.path()?d.location.href=b.new_license_store_url:k.get("redirect_by_auth")||"/receive_auth"===window.location.pathname?(k.remove("redirect_by_auth"),a.is_sign_in=null!=k.get("access_token"),r()):o.checkLoginStatus().then(function(b){return g.debug("checkLoginStatus",b),"not_authorized"===b.status?(a.is_sign_in=!1,k.remove("access_token"),k.remove("refresh_token"),a.current_view=null,c.path(""),a.hidePageLoading()):"app_not_authorized"===b.status?a.signin():(a.is_sign_in=!0,k.put("access_token",b.access_token,{secure:!0}),k.put("refresh_token",b.refresh_token,{secure:!0}),r())},function(b){return g.debug("checkLoginStatus error",b),a.hidePageLoading()})},a.getCurrentSiteUrl=function(a,b){var e,f,h,i,k;switch(null==b&&(b=!1),a){case"global":f=QCONFIG.license_shop_domain;break;case"china":f=QCONFIG.license_shop_cn_domain}b&&(i=c.search(),i.not_notice="yes",g.debug("parameter_object",i),c.search(i)),e=new URI(c.absUrl()),g.debug("current_url",e),h=e.host(),e.setQuery("lang",getCurrentLang()),k=e.href(),h!==f&&(k=k.replace(h,f)),g.debug("redirect_uri",k),j(function(){return d.location.href=k},500)},a.showWarningSiteIpNotMatchDialog=function(b,c){var d;return g.debug("showWarningSiteIpNotMatchDialog site",c),a.showScreenMask(),d=a.$new(),d.is_manually=b,a.warning_site_ip_not_match_dialog=h.open({templateUrl:localizedUrl("/partials/dialog/site_ip_warning.mak?cacheSlayer="+(new Date).getTime()),controller:"checkSiteIpCtrl",backdrop:"static",scope:d}),a.warning_site_ip_not_match_dialog.result.then(function(d){return d?a.getCurrentSiteUrl(c,b):A()})["finally"](function(){var b;return a.hideScreenMask(),b=null})},a.checkIpMeetTheSite=function(){var b,d;return b=c.search(),g.debug("checkIpMeetTheSite not_notice",b),g.debug("checkIpMeetTheSite not_notice_site_ip_check",k.get("not_notice_site_ip_check")),null!=b.not_notice&&(A(),delete b.not_notice,c.search(b)),k.get("not_notice_site_ip_check")||QCONFIG.china_site===QCONFIG.ip_in_china?void 0:(d="china",QCONFIG.china_site&&(d="global"),a.showWarningSiteIpNotMatchDialog(!1,d))},b.selectPromoteProduct=function(c){return a.selected_promote_product=c,b.stopAutoPlayPromote(),setTimeout(resizeSlider,50)},b.startAutoPlayPromote=function(){return g.debug("do startAutoPlayPromote"), b.$broadcast("evt_start_play_promote")},b.stopAutoPlayPromote=function(){return g.debug("do stopAutoPlayPromote"),b.$broadcast("evt_stop_play_promote")},b.showSideNavMenu=function(){return b.show_side_nav=!b.show_side_nav},b.openLink=function(a){b.closeInfoMenu(),d.open(a,"_blank")},b.goToProfile=function(){return a.gotoAuthCenter("/profile",!0)},b.switchSite=function(c){if(g.debug("switch site not_notice_site_ip_check",k.get("not_notice_site_ip_check")),g.debug("switch site ip_in_china",QCONFIG.ip_in_china),g.debug("switch site site",c),b.closeInfoMenu(),k.get("not_notice_site_ip_check"))a.getCurrentSiteUrl(c,!0);else switch(g.debug("not notice"),c){case"china":QCONFIG.ip_in_china?a.getCurrentSiteUrl(c,!0):a.showWarningSiteIpNotMatchDialog(!0,c);break;case"global":QCONFIG.ip_in_china?a.showWarningSiteIpNotMatchDialog(!0,c):a.getCurrentSiteUrl(c,!0)}},b.closeInfoMenu=function(){g.debug("do closeInfoMenu"),b.current_dropdown_menu=null},b.toggleDropdown=function(a){g.debug("$scope.current_dropdown_menu",a),b.current_dropdown_menu=b.current_dropdown_menu===a?null:a},b.selectLang=function(e){var f,g,i,j,l,m;if(g=getQueryParam("lang"),l=c.absUrl(),b.china_site){if(j="lang="+e,null!=g?i=l.replace("lang="+g,j):(m=new URL(l),i=m.protocol+"//"+m.hostname+m.pathname,null!=m.search&&m.search.length>1?i=i+m.search+"&lang=zh":i+="?lang=zh"),k.put("lang","zh",{expires:getCookieExpireDate(),path:"/",secure:!0}),"zh"!==e){if(i=i.replace(QCONFIG.license_shop_cn_domain,QCONFIG.license_shop_domain),QCONFIG.double_check_redirect_to_global)return a.showScreenMask(),f=a.$new(),t=h.open({templateUrl:localizedUrl("/partials/dialog/check-to-switch-global.mak"),backdrop:"static",scope:f}),t.result.then(function(b){return a.hideScreenMask(),b?d.location.href=i:void 0})["finally"](function(){return t=null});d.location.href=i}}else k.put("lang",e,{expires:getCookieExpireDate(),path:"/",secure:!0}),null!=g?(i=removeQueryParameter(l,"lang"),d.location.href=i):d.location.reload()},b.agreeSaveCookie=function(){var a;return b.user_agree_to_save=!0,k.put("user_agree_to_save",!0,{expires:getCookieExpireDate(),secure:!0}),a={functional:!0,analytic:!0},k.put("cookie_setting",JSON.stringify(a),{expires:getCookieExpireDate(),secure:!0})},b.showCookieSettingDialog=function(){var c,d;return b.closeInfoMenu(),a.showScreenMask(),c=b.$new(!0),c.page_item="general",c.cookie_setting=a.cookie_setting,d=h.open({templateUrl:localizedUrl("/partials/dialog/cookie_setting.mak?cacheSlayer="+(new Date).getTime()),controller:"settingCookieCtrl",backdrop:"static",scope:c}),d.result.then(function(b){return a.hideScreenMask(),g.debug("result",b),b?window.location.href="/":void 0})},b.showAddLicenseDialog=function(){var c,d;return b.closeInfoMenu(),a.showScreenMask(),c=b.$new(!0),g.debug("showAddLicenseDialog $scope.organization_list:",b.organization_list),c.organization_list=b.organization_list,d=h.open({templateUrl:localizedUrl("/partials/dialog/add_license_dialog.mak?cacheSlayer="+(new Date).getTime()),controller:"addLicenseCtrl",backdrop:"static",scope:c}),d.result.then(function(c){return a.hideScreenMask(),g.debug("result",c),c?b.$broadcast(p):void 0})},b.showProductView=function(b){var d;return d="/license_product",c.path(d).search({pid:b,cacheSlayer:(new Date).getTime()}),a.current_view=d},b.$on("evt_root_click",function(){b.current_dropdown_menu=null,b.show_side_nav=!1}),b.$on("evt_back_product_inner_list",function(b,c){return g.debug("evt_back_product_inner_list",c),a.setView("/license_product_inner_list",{app_display_name:c})}),b.$on("evt_get_organization",function(a,d){var e;return g.debug("evt_get_organization, $scope.organization_list",d),e=c.search(),b.organization_list=d}),a.$watch("user_profile",function(a){var c;return g.debug("refreshAvatar profile base:",a),null!=a?(c=a,null!=a.result&&(c=a.result),b.user_display_name=c.display_name):void 0}),x()}]),a.controller("addLicenseCtrl",["$rootScope","$scope","$injector","$log","$timeout","$location","$cookies","alertService","messageService","apiService",function(a,b,c,d,e,f,g,h,i,j){var k,l,m,n,o,p,q;return!QCONFIG.china_site&&a.cookie_setting.analytic&&(k=c.get("Analytics"),m=c.get("gtmService")),l="L",p=null,b.license_key_list_limit=10,b.all_license_key_verified=!1,b.view="select_method",b.option={method:"license_key",pak:null,agreement:!1,selected_organization:b.organization_list[0]},b.product_info=null,b.activate_success=!1,b.dialog_loading=!1,b.pak_transfer_error_msg=i.getText("license_pak_not_transfer","",{item_1:i.getText("license_pak_not_transfer_item_1"),item_2:i.getText("license_pak_not_transfer_item_2")}),b.loading_message="",q=''+QCONFIG.firmware_date+"",b.remind_msg_1="( "+i.getText("remind_old_license_store_dialog_msg_1","",{verison:q})+" )",o=''+i.getText("here_word")+"",b.remind_msg_3=i.getText("remind_old_license_store_dialog_msg_3","",{link:o}),b.license_key_list=[{is_error:!1,error_msg:"",index:0,license_key:"",license_key_1:"",license_key_2:"",license_key_3:"",license_key_4:"",license_key_5:"",activate_status:null}],b.product_key_list=[],b.have_expiring_pregen_key=!1,n=function(a){var c,d,e,f,g,h;for(null==a&&(a=null),g=b.product_key_list,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(function(){var b,e,f,g;for(f=d.keys,g=[],b=0,e=f.length;e>b;b++)c=f[b],c.activate_status="success",null!=a&&null!=a[c.product_key]?g.push(c.activate_status="failed"):g.push(void 0);return g}());return h},b.selectOrganization=function(){return d.debug("$scope.selected_organization:",b.option.selected_organization)},b.closeDialog=function(){return b.$close(b.activate_success)},b.selectMethod=function(){return d.debug("selectMethod",b.option.method),"license_key"===b.option.method?b.view="enter_license_key":b.view="enter_pak"},b.enterKey=function(){var c,e,f,g,h,k,l,m,n,o,p,q,r,s;switch(d.debug("$scope.option.method",b.option.method),b.option.method){case"license_key":for(d.debug("$scope.license_key_list 1",b.license_key_list),f=0;ff;)b.license_key_list[h].license_key===b.license_key_list[f].license_key&&b.license_key_list.remove(b.license_key_list[h]),h--;f++}for(d.debug("$scope.license_key_list 2",b.license_key_list),c={name:b.license_key_list[0].product_info.title,keys:[]},b.product_key_list.push(c),e=0,r=b.license_key_list,n=0,p=r.length;p>n;n++)if(k=r[n],null!=k.product_info){for("expiring"===k.product_info.pregen_status&&(e++,b.have_expiring_pregen_key=!0,k.activate_status="expiring"),l=!0,s=b.product_key_list,o=0,q=s.length;q>o;o++)if(m=s[o],k.product_info.title===m.name){l=!1,m.keys.push(k);break}l&&(g={name:k.product_info.title,keys:[k]},b.product_key_list.push(g))}return d.debug("$scope.product_key_list",b.product_key_list),b.add_license_pregen_key_alert=i.getText("add_license_pregen_key_alert","",{number:e}),b.view="multiple_key_confirm";case"pak":return d.debug("enterKey"),b.get_pak_info_error=!1,b.pak_transfer_error=!1,a.showDialogLoading(i.getText("loading_msg_add_license_please_wait")),b.option.pak=b.option.pak.toUpperCase(),j.getLicenseInfoForPak(b.option.pak).then(function(a){return d.debug("migrateLicense response",a),b.get_pak_info_error=!1,null!=a.result[0].Udi&&a.result[0].Udi.length>0&&"ACT"===a.result[0].Status?b.pak_transfer_error=!0:(b.product_info={title:a.result[0].SkuName},b.view="confirm_license")},function(a){return b.get_pak_info_error=!0,b.get_pak_info_error_msg=i.getText("license_pak_error"),d.debug("migrateLicense error",a)})["finally"](function(){return a.hideDialogLoading()})}},b.confirmLicense=function(){var c,e,f,g,h,l;switch(a.showDialogLoading(i.getText("loading_msg_add_license_please_wait")),d.debug("$scope.option.selected_organization",b.option.selected_organization),b.option.method){case"license_key":for(f=[],l=b.license_key_list,g=0,h=l.length;h>g;g++)e=l[g],null!=e.product_key&&f.push(e.product_key);return c={},null!=b.option.selected_organization.organization_id?(c.type="organization",c.id=b.option.selected_organization.organization_id):(c.type="user",c.id=b.option.selected_organization.user_id),j.activateLicenseForProductKey(f,c).then(function(a){return d.debug("activateLicenseForProductKey response",a),b.activate_success=!0,null!=k&&k.trackEvent("select_add_license_mode",b.option.method),null!=m&&m.logCustomEvent("select_add_license_method",{add_license_method:b.option.method}),n()},function(a){return d.debug("activateLicenseForProductKey error",a),b.activate_error=!0,a.errors?n(a.errors):void 0})["finally"](function(){return a.hideDialogLoading(),b.is_activte=!0});case"pak":return d.debug("enterKey"),j.migrateLicense(b.option.pak).then(function(a){return d.debug("migrateLicense response",a),null!=k&&k.trackEvent("select_add_license_mode",b.option.method),null!=m&&m.logCustomEvent("select_add_license_method",{add_license_method:b.option.method}),b.activate_success=!0},function(a){return d.debug("migrateLicense error",a),b.activate_error=!0,b.confirm_error_code=a.code})["finally"](function(){return a.hideDialogLoading(),b.is_activte=!0})}},b.$on("evt_show_dialog_loading",function(a,c){b.loading_message=c,b.dialog_loading=!0}),b.$on("evt_hide_dialog_loading",function(){b.dialog_loading=!1})}]),a.controller("settingCookieCtrl",["$rootScope","$scope","$injector","$log","$timeout","$location","$cookies","alertService","messageService","apiService",function(a,b,c,d,e,f,g,h,i,j){return b.title_string=i.getText("cookie_setting_title","",{app_name:i.getText("license_manager")}),b.saveCookieSetting=function(){return g.put("user_agree_to_save",!0,{expires:getCookieExpireDate(),secure:!0}),d.debug("$scope.cookie_setting:",b.cookie_setting),g.put("cookie_setting",JSON.stringify(b.cookie_setting),{expires:getCookieExpireDate(),secure:!0}),b.$close(!0)},d.debug("cookie_setting:",b.cookie_setting),b.cookie_setting?void 0:b.cookie_setting={analytic:!0,functional:!0}}]),a.directive("userAvatar",["$rootScope","$log",function(a,b){var c,d,e;return c="/static/img/util/avatar-default.jpg",e="/static/img/util/avatar-male-default.jpg",d="/static/img/util/avatar-female-default.jpg",b.debug("userAvatar directive:",a.user_profile),{template:"",replace:!0,restrict:"E",link:function(f,g,h,i){var j,k;return j=1,null==h.size&&(h.size="medium"),k=function(a){var f,i;return b.debug("refresh avatar",a),j=a.gender,i=null,a.avatars&&(i=a.avatars[h.size],i||(i=a.avatars.medium)),i?(i=new URI(i).setQuery("r",(new Date).getTime()).href(),$(g).attr("src",i)):(f=c,0===j?f=d:1===j&&(f=e),$(g).attr("src",f))},$(g).load(function(){return this.width>this.height?$(g).css({height:"100%",width:"","max-width":"none"}):$(g).css({height:"",width:"100%"})}),$(g).error(function(a){var b;return b=0===j?d:e,$(g).attr("src",b)}),a.$watch("user_profile",function(a){var c;return b.debug("refreshAvatar profile",a),null!=a?(c=a,null!=a.result&&(c=a.result),k(c)):void 0})}}}])}.call(this);