import{w}from"./chunk-JZWAC4HX-0uKZ9a0b.js";import{j as m}from"./jsx-runtime-C5WNSv3b.js";import{r as u}from"./index-Bi6L2ga8.js";import{E as g,D as h}from"./epic-video-CBD2QuF7.js";import"./use-event-source-lSuOQRXY.js";import"./index-E_6kulJP.js";import"./index-B2VNpNxJ.js";import"./index-BCfhIjlz.js";import"./misc-w_rthUBN.js";import"./tooltip-DXU4r0k_.js";import"./root-loader-DlSJfUY6.js";import"./pe-tear8uic.js";import"./schemas-siASSt6b.js";import"./online-CIe0rJXF.js";import"./loading-DI7gaEz8.js";import"./format-CZ5n8p10.js";import"./user-DVcB6tJK.js";import"./workshop-config-BDoPVTl_.js";function l(p,r,i={}){const{schema:s}=i,e=crypto.randomUUID();return new Promise((t,o)=>{if(!window.parent||window.parent===window){console.log("[MCP] No parent frame available. Would have sent message:",{type:p,messageId:e,payload:r}),o(new Error("No parent frame available"));return}window.parent.postMessage({type:p,messageId:e,payload:r},"*");function n(a){if(a.data.type!=="ui-message-response"||a.data.messageId!==e)return;window.removeEventListener("message",n);const{response:d,error:f}=a.data.payload;if(f)return o(f);if(!s)return t(d);const c=s.safeParse(d);return c.success?t(c.data):o(c.error)}window.addEventListener("message",n)})}const H=w(function({loaderData:r}){const i=u.useRef(null);u.useEffect(()=>{r.videoInfos?.finally(()=>{if(window.parent.postMessage({type:"ui-lifecycle-iframe-ready"},"*"),!i.current)return;const e=i.current.clientHeight,t=i.current.clientWidth;window.parent.postMessage({type:"ui-size-change",payload:{height:e,width:t}},"*")})},[r.videoInfos]);async function s(e){const t=e.target;if(!(t instanceof HTMLAnchorElement))return;const o=t.href;if(!o)return;e.preventDefault(),e.stopPropagation();const n=o.startsWith("http")?new URL(o):new URL(o,window.location.origin);n.host===window.location.host&&n.pathname==="/login"&&await l("tool",{toolName:"login",params:{workshopDirectory:ENV.EPICSHOP_CONTEXT_CWD}}),await l("link",{url:n.toString()})}return m.jsx("div",{ref:i,onClickCapture:s,children:m.jsx(g,{epicVideoInfosPromise:r.videoInfos,children:m.jsx(h,{url:r.videoUrl})})})});export{H as default};
//# sourceMappingURL=epic-video-Cy2gEUna.js.map
