import{S as s,N as t,F as i,b as S,T as m,c as o,v,j as f}from"./parser-RGrRIRgY.js";import{$ as n,g as E,w as d,f as g}from"./app-JmgyQoR0.js";function M(l){let u=0;return{USER_ID:n?s(n.id):t,USER_NAME:n?s(n.name):t,USER_USERNAME:n?s(n.username):t,"Mk:dialog":i(async([a,r,e])=>(await E({type:e?e.value:"info",title:a.value,text:r.value}),t)),"Mk:confirm":i(async([a,r,e])=>(await d({type:e?e.value:"question",title:a.value,text:r.value})).canceled?S:m),"Mk:api":i(async([a,r,e])=>{if(e&&(o(e),typeof e.value!="string"))throw new Error("invalid token");if(u++,u>16)return t;if(a.value.includes("://")||a.value.includes(".."))throw new Error("invalid endpoint");const c=await g(a.value,v(r),e?e.value:l.token||null);return f(c)}),"Mk:save":i(([a,r])=>(o(a),localStorage.setItem(`aiscript:${l.storageKey}:${a.value}`,JSON.stringify(v(r))),t)),"Mk:load":i(([a])=>(o(a),f(JSON.parse(localStorage.getItem(`aiscript:${l.storageKey}:${a.value}`))))),"Mk:url":i(()=>s(window.location.href))}}export{M as c};
