import{c as d,o as i,b as r,bE as h,bF as w,aX as l,aY as c,a0 as p,a2 as _,g as b,h as v,r as m,v as k,a4 as S,b1 as x,D as u,K as C,F as A,p as B,k as V,w as F,d as L,t as M,f as N}from"./Bq-XgLEJ.js";function D(a,t){return i(),d("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon"},[r("path",{d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625Z"}),r("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"})])}const y=h("strategies",{state:()=>({strategies:[]}),persist:{storage:w.localStorage},actions:{async getStrategies(){const{data:a,error:t}=await _("/strategy/all",!0);if(t.value&&t.value.statusCode!==200){c(t);return}const e=a.value;this.strategies=e.strategies},async getStrategy(a){const{data:t,error:e}=await l("/strategy/get",{name:a},!0);return e.value&&e.value.statusCode!==200?(c(e),""):t.value.content},async saveStrategy(a,t){const{data:e,error:s}=await l("/strategy/save",{name:a,content:t},!0);if(s.value&&s.value.statusCode!==200){c(s);return}const n=e.value;p("success",n.message)},async deleteStrategy(a){const{data:t,error:e}=await l("/strategy/delete",{name:a},!0);if(e.value&&e.value.statusCode!==200){c(e);return}const s=t.value;p("success",s.message)}}}),E={class:"grid grid-cols-1 overflow-auto border-r dark:border-gray-600",style:{height:"calc(100vh - 4rem - 4px)"}},H={class:"flex justify-between items-center border-b dark:border-gray-600"},Z=b({__name:"StrategiesSidebar",setup(a){const t=v(()=>y().strategies),e=m(""),s=v(()=>t.value.filter(n=>n.toLowerCase().includes(e.value.toLowerCase())));return k(async()=>{setTimeout(async()=>{await y().getStrategies()},200)}),(n,g)=>{const f=N;return i(),d("div",E,[r("section",null,[r("section",null,[r("div",H,[S(r("input",{"onUpdate:modelValue":g[0]||(g[0]=o=>C(e)?e.value=o:null),class:"w-full px-4 py-2 bg-gray-50 focus:outline-none dark:bg-backdrop-dark",placeholder:"Search strategies..."},null,512),[[x,u(e)]])]),(i(!0),d(A,null,B(u(s),o=>(i(),V(f,{key:o,to:`/strategies/${o}`,class:"px-4 py-2 bg-gray-50 dark:bg-backdrop-dark hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer select-none flex items-center"},{default:F(()=>[L(u(D),{class:"w-4 h-4 mr-2"}),r("span",null,M(o),1)]),_:2},1032,["to"]))),128))])])])}}});export{Z as _,y as u};
