import{getAssetUrl as e}from"./lib/assets-url.js";import{getDocUrl as o}from"./lib/dev-hub-url.js";import{notifySuccess as a,notifyError as n}from"./lib/notifications.js";import{defineSmartComponent as t}from"./lib/smart/define-smart-component.js";import{i18n as r}from"./translation.js";import"./cc-smart-container.js";import{CcAddonInfoClient as s,formatVersionState as i}from"./cc-addon-info.client.js";import"./cc-addon-info.js";t({selector:'cc-addon-info[smart-mode="keycloak"]',params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String},appOverviewUrlPattern:{type:String},addonDashboardUrlPattern:{type:String},grafanaLink:{type:Object,optional:!0},logsUrlPattern:{type:String}},onContextUpdate({context:t,onEvent:l,updateComponent:d,signal:p}){const{apiConfig:c,ownerId:g,addonId:m,appOverviewUrlPattern:v,addonDashboardUrlPattern:f,grafanaLink:k}=t;let u="";const y=new s({apiConfig:c,ownerId:g,addonId:m,providerId:"keycloak",grafanaLink:k,signal:p});d("state",{type:"loading",version:{stateType:"up-to-date",installed:"0.0.0",latest:"0.0.0"},creationDate:"2025-08-06 15:03:00",openGrafanaLink:null!=k?"https://example.com":null,linkedServices:[{type:"app",name:"Java",logoUrl:null,link:"https://example.com"},{type:"addon",name:"PostgreSQL",logoUrl:null,link:"https://example.com"},{type:"addon",name:"FS Bucket",logoUrl:null,link:"https://example.com"}]}),d("docLink",{text:r("cc-addon-info.doc-link.keycloak"),href:o("/addons/keycloak")}),y.getAddonInfo().then((({operatorVersionInfo:o,addonInfo:a,grafanaAppLink:n,operator:r})=>{const s=r.resources.entrypoint;u=t.logsUrlPattern.replace(":id",s),d("state",{type:"loaded",version:i(o),creationDate:a.creationDate,openGrafanaLink:n,linkedServices:[{type:"app",name:"Java",logoUrl:e("/logos/java-jar.svg"),link:v.replace(":id",s)},{type:"addon",name:"PostgreSQL",logoUrl:e("/logos/pgsql.svg"),link:f.replace(":id",r.resources.pgsqlId)},{type:"addon",name:"FS Bucket",logoUrl:e("/logos/fsbucket.svg"),link:f.replace(":id",r.resources.fsbucketId)}]})})).catch((e=>{console.error(e),d("state",{type:"error"})})),l("cc-addon-version-change",(e=>{d("state",(e=>{e.version={...e.version,stateType:"requesting-update"}})),y.updateOperatorVersion(e).then((({availableVersions:o})=>{a(r("cc-addon-info.version.update.success.content",{logsUrl:u}),r("cc-addon-info.version.update.success.heading",{version:e})),d("state",(a=>{const n=e!==a.version.latest;a.version=i({installed:e,available:o,latest:a.version.latest,needUpdate:n})}))})).catch((e=>{d("state",(e=>{e.version={...e.version,stateType:"update-available"}})),n(r("cc-addon-info.version.update.error")),console.error(e)}))}))}});
//# sourceMappingURL=cc-addon-info.smart-keycloak.js.map
