let d=0;function f(e){return`${e}_callback_${Date.now()}_${d++}`}function h(e,t){return typeof t>"u"&&(t={}),new Promise((n,r)=>{const s=f("exec");window[s]=(i,l,a)=>{n({errno:i,stdout:l,stderr:a}),o(s)};function o(i){delete window[i]}try{ksu.exec(e,JSON.stringify(t),s)}catch(i){r(i),o(s)}})}function c(){this.listeners={}}c.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)};c.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(n=>n(...t))};function u(){this.listeners={},this.stdin=new c,this.stdout=new c,this.stderr=new c}u.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)};u.prototype.emit=function(e,...t){this.listeners[e]&&this.listeners[e].forEach(n=>n(...t))};function w(e,t,n){typeof t>"u"?t=[]:t instanceof Array||(n=t),typeof n>"u"&&(n={});const r=new u,s=f("spawn");window[s]=r;function o(i){delete window[i]}r.on("exit",i=>{o(s)});try{ksu.spawn(e,JSON.stringify(t),JSON.stringify(n),s)}catch(i){r.emit("error",i),o(s)}return r}function y(e){ksu.fullScreen(e)}function k(e){ksu.enableEdgeToEdge(e)}function p(e){ksu.toast(e)}function g(){return ksu.moduleInfo()}function m(e){try{return JSON.parse(ksu.listPackages(e))}catch{return[]}}function N(e){try{return typeof e!="string"&&(e=JSON.stringify(e)),JSON.parse(ksu.getPackagesInfo(e))}catch{return[]}}function S(){ksu.exit()}export{k as enableEdgeToEdge,h as exec,S as exit,y as fullScreen,N as getPackagesInfo,m as listPackages,g as moduleInfo,w as spawn,p as toast};
