import{c as O,d as j}from"./chunk-6CK3UN3B.js";import{a as u,b as $}from"./chunk-KKWEGAND.js";import{ac as g,bc as k,gi as w,hi as W,oc as r,pc as z,uc as P,vc as G}from"./chunk-EAIMSMGJ.js";import{a as F,b as V}from"./chunk-TS62PHQY.js";import{C as D,p as M}from"./chunk-Z5RJRCWC.js";import{Ac as m,Dc as x,Gd as A,Ia as d,Na as h,Ob as y,Sb as C,Tb as S,dd as B,ec as s,fc as b,ia as l,jc as v,lc as a,na as U,qc as T,rc as _,sc as c,ub as f,ya as I,zb as n}from"./chunk-JSJB5BKT.js";import{e as N}from"./chunk-SZAW6ZBW.js";function H(t,p){if(t&1&&c(0,"i",4),t&2){let e=m();v("dvl-icon dvl-icon-",e.imageIcon==null?null:e.imageIcon.icon,""),b("color",e.item!=null&&e.item.isTemplate&&(e.imageIcon==null?null:e.imageIcon.color)===e.defaultColor?"":e.imageIcon==null?null:e.imageIcon.color),s("ngStyle",e.iconStyle)}}function q(t,p){if(t&1&&c(0,"img",2),t&2){let e=m();x("src",e.customImage,f),s("ngStyle",e.imageStyle)}}function J(t,p){if(t&1&&c(0,"i",3),t&2){let e=m();s("ngStyle",B(1,E,e.imageIcon==null?null:e.imageIcon.color))}}var E,ce,K=N(()=>{A();V();$();j();U();k();G();D();z();W();A();E=t=>({"background-color":t});ce=(()=>{class t extends F{constructor(){super(...arguments),this.hasShortcut=!1,this.customImageService=I(O)}ngOnInit(){this.item&&(this.updateImage(),this.subscribeToImageChanged())}ngOnChanges(e){this.updateImage()}updateImage(){this.globalImageId?this.getGlobalImage():this.customImageBytes?this.getCustomImage():this.getImageIcon()}getImageIcon(){if(!this.item)return;let e=this.item.type??this.item.connectionType;if(this.defaultColor=u.getFromTypes(e,this.item.connectionSubType,this.getSpecificSubType(e,this.item)).color,this.customImage=null,this.item?.imageIcon)this.imageIcon=this.item.imageIcon;else{let o=u.getFromConnection(this.item);this.imageIcon=o.icon&&o.color?o:null}}getSpecificSubType(e,o){switch(e){case g.VPN:return P[o.vpnApplication??o.data?.vpn?.application];case g.PAM:switch(r[o.connectionSubType]){case r.AWSIAMUser:return w[o.awsCredentialMode??o.data?.awsPamCredentialSettings?.credentialMode]}}}getGlobalImage(){this.customImageService.getById(this.globalImageId).pipe(l(this.destroyed$)).subscribe(e=>{e?this.customImage=this.customImageService.customImageToViewModel(e).imageUrl:this.customImageBytes?this.getCustomImage():this.getImageIcon()})}getCustomImage(){return this.customImage=this.customImageBytes,this.customImageBytes&&this.customImageBytes.indexOf("data:image/png;base64")<0&&(this.customImage="data:image/png;base64,"+this.customImageBytes),this.customImageBytes}subscribeToImageChanged(){this.customImageService.iconChanged.pipe(l(this.destroyed$)).subscribe(()=>this.updateImage())}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=h(t)))(i||t)}})()}static{this.\u0275cmp=y({type:t,selectors:[["dvls-connection-icon-and-custom-image-component"]],inputs:{item:"item",globalImageId:"globalImageId",customImageBytes:"customImageBytes",imageStyle:"imageStyle",iconStyle:"iconStyle",hasShortcut:"hasShortcut"},features:[C,d],decls:4,vars:3,consts:[[2,"position","relative"],[3,"color","ngStyle","class"],[3,"ngStyle","src"],[1,"shortcut-icon","dvl-icon","dvl-icon-shortcut",3,"ngStyle"],[3,"ngStyle"]],template:function(o,i){o&1&&(T(0,"div",0),S(1,H,1,6,"i",1)(2,q,1,2,"img",2)(3,J,1,3,"i",3),_()),o&2&&(n(),a(!i.customImage&&i.imageIcon?1:-1),n(),a(i.customImage?2:-1),n(),a(i.hasShortcut?3:-1))},dependencies:[M],styles:[".shortcut-icon[_ngcontent-%COMP%]{position:absolute;right:0;bottom:0;font-size:12px;color:#fff;border:1px solid #ffffff}"]})}}return t})()});export{ce as a,K as b};
