define(["require","exports","tslib","../deps/bluebird_fork","../definition/ProgramInspector","../execution/ActivityLoader","../Activator","./ProgramRunner","../licensing/LicenseChecker","../LanguageStringUtils","../Task"],function(e,t,i,a,o,r,s,l,c,n,m){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),a=i.__importDefault(a);var u=(g.buildOptions=function(e,t){(t=i.__assign({},t||{})).locale=o.canonicalizeLocale(t.locale),t.locale||(t.locale=e.getDefaultLocale());var r=n.getStringsForProgram(e,t);return t.environment=i.__assign({encodeHtml:function(e){return"string"==typeof e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},getText:function(e){if("string"==typeof e&&"@"===e.charAt(0)){var t=e.slice(1);if(t in r)return r[t]}return e},strings:r},t.environment||{}),t},g.prototype.createHandler=function(e,t){var r=this.implementations[e];if(void 0!==r){r=a.default.resolve(r);return r.isFulfilled()?new(r.value()):r.then(function(e){return a.default.attempt(function(){return new e})})}for(var n=0,i=this.factories;n<i.length;n++){var o=i[n].create(e,this._registerFormElement,t);if(void 0!==o)return o}},g.prototype.run=function(r,n){var i=this;return m.Task.attempt(function(){var e;r instanceof o.ProgramInspector?e=r:(e=new o.ProgramInspector).import(r),c.check(e.program,i.appSkuCode),n=g.buildOptions(e,n);var t=e.resolveStart(n?n.start:void 0);return l.run(i,e,n,t)})},g);function g(e){var n=this;this._getFormElementRegistration=function(e){return n.formElements[e]},this._registerFormElement=function(e){var t,r=e.id;n.formElements[r]?(t=i.__assign(i.__assign({},n.formElements[r]),e),n.formElements[r]=t):n.formElements[r]=e},this.activator=new s.Activator,this.environment={},this.trivia={getFormElementRegistration:this._getFormElementRegistration,registerFormElement:this._registerFormElement},this.factories=[],this.implementations={},this.formElements=i.__assign({},r.getCachedFormElements()),this.appSkuCode=e}t.Engine=u});