text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.uintCV = exports.intCV = void 0;
  const BigNum = require("bn.js");
  const constants_1 = require("../../constants");
  const clarityValue_1 = require("../clarityValue");
  const intCV = (value) => {
      const bn = new BigNum(value);
      const twos = bn.toTwos(constants_1.CLARITY_INT_SIZE);
      if (twos.bitLength() > constants_1.CLARITY_INT_SIZE) {
          throw new Error('Cannot construct clarity integer from value greater than INT_SIZE bits');
      }
      return { type: clarityValue_1.ClarityType.Int, value: twos };
  };
  exports.intCV = intCV;
  const uintCV = (value) => {
      const bn = new BigNum(value);
      const twos = bn.toTwos(constants_1.CLARITY_INT_SIZE);
      if (twos.isNeg()) {
          throw new Error('Cannot construct unsigned clarity integer from negative value');
      }
      else if (twos.bitLength() > constants_1.CLARITY_INT_SIZE) {
          throw new Error('Cannot construct unsigned clarity integer from value greater than 128 bits');
      }
      return { type: clarityValue_1.ClarityType.UInt, value: twos };
  };
  exports.uintCV = uintCV;
  //# sourceMappingURL=intCV.js.map