import{getAssetUrl as e}from"./lib/assets-url.js";import{getDocUrl as o}from"./lib/dev-hub-url.js";import{notifySuccess as t,notifyError as a}from"./lib/notifications.js";import{defineSmartComponent as n}from"./lib/smart/define-smart-component.js";import{i18n as r}from"./translation.js";import"./cc-smart-container.js";import{CcAddonInfoClient as i,formatVersionState as s}from"./cc-addon-info.client.js";import"./cc-addon-info.js";n({selector:'cc-addon-info[smart-mode="otoroshi"]',params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String},appOverviewUrlPattern:{type:String},addonDashboardUrlPattern:{type:String},scalabilityUrlPattern:{type:String},grafanaLink:{type:Object,optional:!0},logsUrlPattern:{type:String}},onContextUpdate({context:n,onEvent:l,updateComponent:d,signal:p}){const{apiConfig:c,ownerId:m,addonId:g,appOverviewUrlPattern:v,addonDashboardUrlPattern:f,scalabilityUrlPattern:y,grafanaLink:u}=n;let h="";const b=new i({apiConfig:c,ownerId:m,addonId:g,providerId:"otoroshi",grafanaLink:u,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!=u?"https://example.com":null,openScalabilityLink:"/placeholder",linkedServices:[{type:"app",name:"Java",logoUrl:null,link:"https://example.com"},{type:"addon",name:"Redis",logoUrl:null,link:"https://example.com"}]}),d("docLink",{text:r("cc-addon-info.doc-link.otoroshi"),href:o("/addons/otoroshi")}),b.getAddonInfo().then((({operatorVersionInfo:o,addonInfo:t,grafanaAppLink:a,operator:r})=>{const i=r.resources.entrypoint;h=n.logsUrlPattern.replace(":id",i),d("state",{type:"loaded",version:s(o),creationDate:t.creationDate,openGrafanaLink:a,openScalabilityLink:y.replace(":id",i),linkedServices:[{type:"app",name:"Java",logoUrl:e("/logos/java-jar.svg"),link:v.replace(":id",i)},{type:"addon",name:"Redis",logoUrl:e("/logos/redis.svg"),link:f.replace(":id",r.resources.redisId)}]})})).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"}})),b.updateOperatorVersion(e).then((({availableVersions:o})=>{t(r("cc-addon-info.version.update.success.content",{logsUrl:h}),r("cc-addon-info.version.update.success.heading",{version:e})),d("state",(t=>{const a=e!==t.version.latest;t.version=s({installed:e,available:o,latest:t.version.latest,needUpdate:a})}))})).catch((e=>{d("state",(e=>{e.version={...e.version,stateType:"update-available"}})),a(r("cc-addon-info.version.update.error")),console.error(e)}))}))}});
//# sourceMappingURL=cc-addon-info.smart-otoroshi.js.map
