(()=>{function t(n,t,e,a,o,i,l,c){var p="access.control",r="allow.origin",s=l('The "Allowed domain" setting allows your JavaScript web application to directly communicate with the REST API.\n\nOptions:\n- Enter "*" to allow communication from any host,\n- enter "http://my.host.com, http://myother.host.com" to allow applications from http://my.host.com and from http://myother.host.com to communicate with the platform,\n- leave the field blank to allow access only from your tenant\'s domain.\n\nFor more information, check <a target="_blank" rel="noopener noreferrer" href="https://enable-cors.org">enable-cors.org</a>'),u=c.getString("e.g. {{ example }}",{example:"*"});function h(t){return _.filter(t,{type:"HOSTED"})}function f(t){var e=t.key.replace(/\./,"_");n[e]=t}function m(){e.detail({category:p,key:r}).then(function(t){return t.data}).then(f)}_.assign(n,{applicationSettings:{},updateDefaultApp:function(){return e.updateOption({category:"application",key:"default.application",value:n.applicationSettings.defaultApplication.id}).then(function(){i.success(c.getString('Application "{{appName | humanizeAppName}}" is now the default application for the tenant.',{appName:n.applicationSettings.defaultApplication.contextPath}))})},helpText:s,placeholderText:u,saveAccessControl:function(t){return""===t.value?e.deleteOption({category:p,key:r}).then(function(){i.success(l("Access not allowed from any domains."))}):(t=>e.updateOption({category:p,key:r,value:t.value}).then(m).then(function(){i.success(c.getString("Access allowed from domain(s): {{value}}.",t))}))(t)},filterHostedApps:h}),o.listByVisibleLinks().then(function(t){n.applications=h(t),e.detail({category:"application",key:"default.application"}).then(function(t){n.applicationSettings.defaultApplication=_.find(n.applications,{id:t.data.value})})}),m(),a.changeTitle({title:l("Application")})}t.$inject=["$scope","$q","c8ySettings","c8yTitle","c8yApplication","c8yAlert","gettext","gettextCatalog"],angular.module("c8y.parts.applicationSettings").controller("applicationSettingsCtrl",t)})();