var h=Object.defineProperty;var g=(r,t,e)=>t in r?h(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>(g(r,typeof t!="symbol"?t+"":t,e),e);import{d as w,eA as b,J as v,b as k,c as $,u as _}from"./outputWidgets.c072fe4e.js";import{a as I}from"./asyncComputed.376cdc00.js";import"./console.a87f2a82.js";import{C as l}from"./gateway.18ca6e0a.js";import{A}from"./activeRecord.fdc25b97.js";import"./index.90440471.js";import{q as C}from"./icons.158b4825.js";import{_ as j}from"./CrudView.vue_vue_type_script_setup_true_lang.9296340f.js";import"./index.00103e26.js";import"./Form.9f52866c.js";import"./Title.e3dcb8ea.js";import"./CollapsePanel.ecfd8c73.js";import"./index.d808811c.js";import"./index.ec8e038a.js";import"./index.dce83dc7.js";import"./dayjs.a56ae918.js";import"./index.4e6af937.js";import"./index.8ab39784.js";import"./TabPane.df5f41ca.js";import"./index.c5fd7926.js";import"./index.148bcdd7.js";import"./index.d9c3e0de.js";import"./index.e5a5efcd.js";import"./index.e7c5574b.js";import"./index.96de14c0.js";import"./index.28ce0851.js";import"./index.2e3640f1.js";import"./index.4cff163b.js";import"./pubsub.98ad9fe0.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="d419ece2-4c3e-4e55-a990-e1cd317138ff",r._sentryDebugIdIdentifier="sentry-dbid-d419ece2-4c3e-4e55-a990-e1cd317138ff")}catch{}})();class P{constructor(){u(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 s=new P;class o{constructor(t,e){u(this,"record");this.projectId=t,this.record=A.create(s,e,"id")}static async list(t){return(await s.list(t)).map(a=>new o(t,a))}static async create(t,e,a){const n=await s.create({projectId:t,name:e,value:a});return new o(t,n)}static async get(t,e){const a=await s.get(e);return new o(t,a)}static async update(t,e,a){const n=await s.update(e,a);return new o(t,n)}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 s.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const st=w({__name:"EnvVars",setup(r){const e=b().params.projectId,{loading:a,result:n,refetch:d}=I(()=>o.list(e)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:i,value:c}){await o.create(e,i,c),d()}const f=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=n.value)==null?void 0:i.map(p=>({key:p.key,cells:[{text:p.key},{text:"Actions",actions:[{icon:C,label:"Delete",async onClick(){await p.delete(),d()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(j,{"entity-name":"Env var",loading:_(a),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{st as default};
//# sourceMappingURL=EnvVars.51434183.js.map
