<commit_before>import { oneWay, readOnly } from '@ember/object/computed';
import Component from '@ember/component';
import { dasherize } from '@ember/string';
import { computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { inject as service } from '@ember/service';
import layout from '../templates/components/modal-dialog';
import { warn } from '@ember/debug';
import { DEBUG } from '@glimmer/env';

const VALID_OVERLAY_POSITIONS = ['parent', 'sibling'];

export default Component.extend({
  tagName: '',
  layout,
  modalService: service('modal-dialog'),
  destinationElementId: null,

  init() {
    this._super(...arguments);
    if (!this.get('destinationElementId')) {
      this.set('destinationElementId', this.get('modalService.destinationElementId'));
    }
  },

  modalDialogComponentName: computed('renderInPlace', 'tetherTarget', 'animatable', 'hasLiquidWormhole', 'hasLiquidTether', function(){
    let tetherTarget = this.get('tetherTarget');
    let hasLiquidTether = this.get('hasLiquidTether');
    let hasLiquidWormhole = this.get('hasLiquidWormhole');
    let animatable = this.get('animatable');

    if (this.get('renderInPlace')) {
      return 'ember-modal-dialog/-in-place-dialog';
    } else if (tetherTarget && hasLiquidTether && hasLiquidWormhole && animatable === true) {
      return 'ember-modal-dialog/-liquid-tether-dialog';
    } else if (tetherTarget) {
      this.ensureEmberTetherPresent();
      return 'ember-modal-dialog/-tether-dialog';
    } else if (hasLiquidWormhole && animatable === true) {
      return 'ember-modal-dialog/-liquid-dialog';
    }
    return 'ember-modal-dialog/-basic-dialog';
  }),
  animatable: null,
  hasLiquidWormhole: readOnly('modalService.hasLiquidWormhole'),
  hasLiquidTether: readOnly('modalService.hasLiquidTether'),

  didReceiveAttrs() {
    this._super(...arguments);
    if (DEBUG) {
      this.validateProps();
    }
  },
  validateProps() {
    let overlayPosition = this.get('overlayPosition');
    if (VALID_OVERLAY_POSITIONS.indexOf(overlayPosition) === -1) {
      warn(
        `overlayPosition value '${overlayPosition}' is not valid (valid values [${VALID_OVERLAY_POSITIONS.join(', ')}])`,
        false,
        { id: 'ember-modal-dialog.validate-overlay-position'}
      );
    }
  },
  // onClose - set this from templates

  /* eslint-disable ember/avoid-leaking-state-in-ember-objects */

  // containerClass - set this from templates
  containerClassNames: ['ember-modal-dialog'], // set this in a subclass definition

  // overlayClass - set this from templates
  overlayClassNames: ['ember-modal-overlay'], // set this in a subclass definition

  // wrapperClass - set this from templates
  wrapperClassNames: ['ember-modal-wrapper'], // set this in a subclass definition

  concatenatedProperties: ['containerClassNames', 'overlayClassNames', 'wrapperClassNames'],
  /* eslint-enable ember/avoid-leaking-state-in-ember-objects */

  hasOverlay: true,
  translucentOverlay: false,
  overlayPosition: 'parent', // `parent` or `sibling`
  clickOutsideToClose: false,
  renderInPlace: false,
  tetherTarget: null,
  stack: oneWay('elementId'), // pass a `stack` string to set a "stack" to be passed to liquid-wormhole / liquid-tether
  value: 0, // pass a `value` to set a "value" to be passed to liquid-wormhole / liquid-tether

  targetAttachment: 'middle center',
  tetherClassPrefix: null,
  attachmentClass: computed('attachment', function() {
    let attachment = this.get('attachment');
    if (isEmpty(attachment)) {
      return;
    }
    return attachment.split(' ').map((attachmentPart) => {
      return `emd-attachment-${dasherize(attachmentPart)}`;
    }).join(' ');
  }),
  targetAttachmentClass: computed('targetAttachment', function() {
    let targetAttachment = this.get('targetAttachment') || '';
    // Convert tether-styled values like 'middle right' to 'right'
    targetAttachment = targetAttachment.split(' ').slice(-1)[0];
    return `ember-modal-dialog-target-attachment-${dasherize(targetAttachment)} emd-target-attachment-${dasherize(targetAttachment)}`;
  }),
  ensureEmberTetherPresent() {
    if (!this.get('modalService.hasEmberTether')) {
      throw new Error('Please install ember-tether in order to pass a tetherTarget to modal-dialog');
    }
  },
  actions: {
    onClose() {
      if (this.get('onClose')) {
        this.get('onClose')();
      }
    },
    onClickOverlay(e) {
      e.preventDefault();
      if (this.get('onClickOverlay')) {
        this.get('onClickOverlay')();
      } else {
        if (this.get('onClose')) {
          this.get('onClose')();
        }
      }<commit_msg>check type function for action callbacks<commit_after>import { oneWay, readOnly } from '@ember/object/computed';
import Component from '@ember/component';
import { dasherize } from '@ember/string';
import { computed } from '@ember/object';
import { isEmpty, typeOf } from '@ember/utils';
import { inject as service } from '@ember/service';
import layout from '../templates/components/modal-dialog';
import { warn } from '@ember/debug';
import { DEBUG } from '@glimmer/env';

const VALID_OVERLAY_POSITIONS = ['parent', 'sibling'];

export default Component.extend({
  tagName: '',
  layout,
  modalService: service('modal-dialog'),
  destinationElementId: null,

  init() {
    this._super(...arguments);
    if (!this.get('destinationElementId')) {
      this.set('destinationElementId', this.get('modalService.destinationElementId'));
    }
  },

  modalDialogComponentName: computed('renderInPlace', 'tetherTarget', 'animatable', 'hasLiquidWormhole', 'hasLiquidTether', function(){
    let tetherTarget = this.get('tetherTarget');
    let hasLiquidTether = this.get('hasLiquidTether');
    let hasLiquidWormhole = this.get('hasLiquidWormhole');
    let animatable = this.get('animatable');

    if (this.get('renderInPlace')) {
      return 'ember-modal-dialog/-in-place-dialog';
    } else if (tetherTarget && hasLiquidTether && hasLiquidWormhole && animatable === true) {
      return 'ember-modal-dialog/-liquid-tether-dialog';
    } else if (tetherTarget) {
      this.ensureEmberTetherPresent();
      return 'ember-modal-dialog/-tether-dialog';
    } else if (hasLiquidWormhole && animatable === true) {
      return 'ember-modal-dialog/-liquid-dialog';
    }
    return 'ember-modal-dialog/-basic-dialog';
  }),
  animatable: null,
  hasLiquidWormhole: readOnly('modalService.hasLiquidWormhole'),
  hasLiquidTether: readOnly('modalService.hasLiquidTether'),

  didReceiveAttrs() {
    this._super(...arguments);
    if (DEBUG) {
      this.validateProps();
    }
  },
  validateProps() {
    let overlayPosition = this.get('overlayPosition');
    if (VALID_OVERLAY_POSITIONS.indexOf(overlayPosition) === -1) {
      warn(
        `overlayPosition value '${overlayPosition}' is not valid (valid values [${VALID_OVERLAY_POSITIONS.join(', ')}])`,
        false,
        { id: 'ember-modal-dialog.validate-overlay-position'}
      );
    }
  },
  // onClose - set this from templates

  /* eslint-disable ember/avoid-leaking-state-in-ember-objects */

  // containerClass - set this from templates
  containerClassNames: ['ember-modal-dialog'], // set this in a subclass definition

  // overlayClass - set this from templates
  overlayClassNames: ['ember-modal-overlay'], // set this in a subclass definition

  // wrapperClass - set this from templates
  wrapperClassNames: ['ember-modal-wrapper'], // set this in a subclass definition

  concatenatedProperties: ['containerClassNames', 'overlayClassNames', 'wrapperClassNames'],
  /* eslint-enable ember/avoid-leaking-state-in-ember-objects */

  hasOverlay: true,
  translucentOverlay: false,
  overlayPosition: 'parent', // `parent` or `sibling`
  clickOutsideToClose: false,
  renderInPlace: false,
  tetherTarget: null,
  stack: oneWay('elementId'), // pass a `stack` string to set a "stack" to be passed to liquid-wormhole / liquid-tether
  value: 0, // pass a `value` to set a "value" to be passed to liquid-wormhole / liquid-tether

  targetAttachment: 'middle center',
  tetherClassPrefix: null,
  attachmentClass: computed('attachment', function() {
    let attachment = this.get('attachment');
    if (isEmpty(attachment)) {
      return;
    }
    return attachment.split(' ').map((attachmentPart) => {
      return `emd-attachment-${dasherize(attachmentPart)}`;
    }).join(' ');
  }),
  targetAttachmentClass: computed('targetAttachment', function() {
    let targetAttachment = this.get('targetAttachment') || '';
    // Convert tether-styled values like 'middle right' to 'right'
    targetAttachment = targetAttachment.split(' ').slice(-1)[0];
    return `ember-modal-dialog-target-attachment-${dasherize(targetAttachment)} emd-target-attachment-${dasherize(targetAttachment)}`;
  }),
  ensureEmberTetherPresent() {
    if (!this.get('modalService.hasEmberTether')) {
      throw new Error('Please install ember-tether in order to pass a tetherTarget to modal-dialog');
    }
  },
  actions: {
    onClose() {
      if (typeOf(this.get('onClose')) === 'function') {
        this.get('onClose')();
      }
    },
    onClickOverlay(e) {
      e.preventDefault();
      if (typeof(this.get('onClickOverlay')) === 'function') {
        this.get('onClickOverlay')();
      } else {
        if (typeof(this.get('onClose')) === 'function') {
          this.get('onClose')();
        }
      }
{'fraction_non_alphanumeric': 0.14910790144435004, 'fraction_numerical': 0.0008496176720475786, 'mean_word_length': 3.8267555099948742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1533805', 'n_tokens_mistral': 2879, 'n_tokens_neox': 2845, 'n_words': 617}