var h=Object.defineProperty;var b=(a,e,t)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var d=(a,e,t)=>(b(a,typeof e!="symbol"?e+"":e,t),t);import{d as g,eB as w,G as v,b as k,c as $,u as I}from"./outputWidgets.e822ff0f.js";import{a as C}from"./asyncComputed.68870ff7.js";import"./router.8fbd98d9.js";import"./index.3b830ff3.js";import{C as c}from"./gateway.349a9491.js";import{E as _}from"./record.edca104e.js";import{g as j}from"./icons.0ab0d55f.js";import{C as P}from"./CrudView.0a0ee0a6.js";import"./Base.775de4d5.js";import"./transButton.f06af665.js";import"./Text.4c9d53a2.js";import"./Title.5afb3003.js";import"./index.bf8163eb.js";import"./pubsub.ae710ef5.js";import"./url.c786ab78.js";import"./index.eb9667df.js";import"./index.1b95bbbc.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="86fc3c67-295e-451c-8d90-e0919d6aa998",a._sentryDebugIdIdentifier="sentry-dbid-86fc3c67-295e-451c-8d90-e0919d6aa998")}catch{}})();class x{constructor(){d(this,"urlPath","env-vars")}async create(e){return c.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await c.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return c.get(`projects/${e}/${this.urlPath}`)}async get(e){return c.get(`${this.urlPath}/${e}`)}async update(e,t){return c.patch(`${this.urlPath}/${e}`,t)}}const l=new x;class n{constructor(e,t){d(this,"record");this.projectId=e,this.record=_.from(t)}static async list(e){return(await l.list(e)).map(r=>new n(e,r))}static async create(e,t,r){const s=await l.create({projectId:e,name:t,value:r});return new n(e,s)}static async get(e,t){const r=await l.get(t);return new n(e,r)}static async update(e,t,r){const s=await l.update(t,r);return new n(e,s)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(e){this.record.set("value",e)}async delete(){await l.delete(this.projectId,this.key)}}const T=g({__name:"EnvVars",setup(a){const t=w().params.projectId,{loading:r,result:s,refetch:p}=C(()=>n.list(t)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:o,value:i}){await n.create(t,o,i),p()}const f=v(()=>{var o,i;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(i=(o=s.value)==null?void 0:o.map(u=>({key:u.key,cells:[{text:u.key},{text:"Actions",actions:[{icon:j,label:"Delete",async onClick(){await u.delete(),p()},dangerous:!0}]}]})))!=null?i:[]}});return(o,i)=>(k(),$(P,{"entity-name":"Env var",loading:I(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:f.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{T as default};
//# sourceMappingURL=EnvVars.84186d57.js.map
