import{r as p,j as l,z as T,f as v,J as E,H as P,i as x,a as b,b as R,c as U,o as z}from"../chunks/chunk-CF7PZJR8.js";import{u as A,a as C,c as _,S as j,b as D,C as F,d as O,h as y,V,e as L,A as B,W as H}from"../chunks/chunk-DH1DswfA.js";import{t as u,T as I}from"../chunks/chunk-DvrnVFXc.js";import{u as S,a as M,F as N}from"../chunks/chunk-BGUxsRwc.js";import{X as Z,D as k,Z as $}from"../chunks/chunk-BD-Bs-uJ.js";import{j as K}from"../chunks/chunk-BUK5U-1n.js";import{c as W}from"../chunks/chunk-ChHTQ4Sk.js";import"../chunks/chunk-BdvozYt0.js";/* empty css                      */import"../chunks/chunk-BXl3LOEh.js";import"../chunks/chunk-2B0sFjzh.js";import"../chunks/chunk-SmZMj1n8.js";import"../chunks/chunk-BHDKgRpG.js";import"../chunks/chunk-Q1j31JH2.js";import"../chunks/chunk-4_gci6_w.js";function X({stream:a,onScenePublish:d}){const[o,f]=p.useState(!1),s=async n=>{const i=n.target.files?.[0];if(i){if(!i.name.endsWith(".vrz")){alert("Please select a .vrz file");return}f(!0);try{const e=await i.arrayBuffer(),{sceneYaml:t,assetsInZip:h}=await A(e),g=C.getState().ops.addFileByMapping;if(g(h,!0),t){const w=K.load(t),m=_(w,h);a.publish(j(m)),d?.()}}catch(e){console.error("Error processing VRZ file:",e),alert("Failed to process VRZ file")}finally{f(!1)}}};return l.jsx("div",{className:"absolute top-4 left-4 z-10",children:l.jsxs("label",{className:"inline-flex cursor-pointer items-center rounded bg-blue-500 px-4 py-2 text-white hover:bg-blue-600 disabled:opacity-50",children:[o?"Processing...":"Upload .vrz file",l.jsx("input",{type:"file",accept:".vrz",onChange:s,disabled:o,className:"hidden"})]})})}function q({stream:a,editMode:d,headlessRenderer:o}){const{children:f,rawChildren:s,bgChildren:n,htmlChildren:i,ops:e,...t}=D();return p.useEffect(()=>{const h=[a.subscribe("SET",e.set),a.subscribe("ADD",e.add),a.subscribe("UPDATE",e.update),a.subscribe("UPSERT",e.upsert),a.subscribe("REMOVE",e.removeByKey),a.subscribe("TIMEOUT",e.timeout)];return()=>h.forEach(g=>g())},[e.add,e.removeByKey,e.set,e.timeout,e.update,e.upsert,a]),l.jsx(F,{children:l.jsxs(O,{rawChildren:y(s,d),bgChildren:y(n,d),htmlChildren:y(i,d),frameloop:"demand",editMode:d,...t,children:[y(f,d),o]})})}function J({captureFormat:a="image/png",captureQuality:d=.95,captureDelay:o=1e3}={}){const s=!(typeof window<"u"&&(window.__PUPPETEER__||navigator.userAgent.includes("HeadlessChrome"))),n=Y(),{gl:i,scene:e,camera:t,invalidate:h}=S(),g=p.useRef(!1);return p.useEffect(()=>{if(!n||g.current)return;g.current=!0,console.log("🎬 Scene ready, preparing to capture...");for(let r=0;r<3;r++)h(),i.render(e,t);setTimeout(()=>{console.log("🎬 Extra delay complete, rendering final frames...");for(let r=0;r<5;r++)i.render(e,t);requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{w()})})})},o);function w(){try{i.render(e,t),console.log("📸 Capturing scene...");const r=i.domElement.toDataURL(a,d);console.log("✅ Scene captured successfully, data URL length:",r.length),typeof window<"u"&&(window.__CAPTURED_IMAGE__=r,window.__CAPTURE_COMPLETE__=!0),s&&m(r)}catch(r){console.error("❌ Failed to capture scene:",r),typeof window<"u"&&(window.__CAPTURE_ERROR__=r.message,window.__CAPTURE_COMPLETE__=!0)}}function m(r){const c=document.createElement("img");c.src=r,c.style.cssText=`
        position: fixed;
        bottom: 10px;
        right: 10px;
        width: 200px;
        border: 2px solid #0f0;
        z-index: 9999;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
      `,c.title="Captured Scene Preview",document.body.appendChild(c),setTimeout(()=>c.remove(),5e3)}},[n,i,e,t,h,a,d,s,o]),null}function Y(a=10,d=5e3){const[o,f]=p.useState(!1),s=p.useRef(0),n=p.useRef(0),{invalidate:i}=S();return p.useEffect(()=>{const e=u.onStart,t=u.onLoad,h=u.onProgress,g=u.onError;u.onStart=(m,r,c)=>{console.log(`🔄 Loading started: ${c-r} items remaining`),n.current=c-r,s.current=0,f(!1),e?.(m,r,c)},u.onProgress=(m,r,c)=>{console.log(`⏳ Loading progress: ${r}/${c} - ${m}`),n.current=c-r,h?.(m,r,c)},u.onLoad=()=>{console.log("✅ All assets loaded"),n.current=0,t?.()},u.onError=m=>{console.error(`Failed to load: ${m}`),n.current=Math.max(0,n.current-1),g?.(m)};const w=setTimeout(()=>{o||(console.warn("⚠️ Scene ready timeout reached, forcing ready state"),f(!0))},d);return()=>{clearTimeout(w),u.onStart=e,u.onLoad=t,u.onProgress=h,u.onError=g}},[o,d]),M(()=>{o||(i(),n.current===0?(s.current++,s.current>=a&&(console.log(`✅ Scene ready after ${s.current} stable frames`),f(!0))):s.current=0)}),o}typeof window<"u"&&(window.React=T,window.ReactDOM=v,window.VUER=V,window.THREE=I,window.JSX=E,window.FIBER=N,window.XR=Z,window.Drei=k,window.ZUSTAND=$);function G(){const[{message:a,mtype:d},o]=p.useState({message:null,mtype:null}),f=p.useMemo(()=>({showError:t=>setTimeout(()=>o({message:t,mtype:"error"}),1),showSuccess:t=>setTimeout(()=>o({message:t,mtype:"success"}),1),showWarning:t=>setTimeout(()=>o({message:t,mtype:"warning"}),1),showInfo:t=>setTimeout(()=>o({message:t,mtype:"info"}),1),showModal:t=>{console.log(t)}}),[]),s=p.useMemo(()=>new L,[]),[n,i]=p.useState(0),e=()=>{i(Date.now())};return l.jsxs(l.Fragment,{children:[l.jsx(P,{children:l.jsx("title",{children:"Vuer (Headless render)"})}),l.jsxs("main",{className:W("flex h-screen w-screen items-center justify-center overflow-hidden"),children:[l.jsx(X,{stream:s,onScenePublish:e}),l.jsx(B,{value:f,children:l.jsx(H,{children:l.jsx(q,{stream:s,headlessRenderer:n>0?l.jsx(J,{},n):void 0},"scene")})})]})]})}const Q=Object.freeze(Object.defineProperty({__proto__:null,default:G},Symbol.toStringTag,{value:"Module"})),he={hasServerOnlyHook:{type:"computed",definedAtData:null,valueSerialized:{type:"js-serialized",value:!0}},isClientRuntimeLoaded:{type:"computed",definedAtData:null,valueSerialized:{type:"js-serialized",value:!0}},onBeforeRenderEnv:{type:"computed",definedAtData:null,valueSerialized:{type:"js-serialized",value:null}},dataEnv:{type:"computed",definedAtData:null,valueSerialized:{type:"js-serialized",value:{server:!0}}},guardEnv:{type:"computed",definedAtData:null,valueSerialized:{type:"js-serialized",value:null}},onRenderClient:{type:"standard",definedAtData:{filePathToShowToUser:"vike-react/__internal/integration/onRenderClient",fileExportPathToShowToUser:[]},valueSerialized:{type:"pointer-import",value:z}},onPageTransitionStart:{type:"standard",definedAtData:{filePathToShowToUser:"/pages/+onPageTransitionStart.ts",fileExportPathToShowToUser:[]},valueSerialized:{type:"plus-file",exportValues:U}},onPageTransitionEnd:{type:"standard",definedAtData:{filePathToShowToUser:"/pages/+onPageTransitionEnd.ts",fileExportPathToShowToUser:[]},valueSerialized:{type:"plus-file",exportValues:R}},Page:{type:"standard",definedAtData:{filePathToShowToUser:"/pages/headless-render/+Page.tsx",fileExportPathToShowToUser:[]},valueSerialized:{type:"plus-file",exportValues:Q}},hydrationCanBeAborted:{type:"standard",definedAtData:{filePathToShowToUser:"vike-react/config",fileExportPathToShowToUser:["default","hydrationCanBeAborted"]},valueSerialized:{type:"js-serialized",value:!0}},Layout:{type:"cumulative",definedAtData:[{filePathToShowToUser:"/pages/+Layout.tsx",fileExportPathToShowToUser:[]}],valueSerialized:[{type:"plus-file",exportValues:b}]},title:{type:"standard",definedAtData:{filePathToShowToUser:"/+config.ts",fileExportPathToShowToUser:["default","title"]},valueSerialized:{type:"js-serialized",value:"Vuer UIKit | FortyFive Labs"}},Loading:{type:"standard",definedAtData:{filePathToShowToUser:"vike-react/__internal/integration/Loading",fileExportPathToShowToUser:[]},valueSerialized:{type:"pointer-import",value:x}}};export{he as configValuesSerialized};
