!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","./deps/bluebird_fork","esri/request","./activities/arcgis/ArcGisApiVersion","./definition/ProgramInspector","./Collections"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=e("tslib"),s=r.__importDefault(e("./deps/bluebird_fork")),o=r.__importDefault(e("esri/request")),n=e("./activities/arcgis/ArcGisApiVersion"),i=e("./definition/ProgramInspector"),c=e("./Collections"),e=(a.prototype.resolveInspector=function(o,n,i){var c=this;return void 0===n&&(n=!0),s.default.attempt(function(){if(!o)return c.downloadAndResolveInspector(void 0,i);var e="string"==typeof o?o:o.program||o.url;if(n){var t="string"==typeof o?o:o.id||o.url;if(null!=t){var r=c._cache.find(t);return void 0!==r?r:(c._cache.assign(t,c.downloadAndResolveInspector(e,i).catch(function(e){return c._cache.remove(t),s.default.reject(e)})),c._cache.find(t))}}return c.downloadAndResolveInspector(e,i)})},a.prototype.downloadAndResolveInspector=function(e,t){return e instanceof i.ProgramInspector?s.default.resolve(e):"object"==typeof e?this.createInspector(e):(t||this.loadWorkflow)(e).then(this.createInspector).catch(function(e){return s.default.reject(e)})},a.prototype.loadWorkflow=function(e){var t=e.match(/^(.*?)\/home\/item\.html\?id=(.*?)(\#.*)?$/);return null!=t&&(e=t[1]+"/sharing/rest/content/items/"+t[2]+"/data?f=json"),n.isArcGisApiVersion3x?s.default.resolve(o.default({url:e})):s.default.resolve(o.default(e)).then(function(e){return s.default.resolve(e.data)})},a.prototype.createInspector=function(t){return s.default.attempt(function(){if(t instanceof i.ProgramInspector)return t;var e=new i.ProgramInspector;return e.import(t),e})},a);function a(){this._cache=new c.Dictionary}t.ProgramInspectorFacility=e});