/* Auto generated, hash = 4d2fpqldauk1kpi63g06hej96 */
/**
 * Hack to avoid dynamic concatenation of footer-scripts, the scripts was originallly
 * designed to only work in dynamic concat state due to interdependence of scripts on shared variables.
 * https://jira01.corp.linkedin.com:8443/browse/HUED-14097
 *
 * Extracting out all the shared variables b/w interdependent footer scripts and creates a new closure
 *
 * start of the dynamic concat fix closure
 */
(function(context) {
    context = context || {};
    var LI = context.LI;
    var globalNavAPI = window.globalNav || context.globalNav;
    var _namespaces = context._namespaces;
    var Injector = context.Injector;
    var Helpers = context.Helpers;
    var Promise = context.Promise;
    var Request = context.Request;
    var Delegate = context.Delegate;
    var CustomEvents = context.CustomEvents;
    var CookieManager = context.CookieManager;
    var WeightedQueue = context.WeightedQueue;
    var NodeStash = context.NodeStash;
    var NavMenu = context.NavMenu;
    var InboxNavAPI = context.InboxNavAPI;
    var SlidingNavView = context.SlidingNavView;
    var TourManager = context.TourManager;
    var AddConnectionsFactory = context.AddConnectionsFactory;
    var AddConnectionsDecorator = context.AddConnectionsDecorator;
    var PageShift = context.PageShift;
    var AutoHide = context.AutoHide;
    var AlertFactory = context.AlertFactory;
    var GlobalAlertManager = context.GlobalAlertManager;

var PageShift=function(){var c=Injector.resolve("Helpers",function(c){PageShift.instance={containers:[],shift:function(a){this._setOffset(a)},restore:function(){this._setOffset(null)},register:function(a){a&&(a.length||(a=[a]),Array.prototype.forEach.call(a,function(a){this.containers.push({node:a})}.bind(this)))},_getOffset:function(a){var b=a.offset;isNaN(b)&&(b=c.getComputedStyle(a.node,"margin-top"),b=parseInt(b,10)||0,a.offset=b);return b},_setOffset:function(a){var b=0;a&&(b=a.offsetHeight);
this.containers.forEach(function(a){a&&"style"in a.node&&(a.node.style.marginTop=this._getOffset(a)+b+"px")}.bind(this))}}});PageShift.instance||c();return PageShift.instance};
var WeightedQueue=function(a){this.queue=[];this.isDirty=!1;this.config=a||{};this.config.weight=this.config.weight||0;this.config.sort="function"===typeof this.config.sort?this.config.sort:this._sortByAscendingWeight};
WeightedQueue.prototype={getLength:function(){return this.queue.length},enqueue:function(a,b){this.queue.push({weight:isNaN(b)?this.config.weight:b,item:a});this.isDirty=!0},dequeue:function(){this._clean();return this.queue.length?this.queue.pop().item:void 0},peek:function(){this._clean();return this.queue.length?this.queue[this.queue.length-1].item:void 0},_sortByAscendingWeight:function(a,b){return a.weight-b.weight},_clean:function(){this.isDirty&&(this.queue=this.queue.sort(this.config.sort),
this.isDirty=!1)}};
var AutoHide=function(n){var k=n||3E3,c=0,l=0,f=null,d={},g,e,h,m;h=Date.now||function(){return+new Date};m=function(a){var b;if(!a||!a.autoHide)return null;b=a.autoHide;if(isNaN(b)||b)if(b=k,a=a.contents)a=a.textContent||a.innerText||"",b+=55*a.length;return b};e=function(){window.clearTimeout(f);f=null};g=function(){var a;e();d.currentAlert&&(a=m(d.currentAlert))&&(l=h(),a=Math.max(k,a-c),f=window.setTimeout(function(){d.removeFn()},a))};return{start:function(a,b){a&&(d.currentAlert=a);b&&(d.removeFn=
b);g()},resume:g,stop:e,pause:function(){c+=Math.max(h()-l,0);e()},clear:function(){c=0;e()},_getTimer:function(){return f},_getElapsedTime:function(){return c}}};
var AlertFactory={create:function(){var a=LIModules.imports("jSecure"),b;return function(c){var d=c.node||document.createElement("div"),e=c.message||"",g=c.type||"error",h=!!c.animate,f=!!c.dismissable,l=c.dismissMsg||"",k;"undefined"===typeof b&&a&&(k=LIModules.requires("LiX"),k=k.get("jsecure_injectAlert"),b="enabled"===k);d.innerHTML="";e=b?this._buildNodeSecure(a,g,e,l,f):this._buildNode(g,e,l,f);d.appendChild(e);h&&c.node&&this.animate(c);f&&!c.disableDismissHandler&&d.addEventListener("click",
function(a){a.target.classList.contains("dismiss")&&(a.preventDefault(),this.remove(d,h))}.bind(this));return d}}(),remove:function(a,b){b?this.animate({node:a,shouldRemove:!0,callback:function(){a.innerHTML=""}}):a.innerHTML=""},animate:function(a){if(!a.node)throw Error("you must provide a node");var b=a.node,c=a.callback,d=a.shouldRemove;b.length?Array.prototype.forEach.call(b,function(a){this._determineAnimation(a,c,d)}.bind(this)):this._determineAnimation(b,c,d)},_buildNode:function(a,b,c,d){var e=
document.createElement("div");e.className="alert "+a;e.setAttribute("role","alert");e.innerHTML=b;d&&(a=document.createElement("button"),a.className="dismiss",a.setAttribute("type","button"),a.setAttribute("id","dismiss-alert"),c&&(a.innerHTML=c),e.appendChild(a));return e},_buildNodeSecure:function(a,b,c,d,e){var g=document.createElement("div"),h={type:b,msg:c,dismissMsg:d},f={};b="";Object.keys(h).forEach(function(b){f[b]=new a.UnsafeString(h[b])});b='\x3cdiv class\x3d"alert {type}" role\x3d"alert"\x3e{msg}';
e&&(b+='\x3cbutton class\x3d"dismiss" type\x3d"button" id\x3d"dismiss-alert"\x3e',d&&(b+="{dismissMsg}"),b+="\x3c/button\x3e");a.setElementContent(g,b+"\x3c/div\x3e",f);return g.firstChild},_determineAnimation:function(a,b,c){a.firstChild&&a.firstChild.classList.add(c?"animate-out":"animate-in");"function"===typeof b&&b()}};
var NodeStash=function(){this.nodes={};this.uid=0};NodeStash.prototype={getUID:function(){return"NodeStash#uid:"+ ++this.uid},stash:function(a,b){var c;if(!a)return null;b=!b&&isNaN(b)?this.getUID():b;c=document.createElement("div");c.appendChild(a);this.nodes[b]=c;return{uid:b,node:a}},retrieve:function(a){return(a=this.nodes[a])&&a.firstChild},remove:function(a){var b=this.nodes[a];b&&b.remove&&b.remove();delete this.nodes[a]}};
var oDefine="function"===typeof define?define:void 0;define=void 0;
(function(k,s){"object"===typeof exports&&"undefined"!==typeof module?s(exports):"function"===typeof define&&define.amd?define(["exports"],s):(k="undefined"!==typeof globalThis?globalThis:k||self,s(k.ConsentCookieParser={}))})(this,function(k){function s(f,b){(null==b||b>f.length)&&(b=f.length);for(var a=0,c=Array(b);a<b;a++)c[a]=f[a];return c}function x(f,b){if(!(f instanceof b))throw new TypeError("Cannot call a class as a function");}function y(f,b){for(var a=0;a<b.length;a++){var c=b[a];c.enumerable=
c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(f,z(c.key),c)}}function A(f,b,a){return b&&y(f.prototype,b),a&&y(f,a),Object.defineProperty(f,"prototype",{writable:!1}),f}function p(f,b,a){return(b=z(b))in f?Object.defineProperty(f,b,{value:a,enumerable:!0,configurable:!0,writable:!0}):f[b]=a,f}function z(f){a:if("object"==typeof f&&f){var b=f[Symbol.toPrimitive];if(void 0!==b){f=b.call(f,"string");if("object"!=typeof f)break a;throw new TypeError("@@toPrimitive must return a primitive value.");
}f=String(f)}return"symbol"==typeof f?f:f+""}function B(f){if("string"!==typeof f)throw new TypeError("URNs must be of type string, but the parameter passed to extractEntityInfoFromUrn was of type "+typeof f+".");f=C.exec(f);var b,a;f&&(b=f[1].replace(L,""),a=f[2]);return{id:a,type:b}}function D(f){f=B(f);var b=f.id;f=f.type;var a={};if("("===b.charAt(0))for(var b=b.substring(1,b.length-1).split(M),c=0,e;e=b[c];++c)0===e.indexOf("urn")&&(b[c]=D(e));a[f]=b;return a}function E(f){return"undefined"===
typeof atob&&"undefined"!==typeof Buffer?Buffer.from(f,"base64").toString("binary"):atob(f)}var C=/urn:[^:]+:([a-z]\w*)(?::(.+))?/,L=/^fs_/,M=/(?![^(]*\)),/,N={checkForEntityId:function(f){var b=C.exec(f);return b?b[2]:f},extractEntityInfoFromUrn:B,urnToObject:D},n=function(f,b){var a=b.match(new RegExp("(?:^|; *)".concat(f,"\x3d([^;]*)")));return a&&1<a.length?a[1]:null},t={ADVERTISING:"ADVERTISING",ANALYTICS_AND_RESEARCH:"ANALYTICS_AND_RESEARCH",FUNCTIONAL:"FUNCTIONAL"},g={GUEST:"GUEST",MEMBER:"MEMBER",
ENTERPRISE_UNBOUND:"ENTERPRISE_UNBOUND"},q=p(p(p({},g.GUEST,"li_gc"),g.MEMBER,"li_mc"),g.ENTERPRISE_UNBOUND,"li_ec"),O=p(p(p({},g.GUEST,"mypreferences/g/guest-cookies"),g.MEMBER,"settings/member-cookies"),g.ENTERPRISE_UNBOUND,"mypreferences/e/enterprise-cookies"),F=Object.freeze(["dark","light"]),l=A(function b(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,
d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;x(this,b);a=a||{};this.consentAvailable=!1;this.issuedAt=c;this.userMode=e;this.optedInConsentMap={};for(var h in t)a[h]=a[h]||0,0!==a[h]&&(this.consentAvailable=!0),this.optedInConsentMap[h]=1===a[h]||0===a[h]&&1===d}),H=function(){var b=[t.ADVERTISING,t.ANALYTICS_AND_RESEARCH,t.FUNCTIONAL],a=[0,1,2,0],c=function(c){for(var e={},d=0;d<b.length;d++)e[b[d]]=a[c>>2*d&3];return e},e=function(b){var c=0;0<=b&&3>=b&&(c=a[b]);return c},d=function(a){try{var b=
N.urnToObject(a);if(b&&b.enterpriseProfile&&2<=b.enterpriseProfile.length&&b.enterpriseProfile[0].enterpriseAccount)return{enterpriseAccountId:parseInt(b.enterpriseProfile[0].enterpriseAccount,10),enterpriseProfileId:parseInt(b.enterpriseProfile[1],10)}}catch(c){}return null};return{parseConsentBody:function(a,b){var d=a.match(/^(\d+);(\d+);(\d+);((?:.|\s)+)/);if(!d)return{error:"Invalid consent body encoding",consent:new l};var g=c(parseInt(d[1],10)),k=new Date(1E3*parseInt(d[2],10)),d=e(parseInt(d[3],
10));return{error:null,consent:new l(g,k,b,d)}},parseConsentBodyEnterpriseUnbound:function(a,b,k){b=d(b);if(!b)return{error:"Invalid enterprise profile urn provided",consent:new l};var n=b.enterpriseAccountId,q=b.enterpriseProfileId;a=a.match(/^((?:\d+,\d+,\d+,\d+,\d+)(?:\|(?:\d+,\d+,\d+,\d+,\d+))*);(\d+);(\d+);(?:(?:.|\s)+)$/);if(!a)return{error:"Invalid consent body encoding",consent:new l};b=a[1].split("|").map(function(a){return a.split(",").map(function(a){return parseInt(a,10)})}).filter(function(a){var b,
c;c=Array.isArray(a)?a:void 0;if(!c)a:{var d=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=d){var e,h,g,m=[],l=!0,G=!1;try{for(h=(d=d.call(a)).next;!(l=(b=h.call(d)).done)&&(m.push(b.value),4!==m.length);l=!0);}catch(t){G=!0,e=t}finally{try{if(!l&&null!=d.return&&(g=d.return(),Object(g)!==g)){c=void 0;break a}}finally{if(G)throw e;}}c=m}else c=void 0}(b=c)||(a?"string"==typeof a?b=s(a,4):(e={}.toString.call(a).slice(8,-1),b=("Object"===e&&a.constructor&&(e=
a.constructor.name),"Map"===e||"Set"===e?Array.from(a):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?s(a,4):void 0)):b=void 0);if(!(a=b))throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");b=a[2];e=a[3];return a[1]===n&&b===q&&e===k})[0];if(!b)return{error:null,consent:new l};b=c(b[0]);var m=new Date(1E3*parseInt(a[2],10));a=e(parseInt(a[3],10));return{error:null,consent:new l(b,
m,g.ENTERPRISE_UNBOUND,a)}}}}(),P=/^(\d+);((?:.|\s)+)/,I=function(b){var a={},c;for(c in t)a[c]=b;return{error:null,consent:new l(a,null,null,b)}},J=function(){var b=document.domain.match(/^(?:|.*\.)([^\.]+\.[^\.]+)$/);return b?b[1]:"linkedin-ei.com"},v=function(b,a,c,e){b&&1<b.length&&'"'==b.charAt(0)&&'"'==b.charAt(b.length-1)&&(b=b.substring(1,b.length-1));var d=null;try{d=E(b).match(P)}catch(h){}if(!d)return{error:"Invalid consent encoding",consent:new l};b=parseInt(d[1],10);d=d[2];switch(b){case 1:return a===
g.ENTERPRISE_UNBOUND?H.parseConsentBodyEnterpriseUnbound(d,c,e):H.parseConsentBody(d,a);default:return{error:"Invalid encoded consent version ".concat(b),consent:new l}}},K=function(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,a=1<arguments.length?arguments[1]:void 0,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},e=c.enterpriseProfileUrn,c=c.enterpriseAppInstanceId;if("string"!==typeof a){if("undefined"===typeof document)return{error:"cookie string must be provided in SSR mode",
consent:new l};a=document.cookie}if(e&&!c||!e&&c)return{error:"enterpriseProfileUrn and enterpriseAppInstanceId must both be provided if at least one is provided",consent:new l};if(!(b!==g.ENTERPRISE_UNBOUND||e&&c))return{error:"enterpriseProfileUrn and enterpriseAppInstanceId are required for unbound userMode",consent:new l};if(!b){if((b=n(q[g.ENTERPRISE_UNBOUND],a))&&e&&c&&(b=v(b,g.ENTERPRISE_UNBOUND,e,c),b.consent.userMode===g.ENTERPRISE_UNBOUND||b.error))return b;b=n("liap",a)?n(q[g.MEMBER],a)?
g.MEMBER:g.GUEST:n(q[g.GUEST],a)?g.GUEST:g.MEMBER}var d=n(q[b],a),e=d?v(d,b,e,c):n(q[g.GUEST],a)||n(q[g.MEMBER],a)||n(q[g.ENTERPRISE_UNBOUND],a)?I(2):I(1);return e},w={SHARE_DATA_WITH_TRUSTED_PARTNERS:"SHARE_DATA_WITH_TRUSTED_PARTNERS"},r=A(function a(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=c.guestPreferencesData,e=void 0===e?null:e,d=c.issuedAt,d=void 0===d?null:d,c=c.defaultConsent,c=void 0===c?0:c;x(this,a);e=e||{};this.issuedAt=d;this.guestPreferencesMap={};for(var h in w)"number"!==
typeof e[h]&&(e[h]=c),this.guestPreferencesMap[h]=1===e[h]}),Q=function(){var a=[w.SHARE_DATA_WITH_TRUSTED_PARTNERS],c=[0,1];return{parseGuestPreferencesBody:function(e){var d=e.match(/^(\d+);(\d+)/);if(!d)return{error:"Invalid guest preferences body encoding",guestPreferences:new r};e=d[1];a:{for(var d=d[2],h={},g=0;g<a.length;g++){var k=a[g],l=d[g];if(void 0===c[l]){d=void 0;break a}h[k]=c[l]}d=h}return d?{error:null,guestPreferences:new r({guestPreferencesData:d,issuedAt:new Date(1E3*e)})}:{error:"Invalid guest preferences consent provided",
guestPreferences:new r}}}}(),R=/^(\d+);((?:.|\d)+)/,S=function(a){a&&1<a.length&&'"'==a.charAt(0)&&'"'==a.charAt(a.length-1)&&(a=a.substring(1,a.length-1));var c=null;try{c=E(a).match(R)}catch(e){}if(!c)return{error:"Invalid guest preferences encoding",guestPreferences:new r};a=parseInt(c[1],10);c=c[2];switch(a){case 1:return Q.parseGuestPreferencesBody(c);default:return{error:"Invalid encoded guest preferences version ".concat(a),guestPreferences:new r}}};k.GUEST_PREFERENCES=w;k.NON_ESSENTIAL_CATEGORIES=
t;k.SETTINGS_COLOR_SCHEME=F;k.USER_MODE=g;k.getBannerData=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=2<arguments.length?arguments[2]:void 0,d=K(a,document.cookie,c),h=d.consent,a=a||h.userMode||g.GUEST,d=!d.error&&!h.consentAvailable,h=e,e=O[a],k=c.enterpriseProfileHash,c=c.enterpriseAppInstanceId,l=new URLSearchParams;a===g.ENTERPRISE_UNBOUND&&(k&&l.append("p",k),c&&l.append("iid",c));"string"===typeof h&&
(h=h.toLowerCase(),F.includes(h)&&l.append("li_theme",h));c=Array.from(l).length?"?"+l.toString():"";c="https://www.".concat(J(),"/").concat(e).concat(c);return{showBanner:d,userMode:a,managePreferenceUrl:c}};k.getCookieConsent=K;k.getPreferenceStatuses=function(a){"string"!==typeof a&&(a=document.cookie);return(a=n("li_gp",a))?S(a):{error:null,guestPreferences:new r({defaultConsent:1})}};k.parseEncodedConsent=v;k.updateCookieConsent=function(a,c){var e=a.optedInConsentMap,d=a.updateSettings,h=a.userMode,
l=a.xLiTrackPayload,k=a.enterpriseContext||{},s=k.enterpriseProfileHash,p=k.enterpriseAppInstanceId;c=c||function(a,c){};k=n(q[g.ENTERPRISE_UNBOUND],document.cookie);e||c("optedInConsentMap is a required option",null);var m=new XMLHttpRequest,r=new URLSearchParams;k&&p&&r.append("appInstanceId",p);p=Array.from(r).length?"?"+r.toString():"";m.open("POST","https://www.".concat(J(),"/cookie-consent/").concat(p));m.setRequestHeader("Content-Type","application/json");l&&m.setRequestHeader("X-LI-Track",
l);k&&s&&m.setRequestHeader("x-li-identity",s);m.withCredentials=!0;m.onload=function(){200!==m.status?c("Request failed with status ".concat(m.status),null):c(null,m)};m.onerror=function(){c("Request failed with an error",m)};var d={UPDATE_SETTINGS:d,USER_MODE:h,CATEGORIES:{}},u;for(u in t)h=void 0,!0===e[u]?h=1:!1===e[u]&&(h=2),d.CATEGORIES[u]=h;m.send(JSON.stringify(d))};Object.defineProperty(k,"__esModule",{value:!0})});
define=oDefine;
var GlobalAlertManager;
(function(){var e=LIModules.imports("GlobalAlertManager");if(e)GlobalAlertManager=function(){this.injectAlert=e.injectAlert;this.removeAlert=e.removeAlert;this.events={on:function(){window.console.error("Invalid call to `globalNav.alertManager.events.on` in a non-consumer2 context")}}};else{var d={MAINTENANCE:100,UNKNOWN:200,EMAIL:300,SUBS:400,POLICY:500,APP:600,ACTION:700},k=/<(span|a|button)[^>]+class\s*=\s*['\"]?[^'\"]*?\bdismiss\b/i,g=/<a/i,h={"global-maintenance-notice":d.MAINTENANCE,"notice-cookie-policy":d.POLICY,
"notice-cookie-usage":d.POLICY,"notice-cookie-consent":d.POLICY,"notice-privacy":d.POLICY+1,"global-error":d.APP,"notice-review-email":d.EMAIL,"notice-subscription":d.SUBS,"ie-deprecation-banner":d.MAINTENANCE-1};GlobalAlertManager=Injector.resolve("WeightedQueue, Helpers, AutoHide, PageShift, AlertFactory, NodeStash, CustomEvents",function(a,c,b,l,d,f,m,e){this.queue=new a;this.nodeStash=new f;this.helpers=c;this.autoHide=b();this.pageShift=l;this.alertFactory=d;this._attachEvents();this.events=
m;this._pauseEvents=!1;window.addEventListener("globalNav:ready",this._enqueueExistingAlerts.bind(this))});var b=GlobalAlertManager.prototype;b.queueUID=0;b.alertContainers={};b.hasInjectedAlertQueueContainer=!1;b.currentAlert=null;b.enqueue=function(a,c,b){a&&(a=this._normalizeAlert(a,c))&&a.meta&&(a.meta.origin=b,this.currentAlert&&this.currentAlert.meta.weight===a.meta.weight&&this._dequeue(),this.queue.enqueue(a,a.meta.weight),this.showTopAlert())};b.dequeue=function(a){(a=this.currentAlert)&&
this.currentAlert.isDismissable&&this._dequeue();return a};b.showTopAlert=function(){var a=this._getAlertContainer("global-alert-queue"),c=this._stashCurrentAlert(),b;this.queue.getLength()?(this.currentAlert=this.queue.peek(),c&&c.meta.uid===this.currentAlert.meta.uid?a.appendChild(this.currentAlert.contents):(this._triggerEvent("willShowAlert",this.currentAlert),this.autoHide.clear(),b=this.currentAlert.contents,a.appendChild(b),setTimeout(function(){var c=this.currentAlert.autoHide;this.alertFactory.animate({node:a,
callback:function(){c||window.setTimeout(function(){this.pageShift.shift(b)}.bind(this),600);this.autoHide.start(this.currentAlert,this._removeAlert.bind(this))}.bind(this)});c&&this.pageShift.shift(null)}.bind(this),0),this._triggerEvent("didShowAlert",this.currentAlert))):(this.autoHide.clear(),this.alertFactory.remove(a,!0),this.pageShift.restore())};b.injectAlert=function(a){var c={},b;this._triggerEvent("willAddAlert");if(a.node)return this.alertFactory.create(a),this._triggerEvent("didAddAlert"),
a.node;this._stashCurrentAlert();a.weight=this._normalizeWeight(a.weight);a.disableDismissHandler=!0;a.animate=!0;c.meta={weight:a.weight,uid:++this.queueUID};c.isDismissable=!!a.dismissable;c.autoHide="undefined"!==typeof a.autoHide?a.autoHide:c.isDismissable&&!g.test(a.message||"");b=this.alertFactory.create(a);c.contents=b.firstChild;this.nodeStash.stash(c.contents,c.meta.uid);this.enqueue(c,a.weight,a.origin||"injectAlert");this._triggerEvent("didAddAlert",this.currentAlert);return this._getAlertContainer("global-alert-queue")};
b.removeAlert=function(a,c){c=c||!0;this._triggerEvent("willRemoveAlert",this.currentAlert);a&&this.alertFactory.remove(a,c);this._removeAlert()};b._attachEvents=function(){var a=this._getAlertContainer("global-alert-queue");this.userEvents={click:this._handleClick,focus:this.autoHide.pause,mouseenter:this.autoHide.pause,mouseleave:this.autoHide.resume,blur:this.autoHide.resume};Object.keys(this.userEvents).forEach(function(c){a.addEventListener(c,this.userEvents[c].bind(this),!1)}.bind(this))};b.removeEvents=
function(){var a=this._getAlertContainer("global-alert-queue");Object.keys(this.userEvents).forEach(function(c){a.removeEventListener(c,this.userEvents[c],!1)})};b._removeAlert=function(){var a=this.dequeue();this.showTopAlert();this._triggerEvent("didRemoveAlert",a)};b._enqueueExistingAlerts=function(){var a=this.currentAlert;this._pauseEvents=!0;Object.keys(h).forEach(function(a){var b=document.getElementById(a);b&&this.enqueue(b.children[0],this._normalizeWeight(h[a]),a)}.bind(this));this._pauseEvents=
!1;!this.currentAlert||a&&a.meta.uid===this.currentAlert.meta.uid||(this._triggerEvent("willShowAlert",this.currentAlert),this._triggerEvent("didShowAlert",this.currentAlert))};b._stashCurrentAlert=function(){this.currentAlert&&this.nodeStash.stash(this.currentAlert.contents,this.currentAlert.meta.uid);return this.currentAlert};b._injectAlertQueueContainer=function(){var a=this._getHomeForQueue(),c=this._createQueueNode();a.attach(c);this.hasInjectedAlertQueueContainer=!0};b._getHomeForQueue=function(){var a=
document.getElementById("layout-header"),c=document.getElementById("application-body")||document.body,b=function(){};a?(this.pageShift.register(document.getElementById("text-ad-container")||document.getElementById("layout-main")),c=a,b=function(a){a.className="layout-wrapper";c.appendChild(a)}):c&&(b=function(a){c.insertBefore(a,c.firstChild)});return{attach:b}};b._createQueueNode=function(){var a=document.createElement("div");a.id="global-alert-queue";return this.alertContainers["global-alert-queue"]=
a};b._getAlertContainer=function(a){var c=this.alertContainers;this.hasInjectedAlertQueueContainer||this._injectAlertQueueContainer();c[a]=c[a]||document.getElementById(a);return c[a]};b._dequeue=function(){this.nodeStash.remove(this.currentAlert.contents);this.queue.dequeue();this.showTopAlert()};b._normalizeAlert=function(a,c){function b(a){d.meta={weight:f._normalizeWeight(c),uid:++f.queueUID};"undefined"===typeof d.contents&&(e.innerHTML=a,d.contents=e.firstChild);d.isDismissable=k.test(a);d.autoHide=
d.isDismissable&&!g.test(a)}var d={},e=document.createElement("div"),f=this;this.helpers.isElement(a)?(d.contents=a,e.innerHTML="",b(e.appendChild(a).innerHTML)):this.helpers.isObject(a)?d=a:"string"===typeof a&&b(a);return d};b._normalizeWeight=function(a){return"undefined"===typeof a?d.ACTION:d[a]||a||0};b._handleClick=function(a){(a.target.classList.contains("dismiss")||a.target.classList.contains("alert-action-dismiss"))&&this.removeAlert()};b._triggerEvent=function(){this._pauseEvents||this.events.trigger.apply(this.events,
arguments)}}})();
(function(window) {

  var getCookie = function(name) {
    var v = document.cookie.match('(?:^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
    return v ? v[1] : undefined;
  };

  var initialized = false; // keep track of whether or not we've initialized

  var alertManager;

  /**
   * Resources for handling the cookie usage banner
   * This is an imported login from static-common/scripts/apps/chrome/euCookiePolicy.js
   * @type {string}
   */
  var cookieUsageAlert = 'notice-cookie-usage';
  var MAX_COUNT = 3;
  var KEY = 'LIcookiePolicyDisplays';
  var euCookiePolicyNode = document.getElementById(cookieUsageAlert);

  /**
   * Resources for handling the cookie consent banner
   */
  var ConsentCookieParser = (window && window.ConsentCookieParser) || {};
  var bannerMetaData = (ConsentCookieParser.getBannerData instanceof Function) && ConsentCookieParser.getBannerData();
  var cookieConsentAlert = 'notice-cookie-consent';
  var cookieConsentNode = document.getElementById(cookieConsentAlert);
  var nonEssentialCategories = ConsentCookieParser.NON_ESSENTIAL_CATEGORIES || {};

  function updateCookieConsent(consent, cb) {
    var optedInConsentMap = {};
    Object.keys(nonEssentialCategories).forEach(key => {
      optedInConsentMap[key] = consent || false;
    });
    var payload = {
      'optedInConsentMap' : optedInConsentMap
    };

    if(ConsentCookieParser.updateCookieConsent instanceof Function) {
      ConsentCookieParser.updateCookieConsent(payload, cb);
    }
  }

  /**
   * Getter/Setter for 'notice-cookie-usage' impression **ONLY**
   * @param value
   */
  function setImpressionCount(value) {
    // try setting the count via localStorage
    try {
      window.localStorage.setItem(KEY, value);
    }
        // otherwise set it via the cookie
    catch (e) {
      document.cookie = KEY + '=' + value + ';path=/';
    }
  }

  function getImpressionCount() {
    var value;
    // try getting the count from localStorage
    try {
      value = window.localStorage.getItem(KEY);
    }
        // otherwise read it from the cookie
    catch (e) {
      value = getCookie(KEY) || 0;
    }
    // value is a string, so cast to an int
    return parseInt(value, 10) || 0;
  }

  // defines a mapping for node (id based) implementation bindings
  var alertBindingsMap = {
    // PRIVACY POLICY
    'notice-privacy': function(node) {
      var ACTION_URL = node.getAttribute('data-url'); // the URL to pass to recordAction

      var alertId = node.id;

      (function bindImpressionAction() {
        alertManager.onView(alertId, function() {
          recordAction(ACTION_URL);
        });
      }());

      (function bindInteractiveActions() {
        if (node.getAttribute('data-record-on-interact') !== 'true') {
          return;
        }

        // when the user clicks on any link or button within the alert...
        [].forEach.call(node.querySelectorAll('a, button'), function(iNode) {
          iNode.addEventListener('click', function() {
            // record the action
            recordAction(ACTION_URL, 'closed=true');
          });
        });
      }());
    },

    // COOKIE POLICY
    'notice-cookie-policy': function(node) {
      var ACTION_URL = node.getAttribute('data-url'); // the URL to pass to recordAction

      var alertId = node.id;

      // bind the impression based actions
      (function bindImpressionAction() {
        alertManager.onView(alertId, function() {
          recordAction(ACTION_URL, 'viewed=1');
        });
      }());

      // bind a handler to nodes that will "accept" this notice
      (function bindAcceptAction() {
        [].forEach.call(node.querySelectorAll('a, .dismiss'), function(accept) {
          accept.addEventListener('click', function() {
            recordAction(ACTION_URL, 'accepted=1');
          });
        });
      }());
    },

    // COOKIE USAGE
    'notice-cookie-usage': function(node) {
      var alertId = node.id;

      // bind the impression based actions
      (function bindImpressionAction() {
        alertManager.onView(alertId, function() {
          //update the local storage
          setImpressionCount(getImpressionCount() + 1);
        });
      }());

      // bind a handler to nodes that will "accept" this notice
      (function bindAcceptAction() {
        [].forEach.call(node.querySelectorAll('.dismiss'), function(accept) {
          accept.addEventListener('click', function() {
            //update local storage
            setImpressionCount(MAX_COUNT);
          });
        });
      }());
    },
    // Cookie Consent
    'notice-cookie-consent': function(node) {
     [].forEach.call(node.querySelectorAll('button'), function(iNode) {
       iNode.addEventListener('click', function(e) {
         var actionButton = e && e.target;
         var actionType = (actionButton instanceof Element) && actionButton.getAttribute('data-action-type');
         var actionUrl = (actionButton instanceof Element) && actionButton.getAttribute('data-url');
         actionUrl = jSecure && actionUrl && jSecure.sanitizeUrl && jSecure.sanitizeUrl(actionUrl);

         switch(actionType) {
           case "LINK":
             // call update consent
             updateCookieConsent(false, function() {
               window.location.assign(actionUrl || bannerMetaData.managePreferenceUrl)
             });
             break;
           case "ACCEPT":
             //call update consent
             updateCookieConsent(true, function() {
               //fire and forget
             });
             break;
           case "DENY":
             updateCookieConsent(false, function() {
               //fire and forget
             });
             break;
           default:
             break;
         }
       });
     });
    },

    'notice-subscription': function(node) {
      var ACTION_URL = node.getAttribute('data-url'); // the URL to pass to recordAction

      var alertId = node.id;

      (function bindInteractiveActions() {
        // when the user clicks on any link or button within the alert...
        [].forEach.call(node.querySelectorAll('a, button'), function(iNode) {
          iNode.addEventListener('click', function() {
            // record the action
            recordAction(ACTION_URL);
          });
        });
      }());
    }
  };


  /**
   * create the `alertManager` interface for later use
   * this has to be done during `init` phase so we can determine our environment
   */
  function createAlertManager() {
    var _alertManager = window.globalNav && window.globalNav.alertManager;

    // if globalNav.alertManager is present...
    if (_alertManager) {
      alertManager = {
        onView: function(origin, callback) {
          _alertManager.onWillShowAlert(function(alert) {
            // if the shown alert matches the alert we've bound this event to...
            if (alert && alert.meta && alert.meta.origin === origin) {
              // invoke it
              callback();
            }
          });
        }
      };
    }
    // otherwise...
    else {
      alertManager = {
        onView: function(origin, callback) {
          // assume views happen immediately (no queue), so just invoke it
          callback();
        }
      };
    }
  }

  /**
   * handles recording actions to a given URL
   * @param  {String} url The url to record to
   * @param  {String} postData The data to record
   */
  function recordAction(url, postData) {
    try {
      var request = new XMLHttpRequest();
      request.open('POST', url, true);
      request.setRequestHeader('X-IsAJAXForm', '1');
      request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      request.send(postData);
    } catch (e) {}
  }

  /**
   * Initialize the alert handlers
   */
  function init() {
    // if we've already initialized, just exit
    if (initialized) {
      return;
    }

    // depending on whether or not globalNav's alertManager exists, the behavior changes...
    createAlertManager();

    // for each alert binding...
    Object.keys(alertBindingsMap).forEach(function(alertId) {
      // if the node exists...
      var node = document.getElementById(alertId);
      if (node) {
        // call it's mapped binding
        alertBindingsMap[alertId](node);
      }
    });

    initialized = true; // yes
  }

  /**
   * Remove the 'notice-cookie-usage` alert in case it's impression count is more
   * than the MAX_COUNT or cookie consent banner is active
   */
  if (euCookiePolicyNode instanceof Element) {
    // and if the current impression count is less than the max count...
    var li_gc = getCookie("li_gc");
    var li_mc = getCookie("li_mc");
    if ((getImpressionCount() >= MAX_COUNT) || li_gc || li_mc) {
      euCookiePolicyNode.parentNode.removeChild(euCookiePolicyNode);
    }
  }
  /**
   * Remove the `notice-cookie-consent` alert in case cookie parser says so
   */
  if(cookieConsentNode instanceof Element) {
    if(!bannerMetaData.showBanner) {
      cookieConsentNode.parentNode.removeChild(cookieConsentNode);
    }
  }

  // if it's a testing environment, expose some methods
  if (window.LI_JS_TEST) {
    window.alertHandler = {
      recordAction: recordAction,
      createAlertManager: createAlertManager,
      alertBindingsMap: alertBindingsMap,
      getAlertManager: function() {
        return alertManager;
      },
      init: function() {
        initialized = false;
        init();
      }
    };
  }
  // othwerise, setup for init
  else {
    // we need to initialize when things are ready, but what things?
    // if globalNav is on the page, we want to initialize as soon as globalNav:ready fires
    // this will allow us to inject bindings just before globalNav.alertManager takes over
    window.addEventListener('globalNav:ready', init);
    // otherwise, we'll initialize when the page is ready
    window.addEventListener('load', init);
  }
}(window));

/**
 * Hack to avoid dynamic concatenation of footer-scripts, the scripts was originallly
 * designed to only work in dynamic concat state due to interdependence of scripts on shared variables.
 * https://jira01.corp.linkedin.com:8443/browse/HUED-14097
 *
 * Extracting out all the shared variables b/w interdependent footer scripts and updating the LIContext with the
 * new state.
 *
 * end of the dynamic concat fix closure
 */
var LIContext = {};
LIContext.LI = LI;
LIContext.globalNav = window.globalNav || {};
LIContext.Injector = Injector;
LIContext._namespaces = _namespaces;
LIContext.Helpers = Helpers;
LIContext.Promise = Promise;
LIContext.Request = Request;
LIContext.Delegate = Delegate;
LIContext.CustomEvents = CustomEvents;
LIContext.CookieManager = CookieManager;
try{LIContext.NavMenu = NavMenu;} catch(e) {LIContext.NavMenu=undefined;}
try{LIContext.WeightedQueue = WeightedQueue;} catch(e) {LIContext.WeightedQueue=undefined;}
try{LIContext.NodeStash = NodeStash;} catch(e) {LIContext.NodeStash=undefined;}
try{LIContext.InboxNavAPI = InboxNavAPI;} catch(e) {LIContext.InboxNavAPI=undefined;}
try{LIContext.SlidingNavView = SlidingNavView;} catch(e) {LIContext.SlidingNavView=undefined;}
try{LIContext.TourManager = TourManager;} catch(e) {LIContext.TourManager=undefined;}
try{LIContext.AddConnectionsFactory = AddConnectionsFactory;} catch(e) {LIContext.AddConnectionsFactory=undefined;}
try{LIContext.AddConnectionsDecorator = AddConnectionsDecorator;} catch(e) {LIContext.AddConnectionsDecorator=undefined;}
try{LIContext.PageShift = PageShift;} catch(e) {LIContext.PageShift=undefined;}
try{LIContext.AutoHide = AutoHide;} catch(e) {LIContext.AutoHide=undefined;}
try{LIContext.AlertFactory = AlertFactory;} catch(e) {LIContext.AlertFactory=undefined;}
try{LIContext.GlobalAlertManager = GlobalAlertManager;} catch(e) {LIContext.GlobalAlertManager=undefined;}
window.LIContext = LIContext;
})(window.LIContext);
