(()=>{function n(n,e,o,c,t,l,r,u){var i=[],a={loading:!0};function s(){a.loading=!1}function f(n){return _.filter(n,function(n){return!n.hideFromList})}function h(n){var t,e=_.keys(l);return 0===e.length?n:_.filter(n,function(n){return!!(n.contexts&&(t=_.keys(n.contexts),0<_.intersection(e,t).length))})}function g(n){return _.filter(n,function(n){return!r||r(n)})}function m(n){n.forEach(function(n){i.push(n)})}function d(){1===i.length&&i[0]._active&&v(i[0])}function v(n){var t,r,i;return t=n._active?c.createInstanceWithUI(n,(i={},n=(r=n).contexts&&_.intersection(_.keys(l),_.keys(r.contexts))||[],_.forEach(n,function(n){var e={obj:l[n]},c={rule:i};_.forEach(r.contexts[n],function(n,t){t=o("obj.".concat(t)),n=o("rule.".concat(n)),t=t(e);null!=t&&n.assign(c,t)})}),_.assign(i,u))).then(e.close):t}n.ruleTemplates=i,n.cancel=function(){e.dismiss()},n.createInstance=v,n.loading=a,n.icon=c.getRuleIcon(),t.list().then(f).then(h).then(g).then(m).then(d).finally(s)}n.$inject=["$scope","$uibModalInstance","$parse","smartRulesSvc","smartRuleTemplatesSvc","context","ruleTemplatesFilterFn","ruleInitialObj"],angular.module("c8y.smartRules").controller("SmartRuleAddCtrl",n)})();