import{b as I,a as M,h as d,i as C,j as u,K as B,E as m,z as n,u as a,q as T,X as D,t as h,G as E,x as N,F as V,I as $,J as z}from"./vue-y3KLWBaS.js";import{I as F,a as g}from"./parser-RGrRIRgY.js";import{P as H}from"./index-eSfribeX.js";import{u as K}from"./widget-qjKd4HCd.js";import{i as U,$ as j,v as q,g as w,n as A}from"./app-JmgyQoR0.js";import{M as G}from"./MkContainer-6laePfDX.js";import{c as J}from"./api-I791pgl2.js";const L=r=>($("data-v-9adcbf97"),r=r(),z(),r),R=L(()=>a("i",{class:"ph-terminal-window ph-bold ph-lg"},null,-1)),W={class:"uylguesu _monospace"},X={class:"logs"},f="aiscript",O=I({__name:"aiscript",props:{widget:{}},emits:["updateProps"],setup(r,{expose:_,emit:x}){const v={showHeader:{type:"boolean",default:!0},script:{type:"string",multiline:!0,default:"(1 + 1)",hidden:!0}},c=r,y=x,{widgetProps:o,configure:k}=K(f,v,c,y),i=M([]),S=new H,b=async()=>{var e;i.value=[];const l=new F(J({storageKey:"widget",token:(e=j)==null?void 0:e.token}),{in:t=>new Promise(p=>{q({title:t}).then(({canceled:Q,result:P})=>{p(P)})}),out:t=>{i.value.push({id:Math.random().toString(),text:t.type==="str"?t.value:g(t),print:!0})},log:(t,p)=>{switch(t){case"end":i.value.push({id:Math.random().toString(),text:g(p.val,!0),print:!1});break}}});let s;try{s=S.parse(o.script)}catch(t){w({type:"error",text:`Syntax error : ${t}`});return}try{await l.exec(s)}catch(t){w({type:"error",text:String(t)})}};return _({name:f,configure:k,id:c.widget?c.widget.id:null}),(l,s)=>(d(),C(G,{"show-header":n(o).showHeader,class:"mkw-aiscript"},{header:u(()=>[R,B(m(n(U).ts._widgets.aiscript),1)]),default:u(()=>[a("div",W,[T(a("textarea",{"onUpdate:modelValue":s[0]||(s[0]=e=>n(o).script=e),placeholder:"(1 + 1)"},null,512),[[D,n(o).script]]),a("button",{class:"_buttonPrimary",onClick:b},"RUN"),a("div",X,[(d(!0),h(V,null,E(i.value,e=>(d(),h("div",{key:e.id,class:N(["log",{print:e.print}])},m(e.text),3))),128))])])]),_:1},8,["show-header"]))}}),ot=A(O,[["__scopeId","data-v-9adcbf97"]]);export{ot as default};
