function hasNeverAutologin(b,a){var e=lpcanonizeUrl(b);if(g_neverurls.onlyautologins&&g_neverurls.onlyautologins.length>0){for(var d=false,c=0;g_neverurls.onlyautologins&&c<g_neverurls.onlyautologins.length;c++){var f=g_neverurls.onlyautologins[c];if(f==a||f==e){d=true;break}}if(!d)return true}for(c=0;g_neverurls.neverautologins&&c<g_neverurls.neverautologins.length;c++){f=g_neverurls.neverautologins[c];if(f==a||f==e)return true}return false}
function hasNeverGenerate(b,a){var e=lpcanonizeUrl(b);if(g_neverurls.onlygenerates&&g_neverurls.onlygenerates.length>0){for(var d=false,c=0;g_neverurls.onlygenerates&&c<g_neverurls.onlygenerates.length;c++){var f=g_neverurls.onlygenerates[c];if(f==a||f==e){d=true;break}}if(!d)return true}for(c=0;g_neverurls.nevergenerates&&c<g_neverurls.nevergenerates.length;c++){f=g_neverurls.nevergenerates[c];if(f==a||f==e)return true}return false}
function hasNeverFormFill(b,a){var e=lpcanonizeUrl(b);if(g_neverurls.onlyformfills&&g_neverurls.onlyformfills.length>0){for(var d=false,c=0;g_neverurls.onlyformfills&&c<g_neverurls.onlyformfills.length;c++){var f=g_neverurls.onlyformfills[c];if(f==a||f==e){d=true;break}}if(!d)return true}for(c=0;g_neverurls.neverformfills&&c<g_neverurls.neverformfills.length;c++){f=g_neverurls.neverformfills[c];if(f==a||f==e)return true}return false}var g_accessibility_enabled=-1;
function handleFill(b,a){var e=false;if(!((!lploggedin||grid_getdata("active")!=null)&&!skiplogin()))if(a.cmd=="autofillaid"||a.cmd=="autologinaid"){var d=a.aid;g_last_launch[d]=(new Date).getTime();if(typeof g_sites[d]!="undefined"){e=a.cmd=="autologinaid";fill(b,g_sites[d],null,e,!e,"all",true,false,true)}}else if(!(typeof a=="undefined"||!a||typeof a.url=="undefined")){var c=a.url;console_log("request to fill "+c);if(!lp_url_is_lastpass(c)){if(typeof g_launches[b]!="undefined"&&g_launches[b]){d=
g_launches[b];if(check_ident_aid(d)){g_launches[b]=null;if(typeof g_sites[d]!="undefined")is_guiless()?fill(b,g_sites[d],null,false,false,"all",true,false,false,false):fill(b,g_sites[d],null,true,false,a.docnum,false,true)}}d=lp_gettld_url(c);var f=getsites(d);f=reorderOnURL(f,c,true);if(hasNeverAutologin(c,d))f=[];d=a.force==0&&a.topurl!=c?lp_gettld_url(a.topurl):"";if(d!=""&&hasNeverAutologin(a.topurl,d))f=[];for(var h in f){try{if(g_ischrome&&f[h].basic_auth==1&&g_accessibility_enabled<=0&&lpGetPref("basicauthnever",
0)==0)if(g_is_mac&&have_nplastpass()&&typeof g_nplastpass.accessibility_enabled=="function"){g_accessibility_enabled=g_nplastpass.accessibility_enabled()?1:0;g_accessibility_enabled==0&&setTimeout(function(){get_selected_tab(null,function(k){sendCS(gettabid(k),{cmd:"showbasicauthnotification",needbinary:0,text:gs("In order for LastPass to fill into basic authentication dialogs, you need to enable access for assistive devices.")})})},100)}else if((g_is_win||g_is_mac)&&!have_nplastpass()){g_accessibility_enabled=
0;setTimeout(function(){get_selected_tab(null,function(k){sendCS(gettabid(k),{cmd:"showbasicauthnotification",needbinary:1,text:gs("In order for LastPass to fill into basic authentication dialogs, you need to install the binary version of LastPass for Chrome.")})})},100)}}catch(i){}var g=false;d=f[h].aid;if(check_ident_aid(d))if(typeof g_sites[d]!="undefined"){d=g_sites[d];if(d.never_autofill)g=true;if(d.pwprotect||g_prompts.login_site_prompt)g=true;if(!d.genpw)if(!(d.fields.length==0&&d.username==
"")){if(d.url.indexOf("https://")==0&&c.indexOf("https://")!=0)g=true;if(parseInt(lpGetPref("automaticallyFill",1))==0&&parseInt(lpGetPref("highlightFields",1))==0)g=true;if(!g){if(h=!d.save_all){if(typeof g_fillfieldsmatches[c]=="undefined")g_fillfieldsmatches[c]=[];g_fillfieldsmatches[c][g_fillfieldsmatches[c].length]=d;g_fillfieldsmatchescurridx[c]=0}g=parseInt(lpGetPref("automaticallyFill",1));fill(b,d,a.docid,null,h,a.docnum,null,true,null,g)}if(lpGetPref("showFillNotificationBar",1)!=0){get_selected_tab(null,
function(){sendCS(b,{cmd:"showfillnotification",text:gs("LastPass has filled your login information into the form on this page."),sites:cache_usernames(f),docnum:a.docnum})});e=true}break}}}!e&&lpGetPref("showNotificationsAfterClick",1)==0&&checkgenpwfillforms(b,c)}}}
function checkgenpwfillforms(b,a){var e=lp_gettld_url(a),d=lpGetPref("showGenerateNotifications",1)!=1||hasNeverGenerate(a,e),c=lpGetPref("showFormFillNotifications",1)!=1||hasNeverFormFill(a,e),f=[];if(!c){for(var h=0;h<g_formfills.length;h++)if(check_ident_ffid(g_formfills[h].ffid))f[f.length]=g_formfills[h];if(f.length==0)c=true}if(!d||!c)sendCS(b,{cmd:"checkgenpwfillforms",nevergenerate:d,neverformfill:c,sites:cache_usernames(reorderOnURL(getsites(e),a,true,true)),formfills:LPJSON.stringify(f),
language_data:g_language_data,ff:g_cachedffdat})}function cache_usernames(b){for(var a in b)b[a].useusername=getusernamefromacct(b[a]);return LPJSON.stringify(b)}
function hasNeverSave(b,a){var e=lpcanonizeUrl(b);if(g_neverurls.onlyaccounts&&g_neverurls.onlyaccounts.length>0){for(var d=false,c=0;g_neverurls.onlyaccounts&&c<g_neverurls.onlyaccounts.length;c++){var f=g_neverurls.onlyaccounts[c];if(f==a||f==e){d=true;break}}if(!d)return true}for(c=0;g_neverurls.neveraccounts&&c<g_neverurls.neveraccounts.length;c++){f=g_neverurls.neveraccounts[c];if(f==a||f==e)return true}return false}
function handleNever(b,a){if(a.cmd=="neverautofill"){var e=a.aid;if(typeof g_sites[e]=="undefined")return;g_sites[e].never_autofill=true;g_sites[e].autologin=false;e="aid="+en(e);lpMakeRequest(base_url+"set_never_autofill.php",e,null,null)}else if(a.cmd=="neverdomain"||a.cmd=="neverpage"){var d=a.cmd=="neverdomain"?lp_gettld_url(a.url):lpcanonizeUrl(a.url);e="url="+en(AES.url2hex(d));if(typeof a.fromsave!="undefined"&&a.fromsave)g_neverurls.neveraccounts.push(d);else if(typeof a.fromgenerate!="undefined"&&
a.fromgenerate){e+="&type=1";g_neverurls.nevergenerates.push(d)}else if(typeof a.fromformfill!="undefined"&&a.fromformfill){e+="&type=2";g_neverurls.neverformfills.push(d)}else{e+="&type=3";g_neverurls.neverautologins.push(d)}lpMakeRequest(base_url+"add_never.php",e,null,null)}g_local_accts_version++;rewritelocalfile()}
function handleSave(b,a){if(typeof SAVEALLFORMSUBMITS=="undefined"){if(!lploggedin)return;if(lp_url_is_lastpass(a.url))return}for(var e=a.formdata.split("\n"),d=false,c=false,f="",h="",i=[],g=0;g<e.length;g++){var k=e[g].split("\t");if(k.length==4){var j=decodeURIComponent(k[2]);k=k[3];if((!d||!c)&&("text"==k||"email"==k)&&j.length){f=j;d=true;if(c==false&&typeof SpecialSites[lpcanonizeUrl(a.url)]!="undefined")c=true}if(k=="password"){i[i.length]=j;if(!c&&j.length){h=j;c=true}}}}if(c){a.username=
f;a.password=h;if(!d&&i.length>1){a.username=i[0];a.password=i[1]}e=lp_gettld_url(a.url);a.tld=e;c=false;j="";if(i.length>1&&i[i.length-1]==i[i.length-2]&&i[i.length-1]!=""){c=true;j=i[i.length-1]}else if(i.length>1&&i[0]==i[1]&&i[0]!=""){c=true;j=i[0]}if(c&&array_length(getsites(e,true))>0){g_notification_type="change";a.newpw=j;g_notification_data=a;sendTS({cmd:"notification",type:"change"});if(lpGetPref("showChangeNotificationBar",1)!=0){i=getsites(e,true);var m;a.sitecount=array_length(i);if(array_length(i)==
1)for(g in i){a.singleaid=g;m=gs("LastPass detected a password change for user:")+" "+getusernamefromacct(g_sites[g]);break}else m=gs("LastPass detected a password change for domain:")+" "+e;sendCS(b,{cmd:"showchangenotification",text:m,notificationdata:a});g_persistent_notifications[b]={cmd:"showchangenotification",text:m,notificationdata:a}}}else if(!hasNeverSave(a.url,e)){i=getsites(e);for(var l in i)if(check_ident_aid(l))if(typeof g_sites[l]!="undefined"){g=g_sites[l];if((!d||f==lpmdec_acct(g.username,
true,g,g_shares)||f.indexOf("****")==0)&&h==lpmdec_acct(g.password,true,g,g_shares)||g.save_all&&isMatch(g,d,f,h)||f==lpmdec_acct(g.username,true,g,g_shares)&&h=="")return}g_notification_type="save";g_notification_data=a;if(typeof ManSubmitCallback=="function"){d=[];d.postdata=g_notification_data.formdata;d.tld=e;ManSubmitCallback(d)}else{lpGetPref("showSaveSiteNotifications",0)!=0&&sendTS({cmd:"notification",type:"save"});if(lpGetPref("showSaveNotificationBar",1)!=0)if(lpCheckAddSite(a.username,
a.password,e)){sendCS(b,{cmd:"showaddnotification",text:gs("Should LastPass remember this password?"),notificationdata:LPJSON.stringify(a)});g_persistent_notifications[b]={cmd:"showaddnotification",text:gs("Should LastPass remember this password?"),notificationdata:LPJSON.stringify(a)}}}}}}
function lpCheckAddSite(b,a,e){var d=lp_get_gmt_timestamp(),c=[],f;for(f in g_rejectedaddsites){var h=g_rejectedaddsites[f];if(d>h.rejectedTime+600)c[c.length]=f}for(f=c.length-1;f>=0;f--)g_rejectedaddsites.splice(c[f],1);for(f in g_rejectedaddsites){h=g_rejectedaddsites[f];if(h.username==b&&lpdec(h.encryptedPassword)==a&&compare_tlds(h.tld,e))return false}return true}
function handleUpdateFields(b,a){var e=a.aid,d=g_sites[e],c=issharedfolder(g_shares,d.group);if(checkreadonly(c,true)){var f=[],h=[],i=updateAndEncryptData(a.formdata,f,h,d);update_username_from_fields_if(d,f);for(var g=d.fields.length-1;g>=0;g--)!d.fields[g].otherfield&&d.fields[g].otherlogin!="1"&&d.fields.splice(g,1);for(g=0;g<f.length;g++)d.fields[d.fields.length]=f[g];g_local_accts_version++;rewritelocalfile();e="data="+en(bin2hex(i))+"&ref="+en(url2hex(a.url))+"&updatefields=1&aid="+en(e);e+=
c==false?"":"&sharedfolderid="+en(c.id);d.postdata=e;d.posturl=base_url+"gm_deliver.php";d.newvalues=h;updateFieldsFromSubmit(e,d)}}
function handleAddUrid(b,a){var e=a.aid,d=g_sites[e],c=issharedfolder(g_shares,d.group);if(checkreadonly(c,true)){for(var f=[],h=0;h<d.fields.length;h++)if(d.fields[h].otherlogin=="1"&&!lp_in_array(d.fields[h].urid,f))f[f.length]=d.fields[h].urid;if(!(f.length>=10)){var i=[];f=[];var g=updateAndEncryptData(a.formdata,i,f,d);update_username_from_fields_if(d,i);for(h=0;h<i.length;h++){i[h].otherlogin="1";i[h].url=url2hex(a.url);d.fields[d.fields.length]=i[h]}g_local_accts_version++;rewritelocalfile();
e="data="+en(bin2hex(g))+"&ref="+en(url2hex(a.url))+"&addurid=1&aid="+en(e);e+=c==false?"":"&sharedfolderid="+en(c.id);d.postdata=e;d.posturl=base_url+"gm_deliver.php";d.newvalues=f;updateFieldsFromSubmit(e,d)}}}
function update_username_from_fields_if(b,a){for(var e=0,d="",c=0;c<a.length;c++)if("text"==a[c].type||"email"==a[c].type){d=a[c].value;if(++e>=2)break}if(e==1&&d!=""){for(c=e=0;c<b.fields.length;c++)if(!b.fields[c].otherfield&&("text"==b.fields[c].type||"email"==b.fields[c].type)){e++;break}if(e==0){b.username=d;b.unencryptedUsername=lpdec_acct(crypto_btoa(b.username),b,g_shares)}}}
function updateAndEncryptData(b,a,e,d){var c="";b=typeof b!="undefined"?b.split("\n"):[];for(var f=0;f<b.length;f++){var h=b[f].split("\t");if(h.length==4){var i=decodeURIComponent(h[1]),g=decodeURIComponent(h[2]);h=h[3];var k=false,j=g,m=false;if("email"==h||"text"==h||"password"==h||"hidden"==h||"textarea"==h){e&&e.push(g);g=lpenc_acct(g,d,g_shares);c+="0\t"+en(i)+"\t"+en(g)+"\t"+en(h)+"\n";if(h!="hidden"){k=true;j=crypto_atob(g)}}else if(h=="action")c+="0\taction\t"+en(g)+"\taction\n";else if(h==
"method")c+="0\tmethod\t"+en(g)+"\tmethod\n";else{c+="0\t"+en(i)+"\t"+en(g)+"\t"+en(h)+"\n";if(h=="radio"||h=="checkbox"){m=g.substring(g.length-2)=="-1";if(h!="radio"||m){k=true;j=g.substring(0,g.length-2)}}else if(h=="select-one")k=true}if(k){g=[];g.otherfield=false;g.name=i;g.type=h;g.value=j;g.checked=m;g.formname="";g.urid="0";g.otherlogin="0";g.url="";a[a.length]=g}}}return c}function handleSaveAll(b,a){a.save_all=1;g_site_data=a;openURL(getchromeurl("site.html"))}
function isMatch(b,a,e,d){a=a?false:true;for(var c=false,f=0;f<b.fields.length;f++)if(!(b.fields[f].type!="text"&&b.fields[f].type!="password"&&b.fields[f].type!="email")){var h=lpmdec_acct(b.fields[f].value,true,b,g_shares);if(("text"==b.fields[f].type||"email"==b.fields[f].type)&&e==h)a=true;if(b.fields[f].type=="password"&&d==h)c=true}if(a&&c)return true;return false}
function fill(b,a,e,d,c,f,h,i,g,k){if(typeof k=="undefined"||k==null)k=1;g||(g=false);if(!i&&(a.pwprotect||g_prompts.login_site_prompt)){console_log("FILL : Showing Security Prompt");security_prompt(function(){setTimeout(function(){fill(b,a,e,d,c,f,h,true,g)},100)})}else get_selected_tab(null,function(j){if(k&&(h||a.basic_auth==1))if(j.id==b)if(g_ischrome&&have_nplastpass()&&typeof g_nplastpass.fill_basicauth=="function"){j=getusernamefromacct(a);var m=getpasswordfromacct(a);if(j!=""||m!=""){var l=
check_autologin(d,a);if(g_nplastpass.fill_basicauth(j,m,h?true:false,lp_gettld_url(a.url),l?true:false)){g_basicauth_found=false;return}}}if(is_guiless())k=1;j=a.fields;l=j.length;c=c==1?1:0;h=h?1:0;m=a.sharedfromaid!=null&&a.sharedfromaid!=""&&a.sharedfromaid!="0"&&a.sharedfromaid!="null"?1:0;if(l!=0){var p=0;for(l=0;l<j.length;l++)j[l].type=="password"&&p++;p=!a.save_all&&p==0;for(l=0;l<j.length;l++)if(!(!a.save_all&&c&&j[l].type!="password"&&!h&&!p)){var n=j[l],q=n.value,o=n.type;if(!(typeof a.captcha_id!=
"undefined"&&a.captcha_id!=""&&a.captcha_id==n.name&&o=="text")){if("text"==o||"password"==o||"email"==o||"textarea"==o)q=lpmdec_acct(q,true,a,g_shares);if(q!=""){var r=typeof g_last_launch!="undefined"&&typeof g_last_launch[a.aid]!="undefined"&&(new Date).getTime()-g_last_launch[a.aid]<=25E3;n={cmd:"fillfield",manualfill:g,name:n.name,value:q,formname:n.formname,type:o,docid:e,aid:a.aid,checked:n.checked,doconfirm:c||a.save_all&&o=="password"?1:0,tabid:b,allowforce:h,custom_js:a.custom_js,sharedsite:m,
otherfield:n.otherfield,domains:getacceptabletlds(a.url),automaticallyFill:k,is_launch:r};if(a.custom_js!=""){n.username=getusernamefromacct(a);n.password=getpasswordfromacct(a);n.onlyfill=d?0:1}sendCS(b,n,f)}}}}else if(h){console_log("no fields. finding best match "+getusernamefromacct(a)+" and <hidden>");r=typeof g_last_launch!="undefined"&&typeof g_last_launch[a.aid]!="undefined"&&(new Date).getTime()-g_last_launch[a.aid]<=25E3;sendCS(b,{cmd:"fillbest",username:getusernamefromacct(a),password:getpasswordfromacct(a),
docid:e,aid:a.aid,custom_js:a.custom_js,updatefields:1,addurid:0,sharedsite:m,domains:getacceptabletlds(a.url),automaticallyFill:k,is_launch:r},f)}if(!c){l=check_autologin(d,a);if(typeof AUTOSUBMIT!="undefined")l=true;if(typeof a.custom_js=="string"&&a.custom_js!="")sendCS(b,{cmd:"run_custom_js",docid:e,custom_js:a.custom_js,username:getusernamefromacct(a),password:lpmdec_acct(a.password,true,a,g_shares),onlyfill:l?0:1,loc:3},f);if(typeof a.custom_js!="string"||a.custom_js.indexOf("lpdontsubmit")==
-1)if(l)sendCS(b,{cmd:"submit",docid:e,submit_id:typeof a.submit_id!="undefined"?a.submit_id:"",submit_html:typeof a.submit_html!="undefined"?a.submit_html:"",submit_js:typeof a.submit_js!="undefined"?a.submit_js:""},f);if(g_loglogins||LPISLOC)if(typeof g_loggedLogins[a.aid]=="undefined"){g_loggedLogins[a.aid]="1";loglogin(a.aid)}}})}function showpageoverlay(b){sendCS(b,{cmd:"showoverlay",urlprefix:getchromeurl("",true)})}
function check_autologin(b,a){var e=false;if(b)e=true;else if(a.autologin){var d=(new Date).getTime(),c=parseInt(lpGetPref("autoautoVal",25));if(isNaN(c)||c==""||c<=0)c=25;c=d-c*1E3;if(typeof a.last_auto_login=="undefined"||isNaN(a.last_auto_login)||a.last_auto_login<c){console_log("Launching autologin");a.last_auto_login=d;e=true}}return e}
function fillfieldsconfirm(b){var a=b.url,e=b.result,d=b.aid,c=b.docid,f=b.tabid,h=b.manualfill,i=typeof b.automaticallyFill!="undefined"?b.automaticallyFill:1,g=g_sites[d],k=g.sharedfromaid!=null&&g.sharedfromaid!=""&&g.sharedfromaid!="0"&&g.sharedfromaid!="null"?1:0;if(g.save_all){if(!e||h){a=typeof g_last_launch!="undefined"&&typeof g_last_launch[g.aid]!="undefined"&&(new Date).getTime()-g_last_launch[g.aid]<=25E3;sendCS(f,{cmd:"fillbest",username:getusernamefromacct(g),password:getpasswordfromacct(g),
docid:c,aid:g.aid,updatefields:0,addurid:0,sharedsite:k,domains:getacceptabletlds(g.url),automaticallyFill:i,is_launch:a},b.docnum)}}else if(e){(g=g_sites[d])&&fill(f,g,c,null,false,b.docnum,null,true,null,i);delete g_fillfieldsmatches[a];delete g_fillfieldsmatchescurridx[a]}else if(b.allowforce){a=typeof g_last_launch!="undefined"&&typeof g_last_launch[g.aid]!="undefined"&&(new Date).getTime()-g_last_launch[g.aid]<=25E3;sendCS(f,{cmd:"fillbest",username:getusernamefromacct(g),password:getpasswordfromacct(g),
docid:c,aid:g.aid,updatefields:0,addurid:1,sharedsite:k,domains:getacceptabletlds(g.url),automaticallyFill:i,is_launch:a},b.docnum)}else{if(g=g_fillfieldsmatches[a]){k=false;for(e=0;e<g.length;e++){d=g[e].aid;if(k){(g=g_sites[d])&&fill(f,g,c,null,true,b.docnum,null,true,null,i);return}if(e==g_fillfieldsmatchescurridx[a]){g_fillfieldsmatchescurridx[a]++;k=true}}}delete g_fillfieldsmatches[a];delete g_fillfieldsmatchescurridx[a]}}
function web2plug(b){if(b.rsa=="2"){g_local_key=AES.hex2bin(b.key);g_local_key_hex=b.key;g_local_key_hash=SHA256(g_local_key);rsa_userchangedpassword();b=opendb();createDataTable(b);b&&!LPISLOC&&b.transaction(function(a){a.executeSql("DELETE FROM LastPassData WHERE username_hash=? AND type=?",[db_prepend(g_username_hash),"accts"],function(){},function(e,d){console_log(d)})});lpWriteKeyFile()}else if(g_username!=""&&g_username!=b.username)if(b.rsa=="1"){g_local_key=AES.hex2bin(b.key);g_local_key_hex=
b.key;g_local_key_hash=SHA256(g_local_key);lpWriteKeyFile();lplogincheck(true)}else loggedOut(false,"web2plug");else{g_local_key=AES.hex2bin(b.key);g_local_key_hex=b.key;g_local_key_hash=SHA256(g_local_key);lpWriteKeyFile()}}
function recover(b,a,e,d){var c=lpParseUri(a);a=c.directory;c=c.file;a=a.replace(/^\/~[^\/]*/,"");if(!(a!=""&&a!="/"&&a!="/sso/"))if(c=="recover.php"){a=GetOTPHash(null,b,e,d);c="nouser";if(a!=""&&a!=null)c=AES.bin2hex(a);console_log("hash after GetOTPHash for "+e+" is: "+c);sendCS(b,{cmd:"recover",otp:c},d)}}
function loginfromwebsite(b){if(b.wxusername!=""&&b.keyhex!=""){var a=opendb();createSavedLoginsTable(a);a&&a.transaction(function(d){var c=(new Date).getTime();d.executeSql("UPDATE LastPassSavedLogins2 SET last_login = ? WHERE username = ?",[c,b.wxusername],function(f,h){h.rowsAffected==0&&f.executeSql("INSERT INTO LastPassSavedLogins2 (username, password, last_login) VALUES (?, '', ?)",[b.wxusername,c])},function(f,h){console_log(h)});d.executeSql("SELECT * FROM LastPassSavedLogins2 WHERE username = ? AND password != ''",
[b.wxusername],function(f,h){if(h.rows.length>0){var i=h.rows.item(0).password;if(h.rows.item(0)["protected"])i=unprotect_data(i);var g=get_key_iterations(b.wxusername);make_lp_key_iterations(b.wxusername,i,g)!=b.keyhex&&f.executeSql("UPDATE LastPassSavedLogins2 SET password = '' WHERE username = ?",[b.wxusername])}},function(){})});a=AES.hex2bin(b.keyhex);var e=g_local_key!=null?AES.bin2hex(g_local_key):"";if(!(lploggedin&&g_username==b.wxusername&&e==b.keyhex))if(lploggedin&&g_username==b.wxusername){g_local_key=
a;g_local_key_hex=b.keyhex;g_local_key_hash=SHA256(g_local_key)}else{lploggedin&&g_username!=""&&loggedOut(false,"differentuser");if(b.wxsessid!="")lp_phpsessid=b.wxsessid;g_local_key=a;g_local_key_hex=b.keyhex;g_local_key_hash=SHA256(g_local_key);lpWriteKeyFile();LP.lplogincheck(true,null,b.wxusername,b.wxhash)}}else lploggedin||LP.lplogincheck(true)}
function reorderOnURL(b,a,e,d){var c=lpParseUri(a),f=lpcanonizeUrl(a,c),h=typeof c.path=="string"?c.path.split("/"):[],i=lp_gettld_url(a),g=[],k;for(k in b)if(check_ident_aid(k)){var j=g_sites[k];if(!(typeof j=="undefined"||typeof j.url=="undefined"))if(!(!j.save_all&&e&&j.unencryptedUsername==""&&j.password==""))if(!(d&&!accthaspassword(j))){var m=lpParseUri(j.url);j.realmmatch=a==g_basicauth_url&&(lpmdec_acct(j.realm_data,true,j,g_shares)==g_basicauth_realm||g_basicauth_found&&g_basicauth_realm==
""&&j.basic_auth==1);j.servermatch=c.host==m.host;j.portmatch=compare_ports(c,m);j.serverportmatch=j.servermatch&&j.portmatch?1:0;j.usernamematch=typeof g_username_vals[a]!="undefined"&&g_username_vals[a]!=""&&g_username_vals[a]==j.unencryptedUsername;j.urlmatch=lpcanonizeUrl(j.url)==f?true:false;m=typeof m.path=="string"?m.path.split("/"):[];var l;for(l=0;l<h.length&&l<m.length;l++)if(m[l]!=h[l])break;j.pathlevelmatch=l;j.fieldmatchcount=0;g.push(j)}}g.sort(lp_aids_sort_func);return g=checkurlrules(g_urlrules,
g,i,typeof c.path=="string"?c.path:"",c.host,g_sites,get_port(c))}
function lp_aids_sort_func(b,a){if(b.realmmatch!=a.realmmatch)return b.realmmatch?-1:1;else if(b.usernamematch!=a.usernamematch)return b.usernamematch?-1:1;else if(b.urlmatch!=a.urlmatch)return b.urlmatch?-1:1;else if(b.serverportmatch&&a.serverportmatch&&b.pathlevelmatch!=a.pathlevelmatch)return b.pathlevelmatch>a.pathlevelmatch?-1:1;else if(b.serverportmatch!=a.serverportmatch)return b.serverportmatch?-1:1;else if(b.servermatch!=a.servermatch)return b.servermatch?-1:1;else if(b.fieldmatchcount!=
a.fieldmatchcount)return b.fieldmatchcount>a.fieldmatchcount?-1:1;else if(b.last_touch!=a.last_touch)return b.last_touch>a.last_touch?-1:1;else if(b.name!=a.name)return b.name<a.name?-1:1;return 0}function lp_sort_case_insensitive_name(b,a){b=b.name.toLowerCase();a=a.name.toLowerCase();return b<a?-1:1}
function launchautologin(b,a){if(check_ident_aid(b)){var e=g_sites[b];if(e)if(!a&&(e.pwprotect||g_prompts.login_site_prompt))security_prompt(function(){launchautologin(b,true)});else{g_last_launch[e.aid]=(new Date).getTime();openURL(e.url,function(d,c){g_launches[gettabid(d)]=c},e.aid)}}};
