import{h as f}from"./hood-logo-CePbdOqP.js";import{g as u,u as b,O as q,n as U,D as B}from"./overlaySettings-C8Zjt3uj.js";const R="hoodwalletOverlay",o="hoodwallet-overlay",g={x:-1,y:-1,width:390,height:620,tabY:-1,visible:!1,minimized:!1};function l(e,a,n){return Math.max(a,Math.min(n,e))}function F(){try{const e=localStorage.getItem(R);return e?{...g,...JSON.parse(e)}:{...g}}catch{return{...g}}}function d(e){try{localStorage.setItem(R,JSON.stringify(e))}catch{}}function G(){if(document.getElementById("hoodwallet-overlay-styles"))return;const e=document.createElement("style");e.id="hoodwallet-overlay-styles",e.textContent=`
#${o}, #hoodwallet-float {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-sizing: border-box;
}
#${o} {
  position: fixed;
  z-index: 2147483647;
  display: none;
  flex-direction: column;
  min-width: 320px;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid rgba(0, 215, 255, .55);
  border-radius: 22px;
  background: #09080d;
  box-shadow: 0 32px 90px rgba(0, 0, 0, .58), 0 0 0 1px rgba(16, 227, 134, .22), 0 0 48px rgba(0, 215, 255, .22);
  animation: hoodwallet-in .2s ease-out;
}
#${o}.ow-visible { display: flex; }
#${o}.ow-docked {
  top: 0 !important;
  bottom: 0 !important;
  min-height: 100vh;
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
  box-shadow: 0 0 40px rgba(0, 215, 255, .18);
}
#${o}.ow-docked.ow-side-right {
  right: 0 !important;
  left: auto !important;
  border-right: 0;
  border-left: 2px solid rgba(0, 215, 255, .75);
  animation: hoodwallet-dock-right .18s ease-out;
}
#${o}.ow-docked.ow-side-left {
  right: auto !important;
  left: 0 !important;
  border-left: 0;
  border-right: 2px solid rgba(0, 215, 255, .75);
  animation: hoodwallet-dock-left .18s ease-out;
}
#${o}.ow-docked .ow-bar { cursor: default; }
#${o}.ow-docked .ow-resize { display: none; }
#${o}.ow-moving { transition: none; opacity: .94; }
#${o}.ow-minimized {
  display: flex;
  width: 56px !important;
  height: 56px !important;
  min-width: 56px;
  min-height: 56px;
  border-radius: 18px;
}
#${o}.ow-minimized .ow-bar,
#${o}.ow-minimized .ow-frame,
#${o}.ow-minimized .ow-resize { display: none; }
#${o}.ow-minimized .ow-mini { display: grid; }
@keyframes hoodwallet-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes hoodwallet-dock-right {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes hoodwallet-dock-left {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}
html.ow-page-pushed-right {
  width: calc(100% - var(--hoodwallet-dock-width)) !important;
  margin-right: var(--hoodwallet-dock-width) !important;
  overflow-x: hidden !important;
}
html.ow-page-pushed-left {
  width: calc(100% - var(--hoodwallet-dock-width)) !important;
  margin-left: var(--hoodwallet-dock-width) !important;
  overflow-x: hidden !important;
}
#${o} .ow-bar {
  display: flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(180deg, #15121d 0%, #0f0d14 100%);
  cursor: grab;
  user-select: none;
}
#${o} .ow-bar:active { cursor: grabbing; }
#${o} .ow-brand { display: flex; align-items: center; gap: 9px; }
#${o} .ow-logo, #${o} .ow-mini-logo {
  display: block;
  object-fit: cover;
  border-radius: 8px;
  background: #050509;
  box-shadow: inset 0 1px rgba(255, 255, 255, .12), 0 4px 14px rgba(0, 215, 255, .35);
}
#${o} .ow-logo { width: 22px; height: 22px; }
#${o} .ow-title { color: #f7f4ff; font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
#${o} .ow-status { width: 5px; height: 5px; border-radius: 50%; background: #34d399; box-shadow: 0 0 8px #34d399; }
#${o} .ow-controls { display: flex; gap: 3px; }
#${o} .ow-control {
  all: initial;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  color: #8f899d;
  cursor: pointer;
  font: 500 15px/1 system-ui, sans-serif;
  transition: color .14s ease, background .14s ease;
}
#${o} .ow-control:hover { color: #f5f3ff; background: rgba(255, 255, 255, .07); }
#${o} .ow-close:hover { color: #fb7185; background: rgba(244, 63, 94, .1); }
#${o} .ow-frame { flex: 1; min-height: 0; overflow: hidden; background: #09080d; }
#${o} iframe { display: block; width: 100%; height: 100%; border: 0; background: #09080d; }
#${o} .ow-mini {
  all: initial;
  display: none;
  place-items: center;
  width: 56px;
  height: 56px;
  cursor: pointer;
}
#${o} .ow-mini-logo { width: 36px; height: 36px; border-radius: 13px; }
#${o} .ow-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; }
#${o} .ow-resize::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #554d67;
  border-bottom: 2px solid #554d67;
}
#hoodwallet-float {
  all: initial;
  position: fixed;
  right: 0;
  z-index: 2147483646;
  display: flex;
  width: 31px;
  height: 78px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 227, 134, .35);
  border-right: 0;
  border-radius: 13px 0 0 13px;
  color: white;
  background: linear-gradient(180deg, #10e386, #00d7ff 55%, #32b4ff);
  box-shadow: -7px 10px 32px rgba(0, 215, 255, .28), inset 0 1px rgba(255, 255, 255, .25);
  cursor: pointer;
  opacity: .7;
  transition: width .16s ease, opacity .16s ease, box-shadow .16s ease;
  user-select: none;
}
#hoodwallet-float:hover { width: 37px; opacity: 1; box-shadow: -10px 12px 38px rgba(0, 215, 255, .4); }
#hoodwallet-float.ow-side-left {
  right: auto;
  left: 0;
  border-right: 1px solid rgba(16, 227, 134, .35);
  border-left: 0;
  border-radius: 0 13px 13px 0;
}
#hoodwallet-float.ow-hidden { display: none; }
#hoodwallet-float.ow-tab-moving { transition: none; cursor: grabbing; opacity: 1; }
#hoodwallet-float span { color: white; font: 850 13px/1 Inter, system-ui, sans-serif; pointer-events: none; }
`,document.head.appendChild(e)}function T(){if(document.getElementById(o)||!document.body)return null;G();const e=F();let a=B;(e.x<0||e.y<0)&&(e.x=Math.max(12,window.innerWidth-e.width-24),e.y=Math.max(12,(window.innerHeight-e.height)/2)),e.tabY=e.tabY<0?Math.max(20,window.innerHeight/2-39):e.tabY;const n=document.createElement("button");n.id="hoodwallet-float",n.type="button",n.title="Open HoodWallet",n.setAttribute("aria-label","Open HoodWallet"),n.innerHTML=`<img src="${f}" alt="HoodWallet" width="18" height="18" style="border-radius:6px;display:block" />`,n.style.top=`${e.tabY}px`;const t=document.createElement("aside");t.id=o,t.setAttribute("aria-label","HoodWallet overlay"),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.innerHTML=`
    <div class="ow-bar">
      <div class="ow-brand">
        <img class="ow-logo" src="${f}" alt="" width="22" height="22" />
        <span class="ow-title">HoodWallet</span>
        <span class="ow-status" title="Engine ready"></span>
      </div>
      <div class="ow-controls">
        <button class="ow-control ow-minimize" type="button" aria-label="Minimize" title="Minimize">&minus;</button>
        <button class="ow-control ow-close" type="button" aria-label="Close" title="Close">&#215;</button>
      </div>
    </div>
    <div class="ow-frame"><iframe title="HoodWallet" allow="clipboard-write"></iframe></div>
    <button class="ow-mini" type="button" aria-label="Restore HoodWallet"><img class="ow-mini-logo" src="${f}" alt="" width="36" height="36" /></button>
    <div class="ow-resize" role="separator" aria-label="Resize HoodWallet"></div>
  `;const x=t.querySelector("iframe");function _(){const i=chrome.runtime.getManifest().version;return chrome.runtime.getURL(`src/panel/index.html?v=${encodeURIComponent(i)}`)}function p(){x.src=_()}p(),document.body.append(n,t);function y(){const i=a.mode==="docked"&&e.visible&&!e.minimized;document.documentElement.style.setProperty("--hoodwallet-dock-width",`${a.width}px`),document.documentElement.classList.toggle("ow-page-pushed-left",i&&a.side==="left"),document.documentElement.classList.toggle("ow-page-pushed-right",i&&a.side==="right")}function v(i){a=U(i),t.classList.toggle("ow-docked",a.mode==="docked"),t.classList.toggle("ow-side-left",a.side==="left"),t.classList.toggle("ow-side-right",a.side==="right"),n.classList.toggle("ow-side-left",a.side==="left"),a.mode==="docked"?(t.style.width=`${a.width}px`,t.style.height="100vh",t.style.top="0",t.style.left=a.side==="left"?"0":"auto",t.style.right=a.side==="right"?"0":"auto"):(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.style.left=`${e.x}px`,t.style.right="auto",t.style.top=`${e.y}px`),n.style.left=a.side==="left"?"0":"auto",n.style.right=a.side==="right"?"0":"auto",b(a)&&a.alwaysOpen&&(e.visible=!0,e.minimized=!1),s()}function $(){e.visible=!1,e.minimized=!1,s()}function D(){$(),document.documentElement.classList.remove("ow-page-pushed-left","ow-page-pushed-right"),document.documentElement.style.removeProperty("--hoodwallet-dock-width"),n.remove(),t.remove()}function s(){t.classList.toggle("ow-visible",e.visible),t.classList.toggle("ow-minimized",e.minimized&&e.visible),n.classList.toggle("ow-hidden",e.visible&&!e.minimized),y(),d(e)}function L(){const i=chrome.runtime.getManifest().version;x.src.includes(`v=${encodeURIComponent(i)}`)||p(),e.visible=!0,e.minimized=!1,a.mode==="floating"&&(e.x=l(e.x,8,Math.max(8,window.innerWidth-e.width-8)),e.y=l(e.y,8,Math.max(8,window.innerHeight-e.height-8)),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`),s()}function k(){e.visible=!e.visible,e.visible&&(e.minimized=!1),s()}let c=!1,w=!1,E=0,z=0;n.addEventListener("mousedown",i=>{c=!0,w=!1,E=i.clientY,z=n.offsetTop,n.classList.add("ow-tab-moving"),i.preventDefault()}),document.addEventListener("mousemove",i=>{if(!c)return;const I=i.clientY-E;Math.abs(I)>3&&(w=!0),e.tabY=l(z+I,8,Math.max(8,window.innerHeight-86)),n.style.top=`${e.tabY}px`}),document.addEventListener("mouseup",()=>{c&&d(e),c=!1,n.classList.remove("ow-tab-moving")}),n.addEventListener("click",()=>{w||k()});const P=t.querySelector(".ow-bar");let h=!1,S=0,Y=0;P.addEventListener("mousedown",i=>{a.mode!=="docked"&&(i.target.closest(".ow-controls")||(h=!0,S=i.clientX-t.offsetLeft,Y=i.clientY-t.offsetTop,t.classList.add("ow-moving"),i.preventDefault()))}),document.addEventListener("mousemove",i=>{h&&(e.x=l(i.clientX-S,0,Math.max(0,window.innerWidth-t.offsetWidth)),e.y=l(i.clientY-Y,0,Math.max(0,window.innerHeight-t.offsetHeight)),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`)}),document.addEventListener("mouseup",()=>{h&&d(e),h=!1,t.classList.remove("ow-moving")});const C=t.querySelector(".ow-resize");let m=!1,M=0,H=0,O=0,W=0;return C.addEventListener("mousedown",i=>{a.mode!=="docked"&&(m=!0,M=i.clientX,H=i.clientY,O=t.offsetWidth,W=t.offsetHeight,t.classList.add("ow-moving"),i.preventDefault(),i.stopPropagation())}),document.addEventListener("mousemove",i=>{m&&(e.width=l(O+i.clientX-M,320,Math.min(640,window.innerWidth)),e.height=l(W+i.clientY-H,430,Math.min(860,window.innerHeight)),t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)}),document.addEventListener("mouseup",()=>{m&&d(e),m=!1,t.classList.remove("ow-moving")}),t.querySelector(".ow-minimize").addEventListener("click",()=>{e.minimized=!0,s()}),t.querySelector(".ow-mini").addEventListener("click",L),t.querySelector(".ow-close").addEventListener("click",()=>{e.visible=!1,e.minimized=!1,s()}),window.addEventListener("resize",()=>{if(a.mode==="docked"){t.style.width=`${a.width}px`,t.style.height="100vh",y();return}e.x=l(e.x,0,Math.max(0,window.innerWidth-t.offsetWidth)),e.y=l(e.y,0,Math.max(0,window.innerHeight-t.offsetHeight)),e.tabY=l(e.tabY,8,Math.max(8,window.innerHeight-86)),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,n.style.top=`${e.tabY}px`,d(e)}),s(),u().then(v),{show:L,hide:$,toggle:k,applySettings:v,destroy:D,reloadPanelFrame:p}}let r=null;function A(){document.getElementById(o)?.remove(),document.getElementById("hoodwallet-float")?.remove(),document.documentElement.classList.remove("ow-page-pushed-left","ow-page-pushed-right"),document.documentElement.style.removeProperty("--hoodwallet-dock-width")}async function X(){const e=await u();if(!b(e)){r?.destroy(),r=null,A();return}r?r.applySettings(e):r=T()}chrome.runtime.onMessage.addListener(e=>{if(e.type==="PANEL_RELOAD"){r?.reloadPanelFrame();return}if(e.type==="HIDE_OVERLAY"){r?.destroy(),r=null,A();return}(async()=>{const a=await u();b(a)&&(r||(r=T()),r&&(e.type==="SHOW_OVERLAY"&&r.show(),e.type==="TOGGLE_OVERLAY"&&r.toggle()))})()});chrome.storage.onChanged.addListener((e,a)=>{a!=="local"||!e[q]||X()});X();
