@neurodyn/room-viewer 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6651,4 +6651,4 @@ ${em}`:em);function G4(e){return"shopify"===e.source||void 0!==e.apiKey}function
6651
6651
  `);if(n.includes("#include <output_fragment>")){e.fragmentShader=n.replace("#include <output_fragment>",`${r}
6652
6652
  #include <output_fragment>`);return}e.fragmentShader=n.replace("#include <opaque_fragment>",`${r}
6653
6653
  #include <opaque_fragment>`)}(n,t)},e.customProgramCacheKey=()=>`${n()}|neurodyn-room-scene-v2`,e.needsUpdate=!0,()=>{e.onBeforeCompile=r,e.customProgramCacheKey=n,e.side=i,e.transparent=a,e.alphaToCoverage=s,e.needsUpdate=!0}}let Wi=Math.PI/2;function Wa({glbUrl:e,position:t,quaternion:r,materialPatch:n}){let{resourceRef:i,rotation:a,setIsDragging:s}=Vs(),o=z0(e),l=(0,tx.useMemo)(()=>o.scene.clone(!0),[o]),c=(0,tx.useMemo)(()=>{let e;return e=new Set,l.traverse(t=>{if(!t.isMesh||!t.material)return;if(Array.isArray(t.material)){t.material=t.material.map(t=>{let r=t.clone();return e.add(r),r});return}let r=t.material.clone();e.add(r),t.material=r}),Array.from(e)},[l]),u=(0,tx.useMemo)(()=>vb.degToRad(a),[a]);return(0,tx.useLayoutEffect)(()=>{let e=c.map(e=>Wn(e,n));return()=>{e.forEach(e=>e())}},[c,n]),(0,tw.jsx)("group",{ref:i,position:t,quaternion:r,onPointerDown:()=>s(!0),onPointerUp:()=>s(!1),onPointerLeave:()=>s(!1),children:(0,tw.jsx)("group",{"rotation-z":u,children:(0,tw.jsx)("group",{"rotation-x":Wi,children:(0,tw.jsx)("primitive",{object:l})})})})}function Ws(e,t){(0,tx.useLayoutEffect)(()=>{let r=e.current;if(r)return Wn(r,t)},[e,t])}let Wo=[1,1,1];function Wl({node:e,position:t,scale:r=Wo,uvScale:n,materialPatch:i}){let a=(0,tx.useRef)(null);return(0,tx.useEffect)(()=>{if(!a.current||void 0===n)return;let t=a.current.geometry.attributes.uv,r=e.geometry.attributes.uv.array;for(let e=0;e<t.count;e++){let i=r[2*e],a=r[2*e+1];t.setXY(e,i*n,a)}t.needsUpdate=!0},[n,e.geometry]),(0,tx.useLayoutEffect)(()=>{let e=a.current?.material;if(!e)return;let t=(Array.isArray(e)?e:[e]).map(e=>Wn(e,i));return()=>{t.forEach(e=>e())}},[i,e]),(0,tw.jsx)(z3,{ref:a,object:e,position:t,scale:r})}function Wc({width:e,height:t,materialPatch:r}){let{material:n}=Vs(),{nodes:i}=z0(n?.native?.glbUrl),a=(0,tx.useMemo)(()=>{let e=new vx,t={};["vizbl0","vizbl1","vizbl2","vizbl3","vizbl4","vizbl5","vizbl6","vizbl7"].forEach(r=>{let n=i[r];if(!n?.geometry)return;let a=n.clone();a.geometry=n.geometry.clone(),Array.isArray(n.material)?a.material=n.material.map(e=>e.clone()):n.material&&(a.material=n.material.clone()),a.updateMatrixWorld(!0),a.geometry.applyMatrix4(a.matrixWorld),a.position.set(0,0,0),a.rotation.set(0,0,0),a.scale.set(1,1,1),a.updateMatrixWorld(!0),a.geometry.computeBoundingBox(),a.geometry.boundingBox&&(a.geometry.boundingBox.getCenter(e),a.geometry.translate(-e.x,-e.y,-e.z)),a.geometry.computeBoundingBox(),t[r]=a});let r=t.vizbl0;if(!r?.geometry)throw Error("Corner mesh not found");let n=r.geometry.boundingBox,a=n.max.x-n.min.x,s=n.max.y-n.min.y,o={top:0,bottom:0,left:0,right:0},l={top:0,bottom:0,left:0,right:0},c=t.vizbl1;if(c?.geometry){let e=c.geometry.boundingBox;o.top=e.max.x-e.min.x,l.top=e.max.y-e.min.y}let u=t.vizbl3;if(u?.geometry){let e=u.geometry.boundingBox;o.right=e.max.y-e.min.y,l.right=e.max.x-e.min.x}let d=t.vizbl5;if(d?.geometry){let e=d.geometry.boundingBox;o.bottom=e.max.x-e.min.x,l.bottom=e.max.y-e.min.y}let h=t.vizbl7;if(h?.geometry){let e=h.geometry.boundingBox;o.left=e.max.y-e.min.y,l.left=e.max.x-e.min.x}return{cornerSize:{width:a,height:s},barLengths:o,barThickness:l,normalizedNodes:t}},[i]),s=e-2*a.cornerSize.width+.002,o=t-2*a.cornerSize.height+.002,l=s/a.barLengths.top,c=s/a.barLengths.bottom,u=o/a.barLengths.left,d=o/a.barLengths.right;return(0,tw.jsxs)("group",{children:[(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl0,position:[-e/2+a.cornerSize.width/2-.001,t/2-a.cornerSize.height/2+.001,0],materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl1,position:[0,t/2-a.barThickness.top/2+.001,0],scale:[l,1,1],uvScale:l,materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl2,position:[e/2-a.cornerSize.width/2+.001,t/2-a.cornerSize.height/2+.001,0],materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl3,position:[e/2-a.barThickness.right/2+.001,0,0],scale:[1,d,1],uvScale:d,materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl4,position:[e/2-a.cornerSize.width/2+.001,-t/2+a.cornerSize.height/2-.001,0],materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl5,position:[0,-t/2+a.barThickness.bottom/2-.001,0],scale:[c,1,1],uvScale:c,materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl6,position:[-e/2+a.cornerSize.width/2-.001,-t/2+a.cornerSize.height/2-.001,0],materialPatch:r}),(0,tw.jsx)(Wl,{node:a.normalizedNodes.vizbl7,position:[-e/2+a.barThickness.left/2-.001,0,0],scale:[1,u,1],uvScale:u,materialPatch:r})]})}function Wu({width:e,height:t,position:r,quaternion:n,materialPatch:i}){let a=(0,tx.useRef)(null);return Ws(a,i),(0,tw.jsxs)("mesh",{position:r,quaternion:n,children:[(0,tw.jsx)("planeGeometry",{args:[e,t]}),(0,tw.jsx)("meshStandardMaterial",{ref:a,color:"white"})]})}function Wd({src:e,position:t,quaternion:r,materialPatch:n}){let{width:i,height:a,angle:s,material:o,frameWidth:l,rotation:c,resourceRef:u,matting:d,setIsDragging:h}=Vs(),p=zh(EA,e),f=(0,tx.useRef)(null),A=(0,tx.useMemo)(()=>vb.degToRad(s),[s]),g=(0,tx.useMemo)(()=>vb.degToRad(c),[c]);Ws(f,n);let m=i+2*d,v=a+2*d,b=d>0?m:i,y=d>0?v:a;return(0,tw.jsx)("group",{ref:u,position:t,quaternion:r,onPointerDown:()=>h(!0),onPointerUp:()=>h(!1),onPointerLeave:()=>h(!1),children:(0,tw.jsxs)("group",{rotation:[0,g,A],children:[o?.native?.glbUrl&&l>0&&(0,tw.jsx)(Wc,{width:b,height:y,materialPatch:n}),d>0&&(0,tw.jsx)(Wu,{width:m,height:v,position:[0,0,.01],materialPatch:n}),(0,tw.jsxs)("mesh",{position:[0,0,.02],children:[(0,tw.jsx)("planeGeometry",{args:[i,a]}),(0,tw.jsx)("meshStandardMaterial",{ref:f,map:p})]})]})})}function Wh(){let{room:e}=Vs(),t=zc(e=>e.scene),r=zh(EA,e.image_url);return(0,tx.useLayoutEffect)(()=>(r.colorSpace="srgb",t.background=r,()=>{t.background===r&&(t.background=null)}),[t,r]),null}function Wp({plane:e,geometry:t,setPlaneRef:r}){return(0,tw.jsx)("mesh",{ref:t=>r(e,t),geometry:t,userData:{planeId:e.id,kind:e.kind},children:(0,tw.jsx)("meshBasicMaterial",{visible:!1,side:2})})}function Wf(){let{src:e,glbUrl:t,type:r,room:n,patchSceneLoad:i}=Vs(),{gl:a,size:s,camera:o,invalidate:l,raycaster:c,pointer:u}=zc(),d=(0,tx.useMemo)(()=>n.scene??j9(),[n.scene]),[h,p]=zh(EA,[d.planeIds.dataPng,d.shading?.dataPng??"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNoaGgAAAMEAYFL09IQAAAAAElFTkSuQmCC"]),f=(0,tx.useMemo)(()=>({value:0}),[]),A=(0,tx.useMemo)(()=>new vy(1,1),[]),g=(0,tx.useMemo)(()=>new vy(d.planeIds.width,d.planeIds.height),[d.planeIds.height,d.planeIds.width]),m=(0,tx.useMemo)(()=>({planeIdsTexture:h,shadingTexture:p,planeIdsSize:g,viewport:A,activePlaneIdUniform:f}),[f,g,h,p,A]),[v,b]=(0,tx.useState)(null),[y,w]=(0,tx.useState)(null),x=(0,tx.useRef)(null),C=(0,tx.useRef)(new Map),E=(0,tx.useMemo)(()=>d.planes.filter(e=>"carpet"===r?"floor"===e.kind:"floor"!==e.kind),[d.planes,r]),S=(0,tx.useMemo)(()=>E.map(e=>e.id),[E]),M=(0,tx.useMemo)(()=>new Map(d.planes.map(e=>{let t,r;return[e.id,(t=e.polygon3D.flatMap(e=>(function(e,t){let[r,n,i]=e;return[r*(V5(t)*(t.camera.fx/t.camera.fy)),i,-n]})(e,d)),(r=new yy).setAttribute("position",new yh(t,3)),e.polygon3D.length>=4&&r.setIndex([0,1,2,0,2,3]),r)]})),[d]),I=(0,tx.useCallback)((e,t)=>{t?C.current.set(e.id,t):C.current.delete(e.id)},[]);(0,tx.useLayoutEffect)(()=>{o instanceof yj&&(o.fov=d.camera.fovYDeg),o.position.set(0,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),o.updateProjectionMatrix(),l()},[o,l,d.camera.fovYDeg]),(0,tx.useLayoutEffect)(()=>{h.minFilter=1003,h.magFilter=1003,h.wrapS=1001,h.wrapT=1001,h.generateMipmaps=!1,h.needsUpdate=!0,p.minFilter=1006,p.magFilter=1006,p.wrapS=1001,p.wrapT=1001,p.generateMipmaps=!1,p.needsUpdate=!0},[h,p]),(0,tx.useLayoutEffect)(()=>{a.getDrawingBufferSize(A),A.set(Math.max(1,A.x),Math.max(1,A.y))},[a,s.height,s.width,A]),(0,tx.useEffect)(()=>{let e=!1;return b(null),V9(d.planeIds.dataPng,d.planeIds.width,d.planeIds.height).then(t=>{e||b(t)}).catch(t=>{console.error(t),e||b(null)}),()=>{e=!0}},[d.planeIds]),(0,tx.useEffect)(()=>{w(null),x.current=null,f.value=0,i({placementReady:!1,prepareReady:!1,artifactsReady:!1})},[f,i,n.id,r]);let B=(0,tx.useCallback)((e,t)=>{let n,i,a,s,c,u,d,h,p,A=(i=new vx((n=e.geometry.attributes.position).getX(0),n.getY(0),n.getZ(0)),a=new vx(n.getX(1),n.getY(1),n.getZ(1)),s=new vx(n.getX(2),n.getY(2),n.getZ(2)),c=new vx().crossVectors(a.sub(i),s.sub(i)).normalize(),u=o.position.clone().sub(t).normalize(),0>c.dot(u)&&c.multiplyScalar(-1),d=c,h=t.clone().addScaledVector(d,.05),p=function(e,t){if("carpet"===t)return Wt(e);let r=e.clone().normalize(),n=We.clone().addScaledVector(r,-We.dot(r));if(1e-6>n.lengthSq())return Wt(r);n.normalize();let i=new vx().crossVectors(n,r).normalize(),a=new bc().makeBasis(i,n,r);return new vw().setFromRotationMatrix(a)}(d,r),{position:h.toArray(),quaternion:p.toArray(),activePlaneId:e.userData.planeId});x.current=A.activePlaneId,f.value=A.activePlaneId,w(A),l()},[f,o,l,r]),T=(0,tx.useCallback)(e=>v?function({activePlaneId:e,allowedPlaneIds:t,camera:r,planeIdMap:n,planeMap:i,pointer:a,raycaster:s}){let o=new Set(t),l=[],c=new Set,u=e=>{!(null===e||c.has(e))&&o.has(e)&&(c.add(e),l.push(e))};for(let o of(u(function(e,t){let r=Math.floor((e.x+1)*.5*t.width),n=Math.floor((1-e.y)*.5*t.height);if(r<0||n<0||r>=t.width||n>=t.height)return null;let i=t.data[n*t.width+r]??0;return i>0?i:null}(a,n)),u(e),t.forEach(u),s.setFromCamera(a,r),l)){let e=i.get(o),t=e?s.intersectObject(e,!1)[0]:null;if(t)return t}return null}({activePlaneId:x.current,allowedPlaneIds:S,camera:o,planeIdMap:v,planeMap:C.current,pointer:e,raycaster:c}):null,[S,o,v,c]);(0,tx.useEffect)(()=>{if(!v||null!==y)return;let e=E[0],t=e?C.current.get(e.id):null;t&&B(t,function(e){let t=e.geometry.attributes.position,r=new vx;for(let e=0;e<t.count;e++)r.add(new vx(t.getX(e),t.getY(e),t.getZ(e)));return r.divideScalar(Math.max(1,t.count))}(t))},[E,v,y,B]),(0,tx.useEffect)(()=>{i({artifactsReady:null!==v,placementReady:null!==y,prepareReady:null!==y})},[i,v,y]);let k=(0,tx.useCallback)(()=>{let e=T(u);e&&B(e.object,e.point)},[T,u,B]);return(0,tw.jsxs)(tw.Fragment,{children:["carpet"===r?y&&t&&(0,tw.jsx)(H3,{autoTransform:!1,onDrag:k,children:(0,tw.jsx)(Wa,{glbUrl:t,position:y.position,quaternion:y.quaternion,materialPatch:m})}):y&&e&&(0,tw.jsx)(H3,{autoTransform:!1,onDrag:k,children:(0,tw.jsx)(Wd,{src:e,position:y.position,quaternion:y.quaternion,materialPatch:m})}),d.planes.map(e=>(0,tw.jsx)(Wp,{plane:e,geometry:M.get(e.id),setPlaneRef:I},e.id)),(0,tw.jsx)(Wh,{})]})}let WA={position:[0,0,0],up:[0,0,1],near:.01,far:100};function Wg({className:e,ref:t,captureRef:r,onSizeChange:n,...i}){let{room:a,src:s,glbUrl:o,type:l,patchSceneLoad:c}=Vs(),{active:u}=H9(),d=V5((0,tx.useMemo)(()=>a.scene??j9(),[a.scene])),h=(0,tx.useRef)(null),p=(0,tx.useRef)(!1),f=(0,tx.useCallback)(e=>{(h.current=e,"function"==typeof t)?t(e):t&&(t.current=e)},[t]),A=jq("(max-width: 639px)"),{width:g,height:m}=function(e){let t,{ref:r,box:n="content-box"}=e,[{width:i,height:a},s]=(0,tx.useState)(V3),o=(t=(0,tx.useRef)(!1),(0,tx.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),(0,tx.useCallback)(()=>t.current,[])),l=(0,tx.useRef)({...V3}),c=(0,tx.useRef)(void 0);return c.current=e.onResize,(0,tx.useEffect)(()=>{if(!r.current||"u"<typeof window||!("ResizeObserver"in window))return;let e=new ResizeObserver(([e])=>{let t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=V4(e,t,"inlineSize"),i=V4(e,t,"blockSize");if(l.current.width!==r||l.current.height!==i){let e={width:r,height:i};l.current.width=r,l.current.height=i,c.current?c.current(e):o()&&s(e)}});return e.observe(r.current,{box:n}),()=>{e.disconnect()}},[n,r,o]),{width:i,height:a}}({ref:h}),v=(0,tx.useMemo)(()=>{if(!g||!m||!d)return null;let e=g,t=m;return A?e=(t=m)*d:g/m>d?e=m*d:t=g/d,{width:e,height:t}},[g,m,d,A]);return(0,tx.useLayoutEffect)(()=>{v&&n?.(v.width,v.height)},[v,n]),(0,tx.useEffect)(()=>{if(!v||p.current)return;p.current=!0;let e=window.setTimeout(()=>{window.dispatchEvent(new Event("resize"))},250);return()=>{window.clearTimeout(e)}},[v]),(0,tx.useEffect)(()=>{c({placementReady:!1,prepareReady:!1})},[c,a.id,l]),(0,tx.useEffect)(()=>{c({layoutReady:null!==v})},[c,v]),(0,tx.useEffect)(()=>{c({materialReady:"poster"===l?!!s:!!o})},[o,c,s,l]),(0,tx.useEffect)(()=>{c({assetsReady:!u})},[u,c]),(0,tw.jsx)("div",{ref:f,className:jS("size-full flex items-center justify-center sm:pt-21 sm:pb-12",e),...i,children:v&&(0,tw.jsx)(GY,{className:"bg-transparent",frameloop:"demand",camera:WA,gl:{toneMapping:4,toneMappingExposure:1.2,alpha:!0,preserveDrawingBuffer:!0},style:{width:`${v.width}px`,height:`${v.height}px`},children:(0,tw.jsxs)(tx.Suspense,{fallback:null,children:[(0,tw.jsx)(V6,{ref:r}),(0,tw.jsx)(Gj,{files:"poster"===l?["https://cdn.neurodyn.ai/assets/hdr/neutral.hdr"]:void 0,preset:"carpet"===l?"warehouse":void 0}),(0,tw.jsx)(Wf,{})]})})})}function Wm({className:e,...t}){let{containerRef:r,isDragging:n,angle:i,rotation:a,setAngle:s,setRotation:o,type:l}=Vs(),{t:c}=rw(),u=(0,tx.useRef)(null),d=(0,tx.useRef)(null),[h,p]=(0,tx.useState)(!1),f=jq("(max-width: 639px)"),A=jq("(min-width: 768px)"),g="poster"===l||"carpet"===l&&!A,m=(0,tx.useMemo)(()=>"u">typeof navigator&&"function"==typeof navigator.share,[]),v=(0,tx.useCallback)(()=>{f&&u.current?.centerView()},[f]),b=(0,tx.useCallback)(async()=>{if(!m)return;let e=window.location.href,t=c("poster"===l?"shareMessage.poster":"shareMessage.carpet"),r=`${t}
6654
- ${e}`;p(!0);try{let t=d.current;if(t)try{let e=await t.capture(),n=new File([e],"room-scene.png",{type:e.type||"image/png"});if(navigator.canShare?.({files:[n]}))return void await navigator.share({text:r,files:[n]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:r,url:e})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{p(!1)}},[m,c,l]);return(0,tw.jsxs)("div",{className:jS("relative flex items-center justify-center overflow-hidden",e),...t,children:[(0,tw.jsx)(Au,{ref:u,disabled:n,children:(0,tw.jsx)(Ad,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,tw.jsx)(Wg,{captureRef:d,onSizeChange:v})})}),(0,tw.jsx)(V2,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),"carpet"===l&&(0,tw.jsxs)("div",{className:"bg-button-dark typo-button-normal absolute bottom-6 left-1/2 hidden h-9 -translate-x-1/2 items-center gap-1.5 rounded-lg px-3.75 text-text-white md:inline-flex",children:[(0,tw.jsx)("span",{className:"shrink-0",children:c("scene.position")}),(0,tw.jsx)(VW,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-29.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.position")})]}),(0,tw.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[g&&(0,tw.jsxs)(VG,{children:[(0,tw.jsx)(Vj,{asChild:!0,children:(0,tw.jsxs)(jI,{variant:"contrast",size:f?"icon":"default",children:[(0,tw.jsx)(jU,{className:"size-5"}),(0,tw.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.tunePosition")})]})}),(0,tw.jsx)(VV,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,tw.jsxs)(Vl,{children:[(0,tw.jsxs)(Vu,{orientation:"horizontal",children:[(0,tw.jsx)(Vh,{children:c("scene.rotation")}),(0,tw.jsx)(VW,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.rotation")})]}),"poster"===l&&(0,tw.jsxs)(Vu,{orientation:"horizontal",children:[(0,tw.jsx)(Vh,{children:c("scene.angle")}),(0,tw.jsx)(VW,{value:[i],onValueChange:([e])=>s(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.angle")})]})]})})]}),"poster"===l&&(0,tw.jsxs)(jI,{variant:"contrast",size:f?"icon":"default",disabled:!m||h,onClick:b,children:[(0,tw.jsx)(jH,{className:"size-5"}),(0,tw.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.share")})]}),f&&"poster"===l&&(0,tw.jsxs)(VG,{children:[(0,tw.jsx)(Vj,{asChild:!0,children:(0,tw.jsx)(jI,{variant:"contrast",size:"icon",children:(0,tw.jsx)(jz,{})})}),(0,tw.jsxs)(VV,{className:"grid gap-5",portalContainer:r,children:[(0,tw.jsx)(Vy,{}),(0,tw.jsx)(VP,{})]})]})]})]})}function Wv({showDialogCloseButton:e=!1}){let{setContainerRef:t,sceneLoad:r,isRoomScenePending:n,isViewerAccessPending:i,accessError:a}=Vs(),{t:s}=rw(),o=i||n||!Object.values(r).every(Boolean);return a?(0,tw.jsx)("div",{ref:t,className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,tw.jsx)(VH,{variant:a,showDialogCloseButton:e})}):(0,tw.jsxs)("div",{ref:t,className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,tw.jsx)(jk,{asChild:!0,children:(0,tw.jsxs)(jI,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[s("close"),(0,tw.jsx)(ce,{})]})}),!i&&(0,tw.jsxs)(tw.Fragment,{children:[(0,tw.jsx)(Vz,{className:"absolute top-0 right-0 left-0 z-15"}),(0,tw.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,tw.jsx)(Wm,{className:"size-full min-h-0"}),(0,tw.jsx)(VU,{className:"bg-background"})]})]}),(0,tw.jsx)("div",{"aria-hidden":!o,className:jS("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",o?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,tw.jsx)(jj,{variant:"logo"})})]})}let Wb=new it({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(a9(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function Wy({type:e,src:t,tinuuid:r,name:n,height:i,width:a,language:s,dimensionUnit:o="m",displayUnit:l="cm",rooms:c,apiKey:u,source:d="default",showDialogCloseButton:h=!1}){let{i18n:p}=rw(),f=u?.trim()||void 0,A="poster"===e?function(e,t,r="m"){return{width:Vr(e??0,r),height:Vr(t??0,r)}}(a,i,o):null;return(0,tx.useEffect)(()=>{"string"==typeof s&&p.changeLanguage(s)},[p,s]),(0,tw.jsx)(nj,{client:Wb,children:(0,tw.jsx)(Va,{src:t??null,tinuuid:r??null,type:e,name:n,width:A?.width??0,height:A?.height??0,displayUnit:l,rooms:c,apiKey:f,baseURL:"shopify"===d?"/apps/vizbl/http":void 0,source:d,children:(0,tw.jsx)(Wv,{showDialogCloseButton:h})})})}function Ww({type:e,src:t,tinuuid:r,width:n,height:i,dimensionUnit:a,displayUnit:s,name:o,language:l,rooms:c,apiKey:u,source:d,...h}){let[p,f]=(0,tx.useState)(null);return(0,tw.jsxs)(tw.Fragment,{children:[(0,tE.createPortal)((0,tw.jsx)("style",{children:G0.A}),document.head),(0,tE.createPortal)((0,tw.jsxs)(rz.div,{style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,tw.jsx)("style",{children:G3}),(0,tw.jsx)("div",{ref:f}),p&&(0,tw.jsx)(G$,{root:p,storageKey:"neurodyn-theme",children:(0,tw.jsx)(rx,{i18n:G1,children:(0,tw.jsx)(jB,{...h,children:(0,tw.jsxs)(j_,{className:"min-w-full h-svh p-0 rounded-none sm:p-0",portalContainer:p,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,tw.jsxs)(jD,{className:"sr-only",children:[(0,tw.jsx)(jP,{children:o}),(0,tw.jsx)(jL,{})]}),(0,tw.jsx)(Wy,{type:e,src:t,tinuuid:r,name:o,height:i,width:n,dimensionUnit:a,displayUnit:s,language:l,rooms:c,apiKey:u,source:d,showDialogCloseButton:!0})]})})})})]}),document.body)]})}jv({baseURL:"https://api.neurodyn.ai/v1/"}),jl({baseURL:"https://api.neurodyn.ai/"});var Wx=i("../../node_modules/.pnpm/react-dom@19.2.3_react@19.2.3/node_modules/react-dom/client.js");let WC=0;function WE(e,t){let r=e.getAttribute(t);return r?Number(r):void 0}window.__neurodynRoomViewerDialog?.destroy();let WS=new class{container=null;props=null;root=null;openState=!1;destroy(){this.root?.unmount(),this.root=null,this.container?.remove(),this.container=null,this.props=null,this.openState=!1}open(e){this.props=e,this.openState=!0,this.render()}handleOpenChange=e=>{this.openState=e,this.render()};ensureRoot(){return this.root||(this.container=document.createElement("div"),this.container.id=`neurodyn-room-viewer-dialog-root-${WC++}`,document.body.appendChild(this.container),this.root=(0,Wx.createRoot)(this.container)),this.root}render(){this.props&&this.ensureRoot().render((0,tx.createElement)(Ww,{...this.props,onOpenChange:this.handleOpenChange,open:this.openState}))}};function WM(e){let t=e.target instanceof Element?e.target.closest("[data-neurodyn-room-viewer-dialog]"):null;t&&WS.open(function(e,t={}){var r,n,i;let a,s,o;return{type:void 0!==t.type?t.type:e.getAttribute("data-neurodyn-room-viewer-type"),src:void 0!==t.src?t.src:e.getAttribute("data-neurodyn-room-viewer-src"),tinuuid:void 0!==t.tinuuid?t.tinuuid:e.getAttribute("data-neurodyn-room-viewer-tinuuid"),name:void 0!==t.name?t.name:e.getAttribute("data-neurodyn-room-viewer-name"),language:void 0!==t.language?t.language:e.getAttribute("data-neurodyn-room-viewer-language"),width:void 0!==t.width?t.width:WE(e,"data-neurodyn-room-viewer-width"),height:void 0!==t.height?t.height:WE(e,"data-neurodyn-room-viewer-height"),dimensionUnit:void 0!==t.dimensionUnit?t.dimensionUnit:(r="data-neurodyn-room-viewer-dimension-unit","m"===(a=e.getAttribute(r))||"cm"===a||"in"===a?a:void 0),displayUnit:void 0!==t.displayUnit?t.displayUnit:(n="data-neurodyn-room-viewer-display-unit","cm"===(s=e.getAttribute(n))||"in"===s?s:void 0),apiKey:void 0!==t.apiKey?t.apiKey:e.getAttribute("data-neurodyn-room-viewer-api-key"),source:void 0!==t.source?t.source:(i="data-neurodyn-room-viewer-source","default"===(o=e.getAttribute(i))||"shopify"===o?o:void 0)}}(t))}S={destroy:function(){document.removeEventListener("click",WM),WS.destroy(),window.__neurodynRoomViewerDialog===S&&(window.__neurodynRoomViewerDialog=void 0)}},document.addEventListener("click",WM),window.__neurodynRoomViewerDialog=S})()})();
6654
+ ${e}`;p(!0);try{let t=d.current;if(t)try{let e=await t.capture(),n=new File([e],"room-scene.png",{type:e.type||"image/png"});if(navigator.canShare?.({files:[n]}))return void await navigator.share({text:r,files:[n]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:r,url:e})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{p(!1)}},[m,c,l]);return(0,tw.jsxs)("div",{className:jS("relative flex items-center justify-center overflow-hidden",e),...t,children:[(0,tw.jsx)(Au,{ref:u,disabled:n,children:(0,tw.jsx)(Ad,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,tw.jsx)(Wg,{captureRef:d,onSizeChange:v})})}),(0,tw.jsx)(V2,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),"carpet"===l&&(0,tw.jsxs)("div",{className:"bg-button-dark typo-button-normal absolute bottom-6 left-1/2 hidden h-9 -translate-x-1/2 items-center gap-1.5 rounded-lg px-3.75 text-text-white md:inline-flex",children:[(0,tw.jsx)("span",{className:"shrink-0",children:c("scene.position")}),(0,tw.jsx)(VW,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-29.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.position")})]}),(0,tw.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[g&&(0,tw.jsxs)(VG,{children:[(0,tw.jsx)(Vj,{asChild:!0,children:(0,tw.jsxs)(jI,{variant:"contrast",size:f?"icon":"default",children:[(0,tw.jsx)(jU,{className:"size-5"}),(0,tw.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.tunePosition")})]})}),(0,tw.jsx)(VV,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,tw.jsxs)(Vl,{children:[(0,tw.jsxs)(Vu,{orientation:"horizontal",children:[(0,tw.jsx)(Vh,{children:c("scene.rotation")}),(0,tw.jsx)(VW,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.rotation")})]}),"poster"===l&&(0,tw.jsxs)(Vu,{orientation:"horizontal",children:[(0,tw.jsx)(Vh,{children:c("scene.angle")}),(0,tw.jsx)(VW,{value:[i],onValueChange:([e])=>s(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.angle")})]})]})})]}),"poster"===l&&(0,tw.jsxs)(jI,{variant:"contrast",size:f?"icon":"default",disabled:!m||h,onClick:b,children:[(0,tw.jsx)(jH,{className:"size-5"}),(0,tw.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.share")})]}),f&&"poster"===l&&(0,tw.jsxs)(VG,{children:[(0,tw.jsx)(Vj,{asChild:!0,children:(0,tw.jsx)(jI,{variant:"contrast",size:"icon",children:(0,tw.jsx)(jz,{})})}),(0,tw.jsxs)(VV,{className:"grid gap-5",portalContainer:r,children:[(0,tw.jsx)(Vy,{}),(0,tw.jsx)(VP,{})]})]})]})]})}function Wv({showDialogCloseButton:e=!1}){let{setContainerRef:t,sceneLoad:r,isRoomScenePending:n,isViewerAccessPending:i,accessError:a}=Vs(),{t:s}=rw(),o=i||n||!Object.values(r).every(Boolean);return a?(0,tw.jsx)("div",{ref:t,className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,tw.jsx)(VH,{variant:a,showDialogCloseButton:e})}):(0,tw.jsxs)("div",{ref:t,className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,tw.jsx)(jk,{asChild:!0,children:(0,tw.jsxs)(jI,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[s("close"),(0,tw.jsx)(ce,{})]})}),!i&&(0,tw.jsxs)(tw.Fragment,{children:[(0,tw.jsx)(Vz,{className:"absolute top-0 right-0 left-0 z-15"}),(0,tw.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,tw.jsx)(Wm,{className:"size-full min-h-0"}),(0,tw.jsx)(VU,{className:"bg-background"})]})]}),(0,tw.jsx)("div",{"aria-hidden":!o,className:jS("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",o?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,tw.jsx)(jj,{variant:"logo"})})]})}let Wb=new it({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(a9(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function Wy({type:e,src:t,tinuuid:r,name:n,height:i,width:a,language:s,dimensionUnit:o="m",displayUnit:l="cm",rooms:c,apiKey:u,source:d="default",showDialogCloseButton:h=!1}){let{i18n:p}=rw(),f=u?.trim()||void 0,A="poster"===e?function(e,t,r="m"){return{width:Vr(e??0,r),height:Vr(t??0,r)}}(a,i,o):null;return(0,tx.useEffect)(()=>{"string"==typeof s&&p.changeLanguage(s)},[p,s]),(0,tw.jsx)(nj,{client:Wb,children:(0,tw.jsx)(Va,{src:t??null,tinuuid:r??null,type:e,name:n,width:A?.width??0,height:A?.height??0,displayUnit:l,rooms:c,apiKey:f,baseURL:"shopify"===d?"/apps/vizbl-wall-art/http":void 0,source:d,children:(0,tw.jsx)(Wv,{showDialogCloseButton:h})})})}function Ww({type:e,src:t,tinuuid:r,width:n,height:i,dimensionUnit:a,displayUnit:s,name:o,language:l,rooms:c,apiKey:u,source:d,...h}){let[p,f]=(0,tx.useState)(null);return(0,tw.jsxs)(tw.Fragment,{children:[(0,tE.createPortal)((0,tw.jsx)("style",{children:G0.A}),document.head),(0,tE.createPortal)((0,tw.jsxs)(rz.div,{style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,tw.jsx)("style",{children:G3}),(0,tw.jsx)("div",{ref:f}),p&&(0,tw.jsx)(G$,{root:p,storageKey:"neurodyn-theme",children:(0,tw.jsx)(rx,{i18n:G1,children:(0,tw.jsx)(jB,{...h,children:(0,tw.jsxs)(j_,{className:"min-w-full h-svh p-0 rounded-none sm:p-0",portalContainer:p,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,tw.jsxs)(jD,{className:"sr-only",children:[(0,tw.jsx)(jP,{children:o}),(0,tw.jsx)(jL,{})]}),(0,tw.jsx)(Wy,{type:e,src:t,tinuuid:r,name:o,height:i,width:n,dimensionUnit:a,displayUnit:s,language:l,rooms:c,apiKey:u,source:d,showDialogCloseButton:!0})]})})})})]}),document.body)]})}jv({baseURL:"https://api.neurodyn.ai/v1/"}),jl({baseURL:"https://api.neurodyn.ai/"});var Wx=i("../../node_modules/.pnpm/react-dom@19.2.3_react@19.2.3/node_modules/react-dom/client.js");let WC=0;function WE(e,t){let r=e.getAttribute(t);return r?Number(r):void 0}window.__neurodynRoomViewerDialog?.destroy();let WS=new class{container=null;props=null;root=null;openState=!1;destroy(){this.root?.unmount(),this.root=null,this.container?.remove(),this.container=null,this.props=null,this.openState=!1}open(e){this.props=e,this.openState=!0,this.render()}handleOpenChange=e=>{this.openState=e,this.render()};ensureRoot(){return this.root||(this.container=document.createElement("div"),this.container.id=`neurodyn-room-viewer-dialog-root-${WC++}`,document.body.appendChild(this.container),this.root=(0,Wx.createRoot)(this.container)),this.root}render(){this.props&&this.ensureRoot().render((0,tx.createElement)(Ww,{...this.props,onOpenChange:this.handleOpenChange,open:this.openState}))}};function WM(e){let t=e.target instanceof Element?e.target.closest("[data-neurodyn-room-viewer-dialog]"):null;t&&WS.open(function(e,t={}){var r,n,i;let a,s,o;return{type:void 0!==t.type?t.type:e.getAttribute("data-neurodyn-room-viewer-type"),src:void 0!==t.src?t.src:e.getAttribute("data-neurodyn-room-viewer-src"),tinuuid:void 0!==t.tinuuid?t.tinuuid:e.getAttribute("data-neurodyn-room-viewer-tinuuid"),name:void 0!==t.name?t.name:e.getAttribute("data-neurodyn-room-viewer-name"),language:void 0!==t.language?t.language:e.getAttribute("data-neurodyn-room-viewer-language"),width:void 0!==t.width?t.width:WE(e,"data-neurodyn-room-viewer-width"),height:void 0!==t.height?t.height:WE(e,"data-neurodyn-room-viewer-height"),dimensionUnit:void 0!==t.dimensionUnit?t.dimensionUnit:(r="data-neurodyn-room-viewer-dimension-unit","m"===(a=e.getAttribute(r))||"cm"===a||"in"===a?a:void 0),displayUnit:void 0!==t.displayUnit?t.displayUnit:(n="data-neurodyn-room-viewer-display-unit","cm"===(s=e.getAttribute(n))||"in"===s?s:void 0),apiKey:void 0!==t.apiKey?t.apiKey:e.getAttribute("data-neurodyn-room-viewer-api-key"),source:void 0!==t.source?t.source:(i="data-neurodyn-room-viewer-source","default"===(o=e.getAttribute(i))||"shopify"===o?o:void 0)}}(t))}S={destroy:function(){document.removeEventListener("click",WM),WS.destroy(),window.__neurodynRoomViewerDialog===S&&(window.__neurodynRoomViewerDialog=void 0)}},document.addEventListener("click",WM),window.__neurodynRoomViewerDialog=S})()})();
@@ -6651,4 +6651,4 @@ ${eg}`:eg);function G3(e){return"shopify"===e.source||void 0!==e.apiKey}function
6651
6651
  `);if(n.includes("#include <output_fragment>")){e.fragmentShader=n.replace("#include <output_fragment>",`${r}
6652
6652
  #include <output_fragment>`);return}e.fragmentShader=n.replace("#include <opaque_fragment>",`${r}
6653
6653
  #include <opaque_fragment>`)}(n,t)},e.customProgramCacheKey=()=>`${n()}|neurodyn-room-scene-v2`,e.needsUpdate=!0,()=>{e.onBeforeCompile=r,e.customProgramCacheKey=n,e.side=i,e.transparent=a,e.alphaToCoverage=s,e.needsUpdate=!0}}let Wn=Math.PI/2;function Wi({glbUrl:e,position:t,quaternion:r,materialPatch:n}){let{resourceRef:i,rotation:a,setIsDragging:s}=Va(),o=z$(e),l=(0,tw.useMemo)(()=>o.scene.clone(!0),[o]),c=(0,tw.useMemo)(()=>{let e;return e=new Set,l.traverse(t=>{if(!t.isMesh||!t.material)return;if(Array.isArray(t.material)){t.material=t.material.map(t=>{let r=t.clone();return e.add(r),r});return}let r=t.material.clone();e.add(r),t.material=r}),Array.from(e)},[l]),u=(0,tw.useMemo)(()=>vv.degToRad(a),[a]);return(0,tw.useLayoutEffect)(()=>{let e=c.map(e=>Wr(e,n));return()=>{e.forEach(e=>e())}},[c,n]),(0,ty.jsx)("group",{ref:i,position:t,quaternion:r,onPointerDown:()=>s(!0),onPointerUp:()=>s(!1),onPointerLeave:()=>s(!1),children:(0,ty.jsx)("group",{"rotation-z":u,children:(0,ty.jsx)("group",{"rotation-x":Wn,children:(0,ty.jsx)("primitive",{object:l})})})})}function Wa(e,t){(0,tw.useLayoutEffect)(()=>{let r=e.current;if(r)return Wr(r,t)},[e,t])}let Ws=[1,1,1];function Wo({node:e,position:t,scale:r=Ws,uvScale:n,materialPatch:i}){let a=(0,tw.useRef)(null);return(0,tw.useEffect)(()=>{if(!a.current||void 0===n)return;let t=a.current.geometry.attributes.uv,r=e.geometry.attributes.uv.array;for(let e=0;e<t.count;e++){let i=r[2*e],a=r[2*e+1];t.setXY(e,i*n,a)}t.needsUpdate=!0},[n,e.geometry]),(0,tw.useLayoutEffect)(()=>{let e=a.current?.material;if(!e)return;let t=(Array.isArray(e)?e:[e]).map(e=>Wr(e,i));return()=>{t.forEach(e=>e())}},[i,e]),(0,ty.jsx)(z2,{ref:a,object:e,position:t,scale:r})}function Wl({width:e,height:t,materialPatch:r}){let{material:n}=Va(),{nodes:i}=z$(n?.native?.glbUrl),a=(0,tw.useMemo)(()=>{let e=new vw,t={};["vizbl0","vizbl1","vizbl2","vizbl3","vizbl4","vizbl5","vizbl6","vizbl7"].forEach(r=>{let n=i[r];if(!n?.geometry)return;let a=n.clone();a.geometry=n.geometry.clone(),Array.isArray(n.material)?a.material=n.material.map(e=>e.clone()):n.material&&(a.material=n.material.clone()),a.updateMatrixWorld(!0),a.geometry.applyMatrix4(a.matrixWorld),a.position.set(0,0,0),a.rotation.set(0,0,0),a.scale.set(1,1,1),a.updateMatrixWorld(!0),a.geometry.computeBoundingBox(),a.geometry.boundingBox&&(a.geometry.boundingBox.getCenter(e),a.geometry.translate(-e.x,-e.y,-e.z)),a.geometry.computeBoundingBox(),t[r]=a});let r=t.vizbl0;if(!r?.geometry)throw Error("Corner mesh not found");let n=r.geometry.boundingBox,a=n.max.x-n.min.x,s=n.max.y-n.min.y,o={top:0,bottom:0,left:0,right:0},l={top:0,bottom:0,left:0,right:0},c=t.vizbl1;if(c?.geometry){let e=c.geometry.boundingBox;o.top=e.max.x-e.min.x,l.top=e.max.y-e.min.y}let u=t.vizbl3;if(u?.geometry){let e=u.geometry.boundingBox;o.right=e.max.y-e.min.y,l.right=e.max.x-e.min.x}let d=t.vizbl5;if(d?.geometry){let e=d.geometry.boundingBox;o.bottom=e.max.x-e.min.x,l.bottom=e.max.y-e.min.y}let h=t.vizbl7;if(h?.geometry){let e=h.geometry.boundingBox;o.left=e.max.y-e.min.y,l.left=e.max.x-e.min.x}return{cornerSize:{width:a,height:s},barLengths:o,barThickness:l,normalizedNodes:t}},[i]),s=e-2*a.cornerSize.width+.002,o=t-2*a.cornerSize.height+.002,l=s/a.barLengths.top,c=s/a.barLengths.bottom,u=o/a.barLengths.left,d=o/a.barLengths.right;return(0,ty.jsxs)("group",{children:[(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl0,position:[-e/2+a.cornerSize.width/2-.001,t/2-a.cornerSize.height/2+.001,0],materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl1,position:[0,t/2-a.barThickness.top/2+.001,0],scale:[l,1,1],uvScale:l,materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl2,position:[e/2-a.cornerSize.width/2+.001,t/2-a.cornerSize.height/2+.001,0],materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl3,position:[e/2-a.barThickness.right/2+.001,0,0],scale:[1,d,1],uvScale:d,materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl4,position:[e/2-a.cornerSize.width/2+.001,-t/2+a.cornerSize.height/2-.001,0],materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl5,position:[0,-t/2+a.barThickness.bottom/2-.001,0],scale:[c,1,1],uvScale:c,materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl6,position:[-e/2+a.cornerSize.width/2-.001,-t/2+a.cornerSize.height/2-.001,0],materialPatch:r}),(0,ty.jsx)(Wo,{node:a.normalizedNodes.vizbl7,position:[-e/2+a.barThickness.left/2-.001,0,0],scale:[1,u,1],uvScale:u,materialPatch:r})]})}function Wc({width:e,height:t,position:r,quaternion:n,materialPatch:i}){let a=(0,tw.useRef)(null);return Wa(a,i),(0,ty.jsxs)("mesh",{position:r,quaternion:n,children:[(0,ty.jsx)("planeGeometry",{args:[e,t]}),(0,ty.jsx)("meshStandardMaterial",{ref:a,color:"white"})]})}function Wu({src:e,position:t,quaternion:r,materialPatch:n}){let{width:i,height:a,angle:s,material:o,frameWidth:l,rotation:c,resourceRef:u,matting:d,setIsDragging:h}=Va(),p=zd(Ef,e),f=(0,tw.useRef)(null),A=(0,tw.useMemo)(()=>vv.degToRad(s),[s]),g=(0,tw.useMemo)(()=>vv.degToRad(c),[c]);Wa(f,n);let m=i+2*d,v=a+2*d,b=d>0?m:i,y=d>0?v:a;return(0,ty.jsx)("group",{ref:u,position:t,quaternion:r,onPointerDown:()=>h(!0),onPointerUp:()=>h(!1),onPointerLeave:()=>h(!1),children:(0,ty.jsxs)("group",{rotation:[0,g,A],children:[o?.native?.glbUrl&&l>0&&(0,ty.jsx)(Wl,{width:b,height:y,materialPatch:n}),d>0&&(0,ty.jsx)(Wc,{width:m,height:v,position:[0,0,.01],materialPatch:n}),(0,ty.jsxs)("mesh",{position:[0,0,.02],children:[(0,ty.jsx)("planeGeometry",{args:[i,a]}),(0,ty.jsx)("meshStandardMaterial",{ref:f,map:p})]})]})})}function Wd(){let{room:e}=Va(),t=zl(e=>e.scene),r=zd(Ef,e.image_url);return(0,tw.useLayoutEffect)(()=>(r.colorSpace="srgb",t.background=r,()=>{t.background===r&&(t.background=null)}),[t,r]),null}function Wh({plane:e,geometry:t,setPlaneRef:r}){return(0,ty.jsx)("mesh",{ref:t=>r(e,t),geometry:t,userData:{planeId:e.id,kind:e.kind},children:(0,ty.jsx)("meshBasicMaterial",{visible:!1,side:2})})}function Wp(){let{src:e,glbUrl:t,type:r,room:n,patchSceneLoad:i}=Va(),{gl:a,size:s,camera:o,invalidate:l,raycaster:c,pointer:u}=zl(),d=(0,tw.useMemo)(()=>n.scene??j5(),[n.scene]),[h,p]=zd(Ef,[d.planeIds.dataPng,d.shading?.dataPng??"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNoaGgAAAMEAYFL09IQAAAAAElFTkSuQmCC"]),f=(0,tw.useMemo)(()=>({value:0}),[]),A=(0,tw.useMemo)(()=>new vb(1,1),[]),g=(0,tw.useMemo)(()=>new vb(d.planeIds.width,d.planeIds.height),[d.planeIds.height,d.planeIds.width]),m=(0,tw.useMemo)(()=>({planeIdsTexture:h,shadingTexture:p,planeIdsSize:g,viewport:A,activePlaneIdUniform:f}),[f,g,h,p,A]),[v,b]=(0,tw.useState)(null),[y,w]=(0,tw.useState)(null),x=(0,tw.useRef)(null),C=(0,tw.useRef)(new Map),E=(0,tw.useMemo)(()=>d.planes.filter(e=>"carpet"===r?"floor"===e.kind:"floor"!==e.kind),[d.planes,r]),S=(0,tw.useMemo)(()=>E.map(e=>e.id),[E]),M=(0,tw.useMemo)(()=>new Map(d.planes.map(e=>{let t,r;return[e.id,(t=e.polygon3D.flatMap(e=>(function(e,t){let[r,n,i]=e;return[r*(V4(t)*(t.camera.fx/t.camera.fy)),i,-n]})(e,d)),(r=new yb).setAttribute("position",new yd(t,3)),e.polygon3D.length>=4&&r.setIndex([0,1,2,0,2,3]),r)]})),[d]),I=(0,tw.useCallback)((e,t)=>{t?C.current.set(e.id,t):C.current.delete(e.id)},[]);(0,tw.useLayoutEffect)(()=>{o instanceof yG&&(o.fov=d.camera.fovYDeg),o.position.set(0,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),o.updateProjectionMatrix(),l()},[o,l,d.camera.fovYDeg]),(0,tw.useLayoutEffect)(()=>{h.minFilter=1003,h.magFilter=1003,h.wrapS=1001,h.wrapT=1001,h.generateMipmaps=!1,h.needsUpdate=!0,p.minFilter=1006,p.magFilter=1006,p.wrapS=1001,p.wrapT=1001,p.generateMipmaps=!1,p.needsUpdate=!0},[h,p]),(0,tw.useLayoutEffect)(()=>{a.getDrawingBufferSize(A),A.set(Math.max(1,A.x),Math.max(1,A.y))},[a,s.height,s.width,A]),(0,tw.useEffect)(()=>{let e=!1;return b(null),V5(d.planeIds.dataPng,d.planeIds.width,d.planeIds.height).then(t=>{e||b(t)}).catch(t=>{console.error(t),e||b(null)}),()=>{e=!0}},[d.planeIds]),(0,tw.useEffect)(()=>{w(null),x.current=null,f.value=0,i({placementReady:!1,prepareReady:!1,artifactsReady:!1})},[f,i,n.id,r]);let B=(0,tw.useCallback)((e,t)=>{let n,i,a,s,c,u,d,h,p,A=(i=new vw((n=e.geometry.attributes.position).getX(0),n.getY(0),n.getZ(0)),a=new vw(n.getX(1),n.getY(1),n.getZ(1)),s=new vw(n.getX(2),n.getY(2),n.getZ(2)),c=new vw().crossVectors(a.sub(i),s.sub(i)).normalize(),u=o.position.clone().sub(t).normalize(),0>c.dot(u)&&c.multiplyScalar(-1),d=c,h=t.clone().addScaledVector(d,.05),p=function(e,t){if("carpet"===t)return We(e);let r=e.clone().normalize(),n=V7.clone().addScaledVector(r,-V7.dot(r));if(1e-6>n.lengthSq())return We(r);n.normalize();let i=new vw().crossVectors(n,r).normalize(),a=new bl().makeBasis(i,n,r);return new vy().setFromRotationMatrix(a)}(d,r),{position:h.toArray(),quaternion:p.toArray(),activePlaneId:e.userData.planeId});x.current=A.activePlaneId,f.value=A.activePlaneId,w(A),l()},[f,o,l,r]),T=(0,tw.useCallback)(e=>v?function({activePlaneId:e,allowedPlaneIds:t,camera:r,planeIdMap:n,planeMap:i,pointer:a,raycaster:s}){let o=new Set(t),l=[],c=new Set,u=e=>{!(null===e||c.has(e))&&o.has(e)&&(c.add(e),l.push(e))};for(let o of(u(function(e,t){let r=Math.floor((e.x+1)*.5*t.width),n=Math.floor((1-e.y)*.5*t.height);if(r<0||n<0||r>=t.width||n>=t.height)return null;let i=t.data[n*t.width+r]??0;return i>0?i:null}(a,n)),u(e),t.forEach(u),s.setFromCamera(a,r),l)){let e=i.get(o),t=e?s.intersectObject(e,!1)[0]:null;if(t)return t}return null}({activePlaneId:x.current,allowedPlaneIds:S,camera:o,planeIdMap:v,planeMap:C.current,pointer:e,raycaster:c}):null,[S,o,v,c]);(0,tw.useEffect)(()=>{if(!v||null!==y)return;let e=E[0],t=e?C.current.get(e.id):null;t&&B(t,function(e){let t=e.geometry.attributes.position,r=new vw;for(let e=0;e<t.count;e++)r.add(new vw(t.getX(e),t.getY(e),t.getZ(e)));return r.divideScalar(Math.max(1,t.count))}(t))},[E,v,y,B]),(0,tw.useEffect)(()=>{i({artifactsReady:null!==v,placementReady:null!==y,prepareReady:null!==y})},[i,v,y]);let k=(0,tw.useCallback)(()=>{let e=T(u);e&&B(e.object,e.point)},[T,u,B]);return(0,ty.jsxs)(ty.Fragment,{children:["carpet"===r?y&&t&&(0,ty.jsx)(H2,{autoTransform:!1,onDrag:k,children:(0,ty.jsx)(Wi,{glbUrl:t,position:y.position,quaternion:y.quaternion,materialPatch:m})}):y&&e&&(0,ty.jsx)(H2,{autoTransform:!1,onDrag:k,children:(0,ty.jsx)(Wu,{src:e,position:y.position,quaternion:y.quaternion,materialPatch:m})}),d.planes.map(e=>(0,ty.jsx)(Wh,{plane:e,geometry:M.get(e.id),setPlaneRef:I},e.id)),(0,ty.jsx)(Wd,{})]})}let Wf={position:[0,0,0],up:[0,0,1],near:.01,far:100};function WA({className:e,ref:t,captureRef:r,onSizeChange:n,...i}){let{room:a,src:s,glbUrl:o,type:l,patchSceneLoad:c}=Va(),{active:u}=H5(),d=V4((0,tw.useMemo)(()=>a.scene??j5(),[a.scene])),h=(0,tw.useRef)(null),p=(0,tw.useRef)(!1),f=(0,tw.useCallback)(e=>{(h.current=e,"function"==typeof t)?t(e):t&&(t.current=e)},[t]),A=jW("(max-width: 639px)"),{width:g,height:m}=function(e){let t,{ref:r,box:n="content-box"}=e,[{width:i,height:a},s]=(0,tw.useState)(V2),o=(t=(0,tw.useRef)(!1),(0,tw.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),(0,tw.useCallback)(()=>t.current,[])),l=(0,tw.useRef)({...V2}),c=(0,tw.useRef)(void 0);return c.current=e.onResize,(0,tw.useEffect)(()=>{if(!r.current||"u"<typeof window||!("ResizeObserver"in window))return;let e=new ResizeObserver(([e])=>{let t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=V3(e,t,"inlineSize"),i=V3(e,t,"blockSize");if(l.current.width!==r||l.current.height!==i){let e={width:r,height:i};l.current.width=r,l.current.height=i,c.current?c.current(e):o()&&s(e)}});return e.observe(r.current,{box:n}),()=>{e.disconnect()}},[n,r,o]),{width:i,height:a}}({ref:h}),v=(0,tw.useMemo)(()=>{if(!g||!m||!d)return null;let e=g,t=m;return A?e=(t=m)*d:g/m>d?e=m*d:t=g/d,{width:e,height:t}},[g,m,d,A]);return(0,tw.useLayoutEffect)(()=>{v&&n?.(v.width,v.height)},[v,n]),(0,tw.useEffect)(()=>{if(!v||p.current)return;p.current=!0;let e=window.setTimeout(()=>{window.dispatchEvent(new Event("resize"))},250);return()=>{window.clearTimeout(e)}},[v]),(0,tw.useEffect)(()=>{c({placementReady:!1,prepareReady:!1})},[c,a.id,l]),(0,tw.useEffect)(()=>{c({layoutReady:null!==v})},[c,v]),(0,tw.useEffect)(()=>{c({materialReady:"poster"===l?!!s:!!o})},[o,c,s,l]),(0,tw.useEffect)(()=>{c({assetsReady:!u})},[u,c]),(0,ty.jsx)("div",{ref:f,className:jE("size-full flex items-center justify-center sm:pt-21 sm:pb-12",e),...i,children:v&&(0,ty.jsx)(Gq,{className:"bg-transparent",frameloop:"demand",camera:Wf,gl:{toneMapping:4,toneMappingExposure:1.2,alpha:!0,preserveDrawingBuffer:!0},style:{width:`${v.width}px`,height:`${v.height}px`},children:(0,ty.jsxs)(tw.Suspense,{fallback:null,children:[(0,ty.jsx)(V8,{ref:r}),(0,ty.jsx)(GG,{files:"poster"===l?["https://cdn.neurodyn.ai/assets/hdr/neutral.hdr"]:void 0,preset:"carpet"===l?"warehouse":void 0}),(0,ty.jsx)(Wp,{})]})})})}function Wg({className:e,...t}){let{containerRef:r,isDragging:n,angle:i,rotation:a,setAngle:s,setRotation:o,type:l}=Va(),{t:c}=ry(),u=(0,tw.useRef)(null),d=(0,tw.useRef)(null),[h,p]=(0,tw.useState)(!1),f=jW("(max-width: 639px)"),A=jW("(min-width: 768px)"),g="poster"===l||"carpet"===l&&!A,m=(0,tw.useMemo)(()=>"u">typeof navigator&&"function"==typeof navigator.share,[]),v=(0,tw.useCallback)(()=>{f&&u.current?.centerView()},[f]),b=(0,tw.useCallback)(async()=>{if(!m)return;let e=window.location.href,t=c("poster"===l?"shareMessage.poster":"shareMessage.carpet"),r=`${t}
6654
- ${e}`;p(!0);try{let t=d.current;if(t)try{let e=await t.capture(),n=new File([e],"room-scene.png",{type:e.type||"image/png"});if(navigator.canShare?.({files:[n]}))return void await navigator.share({text:r,files:[n]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:r,url:e})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{p(!1)}},[m,c,l]);return(0,ty.jsxs)("div",{className:jE("relative flex items-center justify-center overflow-hidden",e),...t,children:[(0,ty.jsx)(Ac,{ref:u,disabled:n,children:(0,ty.jsx)(Au,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,ty.jsx)(WA,{captureRef:d,onSizeChange:v})})}),(0,ty.jsx)(V1,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),"carpet"===l&&(0,ty.jsxs)("div",{className:"bg-button-dark typo-button-normal absolute bottom-6 left-1/2 hidden h-9 -translate-x-1/2 items-center gap-1.5 rounded-lg px-3.75 text-text-white md:inline-flex",children:[(0,ty.jsx)("span",{className:"shrink-0",children:c("scene.position")}),(0,ty.jsx)(VV,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-29.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.position")})]}),(0,ty.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[g&&(0,ty.jsxs)(VH,{children:[(0,ty.jsx)(VG,{asChild:!0,children:(0,ty.jsxs)(jM,{variant:"contrast",size:f?"icon":"default",children:[(0,ty.jsx)(jQ,{className:"size-5"}),(0,ty.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.tunePosition")})]})}),(0,ty.jsx)(Vj,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,ty.jsxs)(Vo,{children:[(0,ty.jsxs)(Vc,{orientation:"horizontal",children:[(0,ty.jsx)(Vd,{children:c("scene.rotation")}),(0,ty.jsx)(VV,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.rotation")})]}),"poster"===l&&(0,ty.jsxs)(Vc,{orientation:"horizontal",children:[(0,ty.jsx)(Vd,{children:c("scene.angle")}),(0,ty.jsx)(VV,{value:[i],onValueChange:([e])=>s(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.angle")})]})]})})]}),"poster"===l&&(0,ty.jsxs)(jM,{variant:"contrast",size:f?"icon":"default",disabled:!m||h,onClick:b,children:[(0,ty.jsx)(jz,{className:"size-5"}),(0,ty.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.share")})]}),f&&"poster"===l&&(0,ty.jsxs)(VH,{children:[(0,ty.jsx)(VG,{asChild:!0,children:(0,ty.jsx)(jM,{variant:"contrast",size:"icon",children:(0,ty.jsx)(jU,{})})}),(0,ty.jsxs)(Vj,{className:"grid gap-5",portalContainer:r,children:[(0,ty.jsx)(Vb,{}),(0,ty.jsx)(VD,{})]})]})]})]})}function Wm({showDialogCloseButton:e=!1}){let{setContainerRef:t,sceneLoad:r,isRoomScenePending:n,isViewerAccessPending:i,accessError:a}=Va(),{t:s}=ry(),o=i||n||!Object.values(r).every(Boolean);return a?(0,ty.jsx)("div",{ref:t,className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,ty.jsx)(Vz,{variant:a,showDialogCloseButton:e})}):(0,ty.jsxs)("div",{ref:t,className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,ty.jsx)(jT,{asChild:!0,children:(0,ty.jsxs)(jM,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[s("close"),(0,ty.jsx)(l7,{})]})}),!i&&(0,ty.jsxs)(ty.Fragment,{children:[(0,ty.jsx)(VU,{className:"absolute top-0 right-0 left-0 z-15"}),(0,ty.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,ty.jsx)(Wg,{className:"size-full min-h-0"}),(0,ty.jsx)(VQ,{className:"bg-background"})]})]}),(0,ty.jsx)("div",{"aria-hidden":!o,className:jE("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",o?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,ty.jsx)(jG,{variant:"logo"})})]})}let Wv=new ie({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(a5(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function Wb({type:e,src:t,tinuuid:r,name:n,height:i,width:a,language:s,dimensionUnit:o="m",displayUnit:l="cm",rooms:c,apiKey:u,source:d="default",showDialogCloseButton:h=!1}){let{i18n:p}=ry(),f=u?.trim()||void 0,A="poster"===e?function(e,t,r="m"){return{width:Vt(e??0,r),height:Vt(t??0,r)}}(a,i,o):null;return(0,tw.useEffect)(()=>{"string"==typeof s&&p.changeLanguage(s)},[p,s]),(0,ty.jsx)(nG,{client:Wv,children:(0,ty.jsx)(Vi,{src:t??null,tinuuid:r??null,type:e,name:n,width:A?.width??0,height:A?.height??0,displayUnit:l,rooms:c,apiKey:f,baseURL:"shopify"===d?"/apps/vizbl/http":void 0,source:d,children:(0,ty.jsx)(Wm,{showDialogCloseButton:h})})})}function Wy({type:e,src:t,tinuuid:r,width:n,height:i,dimensionUnit:a,displayUnit:s,name:o,language:l,rooms:c,apiKey:u,source:d,...h}){let[p,f]=(0,tw.useState)(null);return(0,ty.jsxs)(ty.Fragment,{children:[(0,tC.createPortal)((0,ty.jsx)("style",{children:G$.A}),document.head),(0,tC.createPortal)((0,ty.jsxs)(rU.div,{style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,ty.jsx)("style",{children:G2}),(0,ty.jsx)("div",{ref:f}),p&&(0,ty.jsx)(GZ,{root:p,storageKey:"neurodyn-theme",children:(0,ty.jsx)(rw,{i18n:G0,children:(0,ty.jsx)(jI,{...h,children:(0,ty.jsxs)(jR,{className:"min-w-full h-svh p-0 rounded-none sm:p-0",portalContainer:p,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,ty.jsxs)(j_,{className:"sr-only",children:[(0,ty.jsx)(jD,{children:o}),(0,ty.jsx)(jP,{})]}),(0,ty.jsx)(Wb,{type:e,src:t,tinuuid:r,name:o,height:i,width:n,dimensionUnit:a,displayUnit:s,language:l,rooms:c,apiKey:u,source:d,showDialogCloseButton:!0})]})})})})]}),document.body)]})}jm({baseURL:"https://api.neurodyn.ai/v1/"}),jo({baseURL:"https://api.neurodyn.ai/"});var Ww=i("../../node_modules/.pnpm/react-dom@19.2.3_react@19.2.3/node_modules/react-dom/client.js");let Wx=0;class WC{container=null;props=null;root=null;openState=!1;destroy(){this.root?.unmount(),this.root=null,this.container?.remove(),this.container=null,this.props=null,this.openState=!1}open(e){this.props=e,this.openState=!0,this.render()}handleOpenChange=e=>{this.openState=e,this.render()};ensureRoot(){return this.root||(this.container=document.createElement("div"),this.container.id=`neurodyn-room-viewer-dialog-root-${Wx++}`,document.body.appendChild(this.container),this.root=(0,Ww.createRoot)(this.container)),this.root}render(){this.props&&this.ensureRoot().render((0,tw.createElement)(Wy,{...this.props,onOpenChange:this.handleOpenChange,open:this.openState}))}}function WE(e,t){let r=e.getAttribute(t);return r?Number(r):void 0}class WS{renderer=new WC;triggers;props;destroyed=!1;constructor(e,t={}){for(const r of(this.triggers="string"==typeof e?Array.from(document.querySelectorAll(e)):[e],this.props=t,this.triggers))r.addEventListener("click",this.handleClick)}destroy(){if(!this.destroyed){for(let e of(this.destroyed=!0,this.triggers))e.removeEventListener("click",this.handleClick);this.renderer.destroy()}}handleClick=e=>{!this.destroyed&&e.currentTarget instanceof Element&&this.renderer.open(function(e,t={}){var r,n,i;let a,s,o;return{type:void 0!==t.type?t.type:e.getAttribute("data-neurodyn-room-viewer-type"),src:void 0!==t.src?t.src:e.getAttribute("data-neurodyn-room-viewer-src"),tinuuid:void 0!==t.tinuuid?t.tinuuid:e.getAttribute("data-neurodyn-room-viewer-tinuuid"),name:void 0!==t.name?t.name:e.getAttribute("data-neurodyn-room-viewer-name"),language:void 0!==t.language?t.language:e.getAttribute("data-neurodyn-room-viewer-language"),width:void 0!==t.width?t.width:WE(e,"data-neurodyn-room-viewer-width"),height:void 0!==t.height?t.height:WE(e,"data-neurodyn-room-viewer-height"),dimensionUnit:void 0!==t.dimensionUnit?t.dimensionUnit:(r="data-neurodyn-room-viewer-dimension-unit","m"===(a=e.getAttribute(r))||"cm"===a||"in"===a?a:void 0),displayUnit:void 0!==t.displayUnit?t.displayUnit:(n="data-neurodyn-room-viewer-display-unit","cm"===(s=e.getAttribute(n))||"in"===s?s:void 0),apiKey:void 0!==t.apiKey?t.apiKey:e.getAttribute("data-neurodyn-room-viewer-api-key"),source:void 0!==t.source?t.source:(i="data-neurodyn-room-viewer-source","default"===(o=e.getAttribute(i))||"shopify"===o?o:void 0)}}(e.currentTarget,this.props))}}window.RoomViewerDialog=WS})()})();
6654
+ ${e}`;p(!0);try{let t=d.current;if(t)try{let e=await t.capture(),n=new File([e],"room-scene.png",{type:e.type||"image/png"});if(navigator.canShare?.({files:[n]}))return void await navigator.share({text:r,files:[n]})}catch(e){console.error("Failed to generate scene screenshot for sharing",e)}await navigator.share({text:r,url:e})}catch(e){e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to share scene",e)}finally{p(!1)}},[m,c,l]);return(0,ty.jsxs)("div",{className:jE("relative flex items-center justify-center overflow-hidden",e),...t,children:[(0,ty.jsx)(Ac,{ref:u,disabled:n,children:(0,ty.jsx)(Au,{wrapperClass:"neurodyn-rzpp-wrapper size-full!",contentClass:"neurodyn-rzpp-content h-full! min-w-full sm:max-w-full",children:(0,ty.jsx)(WA,{captureRef:d,onSizeChange:v})})}),(0,ty.jsx)(V1,{className:"absolute bottom-4 left-4 sm:bottom-6 sm:left-6"}),"carpet"===l&&(0,ty.jsxs)("div",{className:"bg-button-dark typo-button-normal absolute bottom-6 left-1/2 hidden h-9 -translate-x-1/2 items-center gap-1.5 rounded-lg px-3.75 text-text-white md:inline-flex",children:[(0,ty.jsx)("span",{className:"shrink-0",children:c("scene.position")}),(0,ty.jsx)(VV,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-29.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.position")})]}),(0,ty.jsxs)("div",{className:"absolute right-4 bottom-4 inline-flex items-center gap-2 sm:right-6 sm:bottom-6",children:[g&&(0,ty.jsxs)(VH,{children:[(0,ty.jsx)(VG,{asChild:!0,children:(0,ty.jsxs)(jM,{variant:"contrast",size:f?"icon":"default",children:[(0,ty.jsx)(jQ,{className:"size-5"}),(0,ty.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.tunePosition")})]})}),(0,ty.jsx)(Vj,{className:"px-3 py-3.5 bg-button-dark border-button-dark text-text-white",side:"top",align:"end",portalContainer:r,children:(0,ty.jsxs)(Vo,{children:[(0,ty.jsxs)(Vc,{orientation:"horizontal",children:[(0,ty.jsx)(Vd,{children:c("scene.rotation")}),(0,ty.jsx)(VV,{value:[a],onValueChange:([e])=>o(e??0),min:-180,max:180,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.rotation")})]}),"poster"===l&&(0,ty.jsxs)(Vc,{orientation:"horizontal",children:[(0,ty.jsx)(Vd,{children:c("scene.angle")}),(0,ty.jsx)(VV,{value:[i],onValueChange:([e])=>s(e??0),max:75,min:-75,step:1,className:"w-40.5 **:data-[slot=slider-range]:bg-transparent **:data-[slot=slider-thumb]:border-background-base-3 **:data-[slot=slider-thumb]]:bg-background-base-3 **:data-[slot=slider-track]:bg-icons-normal","aria-label":c("scene.angle")})]})]})})]}),"poster"===l&&(0,ty.jsxs)(jM,{variant:"contrast",size:f?"icon":"default",disabled:!m||h,onClick:b,children:[(0,ty.jsx)(jz,{className:"size-5"}),(0,ty.jsx)("span",{className:"sr-only sm:not-sr-only",children:c("scene.share")})]}),f&&"poster"===l&&(0,ty.jsxs)(VH,{children:[(0,ty.jsx)(VG,{asChild:!0,children:(0,ty.jsx)(jM,{variant:"contrast",size:"icon",children:(0,ty.jsx)(jU,{})})}),(0,ty.jsxs)(Vj,{className:"grid gap-5",portalContainer:r,children:[(0,ty.jsx)(Vb,{}),(0,ty.jsx)(VD,{})]})]})]})]})}function Wm({showDialogCloseButton:e=!1}){let{setContainerRef:t,sceneLoad:r,isRoomScenePending:n,isViewerAccessPending:i,accessError:a}=Va(),{t:s}=ry(),o=i||n||!Object.values(r).every(Boolean);return a?(0,ty.jsx)("div",{ref:t,className:"relative size-full overflow-hidden bg-radial from-background-containers to-background-base-2 text-foreground",children:(0,ty.jsx)(Vz,{variant:a,showDialogCloseButton:e})}):(0,ty.jsxs)("div",{ref:t,className:"relative size-full bg-radial from-background-containers to-background-base-2 text-foreground overflow-hidden",children:[e&&(0,ty.jsx)(jT,{asChild:!0,children:(0,ty.jsxs)(jM,{className:"absolute top-3 right-6 z-20",variant:"secondary",children:[s("close"),(0,ty.jsx)(l7,{})]})}),!i&&(0,ty.jsxs)(ty.Fragment,{children:[(0,ty.jsx)(VU,{className:"absolute top-0 right-0 left-0 z-15"}),(0,ty.jsxs)("div",{className:"size-full max-w-full grid grid-rows-[1fr_auto]",children:[(0,ty.jsx)(Wg,{className:"size-full min-h-0"}),(0,ty.jsx)(VQ,{className:"bg-background"})]})]}),(0,ty.jsx)("div",{"aria-hidden":!o,className:jE("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",o?"opacity-100 pointer-events-auto duration-0":"opacity-0 pointer-events-none duration-250ms"),children:(0,ty.jsx)(jG,{variant:"logo"})})]})}let Wv=new ie({defaultOptions:{queries:{gcTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=function(e){if(a5(e))return e.response?.status}(t);return(void 0===r||!(r>=400)||!(r<500))&&e<2}}}});function Wb({type:e,src:t,tinuuid:r,name:n,height:i,width:a,language:s,dimensionUnit:o="m",displayUnit:l="cm",rooms:c,apiKey:u,source:d="default",showDialogCloseButton:h=!1}){let{i18n:p}=ry(),f=u?.trim()||void 0,A="poster"===e?function(e,t,r="m"){return{width:Vt(e??0,r),height:Vt(t??0,r)}}(a,i,o):null;return(0,tw.useEffect)(()=>{"string"==typeof s&&p.changeLanguage(s)},[p,s]),(0,ty.jsx)(nG,{client:Wv,children:(0,ty.jsx)(Vi,{src:t??null,tinuuid:r??null,type:e,name:n,width:A?.width??0,height:A?.height??0,displayUnit:l,rooms:c,apiKey:f,baseURL:"shopify"===d?"/apps/vizbl-wall-art/http":void 0,source:d,children:(0,ty.jsx)(Wm,{showDialogCloseButton:h})})})}function Wy({type:e,src:t,tinuuid:r,width:n,height:i,dimensionUnit:a,displayUnit:s,name:o,language:l,rooms:c,apiKey:u,source:d,...h}){let[p,f]=(0,tw.useState)(null);return(0,ty.jsxs)(ty.Fragment,{children:[(0,tC.createPortal)((0,ty.jsx)("style",{children:G$.A}),document.head),(0,tC.createPortal)((0,ty.jsxs)(rU.div,{style:{display:"block",letterSpacing:"normal",zIndex:0x7fffffff},children:[(0,ty.jsx)("style",{children:G2}),(0,ty.jsx)("div",{ref:f}),p&&(0,ty.jsx)(GZ,{root:p,storageKey:"neurodyn-theme",children:(0,ty.jsx)(rw,{i18n:G0,children:(0,ty.jsx)(jI,{...h,children:(0,ty.jsxs)(jR,{className:"min-w-full h-svh p-0 rounded-none sm:p-0",portalContainer:p,showCloseButton:!1,onInteractOutside:e=>{e.preventDefault()},children:[(0,ty.jsxs)(j_,{className:"sr-only",children:[(0,ty.jsx)(jD,{children:o}),(0,ty.jsx)(jP,{})]}),(0,ty.jsx)(Wb,{type:e,src:t,tinuuid:r,name:o,height:i,width:n,dimensionUnit:a,displayUnit:s,language:l,rooms:c,apiKey:u,source:d,showDialogCloseButton:!0})]})})})})]}),document.body)]})}jm({baseURL:"https://api.neurodyn.ai/v1/"}),jo({baseURL:"https://api.neurodyn.ai/"});var Ww=i("../../node_modules/.pnpm/react-dom@19.2.3_react@19.2.3/node_modules/react-dom/client.js");let Wx=0;class WC{container=null;props=null;root=null;openState=!1;destroy(){this.root?.unmount(),this.root=null,this.container?.remove(),this.container=null,this.props=null,this.openState=!1}open(e){this.props=e,this.openState=!0,this.render()}handleOpenChange=e=>{this.openState=e,this.render()};ensureRoot(){return this.root||(this.container=document.createElement("div"),this.container.id=`neurodyn-room-viewer-dialog-root-${Wx++}`,document.body.appendChild(this.container),this.root=(0,Ww.createRoot)(this.container)),this.root}render(){this.props&&this.ensureRoot().render((0,tw.createElement)(Wy,{...this.props,onOpenChange:this.handleOpenChange,open:this.openState}))}}function WE(e,t){let r=e.getAttribute(t);return r?Number(r):void 0}class WS{renderer=new WC;triggers;props;destroyed=!1;constructor(e,t={}){for(const r of(this.triggers="string"==typeof e?Array.from(document.querySelectorAll(e)):[e],this.props=t,this.triggers))r.addEventListener("click",this.handleClick)}destroy(){if(!this.destroyed){for(let e of(this.destroyed=!0,this.triggers))e.removeEventListener("click",this.handleClick);this.renderer.destroy()}}handleClick=e=>{!this.destroyed&&e.currentTarget instanceof Element&&this.renderer.open(function(e,t={}){var r,n,i;let a,s,o;return{type:void 0!==t.type?t.type:e.getAttribute("data-neurodyn-room-viewer-type"),src:void 0!==t.src?t.src:e.getAttribute("data-neurodyn-room-viewer-src"),tinuuid:void 0!==t.tinuuid?t.tinuuid:e.getAttribute("data-neurodyn-room-viewer-tinuuid"),name:void 0!==t.name?t.name:e.getAttribute("data-neurodyn-room-viewer-name"),language:void 0!==t.language?t.language:e.getAttribute("data-neurodyn-room-viewer-language"),width:void 0!==t.width?t.width:WE(e,"data-neurodyn-room-viewer-width"),height:void 0!==t.height?t.height:WE(e,"data-neurodyn-room-viewer-height"),dimensionUnit:void 0!==t.dimensionUnit?t.dimensionUnit:(r="data-neurodyn-room-viewer-dimension-unit","m"===(a=e.getAttribute(r))||"cm"===a||"in"===a?a:void 0),displayUnit:void 0!==t.displayUnit?t.displayUnit:(n="data-neurodyn-room-viewer-display-unit","cm"===(s=e.getAttribute(n))||"in"===s?s:void 0),apiKey:void 0!==t.apiKey?t.apiKey:e.getAttribute("data-neurodyn-room-viewer-api-key"),source:void 0!==t.source?t.source:(i="data-neurodyn-room-viewer-source","default"===(o=e.getAttribute(i))||"shopify"===o?o:void 0)}}(e.currentTarget,this.props))}}window.RoomViewerDialog=WS})()})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neurodyn/room-viewer",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "react": "^19.2.0",
23
23
  "react-dom": "^19.2.0",
24
- "@neurodyn/react-room-viewer": "0.0.3"
24
+ "@neurodyn/react-room-viewer": "0.0.4"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@google/model-viewer": "4.2.0",