/* 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(e,g){"object"===typeof exports&&"undefined"!==typeof module?g(exports):"function"===typeof define&&define.amd?define(["exports"],g):(e=e||self,g(e.ConsentCookieParser={}))})(this,function(e){function g(c,a,b){a in c?Object.defineProperty(c,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):c[a]=b;return c}var p,h={ADVERTISING:"ADVERTISING",ANALYTICS_AND_RESEARCH:"ANALYTICS_AND_RESEARCH",FUNCTIONAL:"FUNCTIONAL"},c={GUEST:"GUEST",MEMBER:"MEMBER"},m=(p={},g(p,c.GUEST,"li_gc"),g(p,c.MEMBER,
"li_mc"),p),n=function a(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,q=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");b=b||{};this.consentAvailable=!1;this.issuedAt=d;this.userMode=c;this.optedInConsentMap={};for(var f in h)b[f]=b[f]||0,0!==b[f]&&(this.consentAvailable=
!0),this.optedInConsentMap[f]=1===b[f]||0===b[f]&&1===q},v=function(){var a=[h.ADVERTISING,h.ANALYTICS_AND_RESEARCH,h.FUNCTIONAL],b=[0,1,2,0],d=/^(\d+);(\d+);(\d+);((?:.|\s)+)/;return{parseConsentBody:function(c,q){var f=c.match(d);if(!f)return{error:"Invalid consent body encoding",consent:new n};for(var e=parseInt(f[1],10),h={},k=0;k<a.length;k++)h[a[k]]=b[e>>2*k&3];e=new Date(1E3*parseInt(f[2],10));f=parseInt(f[3],10);k=0;0<=f&&3>=f&&(k=b[f]);return{error:null,consent:new n(h,e,q,k)}}}}(),w=/^(\d+);((?:.|\s)+)/,
l=function(a,b){var d=b.match(new RegExp("(?:^|; *)".concat(a,"\x3d([^;]*)")));return d&&1<d.length?d[1]:null},r=function(a){var b={},d;for(d in h)b[d]=a;return{error:null,consent:new n(b,null,null,a)}},s=function(){var a=document.domain.match(/^(?:|.*\.)([^\.]+\.[^\.]+)$/);return a?a[1]:"linkedin-ei.com"},t=function(a,b){a&&1<a.length&&'"'==a.charAt(0)&&'"'==a.charAt(a.length-1)&&(a=a.substring(1,a.length-1));var d=null;try{var c;var e=a;c="undefined"===typeof atob&&"undefined"!==typeof Buffer?Buffer.from(e,
"base64").toString("binary"):atob(e);d=c.match(w)}catch(f){}if(!d)return{error:"Invalid consent encoding",consent:new n};c=parseInt(d[1],10);d=d[2];switch(c){case 1:return v.parseConsentBody(d,b);default:return{error:"Invalid encoded consent version ".concat(c),consent:new n}}},u=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document.cookie;a||(a=l("liap",b)?l(m[c.MEMBER],b)?c.MEMBER:c.GUEST:l(m[c.GUEST],b)?c.GUEST:c.MEMBER);var d=a,e=l(m[d],b),b=e?t(e,d):l(m[c.GUEST],b)||
l(m[c.MEMBER],b)?r(2):r(1);return b};e.NON_ESSENTIAL_CATEGORIES=h;e.USER_MODE=c;e.getBannerData=function(a){var b=u(a),d=b.consent;a=a||d.userMode||c.GUEST;b=!b.error&&!d.consentAvailable;d=a===c.MEMBER?"settings/member-cookies":"mypreferences/g/guest-cookies";d="https://www.".concat(s(),"/").concat(d);return{showBanner:b,userMode:a,managePreferenceUrl:d}};e.getCookieConsent=u;e.parseEncodedConsent=t;e.updateCookieConsent=function(a,b){var d=a.optedInConsentMap,c=a.updateSettings,e=a.userMode;b=b||
function(a,b){};a.optedInConsentMap||b("optedInConsentMap is a required option",null);var f=new XMLHttpRequest;f.open("POST","https://www.".concat(s(),"/cookie-consent/"));f.setRequestHeader("Content-Type","application/json");f.withCredentials=!0;f.onload=function(){200!==f.status?b("Request failed with status ".concat(f.status),null):b(null,f)};f.onerror=function(){b("Request failed with an error",f)};var c={UPDATE_SETTINGS:c,USER_MODE:e,CATEGORIES:{}},g;for(g in h)e=void 0,!0===d[g]?e=1:!1===d[g]&&
(e=2),c.CATEGORIES[g]=e;f.send(JSON.stringify(c))};Object.defineProperty(e,"__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);
