const ipcRenderer=require("electron").ipcRenderer;class IPC{subscribe(e,r){return ipcRenderer.on(e,r),function(){ipcRenderer.removeListener(e,r)}}send(e,...r){try{ipcRenderer.send(e,...r)}catch(n){let o;pm.logger.error("IPC Renderer: Bad usage of IPC",{channel:e,args:r,err:n});try{o=JSON.parse(JSON.stringify(r)),ipcRenderer.send(e,...o)}catch(r){pm.logger.error("IPC Renderer: Bad usage of IPC, cannot stringify circular/BigInt referenced object",{channel:e,newArgs:o,error:r})}}}sendToHost(e,...r){try{ipcRenderer.sendToHost(e,...r)}catch(n){let o;pm.logger.error("IPC Renderer: Bad usage of IPC",{channel:e,args:r,err:n});try{o=JSON.parse(JSON.stringify(r)),ipcRenderer.sendToHost(e,...o)}catch(r){pm.logger.error("IPC Renderer: Bad usage of IPC, cannot stringify circular/BigInt referenced object",{channel:e,newArgs:o,error:r})}}}sendSync(e,...r){pm.logger.warn("Sending synchronous messages over IPC is deprecated!! We recommend you to move your usage to asynchronous messaging over IPC");try{ipcRenderer.sendSync(e,...r)}catch(n){let o;pm.logger&&pm.logger.error&&pm.logger.error("IPC Renderer: Bad usage of IPC",{channel:e,args:r,err:n});try{o=JSON.parse(JSON.stringify(r)),ipcRenderer.sendSync(e,...o)}catch(r){pm.logger.error("IPC Renderer: Bad usage of IPC, cannot stringify circular/BigInt referenced object",{channel:e,newArgs:o,error:r})}}}invoke(e,...r){return ipcRenderer.invoke(e,...r).catch(n=>{if("An object could not be cloned."===n.message){let o;pm.logger&&pm.logger.error&&pm.logger.error("IPC Renderer: Bad usage of IPC",{channel:e,args:r,err:n});try{return o=JSON.parse(JSON.stringify(r)),ipcRenderer.invoke(e,...o)}catch(r){pm.logger.error("IPC Renderer: Bad usage of IPC, cannot stringify circular/BigInt referenced object",{channel:e,newArgs:o,error:r})}}return Promise.reject(n)})}}const sdk={ipc:new IPC};window.pm=window.pm||{},window.pm.sdk=sdk,window.pm.logger={info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),getContext:function(e,r){return{api:e,domain:r}}};