import{r as n}from"./index-BDZD4X5K.js";import{j as y}from"./chunk-UIGDSWPH-fNK8sKgt.js";import{a as E}from"./root-loader-BZ1M-egm.js";import{o as u,l as b,a as g,s as v}from"./types-D4aTVJpv.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"3ea6c863933c57219be78eb06addfb47859d8df2"}}catch{}})();const w=u({type:b("epicshop:file-change"),data:u({filePaths:g(v())})});function R({watchPaths:s}){const t=E(),a=y(),c=n.useRef(a);n.useEffect(()=>{c.current=a},[a]);const i=new URLSearchParams;for(const e of s)i.append("watch",e);const r=i.toString(),h=t.protocol==="https:"?"wss:":"ws:",m=t.hostname,S=t.port,l=`${h}//${m}:${S}/__ws?${r}`;n.useEffect(()=>{if(!r)return;let e=null;function f(){e&&e.close();try{e=new WebSocket(l)}catch(o){console.error("🐨 EpicShop WebSocket failed to connect:",o);return}e.onmessage=o=>{const p=w.safeParse(JSON.parse(o.data));if(!p.success)return;const{data:d}=p;d.type==="epicshop:file-change"&&(console.log("🐨 Revalidating due to file changes:",d.data.filePaths),c.current.revalidate())},e.onclose=o=>{o.code===1006&&setTimeout(()=>{f()},1e3)},e.onerror=o=>{console.error("🐨 EpicShop WebSocket error:",o)}}return f(),()=>{e?.close()}},[r,l])}const I=ENV.EPICSHOP_DEPLOYED?()=>null:R;export{I as u};
//# sourceMappingURL=revalidation-ws-wOM-mPAl.js.map
