var h=Object.defineProperty;var b=(a,t,e)=>t in a?h(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var d=(a,t,e)=>(b(a,typeof t!="symbol"?t+"":t,e),e);import{d as g,ez as w,H as v,b as k,c as $,u as C}from"./outputWidgets.a4629ff8.js";import{a as I}from"./asyncComputed.fb8b9ba6.js";import"./router.ab2ac3ba.js";import{C as l}from"./gateway.68939de7.js";import{A as _}from"./activeRecord.a2b7d343.js";import"./columns.464a3bb5.js";import{k as j}from"./icons.73bff2ab.js";import{C as A}from"./CrudView.a5b1a4eb.js";import"./Title.cf2a531e.js";import"./index.339c7421.js";import"./pubsub.25dc8c41.js";import"./index.f4ac7424.js";import"./Text.eb216708.js";import"./Form.ab59726f.js";import"./url.d6a620b9.js";import"./index.874565bb.js";import"./index.48817ebe.js";import"./index.0f6dde5f.js";import"./index.46db6cb2.js";import"./index.56cfba6d.js";import"./index.fda4c602.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="bc1f6482-51af-4f97-9b80-b76e7da7a0d5",a._sentryDebugIdIdentifier="sentry-dbid-bc1f6482-51af-4f97-9b80-b76e7da7a0d5")}catch{}})();class P{constructor(){d(this,"urlPath","env-vars")}async create(t){return l.post(`projects/${t.projectId}/${this.urlPath}`,{name:t.name,value:t.value})}async delete(t,e){await l.delete(`projects/${t}/${this.urlPath}/${e}`)}async list(t){return l.get(`projects/${t}/${this.urlPath}`)}async get(t){return l.get(`${this.urlPath}/${t}`)}async update(t,e){return l.patch(`${this.urlPath}/${t}`,e)}}const n=new P;class s{constructor(t,e){d(this,"record");this.projectId=t,this.record=_.create(n,e,"id")}static async list(t){return(await n.list(t)).map(r=>new s(t,r))}static async create(t,e,r){const o=await n.create({projectId:t,name:e,value:r});return new s(t,o)}static async get(t,e){const r=await n.get(e);return new s(t,r)}static async update(t,e,r){const o=await n.update(e,r);return new s(t,o)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(t){this.record.set("value",t)}async save(){await this.record.save()}async delete(){await n.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const Y=g({__name:"EnvVars",setup(a){const e=w().params.projectId,{loading:r,result:o,refetch:p}=I(()=>s.list(e)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:i,value:c}){await s.create(e,i,c),p()}const f=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=o.value)==null?void 0:i.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?c:[]}});return(i,c)=>(k(),$(A,{"entity-name":"Env var",loading:C(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{Y as default};
//# sourceMappingURL=EnvVars.9057a209.js.map
