"use strict";

require("core-js/modules/web.dom-collections.iterator.js");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireWildcard(require("react"));

var THREE = _interopRequireWildcard(require("three"));

var _fiber = require("@react-three/fiber");

var _drei = require("@react-three/drei");

var _config = _interopRequireDefault(require("next/config"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const {
  publicRuntimeConfig
} = (0, _config.default)();

const Shoe = _ref => {
  var _File$Shoe5, _File$Shoe6, _modelShoe$nodes$;

  let {
    modelConfig,
    nodes,
    File,
    LOD
  } = _ref;
  let modelShoe;
  let shoeTextrue;
  let name;

  if (File !== null && File !== void 0 && File.Shoe) {
    var _File$Shoe, _File$Shoe3;

    if (File !== null && File !== void 0 && (_File$Shoe = File.Shoe) !== null && _File$Shoe !== void 0 && _File$Shoe.model) {
      var _File$Shoe2;

      modelShoe = (0, _drei.useGLTF)(File === null || File === void 0 ? void 0 : (_File$Shoe2 = File.Shoe) === null || _File$Shoe2 === void 0 ? void 0 : _File$Shoe2.model);
    }

    if (File !== null && File !== void 0 && (_File$Shoe3 = File.Shoe) !== null && _File$Shoe3 !== void 0 && _File$Shoe3.texture) {
      var _File$Shoe4;

      shoeTextrue = (0, _drei.useTexture)(File === null || File === void 0 ? void 0 : (_File$Shoe4 = File.Shoe) === null || _File$Shoe4 === void 0 ? void 0 : _File$Shoe4.texture);
    }
  }

  if (!(File !== null && File !== void 0 && (_File$Shoe5 = File.Shoe) !== null && _File$Shoe5 !== void 0 && _File$Shoe5.model) && modelConfig.Shoe.path) {
    modelShoe = (0, _drei.useGLTF)("".concat(publicRuntimeConfig.CONFIG.s3.endpoint).concat(modelConfig.Shoe.path));
  }

  if (!(File !== null && File !== void 0 && (_File$Shoe6 = File.Shoe) !== null && _File$Shoe6 !== void 0 && _File$Shoe6.texture) && modelConfig.Shoe.texture_path) {
    shoeTextrue = (0, _drei.useTexture)("".concat(publicRuntimeConfig.CONFIG.s3.endpoint).concat(modelConfig.Shoe.texture_path));
  }

  if (shoeTextrue) {
    shoeTextrue.flipY = false;
  }

  modelShoe && modelShoe.scene.traverse(c => {
    if (c.type == "SkinnedMesh") {
      name = c.name;
    }
  });
  return /*#__PURE__*/_react.default.createElement("group", {
    dispose: null
  }, modelShoe && /*#__PURE__*/_react.default.createElement("skinnedMesh", {
    skeleton: nodes["Shoe_001_LOD".concat(LOD, "_GEO")].skeleton,
    geometry: (_modelShoe$nodes$ = modelShoe.nodes["".concat(name)]) === null || _modelShoe$nodes$ === void 0 ? void 0 : _modelShoe$nodes$.geometry,
    frustumCulled: false,
    castShadow: true
  }, shoeTextrue && /*#__PURE__*/_react.default.createElement("meshStandardMaterial", {
    attach: "material",
    map: shoeTextrue
  })));
};

var _default = Shoe;
exports.default = _default;