/*! bxs-vue-ui v3.3.0 */
'use strict';

var normalizeComponent = require('./normalize-component.js');
var html = require('./html.js');

// `Object.keys` method
// https://tc39.github.io/ecma262/#sec-object.keys
var objectKeys = Object.keys || function keys(O) {
  return normalizeComponent.internalObjectKeys(O, normalizeComponent.enumBugKeys);
};

// `Object.defineProperties` method
// https://tc39.github.io/ecma262/#sec-object.defineproperties
var objectDefineProperties = normalizeComponent.DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  normalizeComponent.anObject(O);
  var keys = objectKeys(Properties);
  var length = keys.length;
  var index = 0;
  var key;
  while (length > index) normalizeComponent.definePropertyModule.f(O, key = keys[index++], Properties[key]);
  return O;
};

var IE_PROTO = normalizeComponent.sharedKey('IE_PROTO');

var PROTOTYPE = 'prototype';
var Empty = function () { /* empty */ };

// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
  // Thrash, waste and sodomy: IE GC bug
  var iframe = normalizeComponent.createElement('iframe');
  var length = normalizeComponent.enumBugKeys.length;
  var lt = '<';
  var script = 'script';
  var gt = '>';
  var js = 'java' + script + ':';
  var iframeDocument;
  iframe.style.display = 'none';
  html.html.appendChild(iframe);
  iframe.src = String(js);
  iframeDocument = iframe.contentWindow.document;
  iframeDocument.open();
  iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  iframeDocument.close();
  createDict = iframeDocument.F;
  while (length--) delete createDict[PROTOTYPE][normalizeComponent.enumBugKeys[length]];
  return createDict();
};

// `Object.create` method
// https://tc39.github.io/ecma262/#sec-object.create
var objectCreate = Object.create || function create(O, Properties) {
  var result;
  if (O !== null) {
    Empty[PROTOTYPE] = normalizeComponent.anObject(O);
    result = new Empty();
    Empty[PROTOTYPE] = null;
    // add "__proto__" for Object.getPrototypeOf polyfill
    result[IE_PROTO] = O;
  } else result = createDict();
  return Properties === undefined ? result : objectDefineProperties(result, Properties);
};

normalizeComponent.hiddenKeys[IE_PROTO] = true;

exports.create = objectCreate;
exports.defineProperties = objectDefineProperties;
exports.objectKeys = objectKeys;
