import{r as n}from"./index-B9zr-vzA.js";import{l as m}from"./chunk-JZWAC4HX-5kJHQiQ9.js";import{b as y}from"./root-loader-Cnwtpb_k.js";import{o as p,l as S,i as E,s as v}from"./schemas-RF4TJjJw.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"8a6db0ac5fe78363b0c97fe458a96ce773bf357c"};var s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="d48a4c8c-4f47-4f50-9fbb-b9fe0a96a2b5",t._sentryDebugIdIdentifier="sentry-dbid-d48a4c8c-4f47-4f50-9fbb-b9fe0a96a2b5")}catch{}})();const w=p({type:S("epicshop:file-change"),data:p({filePaths:E(v())})});function R({watchPaths:t}){const s=y(),r=m(),c=n.useRef(r);n.useEffect(()=>{c.current=r},[r]);const f=new URLSearchParams;for(const e of t)f.append("watch",e);const a=f.toString(),b=s.protocol==="https:"?"wss:":"ws:",h=s.hostname,g=s.port,i=`${b}//${h}:${g}/__ws?${a}`;n.useEffect(()=>{if(!a)return;let e=null;function l(){e&&e.close();try{e=new WebSocket(i)}catch(o){console.error("🐨 EpicShop WebSocket failed to connect:",o);return}e.onmessage=o=>{const d=w.safeParse(JSON.parse(o.data));if(!d.success)return;const{data:u}=d;u.type==="epicshop:file-change"&&(console.log("🐨 Revalidating due to file changes:",u.data.filePaths),c.current.revalidate())},e.onclose=o=>{o.code===1006&&setTimeout(()=>{l()},1e3)},e.onerror=o=>{console.error("🐨 EpicShop WebSocket error:",o)}}return l(),()=>{e?.close()}},[a,i])}const D=ENV.EPICSHOP_DEPLOYED?()=>null:R;export{D as u};
//# sourceMappingURL=revalidation-ws-bT9ZdRVV.js.map
