"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TCModelFactory=void 0;var core_1=require("@iabtechlabtcf/core"),makeRandomInt_js_1=require("./makeRandomInt.js"),GVLFactory_js_1=require("./GVLFactory.js"),TCModelFactory=function(){function e(){}return e.noGVL=function(e){return this.createBaseTCModel(e)},e.createBaseTCModel=function(e){var n=e||GVLFactory_js_1.GVLFactory.getLatest(),t=new core_1.TCModel;t.cmpId=(0,makeRandomInt_js_1.makeRandomInt)(2,100),t.cmpVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,10),t.consentScreen=(0,makeRandomInt_js_1.makeRandomInt)(1,5),t.isServiceSpecific=!!(0,makeRandomInt_js_1.makeRandomInt)(0,1),t.vendorListVersion=(0,makeRandomInt_js_1.makeRandomInt)(1,n.vendorListVersion);var o=0,a=(0,makeRandomInt_js_1.makeRandomInt)(1,core_1.TCModel.consentLanguages.size);core_1.TCModel.consentLanguages.forEach((function(e){++o===a&&(t.consentLanguage=e)})),t.publisherCountryCode=String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90))+String.fromCharCode((0,makeRandomInt_js_1.makeRandomInt)(65,90));var r=new Date,s=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())).getTime();t.created=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,s)),t.lastUpdated=new Date((0,makeRandomInt_js_1.makeRandomInt)(1576883249,s));var c={purposes:["publisherConsents","publisherLegitimateInterests","purposeConsents","purposeLegitimateInterests"],specialFeatures:["specialFeatureOptins"],vendors:["vendorConsents","vendorLegitimateInterests","vendorsAllowed","vendorsDisclosed"]};return Object.keys(c).forEach((function(e){Object.keys(n[e]).map((function(e){return+e})).forEach((function(n){c[e].forEach((function(e){3!==(0,makeRandomInt_js_1.makeRandomInt)(1,4)&&t[e].set(n)}))}))})),t},e.addPublisherRestrictions=function(e,n){return e.gvl||(e.gvl=n||GVLFactory_js_1.GVLFactory.getLatest()),Object.keys(e.gvl.vendors).forEach((function(n){var t=e.gvl.vendors[n];if(t.flexiblePurposes.length){var o=t.flexiblePurposes[(0,makeRandomInt_js_1.makeRandomInt)(0,t.flexiblePurposes.length-1)],a=t.purposes.includes(o),r=void 0;r=1===(0,makeRandomInt_js_1.makeRandomInt)(0,1)?new core_1.PurposeRestriction(o,core_1.RestrictionType.NOT_ALLOWED):a?new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_LI):new core_1.PurposeRestriction(o,core_1.RestrictionType.REQUIRE_CONSENT),e.publisherRestrictions.add(+n,r)}})),e},e.withGVL=function(e){var n=this.createBaseTCModel(e);return n.gvl=e||GVLFactory_js_1.GVLFactory.getLatest(),n},e}();exports.TCModelFactory=TCModelFactory;