(()=>{function e(e,n,t,i,a,c,o,p){var r=this;function s(e){t.detail(e).then(n.getResData).then(function(e){r.device=e})}function d(e){return _.isEmpty(e)?"":o.humanizeMapping(e)}function g(n){c.openSelector({selectSingle:!0,managedObject:r.device}).then(function(e){r.mapping[n]=e})}function u(n){a.openFieldbusSelector({device:r.device}).then(function(e){r.mapping[n]=e})}function l(n){i.edit(n).then(function(e){n.config=e})}function m(){var i=e.$parent.$parent.forms.componentForm;r.hasInvalidMapping=!1,_.forOwn(r.mapping,function(e,n){var t=v(n);r.hasInvalidMapping=r.hasInvalidMapping||t,i.$setValidity("statesMapping-".concat(n),!t)})}function v(e){return _.isEmpty(r.mapping[e])}_.assign(r,{$onInit:function(){_.assign(r,{humanizeProperty:d,selectDevicePropertyForState:g,selectFieldbusPropertyForState:u,editComputedProperty:l,isMappingInvalidForState:v}),s(r.deviceId),r.states={red:p("red"),yellow:p("yellow"),green:p("green")},r.mapping||(r.mapping=_.reduce(_.keys(r.states),function(e,n){return e[n]={},e},{})),e.$watch("vm.mapping",m,!0)},$onChanges:function(e){e=e.deviceId&&e.deviceId.currentValue;e&&s(e)}})}e.$inject=["$scope","c8yBase","c8yInventory","c8yComputedProperties","c8yDeviceDatabase","SchemaPropertiesSvc","ScadaWidgetUtilSvc","gettext"],angular.module("c8y.trafficLightWidget").component("statesMapping",{templateUrl:":::PLUGIN_PATH:::/states-mapping.html",bindings:{deviceId:"<",mapping:"="},controller:e,controllerAs:"vm"})})();