(function($){

  'use strict';

  function initializeChosen(){

    'use strict';

    let chosen_elements = [];

    for(let i=1;i<=100;i++){

      if( $('#da-hm-default-language-' + i).length && $('#da-hm-default-locale-' + i).length ){

        chosen_elements.push('#da-hm-default-language-' + i);
        chosen_elements.push('#da-hm-default-script-' + i);
        chosen_elements.push('#da-hm-default-locale-' + i);

      }

    }

    //General
    chosen_elements.push('#da-hm-show-log');
    chosen_elements.push('#da-hm-https');
    chosen_elements.push('#da-hm-detect-url-mode');
    chosen_elements.push('#da-hm-auto-delete');
    chosen_elements.push('#da-hm-auto-alternate-pages');
    chosen_elements.push('#da-hm-import-language');
    chosen_elements.push('#da-hm-import-script');
    chosen_elements.push('#da-hm-import-locale');
    chosen_elements.push('#da-hm-sanitize-url');
    chosen_elements.push('#da-hm-sample-future-permalink');
    chosen_elements.push('#da_hm_set_max_execution_time');
    chosen_elements.push('#da_hm_set_memory_limit');

    //Sync
    chosen_elements.push('#da-hm-sync-status');
    chosen_elements.push('#da-hm-sync-role');
    chosen_elements.push('#da-hm-sync-frequency');
    chosen_elements.push('#da-hm-sync-mode');
    chosen_elements.push('#da-hm-sync-language');
    chosen_elements.push('#da-hm-sync-script');
    chosen_elements.push('#da-hm-sync-locale');
    chosen_elements.push('#da-hm-sync-delete-target');

    $(chosen_elements.join(',')).chosen();

  }

  $(document).ready(function(){

    'use strict';

    initializeChosen();

  });

})(jQuery);