'use strict'
var _extends =
  Object.assign ||
  function(a) {
    for (var b, c = 1; c < arguments.length; c++)
      for (var d in ((b = arguments[c]), b))
        Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d])
    return a
  }
!(function(require, directRequire) {
  const a = require('react'),
    b = require('prop-types'),
    c = require('path'),
    { connect: d } = require('react-redux'),
    e = require('./fc137838572a83604db39acff8e909e0.js'),
    f = require('./1fcc6bd55b687d154a4247e57fe3011d.js'),
    g = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js'),
    h = require('./a8a5e64abb9f7f8caefeee1a1f0c9d3a.js'),
    i = require('./875171e7b864aa58d026d4fa0999fbd1.js'),
    j = require('classnames'),
    k = require('./ff946754202ecf377034d29daac7c8d9.js'),
    l = require('./56c390e04c10e91a4aa2a2c19d9a885d.js')
  class m extends a.Component {
    constructor(a) {
      super(a),
        (this.blinkObjects = {}),
        (this.state = { position: { left: 0, top: 0 } })
    }
    componentDidMount() {
      this.checkDropdownPosition()
    }
    componentDidUpdate(a) {
      this.context.isPopup &&
        !a.show &&
        this.props.show &&
        this.checkDropdownPosition()
    }
    checkDropdownPosition() {
      if (
        this.context.isPopup &&
        this.context.window &&
        this.props.left + 260 > this.context.window.width
      ) {
        let a = this.context.window.width - 260
        0 > a && (a = 0),
          this.setState({
            position: _extends({}, this.state.position, { left: a })
          })
      }
    }
    handleDropdownClick(a) {
      a.stopPropagation()
    }
    handleCopyClick(a) {
      let b = a.currentTarget.dataset.type,
        c = nw.Clipboard.get()
      c.set(this.props[b].toString())
      const d = this.blinkObjects[b]
      d &&
        ((d.style.opacity = '0.5'),
        !this._blinkTimeout &&
          (this._blinkTimeout = setTimeout(() => {
            ;(d.style.opacity = '1'), (this._blinkTimeout = null)
          }, 200))),
        this.props.showSuccessTip('\u590D\u5236\u6210\u529F')
    }
    handlePathOpenClick() {
      k.sendMessage(
        'EDITOR',
        JSON.stringify({
          type: 'COMMAND',
          command: 'openFile',
          data: {
            path: (
              '/' +
              c.posix.join(
                this.props.clientPath,
                (this.props.pathName || '') + '.js'
              )
            ).replace(/\/+/g, '/')
          }
        })
      )
    }
    render() {
      if (global.onlySimulator) return null
      let b = this.props
      return a.createElement(
        i,
        {
          show: b.show,
          style: {
            left: this.state.position.left || this.props.left,
            top: this.state.position.top || this.props.top,
            width: 260
          },
          inClassName: 'ui-popover',
          outClassName: 'ui-animate-fadeOut ui-popover'
        },
        a.createElement(
          'div',
          {
            className: 'ui-dropdown',
            onClick: this.handleDropdownClick.bind(this)
          },
          a.createElement(
            'div',
            { className: 'ui-dropdown-item' },
            a.createElement(
              'div',
              { className: 'ui-dropdown-item-bd' },
              a.createElement(
                'div',
                { className: 'ui-flex ui-dropdown-status-item' },
                a.createElement(
                  'label',
                  { htmlFor: '' },
                  '\u9875\u9762\u8DEF\u5F84'
                ),
                a.createElement(
                  'div',
                  { className: 'ui-flex-item' },
                  a.createElement(
                    'p',
                    {
                      ref: a => (this.blinkObjects.pathName = a),
                      className: 'ui-selectable',
                      title: b.pathName
                    },
                    b.pathName ? b.pathName : '(\u7A7A)'
                  )
                ),
                a.createElement(
                  'div',
                  null,
                  b.pathName
                    ? a.createElement(
                        'a',
                        {
                          onClick: this.handleCopyClick.bind(this),
                          'data-type': 'pathName'
                        },
                        '\u590D\u5236'
                      )
                    : null,
                  b.pathName
                    ? a.createElement(
                        'a',
                        { onClick: this.handlePathOpenClick.bind(this) },
                        '\u6253\u5F00'
                      )
                    : null
                )
              )
            )
          ),
          a.createElement(
            'div',
            { className: 'ui-dropdown-item' },
            a.createElement(
              'div',
              { className: 'ui-dropdown-item-bd' },
              a.createElement(
                'div',
                { className: 'ui-flex ui-dropdown-status-item' },
                a.createElement('label', { htmlFor: '' }, '\u573A\u666F\u503C'),
                a.createElement(
                  'div',
                  { className: 'ui-flex-item' },
                  a.createElement(
                    'p',
                    {
                      ref: a => (this.blinkObjects.scene = a),
                      className: 'ui-selectable'
                    },
                    b.scene ? b.scene : '(\u7A7A)',
                    b.scene ? b.sceneMap[b.scene] || '' : null
                  )
                )
              )
            )
          ),
          a.createElement(
            'div',
            { className: 'ui-dropdown-item' },
            a.createElement(
              'div',
              { className: 'ui-dropdown-item-bd' },
              a.createElement(
                'div',
                { className: 'ui-flex ui-dropdown-status-item' },
                a.createElement(
                  'label',
                  { htmlFor: '' },
                  '\u9875\u9762\u53C2\u6570'
                ),
                a.createElement(
                  'div',
                  { className: 'ui-flex-item' },
                  a.createElement(
                    'p',
                    {
                      ref: a => (this.blinkObjects.query = a),
                      className: 'ui-selectable'
                    },
                    b.query ? b.query : '(\u7A7A)'
                  ),
                  b.query
                    ? a.createElement(
                        'a',
                        {
                          onClick: this.handleCopyClick.bind(this),
                          'data-type': 'query'
                        },
                        '\u590D\u5236'
                      )
                    : null
                )
              )
            )
          )
        )
      )
    }
  }
  ;(m.contextTypes = { isPopup: b.bool, window: b.object }),
    (module.exports = d(
      a => {
        let b = a.simulator,
          c = b.scene,
          d = b.currentWebviewID,
          e = b.webviewInfos,
          f = (e && e[d]) || {},
          g = f.pathName || '',
          h = [],
          i = a.project,
          j = (i.current || {}).miniprogramRoot || ''
        for (let b in f.query) h.push(`${b}=${f.query[b]}`)
        return {
          scene: c,
          pathName: g,
          query: h.join('&'),
          sceneMap: a.config.sceneMap || [],
          clientPath: j
        }
      },
      a => {
        return { showSuccessTip: g.bindActionCreators(f.showSuccessTip, a) }
      }
    )(m))
})(require('lazyload'), require)
