import{getAddon as e}from"@clevercloud/client/esm/api/v2/providers.js";import{ONE_SECOND as o}from"@clevercloud/client/esm/with-cache.js";import{fakeString as r}from"./lib/fake-strings.js";import{sendToApi as n}from"./lib/send-to-api.js";import{defineSmartComponent as t}from"./lib/smart/define-smart-component.js";import"./cc-smart-container.js";import{CcAddonHeaderClient as i}from"./cc-addon-header.client.js";import"./cc-addon-header.js";t({selector:'cc-addon-header[smart-mode="jenkins"]',params:{apiConfig:{type:Object},ownerId:{type:String},addonId:{type:String},logsUrlPattern:{type:String}},onContextUpdate({context:e,updateComponent:o,signal:n}){const{apiConfig:t,ownerId:i,addonId:a}=e,s=new d({apiConfig:t,ownerId:i,addonId:a,signal:n});let p="";o("state",{type:"loading",logsUrl:r(15),openLinks:[{url:r(15),name:r(5)}]}),s.getProviderWithZone().then((({rawAddon:r,rawProvider:n,zone:t})=>{p=e.logsUrlPattern.replace(":id",r.id);const i=`https://${n.host}`;o("state",{type:"loaded",providerId:r.provider.name,providerLogoUrl:r.provider.logoUrl,name:r.name,id:r.realId,zone:t,logsUrl:p,openLinks:[{name:"JENKINS",url:i}]})})).catch((e=>{console.error(e),o("state",{type:"error"})}))}});class d extends i{constructor({apiConfig:e,ownerId:o,addonId:r,signal:n}){super({apiConfig:e,ownerId:o,addonId:r,providerId:"jenkins",signal:n})}_getAddonProvider(){return e({providerId:this._provider,addonId:this._addonId}).then(n({apiConfig:this._apiConfig,signal:this._signal,cacheDelay:o}))}async getProviderWithZone(){const e=await this.getAddon(),[o,r]=await Promise.all([this._getAddonProvider(),this.getZone(e.region)]);return{rawAddon:e,rawProvider:o,zone:r}}}
//# sourceMappingURL=cc-addon-header.smart-jenkins.js.map
