define('ember-overlays/components/create-overlay', ['exports', 'ember-overlays/templates/components/create-overlay', 'ember-overlays/raf', 'ember-overlays/transform', 'ember-concurrency', 'ember-overlays/bounds', 'ember-overlays/scrim-fader'], function (exports, _createOverlay, _raf, _transform, _emberConcurrency, _bounds, _scrimFader) {
  'use strict';

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = Ember.Component.extend({
    layout: _createOverlay.default,
    scrimFader: _scrimFader.default,
    classNames: ['show-overlay'],
    classNameBindings: ['reveal', 'hoverable', 'focused'],
    hovered: false,

    // TODO
    fieldScale: 1,

    _targetRect: function _targetRect() {
      var mark = this.get('at');
      return mark.bounds();
    },


    _waitForTargetRect: /*#__PURE__*/regeneratorRuntime.mark(function _waitForTargetRect() {
      var hiding, $elt, targetRect;
      return regeneratorRuntime.wrap(function _waitForTargetRect$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              hiding = false;
              $elt = this.$();

            case 2:
              targetRect = this._targetRect();

              if (!targetRect) {
                _context.next = 5;
                break;
              }

              return _context.abrupt('return', targetRect);

            case 5:
              if (!hiding) {
                $elt.css({ display: 'none' });
                hiding = true;
              }
              _context.next = 8;
              return (0, _raf.default)();

            case 8:
              _context.next = 2;
              break;

            case 10:
            case 'end':
              return _context.stop();
          }
        }
      }, _waitForTargetRect, this);
    }),

    _translation: function _translation(targetRect, ownRect, currentTransform) {
      return 'translateX(' + (targetRect.left - ownRect.left + currentTransform.tx) + 'px) translateY(' + (targetRect.top - ownRect.top + currentTransform.ty) + 'px)';
    },
    _matchWidth: function _matchWidth($elt, targetRect, ownRect) {
      return $elt.outerWidth() + targetRect.right - targetRect.left - ownRect.right + ownRect.left + 'px';
    },
    _matchHeight: function _matchHeight($elt, targetRect, ownRect) {
      return $elt.outerHeight() + targetRect.bottom - targetRect.top - ownRect.bottom + ownRect.top + 'px';
    },


    _track: (0, _emberConcurrency.task)( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
      var $elt, $ownTarget, lastTargetRect, targetRect, ownRect, t;
      return regeneratorRuntime.wrap(function _callee$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              $elt = this.$();
              $ownTarget = this.$('.target');
              lastTargetRect = void 0;

            case 3:
              return _context2.delegateYield(this._waitForTargetRect(), 't0', 4);

            case 4:
              targetRect = _context2.t0;

              if (!lastTargetRect || !(0, _bounds.boundsEqual)(targetRect, lastTargetRect)) {

                // position ourselves over the target
                ownRect = $ownTarget[0].getBoundingClientRect();
                t = (0, _transform.ownTransform)($elt[0]);

                $elt.css({
                  display: 'initial',
                  transform: this._translation(targetRect, ownRect, t) + ' scale(' + this.get('fieldScale') + ')'
                });
                $ownTarget.css({
                  width: this._matchWidth($ownTarget, targetRect, ownRect),
                  minHeight: this._matchHeight($ownTarget, targetRect, ownRect)
                });
                $elt.find('> label').css({
                  transform: 'translateY(-100%) scale(' + 1 / this.get('fieldScale') + ')'
                });
              }
              lastTargetRect = targetRect;
              _context2.next = 9;
              return (0, _raf.default)();

            case 9:
              if (!(this.get('lockWhileFocused') && this.get('focused'))) {
                _context2.next = 14;
                break;
              }

              _context2.next = 12;
              return (0, _raf.default)();

            case 12:
              _context2.next = 9;
              break;

            case 14:
              _context2.next = 3;
              break;

            case 16:
            case 'end':
              return _context2.stop();
          }
        }
      }, _callee, this);
    })).on('didInsertElement'),

    reveal: Ember.computed.or('hovered', 'highlighted', 'focused'),

    actions: {
      beginHover: function beginHover() {
        this.set('hovered', true);
      },
      endHover: function endHover() {
        this.set('hovered', false);
      },
      targetClicked: function targetClicked() {
        var handler = this.get('onclick');
        if (handler) {
          handler();
        }
      },
      dismiss: function dismiss() {
        var handler = this.get('dismiss');
        if (handler) {
          handler();
        }
      }
    }
  });
});