/* Copyright (C) 2010-2023 OpenVPN, Inc. - http://openvpn.net/ */
var CWSController=function(){function c(g){h(function(v){1==v?g():(console.log("Connection is lost. Reloading..."),k.run())})}function e(g,v,q,u){if("function"==typeof u){var n=u;u={success:n,forbidden:n,error:n}}$.ajax({type:g,url:v,data:q,dataType:"text",beforeSend:function(p,A){p.setRequestHeader("X-OpenVPN","1");p.setRequestHeader("X-CWS-Proto-Ver",m.cws_proto_ver_max)},success:function(p,A,D){p&&"string"==typeof p&&0==p.indexOf(w)&&(p=p.replace(w,""));try{p=JSON.parse(p)}catch(E){}u.success(p,
D)},error:function(p,A,D){(A=p.responseText)&&"string"==typeof A&&0==A.indexOf(w)&&(A=A.replace(w,""));try{A=JSON.parse(A)}catch(E){}403==p.status&&u.forbidden?u.forbidden(A,p):500==p.status?document.write(p.responseText):u.error&&u.error(A,p)}})}function l(g,v){e("POST","/__auth__",g.challenge?{response:g.response}:{username:g.username,password:g.password},{success:function(q,u){v?f():(B=1,k.run())},forbidden:function(q,u){B=2;if("login-failure"==q.type){var n=q.synopsis?q.synopsis:"";"object"==
typeof n&&(n=n[0]);(n=n.match(/^(.+): (.*)/))&&n[1]?f({"auth-error":n[1]}):(n=q.synopsis,y.clear(),z.setCredentials(y),k.dispatch(z),z.showAuthFailure(n))}else if("reason"==q.type){B=3;var p=q.message;n=p.reason;p=p.flags;b("login challenge: "+n);b("  flags: "+p);y.challenge=n;if(p)for(n=0;n<p.length;n++)"R"==p[n]?y.response=!0:"E"==p[n]&&(y.echo=!0);k.dispatch(z)}else location.reload(!0),b("unknown authentication result: "+JSON.stringify(q)),location.reload(!0)}})}function f(g){e("POST","/__logout__",
null,function(v,q){var u=[];C.src&&u.push("src="+encodeURIComponent(C.src));if(g)for(var n in g)u.push(n+"="+encodeURIComponent(g[n]));u=u.join("&");0<u.length&&(u="?"+u);location.hash&&0<location.hash.length&&(u+=location.hash);window.top.location.replace(location.protocol+"//"+location.host+"/"+u)})}function h(g){e("GET",r,{_ts:+new Date},{success:function(v,q){B=1;g(B)},error:function(v,q){B=2;g(B)}})}function x(){c(function(){e("POST","/downloads.json",null,{success:function(g,v){var q=OpenVPN.Connect.app.getController("downloads");
q.setDownloads(g);k.dispatch(q)}})})}function t(g){for(var v={},q=/([^&=]+)=([^&]*)/g,u;u=q.exec(g);)v[decodeURIComponent(u[1])]=decodeURIComponent(u[2]);return v}var b=function(g){console.log("[CWSController] "+g)},m=OpenVPN.Connect.CONFIG,w=m.js_exec_breaker||"",r=2<=m.cws_proto_ver_max?"/session2.json":"/session.json",k=this,y,B=0,C,z;CWSController.prototype.init=function(){b("init()");C=t(location.search.substring(1));y=OpenVPN.Connect.app.getModel("credentials");z=OpenVPN.Connect.app.getController("login");
z.setCredentials(y);h(function(){k.run()});m.company_name&&$("#company-name").html(m.company_name);"hide"==m.cws_footer&&$("#footer").addClass("d-none")};CWSController.prototype.run=function(){b("CWSController.prototype.run()");if(0==B)b("  not ready to run yet");else if(1==B)b("  going to Downloads portal"),x();else if(2==B){b("  not authenticated");k.dispatch(z);if("true"==C.reauth)z.showAuthFailure("Session expired. Please login again.");else if("true"==C.relogin_with_google_auth)z.showAuthFailure("Ready to connect with TOTP two-factor authentication (RFC 6238, e.g. Google Authenticator)");
else if(C.error)z.showAuthFailure("Unexpected error: "+C.error);else if(C["auth-error"]){switch(C["auth-error"]){case "DENY":var g="Your account has been suspended.";break;case "REVOKED":g="Your certificate has been revoked.";break;case "LICENSE":g="This Access Server has reached its concurrent connections limit. Try again later.";break;case "SESSION":g="Your session has expired, please login again.";break;case "SWITCH_REAUTH":g="You have been disconnected from the old server. Please login again to the new server.";
break;default:g=C["auth-error"]}z.showAuthFailure(g)}else C.revoked&&z.showAuthFailure("Your certificate has been revoked.");0==location.hash.indexOf("#user/")&&z.setUsername(location.hash.substr(6))}else b("  other auth status: "+B)};CWSController.prototype.setCredentials=function(g){y=g};CWSController.prototype.login=function(){l(y)};CWSController.prototype.submitResponse=function(){l(y)};CWSController.prototype.discardChallenge=function(){l(y,!0)};CWSController.prototype.logout=function(){f()};
CWSController.prototype.change_password=function(g){c(function(){e("POST","/change_password",g,{success:function(v,q){$("#error").text(v.reason);$("#error").removeClass("d-none");1==v.status&&($("#cancel").addClass("d-none"),$("#error").removeClass("alert-danger"),$("#error").addClass("alert-success"),$("#continue").click(function(){k.run()}))}})})};CWSController.prototype.showChangePassword=function(){c(function(){k.dispatch(OpenVPN.Connect.app.getController("password"))})};CWSController.prototype.showProfiles=
function(){c(function(){e("POST","/downloads.json",null,{success:function(g,v){var q=OpenVPN.Connect.app.getController("profile");q.setProfiles(g);k.dispatch(q)}})})};CWSController.prototype.importProfile=function(g){c(function(){e("POST","/import_profile",{profile_type:g},{success:function(v,q){console.log("profile import URL");console.log(v);window.location=v}})})};CWSController.prototype.download_installer=function(g){c(function(){window.location="download_installer?type="+g})};CWSController.prototype.check_ga=
function(g,v){c(function(){isNaN(g)?($("#qr-error").removeClass("d-none"),$("#qr-error").html("Code must be a 6-digit number")):6!=g.length?($("#qr-error").removeClass("d-none"),$("#qr-error").html("Code length must be exactly 6-digits")):(dict={totp_code:g,secret:$("#ga-key").html()},e("POST","/check_ga",dict,function(q,u){if(1==q){console.log("GA code verified and locked");var n=$("#downloads");0<n.length&&n.remove();$("#googleauth").addClass("d-none");$("#googleauth-locked").removeClass("d-none");
k.run()}else $("#qr-error").removeClass("d-none"),console.log("incorrect GA code")}))})};CWSController.prototype.create_profile=function(){c(function(){var g="create_profile?comment="+$("#input-comment").val();g=g+"&autologin="+($("#checkbox-autologin").is(":checked")?!0:!1);$("#div-tlscryptv2").length&&(g=g+"&tlscryptv2="+($("#checkbox-tlscryptv2").is(":checked")?!0:!1));window.location=g})};CWSController.prototype.delete_profile=function(g){c(function(){e("POST","/delete_profile",g,function(v,q){OpenVPN.Connect.app.getController("cws").showProfiles()})})};
CWSController.prototype.download_profile=function(g,v){c(function(){window.location=v?"download_profile?type="+v:"download_profile?serial="+g})}};CWSController.prototype=new stdui.Application.prototype.Controller;CWSController.prototype.constructor=CWSController;OpenVPN.Connect.app.add("cws",CWSController);
var UserProfileController=function(){var c=this,e,l;UserProfileController.prototype.init=function(){e=OpenVPN.Connect.app.getView("profile")};UserProfileController.prototype.setProfiles=function(f){l=f};UserProfileController.prototype.run=function(){e.setModel(l);e.on_cancel(function(){c.dispatch(OpenVPN.Connect.app.getController("cws"))});e.on_delete_profile(function(){serial=$("#select-delete-profile").val();OpenVPN.Connect.app.getController("cws").delete_profile({serial:serial})});e.on_create_profile(function(){OpenVPN.Connect.app.getController("cws").create_profile()});
e.show()}};UserProfileController.prototype=new stdui.Application.prototype.Controller;UserProfileController.prototype.constructor=UserProfileController;OpenVPN.Connect.app.add("profile",UserProfileController);
var ChangePasswordController=function(){var c=this,e;ChangePasswordController.prototype.init=function(){e=OpenVPN.Connect.app.getView("password")};ChangePasswordController.prototype.run=function(){console.log("changepasswordcontroller.show()");e.on_continue(function(){new_pass=$("#new-password").val();old_pass=$("#current-password").val();new_pass_vfy=$("#new-password-verify").val();error="";old_pass==new_pass&&(error="New password and current password cannot be the same");new_pass&&old_pass&&new_pass_vfy||
(error="All fields are mandatory");new_pass!=new_pass_vfy&&(error="New password and confirmation do not match");""!=error?e.show(error):(dict={current_password:old_pass,new_password:new_pass},OpenVPN.Connect.app.getController("cws").change_password(dict))});e.on_cancel(function(){c.dispatch(OpenVPN.Connect.app.getController("cws"))});e.show()}};ChangePasswordController.prototype=new stdui.Application.prototype.Controller;ChangePasswordController.prototype.constructor=ChangePasswordController;
OpenVPN.Connect.app.add("password",ChangePasswordController);
var LoginController=function(){var c,e,l;LoginController.prototype.init=function(){e=OpenVPN.Connect.app.getView("login");l=OpenVPN.Connect.app.getView("login-challenge")};LoginController.prototype.run=function(){var f=OpenVPN.Connect.app.getController("cws");e.model=c;c.challenge?(l.setCredentials(c),l.show(),l.on_continue(function(){l.hide();f.setCredentials(c);f.submitResponse()}),l.on_cancel(function(){l.hide();f.discardChallenge()})):(e.show(),e.on_downloads(function(){e.hide();f.setCredentials(c);
f.login()}))};LoginController.prototype.setCredentials=function(f){c=f};LoginController.prototype.showAuthFailure=function(f){e.showMessage(f)};LoginController.prototype.setUsername=function(f){e.setUsername(f)}};LoginController.prototype=new stdui.Application.prototype.Controller;LoginController.prototype.constructor=LoginController;OpenVPN.Connect.app.add("login",LoginController);
var DownloadsController=function(){var c=this,e,l;DownloadsController.prototype.init=function(){e=OpenVPN.Connect.app.getView("downloads")};DownloadsController.prototype.run=function(){e.setModel(l);e.setOS(c.getOS());e.show();var f=l.user_profiles,h=l.prop_autogenerate,x=l.prop_autologin,t=l.cws_ui_offer;t.autologin||t.user_locked?t.user_locked||x?f.num_profiles||h?($("#btn-profile").removeClass("d-none"),$("#btn-profile").click(function(){OpenVPN.Connect.app.getController("cws").showProfiles()})):
$("#btn-profile").addClass("d-none"):$("#btn-profile").addClass("d-none"):$("#btn-profile").addClass("d-none");l.allow_password_change?($("#chpasswd").removeClass("d-none"),$("#chpasswd").click(function(){OpenVPN.Connect.app.getController("cws").showChangePassword()})):$("#chpasswd").addClass("d-none");e.on_logout(function(){e.hide();OpenVPN.Connect.app.getController("cws").logout()});e.on_ga_qr_scanned(function(){root=$("#main").find("#qr-challenge");code=root.find("#response-clear").val();OpenVPN.Connect.app.getController("cws").check_ga(code,
e)});e.on_import_profile(function(){root=$("#main").find("#div-import-profile");profile_type=root.find("input[name=profile-type]:checked").val();OpenVPN.Connect.app.getController("cws").importProfile(profile_type,e)});e.on_manage(function(){window.location.href=l.adminui_port!=l.cws_port?"https://"+window.location.hostname+":"+l.adminui_port+"/":"/admin/"})};DownloadsController.prototype.setDownloads=function(f){l=f};DownloadsController.prototype.getOS=function(){var f=window.navigator.userAgent,
h=window.navigator.platform,x=["Win32","Win64","Windows","WinCE"],t=["iPhone","iPad","iPod"],b=null;-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(h)?b="Mac OS":-1!==t.indexOf(h)?b="iOS":-1!==x.indexOf(h)?b="Windows":/Android/.test(f)?b="Android":!b&&/Linux/.test(h)&&(b="Linux");return b}};DownloadsController.prototype=new stdui.Application.prototype.Controller;DownloadsController.prototype.constructor=DownloadsController;OpenVPN.Connect.app.add("downloads",DownloadsController);
var LoginView=function(){this.root=this.cb_downloads=null;this.html=OpenVPN.Connect.app.getHTML("html/login.html")};LoginView.prototype=new stdui.Application.prototype.View;LoginView.prototype.constructor=LoginView;LoginView.prototype.model=null;
LoginView.prototype.show=function(){$("#main").html("");$("#main").append(this.html);this.view=$("#main div:first-child");this.root=$("#main").find("#login");var c=OpenVPN.Connect.CONFIG.saml_enabled,e=OpenVPN.Connect.CONFIG.relay_state;"disabled"==c&&(c=!1);c?"profile"==e?$("#div-btn-saml-cws").remove():$("#div-btn-saml-profile").remove():($("#div-btn-saml-cws").remove(),$("#div-btn-saml-profile").remove(),$("#login-sep").remove());var l=this.model,f=this.root,h=this,x=function(){l.username=f.find("#username").val();
l.password=f.find("#password").val();h.cb_downloads()};f.find("#username").keypress(function(t){if(13==t.keyCode)return x(),!1});f.find("#password").keypress(function(t){if(13==t.keyCode)return x(),!1});f.find("#go").click(x);f.find("#username").focus()};LoginView.prototype.hide=function(){this.view.remove()};LoginView.prototype.setUsername=function(c){this.root.find("#username").val(c);this.root.find("#password").focus()};LoginView.prototype.on_downloads=function(c){this.cb_downloads=c};
LoginView.prototype.showMessage=function(c){var e=this.root.find("#message");c instanceof String||"string"==typeof c?e.show().text(c):e.show().text(c.join("<br />"))};OpenVPN.Connect.app.add("login",LoginView);
var LoginChallengeView=function(){function c(){f()}function e(){m.response&&(m.response=w.val());h()}function l(r){r.keypress(function(k){if(13==k.keyCode)return e(),!1});return r}var f,h,x=OpenVPN.Connect.app.getHTML("html/login-challenge.html"),t,b,m,w;LoginChallengeView.prototype.show=function(){$("#main").html("");$("#main").append(x);t=$("#main div:first-child");b=$("#main").find("#login-challenge");var r=b.find("h5"),k=b.find("#response-masked"),y=b.find("#response-clear");r.text(m.challenge);
m.response?m.echo?(k.remove(),w=y):(y.remove(),w=k):(k.remove(),y.remove(),w=void 0);w&&(r.attr("for",w.attr("id")),l(w).focus(),"Enter Authenticator Code"==m.challenge&&w.attr("placeholder","6-digit code"));b.find("#cancel").click(c);b.find("#continue").click(e)};LoginChallengeView.prototype.hide=function(){t.remove()};LoginChallengeView.prototype.setCredentials=function(r){m=r};LoginChallengeView.prototype.on_cancel=function(r){f=r};LoginChallengeView.prototype.on_continue=function(r){h=r}};
LoginChallengeView.prototype=new stdui.Application.prototype.View;LoginChallengeView.prototype.constructor=LoginChallengeView;OpenVPN.Connect.app.add("login-challenge",LoginChallengeView);
var DownloadsView=function(){var c={},e=OpenVPN.Connect.app.getHTML("html/downloads.html"),l=OpenVPN.Connect.app.getHTML("html/import_profile.html"),f=$("#main div:first-child"),h,x,t=function(b){OpenVPN.Connect.app.getController("cws").download_installer(b)};DownloadsView.prototype.show=function(){relay_state=OpenVPN.Connect.CONFIG.relay_state;if("profile"==relay_state)$("#main").html(""),$("#main").append(l),$("#btn-token-url").click(function(){c.import_profile&&c.import_profile()}),$("#logout").click(function(){c.logout&&
c.logout()}),h.prop_autologin?($("#profile-type-autologin").attr("checked","checked"),$("#profile-type-userlocked").removeAttr("checked")):$("#radioAutologin").remove();else if($("#main").html(""),$("#main").append(e),h.is_external_pki&&(document.getElementById("select-profile-section").style.display="none",document.getElementById("btn-profile").style.display="none"),f=$("#main div:first-child"),"google_auth_key"in h&&h.google_auth_key[2]&&!h.google_auth_key[3]&&!h.skip_ga_enrollment){var b=qrcode(-1,
"L");b.addData(h.google_auth_key[1]);b.make();tbl=b.createTableTag(8,1);document.getElementById("qrcode-table").innerHTML=tbl;$("#qrcode-table").removeClass("d-none");$("#ga-key").text(h.google_auth_key[0]);$("#googleauth").removeClass("d-none");$("#response-clear").removeClass("d-none");$("#response-clear").focus();$("#downloads-buttons").addClass("d-none");qr_submit=function(){c.ga_qr_scanned&&c.ga_qr_scanned()};$("#ga-qr-scanned").click(qr_submit);qr_cancel=function(){c.logout&&c.logout()};$("#ga-qr-cancel").click(qr_cancel);
$("#response-clear").keypress(function(y){if(13==y.keyCode)return qr_submit(),!1})}else{var m=function(y){outer_span=$("<span></span>").attr("class","fa-stack fa-2x").attr("style","color: #ea7e23;");circle=$("<i></i>").attr("class","fa-stack-2x ml-2 cws-circle");inner_span="";inner_span="ios"==y.toLowerCase()?$("<span></span>").attr("style","color: #1a3867;font-size: 24px;font-family: 'Arial narrow';").attr("class","fa-stack-1x").text("iOS"):$("<span></span>").attr("class","fab fa-stack-1x fa-".concat(y)).attr("style",
"color: #1a3867;").text("");outer_span.append(circle);outer_span.append(inner_span);return outer_span};$("#logout").click(function(){c.logout&&c.logout()});!0===h.is_admin&&($("#manage").removeClass("d-none"),$("#manage").click(function(){c.manage&&c.manage()}));var w=!1,r=!1;b=!1;var k=h.cws_ui_offer;null!=x&&("Linux"==x?k.linux&&(b=$("<li></li>"),b.appendTo($("#recommended-apps")),a=$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_linux").text("").appendTo(b),outer_span=
$("<span></span>").attr("class","fa-stack fa-2x").attr("style","color: #ea7e23;"),circle=$("<i></i>").attr("class","fal fa-circle fa-stack-2x"),inner_span=$("<span></span>").attr("style","color: #1a3867;font-size: 24px;font-family: 'Arial narrow';").attr("class","fa-stack-1x").text("iOS"),a.append(m("linux")),b=!0):"Android"==x?k.android&&(b=$("<li></li>"),b.appendTo($("#recommended-apps")),a=$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_connect_android").text("").appendTo(b),
a.append(m("android")),b=!0):"iOS"==x?k.ios&&(b=$("<li></li>"),b.appendTo($("#recommended-apps")),a=$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_connect_ios").text("").appendTo(b),a.append(m("ios")),b=!0):"Mac OS"==x?k.mac_v3?(b=$("<li></li>"),b.appendTo($("#recommended-apps")),d=$("<div></div>").attr("class","cws-item").appendTo(b),a=$("<button></button>").attr("class","cws-installer-button").attr("id","r_mac_v3").text("").appendTo(d),a.append(m("apple")),$("#r_mac_v3").click(function(){t("mac_v3")}),
b=!0):k.mac&&(b=$("<li></li>"),b.appendTo($("#recommended-apps")),a=$("<button></button>").attr("class","cws-installer-button").attr("id","r_mac").text("").appendTo(b),a.append(m("apple")),$("#r_win").click(function(){t("mac")}),b=!0):"Windows"==x&&(k.win_v3?(b=$("<li></li>"),b.appendTo($("#recommended-apps")),d=$("<div></div>").attr("class","cws-item").appendTo(b),a=$("<button></button>").attr("class","cws-installer-button").attr("id","r_win_v3").text("").appendTo(d),a.append(m("windows")),$("#r_win_v3").click(function(){t("win_v3")}),
b=!0):k.win&&(b=$("<li></li>"),b.appendTo($("#recommended-apps")),a=$("<button></button>").attr("class","cws-installer-button").attr("id","win").text("").appendTo(b),a.append(m("windows")),$("#r_win").click(function(){t("win")}),b=!0)));b&&$("#recommended-apps-section").removeClass("d-none");if(1==k.win_v3||null==k.win_v3)b=$("<li></li>"),b.appendTo($("#apps")),a=$("<button></button>").attr("class","cws-installer-button").attr("id","win_v3").text("").appendTo(b),a.append(m("windows")),null==k.win_v3?
$("#win_v3").click(function(){$("#modalDownloadError").modal("show")}):$("#win_v3").click(function(){t("win_v3")}),w=!0;if(1==k.mac_v3||null==k.mac_v3)b=$("<li></li>"),b.appendTo($("#apps")),a=$("<button></button>").attr("class","cws-installer-button").attr("id","mac_v3").text("").appendTo(b),a.append(m("apple")),null==k.mac_v3?$("#mac_v3").click(function(){$("#modalDownloadError").modal("show")}):$("#mac_v3").click(function(){t("mac_v3")}),w=!0;k.linux&&(b=$("<li></li>"),b.appendTo($("#apps")),a=
$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_linux").text("").appendTo(b),a.append(m("linux")),w=!0);k.android&&(b=$("<li></li>"),b.appendTo($("#mobile-apps")),a=$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_connect_android").text("").appendTo(b),a.append(m("android")),w=r=!0);k.ios&&(b=$("<li></li>"),b.appendTo($("#mobile-apps")),a=$("<a></a>").attr("href","https://openvpn.net/clients/index.php?client=openvpn_connect_ios").text("").appendTo(b),
a.append(m("ios")),w=r=!0);w&&$("#all-apps-section").removeClass("d-none");r&&$("#mobile-apps-section").removeClass("d-none");if(1==k.win||null==k.win)b=$("<li></li>"),b.appendTo($("#new-apps")),d=$("<div></div>").attr("class","cws-item").appendTo(b),a=$("<button></button>").attr("class","cws-installer-button").attr("id","win").text("").appendTo(d),a.append(m("windows")),null==k.win?$("#win").click(function(){$("#modalDownloadError").modal("show")}):$("#win").click(function(){t("win")}),$("#deprecated-apps-section").removeClass("d-none");
if(1==k.mac||null==k.mac)b=$("<li></li>"),b.appendTo($("#new-apps")),d=$("<div></div>").attr("class","cws-item").appendTo(b),a=$("<button></button>").attr("class","cws-installer-button").attr("id","mac").text("").appendTo(d),a.append(m("apple")),null==k.mac?$("#mac").click(function(){$("#modalDownloadError").modal("show")}):$("#mac").click(function(){t("mac")}),$("#deprecated-apps-section").removeClass("d-none");m=h.cws_ui_offer.user_locked;w=h.cws_ui_offer.autologin;r=h.prop_autogenerate;k=h.prop_autologin;
h.cws_ui_offer.server_locked&&(b=$("<li></li>"),b.appendTo($("#select-profile")),a=$("<button></button").attr("class","btn btn-link").attr("onclick","OpenVPN.Connect.app.getController('cws').download_profile(null, 'serverlocked')").text("Anyone at this server (server-locked profile)").appendTo(b),$("#select-profile-section").removeClass("d-none"));r&&(m&&(b=$("<li></li>"),b.appendTo($("#select-profile")),a=$("<button></button").attr("onclick","OpenVPN.Connect.app.getController('cws').download_profile(null, 'userlocked')").attr("class",
"btn btn-link").text("Yourself (user-locked profile)").appendTo(b),$("#select-profile-section").removeClass("d-none")),w&&k&&(b=$("<li></li>"),b.appendTo($("#select-profile")),a=$("<button></button").attr("onclick","OpenVPN.Connect.app.getController('cws').download_profile(null, 'autologin')").attr("class","btn btn-link").text("Yourself (autologin profile)").appendTo(b),$("#select-profile-section").removeClass("d-none")))}};DownloadsView.prototype.hide=function(){$("#downloads").addClass("d-none");
var b=$("#main div:first-child");0<b.length&&b.remove();f&&f.remove()};DownloadsView.prototype.on_logout=function(b){c.logout=b};DownloadsView.prototype.on_manage=function(b){c.manage=b};DownloadsView.prototype.on_ga_qr_scanned=function(b){c.ga_qr_scanned=b};DownloadsView.prototype.on_import_profile=function(b){c.import_profile=b};DownloadsView.prototype.setModel=function(b){h=b};DownloadsView.prototype.setOS=function(b){x=b}};DownloadsView.prototype=new stdui.Application.prototype.View;
DownloadsView.prototype.constructor=DownloadsView;OpenVPN.Connect.app.add("downloads",DownloadsView);
var UserProfileView=function(){var c={},e=OpenVPN.Connect.app.getHTML("html/profiles.html"),l=$("#main div:first-child"),f;UserProfileView.prototype.show=function(h){console.log("UserProfileView show()");$("#main").html("");$("#main").append(e);l=$("#main div:first-child");$("#btn-create-profile").click(function(){c.create_profile&&c.create_profile()});$("#btn-delete-profile").click(function(){c.delete_profile&&c.delete_profile()});$("#btn-cancel").click(function(){c.cancel&&c.cancel()});f.prop_autogenerate||
$("#div-create-new-profile").remove();f.cws_ui_offer.tlscryptv2||$("#div-tlscryptv2").remove();f.cws_ui_offer.user_locked||$("#checkbox-autologin").attr("disabled","true");f.cws_ui_offer.autologin||$("#div-autologin").remove();f.prop_autologin||$("#div-autologin").remove();h&&($("#error").removeClass("d-none"),$("#error").html(h));$("[id='tooltip-tlscryptv2']").tooltip({title:"for openvpn 2.5+ clients only",placement:"right"});$('[data-toggle="tooltip"]').tooltip();var x=$("#select-delete-profile"),
t=f.user_profiles;t.num_profiles?(profile_categories=["autologin+tlscryptv2","userlocked+tlscryptv2","autologin","userlocked"],$.each(profile_categories,function(b,m){profiles=t[m];optgrp_delete=$("<optgroup>",{label:m});$.each(profiles,function(w,r){r.comment||(r.comment="");val="#"+r.serial_number+" "+r.comment;optgrp_delete.append($("<option>",{value:r.serial_number,text:val,"data-subtext":"valid until "+r.not_after}))});x.append(optgrp_delete)}),$("#div-delete-profile").removeClass("d-none")):
$("#div-delete-profile").addClass("d-none");$(".selectpicker").selectpicker()};UserProfileView.prototype.hide=function(){var h=$("#main div:first-child");0<h.length&&h.remove();l&&l.remove()};UserProfileView.prototype.on_delete_profile=function(h){c.delete_profile=h};UserProfileView.prototype.on_create_profile=function(h){c.create_profile=h};UserProfileView.prototype.on_back=function(h){c.create_profile=h};UserProfileView.prototype.on_continue=function(h){c["continue"]=h};UserProfileView.prototype.on_cancel=
function(h){c.cancel=h};UserProfileView.prototype.setModel=function(h){f=h}};UserProfileView.prototype=new stdui.Application.prototype.View;UserProfileView.prototype.constructor=UserProfileView;OpenVPN.Connect.app.add("profile",UserProfileView);
var ChangePasswordView=function(){var c={},e=OpenVPN.Connect.app.getHTML("html/password.html"),l=$("#main div:first-child");ChangePasswordView.prototype.show=function(f){$("#main").html("");$("#main").append(e);l=$("#main div:first-child");$("#continue").click(c["continue"]);$("#cancel").click(c.cancel);f&&$("#error").removeClass("d-none");$("#error").html(f)};ChangePasswordView.prototype.hide=function(){var f=$("#main div:first-child");0<f.length&&f.remove();l&&l.remove()};ChangePasswordView.prototype.on_continue=
function(f){c["continue"]=f};ChangePasswordView.prototype.on_cancel=function(f){c.cancel=f}};ChangePasswordView.prototype=new stdui.Application.prototype.View;ChangePasswordView.prototype.constructor=ChangePasswordView;OpenVPN.Connect.app.add("password",ChangePasswordView);var Credentials=function(){};
Credentials.prototype={username:null,password:null,challenge:null,echo:!1,response:null,clear:function(){this.username=this.password=this.challenge=this.response=null;this.echo=!1},clearPassword:function(){this.password=null},clearChallenge:function(){this.challenge=this.response=null;this.echo=!1},isEmpty:function(){return this.username==this.password==this.challenge==this.response==null&&0==this.echo}};OpenVPN.Connect.app.add("credentials",Credentials);
