var g_CS={},g_CS_count={},g_CS_tabs={},g_nexttabid=1,poll_timeout=6E4,debug=true,g_local_key=null,g_local_key_hex=null,g_local_hash=null,g_local_key_hash=null,g_username=null,g_username_hash=null,g_uid=null,g_pwdeckey=null,g_token="",g_identity="",g_sites=[],g_tlds=[],g_securenotes=[],g_applications=[],g_prompts=[],g_local_accts_version=-1,g_server_accts_version=-1,g_identities=[],g_formfills=[],g_neverurls=[],g_equivalentdomains=[],g_urlrules=[],g_prefoverrides=[],g_pendings=[],g_shareeautopushes=
[],g_shareeautopushests=0,g_loglogins=false,g_isadmin=false,g_iscompanyadmin=false,g_launches=[],g_last_launch=[],ischrome=true,g_icons=[],g_icons_length=0,g_loggedinoffline=false,g_loggedinonline=false,g_shares=[],g_notification_type=null,g_notification_data=null,g_site_data=null,g_formfill_data=null,g_reprompt_callback=null,g_reprompt_error_callback=null,g_omnikey_callback=null,g_last_reprompt_time=0,g_premium_exp=0,g_enterpriseuser=0,g_lastpollcheck=0,g_lastpoll=0,g_logoff_other_ses=false,g_generatedpw=
false,g_gblprefs=[],g_userprefs=[],g_fillfieldsmatches=[],g_fillfieldsmatchescurridx=[],g_currenturl="",g_currenttabid="",g_badgedata=null,g_saveall_url,g_saveall_framestotal,g_saveall_framesdone,g_saveall_docnumsdone,g_saveall_formdata,g_genpws=[],g_lp_hotkeys=["generateHk","recheckHk","searchHk","nextHk","prevHk","homeHk","submitHk","saveallHk","logoffHk","defaultffidHk","openpopoverHk"],g_generate_url="",g_generate_url_prev="",g_changepwnewpw="",g_changepwtld="",g_curr_fill_aid=0,g_is_win=navigator.appVersion.indexOf("Windows")!=
-1,g_is_mac=navigator.appVersion.indexOf("Mac")!=-1,g_is_linux=navigator.appVersion.indexOf("Linux")!=-1,g_can_open_popover=typeof SafariExtensionPopover!="undefined",g_retryonlinetimerid=null,g_notifytimerid=null,g_loggedLogins=[],g_master_password_saved=false,g_create_account_data=null,g_nplastpass=null,g_loginstarted=false,g_persistent_notifications=[],g_rejectedaddsites=[],g_checkgeneratepasswordcallback=null,g_db_transaction_tested=false,g_db_transaction_worked=false,g_hidevault=false,g_hidenotes=
false,g_hideidentities=false,g_hideexport=false,g_hideimport=false,g_hidesharing=false,g_hideprint=false,lp_rsaprivatekeyhex="",lp_rsaprivatekeyenchex="",lp_rsaprivatekeyenchexserverhash="",g_selectedtabid=-1,g_selectedtab=null,g_export_output="",g_editfieldsopener=null,g_currenttld=null,SpecialSites={},g_cachedffdat=null,g_plug2web_timeout=20,g_plug2web_last_initiated=0;function lpobjrejectedaddsite(){}var g_opera_button=null,g_username_vals=[],g_datacache=[],g_nplastpass_loaded=false;
function have_nplastpass(a){try{if(g_nplastpass&&g_nplastpass_loaded&&typeof g_nplastpass.alert=="undefined")g_nplastpass=null}catch(b){}if(!g_nplastpass)for(var c=0;c<(g_issafari?2:1);c++)try{if(c==0)g_nplastpass=document.getElementById("nplastpass");else if(g_issafari)for(var d=0;d<safari.extension.bars.length;d++)if(safari.extension.bars[d].identifier=="LPMenu"){var e=safari.extension.bars[d].contentWindow.document;e.getElementById("nplastpass")&&e.body.removeChild(e.getElementById("nplastpass"));
var f=e.createElement("embed");f.setAttribute("id","nplastpass");f.setAttribute("type","application/x-vnd-lastpass");f.setAttribute("style","visibility: hidden;");e.body.appendChild(f);g_nplastpass=f;break}g_nplastpass.is_chrome_portable();g_nplastpass_loaded=typeof g_nplastpass.alert!="undefined";break}catch(g){}try{return typeof g_nplastpass.alert!="undefined"&&(a||navigator.userAgent.indexOf("Chrome/4.1.249.1042")==-1)}catch(h){return false}}
function command_handler(a){a.command=="LPToolButtonClick"&&buttonclick()}function buttonclick(){if(lploggedin){try{if(typeof SafariExtensionPopover!="undefined"){openpopover(0);return}}catch(a){}update_menus();toggle_menu()}else open_login()}var g_popoverstartpage=0;
function openpopover(a){for(var b=safari.application.activeBrowserWindow,c=0;c<safari.extension.toolbarItems.length;c++){var d=safari.extension.toolbarItems[c];if(b==d.browserWindow&&d.identifier.indexOf("LPToolButton")!=-1){d.popover.width=369;d.popover.height=487;d.popover.contentWindow.menuload(0);d.popover.contentWindow.showwin(369,497,getchromeurl("popover.html"));d.showPopover();g_popoverstartpage=a}}}
function gettabid(a){if(g_ischrome)return a.id;else if(g_issafari){if(typeof a.myData=="undefined"){a.myData=g_nexttabid++;g_CS_tabs[a.myData]=a}return a.myData}else if(g_isopera){for(var b in g_CS_tabs)if(g_CS_tabs[b].url==a.url)return b;b=g_nexttabid++;g_CS_tabs[b]=a;return b}}function get_all_windows(a,b){if(g_ischrome)chrome.windows.getAll(a,b);else if(g_issafari)b(safari.application.browserWindows);else g_isopera&&b(opera.extension.windows.getAll())}
function get_tabs_length(a){try{return a.tabs.length}catch(b){return 0}}function close_tab(a){get_all_windows({populate:true},function(b){b.length==1&&get_tabs_length(b[0])==1&&gettabid(b[0].tabs[0])==gettabid(a)&&openURL("about:tabs");if(g_ischrome)chrome.tabs.remove(gettabid(a));else if(g_issafari||g_isopera)a.close()})}
function cleanup_tabs(){if(g_issafari)for(var a in g_CS)for(var b in g_CS[a]){if(typeof g_CS[a][b].browserWindow=="undefined"||!g_CS[a][b].browserWindow){delete g_CS[a];typeof g_CS_tabs[a]!="undefined"&&delete g_CS_tabs[a]}break}}function get_selected_tab(a,b){if(g_ischrome)chrome.tabs.getSelected(a,b);else if(g_issafari)b(safari.application.activeBrowserWindow.activeTab);else if(g_isopera)if(opera.extension.tabs.getFocused())b(opera.extension.tabs.getFocused());else return false;return true}
function message_handler(a){if(g_isopera){a.message=a.data;a.name=a.data.messagetype}var b=false;if(typeof a.message.g_user_prefs_to_write!="undefined"){b=true;var c=LPJSON.parse(a.message.g_user_prefs_to_write),d;for(d in c)lpPutUserPref(d,c[d])}if(typeof a.message.g_global_prefs_to_write!="undefined"){b=true;c=LPJSON.parse(a.message.g_global_prefs_to_write);for(d in c)lpPutGblPref(d,c[d])}b&&lpWriteAllPrefs();if(a.name=="connect"){var e=false,f=gettabidfromevent(a);if(a.message.name==geteventtargeturl(a)){cleanup_tabs();
g_CS[f]=[];g_CS_count[f]=0;g_loggedLogins=[];e=true}if(typeof g_CS[f]=="undefined"||!g_CS[f]){g_CS[f]=[];g_CS_count[f]=0}b=a.message.docnum;g_CS[f][b]=geteventtarget(a);g_CS_count[f]++;d={cmd:"setdocnum",docnum:b};if(lpGetPref("showNotificationsAfterClick",1)==0)d={cmd:"setdocnum",docnum:b,language_data:g_language_data,ff:g_cachedffdat};sendCS(f,d,b);e&&typeof g_persistent_notifications[f]!="undefined"&&g_persistent_notifications[f]&&sendCS(f,g_persistent_notifications[f])}else if(a.name=="focus"){e=
lp_gettld_url(a.message.url);if(!compare_tlds(e,g_currenttld)){update_menus();g_currenttld=e}}else if(a.name=="message")receiveCS(gettabidfromevent(a),a.message,0,{tab:geteventtarget(a)});else if(a.name=="LP_do_login")LP_do_login(a.message.u,a.message.p,a.message.rememberemail,a.message.rememberpassword,a.message.donotclearmultifactor,a.message.showvault,a.message.lpkey,a.message.lphash);else if(a.name=="openURL"){if(typeof a.message.g_site_data!="undefined"){g_site_data=LPJSON.parse(a.message.g_site_data);
g_site_data.fields=get_record(get_record_id(g_site_data)).fields}openURL(a.message.url)}else if(a.name=="reprompt_callback"){set_last_reprompt_time();g_reprompt_callback_save()}else if(a.name=="reprompt_error_callback")g_reprompt_error_callback_save();else if(a.name=="omnikey_callback")g_omnikey_callback_save(a.message.pin);else if(a.name=="update_prefs")if(a.message.page=="prefs"){lpGetPref("storeLostOTP")||DeleteOTP();if(lpGetPref("logoffWhenCloseBrowser")||lpGetPref("idleLogoffVal")>0)lpGetPref("rememberpassword")==
0&&deletesavedpw(g_username);start_idle_checker();setprefs("all","all")}else{if(a.message.page=="generate")g_genpws=a.message.g_genpws}else if(a.name=="copytoclipboard")copytoclipboard(a.message.g_data);else if(a.name=="update_prompts")g_prompts=LPJSON.parse(a.message.g_prompts);else if(a.name=="openall")openall(a.message.group);else if(a.name=="deleteGroup")deleteGroup(a.message.group,null,function(){event_dispatch_message(a,"delete_group_callback",{})});else if(a.name=="copyusername")copyusername(a.message.aid);
else if(a.name=="copypassword")copypassword(a.message.aid);else if(a.name=="copynote")copynote(a.message.aid);else if(a.name=="deleteAid")deleteAid(a.message.aid,null,false,false,function(){event_dispatch_message(a,"delete_aid_callback",{})});else if(a.name=="editAid")editAid(a.message.aid);else if(a.name=="unlock_plug2web")unlock_plug2web();else if(a.name=="gotourl")gotourl(a.message.aid);else if(a.name=="launch")launch(a.message.aid);else if(a.name=="open_login")open_login(a.message.forcetab);else if(a.name==
"addprofile")addprofile();else if(a.name=="update_create_account_data")g_create_account_data=LPJSON.parse(a.message.create_account_data);else if(a.name=="addcreditcard")addcreditcard();else if(a.name=="editprofile")editprofile(a.message.ffid);else if(a.name=="openprefs")openprefs(a.message.tab);else if(a.name=="openbaseurl")openbaseurl(a.message.suffix);else if(a.name=="changemasterpassword")changemasterpassword();else if(a.name=="openaddsecurenote")openaddsecurenote();else if(a.name=="loggedOut")loggedOut(a.message.skiprequest,
a.message.from);else if(a.name=="switch_identity")switch_identity(a.message.iid);else if(a.name=="renameGroup")renameGroup(a.message.origgrp,a.message.newgrp);else if(a.name=="addEmptyGroup")addEmptyGroup(a.message.newgrp);else if(a.name=="moveSelectedToGroup")moveSelectedToGroup(a.message.group,a.message.aids);else if(a.name=="security_prompt")security_prompt(function(){event_dispatch_message(a,"security_prompt_callback",{})});else if(a.name=="savePassword")savePassword(a.message.pass,a.message.url,
a.message.tabid,a.message.nofill);else if(a.name=="checkgeneratepassword"){g_checkgeneratepasswordcallback=function(){event_dispatch_message(a,"generatepasswordfound",{})};sendCS(a.message.tabid,{cmd:"checkgeneratepassword"})}else if(a.name=="fillform")fillform(a.message.ffid,false,a.message.origtabid,a.message.ccffid);else if(a.name=="changePassword")changePassword(a.message.password,a.message.aids);else if(a.name=="receiveTS")receiveTS(null,a.message);else if(a.name=="deleteformfill")deleteformfill(a.message.ffid);
else if(a.name=="addeditformfill")addeditformfill(LPJSON.parse(a.message.ffdata),LPJSON.parse(a.message.site));else if(a.name=="fix_tlds")fix_tlds(a.message.oldtld,a.message.newtld,a.message.aid);else if(a.name=="moveIntoSharedFolder")moveIntoSharedFolder(LPJSON.parse(a.message.shareinfo),LPJSON.parse(a.message.aidsThatChangedGroups),LPJSON.parse(a.message.aidsnewgrps),a.message.copy);else if(a.name=="increment_local_accts_version")increment_local_accts_version();else if(a.name=="rewritelocalfile")rewritelocalfile();
else if(a.name=="saveSite")saveSite(a.message.postdata,fix_fields(LPJSON.parse(a.message.acct)));else if(a.name=="openLinkedSites")openLinkedSites(a.message.password,a.message.tld);else if(a.name=="generate")opengenpw();else if(a.name=="savethesite"||a.name=="changepw"||a.name=="disablebtn"||a.name=="createaccountbtn"||a.name=="tryagainbtn"||a.name=="feedbackbtn"||a.name=="basicauthneverbtn"||a.name=="basicauthmoreinfobtn"||a.name=="fillformffid"||a.name=="chooseprofilecc"||a.name=="recheckpage"){f=
gettabidfromevent(a);processCS(f,a.message)}else if(a.name=="saveAllSite")saveAllSite(a.message.postdata,fix_fields(LPJSON.parse(a.message.acct)));else if(a.name=="saveSiteFromSubmit")saveSiteFromSubmit(a.message.postdata,fix_fields(LPJSON.parse(a.message.acct)));else if(a.name=="saveFields")saveFields(a.message.getdata,a.message.postdata,fix_fields(LPJSON.parse(a.message.aData)));else if(a.name=="set_editfieldsopener")set_editfieldsopener(geteventtarget(a));else if(a.name=="close_editfieldsopener")close_editfieldsopener();
else if(a.name=="unprotect_data")event_dispatch_message(a,"unprotect_data_callback",{protected_data:a.message.data,unprotected_data:unprotect_data(a.message.data)});else if(a.name=="change_master_password")event_dispatch_message(a,"change_master_password_callback",{newdata:change_master_password(a.message.newusername,a.message.newpassword,a.message.toserver)});else if(a.name=="lpvt_store_data_and_setsinglefactortype")lpvt_store_data_and_setsinglefactortype(a.message.data);else if(a.name=="delete_file")delete_file(a.message.f);
else if(a.name=="update_site"){e=fix_fields(LPJSON.parse(a.message.site));if(is_application(e))g_applications[e.appaid]=e;else if(e.sn)g_securenotes[e.aid]=e;else g_sites[e.aid]=e}else if(a.name=="update_fields"){g_sites[a.message.aid].fields=LPJSON.parse(a.message.fields);g_sites[a.message.aid]=fix_fields(g_sites[a.message.aid])}else if(a.name=="select_selectedtabid")select_selectedtabid();else if(a.name=="closecurrenttab")closecurrenttab(a.message.page);else if(a.name=="add_identity")add_identity();
else if(a.name=="checkforupdates")checkforupdates();else if(a.name=="clearforms")clearforms();else if(a.name=="clearrecent")clearrecent();else if(a.name=="openabout")openabout();else if(a.name=="openaddsite")openaddsite();else if(a.name=="openchooseprofilecc")openchooseprofilecc();else if(a.name=="openexport")openexport();else if(a.name=="openfavorites")openfavorites();else if(a.name=="openfeedback")openfeedback();else if(a.name=="opengenpw")opengenpw();else if(a.name=="openhelp")openhelp();else if(a.name==
"openimport")openimport();else if(a.name=="doimport")doimport(a.message.source,a.message.filename);else if(a.name=="openimportchrome")openimportchrome();else if(a.name=="openlastpassexport")openlastpassexport();else if(a.name=="openpremium")openpremium();else if(a.name=="openentconsole")openentconsole();else if(a.name=="opensearch")opensearch();else if(a.name=="openseccheck")openseccheck();else if(a.name=="opensessions")opensessions();else if(a.name=="openvault")openvault();else if(a.name=="recheckpage")recheckpage();
else if(a.name=="refreshsites")refreshsites();else if(a.name=="saveall")saveall();else if(a.name=="upgradetoserver")upgradetoserver();else if(a.name=="clearCache")clearCache(a.message.noprompt);else if(a.name=="loglogin")loglogin(a.message.aid);else if(a.name=="deleteNever")deleteNever(LPJSON.parse(a.message.n));else if(a.name=="fillaid")fillaid(a.message.aid);else if(a.name=="openprint")openprint(a.message.notes);else if(a.name=="getnotificationdata"){f=gettabidfromevent(a);typeof g_datacache[f]!=
"undefined"&&sendCS(f,{cmd:"gotnotificationdata",html:g_datacache[f]},"all")}else if(a.name=="hideoverlay"||a.name=="slidedownoverlay"||a.name=="slideupoverlay"){f=gettabidfromevent(a);sendCS(f,{cmd:a.name},"all")}else if(a.name=="autofillaid"||a.name=="autologinaid"){f=gettabidfromevent(a);a.message.topurl=geteventtargeturl(a);handleFill(f,a.message)}else if(a.name=="never"){f=gettabidfromevent(a);handleNever(f,a.message)}else if(a.name=="getdata"){b={g_userprefsstr:LPJSON.stringify(g_userprefs),
g_gblprefsstr:LPJSON.stringify(g_gblprefs),g_username:g_username,ischrome:ischrome,LPISLOC:LPISLOC,LPISUPEK:LPISUPEK,LPISUPEKCAPABLE:LPISUPEKCAPABLE,lp_iscbc:lp_iscbc,g_promptsstr:LPJSON.stringify(g_prompts),lploggedin:lploggedin,g_can_copy_to_clipboard:can_copy_to_clipboard(),g_can_clear_clipboard:can_clear_clipboard()};b.g_is_win=g_is_win;b.g_is_linux=g_is_linux;b.g_is_mac=g_is_mac;b.g_have_nplastpass=have_nplastpass();b.g_isadmin=g_isadmin;b.g_iscompanyadmin=g_iscompanyadmin;b.base_url=base_url;
switch(a.message.page){case "login":if(g_reprompt_callback){b.g_reprompt_callback="g_reprompt_callback";g_reprompt_callback_save=g_reprompt_callback;g_reprompt_callback=null;b.g_local_key=g_local_key;b.g_local_key_hex=g_local_key_hex}if(g_reprompt_error_callback){b.g_reprompt_error_callback="g_reprompt_error_callback";g_reprompt_error_callback_save=g_reprompt_error_callback;g_reprompt_error_callback=null}break;case "omnikey":if(g_omnikey_callback){b.g_omnikey_callback="g_omnikey_callback";g_omnikey_callback_save=
g_omnikey_callback;g_omnikey_callback=null}break;case "export":b.g_export_output=g_export_output;g_export_output="";break;case "prefs":b.g_can_open_popover=g_can_open_popover;b.g_pref_tab=g_pref_tab;g_pref_tab=null;b.g_master_password_saved=g_master_password_saved;f=[];for(e=0;e<g_formfills.length;e++)if(check_ident_ffid(g_formfills[e].ffid))f[f.length]=g_formfills[e];b.g_formfills=LPJSON.stringify(f);b.g_prefoverrides=LPJSON.stringify(g_prefoverrides);break;case "vault":b.g_username=g_username;b.g_local_accts_version=
g_local_accts_version;b.lploggedin=lploggedin;b.g_identity=g_identity;b.g_isadmin=g_isadmin;b.g_icons_length=g_icons_length;b.recentCount=getRecentCount();if(typeof a.message.g_username=="undefined"||g_username!=a.message.g_username||g_local_accts_version>a.message.g_local_accts_version||lploggedin!=a.message.lploggedin||g_identity!=a.message.g_identity||g_isadmin!=a.message.g_isadmin){b.g_hideidentities=g_hideidentities;b.g_identities=LPJSON.stringify(g_identities);c=[];for(e in g_sites)if(check_ident_aid(g_sites[e].aid))c[e]=
g_sites[e];b.g_sites=LPJSON.stringify(c);d=[];for(e in g_securenotes)if(check_ident_aid(g_securenotes[e].aid))d[e]=g_securenotes[e];b.g_securenotes=LPJSON.stringify(d);d=[];for(e in g_applications)if(check_ident_appaid(g_applications[e].appaid))d[e]=g_applications[e];b.g_applications=LPJSON.stringify(d);f=[];for(e=0;e<g_formfills.length;e++)if(check_ident_ffid(g_formfills[e].ffid))f[f.length]=g_formfills[e];b.g_formfills=LPJSON.stringify(f);f=[];for(e=0;e<g_pendings.length;e++)if(check_ident_aid(g_pendings[e].aid))f[f.length]=
g_pendings[e];b.g_pendings=LPJSON.stringify(f);b.g_username_hash=g_username_hash;b.searchinnotes=get_searchNotesPref();b.lpclearrecent=lpclearrecent;b.g_icons_length=g_icons_length;b.clearRecentTime=getClearRecentTime();b.g_icons=LPJSON.stringify(g_icons);b.g_local_key=g_local_key;b.g_local_key_hex=g_local_key_hex}break;case "toolstrip":case "toolstripchangepw":b.g_generate_url=g_generate_url;if(g_generate_url!="")g_generate_url_prev=g_generate_url;g_generate_url="";b.g_changepwnewpw=g_changepwnewpw;
b.g_changepwtld=g_changepwtld;b.lploggedin=lploggedin;b.g_genpws=g_genpws;b.g_local_key=g_local_key;b.g_local_key_hex=g_local_key_hex;b.g_badgedata=g_badgedata;b.g_premium_exp=g_premium_exp;b.g_enterpriseuser=g_enterpriseuser;b.g_hideexport=g_hideexport;b.g_hideidentities=g_hideidentities;b.g_hideimport=g_hideimport;b.g_hidenotes=g_hidenotes;b.g_hideprint=g_hideprint;b.g_identity=g_identity;b.clearRecentTime=getClearRecentTime();c=[];for(e in g_sites)if(check_ident_aid(g_sites[e].aid))c[e]=g_sites[e];
b.g_sites=LPJSON.stringify(c);d=[];for(e in g_securenotes)if(check_ident_aid(g_securenotes[e].aid))d[e]=g_securenotes[e];b.g_securenotes=LPJSON.stringify(d);d=[];for(e in g_applications)if(check_ident_appaid(g_applications[e].appaid))d[e]=g_applications[e];b.g_applications=LPJSON.stringify(d);var g=getcurrenturl();d=getsites(a.message.page=="toolstripchangepw"?g_changepwtld:lp_gettld_url(g),a.message.page=="toolstripchangepw");if(a.message.page=="toolstrip")d=reorderOnURL(d,g);e=[];for(f in d){if(a.message.page==
"toolstrip")f=d[f].aid;e[f]=g_sites[f]}b.g_sites_tld=LPJSON.stringify(e);f=[];for(e=0;e<g_formfills.length;e++)if(check_ident_ffid(g_formfills[e].ffid))f[f.length]=g_formfills[e];b.g_formfills=LPJSON.stringify(f);b.g_identities=LPJSON.stringify(g_identities);b.g_nevers=LPJSON.stringify(getnevers());b.g_icons=LPJSON.stringify(g_icons);b.g_menuheight=getmenuheight(true,true,true,true);break;case "formfill":b.g_formfill_data=LPJSON.stringify(g_formfill_data);g_formfill_data=null;b.countryfromip=countryfromip;
b.g_generatedpw=g_generatedpw;b.lploggedin=lploggedin;b.g_local_key=g_local_key;b.g_local_key_hex=g_local_key_hex;break;case "site":g=g_site_data.url;b.g_site_data=LPJSON.stringify(g_site_data);g_site_data=null;b.g_generatedpw=g_generatedpw;b.g_local_key=g_local_key;b.g_local_key_hex=g_local_key_hex;c=[];for(e in g_sites)if(check_ident_aid(g_sites[e].aid))c[e]=g_sites[e];b.g_sites=LPJSON.stringify(c);d=getsites(lp_gettld_url(g),true);c=[];for(f in d)c[f]=g_sites[f];b.g_sites_tld=LPJSON.stringify(c);
b.g_shares=LPJSON.stringify(g_shares);d=[];for(e in g_securenotes)if(check_ident_aid(g_securenotes[e].aid))d[e]=g_securenotes[e];b.g_securenotes=LPJSON.stringify(d);d=[];for(e in g_applications)if(check_ident_appaid(g_applications[e].appaid))d[e]=g_applications[e];b.g_applications=LPJSON.stringify(d);b.lploggedin=lploggedin;b.g_prompts=g_prompts;break;case "create_account":case "reenter_password":b.g_create_account_data=LPJSON.stringify(g_create_account_data)}event_dispatch_message(a,"gotdata",b)}}
function update_menus(){g_ischrome&&get_selected_tab(null,function(b){rebuildcontext(b.url)});if(g_issafari)for(var a=0;a<safari.extension.bars.length;a++)if(safari.extension.bars[a].identifier=="LPMenu"){safari.extension.bars[a].label=gs("LastPass Menu");safari.extension.bars[a].contentWindow.redraw_menu();lploggedin||safari.extension.bars[a].hide()}}
function toggle_menu(a){for(var b=0;b<safari.extension.bars.length;b++)if(safari.extension.bars[b].browserWindow==safari.application.activeBrowserWindow&&safari.extension.bars[b].identifier=="LPMenu")a||safari.extension.bars[b].visible?safari.extension.bars[b].hide():safari.extension.bars[b].show()}function close_menu(){toggle_menu(true)}
function onLoad(){L("BG : loaded");if(g_isopera){g_opera_button=opera.contexts.toolbar.createItem({disabled:false,title:"LastPass",icon:"icon_gray2.gif",popup:{width:"1px",height:"1px",href:getchromeurl("lp_toolstrip.html?browseraction=1")}});opera.contexts.toolbar.addItem(g_opera_button);opera.extension.tabs.onfocus=function(){var b=opera.extension.tabs.getFocused();b=b?b.url:"";if(b!=""&&b.indexOf("widget")==-1){g_generate_url_prev=g_generate_url;g_generate_url=punycode.URLToUnicode(b);opera.postError("######################################################### Setting bg.g_generate_url="+
g_generate_url)}else if(g_generate_url==""&&g_generate_url_prev!=""){g_generate_url=g_generate_url_prev;opera.postError("######################################################### Setting B bg.g_generate_url="+g_generate_url_prev)}else opera.postError("######################################################### NOT changing bg.g_generate_url="+g_generate_url)}}if(g_issafari){safari.application.addEventListener("command",command_handler,false);safari.application.addEventListener("message",message_handler,
false)}else g_isopera&&opera.extension.addEventListener("message",message_handler,false);var a=false;have_nplastpass()&&typeof g_nplastpass.lpvt_setup_if=="function"&&!is_guiless()&&g_nplastpass.lpvt_setup_if();if(have_nplastpass()&&typeof g_nplastpass.file_exists=="function"){if(g_nplastpass.file_exists("LPISLOC"))if(g_nplastpass.lpvt_verify_file_contents(g_nplastpass.read_file("LPISLOC")))LPISLOC=true;else a=true;if(g_nplastpass.file_exists("LPISUPEK"))if(g_nplastpass.lpvt_verify_file_contents(g_nplastpass.read_file("LPISUPEK")))LPISUPEK=
true;else a=true;if(g_nplastpass.file_exists("LPISUPEKCAPABLE"))if(g_nplastpass.lpvt_verify_file_contents(g_nplastpass.read_file("LPISUPEKCAPABLE")))LPISUPEKCAPABLE=true;else a=true}a&&setTimeout(function(){alert(gs("LastPass has detected an installation error.  Please reinstall LastPass."))},1E3);g_ischrome&&!is_guiless()&&typeof chrome.browserAction.setPopup=="function"&&chrome.browserAction.onClicked.addListener(function(){open_login(true)});drawIconAtRotation(0);g_hidevault=get_registry_value("Software\\LastPass",
"hidevault","0")=="1";g_hidenotes=get_registry_value("Software\\LastPass","hidenotes","0")=="1";g_hideidentities=get_registry_value("Software\\LastPass","hideidentities","0")=="1";g_hideexport=get_registry_value("Software\\LastPass","hideexport","0")=="1";g_hideimport=get_registry_value("Software\\LastPass","hideimport","0")=="1";g_hidesharing=get_registry_value("Software\\LastPass","hidesharing","0")=="1";g_hideprint=get_registry_value("Software\\LastPass","hideprint","0")=="1";if(LPISLOC)g_hideidentities=
g_hidesharing=g_hideprint=true;lpReadAllPrefs(function(b){createContextMenus();if(b==0)if(g_ischrome){lpPutGblPref("welcomedone",1);lpWriteAllPrefs();!LPISLOC&&!is_guiless()&&openURL(getchromeurl("welcome.html"))}lpGetPref("enablenamedpipes",1)==1&&have_nplastpass()&&lpnp_init();if(LPISLOC||!g_np_init)httptest()});setup_poll_timer();DeleteOldDynamicFiles();getchromeurl("needtoreinstall.html").indexOf("kegdhfdpgckamaoikbjiemmikleploeh")!=-1&&openURL(base_url+"/needtoreinstall.html");g_ischrome&&have_nplastpass()&&
typeof g_nplastpass.setup_basicauth_timer=="function"&&g_nplastpass.setup_basicauth_timer();LoadSpecialSites();setTimeout(check_key_for_changes,6E4);if(typeof PARTNERMAN!="undefined"){a=localStorage.getItem("lastmanversion");localStorage.setItem("lastmanversion",lpversion);if(a==null||a!=lpversion){g_loosebasematching=true;refresh_windows()}}}
function check_key_for_changes(){if(!(null==g_local_key_hash||""==g_local_key))if(g_local_key_hash!=null&&SHA256(g_local_key)!=g_local_key_hash){L("LOGGING OFF : cosmicrays");loggedOut();lpReportError("INVESTIGATE! KEY_HASH IS WRONG! COSMIC RAYS?")}this.setTimeout(check_key_for_changes,6E4)}
if(g_ischrome){chrome.extension.onConnect.addListener(function(a){var b=false;if(a.tab&&a.tab.url&&a.name==a.tab.url){g_CS[a.tab.id]=[];g_CS_count[a.tab.id]=0;g_loggedLogins=[];b=true;g_datacache[a.tab.id]=""}if(typeof g_CS[a.tab.id]=="undefined"||!g_CS[a.tab.id]){g_CS[a.tab.id]=[];g_CS_count[a.tab.id]=0}var c=g_CS[a.tab.id].length;g_CS[a.tab.id][c]=a;g_CS_count[a.tab.id]++;var d={cmd:"setdocnum",docnum:c};if(lpGetPref("showNotificationsAfterClick",1)==0)d={cmd:"setdocnum",docnum:c,ff:g_cachedffdat};
sendCS(a.tab.id,d,c);b&&typeof g_persistent_notifications[a.tab.id]!="undefined"&&g_persistent_notifications[a.tab.id]&&sendCS(a.tab.id,g_persistent_notifications[a.tab.id]);a.onMessage.addListener(function(e,f){receiveCS(f.tab.id,e,0,a)});a.onDisconnect.addListener(function(e){receiveCS(e.tab.id,null,1,a)})});chrome.extension.onRequest.addListener(function(a,b,c){if(typeof a.cmd!="undefined")if(a.cmd=="getnotificationdata")typeof g_datacache[b.tab.id]!="undefined"&&c(g_datacache[b.tab.id]);else if(a.cmd==
"hideoverlay"||a.cmd=="slidedownoverlay"||a.cmd=="slideupoverlay")sendCS(b.tab.id,{cmd:a.cmd});else if(a.cmd=="autofillaid"||a.cmd=="autologinaid"){a.topurl=b.tab.url;handleFill(b.tab.id,a)}else typeof a.action!="undefined"&&a.action=="never"?handleNever(b.tab.id,a):receiveCS(b.tab.id,a,0,{tab:b.tab})})}function disconnectCS(a){if(typeof g_CS[a]!="undefined"&&g_CS[a]){for(var b in g_CS[a]){g_CS[a][b].disconnect();g_CS[a][b]=null}g_CS_count[a]=0}}
function sendCS(a,b,c,d){if(a=="all")for(var e in g_CS)for(var f in g_CS[a])try{sendCS(e[f],b)}catch(g){b.cmd=="saveall"&&g_saveall_framestotal--}else if(typeof g_CS[a]=="undefined"||!g_CS[a]){L("BG -> CS["+a+"] : FAILED");d||setTimeout(function(){sendCS(a,b,c,true)},300)}else{b.urlprefix=getchromeurl("",true);d=true;for(e in g_CS[a]){if(typeof c=="undefined"){if(!d)continue;d=false}else if(c!="all"&&c!=e)continue;try{if(g_ischrome)g_CS[a][e].postMessage(b);else if(g_issafari){b.docnum=e;g_CS[a][e].page.dispatchMessage("message",
b)}else if(g_isopera){b.docnum=e;b.messagetype="message";g_CS[a][e].postMessage(b)}}catch(h){}}}}function receiveCS(a,b,c,d){if(c){if(--g_CS_count[a]<=0)g_CS[a]=null}else if(typeof b.cmd=="undefined")L("CS["+a+"] -> BG : INVALIDMSG");else processCS(a,b,d)||L("CS["+a+"] -> BG : INVALIDMSG")}
function sendTS(a,b){if(!(g_issafari||g_isopera))try{a.cmd=="notification"&&a.type!="upgrade"&&set_badge(a);if(!(a.cmd!="notification"||a.type!="upgrade")){var c=typeof b=="undefined"?"all":b,d=false,e=chrome.extension.getViews(),f;for(f in e)if(typeof e[f].receiveBG=="function"&&(c=="all"||typeof e[f].g_toolstripid!="undefined"&&c==e[f].g_toolstripid)){L("BG -> TS : cmd="+a.cmd);e[f].receiveBG(a);d=true;if(c!="all")break}d||L("BG -> TS : FAILED")}}catch(g){L("BG -> TS : FAILED error="+g)}}
function set_badge(a){if(!(g_issafari||g_isopera||is_guiless())){chrome.browserAction.setBadgeText({text:"1"});g_badgedata=a;currrotation=0;animateFlip()}}function clear_badge(){if(!(g_issafari||g_isopera||is_guiless())){chrome.browserAction.setBadgeText({text:""});currrotation=numrotations;g_badgedata=null;drawIconAtRotation(0)}}
function receiveTS(a,b){if(typeof b.cmd=="undefined"){L("TS["+a+"] -> BG : INVALIDMSG");return null}L("TS["+a+"] -> BG : cmd="+b.cmd);switch(b.cmd){case "getloginstate":lploggedin&&sendTS({cmd:"login"},a);break;case "sesameauth":sesame_auth(b.otp,b.label);break;case "yubikeyauth":yubikey_auth(b.otp,b.label);break;case "googleauthauth":googleauth_auth(b.otp,b.label);break;case "gridauth":grid_auth(b.gridvalues,b.label);break;case "multifactorauth":multifactor_auth(["multifactorresponse"],b.label);
break;case "lostkey":lostkey();break;case "googleauthlostkey":googleauthlostkey();break;case "sesamelostkey":sesamelostkey();break;case "gridlostkey":gridlostkey();break;case "multifactorlostkey":multifactorlostkey(b.type);break;case "turnofficon":lpTurnOffIcon();break;default:L("TS["+g_toolstripid+"] -> BG : INVALIDMSG");return null}}function omnikey_get_pin(a){g_omnikey_callback=a;openURL(getchromeurl("omnikey.html"))}
function processCS(a,b,c){if(typeof b.url!="undefined")b.url=punycode.URLToUnicode(b.url);switch(b.cmd){case "rsadecrypt":if(lp_url_is_lastpass(b.url)){c=b.sharekeyenchex;var d="";if(!b.sharerpublickeyhex||!c){sendCS(a,{cmd:"rsadecrypt",rc:"rsaerror",sharekeyhex:""});break}}break;case "plug2web":if(lp_url_is_lastpass(b.url)){if(g_plug2web_last_initiated<lp_get_gmt_timestamp()-g_plug2web_timeout)break;else g_plug2web_last_initiated=0;d=lpParseUri(b.url);c=d.directory;d=d.file;c=c.replace(/^\/~[^\/]*/,
"");if(c!=""&&c!="/"&&c!="/sso/"&&c!="/sso/webroot/"&&c!="/sso/aso/"){lpdbg("error","Keyplug2web request from invalid directory: "+c);break}d=d.replace(/#/,"");if(d!=""&&d!="index.php"&&d!="import.php"&&d!="export.php"&&d!="otp.php"&&d!="frameset.php"&&d!="frame_login.php"&&d!="gettopost.php"&&d!="misc_challenge.php"&&d!="enterprise_users.php"){lpdbg("error","Keyplug2web request from invalid file: "+d);break}if(g_username!=null&&g_username!="")b.username&&b.username!=""&&fix_username(b.username)!=
fix_username(g_username)?loggedOut(false,"plug2webA"):sendCS(a,{cmd:"plug2web",username:g_username,key:AES.bin2hex(g_local_key),version:lpversion,identity:g_identity},b.docnum)}break;case "web2plug":lp_url_is_lastpass(b.url)&&web2plug(b);break;case "lpgologin":if(typeof ManGetKey=="function"&&lp_url_is_lastpass(b.url))if(b.data=="")ManGetKey(b.session_key);else{c=ManParse(b.data);ManLaunch(c)}break;case "logoff":lp_url_is_lastpass(b.url)&&lploggedin&&loggedOut(false,"logoff");break;case "login":lp_url_is_lastpass(b.url)&&
loginfromwebsite(b);break;case "fill":case "autofillaid":case "autologinaid":b.topurl=c.tab.url;handleFill(a,b);break;case "checkgenpwfillforms":lploggedin&&checkgenpwfillforms(a,b.url);break;case "neverautofill":case "neverpage":case "neverdomain":handleNever(a,b);if(typeof b.fromsave!="undefined"){g_persistent_notifications[a]=null;b.notificationdata=LPJSON.parse(b.notificationdata);c=b.notificationdata.username;d=b.notificationdata.password;lpAddRejectedSite(c,d,b.tld);clear_badge()}break;case "clearnotification":clear_badge();
g_persistent_notifications[a]=null;break;case "notnow":b.notificationdata=LPJSON.parse(b.notificationdata);c=b.notificationdata.username;d=b.notificationdata.password;lpAddRejectedSite(c,d,b.tld);g_persistent_notifications[a]=null;clear_badge();break;case "savethesite":c=LPJSON.parse(b.notificationdata);c.addsite=1;g_site_data=c;openURL(getchromeurl("site.html"));g_persistent_notifications[a]=null;clear_badge();break;case "changepw":c=b.notificationdata;if(typeof c.sitecount=="undefined")c=LPJSON.parse(b.notificationdata);
c.sitecount==1?changePassword(c.newpw,Array(c.singleaid)):openchangepw(c.newpw,c.tld);g_persistent_notifications[a]=null;clear_badge();break;case "save":handleSave(a,b);break;case "updatefields":handleUpdateFields(a,b);break;case "addurid":handleAddUrid(a,b);break;case "saveall":if(typeof g_saveall_docnumsdone[b.docnum]=="undefined"){g_saveall_docnumsdone[b.docnum]=1;g_saveall_formdata+=b.formdata;++g_saveall_framesdone>=g_saveall_framestotal&&handleSaveAll(a,{cmd:"saveall",addsite:1,url:g_saveall_url,
formdata:g_saveall_formdata})}break;case "clearcache":lp_url_is_lastpass(b.url)&&clearCache(true,false,false);break;case "getimportdata":if(lp_url_is_lastpass(b.url)){d=lpParseUri(b.url);c=d.directory;d=d.file;c=c.replace(/^\/~[^\/]*/,"");if(c!=""&&c!="/"&&c!="/sso/")break;if(d!="import.php")break;sendCS(a,{cmd:"gotimportdata",source:lpimportsource,data:btoa(AES._utf8_encode(lpimportdata))});lpimportsource=lpimportdata=""}break;case "recover":lp_url_is_lastpass(b.url)&&recover(a,b.url,b.username,
b.docnum);break;case "launchautologin":lp_url_is_lastpass(b.url)&&launchautologin(b.aid);break;case "getprefs":g_username_vals[b.url]=b.username_val;setprefs(a,b.docnum);break;case "getuuid":sendCS(a,{cmd:"setuuid",uuid:getuuid()},b.docnum);break;case "setupmultifactor":b.tabid=a;if(b.username==g_username){var e="type="+LP.en(b.type)+"&username="+LP.en(b.username);lpMakeRequest(base_url+"setupmultifactor.php",e,lpSetupMultifactorResponse,function(){lpSetupMultifactorError(b)},b)}else sendCS(a,{cmd:"setupmultifactor",
result:"error"},b.docnum);break;case "setupsinglefactor":b.tabid=a;if(b.username==g_username||b.silent=="1"){e="type="+LP.en(b.type)+"&username="+LP.en(b.username);var f=true,g=function(){if(f)lpMakeRequest(base_url+"setupmultifactor.php",e,lpSetupMultifactorResponse,function(){lpSetupMultifactorError(b)},b);else b.silent!="1"&&sendCS(a,{cmd:"setupsinglefactor",result:"error"},b.docnum)};b.type=="omnikey"?omnikey_get_pin(function(l){var k="";if(have_nplastpass()&&typeof g_nplastpass.omnikey_get_public_key==
"function")k=g_nplastpass.omnikey_get_public_key(l);if(k=="")f=false;else e+="&secret="+encodeURIComponent(k);g()}):g()}else b.silent!="1"&&sendCS(a,{cmd:"setupsinglefactor",result:"error"},b.docnum);break;case "checkmultifactorsupport":c="";d="error";if(have_nplastpass()&&typeof g_nplastpass.omnikey_supported=="function"&&g_nplastpass.omnikey_supported()){c="omnikey";d="done"}else if(have_nplastpass()&&typeof g_nplastpass.winbio_supported=="function"&&g_nplastpass.winbio_supported()){c="winbio";
d="done"}else if((LPISUPEK||LPISUPEKCAPABLE||g_premium_exp>lp_get_local_timestamp())&&have_nplastpass()&&typeof g_nplastpass.lpvt_supported=="function"&&g_nplastpass.lpvt_supported()){c="vtapi";d="done"}sendCS(a,{cmd:"checkmultifactorsupport",type:c,result:d},b.docnum);break;case "verifymultifactor":c=b.eventdata1;if(c=="winbio")if(have_nplastpass()&&typeof g_nplastpass.winbio_verify_user=="function"){b=g_nplastpass.winbio_verify_user("",gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),
gs("Cancel"));sendCS(a,{cmd:"verifymultifactor",eventdata3:lpenc(b),eventdata2:"done"},b.docnum)}break;case "multifactorauth":var h="";if(b.type=="trueapi"){c=SHA256(SHA256(fix_username(b.username)+b.type));if(c.length!=64)if(have_nplastpass()&&typeof g_nplastpass.trueapi_get_hash=="function")c=g_nplastpass.trueapi_get_hash(b.username);if(c!="")h=SHA256(c+b.challenge)}else if(b.type=="omnikey"){omnikey_get_pin(function(){if(have_nplastpass()&&typeof g_nplastpass.omnikey_decrypt=="function")h=g_nplastpass.omnikey_decrypt(b.username);
sendCS(a,{cmd:"multifactorauth",multifactorresponse:h,result:h!=""?"done":"error"},b.docnum)});return}sendCS(a,{cmd:"multifactorauth",multifactorresponse:h,result:h!=""?"done":"error"},b.docnum);break;case "multifactorreprompt":security_prompt(function(){sendCS(a,{cmd:"multifactorauth",result:"done"},b.docnum)},function(){sendCS(a,{cmd:"multifactorauth",result:"error"},b.docnum)});break;case "refresh":if(lp_url_is_lastpass(b.url))b.from=="settings"?lplogincheck(b.type=="2"?"websiterefreshrsa":"websiterefresh"):
get_accts();break;case "switchidentity":lp_url_is_lastpass(b.url)&&switch_identity(b.iid,true,true);break;case "fillfieldconfirm":fillfieldsconfirm(b);break;case "deleteaid":deleteAid(b.aid,null,true,true);break;case "savenotificationhtml":g_datacache[a]=b.text;break;case "rebuildcontext":rebuildcontext(b.url);break;case "rebuildcontextonload":rebuildcontextonload();break;case "runhotkey":switch(b.hotkey){case "generateHk":opengenpw();break;case "recheckHk":recheckpage();break;case "searchHk":opensearch();
break;case "nextHk":fillnext(1);break;case "prevHk":fillnext(-1);break;case "homeHk":openvault();break;case "submitHk":fillnext(0,true);break;case "saveallHk":saveall();break;case "logoffHk":loggedOut(false,"hotkey");break;case "defaultffidHk":fill_default_ffid();break;case "openpopoverHk":buttonclick()}break;case "reporterror":lpReportError(b.e,"");break;case "recheckpage":recheckpage();break;case "copyusername":copyusername(b.aid);break;case "copypassword":copypassword(b.aid);break;case "editprofile":editprofile(b.ffid);
break;case "fillformffid":fillform(b.ffid);break;case "addprofile":addprofile();break;case "addcreditcard":addcreditcard();break;case "clearforms":clearforms();break;case "chooseprofilecc":openchooseprofilecc();break;case "generate":opengenpw();break;case "fillcurrentaid":fillcurrent(b.aid);break;case "generatepasswordfound":if(g_checkgeneratepasswordcallback){g_checkgeneratepasswordcallback();g_checkgeneratepasswordcallback=null}break;case "log":console_log(b.msg);break;case "disablebtn":openURL(base_url+
b.notificationdata.multifactor_disable_url);break;case "createaccountbtn":openURL(getchromeurl("welcome.html"));break;case "tryagainbtn":open_login();break;case "feedbackbtn":openfeedback();break;case "basicauthneverbtn":lpPutUserPref("basicauthnever","1");lpWriteAllPrefs();break;case "basicauthmoreinfobtn":have_nplastpass()?openURL(base_url+"chromebasicauth.php"):openURL(base_url+"lpchrome.php");break;case "gohome":if(g_ischrome)chrome.tabs.update(a,{url:getchromeurl("homelocal.html")});else if(g_issafari)c.tab.url=
getchromeurl("homelocal.html");else g_isopera&&c.tab.update({url:getchromeurl("homelocal.html")});if(b.email!=""&&b.sesameotp!=""){lplog("LOGGING OFF : gohome");lplogoff();sesame_setotp(b.sesameotp);openURL(getchromeurl("login.html?sesameusername="+encodeURIComponent(b.email)))}break;default:L("CS["+a+"] -> BG : INVALIDMSG");return false}return true}
function ManLaunch(a){if(typeof a=="object"&&typeof a.url!="undefined"){g_sites=[];g_sites[a.aid]=a;g_last_launch[a.aid]=(new Date).getTime();openURL(a.url,function(b,c){if(a.basic_auth=="1")setTimeout(function(){fill(gettabid(b),a,null,false,false,"all",true,true)},250);else g_launches[gettabid(b)]=c},a.aid)}}
function open_login(){if(!skiplogin()){var a=getsinglefactortype();if(a=="trueapi"&&have_nplastpass()&&typeof g_nplastpass.trueapi_default_login_exists=="function"&&g_nplastpass.trueapi_default_login_exists()){var b={},c={},d={};if(g_nplastpass.trueapi_get_default_login(b,c,d)){multifactor_setdata("password_offline",d.value);multifactor_setdata("type",a);LP_do_login(b.value,c.value,null,null,true);return false}}if(LPISUPEK||a=="vtapi"){if(have_nplastpass()&&typeof g_nplastpass.lpvt_verify_user=="function"){b=
encodeURIComponent(lpCreatePass(8,1,1,1,0,1,0,1));b=g_nplastpass.lpvt_verify_user(b,gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),gs("Cancel"),gs("Swipe current user's finger"));if(b!=""){b=b.split("|");if(b.length==2){LP_do_login(decodeURIComponent(b[0]),decodeURIComponent(b[1]));return false}}}if(LPISUPEK&&LPISLOC){have_nplastpass()&&typeof g_nplastpass.lpvt_has_data=="function"&&g_nplastpass.lpvt_has_data()?lpshowError("LoginError",false,true):lpshowError("Before you can use LastPass, you must first connect your fingerprint reader and enroll one or more fingers.",
false,true);return false}}if(a=="validity")if(have_nplastpass()&&typeof g_nplastpass.validity_verify_user=="function"){b=g_nplastpass.validity_verify_user("",gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),gs("Cancel"));if(b!=""){b=b.split("|");if(b.length==2){LP_do_login(decodeURIComponent(b[0]),decodeURIComponent(b[1]));return false}}}if(a=="winbio")if(have_nplastpass()&&typeof g_nplastpass.winbio_verify_user=="function"){b=g_nplastpass.winbio_verify_user("",gs("Swipe finger"),
gs("Swipe your finger on the fingerprint sensor"),gs("Cancel"));if(b!=""){b=b.split("|");if(b.length==2){LP_do_login(decodeURIComponent(b[0]),decodeURIComponent(b[1]));return false}}}try{if(g_issafari&&typeof SafariExtensionPopover!="undefined"){var e=safari.application.activeBrowserWindow;for(a=0;a<safari.extension.toolbarItems.length;a++){var f=safari.extension.toolbarItems[a];if(e==f.browserWindow&&f.identifier.indexOf("LPToolButton")!=-1){f.popover.width=369;f.popover.height=497;f.popover.contentWindow.showwin(369,
497,getchromeurl("login_small.html"));f.showPopover();return}}}}catch(g){}openURL(getchromeurl("login.html"))}}function closePop(){if(g_issafari&&typeof SafariExtensionPopover!="undefined")for(var a=0;a<safari.extension.toolbarItems.length;a++)safari.extension.toolbarItems[a].identifier.indexOf("LPToolButton")!=-1&&safari.extension.toolbarItems[a].popover.hide()}
function fillnext(a,b){lploggedin?get_selected_tab(null,function(c){getBG().setcurrenttabid(gettabid(c));getBG().setcurrenturl(c.url);c=getmatchingsites(1);if(c.length>0){for(var d=0;d<c.length;d++)if(c[d].aid==g_curr_fill_aid)break;if(d==c.length)g_curr_fill_aid=a==-1?c[c.length-1].aid:c[0].aid;else{if(a==1){if(++d>=c.length)d=0}else if(a==-1)if(--d<0)d=c.length-1;g_curr_fill_aid=c[d].aid}b?fill(getcurrenttabid(),g_sites[g_curr_fill_aid],null,true,false,"all",false,false,true):fillaid(g_curr_fill_aid)}}):
open_login()}function getInt(a){a=parseInt(a);if(a==""||a==NaN)a=0;return a}
function loggedIn(a){L("BG : loggedIn");lploggedin=true;lpReadAllPrefs(postlogin);if(typeof localStorage!="undefined"){var b=localStorage.getItem(db_prepend("lastversion"));checkOpenUpgradePage(b);localStorage.setItem(db_prepend("lastversion"),lpversion);b=opendb();createSavedLoginsTable(b);b&&b.transaction(function(c){c.executeSql("SELECT * FROM LastPassSavedLogins2 WHERE username = ? AND password != ''",[g_username],function(d,e){if(e.rows.length>0)g_master_password_saved=true},function(){})});
a&&setTimeout("refresh_windows();",500);drawIconAtRotation(0);sendTS({cmd:"login"})}}
function checkOpenUpgradePage(a){var b=lpversion,c=0,d=0,e=0,f=0;if(a)for(var g=a.split("."),h=0;h<g.length;h++)if(h==0)c=parseInt(g[h]);else if(h==1)d=parseInt(g[h]);else h==2&&parseInt(g[h]);b=b.split(".");for(h=0;h<b.length;h++)if(h==0)e=parseInt(b[h]);else if(h==1)f=parseInt(b[h]);else h==2&&parseInt(b[h]);if(a&&a!="null"&&(e>c||f>d))openURL(base_url+"upgrade.php?ver="+lpversion+"&type="+encodeURIComponent(get_method())+"&upgrade="+a)}
function get_searchNotesPref(){if(lpGetPref("searchNotes",1)==1)return true;return false}function postlogin(){g_lastpollcheck=(new Date).getTime();if(lpGetPref("logoffWhenCloseBrowser",0)==1&&lpGetPref("logoffWhenCloseBrowserVal",0)>0){lpPutUserPref("lastpollcheck",g_lastpollcheck);lpWriteAllPrefs()}}function lplogin(){open_login()}function lplogoff(){loggedOut(false,"lplogoff")}function lplogoff_if(){lploggedin&&loggedOut(false,"lplogoff_if")}var rotation=0,numrotations=504,currrotation=0;
function animateFlip(){rotation+=1/36;if(rotation>=1)rotation-=1;if(++currrotation>=numrotations)rotation=0;else setTimeout("animateFlip()",10);drawIconAtRotation(rotation)}
function drawIconAtRotation(a){if(!is_guiless())if(g_issafari){for(a=0;a<safari.extension.toolbarItems.length;a++)if(safari.extension.toolbarItems[a].identifier.indexOf("LPToolButton")!=-1)safari.extension.toolbarItems[a].image=getchromeurl(lploggedin?"icon_on.png":"icon_off.png");update_menus()}else if(g_isopera)setTimeout(function(){if(lploggedin){if(g_opera_button.icon!="icon2.gif"){g_opera_button.icon="icon2.gif";g_opera_button.popup.width="450px";g_opera_button.popup.height="450px";g_opera_button.popup.href=
getchromeurl("lp_toolstrip.html?browseraction=1")}}else if(g_opera_button.icon!="icon_gray2.gif"){g_opera_button.icon="icon_gray2.gif";g_opera_button.popup.width="1px";g_opera_button.popup.height="1px";g_opera_button.popup.href=getchromeurl("lp_toolstrip.html?browseraction=1")}},0);else{var b=document.getElementById(g_badgedata!=null?g_badgedata.cmd=="notification"&&g_badgedata.type=="save"?"icon_green":"icon_yellow":lploggedin?"icon":"icon_gray"),c=document.getElementById("canvas").getContext("2d");
c.save();c.clearRect(0,0,19,19);c.translate(9,9);c.rotate(2*Math.PI*ease(a));c.drawImage(b,-b.width/2,-b.height/2);c.restore();chrome.browserAction.setIcon({imageData:c.getImageData(0,0,19,19)});if(typeof chrome.browserAction.setPopup=="function")chrome.browserAction.setPopup({popup:lploggedin||g_badgedata!=null?"lp_toolstrip.html?browseraction=1":""})}}function ease(a){return(1-Math.sin(Math.PI/2+a*Math.PI))/2}
function lpAddRejectedSite(a,b,c){var d=new lpobjrejectedaddsite;d.username=a;d.encryptedPassword=lpenc(b);d.tld=c;d.rejectedTime=lp_get_gmt_timestamp();g_rejectedaddsites[g_rejectedaddsites.length]=d}
function loggedOut(a,b){L("BG : loggedOut from="+b);get_all_windows({populate:true},function(d){for(var e=0;e<d.length;e++)for(var f=0;f<get_tabs_length(d[e]);f++){var g=d[e].tabs[f].url;g&&lp_url_is_lastpassext(g)&&g.indexOf("homelocal.html")==-1&&g.indexOf("welcome.html")==-1&&g.indexOf("mathfail.html")==-1&&g.indexOf("login.html")==-1&&close_tab(d[e].tabs[f])}});lploggedin&&lpnp_notify("logout");notifications_closeall();closeallnotifications();yubikey_cleardata();googleauth_cleardata();sesame_cleardata();
grid_cleardata();multifactor_cleardata();lpSaveData("","key");var c=false;if(!lploggedin)c=a=true;lploggedin=false;last_idle_check=0;g_pwdeckey=g_uid=lpuid=g_username_hash=g_username=g_local_key_hash=g_local_hash=g_local_key_hex=g_local_key=null;g_sites=[];g_tlds=[];g_securenotes=[];g_applications=[];g_prompts=[];g_icons=[];g_icons_length=0;g_server_accts_version=g_local_accts_version=-1;g_identities=[];g_pendings=[];g_shareeautopushes=[];g_formfills=[];g_neverurls=[];g_equivalentdomains=[];g_urlrules=
[];g_prefoverrides=[];g_iscompanyadmin=g_isadmin=g_loglogins=false;g_launches=[];g_fillfieldsmatches=[];g_fillfieldsmatchescurridx=[];g_loggedinonline=g_loggedinoffline=false;lp_phpsessid="";g_enterpriseuser=g_premium_exp=0;g_loginstarted=false;lpReadAllPrefs();rotation=0;drawIconAtRotation();if(g_badgedata!=null&&(g_badgedata.cmd!="notification"||g_badgedata.type!="error"))clear_badge();rsa_clearvars();rsa_setpendingsharests(true);g_genpws=[];g_master_password_saved=false;g_persistent_notifications=
[];g_rejectedaddsites=[];g_shares=[];g_datacache=[];lpdisableoffline=false;countryfromip="";sendTS({cmd:"logoff"});c||setTimeout("refresh_windows();",500);a||lpMakeRequest(base_url+"logout.php?chrome_plugin=1&noredirect=1","",null,null)}function getmenurowheight(){return 20}function getmatchingsitesheight(a){a=a.length*getmenurowheight();if(a>200)a=200;return a}
function getmenuheight(a,b,c,d){var e=15;if(g_premium_exp>lp_get_local_timestamp()||g_enterpriseuser)--e;var f=getmenurowheight();e=e*f;if(typeof a=="undefined"||a){a=getmatchingsites();if(a.length>0){e+=f;e+=getmatchingsitesheight(a)}}if(typeof b=="undefined"||b)e+=32;if(typeof c=="undefined"||c)e+=15;if(d)e-=50;return e}function fillaid(a,b){var c=b?true:false;g_last_launch[a]=(new Date).getTime();setTimeout(function(){fill(getcurrenttabid(),g_sites[a],null,false,true,"all",true,c,true)},100)}
function setcurrenturl(a){g_currenturl=a}function setcurrenttabid(a){g_currenttabid=a}function getmatchingsites(){var a=getcurrenturl();lpcanonizeUrl(a);var b=lp_gettld_url(a);b=getsites(b);b=reorderOnURL(b,a);var c,d;a=[];for(c in b){d=b[c].aid;if(typeof g_sites[d]!="undefined"){d=g_sites[d];a.push({aid:d.aid,name:d.name,username:getusernamefromacct(d),fiid:d.fiid})}}return a}
function getnevers(){var a=getcurrenturl(),b=lp_gettld_url(a);a=lpcanonizeUrl(a);var c=[];getneverfor(c,"neveraccounts",a,b);getneverfor(c,"neverautologins",a,b);getneverfor(c,"neverformfills",a,b);getneverfor(c,"nevergenerates",a,b);return c}function getneverfor(a,b,c,d){if(g_neverurls[b]&&g_neverurls[b].length>0)for(var e=0;g_neverurls[b]&&e<g_neverurls[b].length;e++){var f=g_neverurls[b][e];if(f==c)a.push({type:b,url:f,domain:0});else f==d&&a.push({type:b,url:f,domain:1})}}
function getsites(a,b){var c;if(typeof g_equivalentdomains[a]!="undefined"){var d=g_equivalentdomains[a];if(typeof g_equivalentdomains[d]!="undefined")c=g_equivalentdomains[d]}else c=Array(a);d=[];for(var e=0;e<c.length;e++)if(typeof g_tlds[c[e]]!="undefined")for(var f in g_tlds[c[e]]){if(b){if(g_sites[f].genpw)continue;var g=issharedfolder(g_shares,g_sites[f].group);if(!checkreadonly(g,true))continue}d[f]=g_tlds[c[e]][f]}return d}
function accthaspassword(a){if(a.save_all){for(var b=0;b<a.fields.length;b++)if(a.fields[b].type=="password"&&a.fields[b].value!="")return true;return false}else return a.password!=""}function lp_url_is_lastpass(a){if(a.indexOf(base_url)==0||a.indexOf("https://lastpass.com/")==0)return true;else if(typeof g_loosebasematching!="undefined"){a=lp_gettld_url(a);return RegExp(a+"/$").test(base_url)}return false}
function lp_url_is_lastpassext(a){var b=getchromeurl("");if(a&&a.indexOf(b)==0)return true;return false}function openvault(a){if(!a&&!lploggedin)open_login();else a?get_all_windows({populate:true},function(b){for(var c=0;c<b.length;c++)for(var d=0;d<get_tabs_length(b[c]);d++)if(b[c].tabs[d].url==getchromeurl("homelocal.html"))return;openURL(getchromeurl("homelocal.html"))}):openURL(getchromeurl("homelocal.html"))}
function openurlifnotopen(a){get_all_windows({populate:true},function(b){for(var c=0;c<b.length;c++)for(var d=0;d<get_tabs_length(b[c]);d++)if(b[c].tabs[d].url==a)return;openURL(getchromeurl("homelocal.html"))})}
function openimport(){if((g_is_win||g_is_mac||g_is_linux)&&have_nplastpass()&&typeof g_nplastpass.choose_file=="function"){var a="import_other.html";if(g_issafari&&g_is_mac)a+="?getfile=1";openURL(getchromeurl(a))}else{unlock_plug2web();openURL(base_url+"import.php?hasplugin="+LP.en(lpversion)+get_identity_param())}}
function doimport(a,b){lpimportdata=b?g_nplastpass.read_file(b,true):g_nplastpass.choose_file();if(lpimportdata!=""){lpimportsource=a;unlock_plug2web();openURL(base_url+"import.php?fromplugin=1"+get_identity_param())}else b&&alert(gs("That file is missing or empty.  Please enter the full path of the file to import."))}function openimportchrome(){openURL(getchromeurl("import.html"))}function openexport(){doexport()}
function openlastpassexport(a){if(lpGetPref("noexport",0)==1)alert(gs("CompanyPolicyProhibits"));else{have_nplastpass()&&typeof g_nplastpass.write_file=="function"&&typeof g_nplastpass.get_path=="function"||alert(gs("The binary version of the LastPass plugin is required for this operation. It can be downloaded from lastpass.com."));if(!g_generatedpw)if(!a){security_prompt(function(){openlastpassexport(true)});return}rewritelocalfile(false,true,true);alert(gs("Your data has been exported to")+"\n"+
g_nplastpass.get_path()+"lpexport.xml")}}function openprint(a){unlock_plug2web();var b=base_url+"export.php?plug=1&print=1&hasplugin="+LP.en(lpversion)+get_identity_param();if(a)b+="&notes=1";openURL(b)}g_pref_tab=null;function openprefs(a){if(a)g_pref_tab=a;openURL(getchromeurl(g_isopera?"options.html":"prefs.html"))}function openhelp(){openURL(base_url+"help.php?fromwebsite=1")}function openpremium(){openURL(base_url+"premium.php")}
function openentconsole(){openURL(base_url+"enterprise_home.php")}
function openall(a,b){if(a==gs("favorites"))openfavorites();else if(a==gs("recently usedlower"))openallrecent();else{var c=[],d=false,e;for(e in g_sites)if(check_ident_aid(g_sites[e].aid))if(g_sites[e].group==a){c.push(g_sites[e]);d|=g_sites[e].pwprotect}if(c.length!=0)if(!b&&(d||g_prompts.login_site_prompt))security_prompt(function(){openall(a,true)});else for(e=0;e<c.length;e++){d=c[e];g_last_launch[d.aid]=(new Date).getTime();openURL(d.url,function(f,g){console_log("setting aid "+gettabid(f)+" "+
g);g_launches[gettabid(f)]=g},d.aid,true)}}}
function openallrecent(a){var b=[],c;for(c in g_sites)check_ident_aid(g_sites[c].aid)&&b.push(g_sites[c]);b.sort(function(f,g){return f.last_touch>g.last_touch?1:-1});var d=[],e=false;for(c=0;d.length<10&&c<b.length;c++)if(b[b.length-c-1].url!="http://group"){e|=b[b.length-c-1].pwprotect;d[d.length]=b[b.length-c-1]}if(d.length!=0)if(!a&&(e||g_prompts.login_site_prompt))security_prompt(function(){openallrecent(true)});else for(c=0;c<d.length;c++){a=d[c];g_last_launch[a.aid]=(new Date).getTime();openURL(a.url,
function(f,g){console_log("setting aid "+gettabid(f)+" "+g);g_launches[gettabid(f)]=g},a.aid,true)}}
function openfavorites(a){var b=[],c=false,d;for(d in g_sites)if(check_ident_aid(g_sites[d].aid))if(g_sites[d].fav=="1"){b.push(g_sites[d]);c|=g_sites[d].pwprotect}if(b.length!=0)if(!a&&(c||g_prompts.login_site_prompt))security_prompt(function(){openfavorites(true)});else for(d=0;d<b.length;d++){a=b[d];g_last_launch[a.aid]=(new Date).getTime();openURL(a.url,function(e,f){console_log("setting aid "+gettabid(e)+" "+f);g_launches[gettabid(e)]=f},a.aid,true)}}
function saveall(){lploggedin?get_selected_tab(null,function(a){g_saveall_url=punycode.URLToUnicode(a.url);g_saveall_framestotal=g_CS_count[gettabid(a)];g_saveall_framesdone=0;g_saveall_docnumsdone=[];g_saveall_formdata="";sendCS(gettabid(a),{cmd:"saveall"},"all")}):open_login()}function openfeedback(){openURL(base_url+"feedback.php")}
function opengenpw(){get_selected_tab(null,function(a){if(g_generate_url!="")g_generate_url_prev=g_generate_url;g_generate_url=a.url;try{if(g_issafari&&typeof SafariExtensionPopover!="undefined"){openpopover(3);return}}catch(b){}openURL(getchromeurl("lp_toolstrip.html?browseraction=1&generate=1&tabid="+en(gettabid(a))))})}function openchooseprofilecc(){get_selected_tab(null,function(a){a=gettabid(a);openURL(getchromeurl("lp_toolstrip.html?browseraction=1&chooseprofilecc=1&tabid="+en(a)))})}
function openchangepw(a,b){g_changepwnewpw=a;g_changepwtld=b;openURL(getchromeurl("lp_toolstrip.html?browseraction=1&changepw=1"))}function opensearch(){lploggedin?openURL(getchromeurl("home.html")):open_login()}function recheckpage(){lploggedin?get_selected_tab(null,function(a){a=gettabid(a);sendCS(a,{cmd:"recheck"},"all")}):open_login()}function refreshsites(){get_accts()}
function clearAllData(){var a=opendb();createDataTable(a);a&&a.transaction(function(b){b.executeSql("DELETE FROM LastPassData"+(LPISLOC?" WHERE type != 'key' AND type != 'accts'":""),[],function(){console_log("DESTROYING LastPassDatang Table")},function(c,d){console_log(d)})})}
function clearCache(a,b,c){if(typeof b=="undefined")b=true;if(typeof c=="undefined")c=true;if(!(g_username==null||g_username=="")){if(!LPISLOC){typeof localStorage!="undefined"&&localStorage.removeItem(db_prepend(g_username_hash+"_lt.cac"));if(have_nplastpass()&&typeof g_nplastpass.delete_file=="function"){g_nplastpass.delete_file(db_prepend(g_username_hash)+"_lt.cac");g_nplastpass.delete_file(db_prepend(g_username_hash)+"_lpall.slps");g_nplastpass.delete_file(db_prepend(g_username_hash)+"_lpall.lps")}}var d=
"";b||(d+=" AND type != 'icons' AND type != 'rsakey'");c||(d+=" AND type != 'otp'");if(LPISLOC)d+=" AND type != 'key' AND type != 'accts'";c=opendb();createDataTable(c);c&&c.transaction(function(e){e.executeSql("UPDATE LastPassData SET username_hash=? WHERE username_hash=?"+d,["deleteme",db_prepend(g_username_hash)],function(){var f=opendb();createDataTable(f);f&&f.transaction(function(g){g.executeSql("DELETE FROM LastPassData WHERE username_hash=?"+d,["deleteme"],function(){},function(h,l){console_log(l)})})},
function(f,g){console_log(g)})});if(b){b=lpreadretryfile();if(b!=null&&b.length>0){b=gs("A retry file has been found. This likely means that not all of your site changes have been saved. Would you like to delete this file and potentially lose some changes?");if(a||confirm(b))lpdeleteretry()}}}}function openabout(){openURL(getchromeurl("about.html"))}function opensessions(){openURL(base_url+"sess.php")}function openseccheck(){unlock_plug2web();openURL(base_url+"?securitychallenge=1")}
function openaddsite(){g_site_data=createNewAcct();g_site_data.addsite="1";g_site_data.noreplace="1";if(!get_selected_tab(null,function(a){g_site_data.url=punycode.URLToUnicode(a.url);openURL(getchromeurl("site.html"))})){g_site_data.url="";openURL(getchromeurl("site.html"))}}function openaddsecurenote(){if(lploggedin){g_site_data=createNewAcct();g_site_data.sn=1;g_site_data.url="http://sn";openURL(getchromeurl("site.html"))}else open_login(1)}
function checkforupdates(){g_notification_type="upgrade";g_notification_data={checking:true};sendTS({cmd:"notification",type:"upgrade"});setTimeout(function(){lpMakeRequest(base_url+"upgrade.php?binary="+(have_nplastpass()?1:0)+"&x=1&ver="+LP.en(lpversion)+(g_issafari?"&safarijs=1":"")+(g_isopera?"&opera=1":""),"",upgrade_response,null)},250)}
function fillform(a,b,c,d){if(check_ident_ffid(a))if(!(d&&!check_ident_ffid(d))){for(var e=0;e<g_formfills.length;e++)if(g_formfills[e].ffid==a)break;if(e!=g_formfills.length){var f;if(d){for(f=0;f<g_formfills.length;f++)if(g_formfills[f].ffid==d)break;if(f==g_formfills.length)return}!b&&(g_formfills[e].pwprotect||d&&g_formfills[f].pwprotect||g_prompts.view_ff_prompt)?get_selected_tab(null,function(g){var h=c?c:gettabid(g);security_prompt(function(){fillform(a,true,h,d)})}):get_selected_tab(null,
function(g){g=c?c:gettabid(g);var h=g_formfills[e],l=d?g_formfills[f]:null,k=[],j=[],i;for(i in h)if(i=="ffid"||i=="profiletype"||i=="pwprotect"||i=="creditmon")k[i]=h[i];else if(i=="custom_fields"){k[i]=[];for(var m=0;m<h[i].length;m++){var o="custom_field"+m;k[o]=[];k[o].cfid=h[i][m].cfid;k[o].text=lpmdec(h[i][m].text,true);k[o].value=lpmdec(h[i][m].value,true);k[o].alttext=lpmdec(h[i][m].alttext,true)}}else if(d&&i.indexOf("cc")==0)k[i]=lpmdec(l[i],true);else{k[i]=lpmdec(h[i],true);if(i=="profilelanguage"&&
typeof translations[k[i]]!="undefined")j[k[i]]=translations[k[i]]}if(typeof j["en-US"]=="undefined")j["en-US"]=translations["en-US"];i=LPJSON.stringify(k);sendCS(g,{cmd:"fillform",toformfill:i,translations:LPJSON.stringify(translations)},"all");logformfill(a)})}}}function getacceptabletlds(a){var b=a=lp_gettld_url(a),c=null;if(typeof g_equivalentdomains[a]!="undefined")c=g_equivalentdomains[a];if(c)for(var d in g_equivalentdomains)if(d==c)b+=","+g_equivalentdomains[d];return b}
function fillcurrent(a,b,c){!b&&(g_sites[a].pwprotect||g_prompts.login_site_prompt)?get_selected_tab(null,function(d){var e=c?c:gettabid(d);security_prompt(function(){fillcurrent(a,true,e)})}):get_selected_tab(null,function(d){d=c?c:gettabid(d);sendCS(d,{cmd:"fillcurrent",password:getpasswordfromacct(g_sites[a]),domains:getacceptabletlds(g_sites[a].url)},"all")})}function openbaseurl(a){openURL(base_url+a)}
function addprofile(a){if(lploggedin)if(!a&&g_prompts.view_ff_prompt)security_prompt(function(){addprofile(true)});else{g_formfill_data={};g_formfill_data.cmd="add";g_formfill_data.type=0;g_formfill_data.data=null;openURL(getchromeurl("formfill.html"))}else open_login(1)}
function addcreditcard(a){if(lploggedin)if(!a&&g_prompts.view_ff_prompt)security_prompt(function(){addcreditcard(true)});else{g_formfill_data={};g_formfill_data.cmd="add";g_formfill_data.type=1;g_formfill_data.data=null;openURL(getchromeurl("formfill.html"))}else open_login(1)}
function editprofile(a,b){if(lploggedin)for(var c=0;c<g_formfills.length;++c){if(a==g_formfills[c].ffid){if(!b&&(g_formfills[c].pwprotect||g_prompts.view_ff_prompt)){security_prompt(function(){editprofile(a,true)});break}g_formfill_data={};g_formfill_data.cmd="edit";g_formfill_data.type=g_formfills[c].profiletype;g_formfill_data.data=g_formfills[c];openURL(getchromeurl("formfill.html"));break}}else open_login(1)}
function clearforms(){get_selected_tab(null,function(a){a=gettabid(a);sendCS(a,{cmd:"clearforms"},"all")})}function lostkey(){openURL(base_url+"lostkey.php?cmd=sendemail&username="+en(g_username))}function googleauthlostkey(){openURL(base_url+"lostkey.php?cmd=sendemail&username="+en(g_username)+"&type=googleauth")}function sesamelostkey(){openURL(base_url+"sesamedisable.php?cmd=sendemail&username="+en(g_username))}
function gridlostkey(){openURL(base_url+"griddisable.php?cmd=sendemail&username="+en(g_username))}function multifactorlostkey(a){openURL(base_url+"multifactordisable.php?cmd=sendemail&username="+en(g_username)+"&type="+en(a))}
function lpshowError(a,b,c,d,e,f){g_notification_type="error";g_notification_data={msg:gs(a),showFeedback:b,showLogin:c,showCreateAccount:d,multifactor_disable_url:e,yellow:f};sendTS({cmd:"notification",type:"error"});setTimeout(function(){get_selected_tab(null,function(g){sendCS(gettabid(g),{cmd:"showerrornotification",text:gs(a),notificationdata:g_notification_data})})},100);console_log(a)}
function launch(a,b){if(is_application(a))g_is_win&&have_nplastpass()?lpnp_notify("launch",{data0:LP.get_appaid(a)}):editAid(a,null,b);else if(check_ident_aid(a)){var c=get_record(a);if(c)if(c.sn)editAid(a);else{var d=c.pwprotect;if(!b&&(d||g_prompts.login_site_prompt))security_prompt(function(){launch(a,true)});else{d=c.url;d.match(/^[a-z]+?\:\/\//i)||(d="http://"+d);g_last_launch[c.aid]=(new Date).getTime();openURL(d,function(e,f){g_launches[gettabid(e)]=f},c.aid)}}}}
function security_prompt(a,b){if(g_prompts.multifactor_reprompt||LPISUPEK){var c=multifactor_getdata("password_offline");if(c&&c!="")if(multifactor_getdata("type")=="trueapi")if(have_nplastpass()&&typeof g_nplastpass.trueapi_get_hash=="function")if(g_nplastpass.trueapi_get_hash(g_username)==c){a();return}c=getsinglefactortype();if(LPISUPEK||c=="vtapi"){if(have_nplastpass()&&typeof g_nplastpass.lpvt_verify_user=="function"){var d=g_nplastpass.lpvt_verify_user("",gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),
gs("Cancel"),gs("Swipe current user's finger"));if(d!=""){d=d.split("|");if(d.length==2)if(null!=g_local_key&&g_local_key!=""&&g_local_key==make_lp_key_iterations(fix_username(decodeURIComponent(d[0])),decodeURIComponent(d[1]),get_key_iterations(fix_username(decodeURIComponent(d[0]))))){a();return}}}if(LPISUPEK&&LPISLOC){typeof b=="function"&&b();return}}if(c=="validity")if(have_nplastpass()&&typeof g_nplastpass.validity_verify_user=="function"){d=g_nplastpass.validity_verify_user("",gs("Swipe finger"),
gs("Swipe your finger on the fingerprint sensor"),gs("Cancel"));if(d!=""){d=d.split("|");if(d.length==2)if(null!=g_local_key&&g_local_key!=""&&g_local_key==make_lp_key_iterations(fix_username(decodeURIComponent(d[0])),decodeURIComponent(d[1]),get_key_iterations(fix_username(decodeURIComponent(d[0]))))){a();return}}}if(c=="winbio")if(have_nplastpass()&&typeof g_nplastpass.winbio_verify_user=="function"){d=g_nplastpass.winbio_verify_user("",gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),
gs("Cancel"));if(d!=""){d=d.split("|");if(d.length==2)if(null!=g_local_key&&g_local_key!=""&&g_local_key==make_lp_key_iterations(fix_username(decodeURIComponent(d[0])),decodeURIComponent(d[1]),get_key_iterations(fix_username(decodeURIComponent(d[0]))))){a();return}}}}c=lpGetPref("reprompttime",0);if((new Date).getTime()-g_last_reprompt_time<=c*1E3)a();else{g_reprompt_callback=a;g_reprompt_error_callback=b;openURL(getchromeurl("login.html"))}}
function get_identity_param(){return"&iid="+LP.en(g_identity)}function add_ident_aid(a){if(g_identity!=""){for(var b=0;b<g_identities.length;b++)if(g_identities[b].iid==g_identity)break;if(!(b>=g_identities.length)){b=g_identities[b];if(b.aids!="")b.aids+=",";b.aids+=a;b.aidarr=b.aids.split(",")}}}
function add_ident_ffid(a){if(g_identity!=""){for(var b=0;b<g_identities.length;b++)if(g_identities[b].iid==g_identity)break;if(!(b>=g_identities.length)){b=g_identities[b];if(b.ffids!="")b.ffids+=",";b.ffids+=a;b.ffidarr=b.ffids.split(",")}}}
function check_ident_aid(a){if(g_identity=="")return true;else{for(var b=0;b<g_identities.length;b++)if(g_identities[b].iid==g_identity)break;if(b>=g_identities.length)return false;b=g_identities[b];if(typeof b.aidarr=="undefined")b.aidarr=b.aids.split(",");return lp_in_array(a,b.aidarr)}}
function check_ident_appaid(a){if(g_identity=="")return true;else{for(var b=0;b<g_identities.length;b++)if(g_identities[b].iid==g_identity)break;if(b>=g_identities.length)return false;b=g_identities[b];if(typeof b.appaidarr=="undefined")b.appaidarr=b.appaids.split(",");return lp_in_array(a,b.appaidarr)}}
function check_ident_ffid(a){if(g_identity=="")return true;else{for(var b=0;b<g_identities.length;b++)if(g_identities[b].iid==g_identity)break;if(b>=g_identities.length)return false;b=g_identities[b];if(typeof b.ffidarr=="undefined")b.ffidarr=b.ffids.split(",");return lp_in_array(a,b.ffidarr)}}
function switch_identity(a,b,c,d,e){if(a!=g_identity){var f=false;if(a!=""){for(var g=0;g<g_identities.length;g++)if(g_identities[g].iid==a){if(g_identities[g].pw_prompt)f=true;break}if(g>=g_identities.length)return}else for(g=0;g<g_identities.length;g++)if(g_identities[g].pw_prompt){f=true;break}if(!b&&(f||g_prompts.switch_identity_prompt)){e&&closePop();security_prompt(function(){switch_identity(a,true)})}else{g_identity=""+a;d||lpnp_notify("switchidentity",{data0:g_identity});lpPutUserPref("identity",
g_identity);lpWriteAllPrefs();c||refresh_windows();update_menus()}}}function add_identity(){unlock_plug2web();openURL(base_url+"?ac=1&addidentity=1")}function setup_poll_timer(){setTimeout("poll_server();",6E4)}function set_last_reprompt_time(){g_last_reprompt_time=(new Date).getTime()}
function compare_tlds(a,b){if(typeof a!="string")return false;if(typeof b!="string")return false;a=a.toLowerCase();b=b.toLowerCase();return a==b?true:typeof g_equivalentdomains[a]!="undefined"&&typeof g_equivalentdomains[b]!="undefined"&&g_equivalentdomains[a]==g_equivalentdomains[b]?true:false}var LP=this;function lpreadretry(){if(typeof localStorage=="undefined")return null;return localStorage.getItem(db_prepend(g_username_hash+".retry"))}
function lpdeleteretry(){if(typeof localStorage=="undefined")return null;localStorage.removeItem(db_prepend(g_username_hash+".retry"))}function lpwriteretry(a){if(g_username_hash==""||g_username_hash==null)return false;if(typeof localStorage=="undefined")return false;localStorage.setItem(db_prepend(g_username_hash+".retry"),a);return true}
function getuuid(){if(LPISLOC)return"";if(typeof localStorage=="undefined")return"";try{var a=localStorage.getItem(db_prepend("lp.uid"));if(a==null||a==""){if(g_is_win&&have_nplastpass()&&typeof g_nplastpass.read_file=="function"){a=g_nplastpass.read_file(db_prepend("lp.suid"));if(a==null||a==""){a=g_nplastpass.read_file(db_prepend("lp.uid"));if(a!=null&&a!=""){var b=protect_data(a,true);g_nplastpass.write_file(db_prepend("lp.suid"),b)}}else a=unprotect_data(a,true)}if(a==null||a==""){a=lpCreatePass(32,
1,1,1,1,1,1,1);localStorage.setItem(db_prepend("lp.uid"),a);if(g_is_win&&have_nplastpass()&&typeof g_nplastpass.write_file=="function"){b=protect_data(a,true);g_nplastpass.write_file(db_prepend("lp.suid"),b)}}}return a}catch(c){console_log("Error in getuuid: "+c);return""}}function lpdbg(a,b){console_log(b)}var lperrorcount=0;
function lpReportError(a){a=a;if(g_prompts.improve!=false){lperrorcount++;if(!(lperrorcount>100)){var b=a.match(/^(.*)location:\s+/);if(b)a=b[1];a="msg=cr() lp("+lpversion+") errors("+lperrorcount+"): "+LP.en(a);lpMakeRequest(base_url+"error.php?",a,null,null)}}}function lplog(a){console_log(a)}function lpatob(a){return atob(a)}function lpbtoa(a){return btoa(a)}function lpGetCurrentWindow(){return window}function bin2hex(a){return AES.bin2hex(a)}function url2hex(a){return AES.url2hex(a)}
function hex2url(a){return AES.hex2url(a)}function hex2bin(a){return AES.hex2bin(a)}function lp_hex2bin(a){return AES.hex2bin(a)}var lastopenauthwin=0;function ismultifactortaburl(a){return a.indexOf("browseraction=1&yubikey=1")!=-1||a.indexOf("browseraction=1&googleauth=1")!=-1||a.indexOf("browseraction=1&sesame=1")!=-1||a.indexOf("browseraction=1&grid=1")!=-1?true:false}
function openURL(a,b,c,d){get_selected_tab(null,function(g){g_selectedtabid=gettabid(g);g_selectedtab=g});a.indexOf("sesameusername")>0&&get_all_windows({populate:true},function(g){for(var h=g.length-1;h>=0;--h)for(var l=get_tabs_length(g[h])-1;l>=0;--l){var k=g[h].tabs[l].url;k&&lp_url_is_lastpassext(k)&&close_tab(g[h].tabs[l])}});var e=false;if(ismultifactortaburl(a))lastopenauthwin=(new Date).getTime();else if(a.indexOf("homelocal.html")!=-1)if((new Date).getTime()-1E3<lastopenauthwin)e=true;b||
(b=function(){});var f=lpGetPref("openpref","tabs");if(f=="same"&&(d||a.indexOf("-extension://")==6))f="tabs";if(typeof PARTNERMAN!="undefined")f="same";if(f=="same")if(g_ischrome)get_selected_tab(null,function(g){if(g.url.match(/^https?:\/\/.*\//)){sendCS(g.id,{cmd:"loadurl",url:a});b(g,c)}else chrome.tabs.create({url:a},function(h){b(h,c)})});else if(g_issafari){e=safari.application.activeBrowserWindow.activeTab;b(e,c);e.url=a}else{if(g_isopera)if(e=opera.extension.tabs.getFocused()){b(e,c);e.update({url:a})}else{e=
opera.extension.tabs.create({focused:true,url:a});b(e,c)}}else if(f=="windows")if(g_ischrome)chrome.windows.create({url:a},function(g){b(g,c)});else if(g_issafari){e=safari.application.openBrowserWindow().activeTab;b(e,c);e.url=a}else{if(g_isopera){e=opera.extension.windows.create({focused:true,url:a});b(e,c)}}else{d=e?false:true;if(g_ischrome)chrome.tabs.create({url:a,selected:d},function(g){b(g,c)});else if(g_issafari){e=safari.application.activeBrowserWindow.openTab(e?"background":"foreground");
b(e,c);e.url=a}else if(g_isopera){e=opera.extension.tabs.create({focused:true,url:a});b(e,c)}}}function copyusername(a){a=get_record(a);copytoclipboard(getusernamefromacct(a))}
function copypassword(a,b){var c=get_record(a);if(c.sharedfromaid!=null&&c.sharedfromaid!=""&&c.sharedfromaid!="0"&&c.sharedfromaid!="null")alert(gs("This is a shared site. You are not permitted to view the password."));else if(!b&&(c.pwprotect||g_prompts.view_pw_prompt))security_prompt(function(){copypassword(a,true)});else{loglogin(a);copytoclipboard(getpasswordfromacct(c))}}
function copynote(a,b){var c=get_record(a);if(!b&&(c.pwprotect||g_prompts.edit_sn_prompt))security_prompt(function(){copynote(a,true)});else{c=typeof c.extra!="undefined"?lpmdec_acct(c.extra,true,c,g_shares):"";copytoclipboard(c)}}
function refresh_windows(){get_all_windows({populate:true},function(a){for(var b=0;b<a.length;b++)for(var c=0;c<get_tabs_length(a[b]);c++)if(lp_url_is_lastpass(a[b].tabs[c].url)&&a[b].tabs[c].url.indexOf("lpnorefresh=1")==-1){var d=a[b].tabs[c].url;if(typeof PARTNERMAN!="undefined")if(g_ischrome)chrome.tabs.update(gettabid(a[b].tabs[c]),{url:d});else safari.application.browserWindows[b].tabs[c].url=d;else{d=d.replace("&nk=1","");sendCS(gettabid(a[b].tabs[c]),{cmd:"loadurl",url:d})}}})}
function closeallnotifications(a){if(typeof a=="undefined")a=false;get_all_windows({populate:true},function(b){for(var c=0;c<b.length;c++)for(var d=0;d<get_tabs_length(b[c]);d++)sendCS(gettabid(b[c].tabs[d]),{cmd:"closenotification",includeerror:a})})}function recheckall(){get_all_windows({populate:true},function(a){for(var b=0;b<a.length;b++)for(var c=0;c<get_tabs_length(a[b]);c++)sendCS(gettabid(a[b].tabs[c]),{cmd:"recheck"},"all")});setprefs("all","all")}
function closecurrenttab(a){get_selected_tab(null,function(b){a!=""&&b.url.indexOf(a)==-1||close_tab(b)});select_selectedtabid()}function fill_default_ffid(){if(lploggedin){var a=lpGetPref("defaultffid","0");if(check_ident_ffid(a))for(var b=0;b<g_formfills.length;b++)if(g_formfills[b].ffid==a){fillform(a);return}confirm(gs("You have not yet chosen a default form fill profile.  Would you like to choose one now?"))&&openprefs()}else open_login()}
function setprefs(a,b){var c=getInt(lpGetPref("highlightFields",1)),d=getInt(lpGetPref("warninsecureforms",0)),e=getInt(lpGetPref("dontfillautocompleteoff",0)),f=getInt(lpGetPref("donotoverwritefilledfields",0)),g=getInt(lpGetPref("showGenerateNotifications",1)),h=getInt(lpGetPref("showFormFillNotifications",1)),l=getInt(lpGetPref("showNotificationsAfterClick",1)),k=getInt(lpGetPref("alwayschooseprofilecc",0)),j=getInt(lpGetPref("automaticallyFill",1));if(is_guiless())c=d=l=g=h=0;var i={cmd:"setprefs",
highlightFields:c,warninsecureforms:d,dontfillautocompleteoff:e,donotoverwritefilledfields:f,showGenerateNotifications:g,showFormFillNotifications:h,showNotificationsAfterClick:l,alwayschooseprofilecc:k,automaticallyFill:j};for(c=0;c<g_lp_hotkeys.length;c++){d=g_lp_hotkeys[c];i[d+"KeyCode"]=lpGetPref(d+"KeyCode");i[d+"Mods"]=lpGetPref(d+"Mods")}a=="all"?get_all_windows({populate:true},function(m){for(var o=0;o<m.length;o++)for(var n=0;n<get_tabs_length(m[o]);n++)sendCS(gettabid(m[o].tabs[n]),i,"all")}):
sendCS(a,i,b)}function get_registry_value(a,b,c){var d=c;if(g_is_win&&have_nplastpass()&&typeof g_nplastpass.get_registry_value=="function"){d=g_nplastpass.get_registry_value(a,b,c);if(typeof d!="string")d=c}return d}function gotourl(a){if(a=get_record(a)){a=a.url;a.match(/^[a-z]+?\:\/\//i)||(a="http://"+a);openURL(a)}}
function deleteNever(a){for(var b=[],c=0;g_neverurls[a.type]&&c<g_neverurls[a.type].length;c++){var d=g_neverurls[a.type][c];d!=a.url&&b.push(d)}g_neverurls[a.type]=b;g_local_accts_version++;rewritelocalfile();b=0;switch(a.type){case "nevergenerates":b=1;break;case "neverformfills":b=2;break;case "neverautologins":b=3}a="delete=1&type="+LP.en(b)+"&url="+LP.en(a.url);lpMakeRequest(base_url+"add_never.php",a,function(){},function(){},null)}function db_prepend(a){if(LPISLOC)a="local_"+a;return a}
function changemasterpassword(){LPISLOC?openURL(getchromeurl("changemasterpw.html")):openbaseurl("?ac=1&opensettings=1")}
function change_master_password(a,b,c,d){var e=get_key_iterations(a),f=make_lp_key_iterations(a,b,e),g=[],h=[],l=[],k=[];if(!getBG().reencrypt(g,getBG().g_sites,f)||!getBG().reencrypt(h,getBG().g_securenotes,f)||!getBG().reencrypt(l,getBG().g_applications,f)||!getBG().reencrypt(k,getBG().g_formfills,f)){alert(gs("An error occurred"));c&&d&&d()}else if(c){b=getBG().g_local_key;getBG().g_local_key=f;getBG().g_local_key_hex=AES.bin2hex(f);getBG().g_local_key_hash=SHA256(f);a=flattendata(g_local_accts_version+
1,g,h,g_prompts,k,g_identities,g_equivalentdomains,g_neverurls,g_premium_exp,lpenc(a),g_pendings,g_shareeautopushes,lpmaxid,g_urlrules,g_prefoverrides,g_shares,l,g_enterpriseuser);getBG().g_local_key=b;getBG().g_local_key_hex=AES.bin2hex(b);getBG().g_local_key_hash=SHA256(b);d&&d(a);return a}else{getBG().g_sites=g;getBG().g_securenotes=h;getBG().g_applications=l;getBG().g_formfills=k;getBG().g_local_accts_version++;getBG().g_local_key=make_lp_key_iterations(a,b,e);getBG().g_local_hash=make_lp_hash_iterations(getBG().g_local_key,
b,e);getBG().g_local_key_hex=AES.bin2hex(getBG().g_local_key);getBG().g_local_key_hash=SHA256(getBG().g_local_key);getBG().g_username=a;getBG().g_username_hash=SHA256(a);getBG().rewritelocalfile(false,true);getBG().g_pwdeckey=getBG().g_local_key;getBG().lpWriteKeyFile();getBG().lpnp_notify("local_pwchange",{data0:g_username,data1:b});alert(gs("Password updated!"));getBG().closecurrenttab("")}}
function reencrypt(a,b,c){for(var d in b){var e=[];if(!reencryptArray(e,b[d],c,false))return false;a[d]=e}return true}
var keystoreencrypt=["username","password","extra","profilename","firstname","middlename","lastname","email","company","ssn","birthday","address1","address2","city","state","state_name","zip","country","country_cc3l","country_name","mobilephone","mobilephone3lcc","mobileext","evephone","evephone3lcc","eveext","phone","phone3lcc","phoneext","fax","fax3lcc","faxext","ccnum","ccexp","cccsc","address3","title","gender","driverslicensenum","taxid","bankname","bankacctnum","bankroutingnum","timezone","county",
"ccstart","ccname","ccissuenum","notes","text","alttext","profilelanguage","lastname2","mobileemail","firstname2","firstname3","lastname3"];
function reencryptArray(a,b,c,d){try{for(var e in b)if(typeof b[e]=="object"){var f=[];if(!reencryptArray(f,b[e],c,e=="custom_fields"?2:d||e=="fields"))return false;a[e]=f}else if(lp_in_array(e,keystoreencrypt)||e=="value"&&(d==2||d&&fieldisencrypted(b))){var g=lpmdec(b[e],true);if((g==null||g=="")&&b[e]!=null&&b[e]!="")return false;var h=lpmenc(g,true,c);a[e]=h}else a[e]=b[e]}catch(l){console_error(l);return false}return true}
function fieldisencrypted(a){for(var b in a)if(b=="type"&&(a[b]=="password"||a[b]=="text"||a[b]=="hidden"||a[b]=="textarea"||"email"==a[b]))return true;else if(b=="id")return true;return false}var lpclearrecent=false;function clearrecent(){if(typeof localStorage!="undefined"){localStorage.setItem(g_username_hash+"recent",lp_get_gmt_timestamp());lpclearrecent=true}}
function getClearRecentTime(){if(typeof localStorage=="undefined")return 0;var a=localStorage.getItem(g_username_hash+"recent");if(a==null)return 0;return a}function getRecentCount(){return lpGetPref("recentUsedCount",10)}function IsIconsUpdated(a){if(lpclearrecent){lpclearrecent=false;return true}return g_icons_length!=a}
function upgradetoserver(){if(g_isopera||confirm(gs("Please note that upgrading from LastPass Local to LastPass Online will result in your password data being uploaded in its encrypted format to LastPass servers.  You will be able to access your data from anywhere, and LastPass will not be able to read it.  Would you like to continue?")))security_prompt(function(){openURL(getchromeurl("welcome.html"))})}
function renameGroup(a,b){if(!(a==gs("favorites")||a==gs("recently usedlower"))){var c=issharedfolder(g_shares,a);if(c!=false&&c.decsharename==a)alert("You cannot rename a top level Shared folder");else{var d=issharedfolder(g_shares,b);if(checkmove(d,c))if(checkreadonly(d)&&checkreadonly(c)){var e=d==false?g_local_key:d.sharekey,f=b;if(d)f=b.substr(d.decsharename.length+1);if(d&&!c){e=[];var g=[];c=[g_sites,g_securenotes,g_applications];b.substr(d.decsharename.length+1);for(var h in c){var l=c[h],
k;for(k in l){f=l[k];if(f.group==a||f.group.indexOf(a+"\\")==0){e[e.length]=get_record_id(f);var j=b;if(f.group.indexOf("\\")>0)j=b+f.group.substr(f.group.indexOf("\\"));g[get_record_id(f)]=j}}}moveIntoSharedFolder(d,e,g)}else{c=[g_sites,g_securenotes,g_applications];g=[];j=[];var i=[];for(h in c){l=c[h];for(k in l){f=l[k];if(f.group==a){f.group=b;if(typeof g[a]=="undefined"){i[i.length]=a;j[a]=get_record_id(f)}else j[a]+=","+get_record_id(f);f=b;if(d)f=f.substr(d.decsharename.length+1);g[a]=f}else if(f.group.indexOf(a+
"\\")==0){var m=f.group;f.group=f.group.replace(a+"\\",b+"\\");if(typeof g[m]=="undefined"){i[i.length]=m;j[m]=get_record_id(f)}else j[m]+=","+get_record_id(f);f=f.group;if(d)f=f.substr(d.decsharename.length+1);g[m]=f}}}g_local_accts_version++;rewritelocalfile();h="xml=1";for(k=0;k<i.length;k++)h+="&ids"+k+"="+LP.en(j[i[k]])+"&newgrp"+k+"="+LP.en(lpenc(g[i[k]],e));h+=d==false?"":"&sharedfolderid="+en(d.id);lpMakeRequest(base_url+"groups.php",h,function(){},function(){},null)}}}}}
function getacct(a){return get_record(a)}
function moveIntoSharedFolder(a,b,c,d,e,f){if(!f){var g=gs("You are moving sites to a shared folder. This will potentially make them available to others.\n\nAre you sure you would like to continue?");if(!confirm(g))return false}for(var h=a.sharekey,l="cmd=uploadaccounts&username="+en(g_username),k="",j=0;j<b.length;j++){var i=getacct(b[j]);g=false;if(typeof i.individualshare!="undefined"&&i.individualshare){if(i.sharedfromaid!=null&&i.sharedfromaid!=""&&i.sharedfromaid!="0"){alert(gs("You cannot move individually shared sites into a shared folder."));
return false}if(d||f)g=true;else{g=gs("A site that has been previously shared cannot be moved to a shared folder.\n\nWould you like to make a copy?");if(confirm(g))g=true;else return false}}if(!e){var m=c[b[j]].substr(a.decsharename.length+1);if(is_application(i))m="&appname"+j+"="+en(i.appname)+"&name"+j+"="+en(lpenc(i.name,h))+"&type"+j+"="+en("cr")+"&group"+j+"="+en(lpenc(m,h))+"&extra"+j+"="+en(lpenc(lpmdec(i.extra,true),h))+"&script"+j+"="+en(i.script)+"&wininfo"+j+"="+en(i.wininfo)+"&wintitle"+
j+"="+en(i.wintitle)+"&exeversion"+j+"="+en(i.exeversion)+"&exehash"+j+"="+en(i.exehash)+"&fiid"+j+"="+en(i.fiid);else{m="&url"+j+"="+en(url2hex(i.url))+"&username"+j+"="+en(lpenc(lpmdec(i.username,true),h))+"&password"+j+"="+en(lpenc(lpmdec(i.password,true),h))+"&name"+j+"="+en(lpenc(i.name,h))+"&type"+j+"="+en("cr")+"&grouping"+j+"="+en(lpenc(m,h))+"&extra"+j+"="+en(lpenc(lpmdec(i.extra,true),h))+"&realm"+j+"="+en(lpenc(lpmdec(i.realm_data,true),h));if(i.save_all)m+="&save_all"+j+"=1"}for(var o=
"",n=0;n<i.fields.length;n++){var q=i.fields[n].value,p=i.fields[n].type;if(is_application(i)||p=="text"||p=="email"||p=="password"||p=="textarea"||p=="hidden")q=lpenc(lpmdec(q,true),h);else if(p=="checkbox"||p=="radio")q+=i.fields[n].checked?"-1":"-0";o+=is_application(i)?"&fields"+j+"id"+n+"="+en(i.fields[n].id)+"&fields"+j+"type"+n+"="+en(i.fields[n].type)+"&fields"+j+"value"+n+"="+en(q):"&fields"+j+"name"+n+"="+en(i.fields[n].name)+"&fields"+j+"type"+n+"="+en(i.fields[n].type)+"&fields"+j+"value"+
n+"="+en(q)+"&fields"+j+"formname"+n+"="+en(typeof i.fields[n].formname=="undefined"?"":i.fields[n].formname)}l+=m;l+=o;if(!g&&!d)k+=en(b[j])+","}}if(e)return true;l+="&sharedfolderid="+en(a.id);d||(l+="&todelete="+k);lpMakeRequest(base_url+"lastpass/api.php",l,function(){get_accts()},function(){alert(gs("An error occurred"))},null);return true}
function moveSelectedToGroup(a,b){var c=b.split(","),d=issharedfolder(g_shares,a);if(checkreadonly(d)){for(var e=false,f=0;f<c.length;f++){var g=getacct(c[f]);g=issharedfolder(g_shares,g.group);if(!checkreadonly(g))return;if(!checkmove(d,g))return;if(d&&!g)e=true}if(e){e=[];for(f=0;f<c.length;f++)e[c[f]]=a;moveIntoSharedFolder(d,c,e)}else{e=[];g=[];if(a==gs("favorites"))for(f=0;f<c.length;f++){var h=getacct(c[f]);if(h&&h.fav=="0")e[e.length]=c[f]}if(c.length>0||e.length>0||g.length>0)changeGroupAndFavorites(c,
e,g,a,d)}}}
function changeGroupAndFavorites(a,b,c,d,e){for(var f=c="",g="",h=0;h<a.length;h++){var l=a[h],k=getacct(l);if(k&&d!=gs("favorites")){k.group=d;c+=g+l;g=","}}g="";for(h=0;h<b.length;h++){l=b[h];if(k=getacct(l)){k.fav="1";f+=g+l;g=","}}g_local_accts_version++;g_server_accts_version++;rewritelocalfile();a=e==false?g_local_key:e.sharekey;b=d;if(e)b=d.substr(e.decsharename.length+1);d="aids="+LP.en(c)+"&newfavaids="+LP.en(f)+"&oldfavaids="+LP.en("")+"&newgrp="+LP.en(lpenc(b,a))+"&xml=1";d+=e==false?"":
"&sharedfolderid="+en(e.id);lpMakeRequest(base_url+"groups.php",d,lpChangeGroupResponse)}function lpChangeGroupResponse(){}function lpReadFile(a){return have_nplastpass()&&typeof g_nplastpass.read_file=="function"?g_nplastpass.read_file(a):""}function is_chrome_portable(){return have_nplastpass()&&typeof g_nplastpass.is_chrome_portable=="function"&&g_nplastpass.is_chrome_portable()}
function doexport(a){if(lpGetPref("noexport",0)==1)setTimeout(function(){alert(gs("CompanyPolicyProhibits"))},0);else{if(!g_generatedpw)if(!a){security_prompt(function(){doexport(true)});return}g_export_output="url,username,password,extra,name,grouping,fav\n";a=[];for(var b in g_sites)if(check_ident_aid(b))if(g_sites[b].url!="http://group")a[a.length]=g_sites[b];for(b in g_securenotes)if(check_ident_aid(b))a[a.length]=g_securenotes[b];for(b=0;b<a.length;b++){var c=a[b];if(!(c.sharedfromaid!=null&&
c.sharedfromaid!=""&&c.sharedfromaid!="0")){var d=[];d[0]=c.url;d[1]=getusernamefromacct(c);d[2]=getpasswordfromacct(c);d[3]=lpmdec_acct(c.extra,true,c,g_shares);d[4]=c.name;d[5]=c.group;d[6]=c.fav;for(var e=c="",f=0;f<d.length;f++){var g=d[f];if(g.match(/,|\r|\n|"/))g='"'+g.replace(/"/g,'""')+'"';c+=e+of(g);e=","}c+="\n";g_export_output+=c}}openURL(getchromeurl("export.html"))}}function fix_tlds(a,b,c){delete g_tlds[a][c];if(typeof g_tlds[b]=="undefined")g_tlds[b]=[];g_tlds[b][c]=true}
function increment_local_accts_version(){g_local_accts_version++}function set_editfieldsopener(a){g_editfieldsopener=a}function close_editfieldsopener(){if(g_editfieldsopener){g_editfieldsopener.close();g_editfieldsopener=null}}function getcurrenturl(){if(g_ischrome)return g_currenturl;else if(g_issafari)return safari.application.activeBrowserWindow.activeTab.url;else if(g_isopera)return opera.extension.tabs.getFocused()?opera.extension.tabs.getFocused().url:""}
function getcurrenttabid(){return g_ischrome?g_currenttabid:g_issafari?gettabid(safari.application.activeBrowserWindow.activeTab):gettabid(opera.extension.tabs.getFocused())}
function getsinglefactortype(){var a="";if(have_nplastpass()&&typeof g_nplastpass.read_file=="function")a=lptrim(g_nplastpass.read_file("singlefactortype"));var b=lpGetPref("singlefactortype","");if(a!=b){if(!have_nplastpass()||typeof g_nplastpass.file_exists!="function"||!g_nplastpass.file_exists("singlefactortype"))a=b;setsinglefactortype(a)}return a}
function setsinglefactortype(a){have_nplastpass()&&typeof g_nplastpass.write_file=="function"&&g_nplastpass.write_file("singlefactortype",a);getBG().lpPutGblPref("singlefactortype",a);a!=""&&getBG().lpPutGblPref("openloginstart",1);getBG().lpWriteAllPrefs()}function get_method(){if(g_ischrome)return"cr";else if(g_issafari)return"sfjs";else if(g_isopera)return"op"}
function select_selectedtabid(){try{if(g_ischrome)g_selectedtabid!=-1&&chrome.tabs.update(g_selectedtabid,{selected:true});else if(g_issafari)g_selectedtab&&g_selectedtab.activate();else g_isopera&&tab.update({focused:true})}catch(a){}}
function addEmptyGroup(a){var b=issharedfolder(g_shares,a);if(checkreadonly(b)){var c=b==false?g_local_key:b.sharekey,d=a;if(b){if(!checkreadonly(b))return;d=a.substr(b.decsharename.length+1)}var e=createNewAcct();e.url="http://group";e.group=a;e.aid="0";a="ajax=1&extjs=1&name=&url="+LP.en(url2hex(e.url))+"&grouping="+LP.en(lpenc(d,c))+"&username=&password=&extra=&aid=0&openid_url=&isbookmark=0";a+=b==false?"":"&sharedfolderid="+en(b.id);lpMakeRequest(base_url+"show.php",a,lpSaveSiteResponse,null,
e)}}function hassites(){for(var a in g_sites)return true;for(a in g_securenotes)return true;return false}var g_basicauth_found=false,g_basicauth_url="",g_basicauth_realm="",g_basicauth_tabid=0;
function basicauth_found(a,b,c){if(a!=g_basicauth_found)(g_basicauth_found=a)&&get_selected_tab(null,function(d){if(lp_gettld_url(c)!=lp_gettld_url(d.url))g_basicauth_found=false;else{g_basicauth_tabid=gettabid(d);g_basicauth_url=punycode.URLToUnicode(d.url);g_basicauth_realm=b;handleFill(gettabid(d),{url:d.url,topurl:d.url,docid:0,force:false,docnum:0})}})}
function basicauth_save(a,b){if(lploggedin){var c=lp_gettld_url(g_basicauth_url);if(!hasNeverSave(g_basicauth_url,c)){var d=typeof g_tlds[c]!="undefined"?g_tlds[c]:[],e;for(e in d)if(check_ident_aid(e))if(typeof g_sites[e]!="undefined"){var f=g_sites[e];if(a==lpmdec_acct(f.username,true,f,g_shares)&&b==lpmdec_acct(f.password,true,f,g_shares))return}g_notification_type="save";data=[];data.username=a;data.password=b;data.realm=g_basicauth_realm;data.url=g_basicauth_url;data.tld=c;g_notification_data=
data;lpGetPref("showSaveSiteNotifications",0)!=0&&sendTS({cmd:"notification",type:"save"});if(lpGetPref("showSaveNotificationBar",1)!=0)if(lpCheckAddSite(data.username,data.password,c)){sendCS(g_basicauth_tabid,{cmd:"showaddnotification",text:gs("Should LastPass remember this password?"),notificationdata:LPJSON.stringify(data)});g_persistent_notifications[g_basicauth_tabid]={cmd:"showaddnotification",text:gs("Should LastPass remember this password?"),notificationdata:LPJSON.stringify(data)}}}}}
var toplevelcontextmenu=null,lastcontexturl=null,contextParents=[],contextMenuIdToId=[];function cmaction(a,b){var c=gettabid(b),d=contextMenuIdToId[a.menuItemId];if(a.parentMenuItemId==contextParents[0])handleFill(c,{url:b.url,topurl:b.url,docid:0,force:false,docnum:0,cmd:"autofillaid",aid:d});else if(a.parentMenuItemId==contextParents[1])copyusername(d);else a.parentMenuItemId==contextParents[2]&&copypassword(d)}function cmaction1(a){fillform(contextMenuIdToId[a.menuItemId])}
function cmaction2(a){editprofile(contextMenuIdToId[a.menuItemId])}function rebuildcontextonload(){get_selected_tab(null,function(a){rebuildcontext(a.url)})}
function rebuildcontext(a){if(!(typeof chrome=="undefined"||typeof chrome.contextMenus=="undefined"))if(!(is_guiless()||lpGetPref("hideContextMenus",0)==1))if(lastcontexturl!=a){lastcontexturl=a;if(contextParents.length){var b=contextParents.pop();chrome.contextMenus.remove(b,function(){lastcontexturl=null;rebuildcontext(a)})}else{contextMenuIdToId=[];if(lploggedin){contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("AutoFill"),contexts:["all"],parentId:toplevelcontextmenu});
contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Copy Username"),contexts:["all"],parentId:toplevelcontextmenu});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Copy Password"),contexts:["all"],parentId:toplevelcontextmenu});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Generate Password"),contexts:["all"],parentId:toplevelcontextmenu,onclick:opengenpw});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Recheck Page"),
contexts:["all"],parentId:toplevelcontextmenu,onclick:function(){recheckpage()}});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Fill Forms"),contexts:["all"],parentId:toplevelcontextmenu});b=lp_gettld_url(a);b=reorderOnURL(getsites(b),a,true,true);for(var c=0;c<b.length;c++)for(var d=0;d<=2;d++){var e=b[c].useusername;e=typeof e!="undefined"&&e.length?" ("+e+")":"";e=chrome.contextMenus.create({title:b[c].name+e,contexts:["all"],parentId:contextParents[d],onclick:cmaction});
contextMenuIdToId[e]=b[c].aid;contextParents[contextParents.length]=e}if(b.length==0)for(d=0;d<=2;d++)chrome.contextMenus.create({title:gs("No Matching Sites!"),contexts:["all"],parentId:contextParents[d]});for(d=0;d<g_formfills.length;d++)if(check_ident_ffid(g_formfills[d].ffid)){contextParents[contextParents.length]=chrome.contextMenus.create({title:g_formfills[d].decprofilename,contexts:["all"],parentId:contextParents[5]});e=chrome.contextMenus.create({title:gs("Fill Form"),contexts:["all"],parentId:contextParents[contextParents.length-
1],onclick:cmaction1});contextMenuIdToId[e]=g_formfills[d].ffid;e=chrome.contextMenus.create({title:gs("Edit Profile"),contexts:["all"],parentId:contextParents[contextParents.length-1],onclick:cmaction2});contextMenuIdToId[e]=g_formfills[d].ffid}contextParents[contextParents.length]=chrome.contextMenus.create({type:"separator",parentId:contextParents[5]});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Add Profile"),contexts:["all"],parentId:contextParents[5],onclick:addprofile});
contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Add Credit Card"),contexts:["all"],parentId:contextParents[5],onclick:addcreditcard});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Clear Forms"),contexts:["all"],parentId:contextParents[5],onclick:clearforms});contextParents[contextParents.length]=chrome.contextMenus.create({title:gs("Choose Profile and Credit Card"),contexts:["all"],parentId:contextParents[5],onclick:openchooseprofilecc})}}}}
function createContextMenus(){typeof chrome!="undefined"&&typeof chrome.contextMenus!="undefined"&&!is_guiless()&&chrome.contextMenus.removeAll(function(){if(lpGetPref("hideContextMenus",0)==0)toplevelcontextmenu=chrome.contextMenus.create({title:"LastPass",contexts:["all"],onclick:cm_handler},cm_callback)})}createContextMenus();
function cm_handler(a){console_log("******Context menu item is clicked****");console_log("menuItemId: "+a.menuItemId);console_log("parentMenuItemId: "+a.parentMenuItemId);console_log("mediaType: "+a.mediaType);console_log("linkUrl: "+a.linkUrl);console_log("srcUrl: "+a.srcUrl);console_log("pageUrl: "+a.pageUrl);console_log("frameUrl: "+a.frameUrl);console_log("selectionText: "+a.selectionText);console_log("editable  "+a.editable);lploggedin||open_login()}
function cm_callback(){console_log("Context menu callback function called")}function DeleteOldDynamicFiles(){var a=localStorage.getItem("ff.dat");if(a!=null){var b=a.indexOf("\n");if(b!=-1){a=a.substr(0,b);CompareLastPassVersions(ffver,a)>0&&localStorage.removeItem("ff.dat")}}}function geteventtargeturl(a){return g_isopera?a.message.topurl:a.target.url}function geteventtarget(a){return g_isopera?a.source:a.target}
function GetStringResource(a){if(have_nplastpass()&&typeof g_nplastpass.GetStringResource=="function")return g_nplastpass.GetStringResource("",a);return""}function GetImageResource(a){if(have_nplastpass()&&typeof g_nplastpass.GetImageResource=="function")return"data:image/png;base64,"+g_nplastpass.GetImageResource("",a);return""}function event_dispatch_message(a,b,c){if(g_issafari)geteventtarget(a).page.dispatchMessage(b,c);else if(g_isopera){c.messagetype=b;geteventtarget(a).postMessage(c)}}
function gettabidfromevent(a){if(g_isopera){for(var b=opera.extension.windows.getAll(),c=0;c<b.length;c++)for(var d=0;d<get_tabs_length(b[c]);d++)if(a.data.topurl==b[c].tabs[d].url)return gettabid(b[c].tabs[d]);return-1}else return gettabid(geteventtarget(a))}function LoadSpecialSites(){SpecialSites=[];var a=localStorage.getItem("sites.dat");if(a!=null&&a!=""){a=a.split("\n");for(var b=0;b<a.length;b++)if(a[b].indexOf(".")!=-1)SpecialSites[a[b]]=""}}
function copytoclipboard(a){(g_is_win||g_is_mac)&&have_nplastpass()&&typeof g_nplastpass.copy_to_clipboard=="function"?g_nplastpass.copy_to_clipboard(a):Clipboard.copy(a);if(can_clear_clipboard()){var b=lpGetPref("clearClipboardSecsVal",30);b>0&&setTimeout(function(){clearclipboardif(a)},b*1E3)}}function clearclipboardif(a){if((g_is_win||g_is_mac)&&have_nplastpass()&&typeof g_nplastpass.clear_clipboard_if=="function")g_nplastpass.clear_clipboard_if(a)}
function unlock_plug2web(){g_plug2web_last_initiated=lp_get_gmt_timestamp()}
if(typeof chrome!="undefined"){chrome.omnibox.onInputChanged.addListener(function(a,b){if(lploggedin){if(0!=a.length){var c=[],d=search_results(a,get_searchNotesPref());d.sort(lp_sort_case_insensitive_name);var e=0,f;for(f in d){var g=d[f],h="id";if(g.sn){g=of(g.name);h="sn"}else g=of(g.name)+" ("+of(getusernamefromacct(g))+")";c.push({content:gs("Launch")+" "+g+"     "+h+":"+get_record_id(d[f])+"",description:g});if(e++>7)break}b(c)}}else{0==a.length&&open_login();b([{content:"login",description:"Login to LastPass"}])}});
chrome.omnibox.onInputEntered.addListener(function(a){"login"==a&&open_login();if(/id:\d+$/.test(a)){a=a.split("id:");a=a[1];launchautologin(a)}else if(/id:app\d+$/.test(a)){a=a.split("id:");a=a[1];launch(a)}else if(/sn:\d+$/.test(a)){a=a.split("sn:");a=a[1];editAid(a)}else if(getBG().g_isadmin){console.log("You entered: "+a);openURL("https://rodan.lastpass.com/admintools/search.php?q="+encodeURIComponent(a)+"&xmarks=on")}})}
function contextMenuOnClick(a,b){console.log("item "+a.menuItemId+" was clicked");console.log("info: "+JSON.stringify(a));console.log("tab: "+JSON.stringify(b));lploggedin||open_login()}function can_copy_to_clipboard(){return(g_is_win||g_is_mac)&&have_nplastpass()&&typeof g_nplastpass.copy_to_clipboard=="function"?true:g_ischrome?true:false}function can_clear_clipboard(){return(g_is_win||g_is_mac)&&have_nplastpass()&&typeof g_nplastpass.clear_clipboard_if=="function"?true:false}
function is_guiless(){return typeof g_guiless!="undefined"&&g_guiless==1}function skiplogin(){return typeof g_nologin!="undefined"&&g_nologin==1}function isadmin(){return g_isadmin}function getbaseurl(){return base_url}function update_create_account_data(){}
function lpvt_store_data_and_setsinglefactortype(a){getBG().have_nplastpass()&&typeof getBG().g_nplastpass.lpvt_store_data=="function"&&getBG().g_nplastpass.lpvt_store_data(a,gs("Swipe finger"),gs("Swipe your finger on the fingerprint sensor"),gs("Cancel"),gs("Swipe current user's finger"))&&getBG().setsinglefactortype("vtapi")}function delete_file(){getBG().have_nplastpass()&&typeof getBG().g_nplastpass.delete_file=="function"&&getBG().g_nplastpass.delete_file("LPISLOC")}
function log(a){console_error(a)};
