(()=>{function t(i){t.$inject=["$injector","c8yModal"];var f,c=new WeakMap,a={},u={},p={};function s(t,e,r){var o=a[t],n=_.isArray(e)?e:e.$inject,n=(void 0===n&&(n=i.annotate(e)),_.includes(n,"config"));if(o)throw new Error('Computed property "'.concat(t,'" already registered'));if(n){if(p[t])throw new Error('Computed property factory "'.concat(t,'" already registered'));p[t]={config:r,property:e}}a[t]={config:r,property:e}}function e(o,t){var n=p[t];if(n)return{create:function(t,e){if(u[t])throw new Error('Computed property "'.concat(t,'" already registered'));return u[t]={getter:o.invoke(n.property,void 0,{config:e}),config:n.config},!0},attach:function(t,e,r){d(t,e,{getter:o.invoke(n.property,void 0,{config:r})})}};throw new Error('Computed property factory "'.concat(t,'" is not registered'))}function r(r){_.forEach(a,function(e,t){u[t]||(u[t]={_lazy:!0,getter:function(){var t=this._getter;return t||(this._getter=r.invoke(e.property,void 0,{config:!1}),t=this._getter),t},config:e.config})})}function n(n){_.forEach(u,function(e,r){function t(t){return t&&d(n,r,e)}var o=((e.config||{}).attachIf||_.constant(!0))(n);_.isFunction(_.get(o,"then"))?o.then(t):t(o)})}function g(t,e){if(_.isArray(e))r=t,o=e,c=_.keys(p),a=_.union(_.keys(u),c),_(o).filter("computed").map(function(t){var e=_.last(t.id.split("!!")),r=(t.config||{})._id||String(Math.random()).substr(2),o=t.config||{},n=_.includes(a,e),i=e+(_.includes(c,e)?"_".concat(r):"");return(t.config=o)._id=r,n&&(t.keyPath=[i]),{key:e,keyPath:i,isFactory:_.includes(c,e),config:o,exists:n}}).filter("exists").forEach(function(t){t.isFactory?f(t.key).attach(r,t.keyPath,t.config):g(r,t.key)});else{var r,c,a,o=e;if(o){e=u[o];if(!e)throw new Error('Computed property "'.concat(o,'" is not registered.'));d(t,o,e)}else n(t)}return t}function d(t,e,r){var o,n;_.isObjectLike(t)?_.has(t,e)||(o=r._lazy?r.getter():r.getter,n=o.detach||_.noop,(r=c.get(t))||c.set(t,r=[]),r.push(function(t){n(t),delete t[e]}),Object.defineProperty(t,e,{enumerable:!1,configurable:!0,get:function(){return o(this)}})):console.warn("[Computed properties] Managed object is not an object")}function l(e){var r=this,t=c.get(e);_.forEach(t,function(t){try{t.call(r,e)}catch(t){console.error("Error detaching computed property",t)}}),c.delete(e)}function t(t,n){var o=_.partial(r,t);return{register:function(t,e,r){s(t,e,r),o()},attach:g,detach:l,factory:f=_.partial(e,t),init:o,edit:function(t){var e,r=_.last(t.id.split("!!")),o=p[r];if(o)return e=_.get(o,"config.configTemplateUrl"),n({templateUrl:":::PLUGIN_PATH:::/ui/properties/computedPropertyConfigModal.html",controller:"ComputedPropertyConfigCtrl",size:"sm",resolve:{options:function(){return{configTemplateUrl:e,computedProperty:r,configSchema:_.isObjectLike(t.configSchema)&&t.configSchema,config:angular.copy(t.config)||{},prop:t}}}});throw new Error("".concat(r," is not a factory computed property."))},listFactories:function(){return _.map(p,function(t,e){return{id:e,config:_.clone(t.config)}})}}}return{register:s,$get:t}}function e(t){t.init()}e.$inject=["c8yComputedProperties"],t.$inject=["$injector"],angular.module("c8y.ui").provider("c8yComputedProperties",t).run(e)})();