@neurodyn/ar 0.0.11 → 0.0.13

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.
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_neurodyn_ar=self.webpackChunk_neurodyn_ar||[]).push([["206"],{3761(e,t,n){n.d(t,{f:()=>o});var r=n(2585),i=n(1828);class o{async isSupported(){try{return await this.resolve(),!0}catch{return!1}}async startSession(e){return(await this.resolve()).startSession(e)}resolve(){return this.resolution||(this.resolution=(0,i.U4)(this.options).catch(e=>{throw this.resolution=null,e})),this.resolution}constructor(e={}){(0,r._)(this,"options",void 0),(0,r._)(this,"resolution",void 0),this.options=e,this.resolution=null}}},1828(e,t,n){n.d(t,{Sf:()=>s,U4:()=>l,rZ:()=>a});var r=n(7292),i=n(342),o=n(7734);function a(){return{"8thwall":new i.VU,webxr:new o.c}}async function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a(),[t,n]=await Promise.all([e.webxr.isSupported().catch(()=>!1),e["8thwall"].isSupported().catch(()=>!1)]);return{"8thwall":n,webxr:t}}async function l(){let{backend:e,registry:t=a(),userAgent:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e??(0,r.HE)(n);for(let n of e?[e]:[i,...r.AY.filter(e=>e!==i)]){let e=t[n];if(await e.isSupported().catch(()=>!1))return e}if("u">typeof window&&!window.isSecureContext)throw Error("AR needs a secure connection. Open this page over HTTPS or localhost.");throw Error("AR is not available on this device.")}},7734(e,t,n){n.d(t,{Y:()=>a,c:()=>h});var r=n(2585),i=n(8413),o=n(5807);function a(e){return e}function s(e){return{x:e.x,y:e.y,z:e.z}}function l(e){return{w:e.w,x:e.x,y:e.y,z:e.z}}let u=!1;function c(e,t,n){if(!e.getPose)return null;try{return e.getPose(t(),n)??null}catch(e){return(0,i.Q0)()&&!u&&(u=!0,console.warn("[react-ar] a WebXR space stopped answering; treating it as lost tracking.",e)),null}}class d{setMechanic(e){e!==this.mechanic&&(this.mechanic=e,this.cachedFrame=null)}async attachRenderer(e){e.xr.enabled=!0,e.xr.setReferenceSpaceType("local-floor"),await e.xr.setSession(this.nativeSession)}getCenterHit(e){return this.cachedFrame===e||(this.cachedFrame=e,this.cachedHit=this.readCenterHit(e)),this.cachedHit}readCenterHit(e){let t=null;for(let n of this.readHitTestResults(e)){let e=function(e,t){var n;let r,i=e.getPose(t);if(!i)return null;let{matrix:a,orientation:u,position:c}=i.transform,d=(r=Math.hypot((n={x:a[4]??0,y:a[5]??1,z:a[6]??0}).x,n.y,n.z)||1,{x:n.x/r,y:n.y/r,z:n.z/r}),h={kind:(0,o.Q3)(d),nativeHit:e,normal:d,pose:{orientation:l(u),position:s(c)}};return"wall"!==h.kind||(0,o.aq)(h)?h:null}(n,this.floorSpace);if(e){if(function(e,t){switch(t){case"wall":return(0,o.aq)(e);case"ceiling":return"ceiling"===e.kind;case"floor":return"floor"===e.kind;case"all":return!0}}(e,this.mechanic))return e;t??(t=e)}}return t}readHitTestResults(e){try{return e.getHitTestResults(this.hitTestSource)}catch{return[]}}isTracking(e){return null!==c(e,()=>this.viewerSpace,this.floorSpace)}async createAnchor(e){var t;let n=e.nativeHit;if(!(null==n?void 0:n.createAnchor))throw Error("WebXR anchors are unavailable.");let r=await n.createAnchor();return{delete:()=>{try{null==r||r.delete()}catch{}},getPose:e=>{var t;let n=c(e,()=>r.anchorSpace,this.floorSpace);return n?{orientation:l((t=n.transform).orientation),position:s(t.position)}:null},nativeAnchor:r,pose:{orientation:l((t=e.pose).orientation),position:s(t.position)}}}async end(){this.cachedFrame=null,this.cachedHit=null,this.hitTestSource.cancel(),await this.nativeSession.end()}constructor(e,t,n,i){(0,r._)(this,"nativeSession",void 0),(0,r._)(this,"floorSpace",void 0),(0,r._)(this,"hitTestSource",void 0),(0,r._)(this,"viewerSpace",void 0),(0,r._)(this,"cachedFrame",void 0),(0,r._)(this,"cachedHit",void 0),(0,r._)(this,"mechanic",void 0),this.nativeSession=e,this.floorSpace=t,this.hitTestSource=n,this.viewerSpace=i,this.cachedFrame=null,this.cachedHit=null,this.mechanic="all"}}class h{async isSupported(){var e;return(null==(e=this.xrSystem)?void 0:e.isSessionSupported("immersive-ar"))??!1}async startSession(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.xrSystem)throw Error("WebXR immersive AR is not supported.");let t={optionalFeatures:["dom-overlay","plane-detection"],requiredFeatures:["anchors","hit-test","local-floor"]};e.overlayRoot&&(t.domOverlay={root:e.overlayRoot});let n=await this.xrSystem.requestSession("immersive-ar",t),[r,i]=await Promise.all([n.requestReferenceSpace("viewer"),n.requestReferenceSpace("local-floor")]),o=await n.requestHitTestSource({space:r});if(!o)throw await n.end(),Error("WebXR hit testing is unavailable.");return new d(n,i,o,r)}constructor(e=function(){if("u">typeof navigator)return navigator.xr}()){(0,r._)(this,"xrSystem",void 0),this.xrSystem=e}}},384(e,t,n){n.d(t,{Cm:()=>l,Rl:()=>u,f3:()=>c});var r=n(9081);function i(){}function o(){return"u"<typeof navigator?null:navigator.virtualKeyboard??null}function a(){var e;return Math.round(window.innerHeight||document.documentElement.clientHeight||(null==(e=window.visualViewport)?void 0:e.height)||0)}function s(e){return Number.isFinite(e)?Math.max(0,Math.round(e)):0}function l(e){let t=(0,r.useRef)(null);(0,r.useEffect)(()=>{e||(t.current=null)},[e]);let n=(0,r.useCallback)(t=>{if(!e||"u"<typeof window)return i;let n=window.visualViewport;return null==n||n.addEventListener("resize",t),null==n||n.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{null==n||n.removeEventListener("resize",t),null==n||n.removeEventListener("scroll",t),window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[e]),o=(0,r.useCallback)(()=>{var n;let r,i;return!e||"u"<typeof window?null:(r=window.visualViewport,n={height:Math.ceil(Math.max(window.innerHeight||0,document.documentElement.clientHeight||0,(null==r?void 0:r.height)||0)),width:Math.ceil(Math.max(window.innerWidth||0,document.documentElement.clientWidth||0,(null==r?void 0:r.width)||0))},(i=t.current,i&&i.height===n.height&&i.width===n.width)?i:(t.current=n,n))},[e]),a=(0,r.useSyncExternalStore)(n,o,()=>null);return(0,r.useMemo)(()=>{if(a&&!(a.height<=0)&&!(a.width<=0))return{height:`${a.height}px`,width:`${a.width}px`}},[a])}function u(e){let t=(0,r.useRef)(0),n=(0,r.useRef)(null);(0,r.useLayoutEffect)(()=>{if(!e)return i;let t=o();if(!t)return i;let n=t.overlaysContent;try{t.overlaysContent=!0}catch{return i}return()=>{try{t.overlaysContent=n}catch{}}},[e]);let l=(0,r.useCallback)(()=>{t.current=Math.max(t.current,a())},[]);(0,r.useEffect)(()=>{if(!e){t.current=0,n.current=null;return}l()},[e,l]);let u=(0,r.useCallback)(n=>{if(!e||"u"<typeof window)return i;let r=()=>{t.current=0,l(),n()},a=()=>{l(),n()},s=window.visualViewport,u=o();return null==s||s.addEventListener("resize",a),null==s||s.addEventListener("scroll",a),null==u||u.addEventListener("geometrychange",a),window.addEventListener("resize",a),window.addEventListener("orientationchange",r),()=>{null==s||s.removeEventListener("resize",a),null==s||s.removeEventListener("scroll",a),null==u||u.removeEventListener("geometrychange",a),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",r)}},[e,l]),c=(0,r.useCallback)(()=>{var r;let i;return!e||"u"<typeof window?null:(r=function(e){let t=o(),n=null==t?void 0:t.boundingRect;if(n&&n.height>0)return{bottom:s(e-n.top),height:e,top:0};let r=window.visualViewport;if(!r)return{bottom:0,height:e,top:0};let i=s(r.offsetTop);return{bottom:s(e-r.height-r.offsetTop),height:e,top:i}}(t.current||a()),(i=n.current,i&&i.bottom===r.bottom&&i.height===r.height&&i.top===r.top)?i:(n.current=r,r))},[e]),d=(0,r.useSyncExternalStore)(u,c,()=>null);return(0,r.useMemo)(()=>{if(d)return{"--ar-catalog-keyboard-bottom":`${d.bottom}px`,height:`${d.height}px`,paddingTop:`${d.top}px`}},[d])}function c(e){let t=(0,r.useCallback)(t=>{if(!e||"u"<typeof window)return i;let n=window.visualViewport,r=o();return null==n||n.addEventListener("resize",t),null==r||r.addEventListener("geometrychange",t),window.addEventListener("resize",t),()=>{null==n||n.removeEventListener("resize",t),null==r||r.removeEventListener("geometrychange",t),window.removeEventListener("resize",t)}},[e]),n=(0,r.useCallback)(()=>{var t;if(!e||"u"<typeof window)return!1;let n=null==(t=o())?void 0:t.boundingRect;if(n)return n.height>0;let r=window.visualViewport;return!!r&&a()-r.height-r.offsetTop>0},[e]);return(0,r.useSyncExternalStore)(t,n,()=>!1)}},8413(e,t,n){n.d(t,{Bo:()=>a,Q0:()=>i,R5:()=>o}),n(7292);let r={forcesInPageSession:!1};function i(){return!1}function o(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:"u"<typeof window||window.location.search,!1}function a(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:"u"<typeof window||window.location.search,r}},7218(e,t,n){n.d(t,{$:()=>l});var r=n(8525),i=n(6218),o=n(6642),a=n(5445);n(9081);let s=(0,a.F)("cursor-pointer inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-xl transition-all disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary--hover active:bg-primary--pressed disabled:bg-primary--disabled disabled:opacity-20",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary--hover active:bg-secondary--pressed disabled:bg-secondary--disabled disabled:opacity-20",outline:"border border-button-outline bg-transparent text-foreground hover:border-button-outline-hover active:bg-button-outline-pressed disabled:border-border-dark disabled:opacity-20",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent--pressed",contrast:"bg-contrast text-contrast-foreground hover:bg-contrast--hover active:bg-contrast--pressed disabled:bg-contrast--disabled disabled:opacity-30"},size:{default:"h-9 px-3.5 typo-button-normal [&_svg]:size-5",sm:"h-8 px-3 typo-button-small [&_svg]:size-4",lg:"h-11 px-4 typo-button-big [&_svg]:size-6",icon:"size-9 rounded-full [&_svg]:size-5","icon-sm":"size-8 rounded-full [&_svg]:size-4","icon-lg":"size-11 rounded-full [&_svg]:size-6"}},defaultVariants:{variant:"default",size:"default"}});function l(e){let{className:t,variant:n,size:a,asChild:l=!1,...u}=e,c=l?i.DX:"button";return(0,r.jsx)(c,{"data-slot":"button",className:(0,o.cn)(s({variant:n,size:a,className:t})),...u})}},6486(e,t,n){n.d(t,{Cf:()=>d,HM:()=>u,L3:()=>h,lG:()=>s,rr:()=>v});var r=n(8525),i=n(3285);n(7218);var o=n(6642),a=n(2838);function s(e){let{...t}=e;return(0,r.jsx)(i.bL,{"data-slot":"dialog",...t})}function l(e){let{...t}=e;return(0,r.jsx)(i.ZL,{"data-slot":"dialog-portal",...t})}function u(e){let{...t}=e;return(0,r.jsx)(i.bm,{"data-slot":"dialog-close",...t})}function c(e){let{className:t,...n}=e;return(0,r.jsx)(i.hJ,{"data-slot":"dialog-overlay",className:(0,o.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...n})}function d(e){let{className:t,children:n,contentInsideOverlay:s=!1,showCloseButton:u=!0,portalContainer:d,...h}=e,v=(0,r.jsxs)(i.UC,{"data-slot":"dialog-content",className:(0,o.cn)("bg-background-containers data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-6 rounded-3xl border-0 p-6 shadow-[var(--shadow-login)] duration-200 outline-none sm:max-w-120 sm:p-10",t),...h,children:[n,u&&(0,r.jsxs)(i.bm,{"data-slot":"dialog-close",className:"focus-visible:ring-ring/30 absolute top-4 right-4 inline-flex size-6 cursor-pointer items-center justify-center rounded-full text-icons-light transition-colors hover:text-icons-normal focus-visible:text-icons-dark focus-visible:ring-2 focus-visible:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0",children:[(0,r.jsx)(a.A,{className:"size-6"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]});return(0,r.jsx)(l,{"data-slot":"dialog-portal",container:d,children:s?(0,r.jsx)(c,{children:v}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{}),v]})})}function h(e){let{className:t,...n}=e;return(0,r.jsx)(i.hE,{"data-slot":"dialog-title",className:(0,o.cn)("typo-base-18 text-text-dark",t),...n})}function v(e){let{className:t,...n}=e;return(0,r.jsx)(i.VY,{"data-slot":"dialog-description",className:(0,o.cn)("typo-base-16 text-text-light",t),...n})}n(9081)},6642(e,t,n){n.d(t,{cn:()=>o});var r=n(851),i=n(1137);function o(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,i.QP)((0,r.$)(t))}}}]);
@@ -1,60 +0,0 @@
1
- "use strict";(self.webpackChunk_neurodyn_ar=self.webpackChunk_neurodyn_ar||[]).push([["9"],{784(e,t,r){r.r(t),r.d(t,{ArExperience:()=>na});var n=r(8525),a=r(828),i=r(6514),o=r(9081),s=r(243);function l(e){if(!e||"object"!=typeof e||!("response"in e))return;let t=e.response;if(t&&"object"==typeof t&&"status"in t)return"number"==typeof t.status?t.status:void 0}function c(e,t){let r=l(e);return 401===r||403===r?"access-denied":404===r&&"object"===t?"object-not-published":"object"===t?"object-load-failed":"catalog-load-failed"}var u=r(9811),d=r(1131);function h(e,t){var r,n;let a=(0,d.sq)(e),i=(0,d.Dj)(e),o=(0,d.uW)(e,t),s=i[0],l=(null==o||null==(n=o.native)||null==(r=n.glbUrl)?void 0:r.trim())?{glbUrl:o.native.glbUrl,hid:o.hid??null}:s?{glbUrl:s.glbUrl,hid:s.hid}:null;return l?{dimensions:a.dimensions,glbUrl:l.glbUrl,id:e.uuid??e.tinuuid??l.glbUrl,mechanic:a.mechanic,variantId:l.hid,variants:i}:null}var m=r(683),p=r(7218),f=r(6486),g=r(2838),v=r(851),x=r(1137);function b(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,x.QP)((0,v.$)(t))}var w=r(4656);function y(e){let{className:t,size:r="default",...a}=e;return(0,n.jsx)(w.bL,{"data-slot":"avatar","data-size":r,className:b("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",t),...a})}function j(e){let{className:t,...r}=e;return(0,n.jsx)(w._V,{"data-slot":"avatar-image",className:b("aspect-square size-full rounded-full object-cover",t),...r})}function C(e){let{className:t,...r}=e;return(0,n.jsx)(w.H4,{"data-slot":"avatar-fallback",className:b("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",t),...r})}var R=r(5445),z=r(2849);let k=(0,R.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*=size-])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function N(e){let{className:t,variant:r="default",size:a="default",asChild:i=!1,...o}=e,s=i?z.bL:"button";return(0,n.jsx)(s,{"data-slot":"button","data-variant":r,"data-size":a,className:b(k({variant:r,size:a,className:t})),...o})}var S=r(8763),_=r(384),L=r(8128),M=r(4382),P=r(1213),E=r(5444);let I="var(--v-borders-medium, #bebec8)";function O(e){let{className:t,role:r,"aria-label":a,"aria-live":i,size:o="default",state:s="loading",variant:l="default",...c}=e,u=a??("success"===s?"Success":"error"===s?"Error":"Loading");if("logo"===l){let e="sm"===o?4:5;return(0,n.jsxs)("svg",{...c,role:r??"status","aria-live":i??"polite","aria-label":u,width:"93",height:"91",viewBox:"0 0 93 91",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-slot":"spinner","data-size":o,"data-state":s,className:b("spinner-logo shrink-0","sm"===o?"size-9":"size-22",t),children:[(0,n.jsx)("g",{className:"spinner-logo__intro-shell",children:(0,n.jsx)("path",{d:"M15.7495 62.7798L46.4936 45.0297M46.4936 45.0297L77.2661 62.5451M46.4936 45.0297L46.7111 9.62225M49.9213 79.4237L74.5719 65.1917C75.6436 64.5705 76.5344 63.6811 77.1541 62.6137C77.7738 61.5462 78.1003 60.3385 78.1007 59.1129L78.1729 30.7811C78.1734 29.5494 77.851 28.3427 77.2373 27.2798C76.6236 26.2169 75.7398 25.3343 74.6729 24.7189L50.1007 10.6155C47.926 9.3694 45.2455 9.37719 43.0689 10.6339L18.4183 24.8659C16.2385 26.1244 14.8946 28.4401 14.8895 30.9447L14.8173 59.2766C14.8168 60.5082 15.1392 61.7149 15.7529 62.7778C16.3666 63.8408 17.2504 64.7233 18.3173 65.3387L42.8895 79.4421C45.0642 80.6882 47.7447 80.6805 49.9213 79.4237Z",className:"spinner-logo__outline spinner-logo__outline--intro",vectorEffect:"sm"===o?void 0:"non-scaling-stroke"})}),(0,n.jsx)("circle",{className:"spinner-logo__intro-orb",cx:"46.27",cy:"45.8",r:"11.18",fill:"white",stroke:I,strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("circle",{className:"spinner-logo__result-ring",cx:"46.5",cy:"45.5",r:"33.46",fill:"white",stroke:I,strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("g",{transform:"translate(27.786 31.4489)",children:(0,n.jsx)("g",{className:"spinner-logo__result-glyph spinner-logo__result-glyph--success",children:(0,n.jsx)("path",{d:"M13.6758 28.1023C13.3559 28.101 13.0397 28.0341 12.7467 27.9057C12.4537 27.7772 12.1902 27.59 11.9725 27.3557L0.632479 15.2923C0.208575 14.8406 -0.0185097 14.2389 0.00118164 13.6198C0.020873 13.0006 0.285727 12.4146 0.737479 11.9907C1.18923 11.5668 1.79088 11.3397 2.41006 11.3594C3.02924 11.3791 3.61524 11.6439 4.03915 12.0957L13.6525 22.339L33.2758 0.87233C33.475 0.624349 33.7227 0.419696 34.0038 0.270944C34.2849 0.122191 34.5935 0.0324784 34.9105 0.00731496C35.2276 -0.0178485 35.5464 0.0220682 35.8475 0.124615C36.1485 0.227162 36.4254 0.390174 36.6612 0.603637C36.897 0.8171 37.0866 1.07651 37.2185 1.36593C37.3503 1.65535 37.4216 1.96867 37.428 2.28665C37.4344 2.60463 37.3756 2.92056 37.2555 3.21502C37.1353 3.50949 36.9562 3.77627 36.7291 3.999L15.4025 27.3323C15.1868 27.5709 14.9242 27.7625 14.6311 27.895C14.338 28.0275 14.0208 28.0981 13.6991 28.1023H13.6758Z",fill:I})})}),(0,n.jsx)("g",{transform:"translate(32.4879 31.4885)",children:(0,n.jsx)("g",{className:"spinner-logo__result-glyph spinner-logo__result-glyph--error",children:(0,n.jsx)("path",{d:"M17.3045 14.0095L27.3378 3.99955C27.5554 3.78199 27.728 3.52371 27.8457 3.23946C27.9635 2.95521 28.0241 2.65055 28.0241 2.34288C28.0241 2.03521 27.9635 1.73055 27.8457 1.4463C27.728 1.16205 27.5554 0.903769 27.3378 0.686213C27.1203 0.468656 26.862 0.296082 26.5778 0.178341C26.2935 0.0606 25.9889 -4.58466e-09 25.6812 0C25.3735 4.58466e-09 25.0689 0.0606 24.7846 0.178341C24.5003 0.296082 24.2421 0.468656 24.0245 0.686213L14.0145 10.7195L4.00451 0.686213C3.56514 0.246838 2.96921 -4.62957e-09 2.34784 0C1.72647 4.62957e-09 1.13055 0.246838 0.691177 0.686213C0.251802 1.12559 0.0049634 1.72151 0.0049634 2.34288C0.00496339 2.96425 0.251802 3.56017 0.691177 3.99955L10.7245 14.0095L0.691177 24.0195C0.472196 24.2363 0.29836 24.4943 0.179723 24.7787C0.0610849 25.063 0 25.3681 0 25.6762C0 25.9843 0.0610849 26.2894 0.179723 26.5737C0.29836 26.8581 0.472196 27.1161 0.691177 27.3329C0.908091 27.5516 1.16616 27.7252 1.4505 27.8436C1.73484 27.9621 2.03982 28.0231 2.34784 28.0231C2.65587 28.0231 2.96085 27.9621 3.24519 27.8436C3.52953 27.7252 3.7876 27.5516 4.00451 27.3329L14.0145 17.2995L24.0245 27.3329C24.296 27.6078 24.6314 27.8111 25.0007 27.9245C25.3701 28.0379 25.7618 28.0579 26.1407 27.9828C26.5197 27.9077 26.8741 27.7397 27.1722 27.4939C27.4703 27.2481 27.7028 26.9322 27.8488 26.5745C28.0272 26.1459 28.0736 25.6738 27.9821 25.2187C27.8907 24.7636 27.6655 24.346 27.3355 24.0195L17.3045 14.0095Z",fill:I})})})]})}return(0,n.jsx)(E.A,{"data-slot":"spinner",role:r??"status","aria-live":i??"polite","aria-label":u,className:b("size-4 animate-spin",t),...c})}function T(e){return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",...e,children:[(0,n.jsx)("path",{d:"M22.5601 16.3031L14.8901 3.58311C14.58 3.09793 14.1526 2.69864 13.6476 2.42205C13.1425 2.14546 12.5759 2.00049 12.0001 2.00049C11.4243 2.00049 10.8577 2.14546 10.3526 2.42205C9.84755 2.69864 9.42024 3.09793 9.1101 3.58311L1.4401 16.3031C1.16915 16.7548 1.02189 17.2698 1.01311 17.7964C1.00434 18.323 1.13436 18.8427 1.3901 19.3031C1.68578 19.8214 2.11376 20.2518 2.6303 20.5505C3.14684 20.8492 3.73343 21.0054 4.3301 21.0031H19.6701C20.2629 21.0094 20.8468 20.8593 21.363 20.5678C21.8792 20.2764 22.3093 19.8539 22.6101 19.3431C22.8734 18.8779 23.0075 18.3508 22.9987 17.8163C22.9899 17.2818 22.8385 16.7594 22.5601 16.3031ZM20.8601 18.3531C20.7399 18.5597 20.5655 18.7295 20.3557 18.8441C20.146 18.9586 19.9089 19.0136 19.6701 19.0031H4.3301C4.09132 19.0136 3.85422 18.9586 3.64446 18.8441C3.4347 18.7295 3.26029 18.5597 3.1401 18.3531C3.05233 18.2011 3.00613 18.0286 3.00613 17.8531C3.00613 17.6776 3.05233 17.5051 3.1401 17.3531L10.8201 4.62311C10.9581 4.44082 11.1365 4.29298 11.3412 4.19119C11.5459 4.08939 11.7715 4.03642 12.0001 4.03642C12.2287 4.03642 12.4543 4.08939 12.659 4.19119C12.8637 4.29298 13.0421 4.44082 13.1801 4.62311L20.8501 17.3431C20.9413 17.4954 20.9902 17.6693 20.992 17.8468C20.9937 18.0243 20.9482 18.199 20.8601 18.3531Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M12.0001 17.0001C12.2653 17.0001 12.5197 16.8948 12.7072 16.7073C12.8948 16.5197 13.0001 16.2654 13.0001 16.0001C13.0001 15.7349 12.8948 15.4806 12.7072 15.293C12.5197 15.1055 12.2653 15.0001 12.0001 15.0001C11.7349 15.0001 11.4806 15.1055 11.293 15.293C11.1055 15.4806 11.0001 15.7349 11.0001 16.0001C11.0001 16.2654 11.1055 16.5197 11.293 16.7073C11.4806 16.8948 11.7349 17.0001 12.0001 17.0001Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M12.0001 8.00023C11.7349 8.00023 11.4806 8.10559 11.293 8.29313C11.1055 8.48066 11.0001 8.73502 11.0001 9.00023V13.0002C11.0001 13.2655 11.1055 13.5198 11.293 13.7073C11.4806 13.8949 11.7349 14.0002 12.0001 14.0002C12.2653 14.0002 12.5197 13.8949 12.7072 13.7073C12.8948 13.5198 13.0001 13.2655 13.0001 13.0002V9.00023C13.0001 8.73502 12.8948 8.48066 12.7072 8.29313C12.5197 8.10559 12.2653 8.00023 12.0001 8.00023Z",fill:"currentColor"})]})}function A(e){return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",...e,children:[(0,n.jsx)("path",{d:"M18 3H6C5.20435 3 4.44129 3.31607 3.87868 3.87868C3.31607 4.44129 3 5.20435 3 6V18C3 18.7956 3.31607 19.5587 3.87868 20.1213C4.44129 20.6839 5.20435 21 6 21H18C18.7956 21 19.5587 20.6839 20.1213 20.1213C20.6839 19.5587 21 18.7956 21 18V6C21 5.20435 20.6839 4.44129 20.1213 3.87868C19.5587 3.31607 18.7956 3 18 3ZM6 5H18C18.2652 5 18.5196 5.10536 18.7071 5.29289C18.8946 5.48043 19 5.73478 19 6V14.36L15.8 11.63C15.3042 11.222 14.6821 10.999 14.04 10.999C13.3979 10.999 12.7758 11.222 12.28 11.63L5 17.7V6C5 5.73478 5.10536 5.48043 5.29289 5.29289C5.48043 5.10536 5.73478 5 6 5ZM18 19H6.56L13.56 13.16C13.6945 13.0602 13.8575 13.0062 14.025 13.0062C14.1925 13.0062 14.3555 13.0602 14.49 13.16L19 17V18C19 18.2652 18.8946 18.5196 18.7071 18.7071C18.5196 18.8946 18.2652 19 18 19Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M7.99983 9.99992C8.39766 9.99992 8.77919 9.84188 9.06049 9.56058C9.34179 9.27927 9.49983 8.89774 9.49983 8.49992C9.49983 8.10209 9.34179 7.72056 9.06049 7.43925C8.77919 7.15795 8.39766 6.99992 7.99983 6.99992C7.60201 6.99992 7.22047 7.15795 6.93917 7.43925C6.65787 7.72056 6.49983 8.10209 6.49983 8.49992C6.49983 8.89774 6.65787 9.27927 6.93917 9.56058C7.22047 9.84188 7.60201 9.99992 7.99983 9.99992Z",fill:"currentColor"})]})}function H(e){return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",...e,children:[(0,n.jsx)("path",{d:"M12 2C11.7348 2 11.4804 2.10536 11.2929 2.29289C11.1054 2.48043 11 2.73478 11 3V5C11 5.26522 11.1054 5.51957 11.2929 5.70711C11.4804 5.89464 11.7348 6 12 6C12.2652 6 12.5196 5.89464 12.7071 5.70711C12.8946 5.51957 13 5.26522 13 5V3C13 2.73478 12.8946 2.48043 12.7071 2.29289C12.5196 2.10536 12.2652 2 12 2Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M21.0002 11H19.0002C18.735 11 18.4806 11.1054 18.2931 11.2929C18.1055 11.4804 18.0002 11.7348 18.0002 12C18.0002 12.2652 18.1055 12.5196 18.2931 12.7071C18.4806 12.8946 18.735 13 19.0002 13H21.0002C21.2654 13 21.5197 12.8946 21.7073 12.7071C21.8948 12.5196 22.0002 12.2652 22.0002 12C22.0002 11.7348 21.8948 11.4804 21.7073 11.2929C21.5197 11.1054 21.2654 11 21.0002 11Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M6 12C6 11.7348 5.89464 11.4804 5.70711 11.2929C5.51957 11.1054 5.26522 11 5 11H3C2.73478 11 2.48043 11.1054 2.29289 11.2929C2.10536 11.4804 2 11.7348 2 12C2 12.2652 2.10536 12.5196 2.29289 12.7071C2.48043 12.8946 2.73478 13 3 13H5C5.26522 13 5.51957 12.8946 5.70711 12.7071C5.89464 12.5196 6 12.2652 6 12Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M6.22009 5.00298C6.02357 4.82786 5.76656 4.7362 5.50358 4.74744C5.2406 4.75869 4.99234 4.87196 4.8115 5.06322C4.63065 5.25447 4.53143 5.50867 4.5349 5.77187C4.53838 6.03507 4.64426 6.28656 4.83009 6.47298L6.27009 7.86298C6.36673 7.95629 6.48117 8.02917 6.60659 8.07728C6.73201 8.12538 6.86584 8.14773 7.00009 8.14298C7.1348 8.14246 7.26801 8.11474 7.39173 8.06147C7.51546 8.0082 7.62714 7.93048 7.72009 7.83298C7.90634 7.64561 8.01088 7.39216 8.01088 7.12798C8.01088 6.86379 7.90634 6.61034 7.72009 6.42298L6.22009 5.00298Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M17 8.14285C17.2575 8.14182 17.5047 8.04153 17.69 7.86285L19.13 6.47285C19.3057 6.2893 19.4049 6.04577 19.4075 5.79172C19.4102 5.53767 19.316 5.29214 19.1441 5.10502C18.9723 4.91789 18.7356 4.80319 18.4823 4.78421C18.2289 4.76524 17.9779 4.84341 17.78 5.00285L16.34 6.42285C16.1538 6.61021 16.0493 6.86366 16.0493 7.12785C16.0493 7.39203 16.1538 7.64548 16.34 7.83285C16.5132 8.01557 16.7489 8.12627 17 8.14285Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M12 17.9999C11.7348 17.9999 11.4804 18.1053 11.2929 18.2928C11.1054 18.4803 11 18.7347 11 18.9999V20.9999C11 21.2651 11.1054 21.5195 11.2929 21.707C11.4804 21.8946 11.7348 21.9999 12 21.9999C12.2652 21.9999 12.5196 21.8946 12.7071 21.707C12.8946 21.5195 13 21.2651 13 20.9999V18.9999C13 18.7347 12.8946 18.4803 12.7071 18.2928C12.5196 18.1053 12.2652 17.9999 12 17.9999Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M17.7302 16.1399C17.5392 15.9556 17.2829 15.8547 17.0175 15.8594C16.7521 15.864 16.4995 15.974 16.3152 16.1649C16.1309 16.3559 16.0299 16.6122 16.0346 16.8776C16.0393 17.143 16.1492 17.3956 16.3402 17.5799L17.7802 18.9999C17.9702 19.1835 18.2251 19.2845 18.4893 19.2808C18.7535 19.277 19.0055 19.1688 19.1902 18.9799C19.2837 18.8868 19.3579 18.7762 19.4085 18.6543C19.4591 18.5325 19.4851 18.4019 19.4851 18.2699C19.4851 18.138 19.4591 18.0073 19.4085 17.8855C19.3579 17.7637 19.2837 17.653 19.1902 17.5599L17.7302 16.1399Z",fill:"currentColor"}),(0,n.jsx)("path",{d:"M6.27011 16.141L4.83011 17.531C4.73638 17.624 4.66198 17.7346 4.61121 17.8564C4.56045 17.9783 4.53431 18.109 4.53431 18.241C4.53431 18.373 4.56045 18.5037 4.61121 18.6256C4.66198 18.7474 4.73638 18.858 4.83011 18.951C4.9239 19.0467 5.03596 19.1226 5.15965 19.1741C5.28333 19.2256 5.41612 19.2518 5.55011 19.251C5.79662 19.2531 6.03522 19.1641 6.22011 19.001L7.66011 17.611C7.75466 17.5197 7.83031 17.4107 7.88273 17.2902C7.93516 17.1697 7.96334 17.0401 7.96566 16.9087C7.96798 16.7773 7.9444 16.6467 7.89626 16.5244C7.84813 16.4022 7.77637 16.2905 7.68511 16.196C7.59384 16.1014 7.48484 16.0258 7.36433 15.9734C7.24383 15.9209 7.11418 15.8928 6.98278 15.8904C6.85139 15.8881 6.72082 15.9117 6.59854 15.9598C6.47626 16.008 6.36466 16.0797 6.27011 16.171V16.141Z",fill:"currentColor"})]})}var B=r(6642);function U(e){let{className:t,...r}=e;return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:(0,B.cn)("size-6",t),...r,children:[(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.0625 1.70412C12.1393 1.70359 12.2136 1.7151 12.2842 1.73439C12.6576 1.76978 13.0261 1.88527 13.3604 2.08303L19.7012 5.84084L19.7031 5.84181C20.1036 6.08032 20.4348 6.42322 20.665 6.83498C20.8952 7.24671 21.0168 7.71415 21.0166 8.19142V8.19338L20.998 15.7403C20.9979 16.1352 20.9124 16.526 20.751 16.8848C20.7319 16.9557 20.7049 17.026 20.667 17.0928C20.6355 17.1482 20.5983 17.1987 20.5576 17.2442C20.3296 17.6 20.023 17.8979 19.6631 18.1133L13.2998 21.9072C12.4738 22.3996 11.4611 22.4004 10.6436 21.917L10.6416 21.916L4.30078 18.1582L4.29883 18.1572C3.91023 17.9258 3.58764 17.5957 3.3584 17.2002C3.35105 17.1885 3.34181 17.1773 3.33496 17.1651C3.32803 17.1526 3.32268 17.1387 3.31641 17.126C3.09976 16.7236 2.98517 16.2703 2.98535 15.8076V15.8057L3.00391 8.25588C3.00603 7.28279 3.51293 6.37777 4.33984 5.88478L10.7021 2.09181C11.0682 1.87369 11.4708 1.75231 11.877 1.72658C11.9365 1.71245 11.999 1.70462 12.0625 1.70412ZM5.16895 7.36818C4.87108 7.54583 4.6844 7.87497 4.68359 8.23635L4.66602 15.3838L9.45801 12.5254C9.51085 12.7718 9.60256 13.0142 9.73535 13.2442C9.90127 13.5315 10.1161 13.7727 10.3633 13.9639L5.49512 16.8662L11.499 20.4248C11.8036 20.6044 12.1738 20.6008 12.4707 20.4238L18.5107 16.8233L13.4971 13.877C13.9543 13.482 14.2391 12.9423 14.3242 12.3672L19.3193 15.3037L19.3379 8.21291L19.3369 8.21388C19.3369 8.03517 19.2923 7.85955 19.2061 7.7051C19.1196 7.55056 18.9947 7.42151 18.8447 7.33205L12.8887 3.80275L12.8535 9.73439C12.3304 9.51037 11.7366 9.46806 11.1738 9.63576L11.21 3.76662L5.16895 7.36818Z",fill:"currentColor"}),(0,n.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91641 8.60885C11.7928 7.52595 14.1912 8.16845 15.2748 10.0444C16.3582 11.9209 15.7156 14.3211 13.8393 15.4047C11.9627 16.4879 9.56339 15.8446 8.47989 13.9682C7.39671 12.0916 8.03987 9.69227 9.91641 8.60885ZM13.8031 10.894C13.189 9.83118 11.8293 9.46704 10.766 10.0805C9.7026 10.6945 9.33693 12.0551 9.95059 13.1186C10.5646 14.1821 11.9261 14.5469 12.9897 13.9331C14.0529 13.3189 14.4171 11.9575 13.8031 10.894Z",fill:"currentColor"})]})}var F=r(6103);function q(e){return(0,P.J)(e.uuid)??(0,P.J)(e.tinuuid)}function Y(e){var t;return null==(t=(0,d.Dj)(e)[0])?void 0:t.hid}function $(e,t){return(!t||(0,d.nf)(e)===t)&&(0,d.Dj)(e).length>0}function D(e){let{catalog:t,isEmptySearch:r,isFetchingNextPage:a,mechanic:i,placingObject:o,search:l,onSelectObject:c,onShowAllItems:u}=e,{t:d}=(0,s.Bd)();return r?(0,n.jsx)("div",{className:"grid min-h-[360px] place-items-center px-8 text-center",children:(0,n.jsxs)("div",{className:"grid justify-items-center gap-3",children:[(0,n.jsxs)("div",{className:"grid gap-1",children:[(0,n.jsx)("p",{className:"text-base font-medium text-[#212124]",children:d("catalog.noResults",{search:l.trim()})}),(0,n.jsx)("p",{className:"text-sm font-medium text-[#64646c]",children:d("catalog.noResultsHint")})]}),(0,n.jsx)(N,{type:"button",variant:"outline",className:"h-8 rounded-full border-[#dadae0] px-4 text-xs font-semibold text-[#212124]",onClick:u,children:d("catalog.showAllItems")})]})}):0===t.length?(0,n.jsx)("div",{className:"grid min-h-[300px] place-items-center px-8 text-center",children:(0,n.jsxs)("div",{className:"grid max-w-64 justify-items-center gap-2",children:[(0,n.jsx)(F.A,{"aria-hidden":"true",className:"size-8 text-[#bebec8]"}),(0,n.jsx)("p",{className:"text-sm font-medium text-[#64646c]",children:d("catalog.empty")})]})}):(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-x-2.5 gap-y-4 px-5",children:[t.map((e,t)=>{let r=(0,P.J)(e.name)??d("catalog.unnamedProduct"),a=(0,M.pU)(e),s=$(e,i),l=o===e;return(0,n.jsxs)("button",{type:"button","aria-label":r,className:"ar-catalog-card group relative grid min-w-0 touch-manipulation gap-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-45",disabled:!s||null!==o,onClick:()=>c(e),children:[(0,n.jsx)("span",{className:"ar-catalog-media-frame",children:a?(0,n.jsx)("img",{src:a,alt:"",loading:"lazy",className:"ar-catalog-media-img",decoding:"async",draggable:!1}):(0,n.jsx)(A,{"aria-hidden":"true",className:"size-8 text-[#bebec8]"})}),(0,n.jsx)("span",{className:"truncate text-xs font-medium leading-[1.6] text-[#64646c]",children:r}),l&&(0,n.jsx)("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-white/75",role:"status",children:(0,n.jsx)(O,{className:"size-6"})})]},q(e)??`catalog-object-${t}`)}),a&&(0,n.jsx)("div",{className:"col-span-full grid h-16 place-items-center",role:"status","aria-label":d("catalog.loadingMore"),children:(0,n.jsx)(O,{className:"size-6"})})]})}function V(e){let{className:t,type:r,...a}=e;return(0,n.jsx)("input",{type:r,"data-slot":"input",className:b("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...a})}var Z=r(876);function W(e){let{className:t,onClear:r}=e,{t:a}=(0,s.Bd)();return(0,n.jsx)("button",{type:"button",className:t,onPointerDown:e=>e.preventDefault(),onClick:r,children:a("catalog.clear")})}function G(e){let{onClose:t}=e,{t:r}=(0,s.Bd)();return(0,n.jsx)(N,{type:"button","aria-label":r("close"),variant:"secondary",size:"icon-lg",className:"size-11 rounded-full bg-[#ededed] text-[#212124] hover:bg-[#e3e3e8]",onClick:t,children:(0,n.jsx)(g.A,{className:"size-5","aria-hidden":"true"})})}function X(e){let{catalog:t,gridRef:r,isEmptySearch:a,isFetchingNextPage:i,mechanic:l,placingObject:c,search:u,onClearSearch:d,onClose:h,onScroll:m,onSearchChange:p,onSelectObject:f,onShowAllItems:g}=e,{t:v}=(0,s.Bd)(),x=(0,o.useRef)(null),b=u.trim().length>0;return(0,o.useLayoutEffect)(()=>{var e;null==(e=x.current)||e.focus({preventScroll:!0})},[]),(0,n.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-white text-[#212124]","data-testid":"ar-catalog-search-overlay",children:[(0,n.jsxs)("div",{className:"flex gap-2 px-5 pt-[max(1rem,env(safe-area-inset-top))] pb-3",children:[(0,n.jsxs)("div",{className:"relative flex h-11 min-w-0 flex-1 items-center rounded-full bg-[#ededed] text-[#64646c]",children:[(0,n.jsx)(Z.A,{className:"ml-3 size-5 shrink-0","aria-hidden":"true"}),(0,n.jsx)(V,{ref:x,autoFocus:!0,value:u,"aria-label":v("catalog.searchPlaceholder"),className:"h-11 flex-1 border-0 bg-transparent px-2 pr-24 text-base font-medium text-[#212124] shadow-none placeholder:text-[#64646c] focus-visible:ring-0 md:text-sm",autoComplete:"off",enterKeyHint:"search",inputMode:"search",placeholder:v("catalog.searchPlaceholder"),role:"searchbox",type:"text",onChange:e=>p(e.currentTarget.value)}),b&&(0,n.jsx)(W,{className:"absolute right-5 text-sm font-semibold text-primary",onClear:d})]}),(0,n.jsx)(G,{onClose:h})]}),(0,n.jsx)("div",{ref:r,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain pt-2 pb-[calc(1.5rem+var(--ar-catalog-keyboard-bottom,0px)+env(safe-area-inset-bottom))] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden","data-testid":"ar-catalog-search-results",onScroll:m,children:(0,n.jsx)(D,{catalog:t,isEmptySearch:a,isFetchingNextPage:i,mechanic:l,placingObject:c,search:u,onSelectObject:f,onShowAllItems:g})})]})}function K(e){let{search:t,onClearSearch:r,onClose:a,onOpenSearch:i}=e,{t:o}=(0,s.Bd)(),l=t.trim().length>0;return(0,n.jsxs)("div",{className:"absolute inset-x-0 bottom-0 z-20 flex gap-2 bg-white px-5 pt-4 pb-[max(1.5rem,env(safe-area-inset-bottom))]",children:[(0,n.jsxs)("div",{className:"relative flex min-w-0 flex-1",children:[(0,n.jsxs)("button",{type:"button","aria-label":o("catalog.searchPlaceholder"),className:b("flex h-11 min-w-0 flex-1 items-center rounded-full bg-[#ededed] px-3 text-left text-base font-medium text-[#212124] md:text-sm",l?"pr-24":"text-[#64646c]"),onClick:i,children:[(0,n.jsx)(Z.A,{className:"mr-2 size-5 shrink-0 text-[#64646c]","aria-hidden":"true"}),(0,n.jsx)("span",{className:"truncate",children:l?t:o("catalog.searchPlaceholder")})]}),l&&(0,n.jsx)(W,{className:"absolute top-1/2 right-5 -translate-y-1/2 text-sm font-semibold text-primary",onClear:r})]}),(0,n.jsx)(G,{onClose:a})]})}var J=r(7984);let Q=o.createContext(null);function ee(){let e=o.use(Q);if(!e)throw Error("useCarousel must be used within a <Carousel />");return e}function et(e){let{orientation:t="horizontal",opts:r,setApi:a,plugins:i,className:s,children:l,...c}=e,[u,d]=(0,J.A)({...r,axis:"horizontal"===t?"x":"y"},i),[h,m]=o.useState(!1),[p,f]=o.useState(!1),g=o.useCallback(e=>{e&&(m(e.canScrollPrev()),f(e.canScrollNext()))},[]),v=o.useCallback(()=>{null==d||d.scrollPrev()},[d]),x=o.useCallback(()=>{null==d||d.scrollNext()},[d]),w=o.useCallback(e=>{"ArrowLeft"===e.key?(e.preventDefault(),v()):"ArrowRight"===e.key&&(e.preventDefault(),x())},[v,x]);return o.useEffect(()=>{d&&a&&a(d)},[d,a]),o.useEffect(()=>{if(d)return g(d),d.on("reInit",g),d.on("select",g),()=>{null==d||d.off("select",g)}},[d,g]),(0,n.jsx)(Q,{value:{carouselRef:u,api:d,opts:r,orientation:t||((null==r?void 0:r.axis)==="y"?"vertical":"horizontal"),scrollPrev:v,scrollNext:x,canScrollPrev:h,canScrollNext:p},children:(0,n.jsx)("div",{onKeyDownCapture:w,className:b("relative",s),role:"region","aria-roledescription":"carousel","data-slot":"carousel",...c,children:l})})}function er(e){let{className:t,...r}=e,{carouselRef:a,orientation:i}=ee();return(0,n.jsx)("div",{ref:a,className:"overflow-hidden","data-slot":"carousel-content",children:(0,n.jsx)("div",{className:b("flex","horizontal"===i?"-ml-4":"-mt-4 flex-col",t),...r})})}function en(e){let{className:t,...r}=e,{orientation:a}=ee();return(0,n.jsx)("div",{role:"group","aria-roledescription":"slide","data-slot":"carousel-item",className:b("min-w-0 shrink-0 grow-0 basis-full","horizontal"===a?"pl-4":"pt-4",t),...r})}var ea=r(295);function ei(e){let{...t}=e;return(0,n.jsx)(ea._s.Root,{"data-slot":"drawer",...t})}function eo(e){let{...t}=e;return(0,n.jsx)(ea._s.Portal,{"data-slot":"drawer-portal",...t})}function es(e){let{className:t,...r}=e;return(0,n.jsx)(ea._s.Overlay,{"data-slot":"drawer-overlay",className:b("fixed inset-0 z-50 bg-black/10 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",t),...r})}function el(e){let{className:t,children:r,overlayClassName:a,portalContainer:i,showHandle:o=!0,...s}=e;return(0,n.jsxs)(eo,{"data-slot":"drawer-portal",container:i,children:[(0,n.jsx)(es,{className:a}),(0,n.jsxs)(ea._s.Content,{"data-slot":"drawer-content",className:b("group/drawer-content fixed z-50 flex h-auto flex-col bg-popover text-sm text-popover-foreground data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-t data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:rounded-r-xl data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:rounded-l-xl data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-b data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm",t),...s,children:[o&&(0,n.jsx)("div",{className:"mx-auto mt-4 hidden h-1 w-[100px] shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),r]})]})}function ec(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"drawer-header",className:b("flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-0.5 md:text-left",t),...r})}function eu(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"drawer-footer",className:b("mt-auto flex flex-col gap-2 p-4",t),...r})}function ed(e){let{className:t,...r}=e;return(0,n.jsx)(ea._s.Title,{"data-slot":"drawer-title",className:b("font-heading text-base font-medium text-foreground",t),...r})}function eh(e){let{className:t,...r}=e;return(0,n.jsx)(ea._s.Description,{"data-slot":"drawer-description",className:b("text-sm text-muted-foreground",t),...r})}var em=r(9748);function ep(e){let{className:t,children:r,...a}=e;return(0,n.jsxs)(em.bL,{"data-slot":"scroll-area",className:b("relative",t),...a,children:[(0,n.jsx)(em.LM,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:r}),(0,n.jsx)(ef,{}),(0,n.jsx)(em.OK,{})]})}function ef(e){let{className:t,orientation:r="vertical",...a}=e;return(0,n.jsx)(em.VM,{"data-slot":"scroll-area-scrollbar","data-orientation":r,orientation:r,className:b("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",t),...a,children:(0,n.jsx)(em.lr,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}var eg=r(2828);function ev(e){let{object:t,placing:r=!1,portalContainer:a,showcaseHost:i,testId:l,onOpenChange:c,onPlace:u,onViewOnSite:d}=e,{t:h}=(0,s.Bd)(),[m,p]=(0,o.useState)(),[f,g]=(0,o.useReducer)((e,t)=>t,0),v=(0,o.useMemo)(()=>t?(0,M.H7)(t):[],[t]),x=t?(0,P.J)(t.name)??h("catalog.unnamedProduct"):"",w=(0,P.J)(null==t?void 0:t.description),y=(0,P.R)(i,null==t?void 0:t.tinuuid);return(0,o.useEffect)(()=>{g(0)},[t]),(0,o.useEffect)(()=>{if(!m)return;let e=()=>g(m.selectedScrollSnap());return e(),m.on("select",e),m.on("reInit",e),()=>{m.off("select",e),m.off("reInit",e)}},[m]),(0,n.jsx)(ei,{open:!!t,onOpenChange:c,children:(0,n.jsxs)(el,{"data-testid":l,overlayClassName:"bg-[#212124]/60 backdrop-blur-0",portalContainer:a,showHandle:!1,className:"right-2 bottom-2 left-2 mx-auto max-h-[calc(100svh-72px)] max-w-[386px] overflow-hidden rounded-[24px] border-0 bg-white text-[#212124] shadow-2xl data-[vaul-drawer-direction=bottom]:inset-x-2 data-[vaul-drawer-direction=bottom]:bottom-2 data-[vaul-drawer-direction=bottom]:mt-[72px] data-[vaul-drawer-direction=bottom]:max-h-[calc(100svh-72px)] data-[vaul-drawer-direction=bottom]:rounded-[24px]",children:[(0,n.jsx)("div",{className:"mx-auto mt-2 h-1 w-10 shrink-0 rounded-full bg-[#dadae0]"}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[(0,n.jsxs)(ec,{className:"px-6 pt-4 pb-0 text-left",children:[(0,n.jsx)(ed,{className:"text-base font-medium leading-snug text-[#212124]",children:x}),(0,n.jsx)(eh,{className:"sr-only",children:h("catalog.productDetails")})]}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden px-6 pt-4",children:(0,n.jsx)(ep,{className:"h-full pr-1",children:(0,n.jsxs)("div",{className:"grid gap-4 pb-4",children:[(0,n.jsx)("div",{className:"grid gap-2",children:v.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(et,{className:"select-none touch-pan-y",setApi:p,opts:{duration:18,loop:v.length>1},children:(0,n.jsx)(er,{className:"-ml-0 touch-pan-y will-change-transform",children:v.map(e=>(0,n.jsx)(en,{className:"pl-0",children:(0,n.jsx)("div",{className:"ar-catalog-media-frame",children:(0,n.jsx)("img",{src:e,alt:"",className:"ar-catalog-media-img ar-catalog-media-img--passive",decoding:"async",draggable:!1,loading:"eager"})})},e))})}),v.length>1&&(0,n.jsx)("div",{className:"flex justify-center gap-1.5","aria-hidden":"true",children:v.map((e,t)=>(0,n.jsx)("span",{className:b("size-1.5 rounded-full",t===f?"bg-primary":"bg-[#d9d9d9]")},e))})]}):(0,n.jsx)("div",{className:"grid aspect-[338/237] place-items-center rounded-lg bg-[#ededed]",children:(0,n.jsx)(A,{"aria-hidden":"true",className:"size-10 text-[#bebec8]"})})}),w&&(0,n.jsx)("p",{className:"whitespace-pre-line text-sm font-medium leading-[1.5] text-[#212124]",children:w})]})})}),(0,n.jsxs)(eu,{className:"sticky bottom-0 gap-3 bg-white px-6 pt-3 pb-[max(1.875rem,env(safe-area-inset-bottom))]",children:[u&&(0,n.jsxs)(N,{type:"button",className:"h-11 w-full rounded-xl bg-primary text-base font-semibold text-primary-foreground hover:bg-primary/90",disabled:!t||r,onClick:()=>void u(),children:[r?(0,n.jsx)(O,{className:"size-5"}):(0,n.jsx)(U,{className:"size-6","aria-hidden":"true"}),h("catalog.tryInRoom")]}),y&&(0,n.jsxs)("a",{href:y,target:"_blank",rel:"noreferrer",className:"inline-flex h-6 items-center justify-center gap-1 text-sm font-semibold text-primary",onClick:d,children:[h("catalog.viewOnSite"),(0,n.jsx)(eg.A,{className:"size-4","aria-hidden":"true"})]})]})]})]})})}function ex(){if("u"<typeof document)return;let e=document.activeElement;e instanceof HTMLElement&&e.blur()}function eb(e,t){return{category:e.category,resultCount:t,search:e.search.trim()}}function ew(e){var t;let{catalog:r,categories:a,filters:i,isLoadingCategories:l,mechanic:c,owner:u,ownerAccount:d,pagination:h,setFilters:m,showcaseHost:p,onOpenChange:g,onPlace:v,open:x,portalContainer:b}=e,{t:w}=(0,s.Bd)(),y=(0,L.Xf)(),j=(0,_.Rl)(x),C=(0,_.f3)(x),{fetchNextPage:R,hasNextPage:z,isFetchingNextPage:k}=h,N=(0,o.useRef)(null),S=(0,o.useRef)(eb(i,r.length)),E=(0,o.useRef)(i.search.trim()),[I,O]=(0,o.useState)(null),[T,A]=(0,o.useState)(null),[H,B]=(0,o.useState)(!1),[U,F]=(0,o.useState)(!1),q=(0,o.useRef)(!1);x&&(S.current=eb(i,r.length)),(0,o.useEffect)(()=>{if(x)return y({catalog:S.current,name:"catalog_opened"}),()=>y({catalog:S.current,name:"catalog_closed"})},[y,x]),(0,o.useEffect)(()=>{let e=i.search.trim();if(!x){E.current=e;return}if(e===E.current)return;let t=window.setTimeout(()=>{E.current=e,y({catalog:{category:i.category,search:e},name:"catalog_search_changed"})},400);return()=>window.clearTimeout(t)},[y,i.category,i.search,x]),(0,o.useEffect)(()=>{let e=N.current;x&&e&&!k&&z&&e.scrollHeight<=e.clientHeight&&R()},[r.length,R,z,k,x,U]);let V=(0,o.useCallback)(e=>{if(!z||k)return;let{clientHeight:t,scrollHeight:r,scrollTop:n}=e.currentTarget;n+t>=r-96&&R()},[R,z,k]),Z=(0,o.useCallback)(e=>{e||(F(!1),O(null),A(null),B(!1),m({category:null,search:""})),g(e)},[g,m]),W=(0,o.useCallback)(e=>{m(t=>({...t,search:e}))},[m]),G=(0,o.useCallback)(e=>{m(t=>({...t,category:e})),y({catalog:{category:e,search:i.search.trim()},name:"catalog_category_selected"})},[y,i.search,m]),J=(0,o.useCallback)(()=>{m(e=>({...e,search:""}))},[m]),Q=(0,o.useCallback)(()=>{J(),ex()},[J]),ee=(0,o.useCallback)(()=>{F(!1),ex()},[]);(0,o.useEffect)(()=>{if(!U){q.current=!1;return}if(C){q.current=!0;return}if(!q.current)return;let e=window.setTimeout(ee,200);return()=>window.clearTimeout(e)},[ee,C,U]);let et=(0,o.useCallback)(()=>{m({category:null,search:""}),ee(),y({catalog:{category:null,search:""},name:"catalog_show_all_clicked"})},[ee,y,m]),er=(0,o.useCallback)(e=>{$(e,c)&&(ee(),B(!1),O(e),y({object:(0,L.ZY)(e,Y(e)),name:"catalog_product_opened"}))},[ee,y,c]),en=(0,o.useCallback)(async()=>{if(!I)return;let e=Y(I);e&&(A(I),B(!1),y({object:(0,L.ZY)(I,e),name:"catalog_product_place_clicked"}),await v(I,e).catch(()=>!1)?(y({object:(0,L.ZY)(I,e),name:"catalog_product_place_succeeded"}),Z(!1)):(y({object:(0,L.ZY)(I,e),name:"catalog_product_place_failed"}),B(!0)),A(null))},[y,Z,v,I]),ea=(t=w("catalog.unnamedOwner"),(0,P.J)(null==d?void 0:d.name)??(0,P.J)(null==u?void 0:u.name)??t),ei=(0,M.cV)(null==d?void 0:d.avatar)??(0,M.cV)(null==u?void 0:u.avatar),eo=(0,M.cV)(null==d?void 0:d.background),es=i.search.trim().length>0&&0===r.length;return(0,n.jsx)(f.lG,{open:x,onOpenChange:Z,children:(0,n.jsxs)(f.Cf,{contentInsideOverlay:!0,"data-testid":"ar-catalog-dialog",className:"inset-0 top-0 left-0 flex h-[100svh] max-h-none w-full !max-w-none translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden rounded-none border-0 bg-white p-0 text-[#212124] shadow-none",portalContainer:b,style:j,showCloseButton:!1,onOpenAutoFocus:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:[(0,n.jsx)(f.L3,{className:"sr-only",children:w("catalog.title")}),(0,n.jsx)(f.rr,{className:"sr-only",children:w("catalog.description")}),(0,n.jsxs)("div",{ref:U?void 0:N,"aria-hidden":U,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[calc(5.75rem+var(--ar-catalog-keyboard-bottom,0px)+env(safe-area-inset-bottom))] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden","data-testid":"ar-catalog-grid",onScroll:V,children:[(0,n.jsx)(ey,{accountName:ea,avatarUrl:ei,backgroundUrl:eo}),(0,n.jsx)(ej,{categories:a,filters:i,isLoading:l,onChange:G}),H&&(0,n.jsx)("p",{className:"mx-5 mt-4 rounded-xl bg-red-50 p-3 text-sm font-medium text-red-600","aria-live":"polite",children:w("catalog.placementFailed")}),(0,n.jsx)(D,{catalog:r,isEmptySearch:es,isFetchingNextPage:k,mechanic:c,placingObject:T,search:i.search,onSelectObject:er,onShowAllItems:et})]}),U?(0,n.jsx)(X,{catalog:r,gridRef:N,isEmptySearch:es,isFetchingNextPage:k,mechanic:c,placingObject:T,search:i.search,onClearSearch:J,onClose:ee,onScroll:V,onSearchChange:W,onSelectObject:er,onShowAllItems:et}):(0,n.jsx)(K,{search:i.search,onClearSearch:Q,onClose:()=>Z(!1),onOpenSearch:()=>F(!0)}),(0,n.jsx)(ev,{object:I,placing:T===I,portalContainer:b,showcaseHost:p,onOpenChange:e=>{e||O(null)},onPlace:en,onViewOnSite:()=>{I&&y({object:(0,L.ZY)(I,Y(I)),name:"catalog_product_view_on_site_clicked"})}})]})})}function ey(e){let{accountName:t,avatarUrl:r,backgroundUrl:a}=e;return(0,n.jsxs)("section",{className:"relative grid h-[200px] place-items-center overflow-hidden bg-[#dadae0]",children:[a?(0,n.jsx)("img",{src:a,alt:"",className:"absolute inset-0 size-full object-cover",decoding:"async"}):null,(0,n.jsx)("div",{className:"absolute inset-0 bg-[#212124]/40"}),(0,n.jsxs)("div",{className:"relative z-10 grid justify-items-center gap-3 px-5 text-center text-white",children:[(0,n.jsxs)(y,{className:"size-[72px] border-2 border-white/70 bg-white/20 shadow-sm",children:[(0,n.jsx)(j,{src:r,alt:"",className:"object-cover"}),(0,n.jsx)(C,{className:"bg-white/20 text-white",children:(0,n.jsx)(S.A,{className:"size-8","aria-hidden":"true"})})]}),(0,n.jsx)("h2",{className:"text-lg font-medium leading-tight drop-shadow-sm",children:t})]})]})}function ej(e){let{categories:t,filters:r,isLoading:a,onChange:i}=e,{t:o}=(0,s.Bd)();return a?(0,n.jsx)("div",{className:"flex gap-1 overflow-x-auto px-5 py-5 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:[0,1,2].map(e=>(0,n.jsx)("span",{className:"h-8 w-20 shrink-0 rounded-full bg-[#ededed]"},e))}):(0,n.jsxs)("div",{className:"flex gap-1 overflow-x-auto px-5 py-5 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:[(0,n.jsx)(eC,{active:!r.category,label:o("catalog.all"),onClick:()=>i(null)}),t.map(e=>{var t;return(0,n.jsx)(eC,{active:(null==(t=r.category)?void 0:t.id)===e.id&&r.category.kind===e.kind,label:e.name,onClick:()=>i(e)},`${e.kind}:${e.id}`)})]})}function eC(e){let{active:t,label:r,onClick:a}=e;return(0,n.jsx)(N,{type:"button",variant:t?"default":"secondary",className:b("h-8 shrink-0 rounded-full px-4 text-sm font-medium",t?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-[#ededed] text-[#212124] hover:bg-[#e3e3e8]"),onClick:a,children:r})}var eR=r(2083),ez=r(251),ek=r(4856);let eN={"camera-denied":"cameraDenied",error:"error",rescan:"rescan",unsupported:"unsupported",webview:"webview"},eS={"camera-denied":eR.A,error:ez.A,rescan:ek.A,unsupported:ez.A,webview:eg.A};function e_(e){let{variant:t}=e,{t:r}=(0,s.Bd)(),a=eN[t],i=eS[t];return(0,n.jsxs)("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black/85 p-8 text-center text-white",role:"alert",children:[(0,n.jsx)(i,{"aria-hidden":"true",className:"size-10"}),(0,n.jsx)("h2",{className:"text-lg font-medium",children:r(`runtimeState.${a}.title`)}),(0,n.jsx)("p",{className:"max-w-sm text-sm text-white/80",children:r(`runtimeState.${a}.body`)})]})}function eL(e){let{status:t}=e;return"lost"!==t?null:(0,n.jsx)(e_,{variant:"rescan"})}var eM=r(350);function eP(e){return Math.min(10,Math.max(.45,e))}function eE(e,t){if("floor"!==e.kind)throw Error("Ceiling calibration requires a floor surface hit.");let r=eP(t),n=e.pose.position.y;return{floorY:n,position:{x:e.pose.position.x,y:n+r,z:e.pose.position.z},scale:1,suspensionHeight:r,yaw:0}}function eI(e,t,r){return r?e.suspensionHeight:Math.max(0,e.suspensionHeight-t*e.scale)}var eO=r(308);function eT(){return{missingSince:null,status:"tracking"}}function eA(e,t){if(t.hasPose)return eT();let r=e.missingSince??t.now,n=t.now-r;return n>=5e3?{missingSince:r,status:"lost"}:n>=1e3?{missingSince:r,status:"relocalizing"}:{missingSince:r,status:"tracking"}}let eH={floorY:0,position:{x:0,y:2,z:-1},scale:1,suspensionHeight:2,yaw:0};function eB(){return{...eH,position:{...eH.position}}}function eU(e){return e.runtime.modelHeight??e.resource.dimensions.height}var eF=r(2326);let eq=Object.freeze({engine:!0});function eY(e){let{bridge:t}=e;(0,eF.D)(()=>void 0,1);let r=(0,eF.C)(),n=(0,o.useRef)(r);return n.current=r,(0,o.useEffect)(()=>t.onFrame(e=>{let{time:t}=e;return(0,eF.n)(t,!0,n.current,eq)}),[t]),null}function e$(e){let{texture:t}=e,r=(0,eF.C)(e=>e.scene);return(0,o.useEffect)(()=>(function(e,t){if(!e)return()=>void 0;let r=e.environment;return e.environment=t,()=>{e.environment=r}})(r,t),[r,t]),null}function eD(e){return{mechanic:e.mechanic,objectId:e.id,variantId:e.variantId}}function eV(e){return e instanceof Error?{message:e.message,name:e.name}:{message:"string"==typeof e?e:void 0}}var eZ=r(5615),eW=r(2002),eG=r(7552),eX=r(112);let eK="max(1.5rem, env(safe-area-inset-bottom))";function eJ(e){let{className:t,variant:r}=e;return(0,n.jsx)("span",{className:b("grid place-items-center overflow-hidden rounded-[12px] bg-white",t),children:(null==r?void 0:r.previewUrl)?(0,n.jsx)("img",{alt:"",className:"pointer-events-none h-11 w-[42px] select-none object-contain",src:r.previewUrl}):null})}function eQ(e){let{currentVariantId:t,open:r,portalContainer:a,variants:i,onOpenChange:o,onSelect:l}=e,{t:c}=(0,s.Bd)();return(0,n.jsx)(ei,{open:r,onOpenChange:o,children:(0,n.jsxs)(el,{className:"bg-white text-[#212124]",portalContainer:a,children:[(0,n.jsxs)(ec,{className:"px-6 pt-4 pb-0 text-left",children:[(0,n.jsx)(ed,{className:"text-left text-base font-medium",children:c("catalog.selectVariant")}),(0,n.jsx)(eh,{className:"sr-only",children:c("catalog.selectVariant")})]}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-3 p-6","data-testid":"ar-session-variant-sheet",children:i.map(e=>(0,n.jsxs)("button",{type:"button","aria-pressed":e.hid===t,className:b("grid gap-1 rounded-xl border-2 bg-white p-2 text-left",e.hid===t?"border-primary":"border-[#ededed]"),onClick:()=>l(e.hid),children:[(0,n.jsx)("span",{className:"ar-catalog-media-frame",children:e.previewUrl?(0,n.jsx)("img",{alt:"",className:"ar-catalog-media-img",src:e.previewUrl}):null}),e.name?(0,n.jsx)("span",{className:"truncate text-xs text-[#64646c]",children:e.name}):null]},e.hid))})]})})}let e0="bg-[var(--v-backgrounds-green)] [background-image:var(--v-backgrounds-green-gradient)] text-white";function e1(e){let{activeMechanic:t,confirmDisabled:r,confirmIconLabel:a,confirmLabel:i,controlsRef:o,currentVariant:l,isStarting:c,nextVariant:u,productName:d,showCatalogButton:h,showConfirmButton:m,showConfirmIcon:f,showDeleteButton:g,showSetFloorButton:v,showStartButton:x,onConfirm:b,onDelete:w,onOpenCatalog:y,onOpenProduct:j,onOpenVariants:C,onSetFloorPoint:R,onStart:z}=e,{t:k}=(0,s.Bd)();return(0,n.jsxs)("div",{ref:o,className:"absolute inset-x-6 z-10 grid grid-cols-[1fr_auto_1fr] items-end gap-3",style:{bottom:eK},"data-testid":"ar-session-controls",children:[(0,n.jsx)("div",{className:"flex items-end gap-2",children:g?(0,n.jsx)(p.$,{size:"icon-lg",variant:"secondary","aria-label":k("floor.deleteObject"),"data-testid":"ar-session-delete",onClick:w,children:(0,n.jsx)(eZ.A,{"aria-hidden":"true"})}):null}),(0,n.jsxs)("div",{className:"flex min-w-0 items-end gap-2",children:[x?(0,n.jsx)(p.$,{disabled:c,onClick:z,children:k(c?`${t}.starting`:`${t}.start`)}):null,v?(0,n.jsxs)(p.$,{className:e0,size:"lg",onClick:R,children:[(0,n.jsx)(eW.A,{"aria-hidden":"true"}),k("ceiling.setFloor")]}):null,m?(0,n.jsxs)(p.$,{className:e0,size:"lg","data-testid":"ar-session-confirm",disabled:r,onClick:b,children:[(0,n.jsx)(eW.A,{"aria-hidden":"true"}),i]}):null,u||d?(0,n.jsxs)("div",{className:"grid min-w-0 justify-items-center gap-2",children:[u?(0,n.jsxs)("button",{type:"button","aria-label":k("catalog.selectVariant"),className:"relative h-[69px] w-[76px] shrink-0","data-testid":"ar-session-variant-chip",onClick:C,children:[(0,n.jsx)(eJ,{className:"absolute top-0 left-4 size-[60px] opacity-80",variant:u}),(0,n.jsx)(eJ,{className:"absolute top-[9px] left-0 z-10 size-[60px] shadow-[0_4px_12px_rgba(51,51,65,0.12)]",variant:l})]}):null,d?(0,n.jsxs)("button",{type:"button",className:"flex min-w-0 max-w-[13rem] items-center gap-1.5 rounded-full bg-white px-3 py-2 text-sm font-medium text-[#212124] shadow-[0_2px_10px_rgba(0,0,0,0.18)]","data-testid":"ar-session-product",onClick:j,children:[(0,n.jsx)(eG.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-[#64646c]"}),(0,n.jsx)("span",{className:"truncate",children:d})]}):null]}):null]}),(0,n.jsxs)("div",{className:"flex items-end justify-end gap-2",children:[f?(0,n.jsx)(p.$,{className:`${e0} rounded-full`,size:"icon-lg","aria-label":a,"data-testid":"ar-session-confirm",disabled:r,onClick:b,children:(0,n.jsx)(eW.A,{"aria-hidden":"true"})}):null,h?(0,n.jsx)(p.$,{className:"rounded-full shadow-[0_0_0_1px_rgba(0,0,0,0.12),0_4px_12px_rgba(0,0,0,0.3)]",size:"icon-lg","aria-label":k("catalog.open"),"data-testid":"ar-session-catalog",onClick:y,children:(0,n.jsx)(eX.A,{"aria-hidden":"true"})}):null]})]})}var e2=r(5148),e4=r(5807);function e3(e){let{w:t,x:r,y:n,z:a}=e.orientation;return Math.atan2(2*(t*n+r*a),1-2*(r*r+n*n))}function e7(e,t,r){let n=e3(r)-e3(t),a=Math.atan2(Math.sin(n),Math.cos(n)),i=Math.cos(a),o=Math.sin(a),s=e.position.x-t.position.x,l=e.position.z-t.position.z;return{...e,position:{x:r.position.x+i*s+o*l,y:e.position.y+r.position.y-t.position.y,z:r.position.z-o*s+i*l},yaw:e.yaw+a}}function e5(e,t){if("floor"!==e.kind)throw Error("Floor placement requires a floor surface hit.");return{position:{...e.pose.position},scale:(null==t?void 0:t.scale)??1,yaw:(null==t?void 0:t.yaw)??0}}function e9(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{x:0,y:0,z:1},r=Math.hypot(e.x,e.z);return 0===r?{...t,y:0}:{x:0===e.x?0:e.x/r,y:0,z:0===e.z?0:e.z/r}}function e6(e,t){let r=e9(e),n=e9(t);return Math.min(1,Math.max(-1,r.x*n.x+r.z*n.z))}function e8(e,t,r){let n,a,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.height,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:t.depth/2,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(!(0,e4.aq)(e))throw Error("Wall placement requires a wall surface hit.");let l=(n=e9(e.normal),a={x:r.x-e.pose.position.x,y:0,z:r.z-e.pose.position.z},n.x*a.x+n.z*a.z>=0?n:{x:0===n.x?0:-n.x,y:0,z:0===n.z?0:-n.z});return{surface:"wall",orientationRoot:{pitch:0,position:{x:0,y:-(s+i/2),z:0}},userRoot:{scale:1,yaw:0},worldRoot:{normal:l,position:{x:e.pose.position.x+l.x*o,y:e.pose.position.y,z:e.pose.position.z+l.z*o},yaw:Math.atan2(l.x,l.z)}}}function te(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return-e.minZ*t}function tt(e){return{surface:e.surface,orientationRoot:{position:{...e.orientationRoot.position}},userRoot:{...e.userRoot},worldRoot:{normal:{...e.worldRoot.normal},position:{...e.worldRoot.position},yaw:e.worldRoot.yaw}}}let tr=.4*Math.PI/180;function tn(e,t,r){let n=ta({position:e.worldRoot.position,scale:1,yaw:e.worldRoot.yaw},{position:t.worldRoot.position,scale:1,yaw:t.worldRoot.yaw},r),a=ta({position:{x:0,y:0,z:0},scale:e.userRoot.scale,yaw:e.userRoot.yaw},{position:{x:0,y:0,z:0},scale:t.userRoot.scale,yaw:t.userRoot.yaw},r);return{...t,userRoot:{scale:a.scale,yaw:a.yaw},worldRoot:{...t.worldRoot,position:n.position,yaw:n.yaw}}}function ta(e,t){var r,n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.22,i=t.position.x-e.position.x,o=t.position.y-e.position.y,s=t.position.z-e.position.z,l=Math.hypot(i,o,s),c=(r=e.yaw,Math.atan2(Math.sin((n=t.yaw)-r),Math.cos(n-r)));return{position:l<.001?{...t.position}:{x:e.position.x+i*a,y:e.position.y+o*a,z:e.position.z+s*a},scale:.001>Math.abs(t.scale-e.scale)?t.scale:e.scale+(t.scale-e.scale)*a,yaw:Math.abs(c)<tr?t.yaw:e.yaw+c*a}}let ti=`
2
- uniform float uWidth, uDepth;
3
- varying vec2 vPos;
4
- void main() {
5
- vec3 p = position;
6
- p.x *= uWidth;
7
- p.z *= uDepth;
8
- vPos = p.xz;
9
- gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
10
- }
11
- `,to=`
12
- precision highp float;
13
- uniform float uWidth, uDepth, uBorder, uRadius, uInset, uOpacity;
14
- uniform vec3 uColor;
15
- varying vec2 vPos;
16
-
17
- float sdRoundRect(vec2 p, vec2 b, float r) {
18
- vec2 q = abs(p) - (b - vec2(r));
19
- return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
20
- }
21
-
22
- void main() {
23
- vec2 halfSize = 0.5 * vec2(uWidth, uDepth);
24
- float safeRadius = max(0.0, min(halfSize.x, halfSize.y) - 0.0001);
25
- float r = clamp(uRadius, 0.0, safeRadius);
26
- float dOuter = sdRoundRect(vPos, halfSize - vec2(uInset), max(0.0, r - uInset));
27
- float dInner = sdRoundRect(vPos, halfSize - vec2(uInset + uBorder), max(0.0, r - (uInset + uBorder)));
28
-
29
- float aa = max(fwidth(dOuter), 0.0005);
30
- float outer = smoothstep(0.0, aa, -dOuter);
31
- float inner = smoothstep(0.0, aa, -dInner);
32
- float borderMask = clamp(outer - inner, 0.0, 1.0);
33
-
34
- float alpha = borderMask * uOpacity;
35
- if (alpha < 0.001) discard;
36
- gl_FragColor = vec4(uColor, alpha);
37
- }
38
- `,ts=`
39
- varying vec2 vUv;
40
- void main() {
41
- vUv = uv;
42
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
43
- }
44
- `,tl=`
45
- precision highp float;
46
- varying vec2 vUv;
47
- uniform vec3 uColor;
48
- uniform float uOpacity;
49
- uniform float uSoftness;
50
-
51
- void main() {
52
- vec2 p = vUv * 2.0 - 1.0;
53
- float radial = length(p);
54
- float edge = max(0.01, min(0.99, 1.0 - uSoftness));
55
- float mask = 1.0 - smoothstep(edge, 1.0, radial);
56
- float alpha = mask * uOpacity;
57
- if (alpha < 0.001) discard;
58
- gl_FragColor = vec4(uColor, alpha);
59
- }
60
- `;function tc(){}function tu(e){let{border:t,color:r,depth:n,doubleSide:a,inset:i,opacity:o,radius:s,renderOrder:l,width:c}=e,u=new eO.bdM(1,1).rotateX(-Math.PI/2),d=new eO.BKk({depthWrite:!1,fragmentShader:to,side:2*!!a,transparent:!0,uniforms:{uBorder:{value:t},uColor:{value:new eO.Q1f(r)},uDepth:{value:n},uInset:{value:i},uOpacity:{value:o},uRadius:{value:s},uWidth:{value:c}},vertexShader:ti}),h=new eO.eaF(u,d);return h.renderOrder=l,h.raycast=tc,h}function td(e,t){let{depth:r,radius:n,width:a}=t,i=e.material;i.uniforms.uDepth.value=r,i.uniforms.uRadius.value=n,i.uniforms.uWidth.value=a}function th(e){if(!e)return;e.geometry.dispose();let t=e.material;Array.isArray(t)?t.forEach(e=>e.dispose()):t.dispose()}let tm="#ffffff",tp={depth:.36,radius:.09,width:.36};function tf(e){let{phase:t,placing:r,selected:n}=e;return n||r&&"preview"===t}function tg(e){let{elapsedMs:t,from:r,to:n}=e;return r+(n-r)*(1-(1-Math.min(1,Math.max(0,t/170)))**3)}function tv(e){let{active:t,root:r,surface:a}=e,{groundedShadow:i,revealedShadow:s,stand:l,standShape:c}=(0,o.useMemo)(()=>{let e=function(e){let t;e.updateWorldMatrix(!0,!0);let r=e.matrixWorld.clone().invert(),n=new eO.NRn,a=new eO.NRn,i=new eO.kn4,o=!1;for(let s of(t=[],e.traverse(e=>{"isMesh"in e&&e.isMesh&&t.push(e)}),t))s.geometry.boundingBox||s.geometry.computeBoundingBox(),s.geometry.boundingBox&&(a.copy(s.geometry.boundingBox),a.applyMatrix4(i.multiplyMatrices(r,s.matrixWorld)),o?n.union(a):(n.copy(a),o=!0));return o?{max:{x:n.max.x,y:n.max.y,z:n.max.z},min:{x:n.min.x,y:n.min.y,z:n.min.z}}:null}(r);if(!e)return{groundedShadow:null,revealedShadow:null,stand:null,standShape:null};let t=function(e,t){let r={x:e.max.x-e.min.x,y:e.max.y-e.min.y,z:e.max.z-e.min.z},n={x:(e.min.x+e.max.x)/2,y:(e.min.y+e.max.y)/2,z:(e.min.z+e.max.z)/2};if("wall"===t)return{shadow:null,stand:{border:.016,color:tm,depth:Math.max(.1,r.y+.1),doubleSide:!0,inset:.02,opacity:.92,position:{x:n.x,y:n.y,z:e.min.z-.006},radius:.06,renderOrder:15,rotationX:Math.PI/2,width:Math.max(.1,r.x+.1)}};let a="ceiling"===t;return{shadow:{alwaysVisible:!a,color:"#000000",depth:Math.max(.12,1.08*r.z),opacity:a?.24:.28,position:{x:n.x,y:e.min.y+.002,z:n.z},renderOrder:12,softness:.7,width:Math.max(.12,1.08*r.x)},stand:{border:.02,color:tm,depth:Math.max(.14,r.z+.12),doubleSide:a,inset:.03,opacity:.94,position:{x:n.x,y:a?e.max.y-.006:e.min.y+.006,z:n.z},radius:.09,renderOrder:14,rotationX:0,width:Math.max(.14,r.x+.12)}}}(e,a),n=tu(t.stand);n.position.set(t.stand.position.x,t.stand.position.y,t.stand.position.z),n.rotation.x=t.stand.rotationX,n.visible=!1,td(n,tp);let i={depth:t.stand.depth,radius:t.stand.radius,width:t.stand.width};if(!t.shadow)return{groundedShadow:null,revealedShadow:null,stand:n,standShape:i};let o=function(e){let{color:t,depth:r,opacity:n,renderOrder:a,softness:i,width:o}=e,s=new eO.bdM(o,r).rotateX(-Math.PI/2),l=new eO.BKk({depthWrite:!1,fragmentShader:tl,side:2,transparent:!0,uniforms:{uColor:{value:new eO.Q1f(t)},uOpacity:{value:n},uSoftness:{value:i}},vertexShader:ts}),c=new eO.eaF(s,l);return c.renderOrder=a,c.raycast=tc,c}(t.shadow);return o.position.set(t.shadow.position.x,t.shadow.position.y,t.shadow.position.z),{groundedShadow:t.shadow.alwaysVisible?o:null,revealedShadow:t.shadow.alwaysVisible?null:o,stand:n,standShape:i}},[r,a]);(0,o.useEffect)(()=>()=>{th(l),th(i),th(s)},[i,s,l]);let u=(0,o.useRef)(null),d=(0,o.useRef)({active:!1,elapsedMs:170,fromScale:1e-4,fromShape:tp});return((0,o.useEffect)(()=>{let e=u.current;e&&(e.scale.setScalar(1e-4),e.visible=!1)},[]),(0,o.useEffect)(()=>{var e;let r,n=d.current;n.active=t,n.elapsedMs=0,n.fromScale=(null==(e=u.current)?void 0:e.scale.x)??n.fromScale,n.fromShape=l?{depth:(r=l.material).uniforms.uDepth.value,radius:r.uniforms.uRadius.value,width:r.uniforms.uWidth.value}:n.fromShape},[t,l]),(0,eF.D)((e,t)=>{let r=d.current;if(r.elapsedMs>=170)return;r.elapsedMs+=1e3*t;let n=r.active||r.elapsedMs<170,a=u.current;if(a&&(a.scale.setScalar(tg({elapsedMs:r.elapsedMs,from:r.fromScale,to:r.active?1:1e-4})),a.visible=n),!l||!c)return;let i=r.active?c:tp,o=r.fromShape;td(l,{depth:tg({elapsedMs:r.elapsedMs,from:o.depth,to:i.depth}),radius:tg({elapsedMs:r.elapsedMs,from:o.radius,to:i.radius}),width:tg({elapsedMs:r.elapsedMs,from:o.width,to:i.width})}),l.visible=n}),l)?(0,eF.o)((0,n.jsxs)(n.Fragment,{children:[i?(0,n.jsx)("primitive",{object:i}):null,(0,n.jsx)("primitive",{object:l}),(0,n.jsx)("group",{ref:u,children:s?(0,n.jsx)("primitive",{object:s}):null})]}),r):null}function tx(e){let{doubleSided:t=!1,flat:r=!1,ref:a}=e,i=(0,o.useMemo)(()=>tu(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return{border:.02,color:tm,depth:tp.depth,doubleSide:e,inset:.03,opacity:.94,radius:tp.radius,renderOrder:14,width:tp.width}}(t)),[t]);return(0,o.useEffect)(()=>()=>th(i),[i]),(0,n.jsx)("group",{ref:a,"rotation-x":r?-Math.PI/2:0,visible:!1,children:(0,n.jsx)("primitive",{object:i,"rotation-x":Math.PI/2})})}var tb=r(2585);function tw(e){for(let t of Object.values(e))t instanceof eO.gPd&&t.dispose();e.dispose()}function ty(e){e.traverse(e=>{var t;null==(t=e.geometry)||t.dispose(),Array.isArray(e.material)?e.material.forEach(tw):e.material&&tw(e.material)})}class tj{register(e,t){this.scenes.get(e)!==t&&(this.scenes.set(e,t),this.notify())}has(e){return this.scenes.has(e)}get size(){return this.scenes.size}release(){this.scenes.size&&(this.scenes.forEach(ty),e2.p.clear(Array.from(this.scenes.keys())),this.scenes.clear(),this.notify())}notify(){this.listeners.forEach(e=>e())}constructor(){(0,tb._)(this,"scenes",new Map),(0,tb._)(this,"listeners",new Set),(0,tb._)(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}))}}let tC=(0,o.createContext)(null);function tR(e){let{cache:t,children:r}=e,[a]=(0,o.useState)(()=>new tj),i=t??a;return(0,o.useEffect)(()=>()=>i.release(),[i]),(0,n.jsx)(tC,{value:i,children:r})}function tz(e,t){let r=(0,o.use)(tC);(0,o.useLayoutEffect)(()=>{null==r||r.register(e,t)},[r,t,e])}function tk(e,t){let r=(0,o.useCallback)(t=>e?e.subscribe(t):()=>void 0,[e]),n=(0,o.useCallback)(()=>!!(t&&(null==e?void 0:e.has(t))),[e,t]);return(0,o.useSyncExternalStore)(r,n,n)}function tN(e){return tk((0,o.use)(tC),e)}function tS(e,t,r){return r<=0?0:(t-e)/r*Math.PI}function t_(e,t){return Math.min(2,Math.max(.6,e*t))}class tL{get count(){return this.pointers.size}get moved(){return this.hasMoved}get startX(){return this.startXValue}get startY(){return this.startYValue}down(e){this.pointers.set(e.pointerId,e),1===this.pointers.size&&(this.hasMoved=!1,this.startXValue=e.clientX,this.startYValue=e.clientY)}has(e){return this.pointers.has(e)}move(e){this.pointers.set(e.pointerId,e),this.hasMoved||(this.hasMoved=Math.hypot(e.clientX-this.startXValue,e.clientY-this.startYValue)>=4)}up(e){this.pointers.delete(e.pointerId)}beginPinch(){let e=this.measureSpan();return null!==e&&(this.pinchStart=e,!0)}pinchRatio(){let e=this.measureSpan();return null===e?1:e/Math.max(1,this.pinchStart)}reset(){this.pointers.clear(),this.hasMoved=!1}measureSpan(){if(this.pointers.size<2)return null;let e=this.pointers.values(),t=e.next().value,r=e.next().value;return t&&r?Math.hypot(r.clientX-t.clientX,r.clientY-t.clientY):null}constructor(){(0,tb._)(this,"pointers",new Map),(0,tb._)(this,"hasMoved",!1),(0,tb._)(this,"pinchStart",0),(0,tb._)(this,"startXValue",0),(0,tb._)(this,"startYValue",0)}}class tM{measure(){let e=this.element.getBoundingClientRect();this.height=e.height,this.left=e.left,this.top=e.top,this.width=e.width}setRay(e){this.point.set((e.clientX-this.left)/this.width*2-1,-(e.clientY-this.top)/this.height*2+1),this.raycaster.setFromCamera(this.point,this.camera)}get ray(){return this.raycaster.ray}intersect(e){return e?this.raycaster.intersectObject(e,!0)[0]??null:null}constructor(e,t){(0,tb._)(this,"element",void 0),(0,tb._)(this,"camera",void 0),(0,tb._)(this,"raycaster",void 0),(0,tb._)(this,"point",void 0),(0,tb._)(this,"height",void 0),(0,tb._)(this,"left",void 0),(0,tb._)(this,"top",void 0),(0,tb._)(this,"width",void 0),this.element=e,this.camera=t,this.raycaster=new eO.tBo,this.point=new eO.I9Y,this.height=0,this.left=0,this.top=0,this.width=0,this.measure()}}function tP(e,t){let r=new tM(e,t),n=()=>r.measure();return window.addEventListener("resize",n),window.addEventListener("orientationchange",n),{dispose:()=>{window.removeEventListener("resize",n),window.removeEventListener("orientationchange",n)},raycaster:r}}var tE=r(7734);function tI(e){let{interactionEnabledRef:t,onCentreHit:r,relocalize:n,sceneObjects:a,sessionHasTrackingRef:i,sessionRef:s,setTrackingStatus:l,updateObject:c}=e,u=(0,o.useRef)("tracking");(0,eF.D)((e,o,d)=>{let h=s.current,m=performance.now();if(h&&d){let e=(0,tE.Y)(d);r(h.getCenterHit(e),m);let o=function(e,t,r,n){let a=!0,i="tracking";for(let l of e){var o,s;let e=l.runtime;if(e.anchor){let i=e.anchor.getPose(t);a&&(a=null!==i),e.tracking=eA(e.tracking,{hasPose:null!==i,now:r}),i&&n(l,i)}o=i,s=e.tracking.status,i="lost"===o||"lost"===s?"lost":"relocalizing"===o||"relocalizing"===s?"relocalizing":"tracking"}return{allAnchorPosesAvailable:a,status:i}}(a,e,m,n);t.current=i.current&&o.allAnchorPosesAvailable,u.current!==o.status&&(u.current=o.status,l(o.status))}for(let e of a)i.current&&null===e.runtime.tracking.missingSince&&c(e,m)})}function tO(e){var t;let{currentHitRef:r,manager:a,phaseRef:i,placingObjectId:s,scaleEnabled:l,sceneObjects:c,selectedObjectId:u,sessionHasTrackingRef:d,sessionRef:h,setTrackingStatus:m,updatePhase:p}=e,{camera:f}=(0,eF.C)(),g=(0,o.useRef)(null),v=(0,o.useRef)(!0),x=tN((null==(t=c.find(e=>e.id===s))?void 0:t.resource.glbUrl)??null);return!function(e){let{interactionEnabledRef:t,manager:r,scaleEnabled:n}=e,{camera:a,gl:i}=(0,eF.C)();(0,o.useEffect)(()=>{let e=i.domElement,{dispose:o,raycaster:s}=tP(e,a),l=new eO.Zcv,c=new eO.Pq0,u=new eO.Pq0,d=new eO.Pq0,h=new eO.Pq0,m=new tL,p=null,f=null,g=null,v=1,x=e=>e?r.getSnapshot().objects.find(t=>t.id===e):void 0,b=a=>{if(t.current&&r.isGestureEnabled()){if(a.preventDefault(),e.setPointerCapture(a.pointerId),s.measure(),m.down(a),1===m.count){let e=r.beginGesture((e=>{s.setRay(e);let t=null;for(let e of r.getSnapshot().objects){if(!e.runtime.anchor)continue;let r=s.intersect(e.runtime.hitTarget);r&&(!t||r.distance<t.distance)&&(t={distance:r.distance,id:e.id})}return(null==t?void 0:t.id)??null})(a));e&&((e,t)=>{let r=x(t.objectId);if(r&&(p=t,f=t.mode,g=tt(r.runtime.targetTransform),r.runtime.lastInteractionRef.current=performance.now(),"move"===f)){var n;let t={normal:{...(n=g).worldRoot.normal},point:{...n.worldRoot.position}};c.set(t.normal.x,t.normal.y,t.normal.z),u.set(t.point.x,t.point.y,t.point.z),l.setFromNormalAndCoplanarPoint(c,u),s.setRay(e),s.ray.intersectPlane(l,d)?h.copy(d):f=null}})(a,e)}else if(2===m.count&&p&&n){let e=x(p.objectId);e&&m.beginPinch()&&(f="pinch",v=e.runtime.targetTransform.userRoot.scale)}}},w=n=>{var a,i,o;if(!t.current||!r.isGestureEnabled()||!m.has(n.pointerId)||!p||!g)return;m.move(n);let c=x(p.objectId);c&&((c.runtime.lastInteractionRef.current=performance.now(),"pinch"===f&&2===m.count)?c.runtime.targetTransform.userRoot.scale=t_(v,m.pinchRatio()):1===m.count&&m.moved&&"rotate"===f?c.runtime.targetTransform=(a=g,i=tS(m.startX,n.clientX,e.clientWidth),{...a,userRoot:{...a.userRoot,yaw:a.userRoot.yaw+i}}):1===m.count&&m.moved&&"move"===f&&(s.setRay(n),s.ray.intersectPlane(l,d)&&(c.runtime.targetTransform={...o=g,worldRoot:{...o.worldRoot,position:{x:o.worldRoot.position.x+d.x-h.x,y:o.worldRoot.position.y+d.y-h.y,z:o.worldRoot.position.z+d.z-h.z}}})))},y=e=>{m.up(e),m.count>0||(r.endGesture({moved:m.moved}),p=null,f=null,g=null,m.reset())};return e.addEventListener("pointerdown",b),e.addEventListener("pointermove",w),e.addEventListener("pointerup",y),e.addEventListener("pointercancel",y),()=>{e.removeEventListener("pointerdown",b),e.removeEventListener("pointermove",w),e.removeEventListener("pointerup",y),e.removeEventListener("pointercancel",y),o()}},[a,i,t,r,n])}({interactionEnabledRef:v,manager:a,scaleEnabled:l}),tI({interactionEnabledRef:v,onCentreHit:(e,t)=>{let n=c.find(e=>e.id===s);if(r.current=n?e:null,g.current&&(g.current.visible=!!(n&&e)&&!x,e&&(g.current.position.set(e.pose.position.x,e.pose.position.y,e.pose.position.z),Math.abs(e.normal.y)>=.75?g.current.rotation.set(-Math.PI/2,0,0):g.current.lookAt(f.position))),!e||!n)return;let a=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{height:t.height,maxY:t.height,minY:0},a=(0,e4.Q3)(e.normal);if("wall"===a){let i=e8({...e,kind:"wall"},t,r,n.height);return{surface:a,orientationRoot:{position:{...i.orientationRoot.position}},userRoot:{...i.userRoot},worldRoot:{normal:{...i.worldRoot.normal},position:{...i.worldRoot.position},yaw:i.worldRoot.yaw}}}if("floor"===a){let t=e5({...e,kind:"floor"});return{surface:a,orientationRoot:{position:{x:0,y:-n.minY,z:0}},userRoot:{scale:t.scale,yaw:t.yaw},worldRoot:{normal:{x:0,y:1,z:0},position:t.position,yaw:0}}}return{surface:a,orientationRoot:{position:{x:0,y:-n.maxY,z:0}},userRoot:{scale:1,yaw:0},worldRoot:{normal:{x:0,y:-1,z:0},position:{...e.pose.position},yaw:0}}}(e,n.resource.dimensions,f.position,n.runtime.modelBounds);a.userRoot={...n.runtime.targetTransform.userRoot},n.runtime.targetTransform=a,"searching"===i.current&&(n.runtime.currentTransform=tt(a),n.runtime.lastInteractionRef.current=t,p("preview"))},relocalize:(e,t)=>{var r,n;let a,i,o,s,l,c=e.runtime;c.lastAnchorPose&&(r=c.targetTransform,n=c.lastAnchorPose,o=Math.cos(i=(a=e7({position:r.worldRoot.position,scale:1,yaw:r.worldRoot.yaw},n,t)).yaw-r.worldRoot.yaw),s=Math.sin(i),l=r.worldRoot.normal,c.targetTransform={...r,worldRoot:{...r.worldRoot,normal:{x:o*l.x+s*l.z,y:l.y,z:-s*l.x+o*l.z},position:a.position,yaw:a.yaw}}),c.lastAnchorPose=t},sceneObjects:c,sessionHasTrackingRef:d,sessionRef:h,setTrackingStatus:m,updateObject:e=>{let t=e.runtime;if(!t.root||!t.userRoot||!t.orientationRoot)return;let r=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.22,n=tn(e,t,r),a=ta({position:e.orientationRoot.position,scale:1,yaw:0},{position:t.orientationRoot.position,scale:1,yaw:0},r);return{...n,orientationRoot:{position:a.position}}}(t.currentTransform,t.targetTransform);t.currentTransform=r,t.root.position.set(r.worldRoot.position.x,r.worldRoot.position.y,r.worldRoot.position.z),t.root.rotation.set(0,r.worldRoot.yaw,0),t.userRoot.rotation.set(0,r.userRoot.yaw,0),t.userRoot.scale.setScalar(r.userRoot.scale),t.orientationRoot.position.set(r.orientationRoot.position.x,r.orientationRoot.position.y,r.orientationRoot.position.z)}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tx,{ref:g,doubleSided:!0}),c.map(e=>(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(tT,{decorated:tf({phase:i.current,placing:e.id===s,selected:e.id===u}),object:e,visible:e.id!==s||"searching"!==i.current})},e.id))]})}function tT(e){let{decorated:t,object:r,visible:a}=e;return(0,n.jsx)("group",{ref:e=>{r.runtime.root=e},visible:a,children:(0,n.jsx)("group",{ref:e=>{r.runtime.userRoot=e},children:(0,n.jsx)("group",{ref:e=>{r.runtime.orientationRoot=e},children:(0,n.jsx)("group",{ref:e=>{r.runtime.hitTarget=e},children:(0,n.jsx)(tA,{decorated:t,object:r})})})})})}function tA(e){let{decorated:t,object:r}=e,a=(0,e2.p)(r.resource.glbUrl),i=(0,o.useMemo)(()=>a.scene.clone(!0),[a.scene]);tz(r.resource.glbUrl,a.scene);let s=function(e){let[t,r]=(0,o.useState)(e.runtime.currentTransform.surface);return(0,eF.D)(()=>{let n=e.runtime.currentTransform.surface;n!==t&&r(n)}),t}(r);return(0,o.useLayoutEffect)(()=>{let e=new eO.NRn().setFromObject(i),t=e.getSize(new eO.Pq0);r.runtime.modelBounds={height:t.y>0?t.y:r.resource.dimensions.height,maxY:Number.isFinite(e.max.y)?e.max.y:r.resource.dimensions.height,minY:Number.isFinite(e.min.y)?e.min.y:0}},[r,i]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("primitive",{object:i}),(0,n.jsx)(tv,{active:t,root:i,surface:s})]})}function tH(e){return{...e,position:{...e.position}}}function tB(e){let{currentHitRef:t,heightModeRef:r,manager:a,phaseRef:i,placingObjectId:s,scaleEnabled:l,sceneObjects:c,selectedObjectId:u,sessionHasTrackingRef:d,sessionRef:h,setHeightLabel:m,setTrackingStatus:p,updatePhase:f}=e,g=(0,o.useRef)(null),v=(0,o.useRef)(!0),x=(0,o.useRef)({count:0,firstHit:null}),b=(0,o.useRef)(null);b.current="calibrating"===i.current?s:null;let w=(0,o.useCallback)(e=>{m(eI(e.runtime.targetTransform,eU(e),"calibrating"===i.current))},[i,m]),y=(0,o.useCallback)((e,t)=>{e.runtime.modelHeight!==t&&(e.runtime.modelHeight=t,(e.id===s||e.id===u)&&w(e))},[w,s,u]);return!function(e){let{calibrationObjectIdRef:t,heightModeRef:r,interactionEnabledRef:n,manager:a,onHeightChange:i,scaleEnabled:s}=e,{camera:l,gl:c}=(0,eF.C)();(0,o.useEffect)(()=>{let e=c.domElement,{dispose:o,raycaster:u}=tP(e,l),d=new eO.Zcv(new eO.Pq0(0,1,0)),h=new eO.Pq0,m=new eO.Pq0,p=new tL,f=null,g=null,v=null,x=1,b=e=>e?a.getSnapshot().objects.find(t=>t.id===e):void 0,w=i=>{if(n.current&&a.isGestureEnabled()){if(i.preventDefault(),e.setPointerCapture(i.pointerId),u.measure(),p.down(i),1===p.count)(e=>{let n=t.current,i=r.current?a.getSnapshot().selectedObjectId:n;if(i){let e=b(i);if(!e)return;f={mode:"move",objectId:i},g="height",v=tH(e.runtime.targetTransform);return}let o=(e=>{u.setRay(e);let t=null;for(let e of a.getSnapshot().objects){if(!e.runtime.anchor)continue;let r=u.intersect(e.runtime.hitTarget);r&&(!t||r.distance<t.distance)&&(t={distance:r.distance,floorGizmo:!1,id:e.id});let n=u.intersect(e.runtime.floorGizmo);n&&(!t||n.distance<t.distance)&&(t={distance:n.distance,floorGizmo:!0,id:e.id})}return t})(e),s=a.beginGesture((null==o?void 0:o.id)??null);if(!s)return;let l=b(s.objectId);l&&(f=s,g=s.mode,v=tH(l.runtime.targetTransform),l.runtime.lastInteractionRef.current=performance.now(),"move"===g&&(d.constant=-((null==o?void 0:o.floorGizmo)?v.floorY:v.position.y),u.setRay(e),u.ray.intersectPlane(d,h)?m.copy(h):g=null))})(i);else if(2===p.count&&f&&s&&"height"!==g){let e=b(f.objectId);e&&p.beginPinch()&&(g="pinch",x=e.runtime.targetTransform.scale)}}},y=t=>{if(!a.isGestureEnabled()||!p.has(t.pointerId)||!f||!v)return;p.move(t);let r=b(f.objectId);if(r){if(r.runtime.lastInteractionRef.current=performance.now(),"pinch"===g&&2===p.count)r.runtime.targetTransform.scale=t_(x,p.pinchRatio());else if(1===p.count&&p.moved&&"height"===g)r.runtime.targetTransform=function(e,t,r,n){if(n<=0)return e;let a=eP(e.suspensionHeight+(t-r)/n*2.6);return{...e,position:{...e.position,y:e.floorY+a},suspensionHeight:a}}(v,p.startY,t.clientY,e.clientHeight),i(r);else if(1===p.count&&p.moved&&"rotate"===g)r.runtime.targetTransform.yaw=v.yaw+tS(p.startX,t.clientX,e.clientWidth);else if(1===p.count&&p.moved&&"move"===g){var n;u.setRay(t),u.ray.intersectPlane(d,h)&&(r.runtime.targetTransform={...n=v,position:{x:n.position.x+h.x-m.x,y:n.position.y,z:n.position.z+h.z-m.z}})}}},j=e=>{p.up(e),p.count>0||(!t.current&&f&&a.endGesture({moved:p.moved}),f=null,g=null,v=null,p.reset())};return e.addEventListener("pointerdown",w),e.addEventListener("pointermove",y),e.addEventListener("pointerup",j),e.addEventListener("pointercancel",j),()=>{e.removeEventListener("pointerdown",w),e.removeEventListener("pointermove",y),e.removeEventListener("pointerup",j),e.removeEventListener("pointercancel",j),o()}},[t,l,c,r,n,a,i,s])}({calibrationObjectIdRef:b,heightModeRef:r,interactionEnabledRef:v,manager:a,onHeightChange:w,scaleEnabled:l}),tI({interactionEnabledRef:v,onCentreHit:e=>{let r=(null==e?void 0:e.kind)==="floor"?e:null,n=(null==e?void 0:e.kind)==="ceiling"?e:null,a=function(e,t){if(!t||"floor"!==t.kind)return{stableHit:null,state:{count:0,firstHit:null}};let r=null==e?void 0:e.firstHit,n=null!=r&&.25>=Math.hypot(t.pose.position.x-r.pose.position.x,t.pose.position.y-r.pose.position.y,t.pose.position.z-r.pose.position.z)?{count:((null==e?void 0:e.count)??0)+1,firstHit:r}:{count:1,firstHit:t};return{stableHit:n.count>=8?t:null,state:n}}(x.current,r);if(x.current=a.state,g.current){g.current.visible=function(e){let{hasHit:t,phase:r,placingObjectId:n}=e;return null!==n&&("searching"===r||"floor-ready"===r)&&t}({hasHit:null!==r||null!==n,phase:i.current,placingObjectId:s});let e=r??n;e&&g.current.position.set(e.pose.position.x,e.pose.position.y+.002,e.pose.position.z)}let o=c.find(e=>e.id===s);if(n&&o&&"searching"===i.current)t.current=n,o.runtime.targetTransform=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("ceiling"!==e.kind)throw Error("Direct ceiling placement requires a ceiling surface hit.");let r=eP(e.pose.position.y-t);return{floorY:t,position:{x:e.pose.position.x,y:t+r,z:e.pose.position.z},scale:1,suspensionHeight:r,yaw:0}}(n),o.runtime.currentTransform={...o.runtime.targetTransform,position:{...o.runtime.targetTransform.position}},f("preview");else if(a.stableHit&&o&&"searching"===i.current){t.current=a.stableHit;let e=o.runtime.targetTransform.suspensionHeight;o.runtime.targetTransform=eE(a.stableHit,e),o.runtime.currentTransform={...o.runtime.targetTransform,position:{...o.runtime.targetTransform.position}},m(null),f("floor-ready")}else"floor-ready"===i.current&&(a.stableHit?t.current=a.stableHit:(t.current=null,f("searching")))},relocalize:(e,t)=>{let r=e.runtime;if(r.lastAnchorPose){let e=t.position.y-r.lastAnchorPose.position.y,n=e7(r.targetTransform,r.lastAnchorPose,t);r.targetTransform={...r.targetTransform,...n,floorY:r.targetTransform.floorY+e}}r.lastAnchorPose=t},sceneObjects:c,sessionHasTrackingRef:d,sessionRef:h,setTrackingStatus:p,updateObject:e=>{var t;if(!e.runtime.root)return;let r=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.22,n=ta(e,t,r);return{...t,position:n.position,scale:n.scale,suspensionHeight:n.position.y-t.floorY,yaw:n.yaw}}(e.runtime.currentTransform,e.runtime.targetTransform);e.runtime.currentTransform=r,e.runtime.root.position.set(r.position.x,r.position.y,r.position.z),e.runtime.root.rotation.set(0,r.yaw,0),null==(t=e.runtime.modelRoot)||t.scale.setScalar(r.scale)}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tx,{ref:g,flat:!0}),c.map(e=>(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(tU,{decorated:tf({phase:i.current,placing:e.id===s,selected:e.id===u}),object:e,onMeasured:y,visible:function(e){let{isPlacing:t,phase:r}=e;return!t||"searching"!==r&&"floor-ready"!==r}({isPlacing:e.id===s,phase:i.current})})},e.id))]})}function tU(e){let{decorated:t,object:r,onMeasured:a,visible:i}=e,o=r.runtime.currentTransform;return(0,n.jsx)("group",{ref:e=>{r.runtime.root=e},children:(0,n.jsx)("group",{visible:i,children:(0,n.jsx)("group",{ref:e=>{r.runtime.hitTarget=e,r.runtime.modelRoot=e},scale:o.scale,children:(0,n.jsx)(tF,{decorated:t,glbUrl:r.resource.glbUrl,onMeasured:e=>a(r,e)})})})})}function tF(e){let{decorated:t,glbUrl:r,onMeasured:a}=e,i=(0,e2.p)(r),s=(0,o.useMemo)(()=>i.scene.clone(!0),[i.scene]);tz(r,i.scene);let l=(0,o.useRef)(null),c=(0,o.useRef)(a);return c.current=a,(0,o.useLayoutEffect)(()=>{let e,t,r=l.current;if(!r)return;let n=(r.position.y=0,r.updateMatrixWorld(!0),t=Number.isFinite((e=new eO.NRn().setFromObject(s)).max.y)?e.max.y:0,r.position.y=0===t?0:-t,e.isEmpty()?0:e.getSize(new eO.Pq0).y);n>0&&c.current(n)},[s]),(0,n.jsxs)("group",{ref:l,children:[(0,n.jsx)("primitive",{object:s}),(0,n.jsx)(tv,{active:t,root:s,surface:"ceiling"})]})}function tq(e){var t;let{currentHitRef:r,manager:a,phaseRef:i,placingObjectId:s,scaleEnabled:l,sceneObjects:c,selectedObjectId:u,sessionHasTrackingRef:d,sessionRef:h,setTrackingStatus:m,updatePhase:p}=e,f=(0,o.useRef)(null),g=(0,o.useRef)(0),v=(0,o.useRef)(!0),x=tN((null==(t=c.find(e=>e.id===s))?void 0:t.resource.glbUrl)??null);return!function(e){let{interactionEnabledRef:t,manager:r,scaleEnabled:n}=e,{camera:a,gl:i}=(0,eF.C)();(0,o.useEffect)(()=>{let e=i.domElement,{dispose:o,raycaster:s}=tP(e,a),l=new eO.Zcv(new eO.Pq0(0,1,0)),c=new eO.Pq0,u=new tL,d=new eO.Pq0,h=new eO.Pq0,m=null,p=0,f=1,g=null,v=e=>e?r.getSnapshot().objects.find(t=>t.id===e):void 0,x=a=>{if(t.current&&r.isGestureEnabled()){if(a.preventDefault(),e.setPointerCapture(a.pointerId),s.measure(),u.down(a),1===u.count){let e,t=r.beginGesture((e=>{s.setRay(e);let t=null;for(let e of r.getSnapshot().objects){if(!e.runtime.anchor)continue;let r=s.intersect(e.runtime.hitTarget);r&&(!t||r.distance<t.distance)&&(t={distance:r.distance,id:e.id})}return(null==t?void 0:t.id)??null})(a));t&&(e=v(t.objectId))&&(m=t,g=t.mode,p=e.runtime.targetTransform.yaw,e.runtime.lastInteractionRef.current=performance.now(),"move"===g&&(d.set(e.runtime.targetTransform.position.x,e.runtime.targetTransform.position.y,e.runtime.targetTransform.position.z),l.constant=-d.y,s.setRay(a),s.ray.intersectPlane(l,c)?h.copy(c):g=null));return}if(2===u.count&&m&&n){let e=v(m.objectId);e&&u.beginPinch()&&(g="pinch",f=e.runtime.targetTransform.scale)}}},b=n=>{if(!t.current||!r.isGestureEnabled()||!u.has(n.pointerId)||!m)return;u.move(n);let a=v(m.objectId);if(a){if(a.runtime.lastInteractionRef.current=performance.now(),"pinch"===g&&2===u.count){a.runtime.targetTransform.scale=t_(f,u.pinchRatio());return}if(1===u.count&&u.moved)if("rotate"===g)a.runtime.targetTransform.yaw=p+tS(u.startX,n.clientX,e.clientWidth);else"move"===g&&(s.setRay(n),s.ray.intersectPlane(l,c)&&(a.runtime.targetTransform.position={x:d.x+c.x-h.x,y:d.y,z:d.z+c.z-h.z}))}},w=e=>{u.up(e),u.count>0||(r.endGesture({moved:u.moved}),m=null,g=null,u.reset())};return e.addEventListener("pointerdown",x),e.addEventListener("pointermove",b),e.addEventListener("pointerup",w),e.addEventListener("pointercancel",w),()=>{e.removeEventListener("pointerdown",x),e.removeEventListener("pointermove",b),e.removeEventListener("pointerup",w),e.removeEventListener("pointercancel",w),o()}},[a,i,t,r,n])}({interactionEnabledRef:v,manager:a,scaleEnabled:l}),tI({interactionEnabledRef:v,onCentreHit:(e,t)=>{let n=f.current,a=(null==e?void 0:e.kind)==="floor"?e:null;a?(r.current=a,g.current=t):t-g.current>250&&(r.current=null),n&&(n.visible=!!s&&function(e){let{hasFloorHit:t,lastFloorHitAt:r,modelInRoom:n,now:a,phase:i}=e;return"preview"===i&&!n&&(t||a-r<=250)}({hasFloorHit:null!==a,lastFloorHitAt:g.current,modelInRoom:x,now:t,phase:i.current}));let o=c.find(e=>e.id===s);a&&o&&(null==n||n.position.set(a.pose.position.x,a.pose.position.y+.002,a.pose.position.z),o.runtime.targetTransform=e5(a,o.runtime.targetTransform),"searching"===i.current&&(o.runtime.lastInteractionRef.current=t,p("preview")))},relocalize:(e,t)=>{let r=e.runtime;r.lastAnchorPose&&(r.targetTransform=e7(r.targetTransform,r.lastAnchorPose,t)),r.lastAnchorPose=t},sceneObjects:c,sessionHasTrackingRef:d,sessionRef:h,setTrackingStatus:m,updateObject:e=>{let t=e.runtime;if(!t.root)return;let r=ta(t.currentTransform,t.targetTransform);t.currentTransform=r,t.root.position.set(r.position.x,r.position.y,r.position.z),t.root.rotation.set(0,r.yaw,0),t.root.scale.setScalar(r.scale)}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tx,{ref:f,flat:!0}),c.map(e=>(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(tY,{decorated:tf({phase:i.current,placing:e.id===s,selected:e.id===u}),object:e,visible:e.id!==s||"searching"!==i.current})},e.id))]})}function tY(e){let{decorated:t,object:r,visible:a}=e;return(0,n.jsx)("group",{ref:e=>{r.runtime.root=e},visible:a,children:(0,n.jsx)("group",{ref:e=>{r.runtime.hitTarget=e},children:(0,n.jsx)(t$,{decorated:t,glbUrl:r.resource.glbUrl})})})}function t$(e){let{decorated:t,glbUrl:r}=e,a=(0,e2.p)(r),i=(0,o.useMemo)(()=>a.scene.clone(!0),[a.scene]);return tz(r,a.scene),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("primitive",{object:i}),(0,n.jsx)(tv,{active:t,root:i,surface:"floor"})]})}function tD(e){return"floor"===e.mechanic}function tV(e){return"wall"===e.mechanic}function tZ(e){return"ceiling"===e.mechanic}function tW(e){return"all"===e.mechanic}function tG(e,t,r){for(let n of(t.current=r,e))tV(n)&&(n.runtime.gestureEnabledRef.current=null===r||n.id===r)}function tX(e){let{sessionHasTrackingRef:t,sessionRef:r,setTrackingStatus:n}=e,a=(0,o.useRef)(eT());return(0,eF.D)((e,i,o)=>{let s=r.current;if(!s||!o){t.current=!1;return}let l=s.isTracking((0,tE.Y)(o)),c=a.current.status;t.current=l,a.current=eA(a.current,{hasPose:l,now:performance.now()}),a.current.status!==c&&n(a.current.status)}),null}function tK(e){let{gestureOwnerIdRef:t,manager:r,placingObjectId:n}=e,{camera:a,gl:i}=(0,eF.C)();return(0,o.useEffect)(()=>{let e=i.domElement,{dispose:o,raycaster:s}=tP(e,a),l=new Set,c=e=>{let a=l.size>0;if(l.add(e.pointerId),n||a)return;s.measure(),s.setRay(e);let i=null;for(let e of r.getSnapshot().objects){if(!("wall"===e.mechanic?null!==e.runtime.anchorRef.current:null!==e.runtime.anchor))continue;let t=s.intersect("wall"===e.mechanic?e.runtime.hitTargetRef.current:e.runtime.hitTarget);t&&(!i||t.distance<i.distance)&&(i={distance:t.distance,object:e})}i&&(r.selectObject(i.object.id),tG(r.getSnapshot().objects,t,i.object.id))},u=e=>{l.delete(e.pointerId)};return e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerup",u,!0),e.addEventListener("pointercancel",u,!0),()=>{e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerup",u,!0),e.removeEventListener("pointercancel",u,!0),o()}},[a,t,i,r,n]),null}let tJ={position:{x:0,y:0,z:-1},scale:1,yaw:0};function tQ(){return{...tJ,position:{...tJ.position}}}function t0(e,t){switch(e.mechanic){case"floor":let r;return{dispose:()=>{var e;return null==(e=r.anchor)?void 0:e.delete()},id:t,mechanic:"floor",resource:e,runtime:r={anchor:null,currentTransform:tQ(),hitTarget:null,lastAnchorPose:null,lastInteractionRef:{current:0},root:null,targetTransform:tQ(),tracking:eT()}};case"wall":let n;return{dispose:()=>{var e;return null==(e=n.current)?void 0:e.delete()},id:t,mechanic:"wall",resource:e,runtime:{anchorRef:n={current:null},confirmPlacementRef:{current:null},gestureEnabledRef:{current:!1},hitTargetRef:{current:null},phaseRef:{current:"searching"},tracking:eT()}};case"ceiling":let a;return{dispose:()=>{var e;return null==(e=a.anchor)?void 0:e.delete()},id:t,mechanic:"ceiling",resource:e,runtime:a={anchor:null,currentTransform:eB(),floorGizmo:null,hitTarget:null,lastAnchorPose:null,lastInteractionRef:{current:0},modelHeight:null,modelRoot:null,root:null,targetTransform:eB(),tracking:eT()}};case"all":let i,o;return{dispose:()=>{var e;return null==(e=o.anchor)?void 0:e.delete()},id:t,mechanic:"all",resource:e,runtime:o={anchor:null,currentTransform:tt(i={surface:"floor",orientationRoot:{position:{x:0,y:0,z:0}},userRoot:{scale:1,yaw:0},worldRoot:{normal:{x:0,y:1,z:0},position:{x:0,y:0,z:-1},yaw:0}}),hitTarget:null,lastAnchorPose:null,lastInteractionRef:{current:0},modelBounds:{height:e.dimensions.height,maxY:e.dimensions.height,minY:0},orientationRoot:null,root:null,targetTransform:tt(i),tracking:eT(),userRoot:null}}}}let t1=45*Math.PI/180,t2=8*Math.PI/180,t4=19*Math.PI/180;function t3(e,t,r){let n=Math.cos(t1);if(!r||e6(t,r.normal)>=n-4*Number.EPSILON)return{candidateNormal:null,candidatePoint:null,count:0,shouldSwitch:!1};let a=(null==e?void 0:e.candidateNormal)&&e.candidatePoint&&Math.acos(e6(e.candidateNormal,r.normal))<t4&&.5>=Math.hypot(e.candidatePoint.x-r.point.x,e.candidatePoint.y-r.point.y,e.candidatePoint.z-r.point.z),i=a?e.count+1:1;return{candidateNormal:e9(r.normal),candidatePoint:a?e.candidatePoint:{...r.point},count:i,shouldSwitch:i>=8}}function t7(e,t,r,n){let a=Math.abs(Math.atan2(Math.sin(e-t),Math.cos(e-t))),i=r<=.4&&a<=(n?t4:t2);return{snapped:i,yaw:i?t:e}}function t5(e,t){let r=null;return t.forEach((t,n)=>{let a=e9(t.normal),i=Math.abs((e.x-t.point.x)*a.x+(e.z-t.point.z)*a.z);(!r||i<r.distance)&&(r={distance:i,index:n,wall:t})}),r}function t9(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=r?t5(e,[r]):t5(e,t),i=r?.35:.12;if(!a||a.distance>i)return{attachedWall:null,position:e,wall:null};let o=e9(a.wall.normal),s=(e.x-a.wall.point.x)*o.x+(e.z-a.wall.point.z)*o.z;return{attachedWall:a.wall,position:{x:e.x-o.x*(s-n),y:e.y,z:e.z-o.z*(s-n)},wall:a.wall}}function t6(e,t){if(e.some(e=>{let r=Math.abs(e6(e.normal,t.normal)),n=e9(e.normal),a=Math.abs((t.point.x-e.point.x)*n.x+(t.point.z-e.point.z)*n.z);return r>=Math.cos(15*Math.PI/180)&&a<=.12}))return e;let r=[...e,t];return r.length>12?r.slice(r.length-12):r}function t8(e){return{surface:e.surface,orientationRoot:{pitch:e.orientationRoot.pitch,position:{...e.orientationRoot.position}},userRoot:{...e.userRoot},worldRoot:{normal:{...e.worldRoot.normal},position:{...e.worldRoot.position},yaw:e.worldRoot.yaw}}}function re(e,t){return{normal:e.worldRoot.normal,point:{x:e.worldRoot.position.x-e.worldRoot.normal.x*t,y:e.worldRoot.position.y,z:e.worldRoot.position.z-e.worldRoot.normal.z*t},yaw:e.worldRoot.yaw}}function rt(e){let{anchorRef:t,confirmPlacementRef:r,decorated:a,dimensions:i,gestureEnabledRef:s,glbUrl:l,phaseRef:c,resourceHitTargetRef:u,scaleEnabled:d,sessionHasTrackingRef:h,sessionRef:m,setPlacementPending:p,setPlacementError:f,setTrackingStatus:g,updateAnchorTracking:v,updatePhase:x}=e,{camera:b}=(0,eF.C)(),w=(0,e2.p)(l),y=(0,o.useMemo)(()=>w.scene.clone(!0),[w.scene]);tz(l,w.scene);let j=(0,o.useMemo)(()=>{y.updateMatrixWorld(!0);let e=new eO.NRn().setFromObject(y);return e.isEmpty()?{height:i.height,minY:0,minZ:0}:{height:e.getSize(new eO.Pq0).y,minY:e.min.y,minZ:e.min.z}},[i.height,y]),C=te(j),R=(0,o.useRef)(null),z=(0,o.useRef)(null),k=(0,o.useRef)(null),N=(0,o.useRef)(null),S=u??N,_=(0,o.useRef)(null),L=(0,o.useMemo)(()=>({surface:"wall",orientationRoot:{pitch:0,position:{x:0,y:-i.height/2,z:0}},userRoot:{scale:1,yaw:0},worldRoot:{normal:{x:0,y:0,z:1},position:{x:0,y:1.45,z:-1.25},yaw:0}}),[i]),M=(0,o.useRef)(t8(L)),P=(0,o.useRef)(t8(L)),E=(0,o.useRef)({count:0,hit:null}),I=(0,o.useRef)(null),O=(0,o.useRef)(!1),T=(0,o.useRef)([]),A=(0,o.useRef)({candidateNormal:null,candidatePoint:null,count:0,shouldSwitch:!1}),H=(0,o.useRef)(!1),B=(0,o.useRef)(null),U=(0,o.useRef)(null),F=(0,o.useRef)(0),q=(0,o.useRef)(!1),Y=(0,o.useRef)("tracking"),$=(0,o.useCallback)((e,r,n,a,i)=>{var o;null==(o=t.current)||o.delete(),t.current=r,U.current=new eO.Pq0(e.pose.position.x,e.pose.position.y,e.pose.position.z),P.current=n,i&&(M.current=t8(n)),"wall"===n.surface&&(T.current=t6(T.current,re(n,te(j,n.userRoot.scale)))),F.current=performance.now(),f(!1),x(a)},[t,j,f,x]);r.current=(0,o.useCallback)(()=>{let e=I.current,t=m.current;if(!e||!t||O.current||"preview"!==c.current)return;O.current=!0,null==p||p(!0);let r=t8(P.current);t.createAnchor(e).then(t=>$(e,t,r,"placed",!0)).catch(()=>f(!0)).finally(()=>{O.current=!1,null==p||p(!1)})},[$,c,m,f,p]);let D=(0,o.useCallback)(e=>{let t=m.current;t&&!O.current&&(O.current=!0,t.createAnchor(e).then(t=>{var r;let n=e8(e,i,b.position,j.height,te(j,P.current.userRoot.scale),j.minY),a=null==(r=B.current)?void 0:r.call(B,n);a?$(e,t,a,"selected",!1):t.delete()}).catch(()=>f(!0)).finally(()=>{O.current=!1}))},[b.position,i,$,j,m,f]);return!function(e){let{gestureEnabledRef:t,interactionEnabledRef:r,knownWallsRef:n,lastInteractionRef:a,phaseRef:i,resourceRef:s,scaleEnabled:l,targetTransformRef:c,updatePhase:u,wallOffset:d,wallSlideActiveRef:h,wallSlideSwitchRef:m}=e,{camera:p,gl:f}=(0,eF.C)();(0,o.useEffect)(()=>{let e=f.domElement,{dispose:o,raycaster:g}=tP(e,p),v=new eO.Zcv(new eO.Pq0(0,1,0),0),x=new eO.Zcv,b=new eO.Pq0,w=new eO.Pq0,y=new eO.Pq0,j=new Map,C=null,R=0,z=0,k=0,N=new eO.Pq0,S=new eO.Pq0,_=new eO.Pq0,L=new eO.Pq0,M=null,P=!1,E=0,I=1,O=!1,T=!1,A=()=>d*c.current.userRoot.scale,H=()=>{let e=c.current;if("wall"===e.surface)return{distance:0,yaw:0};let t=t5(e.worldRoot.position,n.current);return t?{distance:t.distance,yaw:t.wall.yaw-e.worldRoot.yaw}:null},B=()=>{let e=H();return null!==e&&t7(c.current.userRoot.yaw,e.yaw,e.distance,!1).snapped},U=e=>{let t=((e,t)=>!!t&&(g.setRay(e),null!==g.intersect(t)))(e,s.current);if("preview"===i.current){C="rotate",R=e.clientX,z=e.clientY,k=c.current.userRoot.yaw,P=B();return}if("placed"===i.current){t&&u("selected"),C=null;return}if("selected"!==i.current){C=null;return}if(h.current="wall-slide"===(C=function(e){let{surface:t="wall",startsOnResource:r}=e;return r?"floor"===t?"floor-move":"wall-slide":"rotate"}({startsOnResource:t,surface:c.current.surface})),R=e.clientX,z=e.clientY,k=c.current.userRoot.yaw,N.set(c.current.worldRoot.position.x,c.current.worldRoot.position.y,c.current.worldRoot.position.z),"rotate"===C&&(P=B()),"wall-slide"===C){let t;t=c.current,N.set(t.worldRoot.position.x,t.worldRoot.position.y,t.worldRoot.position.z),b.set(t.worldRoot.normal.x,t.worldRoot.normal.y,t.worldRoot.normal.z),x.setFromNormalAndCoplanarPoint(b,N),g.setRay(e),(!g.ray.intersectPlane(x,y)||(S.copy(y),0))&&(C=null,h.current=!1)}else if("floor-move"===C){if(M=t9(N,n.current,null,A()).attachedWall,g.setRay(e),!g.ray.intersectPlane(v,y)){C=null;return}_.copy(y),L.copy(N)}},F=n=>{if(r.current&&(null==t?void 0:t.current)!==!1){if(n.preventDefault(),e.setPointerCapture(n.pointerId),g.measure(),j.set(n.pointerId,n),a.current=performance.now(),1===j.size){T=!1,O="selected"===i.current,U(n);return}if(C=null,h.current=!1,2===j.size&&l&&O){let[e,t]=Array.from(j.values());C="pinch",E=Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY),I=c.current.userRoot.scale}}},q=i=>{if(r.current&&(null==t?void 0:t.current)!==!1&&j.has(i.pointerId)){if(j.set(i.pointerId,i),a.current=performance.now(),T||(T=Math.hypot(i.clientX-R,i.clientY-z)>=4),"pinch"===C&&2===j.size){let[e,t]=Array.from(j.values()),r=Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY),n=c.current,a=n.userRoot.scale,i=t_(I,r/Math.max(1,E));if(n.userRoot.scale=i,"wall"===n.surface){let e=d*(i-a);n.worldRoot.position={x:n.worldRoot.position.x+n.worldRoot.normal.x*e,y:n.worldRoot.position.y,z:n.worldRoot.position.z+n.worldRoot.normal.z*e}}return}if(1===j.size){if("rotate"===C&&T){let t=k+tS(R,i.clientX,e.clientWidth),r=H(),n=r?t7(t,r.yaw,r.distance,P):{snapped:!1,yaw:t};P=n.snapped,c.current.userRoot.yaw=n.yaw}else if("wall-slide"===C){let e,t,r;g.setRay(i),g.ray.intersectPlane(x,y)&&(c.current.worldRoot.position=(e=e9(c.current.worldRoot.normal),r=(t={x:y.x-S.x,y:y.y-S.y,z:y.z-S.z}).x*e.x+t.z*e.z,{x:N.x+t.x-e.x*r,y:function(e){for(let t of[1.45,1.07])if(.03>=Math.abs(e-t))return t;return e}(N.y+t.y),z:N.z+t.z-e.z*r}))}else if("floor-move"===C&&(g.setRay(i),g.ray.intersectPlane(v,y))){let e=t9({x:L.x+y.x-_.x,y:L.y,z:L.z+y.z-_.z},n.current,M,A());M=e.attachedWall,c.current.worldRoot.position=e.position,e.wall&&(c.current.worldRoot.normal={...e.wall.normal},c.current.worldRoot.yaw=e.wall.yaw,c.current.userRoot.yaw=0,P=!0)}}}},Y=e=>{j.delete(e.pointerId),C=null,h.current=!1,1===j.size?U(Array.from(j.values())[0]):0===j.size&&(O=!1)},$=e=>{var t,r;let n,a,i,o;if("wall-slide"!==C)return null;let s=j.values().next().value;if(!s)return null;if(b.set(e.worldRoot.normal.x,e.worldRoot.normal.y,e.worldRoot.normal.z),w.set(e.worldRoot.position.x,e.worldRoot.position.y,e.worldRoot.position.z),x.setFromNormalAndCoplanarPoint(b,w),g.setRay(s),!g.ray.intersectPlane(x,y))return null;let l=(t=c.current,r={offsetFromCurrentCenter:{x:S.x-N.x,y:S.y-N.y,z:S.z-N.z},pointOnNextWall:y},a=Math.cos(n=e.worldRoot.yaw-t.worldRoot.yaw),i=Math.sin(n),o={x:r.offsetFromCurrentCenter.x*a+r.offsetFromCurrentCenter.z*i,y:r.offsetFromCurrentCenter.y,z:-r.offsetFromCurrentCenter.x*i+r.offsetFromCurrentCenter.z*a},e.userRoot={...t.userRoot},e.worldRoot.position={x:r.pointOnNextWall.x-o.x,y:r.pointOnNextWall.y-o.y,z:r.pointOnNextWall.z-o.z},e);return N.set(l.worldRoot.position.x,l.worldRoot.position.y,l.worldRoot.position.z),S.copy(y),b.set(l.worldRoot.normal.x,l.worldRoot.normal.y,l.worldRoot.normal.z),x.setFromNormalAndCoplanarPoint(b,N),l};return m.current=$,e.addEventListener("pointerdown",F),e.addEventListener("pointermove",q),e.addEventListener("pointerup",Y),e.addEventListener("pointercancel",Y),()=>{e.removeEventListener("pointerdown",F),e.removeEventListener("pointermove",q),e.removeEventListener("pointerup",Y),e.removeEventListener("pointercancel",Y),m.current===$&&(m.current=null),o()}},[p,t,f,r,n,a,i,s,l,c,u,d,h,m])}({gestureEnabledRef:s,interactionEnabledRef:q,knownWallsRef:T,lastInteractionRef:F,phaseRef:c,resourceRef:S,scaleEnabled:d,targetTransformRef:P,updatePhase:x,wallOffset:C,wallSlideActiveRef:H,wallSlideSwitchRef:B}),(0,eF.D)((e,r,n)=>{let a,o=performance.now(),s=m.current,l=!0;if(q.current=h.current,s&&n){let e=(0,tE.Y)(n),r=s.getCenterHit(e),a=(0,e4.aq)(r)?r:null,u=(null==r?void 0:r.kind)==="floor"||a?r:null,d=function(e,t){var r,n,a,i;let o;if(!(0,e4.aq)(t))return{stableHit:null,state:{count:0,hit:null}};let s=(null==e||null==(r=e.hit)?void 0:r.kind)==="wall"&&(n=e.hit,o=Math.abs(e6(n.normal,t.normal)),a=n.pose.position,i=t.pose.position,.5>=Math.hypot(a.x-i.x,a.y-i.y,a.z-i.z)&&o>=Math.cos(15*Math.PI/180)),l={count:s?e.count+1:1,hit:s?e.hit:t};return{stableHit:l.count>=8?t:null,state:l}}(E.current,a),h=null;if(E.current=d.state,a&&(h=e8(a,i,b.position,j.height,te(j,P.current.userRoot.scale),j.minY)),d.stableHit){let e=e8(d.stableHit,i,b.position,j.height,C,j.minY);T.current=t6(T.current,re(e,C))}if(H.current?(A.current=t3(A.current,P.current.worldRoot.normal,h&&a?{normal:h.worldRoot.normal,point:a.pose.position}:null),a&&A.current.shouldSwitch&&D(a)):A.current=t3(void 0,P.current.worldRoot.normal,null),_.current&&(_.current.visible="searching"===c.current&&null!==u&&!O.current,u&&(_.current.position.set(u.pose.position.x,u.pose.position.y,u.pose.position.z),"floor"===u.kind?_.current.rotation.set(-Math.PI/2,0,0):_.current.lookAt(b.position))),("searching"===c.current||"preview"===c.current)&&!O.current&&(I.current=u,u)){let e=function(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{height:t.height,minY:0,minZ:-t.depth/2},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;if("wall"===e.kind){let i=e8(e,t,r,n.height,te(n,a),n.minY);return i.userRoot.scale=a,i}if("floor"!==e.kind)throw Error("Wall mechanic placement requires a floor or wall surface hit.");return{surface:"floor",orientationRoot:{pitch:0,position:{x:0,y:-n.minY,z:0}},userRoot:{scale:a,yaw:0},worldRoot:{normal:{x:0,y:1,z:0},position:{...e.pose.position},yaw:0}}}(u,i,b.position,j,P.current.userRoot.scale);e.userRoot={...P.current.userRoot},P.current=e,"searching"===c.current&&(M.current=t8(e),F.current=o,x("preview"))}if(("placed"===c.current||"selected"===c.current)&&t.current){let r=t.current.getPose(e),n=U.current,a=v(null!==r,o);l=null!==r,q.current&&(q.current=l),Y.current!==a&&(Y.current=a,g(a)),r&&n&&(P.current.worldRoot.position={x:P.current.worldRoot.position.x+r.position.x-n.x,y:P.current.worldRoot.position.y+r.position.y-n.y,z:P.current.worldRoot.position.z+r.position.z-n.z},n.set(r.position.x,r.position.y,r.position.z))}}if(!h.current||!l)return;let u=R.current,d=z.current,p=k.current;if(!u||!d||!p)return;u.visible="searching"!==c.current;let f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.22;return tn(e,t,r)}(M.current,P.current);M.current=f,u.position.set(f.worldRoot.position.x,f.worldRoot.position.y,f.worldRoot.position.z),u.rotation.set(0,f.worldRoot.yaw,0);let w=(a=f.userRoot.yaw,"wall"===f.surface?{x:0,y:0,z:a}:{x:0,y:a,z:0});d.rotation.set(w.x,w.y,w.z),d.scale.setScalar(f.userRoot.scale),p.position.set(f.orientationRoot.position.x,f.orientationRoot.position.y,f.orientationRoot.position.z),p.rotation.set(f.orientationRoot.pitch,0,0)}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tx,{ref:_}),(0,n.jsx)("group",{ref:R,visible:!1,children:(0,n.jsx)("group",{ref:z,children:(0,n.jsx)("group",{ref:k,children:(0,n.jsx)("group",{ref:S,children:(0,n.jsx)(rr,{decorated:a,scene:y})})})})})]})}function rr(e){let{decorated:t,scene:r}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("primitive",{object:r}),(0,n.jsx)(tv,{active:t,root:r,surface:"wall"})]})}function rn(e){let{manager:t,object:r,onPlaced:a,phase:i,placing:s,scaleEnabled:l,selected:c,sessionHasTrackingRef:u,sessionRef:d,setPlacementError:h,setPlacementPending:m,setTrackingStatus:p,updateSessionPhase:f}=e,g=s?"preview"===i?"preview":"searching":c?"selected":"placed";(0,o.useLayoutEffect)(()=>{r.runtime.phaseRef.current=g},[r,g]);let v=(0,o.useCallback)(e=>{r.runtime.phaseRef.current=e,"selected"===e&&t.selectObject(r.id),s&&(f(e),"placed"===e&&a())},[t,r,a,s,f]),x=(0,o.useCallback)(e=>p(r.id,e),[r.id,p]),b=(0,o.useCallback)((e,t)=>{var n;return n=r.runtime,n.tracking=eA(n.tracking,{hasPose:e,now:t}),n.tracking.status},[r.runtime]);return(0,n.jsx)(rt,{anchorRef:r.runtime.anchorRef,confirmPlacementRef:r.runtime.confirmPlacementRef,decorated:tf({phase:i,placing:s,selected:c}),dimensions:r.resource.dimensions,gestureEnabledRef:r.runtime.gestureEnabledRef,glbUrl:r.resource.glbUrl,phaseRef:r.runtime.phaseRef,resourceHitTargetRef:r.runtime.hitTargetRef,scaleEnabled:l,sessionHasTrackingRef:u,sessionRef:d,setPlacementError:h,setPlacementPending:m,setTrackingStatus:x,updateAnchorTracking:b,updatePhase:v})}let ra=(0,o.memo)(e=>{let{objects:t,phaseRef:r,placement:a,scaleEnabled:i,sessionHasTrackingRef:s,sessionRef:l,tracking:c}=e,{allManager:u,ceilingManager:d,floorManager:h,gestureOwnerIdRef:m,manager:p,snapshot:f}=t,{allHitRef:g,ceilingHitRef:v,floorHitRef:x,handleWallPlaced:b,heightModeRef:w,phase:y,placingObjectId:j,setHeightLabel:C,setPlacementError:R,setPlacementPending:z,updatePhase:k}=a,N=f.objects.find(e=>e.id===j)??null,S=e=>(null==N?void 0:N.mechanic)===e?N.id:null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tX,{sessionHasTrackingRef:s,sessionRef:l,setTrackingStatus:c.setSession}),(0,n.jsx)(tK,{gestureOwnerIdRef:m,manager:p,placingObjectId:j}),(0,n.jsx)(tq,{currentHitRef:x,manager:h,phaseRef:r,placingObjectId:S("floor"),scaleEnabled:i,sceneObjects:f.objects.filter(tD),selectedObjectId:f.selectedObjectId,sessionHasTrackingRef:s,sessionRef:l,setTrackingStatus:c.setFloor,updatePhase:k}),(0,n.jsx)(tB,{currentHitRef:v,heightModeRef:w,manager:d,phaseRef:r,placingObjectId:S("ceiling"),scaleEnabled:i,sceneObjects:f.objects.filter(tZ),selectedObjectId:f.selectedObjectId,sessionHasTrackingRef:s,sessionRef:l,setHeightLabel:C,setTrackingStatus:c.setCeiling,updatePhase:k}),(0,n.jsx)(tO,{currentHitRef:g,manager:u,phaseRef:r,placingObjectId:S("all"),scaleEnabled:i,sceneObjects:f.objects.filter(tW),selectedObjectId:f.selectedObjectId,sessionHasTrackingRef:s,sessionRef:l,setTrackingStatus:c.setAll,updatePhase:k}),f.objects.filter(tV).map(e=>(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(rn,{manager:p,object:e,phase:y,placing:e.id===j,scaleEnabled:i,selected:e.id===f.selectedObjectId,sessionHasTrackingRef:s,sessionRef:l,setPlacementError:R,setPlacementPending:z,setTrackingStatus:c.setWall,updateSessionPhase:k,onPlaced:b})},e.id))]})});ra.displayName="ArSessionLayers";let ri="var(--v-borders-medium)";function ro(e){let{className:t,variant:r="default",size:a="default",state:i="loading",role:o,"aria-live":s,"aria-label":l,...c}=e;switch(r){case"logo":{let e="sm"===a?4:5;return(0,n.jsxs)("svg",{...c,role:o??"status","aria-live":s??"polite","aria-label":l??("success"===i?"Success":"error"===i?"Error":"Loading"),width:"93",height:"91",viewBox:"0 0 93 91",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-slot":"spinner","data-size":a,"data-state":i,className:(0,B.cn)("spinner-logo shrink-0","sm"===a?"size-9":"size-22",t),children:[(0,n.jsx)("g",{className:"spinner-logo__intro-shell",children:(0,n.jsx)("path",{d:"M15.7495 62.7798L46.4936 45.0297M46.4936 45.0297L77.2661 62.5451M46.4936 45.0297L46.7111 9.62225M49.9213 79.4237L74.5719 65.1917C75.6436 64.5705 76.5344 63.6811 77.1541 62.6137C77.7738 61.5462 78.1003 60.3385 78.1007 59.1129L78.1729 30.7811C78.1734 29.5494 77.851 28.3427 77.2373 27.2798C76.6236 26.2169 75.7398 25.3343 74.6729 24.7189L50.1007 10.6155C47.926 9.3694 45.2455 9.37719 43.0689 10.6339L18.4183 24.8659C16.2385 26.1244 14.8946 28.4401 14.8895 30.9447L14.8173 59.2766C14.8168 60.5082 15.1392 61.7149 15.7529 62.7778C16.3666 63.8408 17.2504 64.7233 18.3173 65.3387L42.8895 79.4421C45.0642 80.6882 47.7447 80.6805 49.9213 79.4237Z",className:"spinner-logo__outline spinner-logo__outline--intro",vectorEffect:"sm"===a?void 0:"non-scaling-stroke"})}),(0,n.jsx)("circle",{className:"spinner-logo__intro-orb",cx:"46.27",cy:"45.8",r:"11.18",fill:"white",stroke:ri,strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("circle",{className:"spinner-logo__result-ring",cx:"46.5",cy:"45.5",r:"33.46",fill:"white",stroke:ri,strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("g",{transform:"translate(27.786 31.4489)",children:(0,n.jsx)("g",{className:"spinner-logo__result-glyph spinner-logo__result-glyph--success",children:(0,n.jsx)("path",{d:"M13.6758 28.1023C13.3559 28.101 13.0397 28.0341 12.7467 27.9057C12.4537 27.7772 12.1902 27.59 11.9725 27.3557L0.632479 15.2923C0.208575 14.8406 -0.0185097 14.2389 0.00118164 13.6198C0.020873 13.0006 0.285727 12.4146 0.737479 11.9907C1.18923 11.5668 1.79088 11.3397 2.41006 11.3594C3.02924 11.3791 3.61524 11.6439 4.03915 12.0957L13.6525 22.339L33.2758 0.87233C33.475 0.624349 33.7227 0.419696 34.0038 0.270944C34.2849 0.122191 34.5935 0.0324784 34.9105 0.00731496C35.2276 -0.0178485 35.5464 0.0220682 35.8475 0.124615C36.1485 0.227162 36.4254 0.390174 36.6612 0.603637C36.897 0.8171 37.0866 1.07651 37.2185 1.36593C37.3503 1.65535 37.4216 1.96867 37.428 2.28665C37.4344 2.60463 37.3756 2.92056 37.2555 3.21502C37.1353 3.50949 36.9562 3.77627 36.7291 3.999L15.4025 27.3323C15.1868 27.5709 14.9242 27.7625 14.6311 27.895C14.338 28.0275 14.0208 28.0981 13.6991 28.1023H13.6758Z",fill:ri})})}),(0,n.jsx)("g",{transform:"translate(32.4879 31.4885)",children:(0,n.jsx)("g",{className:"spinner-logo__result-glyph spinner-logo__result-glyph--error",children:(0,n.jsx)("path",{d:"M17.3045 14.0095L27.3378 3.99955C27.5554 3.78199 27.728 3.52371 27.8457 3.23946C27.9635 2.95521 28.0241 2.65055 28.0241 2.34288C28.0241 2.03521 27.9635 1.73055 27.8457 1.4463C27.728 1.16205 27.5554 0.903769 27.3378 0.686213C27.1203 0.468656 26.862 0.296082 26.5778 0.178341C26.2935 0.0606 25.9889 -4.58466e-09 25.6812 0C25.3735 4.58466e-09 25.0689 0.0606 24.7846 0.178341C24.5003 0.296082 24.2421 0.468656 24.0245 0.686213L14.0145 10.7195L4.00451 0.686213C3.56514 0.246838 2.96921 -4.62957e-09 2.34784 0C1.72647 4.62957e-09 1.13055 0.246838 0.691177 0.686213C0.251802 1.12559 0.0049634 1.72151 0.0049634 2.34288C0.00496339 2.96425 0.251802 3.56017 0.691177 3.99955L10.7245 14.0095L0.691177 24.0195C0.472196 24.2363 0.29836 24.4943 0.179723 24.7787C0.0610849 25.063 0 25.3681 0 25.6762C0 25.9843 0.0610849 26.2894 0.179723 26.5737C0.29836 26.8581 0.472196 27.1161 0.691177 27.3329C0.908091 27.5516 1.16616 27.7252 1.4505 27.8436C1.73484 27.9621 2.03982 28.0231 2.34784 28.0231C2.65587 28.0231 2.96085 27.9621 3.24519 27.8436C3.52953 27.7252 3.7876 27.5516 4.00451 27.3329L14.0145 17.2995L24.0245 27.3329C24.296 27.6078 24.6314 27.8111 25.0007 27.9245C25.3701 28.0379 25.7618 28.0579 26.1407 27.9828C26.5197 27.9077 26.8741 27.7397 27.1722 27.4939C27.4703 27.2481 27.7028 26.9322 27.8488 26.5745C28.0272 26.1459 28.0736 25.6738 27.9821 25.2187C27.8907 24.7636 27.6655 24.346 27.3355 24.0195L17.3045 14.0095Z",fill:ri})})})]})}case"default":return(0,n.jsx)(H,{...c,role:o??"status","aria-live":s??"polite","aria-label":l??"Loading","data-slot":"spinner",className:(0,B.cn)("size-4 animate-spin",t)});default:return r}}var rs=r(8413),rl=r(4898),rc=r(7292),ru=r(3761);function rd(e){return e&&"renderBridge"in e?e.renderBridge??null:null}function rh(e){if(e&&"object"==typeof e&&"name"in e){let t=e.name;if("NotAllowedError"===t||"SecurityError"===t)return"camera-denied";if("NotSupportedError"===t)return"unsupported"}return"error"}let rm=(0,o.createContext)(null);function rp(){return(0,o.use)(rm)}function rf(){let{t:e}=(0,s.Bd)();return(0,n.jsx)(f.HM,{asChild:!0,children:(0,n.jsxs)(p.$,{className:"absolute top-3 right-6 z-30",variant:"secondary",children:[e("close"),(0,n.jsx)(g.A,{})]})})}function rg(e){var t,r;let a,i,{children:s,tracker:l,waiting:c=!1}=e,u=(0,o.useMemo)(()=>(0,rs.Bo)().backend,[]),d=function(e){let{tracker:t,webview:r}=e,n=(0,o.useRef)(null),a=(0,o.useRef)(null),i=(0,o.useRef)(null),s=(0,o.useRef)(!1),l=(0,o.useRef)(!0),c=(0,o.useRef)(!1),[u,d]=(0,o.useState)(!1),[h,m]=(0,o.useState)(!1),[p,f]=(0,o.useState)(!1),[g,v]=(0,o.useState)(0),[x,b]=(0,o.useState)(null),[w,y]=(0,o.useState)(!1),[j,C]=(0,o.useState)(()=>r?"webview":null);(0,o.useEffect)(()=>{let e=!0;return l.current=!0,r||t.isSupported().then(t=>{e&&(t?y(!0):C("unsupported"))}).catch(t=>e&&C(rh(t))),()=>{e=!1,l.current=!1;let t=i.current;i.current=null,s.current=!1,null==t||t.end().catch(()=>void 0)}},[t,r]);let R=(0,o.useCallback)(async(e,t)=>{i.current=null,s.current=!1,await (null==e?void 0:e.end().catch(()=>void 0)),d(!1),m(!1),C(rh(t)),b({error:t})},[]),z=(0,o.useCallback)(async e=>{let t=a.current;if(t&&!s.current){s.current=!0;try{await e.attachRenderer(t),m(!0)}catch(t){i.current===e&&await R(e,t)}}},[R]),k=(0,o.useCallback)(async()=>{let e=n.current;if(!e||i.current||c.current)return;c.current=!0,s.current=!1,m(!1),f(!0),v(e=>e+1),b(null),C(null);let r=null;try{if(r=await t.startSession({overlayRoot:e}),!l.current)return void await r.end().catch(()=>void 0);i.current=r,d(!0),await z(r)}catch(e){await R(r,e)}finally{c.current=!1,f(!1)}},[z,R,t]),N=(0,o.useCallback)(e=>{n.current=e},[]),S=(0,o.useCallback)(e=>{a.current=e;let t=i.current;t&&z(t)},[z]);return(0,o.useMemo)(()=>({hasStarted:u,isAttached:h,isStarting:p,runtimeState:j,sessionRef:i,setOverlayRoot:N,setRenderer:S,start:k,startAttempts:g,startFailure:x,supported:w}),[u,h,p,j,N,S,k,g,x,w])}({tracker:(0,o.useMemo)(()=>l??new ru.f({backend:u}),[u,l]),webview:(0,o.useMemo)(()=>(0,rl.N0)(),[])}),[h,m]=(0,o.useState)(null),[p,f]=(0,o.useState)(null),g=(0,o.useRef)(!1),v=(t=d.sessionRef,r=d.hasStarted,a=(0,o.useCallback)(e=>{if(!r)return()=>void 0;let n=0,a=()=>{if(t.current&&"renderBridge"in t.current){if(rd(t.current))return void e();n=requestAnimationFrame(a)}};return a(),()=>cancelAnimationFrame(n)},[r,t]),i=(0,o.useCallback)(()=>r?rd(t.current):null,[r,t]),(0,o.useSyncExternalStore)(a,i,()=>null)),x=(0,o.useCallback)(e=>{d.setOverlayRoot(e),m(e)},[]),w=!function(){var e;let{backend:t,hasUserActivation:r="u">typeof navigator&&!!(null==(e=navigator.userActivation)?void 0:e.isActive)}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(t??(0,rc.HE)())!=="webxr"||r}({backend:u});(0,o.useEffect)(()=>{g.current||!h||d.hasStarted||d.isStarting||d.runtimeState||!d.supported||w||(g.current=!0,d.start())},[h,w,d]);let y=`${d.startAttempts}:${c}`;(0,o.useEffect)(()=>{let e=window.setTimeout(()=>f(y),4e3);return()=>window.clearTimeout(e)},[y]);let j=d.sessionRef.current,C=j&&"renderBridge"in j?!!v:d.isAttached,R=c||function(e){let{hasStarted:t,isDrawing:r,isStarting:n,requiresManualStart:a,runtimeState:i,timedOut:o}=e;return!i&&!o&&(!!t||!!n||!a)&&(!t||!r)}({hasStarted:d.hasStarted,isDrawing:C,isStarting:d.isStarting,requiresManualStart:w,runtimeState:d.runtimeState,timedOut:p===y}),z=(0,o.useMemo)(()=>({overlayRoot:h,renderBridge:v,runtime:d}),[h,v,d]);return(0,n.jsxs)("div",{ref:x,className:"absolute inset-0 overflow-hidden bg-black","data-testid":"ar-session-surface",children:[(0,n.jsx)(rm,{value:z,children:s}),(0,n.jsx)("div",{"aria-hidden":!R,className:b("absolute inset-0 z-10 flex items-center justify-center bg-radial from-background-containers to-background-base-2 transition-opacity",R?"pointer-events-auto opacity-100 duration-0":"pointer-events-none opacity-0 duration-300 ease-in-out"),"data-testid":"ar-session-cover",children:(0,n.jsx)(ro,{variant:"logo"})}),d.runtimeState?(0,n.jsx)(e_,{variant:d.runtimeState}):null,R||d.runtimeState?(0,n.jsx)(rf,{}):null]})}function rv(e){return Math.min(4.5,Math.max(.45,e))}function rx(e){return`${e.toFixed(1)} m`}var rb=r(8993);function rw(e){let{ariaLabel:t,className:r,height:a,onHeightChange:i}=e,s=100-100*((rv(a)-.45)/4.05),l=(0,o.useRef)(null),c=void 0!==i,u=(0,o.useCallback)(e=>{if(!i)return;let t=e.currentTarget.getBoundingClientRect();t.height<=0||i(.45+(1-Math.min(1,Math.max(0,(e.clientY-t.top)/t.height*100/100)))*4.05)},[i]),d=(0,o.useCallback)(e=>{i&&(e.preventDefault(),e.stopPropagation(),l.current=e.pointerId,e.currentTarget.setPointerCapture(e.pointerId),u(e))},[i,u]),h=(0,o.useCallback)(e=>{l.current===e.pointerId&&(e.preventDefault(),e.stopPropagation(),u(e))},[u]),m=(0,o.useCallback)(e=>{l.current===e.pointerId&&(e.preventDefault(),e.stopPropagation(),l.current=null,e.currentTarget.releasePointerCapture(e.pointerId))},[]),p=(0,o.useCallback)(e=>{if(!i)return;let t=e.shiftKey?.5:.1,r={ArrowDown:-t,ArrowLeft:-t,ArrowRight:t,ArrowUp:t,End:.45-a,Home:4.5-a,PageDown:-.5,PageUp:.5}[e.key];void 0!==r&&(e.preventDefault(),i(rv(a+r)))},[a,i]);return(0,n.jsxs)("div",{"aria-hidden":!c||void 0,"aria-label":c?t:void 0,"aria-valuemax":c?4.5:void 0,"aria-valuemin":c?.45:void 0,"aria-valuenow":c?Number(a.toFixed(1)):void 0,"aria-valuetext":c?rx(a):void 0,className:b("absolute top-1/2 right-5 z-10 h-[clamp(180px,56vh,500px)] w-11 -translate-y-1/2 touch-none select-none",c?"pointer-events-auto cursor-ns-resize":"pointer-events-none",r),"data-testid":"ar-session-ceiling-height-scale",role:c?"slider":void 0,tabIndex:c?0:void 0,onKeyDown:p,onPointerCancel:m,onPointerDown:d,onPointerMove:h,onPointerUp:m,children:[(0,n.jsx)("div",{className:"absolute top-0 left-1/2 h-full w-1 -translate-x-1/2 rounded-full bg-[#212124]/50"}),(0,n.jsxs)("div",{className:"absolute left-1/2 -translate-x-1/2 -translate-y-1/2","data-testid":"ar-session-ceiling-height-scale-handle",style:{"--ar-ceiling-height-scale-top":`${s}%`,top:"var(--ar-ceiling-height-scale-top)"},children:[(0,n.jsx)("div",{className:"grid size-11 place-items-center rounded-full bg-[#4796ff] [background-image:radial-gradient(ellipse_50%_50%_at_50%_50%,#4796ff_0%,#3f73ed_100%)] text-white shadow-[0_4px_12px_rgba(51,51,65,0.12)]",children:(0,n.jsx)(rb.A,{"aria-hidden":"true",className:"size-6",strokeWidth:2})}),(0,n.jsx)("span",{className:"absolute top-8 left-1/2 -translate-x-1/2 rounded-[4px] bg-[#212124] px-1 text-[12px] leading-[1.6] font-medium tracking-[0.24px] whitespace-nowrap text-white tabular-nums","data-testid":"ar-session-ceiling-height-scale-label",children:rx(a)})]})]})}var ry=r(7807);function rj(e,t,r){let n,a=null,i=null,o=()=>{let o=e.getSnapshot(),s=null==r?void 0:r.current;if(i&&a===o&&n===s)return i;let l=o.objects.filter(e=>t(e)&&(!r||e.id===s)),c=l.some(e=>e.id===o.selectedObjectId)?o.selectedObjectId:null;return a=o,n=s,i={objects:l,selectedObjectId:c}};return{beginGesture(t,n){let a=o(),i=null===t?a.selectedObjectId??(null==r?void 0:r.current)??(null==n?void 0:n.backgroundObjectId)??null:null;return(null===t?null!==i&&a.objects.some(e=>e.id===i):a.objects.some(e=>e.id===t))?e.beginGesture(t,{backgroundObjectId:i}):null},endGesture:t=>e.endGesture(t),getSnapshot:o,isGestureEnabled:()=>!r||o().objects.length>0}}class rC{addObject(e){if(this.snapshot.objects.some(t=>t.id===e.id))throw Error(`Scene object already exists: ${e.id}`);this.setSnapshot({...this.snapshot,objects:[...this.snapshot.objects,e]})}beginGesture(e,t){if(this.activeGesture)return null;if(e)return this.hasObject(e)?(this.selectObject(e),this.activeGesture={mode:"move",objectId:e,startedOnBackground:!1},{mode:"move",objectId:e}):null;let r=this.snapshot.selectedObjectId,n=(null==t?void 0:t.backgroundObjectId)??r;return n&&this.hasObject(n)?(this.activeGesture={mode:"rotate",objectId:n,startedOnBackground:!0},{mode:"rotate",objectId:n}):null}endGesture(e){this.activeGesture=null}removeObject(e){var t;let r=this.snapshot.objects.find(t=>t.id===e);return!!r&&(this.activeGesture=null,null==(t=r.dispose)||t.call(r),this.setSnapshot({objects:this.snapshot.objects.filter(t=>t.id!==e),selectedObjectId:this.snapshot.selectedObjectId===e?null:this.snapshot.selectedObjectId}),!0)}removeSelectedObject(){return!!this.snapshot.selectedObjectId&&this.removeObject(this.snapshot.selectedObjectId)}selectObject(e){(null===e||this.hasObject(e))&&this.snapshot.selectedObjectId!==e&&this.setSnapshot({...this.snapshot,selectedObjectId:e})}replaceObjectResource(e,t){let r=this.snapshot.objects.find(t=>t.id===e);return!!r&&r.resource!==t&&(this.setSnapshot({...this.snapshot,objects:this.snapshot.objects.map(r=>r.id===e?{...r,resource:t}:r)}),!0)}hasObject(e){return this.snapshot.objects.some(t=>t.id===e)}setSnapshot(e){this.snapshot=e,this.listeners.forEach(e=>e())}constructor(){(0,tb._)(this,"activeGesture",null),(0,tb._)(this,"listeners",new Set),(0,tb._)(this,"snapshot",{objects:[],selectedObjectId:null}),(0,tb._)(this,"getSnapshot",()=>this.snapshot),(0,tb._)(this,"isGestureEnabled",()=>!0),(0,tb._)(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)))}}let rR={tracking:0,relocalizing:1,lost:2};function rz(e){return e.reduce((e,t)=>rR[t]>rR[e]?t:e,"tracking")}function rk(e){return rp()?(0,n.jsx)(rN,{...e}):(0,n.jsx)(rg,{children:(0,n.jsx)(rN,{...e})})}function rN(e){var t,r;let{catalog:a,catalogCategories:i,catalogFilters:l,catalogPagination:c,environmentUrl:u,initialResource:d,isLoadingCatalogCategories:v,object:x,owner:b,ownerAccount:w,resolveCatalogObjectVariant:y,scaleEnabled:j=!1,setCatalogFilters:C,showcaseHost:R}=e,{t:z}=(0,s.Bd)(),k=(0,L.Xf)(),N=(0,o.useRef)(!1),S=(0,o.useRef)("searching"),_=(0,o.useRef)("tracking"),{overlayRoot:M,renderBridge:P,runtime:E}=function(){let e=rp();if(!e)throw Error("An AR scene has to render inside an <ArSessionSurface>.");return e}(),I=`${d.id}:0`,O=function(e){let{initialObject:t,initialObjectId:r,initialResource:n}=e,a=(0,o.useRef)(null),i=(0,o.useRef)(1),[s]=(0,o.useState)(()=>{let e=new rC;return e.addObject(t0(n,r)),e}),l=(0,o.useSyncExternalStore)(s.subscribe,s.getSnapshot,s.getSnapshot),c=(0,o.useMemo)(()=>rj(s,tD,a),[s]),u=(0,o.useMemo)(()=>rj(s,tZ,a),[s]),d=(0,o.useMemo)(()=>rj(s,tW,a),[s]),h=(0,o.useRef)(null);h.current??(h.current=new Map(t?[[r,t]]:[]));let m=h.current,p=(0,o.useCallback)(e=>`${e}:${i.current++}`,[]);return(0,o.useMemo)(()=>({allManager:d,ceilingManager:u,createInstanceId:p,floorManager:c,gestureOwnerIdRef:a,manager:s,snapshot:l,sourceObjects:m}),[d,u,p,c,s,l,m])}({initialObject:x,initialObjectId:I,initialResource:d}),{createInstanceId:T,gestureOwnerIdRef:A,manager:H,snapshot:B,sourceObjects:U}=O,[F,q]=(0,o.useState)(!1),[Y,$]=(0,o.useState)([]),[D,V]=(0,o.useState)(!1),[Z,W]=(0,o.useState)(0),G=(0,o.useRef)(null),[X,K]=(0,o.useState)(null),[J]=(0,o.useState)(()=>new tj),Q=function(){let e=(0,o.useRef)(new Map),[t,r]=(0,o.useState)("tracking"),[n,a]=(0,o.useState)({all:"tracking",ceiling:"tracking",floor:"tracking",wall:"tracking"}),i=(0,o.useCallback)((e,t)=>{a(r=>r[e]===t?r:{...r,[e]:t})},[]),s=(0,o.useCallback)((t,r)=>{e.current.set(t,r),i("wall",rz(Array.from(e.current.values())))},[i]),l=(0,o.useCallback)(t=>{e.current.delete(t),i("wall",rz(Array.from(e.current.values())))},[i]),c=(0,o.useCallback)(e=>i("all",e),[i]),u=(0,o.useCallback)(e=>i("ceiling",e),[i]),d=(0,o.useCallback)(e=>i("floor",e),[i]);return(0,o.useMemo)(()=>({forgetWall:l,setAll:c,setCeiling:u,setFloor:d,setSession:r,setWall:s,status:rz([t,...Object.values(n)])}),[l,n,t,c,u,d,s])}(),ee=E.sessionRef;!function(e){let{emitAnalytics:t,phaseRef:r,resource:n,runtime:a}=e,i=(0,o.useRef)({emitAnalytics:t,phaseRef:r,resource:n});(0,o.useLayoutEffect)(()=>{i.current={emitAnalytics:t,phaseRef:r,resource:n}});let s=(0,o.useRef)(0),l=(0,o.useRef)(!1),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(a.startAttempts<=s.current)return;s.current=a.startAttempts;let{emitAnalytics:e,phaseRef:t,resource:r}=i.current;e({name:"ar_session_start_clicked",object:eD(r),session:{phase:t.current}})},[a.startAttempts]),(0,o.useEffect)(()=>{if(!a.hasStarted||l.current)return;l.current=!0;let{emitAnalytics:e,phaseRef:t,resource:r}=i.current;e({name:"ar_session_started",object:eD(r),session:{phase:t.current}})},[a.hasStarted]),(0,o.useEffect)(()=>{if(!a.startFailure||c.current===a.startFailure)return;c.current=a.startFailure;let{emitAnalytics:e,phaseRef:t,resource:r}=i.current;e({error:eV(a.startFailure.error),name:"ar_session_failed",object:eD(r),session:{phase:t.current}})},[a.startFailure])}({emitAnalytics:k,phaseRef:S,resource:d,runtime:E}),(0,o.useEffect)(()=>()=>H.getSnapshot().objects.forEach(e=>{var t;return null==(t=e.dispose)?void 0:t.call(e)}),[H]);let et=function(e){let{createInstanceId:t,emitAnalytics:r,forgetWallTracking:n,initialPlacingObjectId:a,manager:i,phaseRef:s,resolveCatalogObjectVariant:l,sessionRef:c,sourceObjects:u}=e,d=(0,o.useRef)(null),m=(0,o.useRef)(null),p=(0,o.useRef)(null),f=(0,o.useRef)(!1),g=(0,o.useRef)(!1),[v,x]=(0,o.useState)(a),[b,w]=(0,o.useState)("searching"),[y,j]=(0,o.useState)(null),[C,R]=(0,o.useState)(null),[z,k]=(0,o.useState)(!1),[N,S]=(0,o.useState)(!1),_=(0,o.useCallback)(e=>{s.current=e,w(e)},[s]),M=(0,o.useCallback)(e=>{g.current=e,S(e)},[]),P=(0,o.useCallback)(()=>i.getSnapshot().objects.find(e=>e.id===v)??null,[i,v]),E=(0,o.useCallback)(()=>{x(null),R(null),f.current=!1,_("placed")},[_]),I=(0,o.useCallback)(()=>{let e=P();e&&r({name:"object_placed",object:eD(e.resource),session:{phase:"placed"}}),x(null),_("placed")},[r,P,_]),O=(0,o.useCallback)(async()=>{var e,t,n;let a=P(),i=c.current;if(!a||!i||g.current)return;if("wall"===a.mechanic){r({name:"object_place_clicked",object:eD(a.resource),session:{phase:s.current}}),null==(e=(t=a.runtime.confirmPlacementRef).current)||e.call(t);return}let o=function(e,t){switch(e.mechanic){case"floor":var r;return(null==(r=t.floor)?void 0:r.kind)==="floor"?t.floor:null;case"ceiling":return t.ceiling;case"all":return t.all}}(a,{all:p.current,ceiling:m.current,floor:d.current});if(o){k(!1),M(!0),r({name:"object_place_clicked",object:eD(a.resource),session:{phase:s.current}});try{let e=await i.createAnchor(o);null==(n=a.runtime.anchor)||n.delete(),a.runtime.anchor=e,a.runtime.lastAnchorPose=e.pose,"ceiling"===a.mechanic&&null===y&&j(a.runtime.targetTransform.suspensionHeight),a.runtime.lastInteractionRef.current=performance.now(),E(),r({name:"object_placed",object:eD(a.resource),session:{phase:"placed"}})}catch(e){k(!0),r({error:eV(e),name:"object_place_failed",object:eD(a.resource),session:{phase:s.current}})}finally{M(!1)}}},[y,r,P,s,c,E,M]),T=(0,o.useCallback)(()=>{var e;let t=P();if((null==t?void 0:t.mechanic)!=="ceiling")return;let r=m.current;if(!r||"floor"!==r.kind)return;let n=(e=t.runtime.targetTransform.suspensionHeight,eP(y??e));t.runtime.targetTransform=eE(r,n),t.runtime.currentTransform={...t.runtime.targetTransform,position:{...t.runtime.targetTransform.position}};let a=null===y?"calibrating":"preview";R(eI(t.runtime.targetTransform,eU(t),"calibrating"===a)),_(a)},[y,P,_]),A=(0,o.useCallback)(async(e,n)=>{if(v)return!1;let a=await l(e,n),o=h(a,n);if(!o)return r({name:"object_unavailable",object:(0,L.ZY)(a,n)}),!1;let s=t(o.id);return u.set(s,a),i.selectObject(null),i.addObject(t0(o,s)),x(s),R(null),f.current=!1,d.current=null,m.current=null,p.current=null,_("searching"),M(!1),r({name:"object_ready",object:(0,L.ZY)(a,n)}),!0},[t,r,i,v,l,u,_,M]),H=(0,o.useCallback)(e=>{let t=i.getSnapshot(),n=t.objects.find(e=>e.id===(v??t.selectedObjectId));if(!n)return!1;let a=n.resource.variants.find(t=>t.hid===e);return!!a&&a.hid!==n.resource.variantId&&(i.replaceObjectResource(n.id,{...n.resource,glbUrl:a.glbUrl,variantId:a.hid}),r({name:"object_variant_changed",object:{...eD(n.resource),variantId:a.hid},session:{phase:s.current}}),!0)},[r,i,s,v]),B=(0,o.useCallback)(()=>{let e=i.getSnapshot(),t=e.objects.find(e=>e.id===v)??null,a=t??e.objects.find(t=>t.id===e.selectedObjectId)??null;a&&(r({name:"object_removed",object:eD(a.resource),session:{phase:t?s.current:"selected"}}),"wall"===a.mechanic&&n(a.id),i.removeObject(a.id),u.delete(a.id),t&&(x(null),_("placed")),R(null),f.current=!1)},[r,n,i,s,v,u,_]);return(0,o.useMemo)(()=>({addCatalogObject:A,allHitRef:p,ceilingHitRef:m,floorHitRef:d,handleWallPlaced:I,heightLabel:C,heightModeRef:f,phase:b,place:O,placementError:z,placementPending:N,placingObjectId:v,removeActiveObject:B,selectCeilingFloorPoint:T,setHeightLabel:R,setPlacementError:k,setPlacementPending:M,switchVariant:H,updatePhase:_}),[A,I,C,b,O,z,N,v,B,T,H,_,M])}({createInstanceId:T,emitAnalytics:k,forgetWallTracking:Q.forgetWall,initialPlacingObjectId:(null==(t=B.objects[0])?void 0:t.id)??null,manager:H,phaseRef:S,resolveCatalogObjectVariant:y,sessionRef:ee,sourceObjects:U}),{addCatalogObject:er,heightLabel:en,phase:ea,place:ei,placementError:eo,placementPending:es,placingObjectId:el,removeActiveObject:ec,selectCeilingFloorPoint:eu,setHeightLabel:ed,switchVariant:eh}=et,em=function(e,t){let[r,n]=(0,o.useState)(null);return(0,o.useEffect)(()=>{if(!t||!e)return;let r=!0,a=null;return new ry.Y().loadAsync(e).then(e=>{r?(e.mapping=303,a=e,n(e)):e.dispose()}).catch(()=>{}),()=>{r=!1,n(null),null==a||a.dispose()}},[t,e]),r}(u??null,E.isStarting||E.hasStarted),ep=(0,o.useMemo)(()=>{if(!P)return;let e=P.camera;return e.manual=!0,e},[P]),ef=Q.status,{activeCeilingObject:eg,activeMechanic:ex,activeObject:eb,activeSourceObject:ey,ceilingHeightScaleValue:ej,ceilingScaleCalibrating:eC,currentVariant:eR,displayPhase:ez,hintDismissed:ek,hintKey:eN,nextVariant:eS,placingObject:e_,primaryAction:eM,productCardObject:eO,selectedObject:eT,showCeilingScale:eA,showInitialConfirm:eH,showObjectBar:eB}=function(e){var t,r,n,a;let i,o,{dismissedHints:s,initialObjectId:l,initialResource:c,phase:u,placingObjectId:d,productCardObjectId:h,snapshot:m,sourceObjects:p,trackingStatus:f}=e,g=m.objects.find(e=>e.id===d)??null,v=m.objects.find(e=>e.id===m.selectedObjectId)??null,x=g??v,b=(t=m.objects,r=m.selectedObjectId,n=c.mechanic,(null==(o=(i=d??r)?t.find(e=>e.id===i):t.at(-1))?void 0:o.mechanic)??n),w=g?u:v?"selected":"placed",y=(a=(null==g?void 0:g.mechanic)??null,a?"ceiling"===a&&"floor-ready"===u?"set-floor":"ceiling"===a&&"calibrating"===u?"set-height":"preview"===u?"done":null:null),j="tracking"===f?`${b}.${"placed"===w?"select":"selected"===w?"gestures":"floor-ready"===w?"searching":w}`:`${b}.relocalizing`,C=(null==x?void 0:x.resource.variants)??[],R=Math.max(0,C.findIndex(e=>e.hid===(null==x?void 0:x.resource.variantId))),z=x?p.get(x.id)??null:null,k=(null==x?void 0:x.id)===l,N="done"===y||"set-height"===y,S=!!g&&k&&N,_=(null==x?void 0:x.mechanic)==="ceiling"?x:null,L=!!(g&&(null==_?void 0:_.id)===g.id&&"calibrating"===u);return{activeCeilingObject:_,activeMechanic:b,activeObject:x,activeSourceObject:z,ceilingHeightScaleValue:_?eI(_.runtime.targetTransform,eU(_),L):null,ceilingScaleCalibrating:L,currentVariant:C[R]??null,displayPhase:w,hintDismissed:s.includes(j),hintKey:j,nextVariant:C.length>1?C[(R+1)%C.length]??null:null,placingObject:g,primaryAction:y,productCardObject:x&&h===x.id?z:null,selectedObject:v,showCeilingScale:function(e){let{isPlacingCeiling:t,isSelectedCeiling:r,phase:n}=e;return t&&("calibrating"===n||"preview"===n)||!t&&r}({isPlacingCeiling:(null==g?void 0:g.mechanic)==="ceiling",isSelectedCeiling:!!(!g&&(null==v?void 0:v.mechanic)==="ceiling"),phase:w}),showInitialConfirm:S,showObjectBar:!!x&&!S&&(!g||N)}}({dismissedHints:Y,initialObjectId:I,initialResource:d,phase:ea,placingObjectId:el,productCardObjectId:X,snapshot:B,sourceObjects:U,trackingStatus:ef}),eF=el??B.selectedObjectId;tG(B.objects,A,eF),(0,o.useEffect)(()=>{var e,t;null==(t=ee.current)||null==(e=t.setMechanic)||e.call(t,ex)},[ex,E.hasStarted,ee]);let eq=ek?null:z(eN),eZ=(0,o.useCallback)(()=>{$(e=>e.includes(eN)?e:[...e,eN])},[eN]),eW=()=>(0,L.ZY)(ey,null==eb?void 0:eb.resource.variantId,null==eb?void 0:eb.mechanic),eG=(0,o.useCallback)(e=>{if(eg){var t,r;let n;eg.runtime.targetTransform=(t=eg.runtime.targetTransform,r=eU(eg),n=eP(eC?e:e+r*t.scale),{...t,position:{...t.position,y:t.floorY+n},suspensionHeight:n}),eg.runtime.lastInteractionRef.current=performance.now(),ed(eI(eg.runtime.targetTransform,eU(eg),eC))}},[eg,eC,ed]);(0,o.useLayoutEffect)(()=>{let e=G.current;if(!e)return;let t=()=>W(Math.round(e.getBoundingClientRect().height));if(t(),"u"<typeof ResizeObserver)return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let eX=(0,o.useMemo)(()=>({"--ar-session-hint-bottom":Z>0?`calc(${eK} + ${Z}px + 0.75rem)`:eK,bottom:"var(--ar-session-hint-bottom)"}),[Z]);return(0,o.useEffect)(()=>{if(_.current===ef)return;_.current=ef;let e=e_??eT;k({name:"tracking_status_changed",object:e?eD(e.resource):eD(d),session:{phase:ez,trackingStatus:ef}})},[ez,k,d,e_,eT,ef]),(0,n.jsxs)("div",{className:"absolute inset-0 z-[1] overflow-hidden","data-testid":"ar-session-scene",children:[(0,n.jsxs)(m.Hl,{className:P?"relative z-[1] touch-none":"touch-none",camera:ep??{far:100,near:.01},frameloop:P?"never":"always",gl:{alpha:!0,antialias:!0},scene:P?P.sceneRoot:void 0,onCreated:e=>{let{gl:t}=e;return E.setRenderer(t)},children:[P?(0,n.jsx)(eY,{bridge:P}):null,(0,n.jsx)(e$,{texture:em}),em?null:(0,n.jsx)("ambientLight",{intensity:1.2}),(0,n.jsx)(tR,{cache:J,children:(0,n.jsx)(ra,{objects:O,phaseRef:S,placement:et,scaleEnabled:j,sessionHasTrackingRef:N,sessionRef:ee,tracking:Q})})]},P?"engine":"host"),eA&&null!==ej?(0,n.jsx)(rw,{ariaLabel:z("ceiling.heightMode"),height:ej,onHeightChange:eG}):null,(0,n.jsx)(rS,{modelCache:J,pendingModelUrl:(null==eb?void 0:eb.resource.glbUrl)??null,positionStyle:eX,text:eq,onDismiss:eZ}),(0,n.jsx)(eL,{status:ef}),(0,n.jsx)(e1,{activeMechanic:ex,confirmDisabled:es||"set-height"===eM&&null===en,confirmIconLabel:z(e_?`${ex}.done`:"close"),confirmLabel:z(`${ex}.done`),controlsRef:G,currentVariant:eR,isStarting:E.isStarting,nextVariant:eB?eS:null,productName:eB&&ey?(null==(r=ey.name)?void 0:r.trim())||z("catalog.unnamedProduct"):null,showCatalogButton:!eb,showConfirmButton:eH,showConfirmIcon:eB&&!!eb,showDeleteButton:eB&&!!eb,showSetFloorButton:"set-floor"===eM,showStartButton:!E.hasStarted&&E.supported&&!E.runtimeState,onConfirm:()=>e_?void ei():H.selectObject(null),onDelete:ec,onOpenCatalog:()=>q(!0),onOpenProduct:()=>{K((null==eb?void 0:eb.id)??null),k({name:"catalog_product_opened",object:eW()})},onOpenVariants:()=>V(!0),onSetFloorPoint:eu,onStart:()=>void E.start()}),(0,n.jsx)(f.HM,{asChild:!0,children:(0,n.jsx)(p.$,{className:"absolute top-6 right-6 z-10 bg-black/50 text-white hover:bg-black/60 active:bg-black/70",style:{top:"max(1.5rem, env(safe-area-inset-top))"},size:"icon","aria-label":z("close"),children:(0,n.jsx)(g.A,{"aria-hidden":"true"})})}),eo?(0,n.jsx)("p",{className:"absolute inset-x-6 bottom-24 z-10 rounded-xl bg-black/70 p-4 text-center text-sm text-white",role:"alert",children:z(`${ex}.anchorError`)}):null,(0,n.jsx)(ev,{object:eO,portalContainer:M,showcaseHost:R,testId:"ar-session-product-card",onOpenChange:e=>!e&&K(null),onViewOnSite:()=>k({name:"catalog_product_view_on_site_clicked",object:eW()})}),(0,n.jsx)(eQ,{currentVariantId:null==eb?void 0:eb.resource.variantId,open:D,portalContainer:M,variants:(null==eb?void 0:eb.resource.variants)??[],onOpenChange:V,onSelect:e=>eh(e)&&V(!1)}),(0,n.jsx)(ew,{catalog:a,categories:i,filters:l,isLoadingCategories:v,owner:b,ownerAccount:w,pagination:c,showcaseHost:R,setFilters:C,onOpenChange:q,onPlace:er,open:F,portalContainer:M})]})}function rS(e){let{modelCache:t,onDismiss:r,pendingModelUrl:a,positionStyle:i,text:l}=e,{t:c}=(0,s.Bd)(),{active:u,progress:d}=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],{active:t,progress:r}=(0,eM.p)(),[n,a]=(0,o.useState)({active:!1,progress:0}),i=(0,o.useRef)(0);return(0,o.useEffect)(()=>{if(e){i.current=0,a({active:!1,progress:0});return}if(t){i.current=Math.max(i.current,Math.round(r)),a({active:!0,progress:i.current});return}let n=window.setTimeout(()=>{i.current=0,a({active:!1,progress:0})},400);return()=>window.clearTimeout(n)},[t,e,r]),n}(tk(t,a)||!a);return u||l?(0,n.jsx)("div",{className:"pointer-events-none absolute inset-x-6 z-10 flex justify-center",style:i,"data-testid":"ar-session-hint-shell",children:u?(0,n.jsx)("p",{className:"max-w-full rounded-full bg-black/65 px-4 py-2 text-center text-sm text-white","aria-live":"polite","data-testid":"ar-session-loading",role:"status",children:c("loadingModel",{progress:Math.round(d)})}):(0,n.jsx)("button",{type:"button",className:"pointer-events-auto max-w-full rounded-full bg-black/65 px-4 py-2 text-center text-sm text-white","aria-live":"polite","data-testid":"ar-session-hint",onClick:r,children:l})}):null}function r_(e){let{children:t}=e,{t:r}=(0,s.Bd)();return(0,n.jsxs)("div",{className:"relative flex size-full flex-col items-center justify-center gap-4 overflow-auto bg-radial from-background-containers to-background-base-2 p-4 text-foreground","data-neurodyn-ar-mount":"",children:[(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("h1",{className:"typo-base-18 font-medium",children:r("android.title")}),(0,n.jsx)("p",{className:"mt-1 typo-base-14 text-text-light",children:r("android.description")})]}),t]})}function rL(e){let{variant:t,showDialogCloseButton:r=!1}=e,{t:a}=(0,s.Bd)();return(0,n.jsxs)("div",{className:"relative z-30 flex size-full flex-col items-center justify-center gap-4 bg-radial from-background-containers to-background-base-2 p-4 text-center",children:[(0,n.jsx)(T,{className:"size-8 text-icons-light"}),(0,n.jsx)("h2",{className:"typo-base-16 font-medium text-text-dark",children:a(`accessError.${t}`)}),r&&(0,n.jsx)(f.HM,{asChild:!0,children:(0,n.jsx)(p.$,{variant:"secondary",children:a("close")})})]})}var rM=r(4956),rP=r(9055),rE=r(2966),rI=r(6198),rO=r(7531);function rT(e){return(null==e?void 0:e.url)?{uuid:e.uuid,url:e.url,ext:e.ext,type:e.type,realName:e.realName}:void 0}async function rA(e,t){let{uuid:r,username:n}=e,a=null==n?void 0:n.trim().toLowerCase();if(!r&&!a)throw Error("fetchPublicAccount: uuid or username is required");let{result:i}=await (0,rO.hov)(r?{uuids:[r],limit:1}:{query:a},t),o=i.find(e=>r?e.uuid===r:e.username.toLowerCase()===a);if(!o)throw Error(`Account ${r??n} not found`);return{uuid:o.uuid,username:o.username,name:o.name,email:o.email,email_verified:o.emailVerified,phone:o.phone,phone_verified:o.phoneVerified,region:o.region,type:o.type,source:o.source,app_type:o.appType,accepted_terms:o.acceptedTerms,useObjTags:o.useObjTags,config:o.config,company:o.company,privacy:o.privacy,links:o.links,partnerRefID:o.partnerRefID,refID:o.refID,followers_count:o.followersCount,following_count:o.followingCount,posts_count:o.postsCount,avatar:rT(o.avatar),background:rT(o.background)}}let rH=(0,r(9722).q)({clientName:"API client",configureFunctionName:"configureApiClient",defaultBaseURL:"https://api.vizbl.com/v1"});rH.configureClientRuntime,rH.configureAccessTokenResolverRuntime,rH.configureHeadersResolverRuntime,rH.configureUnauthorizedHandlerRuntime,rH.isClientConfiguredRuntime,rH.assertClientConfiguredRuntime,rH.resetClientForTestsRuntime;let rB=rH.requestRuntime;async function rU(e){return rB(e)}async function rF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{client:r=rU,...n}=t;return(await r({method:"POST",url:"/obj/Fetch",data:e,...n})).data}async function rq(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{client:r=rU,...n}=t;return(await r({method:"POST",url:"/obj/GetPublic",data:e,...n})).data}async function rY(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{client:r=rU,...n}=t;return(await r({method:"POST",url:"/obj/GetTags",data:e,...n})).data}async function r$(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{client:r=rU,...n}=t;return(await r({method:"POST",url:"/obj/GetUserCats",data:e,...n})).data}rH.requestWithoutUnauthorizedRecovery,rH.addResponseInterceptorRuntime;let rD="core-ar";function rV(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function rZ(e){return{baseURL:e.nodeBaseURL,headers:{"x-api-key":e.apiKey},signal:e.signal}}async function rW(e,t){return t.apiKey?(0,rO.ytc)({tinuuid:e},{productType:rD,variantId:t.variantId},rZ(t)):rF({tinuuid:e},{baseURL:t.legacyBaseURL,signal:t.signal})}async function rG(e,t,r){var n,a;let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=(0,P.J)(i.search),s=rV(null==(n=i.category)?void 0:n.id),l=null==(a=i.category)?void 0:a.kind,c="tag"===l&&void 0!==s,u={owners:[e],page:t,...o?{search:o}:{},..."category"===l&&void 0!==s?{catId:String(s)}:{},...c?{tagId:s}:{},...r.apiKey&&c?{activated:!0,productType:rD}:{}};if(!r.apiKey||c)return rq(u,{baseURL:r.legacyBaseURL,signal:r.signal});let d={owners:[e],page:t,...o?{search:o}:{},..."category"===l&&void 0!==s?{catId:s}:{}},h=await (0,rO.avi)(d,{productType:rD},rZ(r));return{folder:h.folder,objs:h.objs,pages_count:h.pages_count}}async function rX(e,t){return rA({uuid:e},{baseURL:t.nodeBaseURL,signal:t.signal})}function rK(e){let t=Number(e.id),r=(0,P.J)(e.name);return Number.isFinite(t)&&r&&e.hasObjs?{id:t,kind:"category",name:r}:null}function rJ(e){let t=rV(e.id),r=(0,P.J)(e.name);return void 0!==t&&r?{id:t,kind:"tag",name:r}:null}function rQ(e,t){return e.id===t.id?0:90===e.id?1:90===t.id?-1:0}async function r0(e,t,r){return"custom"===t?((await rY({ownerUuid:e},{baseURL:r.legacyBaseURL,signal:r.signal})).tags??[]).map(rJ).filter(e=>!!e).sort(rQ):((await r$({ownerUuid:e},{baseURL:r.legacyBaseURL,signal:r.signal})).cats??[]).map(rK).filter(e=>!!e).sort(rQ)}async function r1(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{client:r=rU,...n}=t;return(await r({method:"POST",url:"/layout/GetConfig",data:e,...n})).data}let r2="https://cdn.neurodyn.ai/hdr/modern_bathroom_1k.hdr";function r4(e){return"string"==typeof e&&/^https?:\/\//i.test(e)}async function r3(e){try{let t=await r1(void 0,{baseURL:e.legacyBaseURL,signal:e.signal});return function(e){var t,r,n;if(!e)return null;if(r4(e.hdr_neutral))return e.hdr_neutral;let a=null==(t=e.internal)?void 0:t.hdr_neutral;if(r4(a))return a;let i=null==(n=e.internal)||null==(r=n.links)?void 0:r.find(e=>"hdr_neutral"===e.type&&r4(e.url));return(null==i?void 0:i.url)??null}(t)??r2}catch{return r2}}let r7={category:null,search:""},r5=[],r9=(0,o.createContext)(null);function r6(e){var t,r,a;let{apiKey:i,children:s,hid:l,initialWidgetSessionToken:h,tenant:m,tinuuid:p}=e,f=(null==i?void 0:i.trim())||void 0,g=(null==l?void 0:l.trim())||void 0,v=(null==p?void 0:p.trim())??"",x={apiKey:f,legacyBaseURL:m.legacyApiOrigin,nodeBaseURL:m.apiOrigin},b=!!v,w=(0,rP.I)({queryKey:["ar","object",{apiKey:(t={...x,variantId:g}).apiKey??null,legacyBaseURL:t.legacyBaseURL,nodeBaseURL:t.nodeBaseURL,tinuuid:v,variantId:t.variantId??null}],enabled:b,queryFn:e=>{let{signal:t}=e;return rW(v,{...x,signal:t,variantId:g})}}),y=(0,rP.I)({queryKey:["ar","scene-environment",{legacyBaseURL:x.legacyBaseURL,nodeBaseURL:x.nodeBaseURL}],queryFn:e=>{let{signal:t}=e;return r3({...x,signal:t})},retry:!1,staleTime:1/0}),j=(0,rP.I)({queryKey:["ar","widget-session",{apiKey:f??null,handoffTokenDigest:(0,u.a4)(h),nodeBaseURL:m.apiOrigin}],enabled:!!f,gcTime:0,refetchOnMount:"always",queryFn:e=>{let{signal:t}=e;if(!f)throw Error("API key is required to activate a widget session.");return(0,u.Uu)({apiBaseUrl:m.apiOrigin,apiKey:f,initialWidgetSessionToken:h,signal:t})}}),C=w.data??null,R=(null==C?void 0:C.owner)??null,z=null==R?void 0:R.uuid,[k,N]=(0,o.useState)({filters:r7}),S=k.ownerUuid===z?k.filters:r7,_=(0,o.useCallback)(e=>{N(t=>{var r;return{filters:(r=t.ownerUuid===z?t.filters:r7,"function"==typeof e?e(r):e),ownerUuid:z}})},[z]),L=(0,rP.I)({queryKey:["ar","owner-account",{legacyBaseURL:x.legacyBaseURL,ownerUuid:z??null}],enabled:!!z,queryFn:e=>{let{signal:t}=e;if(!z)throw Error("Owner uuid is required.");return rX(z,{...x,signal:t})}}),M=L.data??null,E=(null==M?void 0:M.useObjTags)===!0?"custom":"standard",I=(0,rP.I)({queryKey:["ar","owner-categories",{categoryMode:E,legacyBaseURL:x.legacyBaseURL,ownerUuid:z??null}],enabled:!!(z&&M),queryFn:e=>{let{signal:t}=e;if(!z)throw Error("Owner uuid is required.");return r0(z,E,{...x,signal:t})}}),O=I.data??r5,T=!!(z&&(!M||L.isLoading||L.isError||I.isLoading||I.isError)),A=(0,o.useMemo)(()=>{let e,t=(e=S.search.trim(),{category:S.category,search:e}),r=t.category;return!r||T||O.some(e=>e.id===r.id&&e.kind===r.kind)?t:{...t,category:null}},[O,S,T]),H=function(e,t){let[r,n]=(0,o.useState)(e);return(0,o.useEffect)(()=>{if(r===e)return;let t=window.setTimeout(()=>n(e),400);return()=>window.clearTimeout(t)},[400,r,e]),r}(A.search,0),B=(0,o.useMemo)(()=>({category:A.category,search:H}),[H,A.category]),{data:U,error:F,fetchNextPage:Y,hasNextPage:$,isFetchingNextPage:D}=(0,rE.q)({queryKey:["ar","owner-objects",{apiKey:x.apiKey??null,categoryId:(null==(r=B.category)?void 0:r.id)??null,categoryKind:(null==(a=B.category)?void 0:a.kind)??null,legacyBaseURL:x.legacyBaseURL,nodeBaseURL:x.nodeBaseURL,ownerUuid:z??null,search:(0,P.J)(B.search)??null}],enabled:!!z,queryFn:e=>{let{pageParam:t,signal:r}=e;if(!z)throw Error("Owner uuid is required.");return rG(z,t,{...x,signal:r},B)},initialPageParam:1,getNextPageParam:(e,t,r)=>{var n;return void 0!==e.pages_count?r<e.pages_count?r+1:void 0:(null==(n=e.objs)?void 0:n.length)?r+1:void 0},placeholderData:rI.rX}),V=(0,o.useMemo)(()=>(function(e,t){if(!e)return t;let r=q(e);return[e,...t.filter(e=>!r||q(e)!==r)]})(C,(null==U?void 0:U.pages.flatMap(e=>e.objs??[]))??[]),[null==U?void 0:U.pages,C]),Z=(0,o.useCallback)(async(e,t)=>{var r;let n=null==(r=e.tinuuid)?void 0:r.trim();return n?rW(n,{apiKey:f,legacyBaseURL:m.legacyApiOrigin,nodeBaseURL:m.apiOrigin,variantId:t}):e},[f,m.apiOrigin,m.legacyApiOrigin]),W=null;v?w.error?W=c(w.error,"object"):C&&!z?W="owner-missing":F&&(W=c(F,"catalog")):W="missing-tinuuid";let G=b&&w.isLoading,X=W?"error":G||!C?"loading":"ready",K=(0,o.useMemo)(()=>({catalog:V,catalogCategories:O,catalogFilters:A,environmentUrl:y.data??null,error:W,fetchNextPage:async()=>{await Y()},hasNextPage:!!$,isFetchingNextPage:D,isLoadingCatalogCategories:T,metadata:C?(0,d.sq)(C):null,object:C,owner:R,ownerAccount:M,resolveCatalogObjectVariant:Z,setCatalogFilters:_,showcaseHost:m.showcaseHost,status:X,variant:C?(0,d.uW)(C,g):null,widgetSession:j.data??null}),[V,O,y.data,W,Y,$,D,T,A,g,C,R,M,Z,_,X,m.showcaseHost,j.data]);return(0,n.jsx)(r9,{value:K,children:s})}function r8(){let e=(0,o.use)(r9);if(!e)throw Error("useArData must be used inside ArDataProvider");return e}function ne(e){let{label:t,value:r}=e;return(0,n.jsxs)("div",{className:"grid grid-cols-[7rem_minmax(0,1fr)] gap-3 border-b border-border py-2 last:border-0",children:[(0,n.jsx)("dt",{className:"text-text-light",children:t}),(0,n.jsx)("dd",{className:"min-w-0 break-words font-mono",children:r??"—"})]})}function nt(e){var t,r,a,i,o,l,c,u;let{showDialogCloseButton:d=!1,value:h}=e,{t:m}=(0,s.Bd)(),v=null==(t=h.metadata)?void 0:t.dimensions;return(0,n.jsxs)("section",{className:"w-full max-w-2xl overflow-auto rounded-xl border border-border bg-background-containers p-5 shadow-lg",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsx)("h1",{className:"typo-base-18 font-medium",children:m("data.title")}),d&&(0,n.jsx)(f.HM,{asChild:!0,children:(0,n.jsx)(p.$,{size:"icon",variant:"secondary","aria-label":m("close"),children:(0,n.jsx)(g.A,{"aria-hidden":"true"})})})]}),(0,n.jsxs)("dl",{className:"mt-3 typo-base-14",children:[(0,n.jsx)(ne,{label:m("data.object"),value:`${(null==(r=h.object)?void 0:r.name)??"—"} (${(null==(a=h.object)?void 0:a.tinuuid)??"—"})`}),(0,n.jsx)(ne,{label:m("data.variant"),value:`${(null==(i=h.variant)?void 0:i.name)??"—"} (${(null==(o=h.variant)?void 0:o.hid)??"—"})`}),(0,n.jsx)(ne,{label:m("data.owner"),value:`${(null==(l=h.owner)?void 0:l.name)??"—"} (${(null==(c=h.owner)?void 0:c.uuid)??"—"})`}),(0,n.jsx)(ne,{label:m("data.mechanic"),value:null==(u=h.metadata)?void 0:u.mechanic}),(0,n.jsx)(ne,{label:m("data.dimensions"),value:v?`${v.width} \xd7 ${v.height} \xd7 ${v.depth} ${v.unit}`:"—"})]}),(0,n.jsxs)("div",{className:"mt-5 flex items-center justify-between gap-3",children:[(0,n.jsxs)("h2",{className:"typo-base-16 font-medium",children:[m("data.catalog"),(0,n.jsxs)("span",{children:[" ","(",h.catalog.length,")"]})]}),h.hasNextPage&&(0,n.jsx)(p.$,{type:"button",variant:"secondary",disabled:h.isFetchingNextPage,onClick:()=>void h.fetchNextPage(),children:h.isFetchingNextPage?m("data.loading"):m("data.loadNextPage")})]}),(0,n.jsx)("ul",{className:"mt-2 grid gap-2",children:h.catalog.map((e,t)=>(0,n.jsx)("li",{className:"rounded-md border border-border px-3 py-2 typo-base-14",children:e.name??e.tinuuid??e.uuid??m("data.unnamedObject")},e.uuid??e.tinuuid??t))})]})}let nr=new Set(["catalog_category_selected","catalog_opened","catalog_product_opened","catalog_product_place_clicked","catalog_product_view_on_site_clicked","catalog_show_all_clicked","object_placed","object_removed","object_variant_changed"]),nn=new a.E({defaultOptions:{queries:{gcTime:3e5,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:(e,t)=>{let r=l(t);return("number"!=typeof r||!(r>=400)||!(r<500))&&e<2}}}});function na(e){let{apiKey:t,hid:r,initialWidgetSessionToken:a,language:l,onAnalyticsEvent:c,scaleEnabled:u=!1,tinuuid:d}=e,{i18n:h}=(0,s.Bd)(),m=function(){let{i18n:e}=(0,s.Bd)(),t=e.resolvedLanguage??e.language;return(0,rM.hs)(t)}(),p=(0,rM._K)(l?(0,rM.hs)(l):m);return(0,o.useEffect)(()=>{l&&h.language!==l&&h.changeLanguage(l)},[h,l]),(0,n.jsx)(i.Ht,{client:nn,children:(0,n.jsx)(r6,{apiKey:t,hid:r,initialWidgetSessionToken:a,tenant:p,tinuuid:d,children:(0,n.jsx)(ni,{onAnalyticsEvent:c,children:(0,n.jsx)(no,{scaleEnabled:u})})})})}function ni(e){var t,r,a;let{children:i,onAnalyticsEvent:s}=e,l=r8(),c=(0,o.useRef)([]),d=(0,o.useRef)(null),m=(0,o.useRef)(null),p=(0,o.useCallback)(()=>{var e,t;return(0,L.ZY)(l.object,null==(e=l.variant)?void 0:e.hid,null==(t=l.metadata)?void 0:t.mechanic)},[null==(t=l.metadata)?void 0:t.mechanic,l.object,null==(r=l.variant)?void 0:r.hid]),f=(0,o.useCallback)((e,t)=>{let r=l.widgetSession;if(!r)return!1;if("widget_opened"===e){if(r.continued||m.current===r.sid)return!0;m.current=r.sid}if("ar_launched"===e){if(d.current===r.sid)return!0;d.current=r.sid}return(0,u.Kq)(r,e,{objectId:t.objectId,variantId:t.variantId}),!0},[l.widgetSession]),g=(0,o.useCallback)(e=>{(0,L.lA)(s,e);let t="ar_session_started"===e.name?"ar_launched":nr.has(e.name)?"interacted":null;if(!t)return;let r=e.object??p();!f(t,r)&&c.current.length<10&&c.current.push({event:t,object:r})},[p,s,f]);return(0,o.useEffect)(()=>{var e;if(("ready"===l.status&&l.object?h(l.object,null==(e=l.variant)?void 0:e.hid):null)&&f("widget_opened",p()),!c.current.length)return;let t=c.current;c.current=t.filter(e=>!f(e.event,e.object))},[l.object,l.status,null==(a=l.variant)?void 0:a.hid,p,f]),(0,n.jsx)(L.Nz,{onEvent:g,children:i})}function no(e){var t,r,a;let{scaleEnabled:i}=e,s=r8(),l=(0,L.Xf)(),c=(0,o.useRef)(null),u=(0,o.useMemo)(()=>{var e;return"ready"===s.status&&s.object?h(s.object,null==(e=s.variant)?void 0:e.hid):null},[s.object,s.status,null==(t=s.variant)?void 0:t.hid]);if((0,o.useEffect)(()=>{if(!s.error)return;let e=`error:${s.error}`;c.current!==e&&(c.current=e,l({error:{code:s.error},name:"object_load_failed"}))},[s.error,l]),(0,o.useEffect)(()=>{var e,t,r,n,a;if("ready"!==s.status){"loading"===s.status&&(c.current=null);return}let i=u?`ready:${u.id}:${u.glbUrl}:${u.mechanic}:${(null==(e=s.variant)?void 0:e.hid)??""}`:`unavailable:${(null==(t=s.object)?void 0:t.uuid)??""}:${(null==(r=s.variant)?void 0:r.hid)??""}`;c.current!==i&&(c.current=i,l({name:u?"object_ready":"object_unavailable",object:(0,L.ZY)(s.object,null==(n=s.variant)?void 0:n.hid,null==(a=s.metadata)?void 0:a.mechanic)}))},[null==(r=s.metadata)?void 0:r.mechanic,s.object,s.status,null==(a=s.variant)?void 0:a.hid,l,u]),s.error)return(0,n.jsx)(rL,{variant:function(e){switch(e){case"access-denied":return"unauthorized";case"missing-tinuuid":case"object-not-published":return"not-found";default:return"unavailable"}}(s.error),showDialogCloseButton:!0});if("ready"===s.status&&!u)return(0,n.jsx)(rL,{variant:"unavailable",showDialogCloseButton:!0});if("ready"===s.status&&(0,rs.R5)())return(0,n.jsx)(nt,{showDialogCloseButton:!0,value:s});let d="loading"===s.status;return(0,n.jsx)(r_,{children:(0,n.jsx)(rg,{waiting:d,children:u?(0,n.jsx)(ns,{data:s,initialResource:u,scaleEnabled:i}):null})})}function ns(e){let{data:t,initialResource:r,scaleEnabled:a}=e;return(0,n.jsx)(rk,{catalog:t.catalog,catalogPagination:{fetchNextPage:t.fetchNextPage,hasNextPage:t.hasNextPage,isFetchingNextPage:t.isFetchingNextPage},catalogCategories:t.catalogCategories,catalogFilters:t.catalogFilters,environmentUrl:t.environmentUrl,initialResource:r,isLoadingCatalogCategories:t.isLoadingCatalogCategories,object:t.object,owner:t.owner,ownerAccount:t.ownerAccount,resolveCatalogObjectVariant:t.resolveCatalogObjectVariant,scaleEnabled:a,setCatalogFilters:t.setCatalogFilters,showcaseHost:t.showcaseHost},`${r.id}:${r.glbUrl}`)}}}]);