(function(){var a;a=angular.module("api_service",["ngCookies"]),a.service("apiService",["$rootScope","$http","$q","$cookies","$window","$log",function(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;return g=200,h=1,i="refresh_token_count",t=0,j=null,q=function(){return j||d.get("access_token")},s=function(){var a,b,c,g,h;return f.warn("Refreshing access token, cookie cached is cleared"),d.remove("access_token"),b=getCurrentLang(),a=encodeURIComponent((new URI).href()),c=QCONFIG.auth_path,g=QCONFIG.redirect_uri,f.debug("refreshAccessToken QCONFIG",QCONFIG),h=""+c+"/oauth/auth?lang="+b+"&response_type=token&client_id="+QCONFIG.client_id+"&redirect_uri="+g+"&state="+a,null!=d.get("not_notice_site_ip_check")&&(h+="¬_notice=yes"),f.debug("refreshAccessToken url",h),e.location.href=h},m=function(a){return a.url=QCONFIG.api_path+a.url,v(a)},n=function(a){return a.url=QCONFIG.api_path_v2+a.url,v(a)},l=function(a){return a.url=QCONFIG.cloud_drive_metadata_path+a.url,w(a)},k=function(a){return a.url=QCONFIG.cloud_drive_content_path+a.url,w(a)},u=function(a){return a.url=QCONFIG.tunnel_api_path+a.url,f.debug("arg.url",a.url),v(a)},o=function(a){var b;return b=QCONFIG.auth_api_path,a.url=b+"/"+QCONFIG.api_version+a.url,v(a)},p=function(a){var b;return b=QCONFIG.auth_api_path,a.url=b+"/v1.2"+a.url,v(a)},w=function(a,d){return null==d&&(d=null),d||(a.headers={"X-Auth-Token":q()},null==a.params&&(a.params={}),a.params.cacheSlayer=(new Date).getTime(),d=c.defer()),b(a).success(function(a,b){return f.debug("_invokeCloudDriveApi data",a),d.resolve(a)}).error(function(a,b,c,e){var g;return f.debug("_invokeCloudDriveApi error data",a),f.debug("_invokeCloudDriveApi status",b),f.debug("_invokeCloudDriveApi headers",c),f.debug("_invokeCloudDriveApi config",e),0===b?f.debug("Api request has been cancelled"):(b%500===1&&f.error("API failed",b,a),(1013001===(g=a.code)||1013002===g||1019999===g)&&(f.debug("access token is rejected"),s()),d.reject(a))}),d.promise},v=function(a,e){return null==e&&(e=null),e||(null==a.params&&(a.params={}),a.params.access_token=q(),a.params.cacheSlayer=(new Date).getTime(),e=c.defer()),b(a).success(function(a,b){return e.resolve(a)}).error(function(b,c,g,h){var i,j,k,l,n,o,p,q,r,t;if(0===c)return f.debug("Api request has been cancelled");if(c%500===1&&f.error("API failed",c,b),(1013001===(t=b.code)||1013002===t||1019999===t)&&(f.debug("access token is rejected"),s()),1129002===b.code){for(p=a.url.split("/"),j=q=0,r=p.length;r>q;j=++q)if(k=p[j],"device"===k){i=p[j+1];break}return l=i+a.params.access_token,null!=d.get("qtoken_"+l)?(o={user_name:d.get("nas_user_"+l),qtoken:d.get("qtoken_"+l)},n={method:"POST",url:"/remote/device/"+i+"/login",data:o},m(n).then(function(b){return v(a,e)},function(a){return a.device_id=i,e.reject(a)})):e.reject(b)}return e.reject(b)}),e.promise},r=function(a){var d;return f.debug("oauthRequest QCONFIG",QCONFIG),d=c.defer(),a.url=QCONFIG.auth_api_path+"/oauth"+a.url,null==a.params&&(a.params={}),a.params.access_token=q(),a.params.cacheSlayer=(new Date).getTime(),b(a).success(function(a,b){return d.resolve(a)}).error(function(a,b,c,e){return b%500===1&&f.error("OAuth API failed",b,a),d.reject(a)}),d.promise},this.setToken=function(a){return j=a},this.getToken=q,this.checkTokenStatus=function(){var c;return c={method:"GET",url:"/tokeninfo"},r(c).then(function(a){return b.post("/auth_extend",{})},function(b){if(f.error("access token error",b),null!=b){switch(b.error){case"invalid_access_token":s();break;case"user_signed_out":a.logout();break;default:f.warn("Unrecognized api response")}throw new Error("Token invalid")}})},this.getProfile=function(){var a;return a={method:"GET",url:"/me"},o(a)},this.getCloudLink=function(a){var b;return b={method:"GET",url:"/cloudlink/device/"+a},m(b)},this.searchDeviceById=function(a){var b;return b={method:"GET",url:"/device/search",params:{device_id:a}},m(b)},this.searchDeviceByName=function(a){var b;return b={method:"GET",url:"/device/search",params:{device_name:a}},m(b)},this.getDeviceCount=function(){var a;return a={method:"GET",url:"/device/count"},m(a)},this.getDevices=function(a,b){var c;return c={method:"GET",url:"/device",params:{offset:a,limit:b}},m(c)},this.getAllDevices=function(){return this.getDevices(0,g)},this.getDevice=function(a){var b;return b={method:"GET",url:"/device/"+a},m(b)},this.getDeviceWhitelist=function(a){var b;return b={method:"GET",url:"/device/"+a+"/whitelist"},n(b)},this.getPrivateServices=function(a,b,c){var d;return d={method:"POST",url:"/device/search",params:{device_id:a,user_name:b,access_code:c}},m(d)},this.updateDevice=function(a,b,c){var d;return d={method:"PUT",url:"/device/"+a,headers:{"X-QNAP-DEVICE-TOKEN":b},data:c},m(d)},this.deleteDevice=function(a){var b;return b={method:"DELETE",url:"/device/"+a},m(b)},this.starMyDevice=function(a,b){var c;return c={method:"PUT",url:"/device/"+a,headers:{"X-QNAP-DEVICE-TOKEN":b},data:{starred:!0}},m(c)},this.unstarMyDevice=function(a,b){var c;return c={method:"PUT",url:"/device/"+a,headers:{"X-QNAP-DEVICE-TOKEN":b},data:{starred:!1}},m(c)},this.getDdnsOfDevice=function(a){var b;return b={method:"GET",url:"/ddns/device/"+a},m(b)},this.activateDdns=function(a){var b;return b={method:"PUT",url:"/ddns/device/"+a,data:{status:"active"}},m(b)},this.disableDdns=function(a){var b;return b={method:"PUT",url:"/ddns/device/"+a,data:{status:"disabled"}},m(b)},this.getAllFavorites=function(){var a;return a={method:"GET",url:"/device/favorite",params:{offset:0,limit:g}},m(a)},this.addFavorite=function(a,b){var c;return c={method:"POST",url:"/device/favorite",data:{device_id:a,nickname:b}},m(c)},this.updateFavorite=function(a,b){var c;return c={method:"PUT",url:"/device/favorite/"+a,data:{nickname:b}},m(c)},this.deleteFavorite=function(a){var b;return b={method:"DELETE",url:"/device/favorite/"+a},m(b)},this.deviceLogin=function(a,b,c,d){var e,f;return f={user_name:b.user_name},null!=b.qtoken?f.qtoken=b.qtoken:f.password=b.password,null!=d&&(f.remember=d),null!=c&&(f.security_code=c),e={method:"POST",url:"/remote/device/"+a+"/login",data:f},m(e)},this.deviceLogout=function(a){var b;return b={method:"POST",url:"/remote/device/"+a+"/logout"},m(b)},this.deviceLogoutAll=function(){var a;return a={method:"POST",url:"/remote/device/logout"},m(a)},this.deviceFeature=function(a){var b;return b={method:"GET",url:"/remote/device/"+a+"/feature"},m(b)},this.getFileList=function(a,b,c,d,e,f,g){var h;return h={method:"GET",url:"/remote/file/device/"+a,params:{path:b,offset:c,limit:d,sort_type:e,reverse:f,hidden:g}},m(h)},this.getTree=function(a,b,c){var d;return d={method:"GET",url:"/remote/file/device/"+a,params:{path:b,dir_only:!0,hidden:c,offset:0,limit:g}},m(d)},this.createDir=function(a,b){var c;return c={method:"POST",url:"/remote/file/device/"+a+"/createdir",data:{path:b}},m(c)},this.renameFile=function(a,b,c){var d;return d={method:"POST",url:"/remote/file/device/"+a+"/rename",data:{src_path:b,dest_path:c}},m(d)},this.moveFiles=function(a,b,c,d){var e;return e={method:"POST",url:"/remote/file/device/"+a+"/move",data:{src_paths:b,dest_path:c,overwrite:d}},m(e)},this.copyFiles=function(a,b,c,d){var e;return e={method:"POST",url:"/remote/file/device/"+a+"/copy",data:{src_paths:b,dest_path:c,overwrite:d}},m(e)},this.deleteFiles=function(a,b){var c;return c={method:"POST",url:"/remote/file/device/"+a+"/delete",data:{paths:b}},m(c)},this.getDownloadLink=function(a,b,c){var d;return d={method:"POST",url:"/remote/file/device/"+a+"/downloadlink",data:{paths:b,file_type:c}},m(d)},this.getUploadLink=function(a,b,c,d,e){var f;return f={method:"POST",url:"/remote/file/device/"+a+"/uploadlink",data:{path:b,file_name:c,file_size:d,overwrite:e}},m(f)},this.getUploadLinkForSharelink=function(a,b,c,d,e){var f;return f={method:"POST",url:"/remote/share/"+b+"/uploadlink",data:{path:c,overwrite:d,pwd:e}},m(f)},this.getFileProperties=function(a,b){var c;return Array.isArray(b)||(b=[b]),c={method:"POST",url:"/remote/file/device/"+a+"/props",data:{paths:b}},m(c)},this.getAllBgProcess=function(a,b){var c;return c={method:"GET",url:"/remote/file/device/"+a+"/bgprocess",params:{status:b}},m(c)},this.deleteAllBgProcess=function(a,b){var c,d;return d={status:b},c={method:"POST",url:"/remote/file/device/"+a+"/bgprocess/delete",data:d},m(c)},this.getBgProcess=function(a,b){var c;return c={method:"GET",url:"/remote/file/device/"+a+"/bgprocess/"+b},m(c)},this.deleteBgProcess=function(a,b){var c;return c={method:"POST",url:"/remote/file/device/"+a+"/bgprocess/"+b+"/delete"},m(c)},this.getViewLink=function(a,b){var c;return c={method:"GET",url:"/remote/file/device/"+a+"/viewlink",params:{path:b}},m(c)},this.getThumbnailLink=function(a,b,c){var d;return d={method:"GET",url:"/remote/file/device/"+a+"/thumbnaillink",params:{path:b,size:c}},m(d)},this.createShareLink=function(a,b,c,d,e,f,g){var h,i;return i={},i.link_name=b,i.link_type=g,i.paths=c,null!=d&&(i.host_name=d),null!=e&&(i.expired_at=moment(e).format("YYYY-MM-DD HH:mm:ss")),null!=f&&(i.access_code=f),h={method:"POST",url:"/remote/share/device/"+a+"/link",data:i},m(h)},this.shareByEmail=function(a,b,c,d,e,f,g,h,i){var j,k;return k={},k.device_id=a,k.link_id=b,k.link_type=f,k.link_name=g,k.message=c,k.link_url=h,null!=i&&(k.expired_at=i),null!=d&&(k.access_code=d),k.receivers=e,j={method:"POST",url:"/share/notify",data:k},m(j)},this.getShareLinkList=function(a,b,c,d,e){var f;return f={method:"GET",url:"/remote/share/device/"+a+"/link",params:{offset:b,limit:c,sort_type:d,reverse:e}},m(f)},this.getShareLinkSmartUrls=function(a){var b;return b={method:"GET",url:"/share/"+a+"/url"},m(b)},this.deleteShareLink=function(a,b){var c;return c={method:"DELETE",url:"/remote/share/device/"+a+"/link",params:{link_ids:b}},m(c)},this.updateShareLink=function(a,b,c,d,e,f,g,h){var i,j;return null==h&&(h=!1),j={},j.link_name=c,j.link_type=g,null!=d&&(j.expired_at=moment(d).format("YYYY-MM-DD HH:mm:ss")),null!=e&&(j.access_code=e),null!=f&&(j.host_name=f),h&&(j.link_option=3),i={method:"PUT",url:"/remote/share/device/"+a+"/link/"+b,data:j},m(i)},this.getShareWithMeList=function(a,b,c,d){var e;return e={method:"GET",url:"/share/favorite",params:{offset:a,limit:b,sort_type:c,reverse:d}},m(e)},this.updateFavoriteLinkStatus=function(a){var b,c;return c={},c._device_link_ids=a,c.unread=!1,b={method:"PUT",url:"/share/favorite/bulk",data:c},m(b)},this.renameShareWithMeList=function(a,b,c){var d,e;return e={},e.nickname=c,d={method:"PUT",url:"/share/favorite/device/"+a+"/link/"+b,data:e},m(d)},this.deleteShareWithMe=function(a,b){var c;return c={method:"DELETE",url:"/share/favorite/device/"+a+"/link/"+b},m(c)},this.getShareAllContentZipPath=function(a,b){var c,d;return d={},null!=b&&(d.access_code=b),d.offset=0,d.limit=1,c={method:"POST",url:"/remote/share/"+a,data:d},m(c)},this.addShareWithMe=function(a,b){var c,d;return d={},d.composed_link_id=a,d.nickname=b,c={method:"POST",url:"/share/favorite",data:d},m(c)},this.getFriend=function(a,b,c){var d;return d={method:"GET",url:"/friend",params:{offset:b,limit:c,sort_type:a}},p(d)},this.searchUser=function(a){var b;return b={method:"GET",url:"/user/search",params:{user_id:a}},o(b)},this.searchUserByEmail=function(a){var b;return b={method:"GET",url:"/user/search",params:{email:a}},o(b)},this.getAllFriends=function(){var a;return a={method:"GET",url:"/friend",params:{offset:0,limit:-1}},p(a)},this.addFriend=function(a){var b;return b={method:"POST",url:"/friend",data:a},p(b)},this.searchFile=function(a,b,c,d,e,f,g,h){var i,j,k;return"enabled"===g.full_text_search_supported&&null!=g.is_full_text_search&&g.is_full_text_search?(g.hidden=h,this.qsirchFullTextSearch(a,b,c,d,e,f,g)):(j={path:b,sort_type:c,reverse:d,offset:e,limit:f,search_type:g.file_type.value,hidden_file:h},null!=g.keyword&&(k=g.keyword.trim(),k&&(j.keyword=k)),null!=g.real_file_size&&("gt"===g.size_condition.value?j.file_size_criteria={gt:g.real_file_size}:j.file_size_criteria={lt:g.real_file_size}),2===g.file_type.value&&(j.file_extension=g.extension),i={method:"POST",url:"/remote/file/device/"+a+"/search",data:j},m(i))},this.qsirchFullTextSearch=function(a,b,c,d,e,f,g){var h,i,j;return j={path:b,sort_type:c,reverse:d,offset:e,limit:f},null!=g.keyword&&(i=g.keyword.trim(),i&&(j.keyword=i)),null!=g.hidden&&g.hidden===!0&&(j.hidden=g.hidden),null!=g.dir_only&&g.dir_only===!0&&(j.dir_only=g.dir_only),h={method:"GET",url:"/remote/device/"+a+"/full_text_search",params:j},m(h)},this.createAlias=function(a,b){var c,d;return d={device_id:a,uri:b},c={method:"POST",url:"/alias",data:d},m(c)},this.setAccessControlMode=function(a,b,c){var d,e;return e={},e.access_control_mode=c,d={method:"PUT",url:"/device/"+a,headers:{"X-QNAP-DEVICE-TOKEN":b},data:e},m(d)},this.addIntoWhitelist=function(a,b){var c,d;return d={},d.users=b,c={method:"POST",url:"/device/"+a+"/whitelist",data:d},m(c)},this.removeFromWhitelist=function(a,b){var c,d,e;return e=null,e=null!=b.qid?b.qid:null!=b.email?b.email:b.phone,d="?qid="+encodeURIComponent(e),c={method:"DELETE",url:"/device/"+a+"/whitelist"+d},m(c)},this.removeAllFromWhitelist=function(a){var b;return b={method:"DELETE",url:"/device/"+a+"/whitelist"},m(b)},this.getInvitations=function(){var a;return a={method:"GET",url:"/invitation"},m(a)},this.acceptInvitations=function(){var a;return a={method:"POST",url:"/invitation/accept"},m(a)},this.getSharedToMeDevices=function(){var a;return a={method:"GET",url:"/device/sharedtome"},m(a)},this.addIntoSharedToMeDevicesAndStar=function(a,b){var c,d;return d={device_id:a,nickname:b,starred:!0},c={method:"POST",url:"/device/sharedtome",data:d},m(c)},this.removeFromSharedToMeDevices=function(a){var b;return b={method:"DELETE",url:"/device/sharedtome/"+a},m(b)},this.starSharedToMeDevice=function(a){var b;return b={method:"PUT",url:"/device/sharedtome/"+a,data:{starred:!0}},m(b)},this.unstarSharedToMeDevice=function(a){var b;return b={method:"PUT",url:"/device/sharedtome/"+a,data:{starred:!1}},m(b)},this.setSharedToMeDeviceNickname=function(a,b){var c;return c={method:"PUT",url:"/device/sharedtome/"+a,data:{nickname:b}},m(c)},this.getCertificateOrder=function(a,b){var c;return c={method:"GET",url:"/certificate/order",params:{offset:a,limit:b}},m(c)},this.getRefund=function(a,b,c){var d;return d={method:"GET",url:"/certificate/refund",params:{order_id:a,offset:b,limit:c}},m(d)},this.getCertificateOrderInfo=function(a){var b;return b={method:"GET",url:"/certificate/order/"+a},m(b)},this.getCertificateUsageRecord=function(a,b){var c;return c={method:"GET",url:"/certificate/usage_record",params:{offset:a,limit:b}},m(c)},this.getLetsEncrypt=function(a){var b;return b={method:"GET",url:"/certificate/usage_record",params:{device_id:a,certificate_type:"letsencrypt",offset:0,limit:1,sort_type:"created_at",reverse:!0}},m(b)},this.getCertificateLicense=function(a,b,c){var d,e;return e=null!=c?{applied_on_device_id:c}:{offset:a,limit:b},d={method:"GET",url:"/certificate/license",params:e},m(d)},this.getCertificateLicenseById=function(a){var b;return b={method:"GET",url:"/certificate/license/"+a},m(b)},this.orderCertificateLicense=function(a){var b,c;return c={products_to_buy:a},b={method:"POST",url:"/certificate/order",data:c},m(b)},this.updateCertificateLicense=function(a,b){var c,d;return d={status:b},c={method:"PUT",url:"/certificate/order/"+a,data:d},m(c)},this.updateLicenseName=function(a,b){var c,d;return d={license_name:b},c={method:"PUT",url:"/certificate/license/"+a,data:d},m(c)},this.getCertificateProductInfo=function(a){var b;return b={method:"GET",url:"/certificate/product/"+a},m(b)},this.getDevicePackages=function(a){var b;return b={method:"GET",url:"/device/"+a+"/package"},m(b)},this.getNewNotificationCount=function(){var a;return a={method:"GET",url:"/notification/new/count"},m(a)},this.getNewNotification=function(a,b){var c;return c={method:"GET",url:"/notification/new"},m(c)},this.getAllNotificationCount=function(){var a;return a={method:"GET",url:"/notification/all/count"},m(a)},this.getAllNotification=function(a,b){var c,d;return d={offset:a,limit:b},c={method:"GET",url:"/notification/all",params:d},m(c)},this.updateAllNotificationStatus=function(){var a;return a={method:"PUT",url:"/notification"},m(a)},this.getTunnelByDeviceId=function(a){var b;return b={method:"GET",url:"/tunnel/agent/"+a},u(b)},this.geoSearch=function(){var a;return a={method:"GET",url:"/utility/geo/search"},m(a)},this.savePair=function(a){var b;return b={method:"POST",url:"/monitor/pair",data:a},m(b)},this.getAllPair=function(a){var b;return b={method:"GET",url:"/monitor/pair",params:{offset:0,limit:200,source_id:a}},m(b)},this.getPair=function(a,b){var c;return c={method:"GET",url:"/monitor/pair",params:{receiver_reg_id:a,receiver_app_id:b}},m(c)},this.removePair=function(a){var b;return b={method:"DELETE",url:"/monitor/pair/"+a},m(b)},this.updatePair=function(a,b){var c;return c={method:"PUT",url:"/monitor/pair/"+a,data:b},m(c)},this.getBrowerNotificationEventSettings=function(){var a;return a={method:"GET",url:"/monitor/subscription"},m(a)},this.setBrowerNotificationEventSettings=function(a,b){var c,d;return d={notification_type:b,event_subscription_types:a},c={method:"POST",url:"/monitor/subscription",data:d},m(c)},this.checkDeviceSupport=function(a){var b;return b={method:"GET",url:"/tunnel/agent/"+a},u(b)},this.createFollowTask=function(a,b,c,d,e,f,g,h,i,j){var k,l;return l={composed_link_id:b,task_name:c,path:d,follow_paths:e},null!=i&&i>0&&(l.maximum_download_rate=i),null!=j&&j>0&&(l.maximum_file_size=j),null!=f&&(l.extensions=f),null!=g&&(l.recurred_at=g),null!=h&&h.length>0&&(l.access_code=h),k={method:"POST",url:"/coordination/device/"+a+"/task",data:l},m(k)},this.moveFollowTask=function(a,b,c,d,e,f,g,h,i,j,k,l,n){var o,p;return p={composed_link_id:d,target_device_id:b,task_name:e,path:f,follow_paths:g,status:k},null!=l&&l>0&&(p.maximum_download_rate=l),null!=n&&n>0&&(p.maximum_file_size=n),null!=h&&(p.extensions=h),null!=i&&(p.recurred_at=i),null!=j&&j.length>0&&(p.access_code=j),o={method:"POST",url:"/coordination/device/"+a+"/task/"+c+"/move",data:p},m(o)},this.updateFollowTask=function(a,b,c,d,e,f,g,h,i,j,k,l){var n,o;return o={composed_link_id:c,task_name:d,path:e,follow_paths:f,status:j},null!=k&&k>0&&(o.maximum_download_rate=k),null!=l&&l>0&&(o.maximum_file_size=l),null!=g&&(o.extensions=g),null!=h&&(o.recurred_at=h),null!=i&&i.length>0&&(o.access_code=i),n={method:"PUT",url:"/coordination/device/"+a+"/task/"+b,data:o},m(n)},this.isShareLinkFollowable=function(a){var b;return b={method:"GET",url:"/remote/share/"+a+"/permission"},m(b)},this.getCurrentAccountFollowings=function(a,b,c){var d;return d={method:"GET",url:"/task",params:{offset:a,limit:b,sort_type:1,reverse:null==c?!1:c}},m(d)},this.unFollowing=function(a,b){var c;return c={method:"DELETE",url:"/coordination/device/"+a+"/task/"+b},m(c)},this.triggerFollowingAction=function(a,b,c){var d;return d={method:"POST",url:"/coordination/device/"+a+"/task/"+b+"/action",data:{action:c}},m(d)},this.checkFollowPermissionbyNasUser=function(a,b,c){var d;return d={method:"GET",url:"/coordination/device/"+a+"/task/"+b+"/permission"},null!=c&&(d.params={nas_user:c}),m(d)},this.getSingleFollowTaskStatus=function(a,b){var c;return c={method:"GET",url:"/coordination/device/"+a+"/task/"+b},m(c)},this.getComposedLinkIdInfo=function(a){var b;return b={method:"GET",url:"/share/"+a},m(b)},this.getDeviceNetworkResources=function(a){var b;return b={method:"GET",url:"/device/"+a+"/network"},m(b)},this.editFileByWOPI=function(a,b,c){var d,e;return e={device_id:a,full_path:b,ui:c},d={method:"POST",url:"/wopi/url",data:e},m(d)},this.getCloudDriveFileInfo=function(a,b){var c;return null==b&&(b=null),c={method:"GET",url:"/files/"+a},null!=b&&(c.params={public_token:b}),l(c)},this.getCloudDriveRootFolder=function(a,b,c){var d,e;return e={max_results:a,order_by:c},0!==b&&(e.page_token=b),d={method:"GET",url:"/folders/root/children",params:e},l(d)},this.getCloudDriveFiles=function(a,b,c,d,e){var f,g;return null==e&&(e=null),g={max_results:b,order_by:d},0!==c&&(g.page_token=c),null!=e&&(g.public_token=e),f={method:"GET",url:"/folders/"+a+"/children",params:g},l(f)},this.createCloudDriveFolder=function(a,b){var c,d;return d={kind:"FOLDER",parents:[b],name:a},c={method:"POST",url:"/folders",data:d},l(c)},this.restoreCloudDriveFile=function(a){var b;return b={method:"POST",url:"/trash/"+a+"/restore"},l(b)},this.deleteCloudDriveFile=function(a,b){var c,d;return d="directory"===a?"folders":"files",c={method:"DELETE",url:"/"+d+"/"+b},l(c)},this.emptyCloudDriveTrashList=function(){var a;return a={method:"DELETE",url:"/trash"},l(a)},this.moveCloudDriveFileToTrash=function(a){var b;return b={method:"PUT",url:"/trash/"+a},l(b)},this.getCloudDriveThumbnailLink=function(a){var b,c;return c={size:800},b={method:"GET",url:"/files/"+a+"/thumbnail_link",params:c},l(b)},this.patchCloudDriveFile=function(a,b,c,d){var e,f,g;return f={parents:[d],name:c},g="directory"===a?"folders":"files",e={method:"PATCH",url:"/"+g+"/"+b,data:f},l(e)},this.copyCloudDriveFile=function(a,b,c){var d;return d={method:"POST",url:"/files/"+a+"/copy?parent="+c+"&name="+b},l(d)},this.searchCloudDriveFile=function(a,b,c,d){var e,f;return f={max_results:a,order_by:c,query:{name:{$contains:d}}},0!==b&&(f.page_token=b),e={method:"GET",url:"/files",params:f},l(e)},this.getCloudDriveTrashList=function(a,b,c){var d,e;return e={max_results:a,order_by:c},0!==b&&(e.page_token=b),d={method:"GET",url:"/trash",params:e},l(d)},this.createCloudDriveShareLink=function(a,b){var c,d;return d={name:a,file_id_list:b},c={method:"POST",url:"/shared",data:d},l(c)},this.updateCloudDriveShareLink=function(a,b){var c,d;return d={name:b},c={method:"PATCH",url:"/shared/"+a,data:d},l(c)},this.getCloudDriveShareLink=function(a,b,c){var d,e;return e={max_results:a,order_by:c,expand:"permissions,children"},0!==b&&(e.page_token=b),d={method:"GET",url:"/shared",params:e},l(d)},this.getCloudDriveShareLinkInfo=function(a,b){var c,d;return null==b&&(b=null),d={expand:"permissions,children"},null!=b&&(d.public_token=b),c={method:"GET",url:"/shared/"+a,params:d},l(c)},this.deleteCloudDriveShareLink=function(a){var b;return b={method:"DELETE",url:"/shared/"+a},l(b)},this.createCloudDrivePermissions=function(a,b,c,d,e,f){var g,h;return null==d&&(d=null),null==e&&(e=null),null==f&&(f=null),h={type:b,role:c},"private"===b?h.user=d:(null!=e&&(h.expired_date=e),null!=f&&(h.password=f)),g={method:"POST",url:"/shared/"+a+"/permissions",data:h},l(g)},this.updateCloudDrivePermissions=function(a,b,c,d,e,f){var g,h;return null==e&&(e=null),null==f&&(f=null),h={type:c,expired_date:e},null!=f&&(h.password=f,"!remove_password!"===f&&(h.password=null)),null!=d&&"public"!==c&&(h.role=d),g={method:"PATCH",url:"/shared/"+a+"/permissions/"+b,data:h},l(g)},this.deleteCloudDrivePermissions=function(a,b){var c;return c={method:"DELETE",url:"/shared/"+a+"/permissions/"+b},l(c)},this.emailCloudDriveShareLink=function(a,b,c,d){var e,f;return f={receiver:c,message:d},e={method:"POST",url:"/shared/"+a+"/permissions/"+b+"/send_email",data:f},l(e)},this}])}).call(this),function(){var a;a=angular.module("geo",["api_service"]),a.run(["$rootScope","$log","apiService",function(a,b,c){return a.local_geo_info={},c.geoSearch().then(function(c){return b.debug("Get geo info of browser",c.result),a.local_geo_info=c.result},function(a){return b.error("Failed to get public IP",a)})}])}.call(this),function(){var a,b,c;a="alert:",b=2e4,c=angular.module("alert",["common"]),c.controller("alertController",["$rootScope","$scope",function(b,c){var d,e;return e=function(b,d,e,f,g,h){var i;return c.title=d,c.message=e,c.code=f,c.on_click=g,c.on_close=h,i=b.name.replace(a,""),c.alertClass=["qalert-open","qalert-"+i].join(" ")},d=function(){return c.title=null,c.message=null,c.on_click=null,c.code=null,"function"==typeof c.on_close&&c.on_close(),c.on_close=null,c.alertClass="qalert-close"},c.closeAlert=d,b.$on(a+"info",e),b.$on(a+"success",e),b.$on(a+"warning",e),b.$on(a+"error",e),b.$on(a+"close",d),c.$on("evt_root_mousedown",function(){return d()}),d()}]),c.service("alertService",["$rootScope","$timeout","messageService",function(c,d,e){var f;return f=function(b){return d(function(){return c.$emit(a+"close")},b)},this.alert=function(b,d,f,g,h,i){var j,k,l;return l=e.getText(b),j=null,g?k=d:d.code?(k=e.getText(d.code,d.message,f),j=d.code):k=e.getText(d,f),c.$emit(a+b,l,k,j,h,i)},this.close=function(){return c.$emit(a+"close")},this.info=function(a,c,d,e,g){return this.alert("info",a,c,d,e,g),f(b)},this.success=function(a,c,d,e,g){return this.alert("success",a,c,d,e,g),f(b)},this.warning=function(a,b,c,d,e){return this.alert("warning",a,b,c,d,e)},this.error=function(a,b,c,d,e){return this.alert("error",a,b,c,d,e)},this}])}.call(this),function(){var a;a=angular.module("footer",[]),a.controller("footerController",["$scope","$window","$log",function(a,b,c){var d,e;return d={zh_TW:{facebook:{url:"http://www.facebook.com/QNAPTaiwan",icon_class:"icon-facebook-sign"},twitter:{url:"http://twitter.com/QNAP_nas",icon_class:"icon-twitter"},youtube:{url:"http://youtube.com/user/qnapsys",icon_class:"icon-youtube-play"},google:{url:"http://plus.google.com/102360486351217532213/posts",icon_class:"icon-google-plus"}},zh:{facebook:{url:"http://e.weibo.com/qnap?ref=http%3A%2F%2Fwww.qnap.com%2Fen%2Findex.php%3Flang%3Den%26sn%3D850",icon_class:"icon-sinaweibo"},twitter:{url:"http://video.sina.com.cn/v/b/68420688-2271524680.html",icon_class:"icon-sinavideo"},youtube:{url:"http://i.youku.com/u/id_UMTU5ODg4ODk2.html",icon_class:"icon-youku"},google:{url:"http://www.tudou.com/programs/view/nZ54wnwqShs/",icon_class:"icon-tudou"}},"default":{facebook:{url:"http://www.facebook.com/QNAPSys",icon_class:"icon-facebook-sign"},twitter:{url:"http://twitter.com/QNAP_nas",icon_class:"icon-twitter"},youtube:{url:"http://youtube.com/user/qnapsys",icon_class:"icon-youtube-play"},google:{url:"http://plus.google.com/102360486351217532213/posts",icon_class:"icon-google-plus"}}},a.lang=getCurrentLang(),a.is_zh="zh"===a.lang,e=$("#footer_word").text(),a.footer_word=e.replace("2013-2014",QCONFIG.year),a.china_site=QCONFIG.china_site,a.openLink=function(a){b.open(a,"_blank")},a.goToQnap=function(){b.open("http://www.qnap.com/","_blank")},a.web_sites=d[a.lang]||d["default"]}])}.call(this),function(){var a;a=angular.module("header",["common","profile","qcloud-ui","api_service"]),a.controller("headerController",["$scope","$rootScope","$window","$location","$log","$interval","$cookies","$http","$q","apiService","messageService","utilities","alertService","profileService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F;return r=/^[a-zA-Z0-9]*$/,p=QCONFIG.image_css_url+"/static/img/util/avatar-default.jpg",o=QCONFIG.image_css_url+"/static/img/util/avatar-female-default.jpg",q=4,s=14,a.show_tooltip=!1,a.search_device_name=null,a.current_dropdown_menu=null,a.new_notification_count=0,a.show_notification=!1,a.new_notification=null,a.china_site=QCONFIG.china_site,v="share"===d.absUrl().split("/")[3],u="device"===d.absUrl().split("/")[3].split("?")[0],t=-1!==d.url().indexOf("shared/links"),D=null,B=!1,z=function(){return j.getNewNotificationCount().then(function(b){return a.new_notification_count=b.result.length},function(a){return e.debug("getNewNotificationCount",a)})},y=function(){return B=!0,a.new_notification=[],j.getAllNotification(0,q).then(function(b){var c,d,e,f,g,h,i,j;if(null!=b.result){for(c=b.result.length,0===c&&(B=!1),j=b.result,h=0,i=j.length;i>h;h++){switch(f=j[h],f.type){case"sharedtome":g={send_user_name:''+f.send_user_name+"",device_name:""+f.data.device_name+""},f.description_msg=k.getText("notification_add_favorite","",g);break;case"follow":switch(f.data.task_status.name){case"complete":g={task_name:''+f.data.task_name+"",device_name:''+f.data.device_name+""},d={elapsed_time:moment(f.data.elapsed_time,"HH:mm:ss").format("HH:mm:ss"),download_files:f.data.downloaded_files,download_size:l.getReadableFileSize(f.data.downloaded_size)},f.description_msg=k.getText("notification_follow_completed","",g)+k.getText("notification_download_success_info","",d);break;case"fail":g={task_name:''+f.data.task_name+"",device_name:''+f.data.device_name+"",error_type:k.getText("notification_follow_fail_"+f.data.task_status.code)},f.description_msg=k.getText("notification_follow_fail","",g)}break;case"bind_device":g={device_name:f.data.device_name,ip_address:f.data.from.ip,location:f.data.from.country},e="notification_bind_device_msg",null!=f.data.device_type&&("AFOTALK"===f.data.device_type||"AFOBOT"===f.data.device_type)&&(e="notification_bind_afobot_device_msg",g.device_code=f.data.device_code),f.description_msg=k.getText(e,"",g);break;case"unbind_device":g={device_name:f.data.device_name,ip_address:f.data.from.ip,location:f.data.from.country},e="notification_unbind_device_msg",null!=f.data.device_type&&("AFOTALK"===f.data.device_type||"AFOBOT"===f.data.device_type)&&(e="notification_unbind_afobot_device_msg",g.device_code=f.data.device_code),f.description_msg=k.getText(e,"",g)}A(f).then(function(b){return a.new_notification.push(b),a.new_notification.length===c?(B=!1,a.show_notification=!0):void 0})}return E()}return B=!1},function(a){return e.debug("getNewNotification",a),B=!1})},A=function(a){return null!=a.send_user_id?j.searchUser(a.send_user_id).then(function(b){return null!=b.result[0].avatars?a.user_avatar=b.result[0].avatars.small:a.user_avatar=QCONFIG.auth_path+"/avatar/"+a.send_user_id+"/s?r=1429172894527",a}):void 0},E=function(){return j.updateAllNotificationStatus().then(function(a){return e.debug("do updateNotificationStatus success")},function(a){return e.debug("getNewNotificationCount",a)})},w=function(a,b){var c,d,f,g,h;return c=864e5,d=a.getTime(),f=b.getTime(),h=Math.abs(d-f),g=Math.round(h/c),e.debug("compare two date",d,d,g),g},x=function(a){return h.get(a)},a.switchSite=function(c){if(e.debug("switch site not_notice_site_ip_check",g.get("not_notice_site_ip_check")),e.debug("switch site ip_in_china",QCONFIG.ip_in_china),e.debug("switch site site",c),a.closeInfoMenu(),g.get("not_notice_site_ip_check"))b.getCurrentPortalSiteUrl(c,!0);else switch(e.debug("not notice"),c){case"china":QCONFIG.ip_in_china?b.getCurrentPortalSiteUrl(c,!0):b.showWarningSiteIpNotMatchDialog(!0,c);break;case"global":QCONFIG.ip_in_china?b.showWarningSiteIpNotMatchDialog(!0,c):b.getCurrentPortalSiteUrl(c,!0)}},a.gotoNotificationTarget=function(c){var e;switch(c.type){case"sharelink":return e=c.data.link_url,QCONFIG.china_site&&(e+="?china_site=true"),void window.open(e,"_blank");case"whitelist":v||u?window.location.href="/u?lang="+getCurrentLang()+"#/shared/device?device_id="+c.data.device_id:b.$broadcast("evt_go_to_share_my_nas",c.data.device_id);break;case"follow":t?b.$broadcast("evt_switch_tab_to_following"):window.location.href="/u?lang="+getCurrentLang()+"#/shared/links?tab=following";break;case"unbind_device":case"bind_device":case"sharedtome":d.path("/notification")}return a.show_notification=!1},a.gotoNotificationPage=function(){return v||u?window.location.href="/u?lang="+getCurrentLang()+"#/notification":d.path("/notification")},a.controlNotificationDropdown=function(){return a.show_notification?a.show_notification=!1:B?void 0:(a.new_notification_count=0,y())},a.checkSearchDeviceName=function(){return a.show_tooltip=!r.test(a.search_device_name)},a.closeInfoMenu=function(){return a.current_dropdown_menu=null},a.backToIndex=function(){return b.is_sign_in?c.location.href=localizedUrl(QCONFIG.portal_path+"/u"):c.location.href=localizedUrl(QCONFIG.portal_path+"/")},a.searchDevice=function(){return a.search_device_name&&r.test(a.search_device_name)===!0?c.location.href=localizedUrl("/device?device_name="+a.search_device_name):void 0},a.toggleDropdown=function(b){return a.current_dropdown_menu=a.current_dropdown_menu===b?null:b;
},a.selectLang=function(a){var b,e,f;g.put("lang",a,{expires:getCookieExpireDate(),path:"/"}),b=getQueryParam("lang"),null!=b?(f=d.absUrl(),e=removeQueryParameter(f,"lang"),c.location.href=e):c.location.reload()},a.goToProfile=function(){return b.gotoAuthCenter("/profile")},a.$on("evt_root_click",function(){return a.current_dropdown_menu=null,a.show_notification=!1}),b.$watch("user_profile",function(b){return b?a.user_display_name=b.display_name:void 0}),a.search_device_name=getQueryParam("device_name"),-1!==d.absUrl().indexOf("goto_service")||-1!==d.absUrl().indexOf("smarturl")?a.hide_sign_in_and_search_device=!0:a.hide_sign_in_and_search_device=!1,b.is_sign_in&&(z(),C=1e3*QCONFIG.get_new_notification_count_timer,D=f(function(){return z()},C)),F=QCONFIG.cms_url+"/news/feeds/rss?lang="+getCurrentLang(),x(F).then(function(a){var b,d,f,h,i,j,k;try{if(b=/\$\{\ *\_\([\'\"](.*)[\'\"]\)\ *\}\$/,f=$.xml2json(a.data,!0),i=f.channel[0].item[0].title[0].text,null!=i&&(i=i.replace(/'/g,"'")),k=i.match(b),null!=k&&null!=k[1]&&(i=k[1]),h=f.channel[0].item[0].link[0].text,j=f.channel[0].item[0].pubDate[0].text,w(new Date(j),new Date)<=s&&null!=h&&h!==g.latest_news_link)return m.alert("info",i,null,!0,function(){return e.debug("Set onclick function "),g.latest_news_link=h,F=new URI(h),F.setQuery("lang",getCurrentLang()),c.open(F.href(),"_blank")},function(){return e.debug("Set onclose funcrion"),g.latest_news_link=h})}catch(l){return d=l,e.info("No News or Parsing Error",d)}},function(a){return e.info("Read the latest news failed",a)})}]),a.directive("userAvatar",["$rootScope","$log",function(a,b){var c,d,e;return c=QCONFIG.image_css_url+"/static/img/util/avatar-default.jpg",e=QCONFIG.image_css_url+"/static/img/util/avatar-male-default.jpg",d=QCONFIG.image_css_url+"/static/img/util/avatar-female-default.jpg",{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),QCONFIG.china_site&&(i=a.avatars.cn.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){return a?k(a):void 0})}}}])}.call(this),function(){var a,b;b=null,a=angular.module("profile",["common","api_service"]),a.run(["$rootScope","$log","apiService","alertService",function(a,c,d,e){return a.is_sign_in?(c.debug("Fetching user profile"),b=d.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),e.error(a)})):void 0}]),a.service("profileService",function(){return this.getProfile=function(){return b},this})}.call(this),function(){var a;a=angular.module("goto",["ngRoute","ngCookies","ui.bootstrap","common","qcloud-ui","api_service","pref"]),a.config(["$sceProvider","$locationProvider",function(a,b){return a.enabled(!1)}]),a.run(["$rootScope","$location",function(a,b){return a.$on("$locationChangeSuccess",function(){return a.actual_location=b.path()})}]),a.service("gotoService",["$http","$q","$log","$location","$modal","preference","$rootScope","messageService",function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n;return l="https",k="http",m="tunnel",i="/cgi-bin/qid/qidRequest.cgi",j=1e4,n=function(c){var d;return d=b.defer(),c.params||(c.params={}),c.params.cacheSlayer=(new Date).getTime(),a(c).success(function(a,b){return a.code===!0&&d.reject(a),d.resolve(a)}).error(function(a,b,c,e){return 504===b&&(a={code:2010002}),d.reject(a)}),d.promise},this.setSmartshareSession=function(a){var b;return b={method:"POST",url:"/ajax/set_smartshare_session",data:a},n(b)},this.getSmartshareSession=function(a){var b,c;return c={signed_redis_session_id:a},b={method:"GET",url:"/ajax/get_smartshare_session",params:c},n(b)},this.confirmUsingTunnel=function(a,b,d){var g,h;return h=b.$new(!0),g=e.open({templateUrl:localizedUrl("/partials/dialog/confirm_using_tunnel"),scope:h,windowClass:"dialog-modal"}),g.result.then(function(a){return a?(c.debug("save to user's preference",a),d.skip_tunnel_relay_confirmation=!0,f.put(PREF_AUTO_CONNECT,d)):c.debug("user clicked the 'I got it!' button without tick the checkbox or clicked the [x] button")})["finally"](function(){return g=null,a()})},this.smarturlProbeRoute=function(d,e,f,g,h,k,n,o,p){var q,r,s,t;return null==g&&(g=i),null==h&&(h=j),null==k&&(k=[]),null==p&&(p=null),t=new URI(d.url),s=b.defer(),q=t.query(!0),t.search(""),t.path(g),t.query({verify_device:1,device_token:e,callback:"JSON_CALLBACK"}),t.addQuery(q),t=t.href(),r={timeout:h},a.jsonp(t,r).success(function(a){if(null==a.verify_result||a.verify_result!==!0)return c.error("probe returns a false verify result at",t),s.resolve(a);switch(c.debug("probe success",t),console.log("Do PROTOCOL_TUNNEL 1",d.scheme),d.scheme){case l:return null!=p&&p.trackEvent("auto_connect",f,""+d.type+" "+d.scheme),c.debug("redirecting to",d.dest_url),window.location.href=d.dest_url;case m:return console.log("Do PROTOCOL_TUNNEL 2",m),o.push(d),s.resolve(d);default:return n.push(d),s.resolve(d)}}).error(function(a,b,e,f){return c.error("probe failed",t,b,a),d.scheme===l&&k.push(d.dest_url),s.resolve()}),s.promise},this.smarturlChooseRoute=function(a,d,e,f,g,i,j){var k,l,m,n,o,p;return c.debug("smarturlChooseRoute among",a),m=b.defer(),n=this,k=[],l=[],o=function(){var b,c,f;for(f=[],b=0,c=a.length;c>b;b++)p=a[b],f.push(n.smarturlProbeRoute(p,d,e,null,QCONFIG.smarturl_probe_timeout_secs,g.user_retry_list,k,l,j));return f}(),b.all(o).then(function(a){var b,d;return c.debug("accessible_http_routes",k),c.debug("accessible_tunnel_route",l),c.debug("retry list",g.user_retry_list),k.length>0?(QCONFIG.china_site||null!=j&&j.trackEvent("auto_connect",e,""+k[0].type+" "+k[0].scheme),c.debug("redirect to",k[0].dest_url),d=new URI(k[0].dest_url),f&&(b=new URI(f),null!=b.path()&&d.path(b.path()),null!=b.query()&&d.query(b.query())),m.resolve({type:"normal",url:d.href()})):l.length>0?(c.debug("redirect to tunnel",l[0].dest_url),d=new URI(l[0].dest_url),f&&(b=new URI(f),b.path()&&d.path(b.path()),b.query()&&d.addQuery(b.query())),null!=j&&j.trackEvent("auto_connect",e,""+l[0].type+" "+l[0].scheme),m.resolve({type:"tunnel",url:d.href()})):m.reject({type:"error",url:"",messages:h.getText("cloudlink_connect_device_failed")})}),m.promise},this}]),a.controller("gotoController",["$rootScope","$scope","$location","$window","$http","$q","$log","$modal","$injector","$timeout","messageService","utilities","alertService","apiService","gotoService","preference",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N;return QCONFIG.china_site||(r=i.get("Analytics"),r.set("dimension1",QCONFIG.userid)),t="/home",y=10,z=5,u="auto_connect",s={skip_tunnel_relay_confirmation:!1},b.error_message=null,b.error_code=null,b.show_init_loading=!0,b.access_code=null,b.access_code_needed=!1,b.wrong_access_code=!1,b.is_access_code_used=!1,b.user_retry_list=[],G=p.get(u,s),b.cloud_install_detect_error=!1,q=QCONFIG.smarturl_url_prefix?QCONFIG.smarturl_url_prefix:"/smarturl",w="https",v="http",x="tunnel",B=null,A=function(){return c.search("callback",null)},M=function(c){switch(c){case"full_screen":a.show_init_loading=!0;break;case"file_list":b.show_file_list_loading=!0;break;case"load_more":b.show_load_more_loading=!0}},F=function(c){switch(c){case"full_screen":a.show_init_loading=!1;break;case"file_list":b.show_file_list_loading=!1;break;case"load_more":b.show_load_more_loading=!1}},L=function(a){return b.current_path=0===a.indexOf(t)?l.resolvePath(a):t,c.path(b.current_path)},E=function(a){var c;return g.debug("error occurred",a),F("full_screen"),null==b.error_code?(c=null!=a&&null!=a.code?a.code:a,b.error_message=k.getText(c),b.error_code=c):void 0},H=function(a,b,c,d){var g,h,i,j;return j=new URI(a.url),i=f.defer(),g=j.query(!0),j.search(""),j.path("/cgi-bin/qid/qidRequest.cgi"),j.query({verify_device:1,device_token:b,callback:"JSON_CALLBACK"}),j.addQuery(g),"tunnel"===a.type&&j.addQuery("tunnel_agent_id",d),j=j.href(),h={timeout:QCONFIG.smarturl_probe_timeout_secs},e.jsonp(j,h).success(function(b){return null!=b.verify_result&&b.verify_result===!0?(a.pass=!0,i.resolve(a)):i.resolve(a)}).error(function(b,c,d,e){return i.resolve(a)}),i.promise},I=function(a,b){var c,e,g;a.pass&&(g=new URI(a.url),e=f.defer(),c=g.query(!0),g.search(""),g.path("/share.cgi"),g.query({ssid:b}),g.addQuery(c),g=g.href(),d.location.href=g)},J=function(a,b){var c,e,g;a.pass&&(g=new URI(a.url),e=f.defer(),c=g.query(!0),g.search(""),g.path(b.service_url),g.hash(b.service_hash),g.addQuery(c),g.addQuery(b.service_query),g=decodeURIComponent(g.href()),d.location.href=g)},K=function(a){var c,e;null==a&&(a=""),g.debug("redirectToRelayPage QCONFIG.portal_path",QCONFIG.portal_path),e=new URI(QCONFIG.portal_path),e.path("share/"+b.composed_link_id),c=new URI(d.location),e.addQuery(c.query(!0)),e.addQuery("session_id",a),d.location.href=e},C=function(a,c,d){var e,h,i,j,k,l,m,n;return g.debug("do_smartshare QCONFIG.portal_path",QCONFIG.portal_path),i=a.token,j=a.link_id,b.composed_link_id=a.composed_link_id,n=a.routes,g.debug("do_smartshare routeList",JSON.stringify(n)),h=QCONFIG.auto_connect_max_requests,e=[],l=[],!n||n.length<=0?void(d&&o.setSmartshareSession(d).then(function(a){return g.debug("do_smartshare setSmartshareSession",JSON.stringify(a)),K(a.result)})):(n.length>h?(e=n.slice(0,+(h-1)+1||9e9),l=n.slice(h)):e=n,k=function(){var b,c,d;for(d=[],b=0,c=e.length;c>b;b++)m=e[b],d.push(H(m,i,j,a.device_id));return d}(),f.all(k).then(function(b){var d,e,f,h;for(g.debug("QCONFIG",QCONFIG),f=0,h=b.length;h>f;f++)if(e=b[f],e.pass)return void(c?J(e,a):o.setSmartshareSession(b).then(function(a){return g.debug("do_smartshare promises",JSON.stringify(a.result)),K(a.result)}));try{window.stop()}catch(i){d=i,document.execCommand("Stop")}return a.routes=l,C(a,c,b)}))},D=function(a,c){var d,e,f,g,h;return null==c&&(c=null),h=a.token,g=a.selected_display_name,e=QCONFIG.auto_connect_max_requests,d=[],f=[],!a.routes||a.routes.length<=0?void(c&&(F("full_screen"),b.error_message=c.messages,b.error_code="")):(a.routes.length>e?(d=a.routes.slice(0,+(e-1)+1||9e9),f=a.routes.slice(e)):d=a.routes,o.smarturlChooseRoute(d,h,g,a.query,b,getCurrentLang(),r).then(function(a){return N(a)},function(b){var c;try{window.stop()}catch(d){c=d,document.execCommand("Stop")}return a.routes=f,D(a,b)}))},N=function(a){var c;return g.debug("_smarturlRedirect",a.url),"normal"===a.type?window.location.href=a.url:"tunnel"===a.type?(c=function(){return window.location.href=a.url},null==G||G.skip_tunnel_relay_confirmation?c():o.confirmUsingTunnel(c,b,G)):(F("full_screen"),b.error_message=a.messages,b.error_code="")},b.autoDetectRoute=function(){var d;return g.debug("autoDetectRoute QCONFIG 1",QCONFIG.portal_path),d=c.search(),o.getSmartshareSession(b.signed_redis_session_id).then(function(c){var d;if(d=c.result,g.info(d),g.debug("autoDetectRoute QCONFIG 2",QCONFIG.portal_path),!d)return b.error_message=k.getText("goto_service_missing_invalid_session_id"),b.error_code=2100001,F("full_screen");switch(a.device_name=d.device_name,b.smarturl_routes=d.routes,g.debug("autoDetectRoute result.routes",JSON.stringify(d.routes)),d.service){case"smartshare":return C(d,!1);case"smartshare_service":return C(d,!0);case"smarturl":return D(d)}},function(a){var c;return 2100002===(c=a.code)?(b.error_message=k.getText("goto_service_missing_invalid_session_id"),b.error_code=a.code,F("full_screen")):E(a)})},b.go=function(a){g.debug("go route",a),b.popup=d.open("","_blank"),b.display_name||(b.display_name=""),null!=r&&r.trackEvent("smarturl",b.display_name,a.scheme),"tunnel"===a.scheme?confirmUsingTunnel(function(){return b.popup.location.href=a.url}):b.popup.location.href=a.url},b.goto_portal_home=function(){return window.location.href=QCONFIG.portal_path},M("full_screen"),b.show_init_loading=!0,b.autoDetectRoute()}])}.call(this),function(){var a;a=angular.module("cloud_install_detect",["ngRoute","ngCookies","ui.bootstrap","common","qcloud-ui","api_service"]),a.controller("detectCloudInstallController",["$rootScope","$scope","$location","$window","$http","$q","$log","$modal","$injector","$timeout","messageService","utilities","alertService","apiService","gotoService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;p=null,QCONFIG.china_site||(p=i.get("Analytics")),null!=p&&p.set("dimension1",QCONFIG.userid),r={qfinder:"http://www.qnap.com/_jump/utility/qfinder.php",myqnapcloud_connect:"http://www.qnap.com/_jump/utility/myqnapcloudconnect.php",qsync:"http://www.qnap.com/_jump/utility/qsync.php",netbak_replicator:"http://www.qnap.com/_jump/utility/netbak.php",qget:"http://www.qnap.com/_jump/utility/qget.php",qfile:"http://www.qnap.com/_jump/mobile/qfile.php",qmanager:"http://www.qnap.com/_jump/mobile/qmanager.php",qmusic:"http://www.qnap.com/_jump/mobile/qmusic.php",qget_mobile:"http://www.qnap.com/_jump/mobile/qget.php",qremote:"http://www.qnap.com/_jump/mobile/qremote.php",vmobile:"http://www.qnap.com/_jump/mobile/vmobile.php"},q={en:"ENG",zh:"SCH",zh_TW:"TCH",de:"GER",es:"SPA",fr:"FRE",it:"ITA",ja:"JPN",ko:"KOR",ru:"RUS",nl:"DUT",pt:"POR"},b.cloud_install_detect_error=!1,E=null,w=null,G=0,D=null,v=null,H=0,F=!1,b.openLink=function(a){return d.open(a,"_blank"),!0},b.init=function(){return b.cloud_install_detect_error=!1,F=!1,o.getSmartshareSession(b.signed_redis_session_id).then(function(a){return null!=a.result&&null!=a.result.routes?(D=a.result,g.debug("routes_result.routes",D.routes),o.smarturlChooseRoute(D.routes,D.token,D.selected_display_name,D.query,b,getCurrentLang(),null,p).then(function(a){var b;return b=new URI(a.url),d.location.href=b.href()},function(a){var b,c,d,e,f;for(b=!0,f=D.routes,d=0,e=f.length;e>d;d++)if(c=f[d],null!=c.type&&"TUNNEL"===c.type){b=!1;break}return b?(u(),t()):x()})):s()},function(a){return y(a)})},s=function(){var a;return a=new URI("/smarturl/"+b.device_name+"/cloud_install"),d.location.href=a.href()},x=function(){return j.cancel(w),j.cancel(v),w=null,v=null,F=!0,G=0,H=0,b.cloud_install_detect_error=!0},y=function(a){return g.debug("error occurred",a)},u=function(){var a;return b.cloud_install_detect_error=!1,a={url:"/ajax/get_tunnel?device_id="+I,method:"GET"},e(a).success(function(a,b){return g.debug("checkTunnel ok"),s()}).error(function(a,b){return g.debug("checkTunnel failed"),G+=QCONFIG.smarturl_cloud_install_probe_timeout_secs,G