var b=Object.defineProperty;var f=(a,e,t)=>e in a?b(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var u=(a,e,t)=>(f(a,typeof e!="symbol"?e+"":e,t),t);import{d as w,ey as g,H as v,b as k,c as $,u as _}from"./registerWidgets.2031932d.js";import{a as I}from"./asyncComputed.57cbb10a.js";import{C as d}from"./gateway.5ec242d0.js";import{A as C}from"./activeRecord.7b173443.js";import"./index.f3f00cf3.js";import{o as j}from"./icons.3cd62928.js";import{_ as A}from"./CrudView.vue_vue_type_script_setup_true_lang.65f898ee.js";import"./passwordlessManager.50ecc1b4.js";import"./pubsub.9625b443.js";import"./storage.8b8c0b1c.js";import"./Modal.380d5af9.js";import"./Title.6d39f4ca.js";import"./transButton.d9059bcf.js";import"./index.bdecc667.js";import"./Text.f7290fbc.js";import"./index.29b38c7d.js";import"./index.b4b072a9.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]="78e29d05-2769-49d8-8da7-7341b73cddb8",a._sentryDebugIdIdentifier="sentry-dbid-78e29d05-2769-49d8-8da7-7341b73cddb8")}catch{}})();class P{constructor(){u(this,"urlPath","env-vars")}async create(e){return d.post(`projects/${e.projectId}/${this.urlPath}`,{name:e.name,value:e.value})}async delete(e,t){await d.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return d.get(`projects/${e}/${this.urlPath}`)}async get(e){return d.get(`${this.urlPath}/${e}`)}async update(e,t){return d.patch(`${this.urlPath}/${e}`,t)}}const n=new P;class s{constructor(e,t){u(this,"record");this.projectId=e,this.record=C.create(n,t,"id")}static async list(e){return(await n.list(e)).map(r=>new s(e,r))}static async create(e,t,r){const o=await n.create({projectId:e,name:t,value:r});return new s(e,o)}static async get(e,t){const r=await n.get(t);return new s(e,r)}static async update(e,t,r){const o=await n.update(t,r);return new s(e,o)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(e){this.record.set("value",e)}async save(){await this.record.save()}async delete(){await n.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const T=w({__name:"EnvVars",setup(a){const t=g().params.projectId,{loading:r,result:o,refetch:p}=I(()=>s.list(t)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:i,value:c}){await s.create(t,i,c),p()}const h=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions"}],rows:(c=(i=o.value)==null?void 0:i.map(l=>({key:l.key,cells:[{text:l.key},{text:"Actions",actions:[{icon:j,label:"Delete",async onClick(){await l.delete(),p()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(A,{"entity-name":"Env var",loading:_(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:h.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{T as default};
//# sourceMappingURL=EnvVars.76484d60.js.map
