var q=Object.defineProperty,A=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var y=(n,e,t)=>e in n?q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,x=(n,e)=>{for(var t in e||(e={}))L.call(e,t)&&y(n,t,e[t]);if(h)for(var t of h(e))$.call(e,t)&&y(n,t,e[t]);return n},V=(n,e)=>A(n,j(e));import{a4 as z,i as r,an as K,a6 as O,M as U,g as i,t as W,f as F,_ as G,aA as H,u as J,bk as Q,C as P}from"./app-JmgyQoR0.js";import{g as X,I as Y}from"./parser-RGrRIRgY.js";import{P as Z}from"./index-eSfribeX.js";import{v as ee}from"./v4-U7xWZqn4.js";import{b as te,a as ne,c as b,h as ae,t as se,l as d,j as m,K as f,E as _,z as g,u as w,d as oe,n as re}from"./vue-y3KLWBaS.js";const ie={class:"_formRoot"},le={class:"_formBlock"},ue=w("i",{class:"ph-check ph-bold ph-lg"},null,-1),ve=te({__name:"plugin.install",setup(n){const e=ne();function t(a){try{return Q(a,"0.12.0")>=0}catch(s){return!1}}function B({id:a,meta:s,src:o,token:l}){P.set("plugins",P.get("plugins").concat(V(x({},s),{id:a,active:!0,configData:{},src:o,token:l})))}const N=new Z;async function C(){if(e.value==null)return;const a=X(e.value);if(a==null){i({type:"error",text:"No language version annotation found :("});return}if(!t(a)){i({type:"error",text:`aiscript version '${a}' is not supported :(`});return}let s;try{s=N.parse(e.value)}catch(p){i({type:"error",text:`Syntax error : ${p}`});return}const o=Y.collectMetadata(s);if(o==null){i({type:"error",text:"No metadata found :("});return}const l=o.get(null);if(l==null){i({type:"error",text:"No metadata found :("});return}const{name:c,version:v,author:k,description:M,permissions:u,config:R}=l;if(c==null||v==null||k==null){i({type:"error",text:"Required property (name, version, author) not found :("});return}const D=u==null||u.length===0?null:await new Promise((p,ce)=>{W(oe(()=>G(()=>import("./MkTokenGenerateWindow-bgSBQwsC.js"),__vite__mapDeps([0,1,2,3]))),{title:r.ts.tokenRequested,information:r.ts.pluginTokenRequestedDescription,initialName:c,initialPermissions:u},{done:async T=>{const{name:E,permissions:I}=T,{token:S}=await F("miauth/gen-token",{session:null,name:E,permission:I});p(S)}},"closed")});B({id:ee(),meta:{name:c,version:v,author:k,description:M,permissions:u,config:R},src:e.value,token:D}),H(),re(()=>{J()})}return b(()=>[]),b(()=>[]),z({title:r.ts._plugin.install,icon:"ph-download-simple ph-bold ph-lg"}),(a,s)=>(ae(),se("div",ie,[d(K,{warn:"",class:"_formBlock"},{default:m(()=>[f(_(g(r).ts._plugin.installWarn),1)]),_:1}),d(O,{modelValue:e.value,"onUpdate:modelValue":s[0]||(s[0]=o=>e.value=o),tall:"",class:"_formBlock"},{label:m(()=>[f(_(g(r).ts.code),1)]),_:1},8,["modelValue"]),w("div",le,[d(U,{disabled:e.value==null,primary:"",inline:"",onClick:C},{default:m(()=>[ue,f(" "+_(g(r).ts.install),1)]),_:1},8,["disabled"])])]))}});export{ve as default};
function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = ["MkTokenGenerateWindow-bgSBQwsC.js","app-JmgyQoR0.js","vue-y3KLWBaS.js","app-9iivmIpH.css"]
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}