text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var tslib_1 = require("tslib");
  var manipulation_1 = require("../../../manipulation");
  var getStructureFuncs = require("../../../manipulation/helpers/getStructureFunctions");
  var typescript_1 = require("../../../typescript");
  var base_1 = require("../base");
  var callBaseSet_1 = require("../callBaseSet");
  var common_1 = require("../common");
  var function_1 = require("../function");
  var callBaseGetStructure_1 = require("../callBaseGetStructure");
  exports.ConstructorDeclarationBase = base_1.ChildOrderableNode(base_1.TextInsertableNode(function_1.OverloadableNode(base_1.ScopedNode(function_1.FunctionLikeDeclaration(base_1.BodyableNode(common_1.Node))))));
  exports.ConstructorDeclarationOverloadBase = base_1.TypeParameteredNode(base_1.JSDocableNode(base_1.ChildOrderableNode(base_1.TextInsertableNode(base_1.ScopedNode(base_1.ModifierableNode(base_1.SignaturedDeclaration(common_1.Node)))))));
  var ConstructorDeclaration = /** @class */ (function (_super) {
      tslib_1.__extends(ConstructorDeclaration, _super);
      function ConstructorDeclaration() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      /**
       * Sets the node from a structure.
       * @param structure - Structure to set the node with.
       */
      ConstructorDeclaration.prototype.set = function (structure) {
          callBaseSet_1.callBaseSet(exports.ConstructorDeclarationBase.prototype, this, structure);
          if (structure.overloads != null) {
              this.getOverloads().forEach(function (o) { return o.remove(); });
              this.addOverloads(structure.overloads);
          }
          return this;
      };
      /**
       * Add a constructor overload.
       * @param structure - Structure to add.
       */
      ConstructorDeclaration.prototype.addOverload = function (structure) {
          return this.addOverloads([structure])[0];
      };
      /**
       * Add constructor overloads.
       * @param structures - Structures to add.
       */
      ConstructorDeclaration.prototype.addOverloads = function (structures) {
          return this.insertOverloads(this.getOverloads().length, structures);
      };
      /**
       * Inserts a constructor overload.
       * @param index - Child index to insert at.
       * @param structure - Structures to insert.
       */
      ConstructorDeclaration.prototype.insertOverload = function (index, structure) {
          return this.insertOverloads(index, [structure])[0];
      };
      /**
       * Inserts constructor overloads.
       * @param index - Child index to insert at.
       * @param structures - Structures to insert.
       */
      ConstructorDeclaration.prototype.insertOverloads = function (index, structures) {
          var childCodes = structures.map(function (structure) { return "constructor();"; });
          return function_1.insertOverloads({
              node: this,
              index: index,
              structures: structures,
              childCodes: childCodes,
              getThisStructure: getStructureFuncs.fromConstructorDeclarationOverload,
              setNodeFromStructure: function (node, structure) { return node.set(structure); },
              expectedSyntaxKind: typescript_1.SyntaxKind.Constructor
          });
      };
      /**
       * Remove the constructor.
       */
      ConstructorDeclaration.prototype.remove = function () {
          manipulation_1.removeOverloadableClassMember(this);
      };
      /**
       * Gets the structure equivalent to this node.
       */
      ConstructorDeclaration.prototype.getStructure = function () {
          var hasImplementation = this.getImplementation() != null;
          var isOverload = this.isOverload();
          var basePrototype = isOverload && hasImplementation ? exports.ConstructorDeclarationOverloadBase.prototype : exports.ConstructorDeclarationBase.prototype;
          var structure = !hasImplementation || isOverload ? {} : { overloads: this.getOverloads().map(function (o) { return o.getStructure(); }) };
          return callBaseGetStructure_1.callBaseGetStructure(basePrototype, this, structure);
      };
      return ConstructorDeclaration;
  }(exports.ConstructorDeclarationBase));
  exports.ConstructorDeclaration = ConstructorDeclaration;
  