var v=Object.defineProperty,w=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var _=(e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,a=(e,t)=>{for(var i in t||(t={}))h.call(t,i)&&_(e,i,t[i]);if(d)for(var i of d(t))F.call(t,i)&&_(e,i,t[i]);return e},c=(e,t)=>w(e,x(t));import{I as A,j as u,F as o,O as C,v as l}from"./parser-RGrRIRgY.js";import{P as k}from"./index-eSfribeX.js";import{c as N}from"./api-I791pgl2.js";import{v as V,J as y,K as M,L as O,N as T,O as j}from"./app-JmgyQoR0.js";import"./vue-y3KLWBaS.js";const E=new k,s=new Map;function G(e){console.info("Plugin installed:",e.name,`v${e.version}`);const t=new A(J({plugin:e,storageKey:`plugins:${e.id}`}),{in:i=>new Promise(n=>{V({title:i}).then(({canceled:r,result:g})=>{n(g)})}),out:i=>{console.log(i)},log:(i,n)=>{}});b({plugin:e,aiscript:t}),t.exec(E.parse(e.src))}function J(e){var i;const t=new Map;for(const[n,r]of Object.entries((i=e.plugin.config)!=null?i:{}))t.set(n,u(typeof e.plugin.configData[n]!="undefined"?e.plugin.configData[n]:r.default));return c(a({},N(c(a({},e),{token:e.plugin.token}))),{"Mk:register_post_form_action":o(([n,r])=>{I({pluginId:e.plugin.id,title:n.value,handler:r})}),"Mk:register_user_action":o(([n,r])=>{P({pluginId:e.plugin.id,title:n.value,handler:r})}),"Mk:register_note_action":o(([n,r])=>{m({pluginId:e.plugin.id,title:n.value,handler:r})}),"Plugin:register_post_form_action":o(([n,r])=>{I({pluginId:e.plugin.id,title:n.value,handler:r})}),"Plugin:register_user_action":o(([n,r])=>{P({pluginId:e.plugin.id,title:n.value,handler:r})}),"Plugin:register_note_action":o(([n,r])=>{m({pluginId:e.plugin.id,title:n.value,handler:r})}),"Plugin:register_note_view_interruptor":o(([n])=>{D({pluginId:e.plugin.id,handler:n})}),"Plugin:register_note_post_interruptor":o(([n])=>{K({pluginId:e.plugin.id,handler:n})}),"Plugin:register_page_view_interruptor":o(([n])=>{$({pluginId:e.plugin.id,handler:n})}),"Plugin:open_url":o(([n])=>{window.open(n.value,"_blank")}),"Plugin:config":C(t)})}function b({plugin:e,aiscript:t}){s.set(e.id,t)}function I({pluginId:e,title:t,handler:i}){y.push({title:t,handler:(n,r)=>{const g=s.get(e);g&&g.execFn(i,[u(n),o(([p,f])=>{!p||!f||r(l(p),l(f))})])}})}function P({pluginId:e,title:t,handler:i}){j.push({title:t,handler:n=>{const r=s.get(e);r&&r.execFn(i,[u(n)])}})}function m({pluginId:e,title:t,handler:i}){T.push({title:t,handler:n=>{const r=s.get(e);r&&r.execFn(i,[u(user)])}})}function D({pluginId:e,handler:t}){M.push({handler:async i=>{const n=s.get(e);if(n)return l(await n.execFn(t,[u(i)]))}})}function K({pluginId:e,handler:t}){O.push({handler:async i=>{const n=s.get(e);if(n)return l(await n.execFn(t,[u(i)]))}})}function $({pluginId:e,handler:t}){pageViewInterruptors.push({handler:async i=>{const n=s.get(e);if(n)return l(await n.execFn(t,[u(i)]))}})}export{G as install};
