"use strict";
/* eslint-disable-next-line no-unused-vars */
function __export(m) {
/* eslint-disable-next-line no-prototype-builtins */
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable-next-line no-unused-vars */
var jtv = require('@mojotech/json-type-validation');
/* eslint-disable-next-line no-unused-vars */
var damlTypes = require('@daml/types');

var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = require('../../../../DA/Internal/Template');

var Fairmint_OpenCapTable_Types_Core = require('../../../../Fairmint/OpenCapTable/Types/Core/module');


exports.OcfVestingCondition = {
  decoder: damlTypes.lazyMemo(function () { return jtv.object({id: damlTypes.Text.decoder, trigger: exports.OcfVestingTrigger.decoder, next_condition_ids: damlTypes.List(damlTypes.Text).decoder, description: jtv.Decoder.withDefault(null, damlTypes.Optional(damlTypes.Text).decoder), portion: jtv.Decoder.withDefault(null, damlTypes.Optional(exports.OcfVestingConditionPortion).decoder), quantity: jtv.Decoder.withDefault(null, damlTypes.Optional(damlTypes.Numeric(10)).decoder), }); }),
  encode: function (__typed__) {
  return {
    id: damlTypes.Text.encode(__typed__.id),
    trigger: exports.OcfVestingTrigger.encode(__typed__.trigger),
    next_condition_ids: damlTypes.List(damlTypes.Text).encode(__typed__.next_condition_ids),
    description: damlTypes.Optional(damlTypes.Text).encode(__typed__.description),
    portion: damlTypes.Optional(exports.OcfVestingConditionPortion).encode(__typed__.portion),
    quantity: damlTypes.Optional(damlTypes.Numeric(10)).encode(__typed__.quantity),
  };
}
,
};



exports.OcfVestingConditionPortion = {
  decoder: damlTypes.lazyMemo(function () { return jtv.object({numerator: damlTypes.Numeric(10).decoder, denominator: damlTypes.Numeric(10).decoder, remainder: damlTypes.Bool.decoder, }); }),
  encode: function (__typed__) {
  return {
    numerator: damlTypes.Numeric(10).encode(__typed__.numerator),
    denominator: damlTypes.Numeric(10).encode(__typed__.denominator),
    remainder: damlTypes.Bool.encode(__typed__.remainder),
  };
}
,
};



exports.OcfVestingTrigger = {
  decoder: damlTypes.lazyMemo(function () { return jtv.oneOf(jtv.object({tag: jtv.constant('OcfVestingStartTrigger'), value: damlTypes.Unit.decoder, }), jtv.object({tag: jtv.constant('OcfVestingScheduleAbsoluteTrigger'), value: exports.OcfVestingTrigger.OcfVestingScheduleAbsoluteTrigger.decoder, }), jtv.object({tag: jtv.constant('OcfVestingScheduleRelativeTrigger'), value: exports.OcfVestingTrigger.OcfVestingScheduleRelativeTrigger.decoder, }), jtv.object({tag: jtv.constant('OcfVestingEventTrigger'), value: damlTypes.Unit.decoder, })); }),
  encode: function (__typed__) {
  switch(__typed__.tag) {
    case 'OcfVestingStartTrigger': return {tag: __typed__.tag, value: damlTypes.Unit.encode(__typed__.value)};
    case 'OcfVestingScheduleAbsoluteTrigger': return {tag: __typed__.tag, value: exports.OcfVestingTrigger.OcfVestingScheduleAbsoluteTrigger.encode(__typed__.value)};
    case 'OcfVestingScheduleRelativeTrigger': return {tag: __typed__.tag, value: exports.OcfVestingTrigger.OcfVestingScheduleRelativeTrigger.encode(__typed__.value)};
    case 'OcfVestingEventTrigger': return {tag: __typed__.tag, value: damlTypes.Unit.encode(__typed__.value)};
    default: throw 'unrecognized type tag: ' + __typed__.tag + ' while serializing a value of type OcfVestingTrigger';
  }
}
,
  OcfVestingScheduleAbsoluteTrigger:({
    decoder: damlTypes.lazyMemo(function () { return jtv.object({date: damlTypes.Time.decoder, }); }),
    encode: function (__typed__) {
  return {
    date: damlTypes.Time.encode(__typed__.date),
  };
}
,
  }),
  OcfVestingScheduleRelativeTrigger:({
    decoder: damlTypes.lazyMemo(function () { return jtv.object({period: exports.OcfVestingPeriod.decoder, relative_to_condition_id: damlTypes.Text.decoder, }); }),
    encode: function (__typed__) {
  return {
    period: exports.OcfVestingPeriod.encode(__typed__.period),
    relative_to_condition_id: damlTypes.Text.encode(__typed__.relative_to_condition_id),
  };
}
,
  }),
};







exports.OcfVestingPeriod = {
  decoder: damlTypes.lazyMemo(function () { return jtv.oneOf(jtv.object({tag: jtv.constant('OcfVestingPeriodDays'), value: exports.OcfVestingPeriod.OcfVestingPeriodDays.decoder, }), jtv.object({tag: jtv.constant('OcfVestingPeriodMonths'), value: exports.OcfVestingPeriod.OcfVestingPeriodMonths.decoder, })); }),
  encode: function (__typed__) {
  switch(__typed__.tag) {
    case 'OcfVestingPeriodDays': return {tag: __typed__.tag, value: exports.OcfVestingPeriod.OcfVestingPeriodDays.encode(__typed__.value)};
    case 'OcfVestingPeriodMonths': return {tag: __typed__.tag, value: exports.OcfVestingPeriod.OcfVestingPeriodMonths.encode(__typed__.value)};
    default: throw 'unrecognized type tag: ' + __typed__.tag + ' while serializing a value of type OcfVestingPeriod';
  }
}
,
  OcfVestingPeriodDays:({
    decoder: damlTypes.lazyMemo(function () { return jtv.object({length_: damlTypes.Int.decoder, occurrences: damlTypes.Int.decoder, cliff_installment: jtv.Decoder.withDefault(null, damlTypes.Optional(damlTypes.Int).decoder), }); }),
    encode: function (__typed__) {
  return {
    length_: damlTypes.Int.encode(__typed__.length_),
    occurrences: damlTypes.Int.encode(__typed__.occurrences),
    cliff_installment: damlTypes.Optional(damlTypes.Int).encode(__typed__.cliff_installment),
  };
}
,
  }),
  OcfVestingPeriodMonths:({
    decoder: damlTypes.lazyMemo(function () { return jtv.object({length_: damlTypes.Int.decoder, occurrences: damlTypes.Int.decoder, day_of_month: exports.OcfVestingDayOfMonth.decoder, cliff_installment: jtv.Decoder.withDefault(null, damlTypes.Optional(damlTypes.Int).decoder), }); }),
    encode: function (__typed__) {
  return {
    length_: damlTypes.Int.encode(__typed__.length_),
    occurrences: damlTypes.Int.encode(__typed__.occurrences),
    day_of_month: exports.OcfVestingDayOfMonth.encode(__typed__.day_of_month),
    cliff_installment: damlTypes.Optional(damlTypes.Int).encode(__typed__.cliff_installment),
  };
}
,
  }),
};







exports.OcfVestingDayOfMonth = {
  OcfVestingDay01: 'OcfVestingDay01',
  OcfVestingDay02: 'OcfVestingDay02',
  OcfVestingDay03: 'OcfVestingDay03',
  OcfVestingDay04: 'OcfVestingDay04',
  OcfVestingDay05: 'OcfVestingDay05',
  OcfVestingDay06: 'OcfVestingDay06',
  OcfVestingDay07: 'OcfVestingDay07',
  OcfVestingDay08: 'OcfVestingDay08',
  OcfVestingDay09: 'OcfVestingDay09',
  OcfVestingDay10: 'OcfVestingDay10',
  OcfVestingDay11: 'OcfVestingDay11',
  OcfVestingDay12: 'OcfVestingDay12',
  OcfVestingDay13: 'OcfVestingDay13',
  OcfVestingDay14: 'OcfVestingDay14',
  OcfVestingDay15: 'OcfVestingDay15',
  OcfVestingDay16: 'OcfVestingDay16',
  OcfVestingDay17: 'OcfVestingDay17',
  OcfVestingDay18: 'OcfVestingDay18',
  OcfVestingDay19: 'OcfVestingDay19',
  OcfVestingDay20: 'OcfVestingDay20',
  OcfVestingDay21: 'OcfVestingDay21',
  OcfVestingDay22: 'OcfVestingDay22',
  OcfVestingDay23: 'OcfVestingDay23',
  OcfVestingDay24: 'OcfVestingDay24',
  OcfVestingDay25: 'OcfVestingDay25',
  OcfVestingDay26: 'OcfVestingDay26',
  OcfVestingDay27: 'OcfVestingDay27',
  OcfVestingDay28: 'OcfVestingDay28',
  OcfVestingDay29OrLast: 'OcfVestingDay29OrLast',
  OcfVestingDay30OrLast: 'OcfVestingDay30OrLast',
  OcfVestingDay31OrLast: 'OcfVestingDay31OrLast',
  OcfVestingStartDayOrLast: 'OcfVestingStartDayOrLast',
  keys: ['OcfVestingDay01','OcfVestingDay02','OcfVestingDay03','OcfVestingDay04','OcfVestingDay05','OcfVestingDay06','OcfVestingDay07','OcfVestingDay08','OcfVestingDay09','OcfVestingDay10','OcfVestingDay11','OcfVestingDay12','OcfVestingDay13','OcfVestingDay14','OcfVestingDay15','OcfVestingDay16','OcfVestingDay17','OcfVestingDay18','OcfVestingDay19','OcfVestingDay20','OcfVestingDay21','OcfVestingDay22','OcfVestingDay23','OcfVestingDay24','OcfVestingDay25','OcfVestingDay26','OcfVestingDay27','OcfVestingDay28','OcfVestingDay29OrLast','OcfVestingDay30OrLast','OcfVestingDay31OrLast','OcfVestingStartDayOrLast',],
  decoder: damlTypes.lazyMemo(function () { return jtv.oneOf(jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay01), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay02), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay03), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay04), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay05), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay06), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay07), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay08), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay09), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay10), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay11), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay12), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay13), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay14), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay15), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay16), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay17), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay18), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay19), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay20), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay21), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay22), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay23), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay24), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay25), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay26), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay27), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay28), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay29OrLast), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay30OrLast), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingDay31OrLast), jtv.constant(exports.OcfVestingDayOfMonth.OcfVestingStartDayOrLast)); }),
  encode: function (__typed__) { return __typed__; },
};



exports.OcfAllocationType = {
  OcfAllocationCumulativeRounding: 'OcfAllocationCumulativeRounding',
  OcfAllocationCumulativeRoundDown: 'OcfAllocationCumulativeRoundDown',
  OcfAllocationFrontLoaded: 'OcfAllocationFrontLoaded',
  OcfAllocationBackLoaded: 'OcfAllocationBackLoaded',
  OcfAllocationFrontLoadedToSingleTranche: 'OcfAllocationFrontLoadedToSingleTranche',
  OcfAllocationBackLoadedToSingleTranche: 'OcfAllocationBackLoadedToSingleTranche',
  OcfAllocationFractional: 'OcfAllocationFractional',
  keys: ['OcfAllocationCumulativeRounding','OcfAllocationCumulativeRoundDown','OcfAllocationFrontLoaded','OcfAllocationBackLoaded','OcfAllocationFrontLoadedToSingleTranche','OcfAllocationBackLoadedToSingleTranche','OcfAllocationFractional',],
  decoder: damlTypes.lazyMemo(function () { return jtv.oneOf(jtv.constant(exports.OcfAllocationType.OcfAllocationCumulativeRounding), jtv.constant(exports.OcfAllocationType.OcfAllocationCumulativeRoundDown), jtv.constant(exports.OcfAllocationType.OcfAllocationFrontLoaded), jtv.constant(exports.OcfAllocationType.OcfAllocationBackLoaded), jtv.constant(exports.OcfAllocationType.OcfAllocationFrontLoadedToSingleTranche), jtv.constant(exports.OcfAllocationType.OcfAllocationBackLoadedToSingleTranche), jtv.constant(exports.OcfAllocationType.OcfAllocationFractional)); }),
  encode: function (__typed__) { return __typed__; },
};



exports.VestingTermsOcfData = {
  decoder: damlTypes.lazyMemo(function () { return jtv.object({id: damlTypes.Text.decoder, allocation_type: exports.OcfAllocationType.decoder, description: damlTypes.Text.decoder, name: damlTypes.Text.decoder, comments: damlTypes.List(damlTypes.Text).decoder, vesting_conditions: damlTypes.List(exports.OcfVestingCondition).decoder, }); }),
  encode: function (__typed__) {
  return {
    id: damlTypes.Text.encode(__typed__.id),
    allocation_type: exports.OcfAllocationType.encode(__typed__.allocation_type),
    description: damlTypes.Text.encode(__typed__.description),
    name: damlTypes.Text.encode(__typed__.name),
    comments: damlTypes.List(damlTypes.Text).encode(__typed__.comments),
    vesting_conditions: damlTypes.List(exports.OcfVestingCondition).encode(__typed__.vesting_conditions),
  };
}
,
};



exports.VestingTerms = damlTypes.assembleTemplate(
{
  templateId: '#OpenCapTable-v32:Fairmint.OpenCapTable.OCF.VestingTerms:VestingTerms',
  templateIdWithPackageId: 'a27d41ef28900c05b37cfa7dcec7fff43819ef9f5803e1e1c66ed3152c5d5401:Fairmint.OpenCapTable.OCF.VestingTerms:VestingTerms',
  keyDecoder: damlTypes.lazyMemo(function () { return jtv.constant(undefined); }),
  keyEncode: function () { throw 'EncodeError'; },
  decoder: damlTypes.lazyMemo(function () { return jtv.object({context: Fairmint_OpenCapTable_Types_Core.Context.decoder, vesting_terms_data: exports.VestingTermsOcfData.decoder, }); }),
  encode: function (__typed__) {
  return {
    context: Fairmint_OpenCapTable_Types_Core.Context.encode(__typed__.context),
    vesting_terms_data: exports.VestingTermsOcfData.encode(__typed__.vesting_terms_data),
  };
}
,
  Archive: {
    template: function () { return exports.VestingTerms; },
    choiceName: 'Archive',
    argumentDecoder: damlTypes.lazyMemo(function () { return pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69.DA.Internal.Template.Archive.decoder; }),
    argumentEncode: function (__typed__) { return pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69.DA.Internal.Template.Archive.encode(__typed__); },
    resultDecoder: damlTypes.lazyMemo(function () { return damlTypes.Unit.decoder; }),
    resultEncode: function (__typed__) { return damlTypes.Unit.encode(__typed__); },
  },
}

);


damlTypes.registerTemplate(exports.VestingTerms, ['a27d41ef28900c05b37cfa7dcec7fff43819ef9f5803e1e1c66ed3152c5d5401', '#OpenCapTable-v32']);

