window.track=window.track||{};(function(f,g){var b,c;c=document.getElementsByTagName("head")[0];f.load=b={};b.script=function(b,d){var a=document.createElement("script");a.src=b;a.async=!0;a.onreadystatechange=a.onload=function(){var b=0,e;if(!a.readyState||a.readyState in{loaded:1,complete:1})if(a.onload=a.onreadystatechange=null,c.removeChild(a),a=null,"function"===typeof d)d();else for(;e=d[b++];)e()};c.appendChild(a)}})(window.track,window);window.track=window.track||{};
(function(e,m){function n(){a.libUrl&&(e.load.script(a.libUrl,k),a.libUrl=null,delete a.libUrl)}function p(h){this.code=encodeURIComponent(h.code+"");this.message=encodeURIComponent(h.message);this.unique=h.unique;this.originTreeId=encodeURIComponent(a.originTreeId);this.appName=encodeURIComponent(a.appName);h=encodeURIComponent;var g,f,b;if(!a.pageKey)if(document.body.id&&0===document.body.id.indexOf("pagekey"))a.pageKey=document.body.id.substring(8);else for(g=document.getElementsByTagName("head")[0].getElementsByTagName("meta"),b=
g.length-1;0<=b;--b)if(f=g[b],"pageKey"===f.name){a.pageKey=f.content;break}this.pageKey=h(a.pageKey)}var a,k;if(a=function(h){var g,f,b,a,d;d={reportUrl:null,libUrl:null,originTreeId:null};f=document.getElementsByTagName("head")[0];a=f.getElementsByTagName("meta");for(g=a.length-1;0<=g;--g)if(b=a[g],h===b.name){d.libUrl=b.content;if(!d.libUrl)return;f.removeChild(b)}else if("lnkd-track-error"===b.name){d.reportUrl=b.content;if(!d.reportUrl)return;var c;a:{c=document.cookie&&document.cookie.split(";");
for(var e=0;e<c.length;e++){for(var l=c[e];" "===l.charAt(0);)l=l.substring(1);if(-1!==l.indexOf("JSESSIONID\x3d")){c=l.substring(11,l.length);'"'===c[0]&&'"'===c[c.length-1]&&(c=c.substring(1,c.length-1));break a}}c=""}c&&-1===d.reportUrl.indexOf("csrfToken")&&(0<d.reportUrl.indexOf("?")?d.reportUrl=d.reportUrl+"\x26csrfToken\x3d"+c:d.reportUrl=d.reportUrl+"?csrfToken\x3d"+c);f.removeChild(b)}else"treeID"===b.name?d.originTreeId=b.content:"appName"===b.name&&(d.appName=b.content);if(d.reportUrl)return d}(m.JSON?
"lnkd-track-lib":"lnkd-track-json-lib")){if(!e.xhr){if(!e.load||!a.libUrl)return;k=[]}e.errors={};e.errors.onMethod=function(a,g){return function(){try{a.apply(m,arguments)}catch(f){g.message=g.message||f.message,e.errors.push(g)}}};e.errors.onMethodName=function(a,g){var f=m,b,k,d,c;d=a.split(".");c=d[0];k=d.length;for(b=0;b<k-1;b++)c=d[b],f=f[c];"function"===typeof f[c]&&(f[c]=e.errors.onMethod(f[c],g))};e.errors.push=function(h){e.xhr?(k&&(k=null),e.xhr.post({url:a.reportUrl,data:new p(h)})):k.push(function(){e.errors.push(h)})};
m.addEventListener("load",n)}})(window.track,window);(function(a){a&&a.errors&&(a.errors.codes={FZ_CACHE_MISS:601,FZ_EMPTY_NODE:602,FZ_DUST_RENDER:603,FZ_DUST_CHUNK:604,FZ_DUST_MISSING_TL:605,FZ_RENDER:606,FZ_XHR_BAD_STATUS:607,FZ_XHR_BAD_CONTENT_TYPE:608,FZ_JSON_PARSE:609,CTRL_INIT:701,RUM_CDN_ID_ERROR:801,RUM_POP_ID_ERROR:802,RUM_POP_BEACONS_ERROR:803,HP_STREAM_SERVER_ERROR:900,HP_STREAM_JS_EXCEPTION:901})})(window.track);(function(a,c){a&&a.errors&&(a.errors.bootstrap=function(){if(c.fs&&a.errors)c.fs.on("error",function(b){var d;if(c.JSON){d={id:b.id};b.xhr&&(d.xhr=b.xhr);try{b.unique=c.JSON.stringify(d)}catch(e){}}a.errors.push(b)})},a.errors.bootstrap())})(window.track,window);/* Auto generated, hash = 3wyihos1uial5uf09hy9dq16h */
// Domain Public by Eric Wendelin http://eriwen.com/ (2008)
//                  Luke Smith http://lucassmith.name/ (2008)
//                  Loic Dachary <loic@dachary.org> (2008)
//                  Johan Euphrosine <proppy@aminche.com> (2008)
//                  Oyvind Sean Kinsey http://kinsey.no/blog (2010)
//                  Victor Homyakov <victor-homyakov@users.sourceforge.net> (2010)
/*global module, exports, define, ActiveXObject*/
(function(global, factory) {
    // Browser globals
    global.printStackTrace = factory();
}(this, function() {
    /**
     * Main function giving a function stack trace with a forced or passed in Error
     *
     * @cfg {Error} e The error to create a stacktrace from (optional)
     * @cfg {Boolean} guess If we should try to resolve the names of anonymous functions
     * @return {Array} of Strings with functions, lines, files, and arguments where possible
     */
    function printStackTrace(options) {
        options = options || {guess: true};
        var ex = options.e || null, guess = !!options.guess;
        var p = new printStackTrace.implementation(), result = p.run(ex);
        return (guess) ? p.guessAnonymousFunctions(result) : result;
    }

    printStackTrace.implementation = function() {
    };

    printStackTrace.implementation.prototype = {
        /**
         * @param {Error} [ex] The error to create a stacktrace from (optional)
         * @param {String} [mode] Forced mode (optional, mostly for unit tests)
         */
        run: function(ex, mode) {
            ex = ex || this.createException();
            mode = mode || this.mode(ex);
            if (mode === 'other') {
                return this.other(arguments.callee);
            } else {
                return this[mode](ex);
            }
        },

        createException: function() {
            try {
                this.undef();
            } catch (e) {
                return e;
            }
        },

        /**
         * Mode could differ for different exception, e.g.
         * exceptions in Chrome may or may not have arguments or stack.
         *
         * @return {String} mode of operation for the exception
         */
        mode: function(e) {
            if (e['arguments'] && e.stack) {
                return 'chrome';
            }

            if (e.stack && e.sourceURL) {
                return 'safari';
            }

            if (e.stack && e.number) {
                return 'ie';
            }

            if (e.stack && e.fileName) {
                return 'firefox';
            }

            if (e.message && e['opera#sourceloc']) {
                // e.message.indexOf("Backtrace:") > -1 -> opera9
                // 'opera#sourceloc' in e -> opera9, opera10a
                // !e.stacktrace -> opera9
                if (!e.stacktrace) {
                    return 'opera9'; // use e.message
                }
                if (e.message.indexOf('\n') > -1 && e.message.split('\n').length > e.stacktrace.split('\n').length) {
                    // e.message may have more stack entries than e.stacktrace
                    return 'opera9'; // use e.message
                }
                return 'opera10a'; // use e.stacktrace
            }

            if (e.message && e.stack && e.stacktrace) {
                // e.stacktrace && e.stack -> opera10b
                if (e.stacktrace.indexOf("called from line") < 0) {
                    return 'opera10b'; // use e.stacktrace, format differs from 'opera10a'
                }
                // e.stacktrace && e.stack -> opera11
                return 'opera11'; // use e.stacktrace, format differs from 'opera10a', 'opera10b'
            }

            if (e.stack && !e.fileName) {
                // Chrome 27 does not have e.arguments as earlier versions,
                // but still does not have e.fileName as Firefox
                return 'chrome';
            }

            return 'other';
        },

        /**
         * Given a context, function name, and callback function, overwrite it so that it calls
         * printStackTrace() first with a callback and then runs the rest of the body.
         *
         * @param {Object} context of execution (e.g. window)
         * @param {String} functionName to instrument
         * @param {Function} callback function to call with a stack trace on invocation
         */
        instrumentFunction: function(context, functionName, callback) {
            context = context || window;
            var original = context[functionName];
            context[functionName] = function instrumented() {
                callback.call(this, printStackTrace().slice(4));
                return context[functionName]._instrumented.apply(this, arguments);
            };
            context[functionName]._instrumented = original;
        },

        /**
         * Given a context and function name of a function that has been
         * instrumented, revert the function to it's original (non-instrumented)
         * state.
         *
         * @param {Object} context of execution (e.g. window)
         * @param {String} functionName to de-instrument
         */
        deinstrumentFunction: function(context, functionName) {
            if (context[functionName].constructor === Function &&
                context[functionName]._instrumented &&
                context[functionName]._instrumented.constructor === Function) {
                context[functionName] = context[functionName]._instrumented;
            }
        },

        /**
         * Given an Error object, return a formatted Array based on Chrome's stack string.
         *
         * @param e - Error object to inspect
         * @return Array<String> of function calls, files and line numbers
         */
        chrome: function(e) {
            return (e.stack + '\n')
                .replace(/^[\s\S]+?\s+at\s+/, ' at ') // remove message
                .replace(/^\s+(at eval )?at\s+/gm, '') // remove 'at' and indentation
                .replace(/^([^\(]+?)([\n$])/gm, '{anonymous}() ($1)$2')
                .replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}() ($1)')
                .replace(/^(.+) \((.+)\)$/gm, '$1@$2')
                .split('\n')
                .slice(0, -1);
        },

        /**
         * Given an Error object, return a formatted Array based on Safari's stack string.
         *
         * @param e - Error object to inspect
         * @return Array<String> of function calls, files and line numbers
         */
        safari: function(e) {
            return e.stack.replace(/\[native code\]\n/m, '')
                .replace(/^(?=\w+Error\:).*$\n/m, '')
                .replace(/^@/gm, '{anonymous}()@')
                .split('\n');
        },

        /**
         * Given an Error object, return a formatted Array based on IE's stack string.
         *
         * @param e - Error object to inspect
         * @return Array<String> of function calls, files and line numbers
         */
        ie: function(e) {
            return e.stack
                .replace(/^\s*at\s+(.*)$/gm, '$1')
                .replace(/^Anonymous function\s+/gm, '{anonymous}() ')
                .replace(/^(.+)\s+\((.+)\)$/gm, '$1@$2')
                .split('\n')
                .slice(1);
        },

        /**
         * Given an Error object, return a formatted Array based on Firefox's stack string.
         *
         * @param e - Error object to inspect
         * @return Array<String> of function calls, files and line numbers
         */
        firefox: function(e) {
            return e.stack.replace(/(?:\n@:0)?\s+$/m, '')
                .replace(/^(?:\((\S*)\))?@/gm, '{anonymous}($1)@')
                .split('\n');
        },

        opera11: function(e) {
            var ANON = '{anonymous}', lineRE = /^.*line (\d+), column (\d+)(?: in (.+))? in (\S+):$/;
            var lines = e.stacktrace.split('\n'), result = [];

            for (var i = 0, len = lines.length; i < len; i += 2) {
                var match = lineRE.exec(lines[i]);
                if (match) {
                    var location = match[4] + ':' + match[1] + ':' + match[2];
                    var fnName = match[3] || "global code";
                    fnName = fnName.replace(/<anonymous function: (\S+)>/, "$1").replace(/<anonymous function>/, ANON);
                    result.push(fnName + '@' + location + ' -- ' + lines[i + 1].replace(/^\s+/, ''));
                }
            }

            return result;
        },

        opera10b: function(e) {
            // "<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
            // "printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
            // "@file://localhost/G:/js/test/functional/testcase1.html:15"
            var lineRE = /^(.*)@(.+):(\d+)$/;
            var lines = e.stacktrace.split('\n'), result = [];

            for (var i = 0, len = lines.length; i < len; i++) {
                var match = lineRE.exec(lines[i]);
                if (match) {
                    var fnName = match[1] ? (match[1] + '()') : "global code";
                    result.push(fnName + '@' + match[2] + ':' + match[3]);
                }
            }

            return result;
        },

        /**
         * Given an Error object, return a formatted Array based on Opera 10's stacktrace string.
         *
         * @param e - Error object to inspect
         * @return Array<String> of function calls, files and line numbers
         */
        opera10a: function(e) {
            // "  Line 27 of linked script file://localhost/G:/js/stacktrace.js\n"
            // "  Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n"
            var ANON = '{anonymous}', lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
            var lines = e.stacktrace.split('\n'), result = [];

            for (var i = 0, len = lines.length; i < len; i += 2) {
                var match = lineRE.exec(lines[i]);
                if (match) {
                    var fnName = match[3] || ANON;
                    result.push(fnName + '()@' + match[2] + ':' + match[1] + ' -- ' + lines[i + 1].replace(/^\s+/, ''));
                }
            }

            return result;
        },

        // Opera 7.x-9.2x only!
        opera9: function(e) {
            // "  Line 43 of linked script file://localhost/G:/js/stacktrace.js\n"
            // "  Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n"
            var ANON = '{anonymous}', lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
            var lines = e.message.split('\n'), result = [];

            for (var i = 2, len = lines.length; i < len; i += 2) {
                var match = lineRE.exec(lines[i]);
                if (match) {
                    result.push(ANON + '()@' + match[2] + ':' + match[1] + ' -- ' + lines[i + 1].replace(/^\s+/, ''));
                }
            }

            return result;
        },

        // Safari 5-, IE 9-, and others
        other: function(curr) {
            var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10;
            var slice = Array.prototype.slice;
            while (curr && curr['arguments'] && stack.length < maxStackSize) {
                fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
                args = slice.call(curr['arguments'] || []);
                stack[stack.length] = fn + '(' + this.stringifyArguments(args) + ')';
                try {
                    curr = curr.caller;
                } catch (e) {
                    stack[stack.length] = '' + e;
                    break;
                }
            }
            return stack;
        },

        /**
         * Given arguments array as a String, substituting type names for non-string types.
         *
         * @param {Arguments,Array} args
         * @return {String} stringified arguments
         */
        stringifyArguments: function(args) {
            var result = [];
            var slice = Array.prototype.slice;
            for (var i = 0; i < args.length; ++i) {
                var arg = args[i];
                if (arg === undefined) {
                    result[i] = 'undefined';
                } else if (arg === null) {
                    result[i] = 'null';
                } else if (arg.constructor) {
                    // TODO constructor comparison does not work for iframes
                    if (arg.constructor === Array) {
                        if (arg.length < 3) {
                            result[i] = '[' + this.stringifyArguments(arg) + ']';
                        } else {
                            result[i] = '[' + this.stringifyArguments(slice.call(arg, 0, 1)) + '...' + this.stringifyArguments(slice.call(arg, -1)) + ']';
                        }
                    } else if (arg.constructor === Object) {
                        result[i] = '#object';
                    } else if (arg.constructor === Function) {
                        result[i] = '#function';
                    } else if (arg.constructor === String) {
                        result[i] = '"' + arg + '"';
                    } else if (arg.constructor === Number) {
                        result[i] = arg;
                    } else {
                        result[i] = '?';
                    }
                }
            }
            return result.join(',');
        },

        sourceCache: {},

        /**
         * @return the text from a given URL
         */
        ajax: function(url) {
            var req = this.createXMLHTTPObject();
            if (req) {
                try {
                    req.open('GET', url, false);
                    //req.overrideMimeType('text/plain');
                    //req.overrideMimeType('text/javascript');
                    req.send(null);
                    //return req.status == 200 ? req.responseText : '';
                    return req.responseText;
                } catch (e) {
                }
            }
            return '';
        },

        /**
         * Try XHR methods in order and store XHR factory.
         *
         * @return <Function> XHR function or equivalent
         */
        createXMLHTTPObject: function() {
            var xmlhttp, XMLHttpFactories = [
                function() {
                    return new XMLHttpRequest();
                }, function() {
                    return new ActiveXObject('Msxml2.XMLHTTP');
                }, function() {
                    return new ActiveXObject('Msxml3.XMLHTTP');
                }, function() {
                    return new ActiveXObject('Microsoft.XMLHTTP');
                }
            ];
            for (var i = 0; i < XMLHttpFactories.length; i++) {
                try {
                    xmlhttp = XMLHttpFactories[i]();
                    // Use memoization to cache the factory
                    this.createXMLHTTPObject = XMLHttpFactories[i];
                    return xmlhttp;
                } catch (e) {
                }
            }
        },

        /**
         * Given a URL, check if it is in the same domain (so we can get the source
         * via Ajax).
         *
         * @param url <String> source url
         * @return <Boolean> False if we need a cross-domain request
         */
        isSameDomain: function(url) {
            return typeof location !== "undefined" && url.indexOf(location.hostname) !== -1; // location may not be defined, e.g. when running from nodejs.
        },

        /**
         * Get source code from given URL if in the same domain.
         *
         * @param url <String> JS source URL
         * @return <Array> Array of source code lines
         */
        getSource: function(url) {
            // TODO reuse source from script tags?
            if (!(url in this.sourceCache)) {
                this.sourceCache[url] = this.ajax(url).split('\n');
            }
            return this.sourceCache[url];
        },

        guessAnonymousFunctions: function(stack) {
            for (var i = 0; i < stack.length; ++i) {
                var reStack = /\{anonymous\}\(.*\)@(.*)/,
                    reRef = /^(.*?)(?::(\d+))(?::(\d+))?(?: -- .+)?$/,
                    frame = stack[i], ref = reStack.exec(frame);

                if (ref) {
                    var m = reRef.exec(ref[1]);
                    if (m) { // If falsey, we did not get any file/line information
                        var file = m[1], lineno = m[2], charno = m[3] || 0;
                        if (file && this.isSameDomain(file) && lineno) {
                            var functionName = this.guessAnonymousFunction(file, lineno, charno);
                            stack[i] = frame.replace('{anonymous}', functionName);
                        }
                    }
                }
            }
            return stack;
        },

        guessAnonymousFunction: function(url, lineNo, charNo) {
            var ret;
            try {
                ret = this.findFunctionName(this.getSource(url), lineNo);
            } catch (e) {
                ret = 'getSource failed with url: ' + url + ', exception: ' + e.toString();
            }
            return ret;
        },

        findFunctionName: function(source, lineNo) {
            // FIXME findFunctionName fails for compressed source
            // (more than one function on the same line)
            // function {name}({args}) m[1]=name m[2]=args
            var reFunctionDeclaration = /function\s+([^(]*?)\s*\(([^)]*)\)/;
            // {name} = function ({args}) TODO args capture
            // /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*function(?:[^(]*)/
            var reFunctionExpression = /['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*function\b/;
            // {name} = eval()
            var reFunctionEvaluation = /['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*(?:eval|new Function)\b/;
            // Walk backwards in the source lines until we find
            // the line which matches one of the patterns above
            var code = "", line, maxLines = Math.min(lineNo, 20), m, commentPos;
            for (var i = 0; i < maxLines; ++i) {
                // lineNo is 1-based, source[] is 0-based
                line = source[lineNo - i - 1];
                commentPos = line.indexOf('//');
                if (commentPos >= 0) {
                    line = line.substr(0, commentPos);
                }
                // TODO check other types of comments? Commented code may lead to false positive
                if (line) {
                    code = line + code;
                    m = reFunctionExpression.exec(code);
                    if (m && m[1]) {
                        return m[1];
                    }
                    m = reFunctionDeclaration.exec(code);
                    if (m && m[1]) {
                        //return m[1] + "(" + (m[2] || "") + ")";
                        return m[1];
                    }
                    m = reFunctionEvaluation.exec(code);
                    if (m && m[1]) {
                        return m[1];
                    }
                }
            }
            return '(?)';
        }
    };

    return printStackTrace;
}));

/** @define {boolean} */ var DEBUG = false;(function(window, xhr, xhrText, tout, callbk, setRequestHeader, onreadystatechange, contentType,
          hdrs){

var create;

function log() {
  if (DEBUG && console) {
    if (console.log.apply) {
      return console.log.apply(console, arguments);
    } else {
      return console.log(argsArray(arguments).join(', '));
    }
  }
}

function error() {
  if (DEBUG && console) {
    if (console.error.apply) {
      return console.error.apply(console, arguments);
    } else {
      return console.error(argsArray(arguments).join(', '));
    }
  }
}

function request(method, o) {
  log('[xhr] creating ' + method + ' request with options:', o);

  var aborted, callback, data, n, name, req, timeout, url;
  data = method.toLowerCase() === 'post' ? o['data'] : null;

  callback = typeof o[callbk] === 'function' ? o[callbk] : (function(){});
  timeout = typeof o[tout] === 'number' ? o[tout] : 20000;
  url = o['bustCache'] ? noCache(o['url']) : o['url'];

  req = create();
  req.open(method, url, true);
  req['withCredentials'] = true;
  req[setRequestHeader]('X-Requested-With', xhrText);

  // Add any request headers specified
  if (o[hdrs]) {
    for (name in o[hdrs]) {
      req[setRequestHeader](name, o[hdrs][name]);
    }

    // Only add the Content-Type header if it wasn't specified
    if (!o[hdrs][contentType]) {
      req[setRequestHeader](contentType, 'application/x-www-form-urlencoded');
    }
  }

  req[onreadystatechange] = function() {
    if (aborted) {
      error('[xhr] aborting, request for ' + url + ' timed out');
      callback({
        status: 408,
        body: 'Request Timeout'
      });
    } else if (req.readyState !== 4) {
      // Still not ready
      return;
    } else {
      log('[xhr] request completed, clearing timeout with value of', n, clearTimeout+'');
      if (n) {
        clearTimeout(n);
        n = null;
      }

      log('[xhr] request completed, invoking callback with params:', req.status, req.responseText);
      callback({
        status: req.status,
        body: req.responseText
      });
    }

    req[onreadystatechange] = null;
  };

  log('[xhr] sending request to url:' + url);
  req.send(data);

  log('[xhr] will timeout request automatically in ' + timeout + 'ms, ' + setTimeout);
  // Automatically abort after the given timeout interval
  setTimeout(function(){
    aborted = true;
    req.abort();
  }, timeout);
}

function noCache(url) {
  if (url.indexOf('?') === -1) {
    url += '?';
  } else {
    url += '&';
  }
  url += '_' + (+(new Date));
  return url;
}

create = function() {
  function standardXHR() {
    log('[xhr] creating XMLHttpRequest...');
    return new window[xhrText]();
  }

  function msAXO() {
    log('[xhr] creating ActiveXObject...');
    return new ActiveXObject('Microsoft.XMLHTTP');
  }

  try {
    return standardXHR();
  } catch (_error) {
    return msAXO();
  }
};

xhr['post'] = function xhrPost(o) {
  request('POST', o);
};

xhr['get'] = function xhrGet(o) {
  request('GET', o);
};

log('[xhr] successfully loaded');

}(window, window['xhr'] = window['xhr'] || {}, 'XMLHttpRequest', 'timeout', 'callback',
  'setRequestHeader', 'onreadystatechange', 'Content-Type', 'hdrs'));

/** @define {boolean} */ var DEBUG = false;/**
 * Client library for the jet (JavaScript Error Tracking) system. Automatically handles errors in
 * the JS runtime and beacons them to the tracking service.
 *
 * This code is intended for global use across the site with minimal dependencies. Anything
 * depended on by this client is lazily loaded to minimize page load impact.
 *
 * As such, the code is also written in a way that allows the JS compiler to best take advantage
 * of minification techniques.
 */

var jet = (function(global, window, document, location, parseInt, noop, apply, funcType, onerror,
          onreadystatechange, constructor, getElementsByTagName, xhrHeaders, jetChromeVersion, trackingID, treeID, pageKey,
          printStackTrace, length, appId, service, serviceInstance, serviceVersion, addEventListener, attachEvent, unload,
          beforeunload, pagehide, isQueueHandler, getPrototypeOf, fireInterval){

/**
 * @const
 * @type {string}
 */
var VERSION = '2.0.5';

/**
 * Clipping lengths for browser telemetry event fields
 */
var PARAM_CLIP = 128;
var RESULT_CLIP = 256;

/**
 * Configuration for the jet client
 * @type {Object.<string, *>}
 */
var conf = {
  'scHost': 'static.licdn.com',
  'url': '/mob/tracking',
  'recordTelemetry': false,
  'timelineLength': 20
};


/**
 * The transport client which is loaded asynchronously (xhr.js)
 */
var xhr = {};

/**
 * The transport client which is loaded asynchronously (xhr.js)
 */
var isXhrInitialized = false;

/**
 * Unique list of tags any errors on this page will occur, can be appended to via jet.tag()
 * @type {Object.<string, number>}
 */
var tags = {};

/**
 * The original onerror callback (defaults to a noop function)
 * @type {function}
 */
var original = noop;


/**
 * Flag indicating whether or not we have initialized jet entirely at least once
 * @type {boolean}
 */
var initialized = false;

/**
 * Queue of errors which will be emitted once the page is unloaded
 * @type {Array.<Function>}
 */
var unloadErrQ = [];

/**
 * Flag indicating whether the unload event was handled
 * @type {boolean}
 */
var unloadHandled = false;

/**
 * Queue of telemetry events which will be sent along with the error
 * @type {Array.<BrowserTelemetryEvent>}
 */
var timeline = [];

/**
 * The input element of the last event, undefined if the event wasn't an input event
 * @type {Object.<DOMElement>}
 */
var prevInputElement;

/**
 * Object to access lib-load-util in order to asynchronously load xhr.min.js and stacktrace.min.js
 * @type {Object.<DOMElement>}
 */
var preLibErrQueueHandler;

/**
 * Boolean to determine whether to load xhr and stacktrace asynchronously
 * @type {boolean}
 */
var isPreLoadLibs;

/**
 * setTimeout handler for publishing jet events to tracking-fe
 */
var unloadTimeoutHandler;

/**
 * Initialize lib load util variables
 */
function initPreLibLoadVariables() {
  preLibErrQueueHandler = window['preLibErrQueueHandler'];
  isPreLoadLibs = preLibErrQueueHandler && typeof preLibErrQueueHandler !== 'undefined';
}

/**
 * Pushes an object to the timeline, removing the first element if necessary
 */
function pushToTimeline(obj,input) {
  obj['t'] = (new Date()).getTime(); // Mark when this event was pushed
  if (timeline.length >= conf['timelineLength']) {
    timeline.shift();
  }
  timeline.push(obj);
  prevInputElement = input;
}

// Clips a result body to fit the 256-character limit
function clipString(str, clipLen) {
  return (str) ? str.substring(0, clipLen): "";
}

// Function for tracking clicks
function trackClicks(e) {
  pushToTimeline({
    'a': 'CLICK',
    'e': (e && e.target) ? e.target.outerHTML : '',
    'p': null,
    'r': null
  });
}

// Function for tracking input
function trackInput(e) {
  if (!e || !e.target) {
    // no op if there is no event or target
    return;
  }
  // If this event continues from a preceeding input event on the same element,
  // replace the preceeding event with this one
  if (e.target === prevInputElement) {
    timeline.pop();
  }
  var isContentEditableTarget = e.target.getAttribute("contentEditable") === "true";
  var inputLength = 0;
  if (e.target.value && e.target.value.length) {
    inputLength = e.target.value.length.toString();
  } else if (isContentEditableTarget && e.target.innerHTML && e.target.innerHTML.length) {
    inputLength = e.target.innerHTML.length.toString();
  }

  pushToTimeline({
    'a': 'INPUT',
    'e': e.target.outerHTML,
    'p': {
      'inputLength': inputLength
    },
    'r': null
  }, e.target);
}

function bindTrackers() {
  // Default functions for browsers that don't support them
  var forEach = function(array, callback) {
    for (var i = 0; i < array.length; i++){
      callback.apply(array, [array[i], i, array]);
    }
  };

  var getOwnPropertyNames = function(object) {
    var ownProperties = [];
    for (var p in object) {
      if (Object.prototype.hasOwnProperty.call(object,p)) {
        ownProperties.push(p);
      }
    }
    return ownProperties;
  }

  // Tracking clicks and inputs
  if (document.body[addEventListener]) {
    document.body[addEventListener]('click',trackClicks);
    document.body[addEventListener]('input',trackInput);
  } else if (document.body[attachEvent]) {
    document.body[attachEvent]('onclick',trackClicks);
    document.body[attachEvent]('oninput',trackInput);
  }

  // Tracking AJAX
  var realXMLHttpRequest = new Object();
  realXMLHttpRequest.open = XMLHttpRequest.prototype.open;
  realXMLHttpRequest.send = XMLHttpRequest.prototype.send;

  // Add the resulting http request and response to the timeline
  function handleHttpResponse(xhr) {
    var _error;
    if (xhr.readyState === 4) {
      var response = "";
      if (xhr.responseType === 'document') {
        if (xhr.responseXML && xhr.responseXML.xml) {
          response = xhr.responseXML.xml;
        } else if (xhr.responseXML && typeof window.XMLSerializer !== 'undefined') {
          try {
            response = (new window.XMLSerializer()).serializeToString(xhr.responseXML);
          } catch (_error) {
            error("Error occured while parsing XML response. Logging empty response into telemetry", _error);
            response = "";
          }
        }
      } else {
        response = xhr.responseText;
      }

      xhr.eventInfo['r'] = {
        's': xhr.status,
        'b': clipString(response, RESULT_CLIP)
      };
      pushToTimeline(xhr.eventInfo);
    }
  }

  // Record the arguments when open is called
  XMLHttpRequest.prototype.open = function(a,b) {
    realXMLHttpRequest.open.apply(this, Array.prototype.slice.call(arguments));
    this.eventInfo = { // Record the event information
      'a': a.toUpperCase(),
      'e': b,
      'p': null
    };
  };

  // Activate the hook when the request is sent and received
  XMLHttpRequest.prototype.send = function(a) {
    var self = this;
    // We're only able to extract POST parameters out of a string
    if (typeof a === 'string') {
      self.eventInfo['p'] = {};
      forEach(a.split('&'), function (arg) {
        var pair = arg.split('=');
        self.eventInfo['p'][pair[0]] = pair[1];
      });
    }
    if (this.addEventListener) {
      self.addEventListener('readystatechange', function() {
        handleHttpResponse(self);
      }, false);
    } else {
      var realOnReadyStateChange = this.onreadystatechange;
      if (realOnReadyStateChange) {
        this.onreadystatechange = function() {
          handleHttpResponse(this);
          realOnReadyStateChange.apply(this, Array.prototype.slice.call(arguments));
        };
      }
    }
    realXMLHttpRequest.send.apply(this, Array.prototype.slice.call(arguments));
  };

  // Tracking Console Commands
  if (window.console) {
    // IE 9.0 console functions are located in the console itself
    var keys = getOwnPropertyNames(window.console);

    if (keys.length <= 1) { // IE 10.0, Firefox and Safari console functions are located in the prototype
      keys = getOwnPropertyNames(Object[getPrototypeOf](window.console));
    }

    if (keys.length <= 2) { // For Chrome they're located in the prototype's prototype
      keys = getOwnPropertyNames(Object[getPrototypeOf](Object[getPrototypeOf](window.console)));
    }

    // Augment each console function with a timeline hook
    forEach(keys, function(key) {
      if (typeof window.console[key] === 'function') {
        // IE8 and IE9 Console functions exist as objects
        var oldFunction = window.console[key];

        window.console[key] = function() {
          // Capture arguments into a string
          var args = {};
          for (var i = 0; i < arguments.length; i++) {
            args[i] = clipString(arguments[i]+'', PARAM_CLIP);
          }

          pushToTimeline({
            'a': 'CONSOLE',
            'e': key,
            'p': args,
            'r': null
          });

          oldFunction.apply(this, Array.prototype.slice.call(arguments));
        };
      }
    });
  }
}

function argsArray(argumentsObj) {
  var i, args = [];
  for (i = 0; i < argumentsObj[length]; i++) {
    args.push(argumentsObj[i]);
  }
  return args;
}

// TODO Move log() and error() into a common file to be used by both xhr.js and jet.js
function log() {
  if (DEBUG && console) {
    if (console.log.apply) {
      return console.log.apply(console, arguments);
    } else {
      return console.log(argsArray(arguments).join(', '));
    }
  }
}

function error() {
  if (DEBUG && console) {
    if (console.error.apply) {
      return console.error.apply(console, arguments);
    } else {
      return console.error(argsArray(arguments).join(', '));
    }
  }
}

function stack(err) {
  var printStackTraceHandler = global[printStackTrace] || window[printStackTrace];
  if (DEBUG) {
    log("[jet:stack] err => " + (JSON.stringify({ err: err })));
    log("[jet:stack] stacktrace => " + (JSON.stringify({ stacktrace: printStackTraceHandler({ 'e': err }) })));
  }

  return err ? printStackTraceHandler({ 'e': err }).join('\n') : '';
}

// Construct the line, column and source file fields for the error object based on the information
// provided in the first frame of the stack trace
function parseStack(stack) {
  var ret = {}, frame, frames, result, stackRxp, idx;

  if (stack) {
    stackRxp = /^(?:.+\s*(?:at\s+)|(?:.+@))?(https?\:\/\/.+[a-zA-Z]*|<anonymous>)\:(\d+)(?:\:(\d+))?$/;
    frames = stack.split("\n");
    frame = stackRxp.test(frames[0]) ? frames[0] : frames[1];
    result = stackRxp.exec(frame.replace(/^\s+/, ""));
    log("[jet:parseStack] regex execution result: " + (JSON.stringify(result)));
    if (result) {
      ret.url = result[1];
      idx = (function lastIndexOf(str, find, i) {
        if (i === undefined) i = str.length-1;
        if (i < 0) i+= str.length;
        if (i > str.length-1) i= str.length-1;
        for (i++; i-- > 0;)
          if (str[i] === find)
            return i;
        return -1;
      }(ret.url, ':'));
      ret.line = parseInt(ret.url.substring(idx+1)) || -1;
      ret.url = ret.url.substring(0, idx);
      if (result[length] > 2) {
        ret.col = parseInt(result[2]) || -1;
      }
    }
  }

  return ret;
}

function handler(msg, url, line, column, err, rethrow, callOrig) {
  // undefined (almost always) happens when uncaught error is passed in,
  // then jet do the report, then original handler should be called.
  callOrig = typeof callOrig === 'undefined' || callOrig;
  if (!err) {
    log('[jet:errorHandler] Ignoring null or undefined err object');
    return callOrig ? invokeOriginal(arguments.callee, arguments) : true;
  }
  if (err['rethrown']) {
    // Since this error is already processed (processed and rethrown at the end of this function),
    // we just invoke Original
    log('[jet:errorHandler] Handling Rethrown error. Invoking original');
    return callOrig ? invokeOriginal(arguments.callee, arguments) : true;
  }

  var data, result, trace, metaElems, elem, appRxp, body, info, i = 0;
  var _error;
  // Always wrap in a try-catch block so that we can fail gracefully and call the original
  // onerror handler if it was registered before us
  try {
    log("[jet:errorHandler] Handling error: " + msg);
    data = {};
    info = data['eventInfo'] = {
      'eventName': 'JavaScriptErrorEvent'
    };
    body = data['eventBody'] = {
      // Library version
      'v': VERSION,
      // Hash
      'h': location.hash ? location.hash.split('#')[1] : '',
      // Host
      'o': location.host,
      // Path
      'p': location.pathname,
      // Protocol
      'l': location.protocol.substring(0, location.protocol[length] - 1),
      // Query
      'q': location.search.substring(1),
      // Tags
      't': (function extractTags(){
        var ret = [];
        var errTags = err['errTags'];
        if (errTags != null) {
          if (errTags[constructor] === Array) {
            ret = ret.concat(errTags);
          } else {
          ret.push(errTags);
          }
        }
        ret = ret.concat(Object.keys(tags));
        return ret;
      }())
    };

    appRxp = new RegExp(appId + '|appName');

    metaElems = document[getElementsByTagName]('meta');
    var bodyElems = [jetChromeVersion, trackingID, treeID, pageKey, service, serviceInstance, serviceVersion];
    for (len = metaElems[length]; i < len; i++) {
      elem = metaElems[i];
      if (bodyElems.indexOf(elem.name) >= 0) {
        log('[jet:errorHandler] Setting '+ elem.name +' via key: ' + elem.name + ', with value: ' +
            elem.content + ', into info: ', info);
        body[elem.name] = elem.content;
      } else if (appRxp.test(elem.name)) {
        info[appId] = elem.content;
      }
      if (info[appId] && bodyElems.every(function(val) { return body.hasOwnProperty(val); })) {
          break;
      }
    }

    // API configs > DOM configs
    for (var ind = 1 ; ind < bodyElems.length; ind++ ) {
      body[bodyElems[ind]] = conf[bodyElems[ind]] || body[bodyElems[ind]]
    }
    info[appId] = conf[appId] || info[appId];

    result = {};
    log('[jet:errorHandler] Parsing trace from error: ', err);
    // Have stacktrace.js create the stack trace for us (if possible)
    trace = stack(err);

    if (err) {
      if (!(msg && url && line)) {
        result = parseStack(trace);
      }
      error(err);
    } else if (msg) {
      error(msg);
    }

    log('[jet:errorHandler] url=' + url + ', result.url=' + result.url);

    // Fill out the error fields
    body['e'] = {
      // Column
      'c': result.col !== null ? result.col : column,
      // Line
      'l': result.line !== null ? result.line : line,
      // Error Message
      'm': msg,
      // Source URL
      'u': result.url || url,
      // Stack
      's': trace,
      // Error type
      't': (err || {}).name || 'Error'
    };

    // Append and flush timeline
    body['b'] = timeline;
    timeline = [];

    log('[jet:errorHandler] sending XHR request...');
    log('[jet:errorHandler] with message: \n' + msg);
    log('[jet:errorHandler] with stacktrace: \n' + trace);
    if (err) {
      log('[jet:errorHandler] where err.stack is: \n' + err.stack);
    }

    // Post the errors to the server later
    unloadErrQ.push(data);
  } catch (_error) {
    error('Error occurred in the onerror handler', _error);
  }
  // If fireInterval is specified in conf and timeout already not set by another error,
  // set a timeout to call unloadHandler to force push the existing errors.
  var jetFireInterval = parseInt(conf[fireInterval]);
  if (!isNaN(jetFireInterval) && !unloadTimeoutHandler) {
    unloadTimeoutHandler = setTimeout(function() {
      unloadHandler(null, true);
    }, jetFireInterval);
  }

  log('[jet:errorHandler] Invoking original onerror handler: ' + original,
      ', with args:', arguments);

  if (rethrow) {
    // If handler is called explicitly from the code, then error is not propagated to the browser and is swallowed
    // Hence we rethrow the error so that it calls the error handler implicitly as a part of Javascript error handling chain
    // and is not swallowed
    err['rethrown'] = true;
    throw err;
  } else if (callOrig) {
    return invokeOriginal(arguments.callee, arguments);
  }
  // If rethrow is false, the previous version of jet-static will invoke original onerror handler.
  // This troubles some test setup. See ticket PPTF-1422.
  // Thus we return `true` here to avoid invoking original error handler and silence the error
  // if not rethrowing error, nor callOrig
  // If one wants to call original window error handler after jet processing, simply specify rethrow,
  // it will go to original error handler.
  return true;
}

function headers() {
  var hdrs;
  hdrs = (conf[xhrHeaders] && conf[xhrHeaders][constructor] === Object) ? conf[xhrHeaders] : {};
  hdrs['Content-Type'] = 'application/json';
  return hdrs;
}

function invokeOriginal(callee, args) {
  if (original !== callee) {
    return original[apply](window, args);
  }
}

function unloadHandler(event, force) {
  if ((force || !unloadHandled) && unloadErrQ.length) {
    //Either libs are loaded or libs are concatenated in line, so xhr will be present in window object
    if (!isXhrInitialized) {
      xhr = window['xhr'];
      log('[jet:initErrorHandler] Successfully required jet/libs/xhr:', xhr.post, xhr.get);
      isXhrInitialized = true;
    }

    xhr['post']({
      'bustCache': 1,
      'data': JSON.stringify(unloadErrQ),
      'hdrs': headers(),
      'url': jet.url(),
      'callback': function handleResponse(response) {
        var msg;
        if (response) {
          if (!response.status || (response.status >= 300 || (response.status < 200))) {
            msg = 'Bad response: ' + response.status + ', ' + response.body;
          }
        } else {
          msg = 'No response object provided: ' + response;
        }
        if (msg) {
          error(msg);
        }
      }
    });
    if (!force) {
      unloadHandled = true;
    }
    // Clear existing timeout if one exists
    if (unloadTimeoutHandler) {
      clearTimeout(unloadTimeoutHandler);
      unloadTimeoutHandler = null;
    }
    unloadErrQ = [];
  }
}

function initErrorHandler() {
  xhr = window['xhr'];
  log('[jet:initErrorHandler] Successfully required jet/libs/xhr:', xhr.post, xhr.get);
  isXhrInitialized = true;

  // Swap the handler
  log('[jet:initErrorHandler] Intializing the global onerror handler');
  window[onerror] = handler;

  // Fire the ready handler if it exists
  if (typeof jet['ready'] === funcType) {
    jet['ready']();
  }
}

var jet = {
  'url': function jetUrl() {
    // Unified tracking service endpoint
    return conf['url'];
  },

  'tag': function jetTag(tag) {
    var t, tagList, i, len;
    tagList = [];
    if (arguments[length] > 1) {
      tagList.push[apply](tagList, arguments);
      // We are not scripting across frames so we're good here
    } else if (tag[constructor] === Array) {
      tagList.push[apply](tagList, tag);
    } else if (tag[constructor] === String) {
      tagList.push(tag);
    }
    for (i = 0, len = tagList[length]; i < len; i++) {
      tags[tagList[i]] = 1;
    }
  },

  /**
   * Populate the given Error object with stack trace, and log or re-throw it.
   * Will cache the operation if the dependent JS libraries are not loaded.
   *
   * @param err {Error} The Error object to generate the stack trace
   * @param errTags An object or array which will be embedded to err object's "errTags" property
   * @param shouldRethrow {boolean} Whether the error be thrown
   * @return {*} The result of the `window.onerror`, `null` if the library are not ready
   */
  'error': function jetError(err, errTags, shouldRethrow) {
    err = err || {};
    err.errTags = errTags;
    shouldRethrow = (shouldRethrow == null) ? true : shouldRethrow;

    if (isPreLoadLibs && !preLibErrQueueHandler['areLibsLoaded']()) {
      // Do it later once we can access the libraries
      preLibErrQueueHandler['getQueuedErrors']().push(function() {jetError(err);});
      return;
    }

    var result = {
      line: err.line || err.lineNumber,
      url: err.sourceURL || err.fileName,
      col: err.columnNumber
    };

    try {
      // Generate the stack with stacktrace.js
      var trace = stack(err);

      if (DEBUG) {
        log("[jet:error] trace => " + (JSON.stringify({ trace: trace })));
      }

      // Prefer the parsed values (for consistency)
      result = parseStack(trace) || result;
    } catch (err) {
      error('[jet:error] Couldn\'t handle manual error', err);
    }

    return window[onerror](err.message, result.url, result.line, result.col, err, shouldRethrow, false);
  },

  'conf': function jetConf(opts) {
    for (var key in opts) {
      conf[key] = opts[key];
    }
  },
  'getConf': function getConf(key) {
    return conf[key];
  },

  'getHandler': function getHandler() {
    return handler;
  },
  'getArgsArray': function getArgsArray(argsObject) {
    return argsArray(argsObject);
  },
  'invokeOriginalErrorHandler': function invokeOriginalErrorHandler(callee, args) {
    return invokeOriginal(callee, args);
  },
  'bind': function jetBind() {
    var on = 'on';
    log('[jet:bind]');

    if (!initialized) {
      initPreLibLoadVariables();
      tags = {};
      if (isPreLoadLibs){
        preLibErrQueueHandler['resetQueuedErrors']();
      }
      if (!isPreLoadLibs) {
        original = typeof window[onerror] === funcType ? window[onerror] : noop;
      } else {
        original = typeof window[onerror] === funcType && !window[onerror][isQueueHandler] ? window[onerror] : noop;
      }

      if (window[addEventListener]) {
        window[addEventListener](pagehide, unloadHandler);
        window[addEventListener](beforeunload, unloadHandler);
        window[addEventListener](unload, unloadHandler);
      } else {
        window[attachEvent](on + beforeunload, unloadHandler);
        window[attachEvent](on + unload, unloadHandler);
      }
      if (conf['recordTelemetry']) { // Set up tracking
        if (window[addEventListener]) {
          window[addEventListener]('DOMContentLoaded', bindTrackers);
        } else {
          window[attachEvent](on+'load', bindTrackers);
        }
      }
      if (!isPreLoadLibs) {
        initErrorHandler();
      } else {
        preLibErrQueueHandler['loadLibraries']();
      }

      initialized = true;
    }
  }
};

if (typeof module != 'undefined' && module.exports) {
  module.exports = jet;
} else {
  window['jet'] = jet;
}
return jet;

}(this, (typeof window !== 'undefined') ? window : null, (typeof document !== 'undefined') ? document : null,
  (typeof document !== 'undefined') ? document.location : null, parseInt, function(){}, 'apply', 'function', 'onerror',
  'onreadystatechange', 'constructor', 'getElementsByTagName', 'xhrHeaders','jet-chromeVersion', 'trackingID', 'treeID', 'pageKey',
  'printStackTrace', 'length', 'appId', 'service', 'serviceInstance', 'serviceVersion', 'addEventListener', 'attachEvent',
  'unload', 'beforeunload', 'pagehide', 'isQueueHandler', 'getPrototypeOf', 'fireInterval'));

(function(a){if(a.jet){var b={recordTelemetry:!0},c=document.getElementById("jet-scHost"),d=document.getElementById("jet-csrfToken");c&&(b.scHost=c.getAttribute("content"));d&&(b.xhrHeaders={"Csrf-Token":d.getAttribute("content")});a.jet.conf(b);a.jet.bind()}})(window);
!function(){try{new window.CustomEvent("test")}catch(t){window.CustomEvent=function(){if(document.createEvent){var t=function(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n};return t.prototype=window.Event.prototype,t}return document.createEventObject?function(t,e){e=e||{};var n={type:t,bubbles:e.bubbles||!1,cancelable:e.cancelable||!1,detail:e.detail||null},r=document.createEventObject();for(var o in n)r[o]=n[o];return r}:function(){}}()}}();
