{"size": 795, "ext": "js", "max_stars_repo_path": "addon/services/print-this.js", "max_stars_repo_name": "LucasHill/ember-print-this", "max_stars_repo_stars_event_min_datetime": "2017-04-03T07:22:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T02:26:50.000Z", "max_issues_repo_path": "addon/services/print-this.js", "max_issues_repo_name": "LucasHill/ember-print-this", "max_issues_repo_issues_event_min_datetime": "2017-08-14T03:25:41.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T23:14:18.000Z", "max_forks_repo_path": "addon/services/print-this.js", "max_forks_repo_name": "LucasHill/ember-print-this", "max_forks_repo_forks_event_min_datetime": "2017-05-09T02:59:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T06:46:12.000Z"}
{"max_stars_count": 12, "max_issues_count": 29, "max_forks_count": 8, "avg_line_length": 31.8, "max_line_length": 81, "alphanum_fraction": 0.6955974843}
import { assign } from '@ember/polyfills';
import { getOwner } from '@ember/application';
import $ from 'jquery';
import Service from '@ember/service';

export default Service.extend({
  print(printSelector, options, jQuery = $) {
    const environment = getOwner(this).resolveRegistration('config:environment');
    const mergedOptions = this._constructPrintOptions(environment, options);

    this._selectElement(printSelector, jQuery).printThis(mergedOptions);
  },

  _constructPrintOptions(environment = { rootURL: '/' }, userOptions = {}) {
    const base = environment.rootURL || environment.baseURL;
    const options = base === '/' ? { } : { base };
    
    return assign(options, userOptions);
  },

  _selectElement: function(toSelect, jQuery) {
    return jQuery(toSelect);
  }
});
