import{r as t}from"./utils-B1oDxhJx.js";import{c as i}from"./chains-By83jz87.js";function E(){const e=t.useCallback((n,x)=>new Promise((g,u)=>{const l=`${n}-${Date.now()}-${Math.random()}`,a=C=>{const{type:f,requestId:v,response:c}=C.data;f===`${n}-response`&&v===l&&(window.removeEventListener("message",a),c.success?g(c.data):u(new Error(c.error||"Unknown error")))};window.addEventListener("message",a),window.parent.postMessage({type:n,payload:x,requestId:l},"*"),setTimeout(()=>{window.removeEventListener("message",a),u(new Error("Request timeout"))},3e4)}),[]),s=t.useCallback(()=>e("get-pool-id"),[e]),r=t.useCallback(()=>e("get-token-mint"),[e]),o=t.useCallback(()=>e("get-bloom-token"),[e]),d=t.useCallback(n=>e("execute-buy",n),[e]),m=t.useCallback(n=>e("execute-sell",n),[e]),k=t.useCallback(n=>e("execute-dev-order",n),[e]),w=t.useCallback(n=>e("execute-transfer-tokens",n),[e]),b=t.useCallback(n=>e("execute-delete-order",n),[e]),h=t.useCallback(n=>e("execute-share-pnl",n),[e]),p=t.useCallback(n=>e("show-toast",n),[e]);return{getPoolId:s,getTokenMint:r,getBloomToken:o,executeBuy:d,executeSell:m,executeDevOrder:k,executeTransferTokens:w,executeDeleteOrder:b,executeSharePnl:h,showToast:p}}function I(){return{chain:t.useMemo(()=>{const s=new URLSearchParams(window.location.search),r=Number(s.get("chain"));return i.find(o=>o.id===r)??i[0]},[]),isLoading:!1}}export{E as a,I as u};
