/* Auto generated, hash = 45rwl1y3pj3zab17wqupydqxk */
(function($) {
  const WWW = "www.";
  var host = window.location.host;
  host = host.startsWith(WWW) ? host.replace(WWW, "") : host

  const BASE_API_PARAMS = {
          'api_key': 'de83ab11be89432cb9e07be7e51b76dd',
          '3pc': 'true'
        },
        API_BASE_URL = `https://profile-api.ads.${host}/v5`,
        OPT_OUT_BASE_URL = `https://dc.ads.${host}`,
        AJAX_TIMEOUT = 5000;

  var BizoApi = {},
      taxonomy_url,
      profile_url,
      write_url,
      opted_out_url,
      opt_out_url;

  /**
   * Create API URL endpoints with API key
   * @param  {String} path        - path the use for endpoint
   * @param  {Object} queryParams - optional additional query parameters
   * @return {String}             - full API URL
   */
  function generate_api_url(path, queryParams) {
    queryParams = $.extend({}, queryParams, BASE_API_PARAMS);
    return API_BASE_URL + path + '?' + $.param(queryParams);
  }

  /**
   * Create opt out URL endpoints
   * @param  {String}   path     - path the use for endpoint
   * @return {String}            - full opt out URL
   */
  function generate_opt_out_url(path) {
    return OPT_OUT_BASE_URL + path;
  }

  /**
   * Wrapper for jsonp request. jsonp doesn't handle request errors properly.
   * Set timeout for 5 seconds and manually reject the deferred to catch errors.
   * @param  {String} url       - URL for request
   * @return {jQuery Deferred}  - Deferred object for request
   */
  function api_call(url) {
    return $.ajax({
      type: 'GET',
      url: url,
      dataType: 'jsonp',
      timeout: AJAX_TIMEOUT
    });
  }

  /**
   * Wrapper for ajax jsonp request.
   * Return data is normalized to boolean.
   * @param  {String} url       - URL for request
   * @return {jQuery Deferred}  - Deferred object for request
   */
  function optOutCall(url) {
    return api_call(url).then(function(data) {
      return (data.optedOut && data.optedOut.toLowerCase() === 'true');
    });
  }

  taxonomy_url  = generate_api_url('/taxonomy.json');
  profile_url   = generate_api_url('/profile.json');
  write_url     = generate_api_url('/writeData.json');
  opted_out_url = generate_opt_out_url('/optedout/');
  opt_out_url   = generate_opt_out_url('/optout/');

  /**
   * Public method to get opted out status.
   * @return {jQuery Deferred}  - Deferred object for request
   */
  BizoApi.isOptedOut = function() {
    return optOutCall(opted_out_url);
  };

  /**
   * Public method to opt out.
   * @return {jQuery Deferred}  - Deferred object for request
   */
  BizoApi.optOut = function() {
    return optOutCall(opt_out_url);
  };

  /**
   * Public method to get Taxonomy data.
   * Return data is filtered after request.
   * @return {jQuery Deferred}  - Deferred object for request
   */
  BizoApi.getTaxonomy = function() {
    return api_call(taxonomy_url).then(function(data) {
      return data.taxonomy.bizographics;
    });
  };

  /**
   * Public method to get Profile data.
   * Return data is filtered after request.
   * @return {jQuery Deferred}  - Deferred object for request
   */
  BizoApi.getProfile = function() {
    return api_call(profile_url).then(function(data) {
      return data.bizographics;
    });
  };

  /**
   * Public method to set Profile data.
   * Return data is filtered after request.
   * @param  {String} data_parameters - jQuery serialized form. Query string of profile
   * @return {jQuery Deferred}        - Deferred object for request
   */
  BizoApi.write = function(data_parameters) {
    var url = write_url + '&' + data_parameters;

    return api_call(url).then(function(data) {
      return data.bizographics;
    });
  };

  LIModules.exports('BizoApi', BizoApi);

})(LIModules.requires('jquery'));

(function(f,h,k,m){var l={li_occupation:"occupation",li_industry:"industry",li_job_function:"job-function",li_location:"location",li_seniority:"seniority",li_company_size:"company-size",li_degree:"degree",li_field_of_study:"field-of-study",li_gender:"gender"};h=h.extend(function(){return{init:function(b){var a=this;a.$form=f(b);a.facetContainers=a._setFacetElements();a.setMessages();f.when(k.getProfile(),k.getTaxonomy()).done(function(b,e){a.setProfile(b);a.setTaxonomy(e)}).fail(function(b){a.showMessage(a.messages.loadError)});
a._bindHandlers()},setMessages:function(){this.messages=Array.prototype.reduce.call(this.$form.find('input[data-type\x3d"message"]'),function(b,a){b[a.name]=a.value;a.parentElement.removeChild(a);return b},{})},setProfile:function(b){this.profile=this._transformProfile(b);this._setProfileDisplayNames()},setTaxonomy:function(b){this.taxonomy=b;this._setTaxonomyOptions()},_transformProfile:function(b){var a={};Object.keys(b).map(function(c,e){var d={names:[],codes:[]};Array.isArray(b[c])?b[c].map(function(a){d.codes.push(a.code);
d.names.push(a.name)}):(d.codes.push(b[c].code),d.names.push(b[c].name));a[c]=d});return a},_setFacetElements:function(){return Array.prototype.reduce.call(this.$form.find(".profile \x3e li"),function(b,a){var c=f(a),e=c.data("facet");b[e]={$el:c};return b},{})},_setProfileDisplayNames:function(){Object.keys(this.profile).map(function(b){var a=this.facetContainers[l[b]];a&&a.$el.find(".current").text(this.profile[b].names.join(", "))},this)},_setTaxonomyOptions:function(){var b=this,a,c,e,d;Object.keys(b.taxonomy).map(function(g){if(a=
b.facetContainers[l[g]])c=a.$el.find(".options select"),d=(e=c.prop("multiple"))?[]:[f("\x3coption/\x3e")],d=b.taxonomy[g].reduce(function(a,c){var d=b.profile[g]&&-1!==b.profile[g].codes.indexOf(c.code);a.push(f("\x3coption/\x3e").val(c.code).text(c.name).prop("selected",d));return a},d),a.$el.find(".options select").prop("name",g).html(d)})},_toggleView:function(){this.$form.find(".current, .options, button").toggle()},saveData:function(){return k.write(this.$form.serialize())},_bindHandlers:function(){var b=
this;b.$form.on("click","button",function(a){a.preventDefault();if("submit"===a.target.type)return b.submitHandler(a);b._toggleView()})},_setFormEnabledState:function(b){b=!!b;this.$form.toggleClass("disabled",!b).find("button").prop("disabled",!b)},submitHandler:function(b){var a=this;a._setFormEnabledState(!1);a.saveData().done(function(b){a.showMessage(a.messages.saveSuccess,!0);a.setProfile(b);a._toggleView(!0)}).fail(function(){a.showMessage(a.messages.saveError)}).always(function(){a._setFormEnabledState(!0)})},
showMessage:function(b,a){m({message:b,type:a?"success":"error",dismissable:!0,autoHide:!0})}}});LIModules.exports("editForm",h)})(LIModules.requires("jquery"),LIModules.requires("Fiber"),LIModules.requires("BizoApi"),LIModules.requires("injectAlert"));
(function(d,e,g,f,h){d=g.extend(function(){return{init:function(a,b){var c=this;c.$form=e(document).find(a);c.$dialog=e(document).find(b);c.setMessages();f.isOptedOut().then(function(a){c._setFormEnabledState(!a);c._setDialog(a)}).fail(function(){c.showMessage(c.messages.loadError)});c._bindHandlers()},setMessages:function(){this.messages=Array.prototype.reduce.call(this.$form.find('input[data-type\x3d"message"]'),function(a,b){a[b.name]=b.value;b.parentElement.removeChild(b);return a},{})},_setFormEnabledState:function(a){a=
!!a;this.$form.toggleClass("disabled",!a).find("button").prop("disabled",!a)},_setDialog:function(a){a=!!a;this.$dialog.addClass("opt-out-banner").text(this._getDialogMessage(a))},_getDialogMessage:function(a){return a?this.messages.optedOut:this.messages.notOptedOut},optOut:function(){return f.optOut()},_bindHandlers:function(){this.$form.on("click","button",this.submitHandler.bind(this))},submitHandler:function(a){var b=this;a.preventDefault();b._setFormEnabledState(!1);b.optOut().done(function(a){b.showMessage(b.messages.saveSuccess,
!0);b._setDialog(a)}).fail(function(){b.showMessage(b.messages.saveError);b._setFormEnabledState(!0)})},showMessage:function(a,b){h({message:a,type:b?"success":"error",dismissable:!0,autoHide:!0})}}});LIModules.exports("optOutForm",d)})(window,LIModules.requires("jquery"),LIModules.requires("Fiber"),LIModules.requires("BizoApi"),LIModules.requires("injectAlert"));
