(()=>{function e(l,u,o,t,e,n,r,i,F,a){var c,p,d="",s="",E={blue:{blue_1:"#08293F",blue_2:"#0B385B",blue_3:"#0F4C7B",blue_4:"#14629F",blue_5:"#1776BF",blue_6:"#1C8CE3",blue_7:"#5FAEEC",blue_8:"#96CAF3",blue_9:"#CDE6F9",blue_10:"#F6FAFE"},purple:{purple_1:"#230052",purple_2:"#310070",purple_3:"#4B00AD",purple_4:"#6800F0",purple_5:"#801FFF",purple_6:"#9A4DFF",purple_7:"#B780FF",purple_8:"#D1ADFF",purple_9:"#E8D6FF",purple_10:"#F9F5FF"},pink:{pink_1:"#570030",pink_2:"#7A0045",pink_3:"#B30065",pink_4:"#E0007F",pink_5:"#FF1F9E",pink_6:"#FF61BA",pink_7:"#FF8FCE",pink_8:"#FFBDE2",pink_9:"#FFE0F1",pink_10:"#FFF5FB"},red:{red_1:"#520005",red_2:"#6B0006",red_3:"#8F0009",red_4:"#BD000C",red_5:"#E0000E",red_6:"#FF1F2D",red_7:"#FF5C66",red_8:"#FF8F96",red_9:"#FFCCCF",red_10:"#FFF0F0"},orange:{orange_1:"#5C2800",orange_2:"#753200",orange_3:"#9E4400",orange_4:"#C25400",orange_5:"#E66400",orange_6:"#FF801F",orange_7:"#FFA057",orange_8:"#FFC89E",orange_9:"#FFE8D6",orange_10:"#FFF6F0"},yellow:{yellow_1:"#474200",yellow_2:"#5C5500",yellow_3:"#807700",yellow_4:"#ADA200",yellow_5:"#D6C800",yellow_6:"#F0DF00",yellow_7:"#FFF01F",yellow_8:"#FFF794",yellow_9:"#FFFBC7",yellow_10:"#FFFEE6"},green:{green_1:"#3B4503",green_2:"#4C5705",green_3:"#657506",green_4:"#829707",green_5:"#A0B909",green_6:"#BAD80A",green_7:"#CDEF0B",green_8:"#EAFA8F",green_9:"#F5FCCA",green_10:"#FAFEE7"},teal:{teal_1:"#063733",teal_2:"#094845",teal_3:"#0C6A64",teal_4:"#108E86",teal_5:"#15B0A6",teal_6:"#19D2C7",teal_7:"#64EDE3",teal_8:"#A9F4F0",teal_9:"#DBFAF9",teal_10:"#F1FDFC"}},g={DEVICE:"device",GROUP:"group",REPORT:"report",EXPORT_CONFIGURATION:"exportConfiguration",APPLICATION:"application"};function C(e){var t,n=(e||"").match(/^\/apps\/([^/]*\/[^/]*)/),n=n&&n[1],r=n&&n.split("/").pop(),i=n&&-1<(c||[]).indexOf(n);return e=e&&!o.get(e)&&!i&&(t=new RegExp("/".concat(r,"$")),i=_.find(c||[],function(e){return t.test(e)}))?e.replace(n,i):e}function f(e){return u.when(t.invoke(e.showIf,e))}function w(e){return r.isAllowed(e)}function A(e){e=Object.keys(e);return e[Math.floor(Math.random()*e.length)]}return{CONTEXT:g,getContext:function(){var e=l.deviceId,t=l.groupId,n=l.reportId,r=l.exportId,i=null,o=null;return e&&(i=g.DEVICE,o=e),t&&(i=g.GROUP,o=t),n&&(i=g.REPORT,o=n),r&&(i=g.EXPORT_CONFIGURATION,o=r),{context:i=l.applicationId?g.APPLICATION:i,id:o}},getContextPath:function(e){return{group:"/group/".concat(e.id),device:"/device/".concat(e.id)}[e.context]},verifyPluginViewPath:function(e){var t,e=e&&e.replace(/\/\//g,"/");return c?u.when(C(e)):(t=p||n.getCurrent().then(n.listPluginsByApplication).then(function(e){return c=_.map(e,"contextPath")}),(p=t).then(_.partial(C,e)))},intersectionObjects:function(e){for(var t=arguments.length,n=new Array(1<t?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return _.filter(_.uniq(e),function(t){return _.every(n,function(e){return _.some(e,function(e){return e.id===t.id})})})},editUserUI:function(){return i({templateUrl:":::PLUGIN_PATH:::/ui/user/editUser.modal.html",title:a("Edit user"),controller:"EditUserCtrl"})},editRetentionRule:function(e){var t=e&&e.id?a("Edit retention rule"):a("Create retention rule");return i({templateUrl:":::PLUGIN_PATH:::/ui/views/editRetentionRuleModal.html",title:t,controller:"editRetentionRuleCtrl",resolve:{rule:function(){return e}}})},configureVisibility:function(t,e,n){var r=u.when(!0),i=e||"show",o=n?_.negate(_.identity):_.identity;return t.showIfPermissions&&(r=r.then(_.partial(w,t.showIfPermissions)).then(function(e){return e?u.when(!0):u.reject()})),(r=t.showIf?r.then(_.partial(f,t)):r).catch(_.constant(!1)).then(function(e){return _.set(t,i,o(e))})},instanceOptions:function(){return _.merge({},window.C8Y_APP&&window.C8Y_APP.C8Y_INSTANCE_OPTIONS,window.C8Y_INSTANCE_OPTIONS)},escapeForRegex:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},shouldShowSmartRules:F.shouldShowLocalSmartRules,emitWindowResize:function(){var e;Event.prototype.initEvent?((e=window.document.createEvent("UIEvents")).initUIEvent("resize",!0,!1,window,0),window.dispatchEvent(e)):window.dispatchEvent(new Event("resize"))},waitForPropertyResolve:function(e,t){var n=u.defer(),r=e.$watch(function(){return _.get(e,t)},function(e){r(),n.resolve(e)});return n.promise},stripHtmlTags:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""},generateColor:function(){for(var e="",t="";(e=A(E))===d;);d=e;for(var n=E[e];(t=A(n))===s;);return n[s=t]},getCookieValue:function(e){return(e=document.cookie.match("(^|;)\\s*".concat(e,"\\s*=\\s*([^;]+)")))?e.pop():""}}}e.$inject=["$routeParams","$q","$templateCache","$injector","$http","c8yApplication","c8yPermissions","c8yModal","c8ySmartRulesAvailability","gettext"],angular.module("c8y.ui").factory("c8yUiUtil",e)})();