@imagineio/configurator-sdk 0.1.1 → 0.1.2
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.
- package/dist/066fc9aa40.js +1 -1
- package/dist/14c83bc57a.js +1 -1
- package/dist/1870fc037b.js +1 -1
- package/dist/2b6aa27f6d.js +1 -1
- package/dist/2cafe3274b.js +1 -1
- package/dist/371ed78aa2.js +1 -1
- package/dist/4910c07ca8.css +24 -7
- package/dist/4e7d0a0d4a.js +1 -1
- package/dist/5c9fd9201c.js +1 -1
- package/dist/6bff84d27e.js +1 -1
- package/dist/87bb469216.js +1 -1
- package/dist/88251d6671.js +1 -1
- package/dist/8f60e5059a.js +1 -1
- package/dist/9c6c598569.js +1 -1
- package/dist/c2a14a77ae.js +1 -1
- package/dist/c44d37da7a.js +1 -1
- package/dist/c9a1656c62.js +1 -1
- package/dist/d4378d9afa.js +1 -1
- package/dist/db4afd43c9.js +1 -1
- package/dist/styles/globals.css +28 -0
- package/package.json +1 -1
package/dist/066fc9aa40.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{themeLayoutKey as
|
|
1
|
+
import{themeLayoutKey as u}from"./5c9fd9201c.js";import o from"./8f60e5059a.js";import m from"./872c4302e0.js";import a from"./be337ddda5.js";function p(){const t=o(e=>e.bootLoading),r=o(e=>e.uiReady),s=o(e=>e.bootDetail),n=o(e=>e.bootProgress),c=o(e=>e.themeReady),i=m(e=>e.isLoading),d=a(e=>e.isLoading);return{loading:!!t,uiReady:!!r,detail:s??null,progress:n??null,themeReady:!!c,catalogLoading:!!i,configLoading:!!d,ready:!i&&!d}}function h(){try{o.getState().endBootLoading?.()}catch{}}function L(){const t=a(n=>n.systemId),r=a(n=>n.systemName),s=a(n=>n.systemConfiguratorKey);return{id:t??null,name:r??null,configuratorKey:s??null}}function S(){try{o.setState(t=>t.themeReady?t:{themeReady:!0})}catch{}}function b(t){try{o.setState({embedded:!!t})}catch{}}function R(t){try{a.setState({systemTheme:u(t),systemThemeRecord:t&&typeof t=="object"?t:null})}catch{}}export{h as endBootLoading,S as markThemeReady,b as setEmbedded,R as setSystemTheme,p as useBootStatus,L as useSystem};
|
package/dist/14c83bc57a.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as L,useRef as y}from"react";import{useFrame as w,useThree as D}from"@react-three/fiber";import*as _ from"three";import s from"./9c6c598569.js";const x=4,A=.02,C=.004,G=.25,P=2,c=new _.Vector3,u=new _.Vector3;function I({controlsRef:n}){const{camera:o,gl:F,invalidate:p}=D(),
|
|
1
|
+
import{useEffect as L,useRef as y}from"react";import{useFrame as w,useThree as D}from"@react-three/fiber";import*as _ from"three";import s from"./9c6c598569.js";const x=4,A=.02,C=.004,G=.25,P=2,c=new _.Vector3,u=new _.Vector3;function I({controlsRef:n}){const{camera:o,gl:F,invalidate:p}=D(),g=y(!1),d=y({target:null,elapsed:0,stalled:0,lastGap:1/0});return L(()=>(s.getState().isFocusing&&p(),s.subscribe((t,e)=>{t.isFocusing&&!e?.isFocusing&&p()})),[p]),L(()=>{let r=null;const t=()=>{clearTimeout(r),r=setTimeout(()=>{s.getState().isFocusing&&s.getState().clearFocus()},5e3)};s.getState().isFocusing&&t();const e=s.subscribe((l,a)=>{l.isFocusing&&!a?.isFocusing&&t(),!l.isFocusing&&a?.isFocusing&&clearTimeout(r)});return()=>{clearTimeout(r),e()}},[]),L(()=>{const r=F.domElement,t=()=>{s.getState().isFocusing&&(g.current=!0)};return r.addEventListener("pointerdown",t),r.addEventListener("wheel",t),r.addEventListener("touchstart",t),()=>{r.removeEventListener("pointerdown",t),r.removeEventListener("wheel",t),r.removeEventListener("touchstart",t)}},[F]),w((r,t)=>{const{focusTarget:e,isFocusing:l,clearFocus:a,setCameraPosition:f,setCameraTarget:E}=s.getState();if(!e||!l)return;if(d.current.target!==e&&(d.current={target:e,elapsed:0,stalled:0,lastGap:1/0},g.current=!1),c.set(...e.position),u.set(...e.target),e.instant){o.position.copy(c),n?.current&&(n.current.target.copy(u),n.current.update()),f([...e.position]),E([...e.target]),a();return}if(g.current){g.current=!1;const S=o.position,m=n?.current?.target;f([S.x,S.y,S.z]),m&&E([m.x,m.y,m.z]),a();return}const v=1-Math.exp(-x*t);o.position.lerp(c,v),n?.current&&(n.current.target.lerp(u,v),n.current.update());const T=o.position.distanceTo(c),h=n?.current?n.current.target.distanceTo(u):0,b=Math.max(T,h),i=d.current;if(i.elapsed+=t,i.stalled=Math.abs(i.lastGap-b)<C*t*60?i.stalled+t:0,i.lastGap=b,T<A&&h<A||i.stalled>G||i.elapsed>P){o.position.copy(c),n?.current&&(n.current.target.copy(u),n.current.update()),f([...e.position]),E([...e.target]),a();return}p()}),null}var V=I;export{V as default};
|
package/dist/1870fc037b.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as te,jsx as r,jsxs as re}from"react/jsx-runtime";import{setTokenProvider as _}from"./33fa2c8ca2.js";import{adoptUrlCredentials as L}from"./1fff100656.js";import{copilotAuthHeaders as A}from"./431a2d8618.js";import{useEffect as u,useState as k,useSyncExternalStore as C,lazy as b,Suspense as v}from"react";import T from"react-dom/client";import"./styles/globals.css";import B from"./87bb469216.js";import I from"./88251d6671.js";import w from"./d617bbb9f5.js";import E from"./7bfcd0a517.js";import{bootConfigurator as D}from"./371ed78aa2.js";import s from"./8f60e5059a.js";import{markThemeReady as M}from"./066fc9aa40.js";import{CopilotContext as U}from"./672404d987.js";import{checkCopilotAvailability as K,getCopilotRuntimeUrl as O,getCopilotWarmupUrl as P}from"./fe58a84b85.js";import{whenConfiguratorLicenceSettled as x,subscribeConfiguratorLicence as z,getConfiguratorAllowed as h,getConfiguratorBlockedMessage as V}from"./3bbcee0334.js";import{resolveRoute as R}from"./61e0c0c9b5.js";import{resolveComponent as S,useComponentRegistry as N}from"./882bc739c8.js";import{useLabels as W}from"./28d887bf8a.js";const H=b(()=>import("./81eb433604.js")),q=6e3,F=12e4,m=()=>{const e=s.getState();e.markUiReady?.(),e.endBootLoading?.()},G=b(async()=>{const[{CopilotKit:e}]=await Promise.all([import("@copilotkit/react-core"),import("@copilotkit/react-ui/styles.css")]);return{default:e}});let a=null,c={ready:!1,error:null},d=0;const p=new Set;let y={};function f(){d+=1;for(const e of p)try{e()}catch{}}function X(e){return p.add(e),()=>{p.delete(e)}}function Y(e={}){if(a)try{a.cancel()}catch{}return c={ready:!1,error:null},f(),a=D({resolveInitialSystemId:e.resolveInitialSystemId??(()=>e.systemId??null),resolveConfigurator:e.resolveConfigurator,resolveConfiguratorKey:e.resolveConfiguratorKey,resolveInitialChannelId:e.resolveInitialChannelId,getToken:e.getToken,onReady:()=>{c={ready:!0,error:null},f()},onError:(o,t)=>{let l=o;t?.code==="unlicensed"?l={unlicensed:!0,message:o}:l={...t,message:o},c={ready:!1,error:l},f()}}),a}function $(){try{a?.cancel()}catch{}a=null,c={ready:!1,error:null},f()}function J(){return C(X,()=>d,()=>d),c}function Q(){const e=s(i=>i.uiReady),o=s(i=>i.bootDetail),t=s(i=>i.bootProgress),l=s(i=>i.themeReady);N();const n=S("LoadingScreen",I),g=W();return e||!l?null:r(n,{overlay:!0,message:g("loading.message","Loading your configurator\u2026"),detail:o,progress:t})}function Z(){const{ready:e,error:o}=J(),t=C(z,h,h);return u(()=>{o&&m()},[o]),u(()=>{t||m()},[t]),!t&&!o?.unlicensed?r(w,{message:V()}):o?o?.unlicensed?r(w,{message:o.message}):r(E,{title:o?.title||"Could not load the configurator.",body:o?.body,fix:o?.fix,reason:o?.reason||"error",onRetry:o?.code==="network"?()=>window.location.reload():null}):e?r(B,{}):null}function j(){const[e,o]=k(null);u(()=>{let n=!0;const g=P();return L(),typeof y.getToken=="function"&&_(y.getToken),x().then(i=>n?i?K():(o(!1),null):null).then(i=>{!n||i===null||o(!!i)}).catch(()=>{n&&o(!1)}),()=>{n=!1}},[]),u(()=>{const n=setTimeout(()=>M(),q);return()=>clearTimeout(n)},[]),u(()=>{const n=setTimeout(()=>m(),F);return()=>clearTimeout(n)},[]);const t=r(U.Provider,{value:{isAvailable:!!e},children:r(Z,{})}),l=e===null?null:e?r(v,{fallback:null,children:r(G,{showDevConsole:!1,enableInspector:!1,runtimeUrl:O(),headers:A,children:t})}):t;return re(te,{children:[l,r(Q,{})]})}function ee(){const e=typeof window<"u"?window.location.pathname:"",o=R(e);if(o)return r(o,{});if(e==="/ar-viewer"||e.endsWith("/ar-viewer")){const t=S("ARViewer",H);return r(v,{fallback:null,children:r(t,{})})}return r(j,{})}function oe(){const e=typeof window<"u"?window.location.pathname:"";return!(R(e)||e==="/ar-viewer"||e.endsWith("/ar-viewer"))}function Se(e,o={}){const t=typeof e=="string"?document.querySelector(e):e;if(t&&typeof t.setAttribute=="function"&&t.setAttribute("data-imagine-root",""),!t)throw new Error(`mountConfigurator: target not found: ${e}`);y=o;const l=oe();l&&Y(o);const n=T.createRoot(t);return n.render(ee()),{unmount:()=>{l&&$(),n.unmount()}}}export{Se as mountConfigurator};
|
package/dist/2b6aa27f6d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as s,jsxs as n}from"react/jsx-runtime";import{useState as Q}from"react";import{useLabels as V}from"./28d887bf8a.js";import X from"./8f60e5059a.js";import S from"./872c4302e0.js";import Y from"./d94df858ea.js";import Z from"./bdec200d00.js";import{optionRecordFrom as ee,optionsForSetFrom as se}from"./4a99ddb3fd.js";import{currentOptionIdFor as oe,readCurrentOptionInputs as te}from"./2c7c1bcef1.js";import{getPlacementBindings as ne}from"./817d930a49.js";import ae from"./9794652102.js";import
|
|
1
|
+
import{jsx as s,jsxs as n}from"react/jsx-runtime";import{useState as Q}from"react";import{useLabels as V}from"./28d887bf8a.js";import X from"./8f60e5059a.js";import S from"./872c4302e0.js";import Y from"./d94df858ea.js";import Z from"./bdec200d00.js";import{optionRecordFrom as ee,optionsForSetFrom as se}from"./4a99ddb3fd.js";import{currentOptionIdFor as oe,readCurrentOptionInputs as te}from"./2c7c1bcef1.js";import{getPlacementBindings as ne}from"./817d930a49.js";import ae from"./9794652102.js";import le from"./54413c1eae.js";import{resolveComponent as d,useComponentRegistry as O}from"./882bc739c8.js";import re from"./37596ace72.js";import ie from"./26155bf68c.js";import ce from"./2cab5c5c23.js";import{LogoIcon as ue,ChevronLeft as me,ChevronRight as pe}from"./c5e990946e.js";import{useHasIcon as de}from"./09c4973968.js";import{useShellModel as he,useEffectiveSelections as fe,CopilotActionsRegister as we,ShellModals as ve,ShellAssistants as _e}from"./c71892453b.js";import{resolveAssetUrl as be}from"./cec035efb1.js";import"./4910c07ca8.css";function ge({Scene:h}){return s(Se,{Scene:h})}function Se({Scene:h}){O();const P=d("Sidebar",Z);O();const B=d("SceneToolbar",le),E=d("GenerateAssetsButton",ie),F=d("SaveProjectButton",ce),{regions:f,isLayoutLoading:u,copilotAvailable:L,handleGenerateAssets:x,isGenerating:G,systemName:R,priceText:U,itemPriceText:w,focusedPlacementId:m,steps:$,stepsScope:ye,productOptionSetCount:Ne,selectedPlacementId:Ce}=he(),j=de("logo"),H=X(e=>e.isMobile),r=V(),v=r("showcase.heading1","Customize"),_=r("showcase.heading2","your design"),y=r("showcase.intro","Select your options below \u2014 the preview updates as you go."),N=S(e=>e.options),C=S(e=>e.materials),c=S(e=>e.features),J=Y(e=>e.sceneSelections),A=$.filter(e=>!e.isSummary),[k,T]=Q(null),b=k!=null?A.find(e=>e.key===k)??null:null,Ae=fe(m),I=e=>{const o=Array.isArray(e)?e[0]:e,a=c?.[o]??c?.[String(o)]??null;if(!a)return null;const l=m!=null&&ne(m)||null,i=se(a,{features:c,options:N,bindings:l}),t=oe({placementId:m,set:a,opts:i,inputs:{...te(),sceneSelections:J}});return t==null?null:ee(a,t,{features:c,options:N,bindings:l})??i.find(p=>String(p?.id)===String(t))??null},K=e=>{const o=I(e);return o?o.name??o.label??o.title??null:null},M=e=>typeof e=="string"&&e?/^https?:|^\//.test(e)?e:`/${e}`:null,z=e=>{if(e==null)return null;if(typeof e=="number")return"#"+e.toString(16).padStart(6,"0");if(typeof e=="string"){const o=e.trim();return/^[0-9a-fA-F]{3}$/.test(o)||/^[0-9a-fA-F]{6}$/.test(o)?"#"+o:o}return null},W=e=>{const o=I(e);if(!o)return null;const a=Array.isArray(e)?e[0]:e,l=c?.[a]||c?.[String(a)],t=/finish/i.test(String(l?.type||""))&&(C?.[o.value]||C?.[String(o.value)])||null,p=o.thumbnail??t?.thumbnail??t?.thumbnailUrl??t?.thumbnail_url,g=t?.textures?.diffuse??t?.diffuseMap??t?.diffuse_map??t?.materialJson?.map,q=be(M(p)||M(g)||null,{kind:"thumbnail"}),D=t?.color??t?.materialJson?.color??o.color??o.color_hex??o.metadata?.color_hex;return{src:q,color:z(D)}};return n("div",{className:"showcase-layout",children:[s(ae,{}),L&&s(we,{}),f.sidebar&&s("aside",{className:"showcase-panel",style:u?{opacity:.6,pointerEvents:"none"}:void 0,children:b?n("div",{className:"showcase-detail",children:[n("button",{type:"button",className:"showcase-back",onClick:()=>T(null),children:[s(me,{})," ",s("span",{children:r("showcase.allOptions","All options")})]}),s("h2",{className:"showcase-detail__title",children:b.label}),s("div",{className:"showcase-detail__body",children:s(P,{embedded:!0,backHeader:!1,filterFeatureIds:b.featureIds})})]}):n("div",{className:"showcase-master",children:[n("div",{className:"showcase-brand",children:[j?s(ue,{className:"showcase-logo"}):null,s("span",{className:"showcase-brand__name",children:R})]}),v||_?n("h1",{className:"showcase-heading",children:[s("span",{className:"showcase-heading__line1",children:v}),v&&_?" ":null,s("span",{className:"showcase-heading__line2",children:_})]}):null,y?s("p",{className:"showcase-sub",children:y}):null,s("div",{className:"showcase-rows",children:A.map(e=>{const o=K(e.featureIds),a=!!o,l=a?W(e.featureIds):null,i=!l?.src&&!!l?.color,t=a&&!i;return n("button",{type:"button",className:"showcase-row",onClick:()=>T(e.key),disabled:u,children:[n("span",{className:`showcase-row__preview${a?i?"":" showcase-row__preview--mono":" showcase-row__preview--empty"}`,style:i?{background:l.color}:void 0,children:[t&&s("span",{className:"showcase-row__preview-initial",children:(o.trim()[0]||"?").toUpperCase()}),l?.src&&s("img",{src:l.src,alt:"",onError:g=>{g.currentTarget.style.display="none"}}),!a&&s("svg",{className:"showcase-row__preview-plus",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:s("path",{d:"M8 3.25v9.5M3.25 8h9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})]}),n("span",{className:"showcase-row__text",children:[s("span",{className:"showcase-row__label",children:e.label}),s("span",{className:"showcase-row__value",children:o||r("showcase.select","Select")})]}),s(pe,{className:"showcase-row__chev"})]},e.key)})}),n("div",{className:"showcase-foot",children:[n("div",{className:"showcase-foot__price",children:[(w?r("shell.itemPrice","ITEM PRICE"):r("shell.total","TOTAL"))?s("span",{className:"showcase-foot__label",children:w?r("shell.itemPrice","ITEM PRICE"):r("shell.total","TOTAL")}):null,s("strong",{className:"showcase-foot__value",children:w||U})]}),n("div",{className:"showcase-foot__actions",children:[s(F,{disabled:u,className:"showcase-save"}),s(E,{onClick:x,isGenerating:G,disabled:u,className:"showcase-cta"})]})]})]})}),n("main",{className:"showcase-scene",children:[s(h,{isMobile:H}),f.toolbar&&s(B,{variant:"desktop"}),f.notifications&&s(re,{}),s(_e,{})]}),s(ve,{})]})}var Ve=ge;export{Ve as default};
|
package/dist/2cafe3274b.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import I from"./8f60e5059a.js";import D from"./9c6c598569.js";import x from"./d94df858ea.js";import S from"./1fac915f8b.js";import y,{deriveSceneFeatures as C}from"./be337ddda5.js";import{runCommand as d,COMMANDS as f}from"./d6851ea979.js";import{runIntent as P,INTENTS as H}from"./6d238282c1.js";import{UI_REGIONS as m}from"./9840b9ce12.js";import{readPieceFrame as M}from"./da7b5f450d.js";import{clearSceneLoadingAfterRender as E}from"./2774152dd2.js";const o=()=>I.getState(),s=()=>D.getState(),l=()=>o().selectedPieceIndex;function b(e=400){import("./a77b15c0d6.js").then(({refreshCanonicalState:t})=>setTimeout(()=>t(),e)).catch(()=>{})}const v=e=>s().selectInstance?.(e!=null?String(e):null),B=v,j=e=>s().selectInstance?.(e!=null?String(e):null),Q=()=>{s().clearSelection?.(),o().clearSelectedFeature()},q=()=>s().selectedInstanceId??l(),$=(e,t)=>o().setSelectedFeature(e,t),z=()=>d(f.MOVE_LEFT),J=()=>d(f.MOVE_RIGHT),K=()=>d(f.DUPLICATE),X=()=>d(f.DELETE),Z=()=>d(f.ADD_CABINET),Y=()=>d(f.OPEN_FINISH);function ee(e){const t=l();return t==null?!1:(o().setHostWidth(t,e),!0)}function te(e,t){const r=l();return r==null?!1:(o().setHostFinish(r,e,t),!0)}function oe(e){const t=l();return t==null?!1:(o().setHostStyle(t,e),!0)}function re(e){const t=l();return t==null?!1:(o().setHostHandleType(t,e),!0)}function ne(e){const t=l();return t==null?!1:(o().setHostHardwareFinish(t,e),!0)}function ce(e,t,r){const n=l();return n==null?!1:(o().setHostDoorType(n,e,t,r),!0)}function se(e){const t=l();return t==null?!1:(o().setHostProductOverride(t,e),!0)}function h(e){const t=o(),r=typeof e=="boolean"?e:!t.is3D;return t.is3D===r?!1:(t.setSceneLoading?.(!0,`Switching to ${r?"3D":"2D"}...`),s().setCameraPosition?.(r?[4,4,6]:[0,10,.1]),t.toggleView(),E(),!0)}const ae=()=>h(!1),ie=()=>h(!0),le=()=>h(),ue=()=>o().is3D,pe=()=>o().toggleDimensions(),de=()=>o().toggleWalls(),fe=()=>o().toggleFloor(),Se=()=>o().toggleCeiling(),ge=()=>s().resetCameraToDefault(),xe=e=>s().setCameraPreset(e),me=(e,t,r)=>{if(Array.isArray(e))return s().focusOnObject(e,Number.isFinite(t)?t:1,r),!0;const n=M(e);return n?(s().focusOnObject(n.center,Number.isFinite(t)?t:n.radius,r??n.facingY),!0):!1};async function he(e){if(e==null)return!1;const r=y.getState().sceneConfigurations?.[s().activeSceneConfigId],n=C(r);let a=!1;try{const{executeLayoutChange:p}=await import("./9526094bb7.js");a=p(e,n)}catch{return!1}const c=n.find(p=>p.type==="layout_change");return c&&x.getState().setSceneSelection(c.id,e),b(),a}const ye=e=>o().setRoomFootprint(e),w=()=>P({type:H.QUOTE_OPEN},()=>{try{o().openModal?.("quote")}catch{}}),Pe=(e={})=>{const{waitForImages:t=!1,generate:r=!1,timeoutMs:n,onProgress:a}=e;return!t&&!r?w():(async()=>{try{const c=await import("./5d05e8982e.js"),p=r===!0?["silo","lifestyle"]:Array.isArray(r)?r:r?[r]:[];if(p.length){const u={silo:c.generateSilo,lifestyle:c.generateLifestyle,ar:c.generateAr,pdf:c.generateBomPdf};await Promise.all(p.map(g=>{const i=u[g];return i?i({timeoutMs:n,onProgress:a}).catch(T=>{}):null}).filter(Boolean))}else{const u=c.generationStatus?.()??null,g=u?[...u.silo??[],...u.lifestyle??[],u.ar,u.pdf].filter(i=>i&&i.status==="generating").map(i=>i.id):[];g.length&&await c.waitForAssets(g,{timeoutMs:n,onProgress:a}).catch(i=>{})}}catch{}return w()})()},L=e=>{try{o().setRegions?.(e)}catch{}},F=(e,t)=>{const r=t.length===0?m:t.flat().filter(c=>typeof c=="string");r.filter(c=>!m.includes(c)).length;const a={};for(const c of r)m.includes(c)&&(a[c]=e);Object.keys(a).length&&L(a)},He=(...e)=>F(!1,e),we=(...e)=>F(!0,e),Fe=e=>{try{o().showInfo?.(e)}catch{}},Ie=(...e)=>{try{o().setSceneLoading?.(...e)}catch{}},De=()=>{try{o().clearSceneLoading?.()}catch{}},Ce=e=>{try{o().setPendingSlotPlacement?.(e)}catch{}},Me=()=>{try{o().clearPendingSlotPlacement?.()}catch{}},Ee=()=>{try{o().clearDeferredHostedProductPlacement?.()}catch{}},be=(...e)=>{try{return o().setHostedProductFeatureForSlot?.(...e)}catch{return}},ve=(...e)=>{try{return o().updateHostedProductSlotForProduct?.(...e)}catch{return}},Le=()=>{try{s().clearSelection?.()}catch{}},Te=e=>{try{s().removeProductInstance?.(e)}catch{}},Oe=(e,t)=>{try{s().updateInstanceVariant?.(e,t)}catch{}},Re=(e,t)=>{try{x.getState().setSceneSelection?.(e,t)}catch{}},Ae=()=>S.getState().undo(),Ue=()=>S.getState().redo(),_e=()=>S.getState().clearHistory(),Ne=()=>(S.getState().past?.length||0)>0,Ve=()=>(S.getState().future?.length||0)>0,Ge=()=>P({type:H.SCENE_RESET},()=>s().resetScene()),ke=e=>o().removeHostedProduct(e),We=()=>o().clearHostedProducts(),Be=e=>o().addHostedProduct(e),je=(e,t)=>o().setPendingHostedProduct(e,t),Qe=()=>o().clearPendingHostedProduct(),qe=(e,t,r,n,a)=>o().placeHostedProductAtPiece(e,t,r,n,a),$e=()=>o().toggleSidebar(),ze=e=>o().setSidebarTab(e),Je=(e,t)=>o().openModal(e,t),Ke=()=>o().closeModal(),Xe=e=>o().addNotification(e),Ze=e=>o().setGuiVisible(e);async function Ye(){const{buildSceneSnapshot:e}=await import("./7f833bc5af.js");return e()}async function et(e){const{restoreSceneSnapshot:t}=await import("./7f833bc5af.js");return t(e)}async function tt(e){const{default:t}=await import("./ee9b9fd7d1.js");return t.copyShareUrl(e)}async function ot(e){const{default:t}=await import("./ee9b9fd7d1.js");return t.generateShareUrl(e)}async function rt(e){if(!e)return null;const{exportModel:t}=await import("./f7b4a178e3.js");return new Promise((r,n)=>{t({model:e,callBack:r}).catch(n)})}async function nt(e){const{generateARModel:t}=await import("./f7b4a178e3.js");return t(e)}async function ct(e){return e?(await import("./ee242c0099.js")).loadDomainDefaults(e):null}async function st(e){const{preloadMaterials:t}=await import("./c44d37da7a.js");return t(e)}async function at(){const{prefetchRemainingMaterialsWhenIdle:e}=await import("./c44d37da7a.js");return e()}async function it(e){const{setFinishPrefetch:t}=await import("./c44d37da7a.js");return t(e)}async function lt(){const{default:e}=await import("./ee9b9fd7d1.js");return e.parseUrlConfig()}async function ut(e){if(!e)return null;const{default:t}=await import("./ee9b9fd7d1.js");return t.restoreFromConfig(e,{configurationGraphStore:y,sceneConfigStore:x})}export{Be as addHostedProduct,Z as addPiece,Ve as canRedo,Ne as canUndo,he as changeLayout,Ee as clearDeferredHostedProductPlacement,_e as clearHistory,We as clearHostedProducts,Qe as clearPendingHostedProduct,Me as clearPendingSlotPlacement,De as clearSceneLoading,Le as clearSceneSelection,Ke as closeModal,tt as copyShareUrl,X as deleteSelected,Q as deselect,K as duplicateSelected,rt as exportModelGLB,me as focusOnObject,nt as generateAR,q as getSelectedProduct,ot as getShareUrl,He as hideUI,ue as isView3D,ct as loadDomainDefaults,z as moveSelectedLeft,J as moveSelectedRight,Xe as notify,Y as openFinishSelector,Je as openModal,Pe as openQuote,lt as parseShareLink,qe as placeHostedProductAtHost,at as prefetchRemainingMaterialsWhenIdle,st as preloadMaterials,Ue as redo,ke as removeHostedProduct,Te as removeSceneInstance,ge as resetCamera,Ge as resetScene,et as restoreSceneSnapshot,ut as restoreShareLink,j as selectAppliance,$ as selectFeature,B as selectPiece,v as selectProduct,xe as setCameraPreset,it as setFinishPrefetch,Ze as setGuiVisible,be as setHostedProductFeatureForSlot,je as setPendingHostedProduct,Ce as setPendingSlotPlacement,ye as setRoomFootprint,Oe as setSceneInstanceVariant,Ie as setSceneLoading,Re as setSceneSelection,ce as setSelectedDoorType,te as setSelectedFinish,re as setSelectedHandle,ne as setSelectedHardwareFinish,se as setSelectedProduct,oe as setSelectedStyle,ee as setSelectedWidth,ze as setSidebarTab,L as setUIRegions,h as setViewMode,Fe as showInfo,we as showUI,Ye as snapshotScene,Se as toggleCeiling,pe as toggleDimensions,fe as toggleFloor,$e as toggleSidebar,le as toggleView,de as toggleWalls,Ae as undo,ve as updateHostedProductSlotForProduct,ae as view2D,ie as view3D};
|
package/dist/371ed78aa2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getApiBaseUrl as F}from"./8ade32d067.js";import{describeBootFailure as K,probeBackendReachable as N,warnIntegrator as q}from"./05973a4da2.js";import{adoptUrlCredentials as J}from"./1fff100656.js";import Q from"./872c4302e0.js";import f from"./be337ddda5.js";import X from"./9c6c598569.js";import i from"./8f60e5059a.js";import
|
|
1
|
+
import{getApiBaseUrl as F}from"./8ade32d067.js";import{describeBootFailure as K,probeBackendReachable as N,warnIntegrator as q}from"./05973a4da2.js";import{adoptUrlCredentials as J}from"./1fff100656.js";import Q from"./872c4302e0.js";import f from"./be337ddda5.js";import X from"./9c6c598569.js";import i from"./8f60e5059a.js";import b from"./1fac915f8b.js";import{recomputePrice as A}from"./67f6338a4a.js";import{setUseMobileTextures as Y}from"./c44d37da7a.js";import{initIframeMessageService as Z}from"./1e243363f6.js";import{whenPiecePositionsReady as ee,waitForAssetsIdle as D}from"./2774152dd2.js";import{applyLayoutSceneSelections as te,applyLayoutStyling as ae}from"./37addc7fb3.js";import{setTokenProvider as ne}from"./33fa2c8ca2.js";import{hideUI as G}from"./2cafe3274b.js";import{UI_REGIONS as k}from"./9840b9ce12.js";const be="This configurator is unavailable.";function ke({resolveInitialSystemId:W,resolveConfigurator:v,resolveConfiguratorKey:R,resolveInitialChannelId:B,getToken:T,onReady:M,onError:P}={}){typeof T=="function"&&ne(T);let s=!1,w=null;return(async()=>{const u=await import("./a77b15c0d6.js"),C=B?.();C!=null&&u.setChannelId?.(C),import.meta.env?.DEV&&!window.__sdkEventLoggerRegistered&&(window.__sdkEventLoggerRegistered=!0,u.on?.("*",n=>{}));let m=W?.();const y=J().shareToken;y&&u.setShareToken?.(y);let r=null;if(y)try{r=await u.loadProject(y);const n=r?.system?.id??r?.system??r?.scene_snapshot?.canonical?.systemId??null;n!=null&&(m=n);try{const d=(r?.scene_snapshot??r?.sceneSnapshot??null)?.theme??null,o=d?.systemThemeRecord??d?.systemTheme??null;if(o!=null){const{applySystemTheme:h}=await import("./5c9fd9201c.js");h(o),i.setState({themeReady:!0})}}catch{}}catch{}const{checkConfiguratorLicence:x,getConfiguratorBlockedMessage:$}=await import("./3bbcee0334.js"),H=await x({systemId:m});if(s)return;if(!H){i.getState().markUiReady?.(),P?.($(),{code:"unlicensed"});return}try{const{refreshEntitlements:n}=await import("./32861ea2b0.js");n().catch(()=>{})}catch{}try{const{ui:n,sceneCapabilities:c}=v?.(m)||{};n&&Object.keys(n).length&&i.setState(n),c&&i.setState({sceneCapabilities:c});const d=R?.(m);d!=null&&f.setState({configuratorKey:d}),i.setState({showWalls:!!c?.walls})}catch{}let L=!1;try{const{prepareTheme:n}=await import("./be0cfe2236.js");L=await n(m)}catch{}if(!s)try{try{await u.loadConfigurator(m)}catch(e){if(e?.status===401||e?.status===403||e?.status===404)throw e;await Q.getState().loadCatalog({systemId:m}),await f.getState().loadConfigurations(m);const t=f.getState(),a=t.systemDomainDefaults??t.systemRoom?.domain_defaults??null;a&&await u.loadDomainDefaults(a)}try{const e=f.getState(),t=e.systemId??m,a=v?.(t)||{};a.ui&&Object.keys(a.ui).length&&i.setState(a.ui);const l=!!e.systemRoom;i.setState({sceneCapabilities:{dimensions:l,walls:l},showWalls:l});const p=R?.(t);p!=null&&f.setState({configuratorKey:p})}catch{}if(!L)try{const{applySystemTheme:e}=await import("./5c9fd9201c.js");let t=null,a=!1;try{const S=new URLSearchParams(window.location.search);S.has("theme")&&(t=S.get("theme"),a=!0)}catch{}if(!a)for(let S=0;S<20;S+=1){const O=f.getState();if(t=O.systemThemeRecord??O.systemTheme,t!=null||s)break;await new Promise(z=>setTimeout(z,100))}if(s)return;const l=typeof document<"u"&&!!document.documentElement.getAttribute("data-theme-id"),p=typeof t=="string"&&/^\d+$/.test(t.trim()),V=l&&p&&!a;(t!=null||a)&&!V&&e(t)}catch{}if(s)return;i.setState({themeReady:!0});const n="ontouchstart"in window||navigator.maxTouchPoints>0,c=Math.min(window.innerWidth,window.innerHeight)<768;Y(n&&c);const d=r?null:await u.parseShareLink(),o=f.getState().sceneConfigurations,h=f.getState().defaultPresetId;let _=h!=null&&o[h]?h:null;_||(_=Object.values(o||{})[0]?.id);const I=r?.scene_snapshot?._state?.sceneGraph?.activeSceneConfigId,g=I!=null&&o[I]?I:d?.sc||_;u.preloadMaterials(o[g]),X.getState().initializeScene(g);try{const{applySceneConfigDefaults:e}=await import("./a77b15c0d6.js");e(g)}catch{}te(o[g]),ae(o[g]),!r&&d&&await u.restoreShareLink(d);const U=new URLSearchParams(window.location.search),E=U.get("gui");(E==="false"||E==="0")&&i.getState().setGuiVisible(!1);const j=U.get("hide");if(j){const e=j.split(",").map(t=>t.trim()).filter(Boolean);if(e.includes("all"))G();else{const t=e.filter(l=>k.includes(l)),a=e.filter(l=>!k.includes(l)&&l!=="all");a.length&&console.warn(`[sdk] ?hide= ignored unknown region(s): ${a.join(", ")}. Known regions: ${k.join(", ")}, or "all".`),t.length&&G(t)}}A(),b.getState().clearHistory(),Z(),import("./a77b15c0d6.js").then(({initConfigEngine:e})=>e()).catch(()=>{}),(()=>{if(s)return;i.setState({bootEvaluating:!0});const e=b.getState();e.pauseTracking();let t=!1;const a=()=>{t||(t=!0,i.setState({bootEvaluating:!1}),e.resumeTracking())};D().then(()=>{if(s){a();return}import("./a77b15c0d6.js").then(async({seedInitialState:l,reevaluateForFocus:p})=>{await l(),!s&&await p()}).catch(()=>{}).finally(()=>{a(),u.prefetchRemainingMaterialsWhenIdle?.()})}).catch(a)})(),M?.(),setTimeout(()=>{s||i.getState().markUiReady?.()},2500),r?(i.setState({isLayoutLoading:!0}),i.getState().setSceneLoading(!0,"Loading your saved design..."),w=ee(async()=>{s||(await u.restoreProject(r),A(),D().then(()=>{if(s)return;i.getState().setInitialPerPieceOverrides(),i.setState({isLayoutLoading:!1}),i.getState().clearSceneLoading(),b.getState().clearHistory();const e=r?.scene_snapshot?.canonical||null;import("./a77b15c0d6.js").then(({restoreConfiguration:t,refreshCanonicalState:a})=>e?t(e):a()).catch(()=>{})}))})):i.getState().setInitialPerPieceOverrides()}catch(n){i.getState().markUiReady?.();const c=n?.status,d=c==null?await N(F()):null,o=K(n,{reachable:d});q(o,n);const h=o.code==="unavailable"?"unavailable":c===401||c===403?"unauthorized":c===404?"unavailable":"network";P?.(`${o.title} ${o.body}`,{code:h,reason:o.code,title:o.title,body:o.body,fix:o.fix,status:c,cause:n})}})(),{cancel(){s=!0,w&&w()}}}export{be as ORG_UNAVAILABLE_MESSAGE,ke as bootConfigurator};
|
package/dist/4910c07ca8.css
CHANGED
|
@@ -122,12 +122,16 @@
|
|
|
122
122
|
.showcase-brand__name { font-size: 13px; font-weight: 600; letter-spacing: 0.4px; color: var(--sc-ink); }
|
|
123
123
|
|
|
124
124
|
.showcase-heading {
|
|
125
|
-
|
|
125
|
+
/* The gap between the title and the line under it — theme-reachable for the same reason
|
|
126
|
+
the size is. Fallback is the shell's own spacing, so an unset theme is unchanged. */
|
|
127
|
+
margin: 0 0 var(--showcase-heading-gap, 16px);
|
|
126
128
|
/* Theme-reachable (beta intake F-16): a record's typography used to apply everywhere
|
|
127
129
|
except the most prominent text on the page. Literal stack stays as the fallback. */
|
|
128
130
|
font-family: var(--font-family-heading, var(--font-family-base, Georgia, 'Times New Roman', 'Playfair Display', serif));
|
|
129
131
|
font-weight: 500;
|
|
130
|
-
|
|
132
|
+
/* Theme-reachable, like the family above it. The fallback is the shell's own size, so a
|
|
133
|
+
theme that says nothing about it looks exactly as it did. */
|
|
134
|
+
font-size: var(--showcase-heading-size, 40px);
|
|
131
135
|
/* Georgia has deep descenders — a 1.1 line-height clipped the tails of "your
|
|
132
136
|
piece". Give the line box room + a hair of descender padding so glyphs never
|
|
133
137
|
touch the box edge. */
|
|
@@ -136,9 +140,16 @@
|
|
|
136
140
|
letter-spacing: -0.2px;
|
|
137
141
|
color: var(--sc-ink);
|
|
138
142
|
}
|
|
143
|
+
/* ONE LINE OR TWO, as a theme setting rather than a hardcoded break.
|
|
144
|
+
`block` on the first line pushes the second onto its own; `inline` lets them run on with
|
|
145
|
+
the space between the spans. theme6's quieter header defaults to one line, theme4 to two,
|
|
146
|
+
and an explicit setting (--showcase-title-line1) overrides either. */
|
|
147
|
+
.showcase-heading__line1 { display: var(--showcase-title-line1, block); }
|
|
148
|
+
:root[data-theme-preset="theme6"] .showcase-heading__line1 { display: var(--showcase-title-line1, inline); }
|
|
149
|
+
|
|
139
150
|
.showcase-sub {
|
|
140
|
-
margin: 0 0 34px;
|
|
141
|
-
font-size: 14px;
|
|
151
|
+
margin: 0 0 var(--showcase-sub-gap, 34px);
|
|
152
|
+
font-size: var(--showcase-sub-size, 14px);
|
|
142
153
|
line-height: 1.55;
|
|
143
154
|
color: var(--sc-ink-soft);
|
|
144
155
|
max-width: 34ch;
|
|
@@ -383,7 +394,7 @@
|
|
|
383
394
|
============================================================================ */
|
|
384
395
|
@media (max-width: 768px) {
|
|
385
396
|
.showcase-layout { flex-direction: column; }
|
|
386
|
-
.showcase-scene { order: -1; flex: 0 0
|
|
397
|
+
.showcase-scene { order: -1; flex: 0 0 50vh; min-height: 0; }
|
|
387
398
|
.showcase-panel {
|
|
388
399
|
flex: 1 1 auto;
|
|
389
400
|
width: auto;
|
|
@@ -410,8 +421,14 @@
|
|
|
410
421
|
.showcase-master { min-height: 0; flex: 1 1 auto; }
|
|
411
422
|
/* Compress the hero so the first option rows peek above the fold. */
|
|
412
423
|
.showcase-brand { margin-bottom: 14px; }
|
|
413
|
-
|
|
414
|
-
|
|
424
|
+
/* The compressed size is the FALLBACK, not an override: a theme that sets a title size
|
|
425
|
+
means it at every width, and hardcoding the number here made the setting look broken to
|
|
426
|
+
anyone whose window — or whose Studio panel — was under 768px. */
|
|
427
|
+
.showcase-heading {
|
|
428
|
+
font-size: var(--showcase-heading-size, 26px);
|
|
429
|
+
margin-bottom: var(--showcase-heading-gap, 8px);
|
|
430
|
+
}
|
|
431
|
+
.showcase-sub { margin-bottom: var(--showcase-sub-gap, 16px); max-width: none; }
|
|
415
432
|
.showcase-detail__title { font-size: 24px; }
|
|
416
433
|
.showcase-foot { padding-top: 18px; }
|
|
417
434
|
.showcase-cta { height: 46px; }
|
package/dist/4e7d0a0d4a.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as o from"three";const t={ACESFilmic:o.ACESFilmicToneMapping,Reinhard:o.ReinhardToneMapping,Linear:o.LinearToneMapping,None:o.NoToneMapping,Cineon:o.CineonToneMapping},d={PCF:o.PCFSoftShadowMap,PCFSoft:o.PCFSoftShadowMap,PCFHard:o.PCFShadowMap,VSM:o.VSMShadowMap,Basic:o.BasicShadowMap},M={toneMapping:o.NoToneMapping,exposure:1,shadowMapType:o.PCFSoftShadowMap};function r(a,p){if(!a||!p)return;if(a.tone_mapping||a.toneMapping){const n=a.tone_mapping??a.toneMapping,s=t[n];s!=null&&(p.toneMapping=s)}const e=a.exposure,i=e!=null&&e!==""?Number(e):NaN;if(p.toneMappingExposure=Number.isFinite(i)?i:M.exposure,a.shadows&&(typeof a.shadows.enabled=="boolean"&&(p.shadowMap.enabled=a.shadows.enabled),a.shadows.type)){const n=d[a.shadows.type];n!=null&&(p.shadowMap.type=n),p.shadowMap.needsUpdate=!0}}export{M as RENDERER_DEFAULTS,r as applyEnvironmentToRenderer};
|
package/dist/5c9fd9201c.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const D=new Set(["theme2","theme3"]),A=new Set(["default","theme1"]),J=new Set(["theme2","theme3","theme4","theme5"]);import{useEffect as Q}from"react";import{markHostTheme as X,isHostThemeApplied as Y,_resetHostTheme as Z}from"./40d6aeb28c.js";import{validateTheme as tt,checkThemeContrast as et,applyCustomCss as P,applyFontUrl as U}from"./b1349d5a21.js";import{setThemeLabels as rt,setLocale as ot}from"./28d887bf8a.js";import nt from"./79a397bb92.js";import W from"./be337ddda5.js";const j={none:"none",sm:"0 1px 2px rgba(0,0,0,0.08)",md:"0 4px 12px rgba(0,0,0,0.12)"},st=new Set(["Inter","Playfair Display","Nunito","Poppins","Roboto","Lato","Montserrat","Merriweather","Open Sans","Raleway","Work Sans"]),it=["--color-primary","--color-primary-dark","--color-secondary","--color-accent","--color-brand-primary","--color-brand-primary-dark","--color-brand-primary-light","--color-brand-primary-rgb","--color-brand-accent","--color-background","--color-foreground","--color-surface","--color-border","--sidebar-width","--sidebar-content-padding","--radius-xl","--thumbnail-border-radius","--btn-height-md","--thumbnail-gap","--font-size-md","--sidebar-section-title-size","--font-size-2xl","--showcase-heading-size","--showcase-sub-size","--showcase-title-line1","--showcase-heading-gap","--showcase-sub-gap","--sidebar-section-title-weight","--font-family-base","--font-family-heading","--btn-border-radius","--btn-shadow","--layout-density","--brand-logo-url","--bg-primary","--bg-secondary","--bg-tertiary","--bg-muted","--text-primary","--text-primary-rgb","--text-secondary","--text-tertiary","--border-default","--border-light","--border-dark"];function wt(e,t){Q(()=>{let r=t??e,o=!1;try{const s=new URLSearchParams(window.location.search);s.has("theme")&&(r=s.get("theme"),o=!0)}catch{}r==null&&!o||ut(r,{force:o})},[e,t])}function S(e){return e?String(e).trim().toLowerCase():""}function at(e){return D.has(S(e))?"dark":"light"}function N(e){if(e==null)return null;if(typeof e=="string")return e.trim().toLowerCase()||null;if(typeof e=="object"){const t=e.layout??e.layoutKey??e.uiTemplate??e.ui_template??null;if(t){const o=String(t).trim().toLowerCase().replace(/[\s_-]+/g,"");if(o)return o}const r=e.name??e.themeName??e.key??null;if(r){const o=String(r).trim().toLowerCase().replace(/[\s_-]+/g,"");if(o)return o}if(e.id!=null)return`theme${e.id}`}return null}function ct(e){X(),v(e),lt(e)}function lt(e){let t;if(e==null||e===""||typeof e=="string"&&A.has(S(e)))t={systemTheme:null,systemThemeRecord:null};else if(typeof e=="string")t={systemTheme:S(e).replace(/[\s_-]+/g,""),systemThemeRecord:null};else if(typeof e=="object")t={systemTheme:N(e),systemThemeRecord:e};else return;try{const r=W.getState();if(r.systemTheme===t.systemTheme&&r.systemThemeRecord===t.systemThemeRecord)return;W.setState(t)}catch{}}async function St(e){if(e==null||e==="")return null;let t=null;try{t=await nt.fetchTheme(e)}catch{return null}return!t||typeof t!="object"?null:(ct(t),t)}function ut(e,{force:t=!1}={}){Y()&&!t||v(e)}function Tt(){Z()}function v(e){const t=typeof document<"u"?document.documentElement:null;if(t){if(e&&typeof e=="object"){const{errors:r,warnings:o}=tt(e),s=et(e);if(!s.pass){const y=s.results.filter(f=>!f.pass).map(f=>`${f.pair} = ${f.ratio??"?"}:1 (needs ${f.min}:1)`).join(", ")}rt(e.labels),e.locale&&ot(e.locale)}if(e==null||e===""||typeof e=="string"&&A.has(S(e))){L(t);return}if(typeof e=="string"){L(t);const r=S(e).replace(/[\s_-]+/g,"");r&&!A.has(r)&&(t.setAttribute("data-theme",r),t.setAttribute("data-theme-preset",r),t.setAttribute("data-theme-mode",at(r)));return}if(typeof e=="object"){L(t);const r=e.colorTokens??e.color_tokens??{},o=e.typographyTokens??e.typography_tokens??{},s=e.layoutDensity??e.layout_density,y=e.logoUrl??e.logo_url,f=e.faviconUrl??e.favicon_url,g=e.config||{},i=g.colors||{},T=N(e);T&&t.setAttribute("data-theme",T),e.id!=null&&t.setAttribute("data-theme-id",String(e.id));const E=String(e.name??e.themeName??e.key??"").trim().toLowerCase().replace(/[\s_-]+/g,"");J.has(E)&&(t.setAttribute("data-theme-preset",E),D.has(E)&&t.setAttribute("data-theme-mode","dark"));const l=(w,M)=>h(w)?w.trim():h(M)?M.trim():null,p=l(i.primary,r.primary);a(t,"--color-primary",p),h(p)&&n(t,"--color-primary-dark",d(p,-.15));const $=l(i.accent,r.accent);if(a(t,"--color-accent",$),h(p)){n(t,"--color-brand-primary",p),n(t,"--color-brand-primary-dark",d(p,-.15)),n(t,"--color-brand-primary-light",d(p,.3));const w=O(p);w&&n(t,"--color-brand-primary-rgb",w),n(t,"--color-brand-accent",h($)?$.trim():p)}a(t,"--color-background",l(i.background,r.background)),a(t,"--color-surface",l(i.surface,r.surface)),a(t,"--color-foreground",l(i.text,r.foreground)),a(t,"--color-secondary",l(i.textMuted,r.secondary)),a(t,"--color-border",l(i.border,r.border));const k=l(i.surface,r.surface),_=l(i.background,r.background),x=l(i.text,r.foreground),R=l(i.textMuted,r.secondary),B=l(i.border,r.border);a(t,"--bg-primary",k??_),a(t,"--bg-secondary",_??d(k,-.04)),a(t,"--bg-tertiary",d(_??k,-.08)),a(t,"--bg-muted",d(_??k,-.02)),a(t,"--text-primary",x);const H=O(x);H&&n(t,"--text-primary-rgb",H),a(t,"--text-secondary",R??d(x,.45)),a(t,"--text-tertiary",R??d(x,.6));const F=B??d(x,.86);a(t,"--border-default",F),a(t,"--border-light",d(F,.35)),a(t,"--border-dark",d(F,-.2));const I=l(i.background,r.background),G=e.mode??r.mode??(I&&pt(I)?"dark":"light");t.setAttribute("data-theme-mode",G);const b=g.sizing||{};n(t,"--sidebar-width",c(b.cardWidth)),n(t,"--sidebar-content-padding",c(b.cardPadding)),n(t,"--radius-xl",c(b.radius)),n(t,"--thumbnail-border-radius",c(b.radius)),n(t,"--btn-height-md",c(b.controlHeight)),n(t,"--thumbnail-gap",c(b.gap));const u=g.typography||{};n(t,"--font-size-md",c(u.baseSize)),n(t,"--sidebar-section-title-size",c(u.labelSize)),n(t,"--font-size-2xl",c(u.headingSize)),n(t,"--showcase-heading-size",c(u.showcaseTitleSize)),n(t,"--showcase-sub-size",c(u.showcaseIntroSize)),n(t,"--showcase-heading-gap",c(u.showcaseTitleGap)),n(t,"--showcase-sub-gap",c(u.showcaseIntroGap));const K={one:"inline",two:"block"}[String(u.showcaseTitleLines||"").trim()];n(t,"--showcase-title-line1",K||null),n(t,"--sidebar-section-title-weight",dt(u.fontWeight));const q=z(u.fontFamily)??z(o.bodyFont),V=z(o.headingFont)??z(u.fontFamily);n(t,"--font-family-base",q),n(t,"--font-family-heading",V),C(u.fontFamily),C(o.headingFont),C(o.bodyFont);const m=g.buttons||{};n(t,"--btn-border-radius",c(m.buttonRadius)),m.shadow!=null&&j[m.shadow]!=null&&n(t,"--btn-shadow",j[m.shadow]),(m.buttonStyle==="filled"||m.buttonStyle==="outline")&&t.setAttribute("data-button-style",m.buttonStyle),s&&n(t,"--layout-density",String(s)),y&&n(t,"--brand-logo-url",`url("${y}")`),f&&ft(f),U(e.fontUrl),P(e.customCss,{nonce:e.cspNonce})}}}const c=e=>typeof e=="number"&&Number.isFinite(e)?`${e}px`:null,dt=e=>typeof e=="number"&&Number.isFinite(e)?String(e):null,h=e=>typeof e=="string"&&/^#[0-9a-f]{6}$/i.test(e.trim());function n(e,t,r){r!=null&&r!==""&&e.style.setProperty(t,r)}function a(e,t,r){h(r)&&e.style.setProperty(t,r.trim())}function z(e){if(!e||typeof e!="string")return null;const t=e.trim();return t?t.includes(",")?t:`'${t}', system-ui, sans-serif`:null}function C(e){if(typeof document>"u"||!e||typeof e!="string")return;const t=e.replace(/['"]/g,"").split(",")[0].trim();if(!st.has(t))return;const r=`gf-${t.replace(/\s+/g,"-").toLowerCase()}`;if(document.getElementById(r))return;const o=document.createElement("link");o.id=r,o.rel="stylesheet",o.href=`https://fonts.googleapis.com/css2?family=${t.replace(/\s+/g,"+")}:wght@400;500;600;700&display=swap`,document.head.appendChild(o)}function L(e){P(null),U(null),["data-theme","data-theme-mode","data-theme-preset","data-theme-id","data-button-style"].forEach(o=>e.removeAttribute(o)),it.forEach(o=>e.style.removeProperty(o));const t=e.style,r=[];for(let o=0;o<t.length;o++){const s=t[o];(s.startsWith("--color-")||s.startsWith("--font-"))&&r.push(s)}r.forEach(o=>t.removeProperty(o))}function ft(e){if(typeof document>"u")return;let t=document.querySelector('link[rel="icon"]');t||(t=document.createElement("link"),t.rel="icon",document.head.appendChild(t)),t.href=e}function d(e,t){const r=/^#?([0-9a-f]{6})$/i.exec(String(e||"").trim());if(!r)return null;const o=parseInt(r[1],16),s=i=>{const T=Math.round(i+(t<0?i*t:(255-i)*t));return Math.max(0,Math.min(255,T))},y=s(o>>16&255),f=s(o>>8&255),g=s(o&255);return`#${((1<<24)+(y<<16)+(f<<8)+g).toString(16).slice(1)}`}function O(e){const t=/^#?([0-9a-f]{6})$/i.exec(String(e||"").trim());if(!t)return null;const r=parseInt(t[1],16);return`${r>>16&255}, ${r>>8&255}, ${r&255}`}function pt(e){const t=/^#?([0-9a-f]{6})$/i.exec(String(e||"").trim());if(!t)return!1;const r=parseInt(t[1],16),o=r>>16&255,s=r>>8&255,y=r&255;return .299*o+.587*s+.114*y<128}export{Tt as _resetThemeOwnership,ut as applySystemTheme,ct as applyTheme,St as applyThemeById,S as normalizeThemeId,N as themeLayoutKey,at as themeMode,wt as useSystemTheme};
|
package/dist/6bff84d27e.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import gt from"./d803155241.js";import{resolveLockVariantId as ht}from"./061b81ad81.js";const lt=E=>{const F=Number(E);return!Number.isFinite(F)||F===0?null:F},ft=(E,F)=>{const H=Array.isArray(E?.hostVariants)?E.hostVariants:Array.isArray(E?.host_variants)?E.host_variants:[];if(!H.length)return null;const R=K=>String(K?.hostVariantId??K?.host_variant_id)===String(F);return H.find(R)||H.find(K=>K?.isDefault??K?.is_default)||H[0]||null},xt=(E,F)=>{const H=E?.placementGroup??E?.placement_group;if(H!=null&&String(H)!=="")return String(H);const R=F?.(E?.variantId)||F?.(E?.productId);return String(R?.placementGroup??R?.placement_group??"")};var zt={id:"grouped-chain",label:"Grouped chain (backend + group attach)",mode:"compute",handlesCorners:!0,computeLayout(E,F={}){const{getProduct:H}=F,R=Array.isArray(E)?E:[],K=p=>String(p?.id??p?.instanceId??""),ut=new Map(R.map(p=>[K(p),p])),W=p=>H?.(p?.variantId)||H?.(p?.productId)||null,it=p=>{const d=W(p),z=d?.hostVariants??d?.host_variants;return Array.isArray(z)&&z.length?z:null},et=p=>{const d=p?.positionedAbove??p?.positioned_above??null;return d!=null?String(d):null},tt=p=>et(p)!=null,nt=p=>ht(p)??ht(W(p)),Mt=p=>nt(p)!=null,ct=p=>String(p?.variantId??p?.productId??""),ot=new Set,C=p=>ot.has(p),j=R.filter(p=>!tt(p)),U=R.filter(p=>tt(p));if(F.useTransform){const p=Math.PI/180;return R.map(d=>{const z=Array.isArray(d?.position)?d.position:[0,0,0],X=Array.isArray(d?.rotation)?d.rotation:[0,0,0];return{position:[Number(z[0])||0,Number(z[1])||0,Number(z[2])||0],rotation:[(Number(X[0])||0)*p,(Number(X[1])||0)*p,(Number(X[2])||0)*p]}})}const G=new Map;for(const p of j){const d=xt(p,H);G.has(d)||G.set(d,[]),G.get(d).push(p)}const x=new Map;for(const[,p]of G){const d=gt.computeLayout(p,F);p.forEach((z,X)=>{const a=d[X]||{position:[0,0,0],rotation:[0,0,0]},s=Array.isArray(z?.position)?z.position:[],t=a.position||[0,0,0],n=lt(s[1]);x.set(z,{position:[t[0],n??t[1],t[2]],rotation:a.rotation||[0,0,0]})})}for(const[,p]of G){const d=new Map;for(const a of p){const s=x.get(a)?.position?.[1]||0;s>.01&&d.set(s,(d.get(s)||0)+1)}if(!d.size)continue;let z=0,X=0;for(const[a,s]of d)s>X&&(X=s,z=a);if(!(X<p.length/2))for(const a of p){const s=x.get(a);s&&(s.position[1]||0)<=.01&&x.set(a,{position:[s.position[0],z,s.position[2]],rotation:s.rotation})}}{const d=t=>{const n=x.get(t);if(!n)return null;const g=n.position,i=-((Array.isArray(n.rotation)?n.rotation[1]:0)||0),h=Math.cos(i),e=Math.sin(i),r=-Math.sin(i),c=Math.cos(i),u=F.getDims?.(t.productId)??F.getDims?.(t.variantId)??null,l=W(t),m=u?.width>.05&&u?.depth>.05,f=m?u.width:l?.width>0?l.width*.0254:.9,w=m?u.depth:l?.depth>0?l.depth*.0254:.95,Z=m&&u.cx||0,N=m&&u.cz||0,I=g[0]+h*Z+r*N,M=g[2]+e*Z+c*N;return[I+h*(f/2)-r*(w/2),M+e*(f/2)-c*(w/2)]},z=new Set;for(const t of R){const n=nt(t);n!=null&&z.add(n)}let X=null,a=0;for(const[t,n]of G){const g=n.reduce((i,h)=>i+(z.has(ct(h))?1:0),0);g>a&&(a=g,X=t)}const s=X!=null?G.get(X):null;if(s){const t=new Map;for(const n of[...s].sort((g,i)=>Number(g.sequence)-Number(i.sequence))){const g=ct(n);t.has(g)||t.set(g,[]),t.get(g).push(n)}for(const[n,g]of G){if(n===X)continue;const i=g.map(c=>({inst:c,tv:nt(c),seq:Number(c.sequence)})).filter(c=>c.tv!=null&&Number.isFinite(c.seq)).sort((c,u)=>c.seq-u.seq);if(!i.length)continue;const h=new Map,e=[];for(const c of i){const u=t.get(c.tv);if(!u||!u.length)continue;const l=h.get(c.tv)||0,m=Math.min(l,u.length-1);h.set(c.tv,l+1);const f=u[m],w=d(c.inst),Z=d(f);!w||!Z||(e.push({seq:c.seq,delta:[Z[0]-w[0],Z[1]-w[1]],lockInst:c.inst}),ot.add(c.inst),ot.add(f))}if(!e.length)continue;e.sort((c,u)=>c.seq-u.seq);const r=new Map;for(const c of g){const u=Number(c?.sequence);let l=e[0];if(Number.isFinite(u))for(const m of e)if(m.seq<=u)l=m;else break;r.set(c,l.delta)}for(const c of g){const u=x.get(c);if(!u)continue;const l=r.get(c)||e[0].delta;x.set(c,{position:[u.position[0]+l[0],u.position[1],u.position[2]+l[1]],rotation:u.rotation})}}}}{const d=X=>{const a=F.getDims?.(X.productId)??F.getDims?.(X.variantId)??null,s=W(X),t=a?.width>.05&&a?.depth>.05;return{w:t?a.width:s?.width>0?s.width*.0254:.9,dp:t?a.depth:s?.depth>0?s.depth*.0254:.6,cx:t&&a.cx||0,cz:t&&a.cz||0}},z=X=>{const a=x.get(X);if(!a)return null;const[s,,t]=a.position,n=(Array.isArray(a.rotation)?a.rotation[1]:0)||0,{cx:g,cz:i}=d(X);return{x:s+g*Math.cos(n)+i*Math.sin(n),z:t-g*Math.sin(n)+i*Math.cos(n),y:a.position[1],r:n}};for(const[,X]of G){const a=X.filter(r=>C(r)&&Number.isFinite(Number(r.sequence))).map(r=>({inst:r,seq:Number(r.sequence)})).sort((r,c)=>r.seq-c.seq);if(a.length<2)continue;const s=[];for(let r=0;r<a.length-1;r++){const c=a[r].inst,u=a[r+1].inst,l=X.filter(Y=>{const _=Number(Y?.sequence);return!C(Y)&&Number.isFinite(_)&&_>a[r].seq&&_<a[r+1].seq}).sort((Y,_)=>Number(Y.sequence)-Number(_.sequence));if(!l.length)continue;const m=-((Array.isArray(x.get(l[0])?.rotation)?x.get(l[0]).rotation[1]:0)||0),f=Math.cos(m),w=Math.sin(m),Z=-w,N=f,I=Y=>Y.x*f+Y.z*w,M=Y=>{const{w:_,dp:T}=d(Y),V=z(Y);return V?Math.abs(Math.cos(V.r+m))*(_/2)+Math.abs(Math.sin(V.r+m))*(T/2):0},A=z(c),o=z(u);if(!A||!o)continue;const b=I(A),k=I(o),q=k>=b?1:-1,y=b+q*M(c),S=k-q*M(u),L=(S-y)*q,B=l.map(Y=>d(Y).w),v=B.reduce((Y,_)=>Y+_,0),P=new Array(l.length);if(v<=L+.02){const Y=v/2;let _=0,T=l.length;for(let D=0;D<l.length;D++)if(_+=B[D],_>Y){T=D;break}let V=y;for(let D=0;D<T;D++)P[D]=V+q*B[D]/2,V+=q*B[D];V=S;for(let D=l.length-1;D>=T;D--)P[D]=V-q*B[D]/2,V-=q*B[D]}else{let Y=0,_=0;for(let O=0;O<l.length&&!(_+B[O]>L+.02);O++)_+=B[O],Y=O+1;for(let O=Y;O<l.length;O++)s.push(l[O]);const V=B.slice(0,Y).reduce((O,dt)=>O+dt,0)/2;let D=0,Q=Y;for(let O=0;O<Y;O++)if(D+=B[O],D>V){Q=O;break}let J=y;for(let O=0;O<Q;O++)P[O]=J+q*B[O]/2,J+=q*B[O];J=S;for(let O=Y-1;O>=Q;O--)P[O]=J-q*B[O]/2,J-=q*B[O]}l.forEach((Y,_)=>{const T=z(Y);if(!T||P[_]==null)return;const{cx:V,cz:D}=d(Y),Q=T.x*Z+T.z*N,J=P[_]*f+Q*Z,O=P[_]*w+Q*N;x.set(Y,{position:[J-(V*Math.cos(T.r)+D*Math.sin(T.r)),T.y,O-(-V*Math.sin(T.r)+D*Math.cos(T.r))],rotation:x.get(Y).rotation})})}const t=(r,c,u)=>{if(!c.length||!r)return;const l=u&&u.rotY!=null,m=l?u.rotY:(Array.isArray(x.get(c[0])?.rotation)?x.get(c[0]).rotation[1]:0)||0,f=-m,w=Math.cos(f),Z=Math.sin(f),N=-Z,I=w,M=S=>S.x*w+S.z*Z,A=z(r);if(!A)return;const o=z(u?.dirRef||c[0]),b=o&&Math.sign(M(o)-M(A))||1,k=d(r),q=Math.abs(Math.cos(A.r+f))*(k.w/2)+Math.abs(Math.sin(A.r+f))*(k.dp/2);let y=M(A)+b*q;for(const S of c){const L=z(S);if(!L)continue;const{w:B,cx:v,cz:P}=d(S),Y=y+b*B/2,_=l?m:L.r,T=l?u.perpLine:L.x*N+L.z*I,V=Y*w+T*N,D=Y*Z+T*I;x.set(S,{position:[V-(v*Math.cos(_)+P*Math.sin(_)),L.y,D-(-v*Math.sin(_)+P*Math.cos(_))],rotation:l?[0,m,0]:x.get(S).rotation}),y+=b*B}},n=a[0].seq,g=a[a.length-1].seq,i=X.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c<n}).sort((r,c)=>Number(c.sequence)-Number(r.sequence)),h=X.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c>g}).sort((r,c)=>Number(r.sequence)-Number(c.sequence));t(a[0].inst,i);const e=a[a.length-1].inst;if(h.length){const r=z(h[0]),c=(Array.isArray(x.get(h[0])?.rotation)?x.get(h[0]).rotation[1]:0)||0,u=-c,l=-Math.sin(u),m=Math.cos(u),f=r?r.x*l+r.z*m:0;t(e,[...s,...h],{rotY:c,perpLine:f,dirRef:h[0]})}else t(e,s)}}const rt=new Map;for(const p of R){if(!C(p))continue;const d=x.get(p);d?.position&&rt.set(p,d.position.slice())}const mt=()=>{for(const[p,d]of rt){const z=x.get(p);z&&x.set(p,{position:d.slice(),rotation:z.rotation})}};{const d=a=>{const s=F.getDims?.(a.productId)??F.getDims?.(a.variantId)??null,t=W(a);return{w:s?.width>0?s.width:t?.width>0?t.width*.0254:.9,dp:s?.depth>0?s.depth:t?.depth>0?t.depth*.0254:.6,h:s?.height>0?s.height:t?.height>0?t.height*.0254:.9,cx:s?.cx||0,cz:s?.cz||0}},z=a=>{const s=x.get(a);if(!s)return null;const[t,n,g]=s.position,i=(Array.isArray(s.rotation)?s.rotation[1]:0)||0,{w:h,dp:e,h:r,cx:c,cz:u}=d(a),l=Math.cos(i),m=Math.sin(i),f=t+c*l+u*m,w=g-c*m+u*l,Z=Math.abs(l),N=Math.abs(m),I=(h*Z+e*N)/2,M=(h*N+e*Z)/2;let A=f-I,o=f+I,b=w-M,k=w+M;if(tt(a)?null:it(a)){const y=ft(W(a),null),S=Array.isArray(y?.position)?y.position:[0,0,0],L=f+(S[0]||0)*l+(S[2]||0)*m,B=w-(S[0]||0)*m+(S[2]||0)*l;A=Math.min(A,L-I),o=Math.max(o,L+I),b=Math.min(b,B-M),k=Math.max(k,B+M)}return{minX:A,maxX:o,minZ:b,maxZ:k,minY:n,maxY:n+r}};let X=1/0;for(const a of R){const s=x.get(a)?.position?.[1]||0;s>.01&&s<X&&(X=s)}if(Number.isFinite(X)){const a=new Map,s=new Map;for(const i of j){const h=z(i);h&&(a.set(i,h),s.set(i,(x.get(i)?.position?.[1]||0)>.01))}const t=j.filter(i=>{if(C(i))return!1;const h=a.get(i);return h&&!s.get(i)&&h.maxY>X+.05}),n=(i,h)=>i.minX<h.maxX-.02&&i.maxX>h.minX+.02&&i.minZ<h.maxZ-.02&&i.maxZ>h.minZ+.02&&i.minY<h.maxY-.02&&i.maxY>h.minY+.02,g=new Set(t);for(const i of t){const h=a.get(i),e=-(x.get(i)?.rotation?.[1]||0),r=Math.cos(e),c=Math.sin(e),u=-c,l=r,m=y=>({lo:Math.min(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c),hi:Math.max(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c)}),f=y=>(y.minX+y.maxX)/2*u+(y.minZ+y.maxZ)/2*l,w=f(h),Z=m(h);let N=!1;for(const y of j){if(!s.get(y))continue;const S=a.get(y);if(S&&n(h,S)){N=!0;break}}if(!N)continue;const I=j.filter(y=>{if(y===i||g.has(y))return!1;const S=-(x.get(y)?.rotation?.[1]||0);if(Math.abs(Math.cos(e-S))<.9)return!1;const L=a.get(y);return L&&Math.abs(f(L)-w)<1});if(!I.length)continue;let M=null;for(const y of[...j,...U]){if(!y?.corner)continue;const S=a.get(y)||z(y);if(!S||Math.abs(f(S)-w)>1.6)continue;const L=m(S);M=(L.lo+L.hi)/2;break}const A=(Z.lo+Z.hi)/2,o=M!=null&&A<M?-1:1;let b=0;const k=Math.max(...I.map(y=>m(a.get(y)).hi)),q=Math.min(...I.map(y=>m(a.get(y)).lo));if(o>0?b=Math.max(0,k+.005-Z.lo):b=Math.min(0,q-.005-Z.hi),Math.abs(b)>.005){const y=x.get(i);x.set(i,{position:[y.position[0]+r*b,y.position[1],y.position[2]+c*b],rotation:y.rotation}),a.set(i,z(i))}}}}const at=p=>String(p?.variantId??p?.productId??""),pt=p=>{const d=et(p);if(d!=null)return ut.get(d)||null;const z=it(p)||[],X=new Set(z.map(a=>String(a?.hostVariantId??a?.host_variant_id)));return R.find(a=>a!==p&&X.has(at(a)))||null};let $=U.slice(),st=!0;for(;$.length&&st;){st=!1;const p=[];for(const d of $){const z=pt(d),X=z?x.get(z):null;if(!X){p.push(d);continue}const a=ft(W(d),at(z)),s=X.position||[0,0,0],t=(Array.isArray(X.rotation)?X.rotation[1]:0)||0,n=Math.cos(t),g=Math.sin(t),i=a&&Array.isArray(a.position)?a.position:[0,0,0],e=(F.getDims?.(z.productId)??F.getDims?.(z.variantId)??null)?.cx||0,r=lt(Array.isArray(d?.position)?d.position[1]:null),c=[s[0]+e*n+(i[2]||0)*g,r??s[1]+(i[1]||0),s[2]-e*g+(i[2]||0)*n],u=a&&Array.isArray(a.rotation)?(a.rotation[1]||0)*Math.PI/180:0;x.set(d,{position:c,rotation:[0,t+u,0]}),st=!0}$=p}for(const p of $){const d=Array.isArray(p?.position)?p.position:[];x.set(p,{position:d.length?d:[0,0,0],rotation:p?.rotation||[0,0,0]})}{const d=[],z=t=>{const n=F.getDims?.(t.productId)??F.getDims?.(t.variantId)??null,g=W(t);return{w:n?.width>0?n.width:g?.width>0?g.width*.0254:.9,dp:n?.depth>0?n.depth:g?.depth>0?g.depth*.0254:.6,h:n?.height>0?n.height:g?.height>0?g.height*.0254:.9,cx:n?.cx||0,cz:n?.cz||0}},X=t=>{const n=x.get(t);if(!n)return null;const[g,i,h]=n.position,e=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,{w:r,dp:c,h:u,cx:l,cz:m}=z(t),f=Math.cos(e),w=Math.sin(e),Z=g+l*f+m*w,N=h-l*w+m*f,I=Math.abs(f),M=Math.abs(w),A=(r*I+c*M)/2,o=(r*M+c*I)/2;return{minX:Z-A,maxX:Z+A,minZ:N-o,maxZ:N+o,minY:i,maxY:i+u}};let a=1/0;for(const t of R){const n=x.get(t)?.position?.[1]||0;n>.01&&n<a&&(a=n)}const s=t=>(x.get(t)?.position?.[1]||0)>.01;for(const t of U){const n=X(t);if(!n||n.maxY<=a+.05)continue;const g=-((Array.isArray(x.get(t)?.rotation)?x.get(t).rotation[1]:0)||0),i=Math.cos(g),h=Math.sin(g),e=-h,r=i,c=o=>Math.min(o.minX*i+o.minZ*h,o.maxX*i+o.maxZ*h),u=o=>Math.max(o.minX*i+o.minZ*h,o.maxX*i+o.maxZ*h),l=o=>(o.minX+o.maxX)/2*e+(o.minZ+o.maxZ)/2*r,m=o=>(o.minX+o.maxX)/2*i+(o.minZ+o.maxZ)/2*h,f=c(n),w=u(n),Z=(f+w)/2,N=l(n);let I=null;for(const o of[...j,...U]){if(!o?.corner)continue;const b=X(o);if(b&&!(Math.abs(l(b)-N)>1.6)){I=m(b);break}}const M=I!=null&&Z<I?-1:1,A=[];for(const o of j){if(C(o)||!s(o))continue;const b=X(o);if(!b)continue;const k=-((Array.isArray(x.get(o)?.rotation)?x.get(o).rotation[1]:0)||0);Math.abs(Math.cos(g-k))<.9||Math.abs(l(b)-N)>1||A.push({inst:o,lo:c(b),hi:u(b)})}if(M>0){const o=A.filter(k=>k.hi>f),b=o.filter(k=>k.lo<w);if(b.length){const k=w-Math.min(...b.map(q=>q.lo))+.01;for(const{inst:q}of o){const y=x.get(q);x.set(q,{...y,position:[y.position[0]+i*k,y.position[1],y.position[2]+h*k]})}d.push({chimShift:+k.toFixed(3),dir:"+run",n:o.length})}}else{const o=A.filter(k=>k.lo<w),b=o.filter(k=>k.hi>f);if(b.length){const k=Math.max(...b.map(q=>q.hi))-f+.01;for(const{inst:q}of o){const y=x.get(q);x.set(q,{...y,position:[y.position[0]-i*k,y.position[1],y.position[2]-h*k]})}d.push({chimShift:+k.toFixed(3),dir:"-run",n:o.length})}}}}{const d=s=>{const t=F.getDims?.(s.productId)??F.getDims?.(s.variantId)??null,n=H?.(s.variantId)||H?.(s.productId);return{w:t?.width>0?t.width:n?.width>0?n.width*.0254:.9,dp:t?.depth>0?t.depth:n?.depth>0?n.depth*.0254:.6,h:t?.height>0?t.height:n?.height>0?n.height*.0254:.9,cx:t?.cx||0,cz:t?.cz||0}},z=s=>{const t=x.get(s);if(!t)return null;const[n,g,i]=t.position,h=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{w:e,dp:r,h:c,cx:u,cz:l}=d(s),m=Math.cos(h),f=Math.sin(h),w=n+u*m+l*f,Z=i-u*f+l*m,N=Math.abs(m),I=Math.abs(f),M=(e*N+r*I)/2,A=(e*I+r*N)/2;return{minX:w-M,maxX:w+M,minZ:Z-A,maxZ:Z+A,minY:g,maxY:g+c}},X=(s,t)=>s&&t&&s.minX<t.maxX-.02&&s.maxX>t.minX+.02&&s.minZ<t.maxZ-.02&&s.maxZ>t.minZ+.02&&s.minY<t.maxY-.02&&s.maxY>t.minY+.02;let a=1/0;for(const s of R){const t=x.get(s)?.position?.[1]||0;t>.01&&t<a&&(a=t)}if(Number.isFinite(a)){const s=new Map;for(const i of R){const h=z(i);h&&s.set(i,h)}const t=i=>(x.get(i)?.position?.[1]||0)>.01,n=R.filter(i=>{if(C(i))return!1;const h=s.get(i);return h&&!t(i)&&h.maxY>a+.05}),g=new Set(n);for(const i of n){const h=-(x.get(i)?.rotation?.[1]||0),e=Math.cos(h),r=Math.sin(h),c=M=>({lo:Math.min(M.minX*e+M.minZ*r,M.maxX*e+M.maxZ*r),hi:Math.max(M.minX*e+M.minZ*r,M.maxX*e+M.maxZ*r)});let u=s.get(i),l=1/0,m=-1/0,f=!1;for(const M of R){if(M===i||g.has(M)||!t(M))continue;const A=s.get(M);if(!A||!X(u,A))continue;const o=c(A);l=Math.min(l,o.lo),m=Math.max(m,o.hi),f=!0}if(!f)continue;const w=c(u),Z=(w.lo+w.hi)/2,N=(l+m)/2,I=Z>=N?m+.005-w.lo:l-.005-w.hi;if(Math.abs(I)>.002){const M=x.get(i);x.set(i,{position:[M.position[0]+e*I,M.position[1],M.position[2]+r*I],rotation:M.rotation}),u=z(i),s.set(i,u)}}}}{const d=s=>{const t=F.getDims?.(s.productId)??F.getDims?.(s.variantId)??null,n=W(s),g=t?.width>.05&&t?.depth>.05;return{w:g?t.width:n?.width>0?n.width*.0254:.9,dp:g?t.depth:n?.depth>0?n.depth*.0254:.6,cx:g&&t.cx||0,cz:g&&t.cz||0}},z=s=>{const t=x.get(s);if(!t)return null;const[n,,g]=t.position,i=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{cx:h,cz:e}=d(s);return{x:n+h*Math.cos(i)+e*Math.sin(i),z:g-h*Math.sin(i)+e*Math.cos(i),y:t.position[1],r:i}},X=s=>{const t=z(s);if(!t)return null;const{w:n,dp:g}=d(s),i=Math.abs(Math.cos(t.r)),h=Math.abs(Math.sin(t.r)),e=(n*i+g*h)/2,r=(n*h+g*i)/2;return{minX:t.x-e,maxX:t.x+e,minZ:t.z-r,maxZ:t.z+r}},a=(s,t)=>s&&t&&s.minX<t.maxX-.04&&s.maxX>t.minX+.04&&s.minZ<t.maxZ-.04&&s.maxZ>t.minZ+.04;for(const[,s]of G){const t=s.filter(o=>C(o)&&Number.isFinite(Number(o.sequence))).map(o=>({inst:o,seq:Number(o.sequence)})).sort((o,b)=>o.seq-b.seq);if(!t.length)continue;const n=t[t.length-1].inst,g=t[t.length-1].seq,i=s.filter(o=>!C(o)&&Number.isFinite(Number(o.sequence))).sort((o,b)=>Number(o.sequence)-Number(b.sequence)),h=[];for(const o of t){const b=X(o.inst);b&&h.push(b)}const e=[];for(const o of i){const b=X(o);b&&(h.some(k=>a(b,k))?e.push(o):h.push(b))}if(!e.length)continue;const r=i.filter(o=>Number(o.sequence)>g&&!e.includes(o)),c=r.length?(Array.isArray(x.get(r[0])?.rotation)?x.get(r[0]).rotation[1]:0)||0:((Array.isArray(x.get(n)?.rotation)?x.get(n).rotation[1]:0)||0)-Math.PI/2,u=-c,l=Math.cos(u),m=Math.sin(u),f=-m,w=l,Z=o=>o.x*l+o.z*m,N=z(n);if(!N)continue;const I=r.length?(()=>{const o=z(r[0]);return o?o.x*f+o.z*w:N.x*f+N.z*w})():N.x*f+N.z*w;let M,A;if(r.length){const o=z(r[0]);M=Math.sign(Z(o)-Z(N))||1,A=Math.max(...r.map(b=>{const k=z(b);return k?Z(k)+M*d(b).w/2:-1/0}))}else{M=1;const o=d(n);A=Z(N)+M*(Math.abs(Math.cos(N.r+u))*(o.w/2)+Math.abs(Math.sin(N.r+u))*(o.dp/2))}if(Number.isFinite(A))for(const o of e){const b=z(o);if(!b)continue;const{w:k,cx:q,cz:y}=d(o),S=A+M*k/2,L=S*l+I*f,B=S*m+I*w;x.set(o,{position:[L-(q*Math.cos(c)+y*Math.sin(c)),b.y,B-(-q*Math.sin(c)+y*Math.cos(c))],rotation:[0,c,0]}),A+=M*k}}}{const d=t=>{const n=F.getDims?.(t.productId)??F.getDims?.(t.variantId)??null,g=W(t),i=n?.width>.05&&n?.depth>.05;return{w:i?n.width:g?.width>0?g.width*.0254:.9,dp:i?n.depth:g?.depth>0?g.depth*.0254:.6,cx:i&&n.cx||0,cz:i&&n.cz||0}},z=t=>{const n=x.get(t);if(!n)return null;const[g,,i]=n.position,h=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,{w:e,dp:r,cx:c,cz:u}=d(t),l=g+c*Math.cos(h)+u*Math.sin(h),m=i-c*Math.sin(h)+u*Math.cos(h),f=Math.abs(Math.cos(h)),w=Math.abs(Math.sin(h)),Z=(e*f+r*w)/2,N=(e*w+r*f)/2;return{minX:l-Z,maxX:l+Z,minZ:m-N,maxZ:m+N}};let X=0,a=0,s=0;for(const t of R){const n=x.get(t);n&&(X+=n.position[0],a+=n.position[2],s+=1)}s&&(X/=s,a/=s);for(const[,t]of G){const n=t.filter(e=>C(e)).map(e=>({b:z(e)})).filter(e=>e.b);if(!n.length)continue;const g=t.filter(e=>!C(e)).map(e=>({inst:e,b:z(e)})).filter(e=>e.b);for(const{b:e}of n){const r=(l,m)=>n.some(({b:f})=>f===e?!1:l==="x"?f.minZ<e.maxZ-.05&&f.maxZ>e.minZ+.05&&(m?f.minX>e.maxX:f.maxX<e.minX):f.minX<e.maxX-.05&&f.maxX>e.minX+.05&&(m?f.minZ>e.maxZ:f.maxZ<e.minZ)),c={xp:[],xn:[],zp:[],zn:[]};for(const{inst:l,b:m}of g){const f=m.minZ<e.maxZ-.05&&m.maxZ>e.minZ+.05,w=m.minX<e.maxX-.05&&m.maxX>e.minX+.05;f&&!w?m.minX>=e.maxX?c.xp.push({inst:l,gap:m.minX-e.maxX}):m.maxX<=e.minX&&c.xn.push({inst:l,gap:e.minX-m.maxX}):w&&!f&&(m.minZ>=e.maxZ?c.zp.push({inst:l,gap:m.minZ-e.maxZ}):m.maxZ<=e.minZ&&c.zn.push({inst:l,gap:e.minZ-m.maxZ}))}const u=(l,m,f,w)=>{if(!l.length||r(m,f))return;const Z=Math.min(...l.map(I=>I.gap));if(Z>.015&&Z<.5){const I=w*Z;for(const{inst:M}of l){const A=x.get(M);A&&x.set(M,{position:[A.position[0]+(m==="x"?I:0),A.position[1],A.position[2]+(m==="z"?I:0)],rotation:A.rotation})}}const N=m==="x"?"z":"x";for(const{inst:I}of l){const M=z(I),A=x.get(I);if(!(!M||!A))if(N==="z"){const o=A.position[2]>a,b=o?M.maxZ:M.minZ,q=(o?e.maxZ:e.minZ)-b;(o?q>0:q<0)&&Math.abs(q)>.015&&Math.abs(q)<.5&&x.set(I,{position:[A.position[0],A.position[1],A.position[2]+q],rotation:A.rotation})}else{const o=A.position[0]>X,b=o?M.maxX:M.minX,q=(o?e.maxX:e.minX)-b;(o?q>0:q<0)&&Math.abs(q)>.015&&Math.abs(q)<.5&&x.set(I,{position:[A.position[0]+q,A.position[1],A.position[2]],rotation:A.rotation})}}};u(c.xp,"x",!0,-1),u(c.xn,"x",!1,1),u(c.zp,"z",!0,-1),u(c.zn,"z",!1,1)}const i=(e,r)=>r==="x"?(e.minX+e.maxX)/2:(e.minZ+e.maxZ)/2,h=(e,r)=>r==="x"?(e.minZ+e.maxZ)/2:(e.minX+e.maxX)/2;for(let e=0;e<n.length;e++)for(let r=e+1;r<n.length;r++){const c=n[e].b,u=n[r].b,l=Math.abs((c.minX+c.maxX)/2-(u.minX+u.maxX)/2),m=Math.abs((c.minZ+c.maxZ)/2-(u.minZ+u.maxZ)/2);let f=null;if(m<.35&&l>.5?f="x":l<.35&&m>.5&&(f="z"),!f)continue;const w=i(c,f)<i(u,f),Z=w?c:u,N=w?u:c,I=f==="x"?Z.maxX:Z.maxZ,M=f==="x"?N.minX:N.minZ,A=h(Z,f),o=t.filter(v=>!C(v)).map(v=>({inst:v,b:z(v)})).filter(({b:v})=>v&&i(v,f)>I-.15&&i(v,f)<M+.15&&Math.abs(h(v,f)-A)<.4).sort((v,P)=>i(v.b,f)-i(P.b,f));if(!o.length)continue;const b=o.map(({inst:v})=>d(v).w),k=b.reduce((v,P)=>v+P,0);if(k>M-I+.02)continue;const q=k/2;let y=0,S=o.length;for(let v=0;v<o.length;v++)if(y+=b[v],y>q){S=v;break}const L=(v,P)=>{const Y=x.get(v);if(!Y)return;const _=(Array.isArray(Y.rotation)?Y.rotation[1]:0)||0,{cx:T,cz:V}=d(v);f==="x"?x.set(v,{position:[P-(T*Math.cos(_)+V*Math.sin(_)),Y.position[1],Y.position[2]],rotation:Y.rotation}):x.set(v,{position:[Y.position[0],Y.position[1],P-(-T*Math.sin(_)+V*Math.cos(_))],rotation:Y.rotation})};let B=I;for(let v=0;v<S;v++)L(o[v].inst,B+b[v]/2),B+=b[v];B=M;for(let v=o.length-1;v>=S;v--)L(o[v].inst,B-b[v]/2),B-=b[v]}}}return mt(),R.map(p=>x.get(p)||{position:[0,0,0],rotation:[0,0,0]})}};import{appendTargetFor as Xt,neighborsFor as Zt,groupByPlacement as It}from"./dc812f3e14.js";export{Xt as appendTargetFor,zt as default,It as groupByPlacement,Zt as neighborsFor};
|
|
1
|
+
import ht from"./d803155241.js";import{resolveLockVariantId as lt}from"./061b81ad81.js";const ft=E=>{const O=Number(E);return!Number.isFinite(O)||O===0?null:O},ut=(E,O)=>{const H=Array.isArray(E?.hostVariants)?E.hostVariants:Array.isArray(E?.host_variants)?E.host_variants:[];if(!H.length)return null;const R=J=>String(J?.hostVariantId??J?.host_variant_id)===String(O);return H.find(R)||H.find(J=>J?.isDefault??J?.is_default)||H[0]||null},Mt=(E,O)=>{const H=E?.placementGroup??E?.placement_group;if(H!=null&&String(H)!=="")return String(H);const R=O?.(E?.variantId)||O?.(E?.productId);return String(R?.placementGroup??R?.placement_group??"")};var wt={id:"grouped-chain",label:"Grouped chain (backend + group attach)",mode:"compute",handlesCorners:!0,computeLayout(E,O={}){const{getProduct:H}=O,R=Array.isArray(E)?E:[],J=p=>String(p?.id??p?.instanceId??""),pt=new Map(R.map(p=>[J(p),p])),W=p=>H?.(p?.variantId)||H?.(p?.productId)||null,it=p=>{const x=W(p),w=x?.hostVariants??x?.host_variants;return Array.isArray(w)&&w.length?w:null},et=p=>{const x=p?.positionedAbove??p?.positioned_above??null;return x!=null?String(x):null},tt=p=>et(p)!=null,nt=p=>lt(p)??lt(W(p)),yt=p=>nt(p)!=null,ct=p=>String(p?.variantId??p?.productId??""),ot=new Set,C=p=>ot.has(p),j=R.filter(p=>!tt(p)),U=R.filter(p=>tt(p));if(O.useTransform){const p=Math.PI/180;return R.map(x=>{const w=Array.isArray(x?.position)?x.position:[0,0,0],Z=Array.isArray(x?.rotation)?x.rotation:[0,0,0];return{position:[Number(w[0])||0,Number(w[1])||0,Number(w[2])||0],rotation:[(Number(Z[0])||0)*p,(Number(Z[1])||0)*p,(Number(Z[2])||0)*p]}})}const G=new Map;for(const p of j){const x=Mt(p,H);G.has(x)||G.set(x,[]),G.get(x).push(p)}const g=new Map;for(const[,p]of G){const x=ht.computeLayout(p,O);p.forEach((w,Z)=>{const a=x[Z]||{position:[0,0,0],rotation:[0,0,0]},s=Array.isArray(w?.position)?w.position:[],t=a.position||[0,0,0],o=ft(s[1]);g.set(w,{position:[t[0],o??t[1],t[2]],rotation:a.rotation||[0,0,0]})})}for(const[,p]of G){const x=new Map;for(const a of p){const s=g.get(a)?.position?.[1]||0;s>.01&&x.set(s,(x.get(s)||0)+1)}if(!x.size)continue;let w=0,Z=0;for(const[a,s]of x)s>Z&&(Z=s,w=a);if(!(Z<p.length/2))for(const a of p){const s=g.get(a);s&&(s.position[1]||0)<=.01&&g.set(a,{position:[s.position[0],w,s.position[2]],rotation:s.rotation})}}{const x=t=>{const o=g.get(t);if(!o)return null;const M=o.position,i=-((Array.isArray(o.rotation)?o.rotation[1]:0)||0),h=Math.cos(i),e=Math.sin(i),r=-Math.sin(i),c=Math.cos(i),l=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,u=W(t),m=l?.width>.05&&l?.depth>.05,f=m?l.width:u?.width>0?u.width*.0254:.9,A=m?l.depth:u?.depth>0?u.depth*.0254:.95,X=m&&l.cx||0,I=m&&l.cz||0,N=M[0]+h*X+r*I,d=M[2]+e*X+c*I;return[N+h*(f/2)-r*(A/2),d+e*(f/2)-c*(A/2)]},w=new Set;for(const t of R){const o=nt(t);o!=null&&w.add(o)}let Z=null,a=0;for(const[t,o]of G){const M=o.reduce((i,h)=>i+(w.has(ct(h))?1:0),0);M>a&&(a=M,Z=t)}const s=Z!=null?G.get(Z):null;if(s){const t=new Map;for(const o of[...s].sort((M,i)=>Number(M.sequence)-Number(i.sequence))){const M=ct(o);t.has(M)||t.set(M,[]),t.get(M).push(o)}for(const[o,M]of G){if(o===Z)continue;const i=M.map(c=>({inst:c,tv:nt(c),seq:Number(c.sequence)})).filter(c=>c.tv!=null&&Number.isFinite(c.seq)).sort((c,l)=>c.seq-l.seq);if(!i.length)continue;const h=new Map,e=[];for(const c of i){const l=t.get(c.tv);if(!l||!l.length)continue;const u=h.get(c.tv)||0,m=Math.min(u,l.length-1);h.set(c.tv,u+1);const f=l[m],A=x(c.inst),X=x(f);!A||!X||(e.push({seq:c.seq,delta:[X[0]-A[0],X[1]-A[1]],lockInst:c.inst}),ot.add(c.inst),ot.add(f))}if(!e.length)continue;e.sort((c,l)=>c.seq-l.seq);const r=new Map;for(const c of M){const l=Number(c?.sequence);let u=e[0];if(Number.isFinite(l))for(const m of e)if(m.seq<=l)u=m;else break;r.set(c,u.delta)}for(const c of M){const l=g.get(c);if(!l)continue;const u=r.get(c)||e[0].delta;g.set(c,{position:[l.position[0]+u[0],l.position[1],l.position[2]+u[1]],rotation:l.rotation})}}}}{const x=Z=>{const a=O.getDims?.(Z.productId)??O.getDims?.(Z.variantId)??null,s=W(Z),t=a?.width>.05&&a?.depth>.05;return{w:t?a.width:s?.width>0?s.width*.0254:.9,dp:t?a.depth:s?.depth>0?s.depth*.0254:.6,cx:t&&a.cx||0,cz:t&&a.cz||0}},w=Z=>{const a=g.get(Z);if(!a)return null;const[s,,t]=a.position,o=(Array.isArray(a.rotation)?a.rotation[1]:0)||0,{cx:M,cz:i}=x(Z);return{x:s+M*Math.cos(o)+i*Math.sin(o),z:t-M*Math.sin(o)+i*Math.cos(o),y:a.position[1],r:o}};for(const[,Z]of G){const a=Z.filter(r=>C(r)&&Number.isFinite(Number(r.sequence))).map(r=>({inst:r,seq:Number(r.sequence)})).sort((r,c)=>r.seq-c.seq);if(a.length<2)continue;const s=[];for(let r=0;r<a.length-1;r++){const c=a[r].inst,l=a[r+1].inst,u=Z.filter(Y=>{const F=Number(Y?.sequence);return!C(Y)&&Number.isFinite(F)&&F>a[r].seq&&F<a[r+1].seq}).sort((Y,F)=>Number(Y.sequence)-Number(F.sequence));if(!u.length)continue;const m=-((Array.isArray(g.get(u[0])?.rotation)?g.get(u[0]).rotation[1]:0)||0),f=Math.cos(m),A=Math.sin(m),X=-A,I=f,N=Y=>Y.x*f+Y.z*A,d=Y=>{const{w:F,dp:D}=x(Y),P=w(Y);return P?Math.abs(Math.cos(P.r+m))*(F/2)+Math.abs(Math.sin(P.r+m))*(D/2):0},z=w(c),n=w(l);if(!z||!n)continue;const b=N(z),q=N(n),v=q>=b?1:-1,y=b+v*d(c),S=q-v*d(l),L=(S-y)*v,_=u.map(Y=>x(Y).w),k=_.reduce((Y,F)=>Y+F,0),V=new Array(u.length);if(k<=L+.02){const Y=k/2;let F=0,D=u.length;for(let T=0;T<u.length;T++)if(F+=_[T],F>Y){D=T;break}let P=y;for(let T=0;T<D;T++)V[T]=P+v*_[T]/2,P+=v*_[T];P=S;for(let T=u.length-1;T>=D;T--)V[T]=P-v*_[T]/2,P-=v*_[T]}else{let Y=0,F=0;for(let B=0;B<u.length&&!(F+_[B]>L+.02);B++)F+=_[B],Y=B+1;for(let B=Y;B<u.length;B++)s.push(u[B]);const P=_.slice(0,Y).reduce((B,xt)=>B+xt,0)/2;let T=0,K=Y;for(let B=0;B<Y;B++)if(T+=_[B],T>P){K=B;break}let Q=y;for(let B=0;B<K;B++)V[B]=Q+v*_[B]/2,Q+=v*_[B];Q=S;for(let B=Y-1;B>=K;B--)V[B]=Q-v*_[B]/2,Q-=v*_[B]}u.forEach((Y,F)=>{const D=w(Y);if(!D||V[F]==null)return;const{cx:P,cz:T}=x(Y),K=D.x*X+D.z*I,Q=V[F]*f+K*X,B=V[F]*A+K*I;g.set(Y,{position:[Q-(P*Math.cos(D.r)+T*Math.sin(D.r)),D.y,B-(-P*Math.sin(D.r)+T*Math.cos(D.r))],rotation:g.get(Y).rotation})})}const t=(r,c,l)=>{if(!c.length||!r)return;const u=l&&l.rotY!=null,m=u?l.rotY:(Array.isArray(g.get(c[0])?.rotation)?g.get(c[0]).rotation[1]:0)||0,f=-m,A=Math.cos(f),X=Math.sin(f),I=-X,N=A,d=S=>S.x*A+S.z*X,z=w(r);if(!z)return;const n=w(l?.dirRef||c[0]),b=n&&Math.sign(d(n)-d(z))||1,q=x(r),v=Math.abs(Math.cos(z.r+f))*(q.w/2)+Math.abs(Math.sin(z.r+f))*(q.dp/2);let y=d(z)+b*v;for(const S of c){const L=w(S);if(!L)continue;const{w:_,dp:k,cx:V,cz:Y}=x(S),F=y+b*_/2,D=u?m:L.r,P=u?l.perpBack!=null?l.perpBack+k/2:l.perpLine:L.x*I+L.z*N,T=F*A+P*I,K=F*X+P*N;g.set(S,{position:[T-(V*Math.cos(D)+Y*Math.sin(D)),L.y,K-(-V*Math.sin(D)+Y*Math.cos(D))],rotation:u?[0,m,0]:g.get(S).rotation}),y+=b*_}},o=a[0].seq,M=a[a.length-1].seq,i=Z.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c<o}).sort((r,c)=>Number(c.sequence)-Number(r.sequence)),h=Z.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c>M}).sort((r,c)=>Number(r.sequence)-Number(c.sequence));t(a[0].inst,i);const e=a[a.length-1].inst;if(h.length){const r=w(h[0]),c=(Array.isArray(g.get(h[0])?.rotation)?g.get(h[0]).rotation[1]:0)||0,l=-c,u=-Math.sin(l),m=Math.cos(l),f=r?r.x*u+r.z*m:0,A=f-x(h[0]).dp/2,X=[...s,...h],I=X.findIndex(z=>!!z?.corner),N=I>=0?X.slice(0,I+1):X;t(e,N,{rotY:c,perpLine:f,perpBack:A,dirRef:h[0]});const d=I>=0?X.slice(I+1):[];if(d.length){const z=X[I],n=[z,...d],b=ht.computeLayout(n,O)||[],q=g.get(z),v=b[0];if(q&&v){const y=(q.rotation?.[1]||0)-(v.rotation?.[1]||0),S=Math.cos(y),L=Math.sin(y);d.forEach((_,k)=>{const V=b[k+1];if(!V)return;const Y=V.position[0]-v.position[0],F=V.position[2]-v.position[2],D=g.get(_);g.set(_,{position:[q.position[0]+Y*S+F*L,D?.position?.[1]??q.position[1],q.position[2]-Y*L+F*S],rotation:[0,(V.rotation?.[1]||0)+y,0]})})}}}else t(e,s)}}const rt=new Map;for(const p of R){if(!C(p))continue;const x=g.get(p);x?.position&&rt.set(p,x.position.slice())}const dt=()=>{for(const[p,x]of rt){const w=g.get(p);w&&g.set(p,{position:x.slice(),rotation:w.rotation})}};{const x=a=>{const s=O.getDims?.(a.productId)??O.getDims?.(a.variantId)??null,t=W(a);return{w:s?.width>0?s.width:t?.width>0?t.width*.0254:.9,dp:s?.depth>0?s.depth:t?.depth>0?t.depth*.0254:.6,h:s?.height>0?s.height:t?.height>0?t.height*.0254:.9,cx:s?.cx||0,cz:s?.cz||0}},w=a=>{const s=g.get(a);if(!s)return null;const[t,o,M]=s.position,i=(Array.isArray(s.rotation)?s.rotation[1]:0)||0,{w:h,dp:e,h:r,cx:c,cz:l}=x(a),u=Math.cos(i),m=Math.sin(i),f=t+c*u+l*m,A=M-c*m+l*u,X=Math.abs(u),I=Math.abs(m),N=(h*X+e*I)/2,d=(h*I+e*X)/2;let z=f-N,n=f+N,b=A-d,q=A+d;if(tt(a)?null:it(a)){const y=ut(W(a),null),S=Array.isArray(y?.position)?y.position:[0,0,0],L=f+(S[0]||0)*u+(S[2]||0)*m,_=A-(S[0]||0)*m+(S[2]||0)*u;z=Math.min(z,L-N),n=Math.max(n,L+N),b=Math.min(b,_-d),q=Math.max(q,_+d)}return{minX:z,maxX:n,minZ:b,maxZ:q,minY:o,maxY:o+r}};let Z=1/0;for(const a of R){const s=g.get(a)?.position?.[1]||0;s>.01&&s<Z&&(Z=s)}if(Number.isFinite(Z)){const a=new Map,s=new Map;for(const i of j){const h=w(i);h&&(a.set(i,h),s.set(i,(g.get(i)?.position?.[1]||0)>.01))}const t=j.filter(i=>{if(C(i))return!1;const h=a.get(i);return h&&!s.get(i)&&h.maxY>Z+.05}),o=(i,h)=>i.minX<h.maxX-.02&&i.maxX>h.minX+.02&&i.minZ<h.maxZ-.02&&i.maxZ>h.minZ+.02&&i.minY<h.maxY-.02&&i.maxY>h.minY+.02,M=new Set(t);for(const i of t){const h=a.get(i),e=-(g.get(i)?.rotation?.[1]||0),r=Math.cos(e),c=Math.sin(e),l=-c,u=r,m=y=>({lo:Math.min(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c),hi:Math.max(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c)}),f=y=>(y.minX+y.maxX)/2*l+(y.minZ+y.maxZ)/2*u,A=f(h),X=m(h);let I=!1;for(const y of j){if(!s.get(y))continue;const S=a.get(y);if(S&&o(h,S)){I=!0;break}}if(!I)continue;const N=j.filter(y=>{if(y===i||M.has(y))return!1;const S=-(g.get(y)?.rotation?.[1]||0);if(Math.abs(Math.cos(e-S))<.9)return!1;const L=a.get(y);return L&&Math.abs(f(L)-A)<1});if(!N.length)continue;let d=null;for(const y of[...j,...U]){if(!y?.corner)continue;const S=a.get(y)||w(y);if(!S||Math.abs(f(S)-A)>1.6)continue;const L=m(S);d=(L.lo+L.hi)/2;break}const z=(X.lo+X.hi)/2,n=d!=null&&z<d?-1:1;let b=0;const q=Math.max(...N.map(y=>m(a.get(y)).hi)),v=Math.min(...N.map(y=>m(a.get(y)).lo));if(n>0?b=Math.max(0,q+.005-X.lo):b=Math.min(0,v-.005-X.hi),Math.abs(b)>.005){const y=g.get(i);g.set(i,{position:[y.position[0]+r*b,y.position[1],y.position[2]+c*b],rotation:y.rotation}),a.set(i,w(i))}}}}const at=p=>String(p?.variantId??p?.productId??""),gt=p=>{const x=et(p);if(x!=null)return pt.get(x)||null;const w=it(p)||[],Z=new Set(w.map(a=>String(a?.hostVariantId??a?.host_variant_id)));return R.find(a=>a!==p&&Z.has(at(a)))||null};let $=U.slice(),st=!0;for(;$.length&&st;){st=!1;const p=[];for(const x of $){const w=gt(x),Z=w?g.get(w):null;if(!Z){p.push(x);continue}const a=ut(W(x),at(w)),s=Z.position||[0,0,0],t=(Array.isArray(Z.rotation)?Z.rotation[1]:0)||0,o=Math.cos(t),M=Math.sin(t),i=a&&Array.isArray(a.position)?a.position:[0,0,0],e=(O.getDims?.(w.productId)??O.getDims?.(w.variantId)??null)?.cx||0,r=ft(Array.isArray(x?.position)?x.position[1]:null),c=[s[0]+e*o+(i[2]||0)*M,r??s[1]+(i[1]||0),s[2]-e*M+(i[2]||0)*o],l=a&&Array.isArray(a.rotation)?(a.rotation[1]||0)*Math.PI/180:0;g.set(x,{position:c,rotation:[0,t+l,0]}),st=!0}$=p}for(const p of $){const x=Array.isArray(p?.position)?p.position:[];g.set(p,{position:x.length?x:[0,0,0],rotation:p?.rotation||[0,0,0]})}{const x=[],w=t=>{const o=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,M=W(t);return{w:o?.width>0?o.width:M?.width>0?M.width*.0254:.9,dp:o?.depth>0?o.depth:M?.depth>0?M.depth*.0254:.6,h:o?.height>0?o.height:M?.height>0?M.height*.0254:.9,cx:o?.cx||0,cz:o?.cz||0}},Z=t=>{const o=g.get(t);if(!o)return null;const[M,i,h]=o.position,e=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,{w:r,dp:c,h:l,cx:u,cz:m}=w(t),f=Math.cos(e),A=Math.sin(e),X=M+u*f+m*A,I=h-u*A+m*f,N=Math.abs(f),d=Math.abs(A),z=(r*N+c*d)/2,n=(r*d+c*N)/2;return{minX:X-z,maxX:X+z,minZ:I-n,maxZ:I+n,minY:i,maxY:i+l}};let a=1/0;for(const t of R){const o=g.get(t)?.position?.[1]||0;o>.01&&o<a&&(a=o)}const s=t=>(g.get(t)?.position?.[1]||0)>.01;for(const t of U){const o=Z(t);if(!o||o.maxY<=a+.05)continue;const M=-((Array.isArray(g.get(t)?.rotation)?g.get(t).rotation[1]:0)||0),i=Math.cos(M),h=Math.sin(M),e=-h,r=i,c=n=>Math.min(n.minX*i+n.minZ*h,n.maxX*i+n.maxZ*h),l=n=>Math.max(n.minX*i+n.minZ*h,n.maxX*i+n.maxZ*h),u=n=>(n.minX+n.maxX)/2*e+(n.minZ+n.maxZ)/2*r,m=n=>(n.minX+n.maxX)/2*i+(n.minZ+n.maxZ)/2*h,f=c(o),A=l(o),X=(f+A)/2,I=u(o);let N=null;for(const n of[...j,...U]){if(!n?.corner)continue;const b=Z(n);if(b&&!(Math.abs(u(b)-I)>1.6)){N=m(b);break}}const d=N!=null&&X<N?-1:1,z=[];for(const n of j){if(C(n)||!s(n))continue;const b=Z(n);if(!b)continue;const q=-((Array.isArray(g.get(n)?.rotation)?g.get(n).rotation[1]:0)||0);Math.abs(Math.cos(M-q))<.9||Math.abs(u(b)-I)>1||z.push({inst:n,lo:c(b),hi:l(b)})}if(d>0){const n=z.filter(q=>q.hi>f),b=n.filter(q=>q.lo<A);if(b.length){const q=A-Math.min(...b.map(v=>v.lo))+.01;for(const{inst:v}of n){const y=g.get(v);g.set(v,{...y,position:[y.position[0]+i*q,y.position[1],y.position[2]+h*q]})}x.push({chimShift:+q.toFixed(3),dir:"+run",n:n.length})}}else{const n=z.filter(q=>q.lo<A),b=n.filter(q=>q.hi>f);if(b.length){const q=Math.max(...b.map(v=>v.hi))-f+.01;for(const{inst:v}of n){const y=g.get(v);g.set(v,{...y,position:[y.position[0]-i*q,y.position[1],y.position[2]-h*q]})}x.push({chimShift:+q.toFixed(3),dir:"-run",n:n.length})}}}}{const x=s=>{const t=O.getDims?.(s.productId)??O.getDims?.(s.variantId)??null,o=H?.(s.variantId)||H?.(s.productId);return{w:t?.width>0?t.width:o?.width>0?o.width*.0254:.9,dp:t?.depth>0?t.depth:o?.depth>0?o.depth*.0254:.6,h:t?.height>0?t.height:o?.height>0?o.height*.0254:.9,cx:t?.cx||0,cz:t?.cz||0}},w=s=>{const t=g.get(s);if(!t)return null;const[o,M,i]=t.position,h=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{w:e,dp:r,h:c,cx:l,cz:u}=x(s),m=Math.cos(h),f=Math.sin(h),A=o+l*m+u*f,X=i-l*f+u*m,I=Math.abs(m),N=Math.abs(f),d=(e*I+r*N)/2,z=(e*N+r*I)/2;return{minX:A-d,maxX:A+d,minZ:X-z,maxZ:X+z,minY:M,maxY:M+c}},Z=(s,t)=>s&&t&&s.minX<t.maxX-.02&&s.maxX>t.minX+.02&&s.minZ<t.maxZ-.02&&s.maxZ>t.minZ+.02&&s.minY<t.maxY-.02&&s.maxY>t.minY+.02;let a=1/0;for(const s of R){const t=g.get(s)?.position?.[1]||0;t>.01&&t<a&&(a=t)}if(Number.isFinite(a)){const s=new Map;for(const i of R){const h=w(i);h&&s.set(i,h)}const t=i=>(g.get(i)?.position?.[1]||0)>.01,o=R.filter(i=>{if(C(i))return!1;const h=s.get(i);return h&&!t(i)&&h.maxY>a+.05}),M=new Set(o);for(const i of o){const h=-(g.get(i)?.rotation?.[1]||0),e=Math.cos(h),r=Math.sin(h),c=d=>({lo:Math.min(d.minX*e+d.minZ*r,d.maxX*e+d.maxZ*r),hi:Math.max(d.minX*e+d.minZ*r,d.maxX*e+d.maxZ*r)});let l=s.get(i),u=1/0,m=-1/0,f=!1;for(const d of R){if(d===i||M.has(d)||!t(d))continue;const z=s.get(d);if(!z||!Z(l,z))continue;const n=c(z);u=Math.min(u,n.lo),m=Math.max(m,n.hi),f=!0}if(!f)continue;const A=c(l),X=(A.lo+A.hi)/2,I=(u+m)/2,N=X>=I?m+.005-A.lo:u-.005-A.hi;if(Math.abs(N)>.002){const d=g.get(i);g.set(i,{position:[d.position[0]+e*N,d.position[1],d.position[2]+r*N],rotation:d.rotation}),l=w(i),s.set(i,l)}}}}{const x=s=>{const t=O.getDims?.(s.productId)??O.getDims?.(s.variantId)??null,o=W(s),M=t?.width>.05&&t?.depth>.05;return{w:M?t.width:o?.width>0?o.width*.0254:.9,dp:M?t.depth:o?.depth>0?o.depth*.0254:.6,cx:M&&t.cx||0,cz:M&&t.cz||0}},w=s=>{const t=g.get(s);if(!t)return null;const[o,,M]=t.position,i=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{cx:h,cz:e}=x(s);return{x:o+h*Math.cos(i)+e*Math.sin(i),z:M-h*Math.sin(i)+e*Math.cos(i),y:t.position[1],r:i}},Z=s=>{const t=w(s);if(!t)return null;const{w:o,dp:M}=x(s),i=Math.abs(Math.cos(t.r)),h=Math.abs(Math.sin(t.r)),e=(o*i+M*h)/2,r=(o*h+M*i)/2;return{minX:t.x-e,maxX:t.x+e,minZ:t.z-r,maxZ:t.z+r}},a=(s,t)=>s&&t&&s.minX<t.maxX-.04&&s.maxX>t.minX+.04&&s.minZ<t.maxZ-.04&&s.maxZ>t.minZ+.04;for(const[,s]of G){const t=s.filter(n=>C(n)&&Number.isFinite(Number(n.sequence))).map(n=>({inst:n,seq:Number(n.sequence)})).sort((n,b)=>n.seq-b.seq);if(!t.length)continue;const o=t[t.length-1].inst,M=t[t.length-1].seq,i=s.filter(n=>!C(n)&&Number.isFinite(Number(n.sequence))).sort((n,b)=>Number(n.sequence)-Number(b.sequence)),h=[];for(const n of t){const b=Z(n.inst);b&&h.push(b)}const e=[];for(const n of i){const b=Z(n);b&&(h.some(q=>a(b,q))?e.push(n):h.push(b))}if(!e.length)continue;const r=i.filter(n=>Number(n.sequence)>M&&!e.includes(n)),c=r.length?(Array.isArray(g.get(r[0])?.rotation)?g.get(r[0]).rotation[1]:0)||0:((Array.isArray(g.get(o)?.rotation)?g.get(o).rotation[1]:0)||0)-Math.PI/2,l=-c,u=Math.cos(l),m=Math.sin(l),f=-m,A=u,X=n=>n.x*u+n.z*m,I=w(o);if(!I)continue;const N=r.length?(()=>{const n=w(r[0]);return n?n.x*f+n.z*A:I.x*f+I.z*A})():I.x*f+I.z*A;let d,z;if(r.length){const n=w(r[0]);d=Math.sign(X(n)-X(I))||1,z=Math.max(...r.map(b=>{const q=w(b);return q?X(q)+d*x(b).w/2:-1/0}))}else{d=1;const n=x(o);z=X(I)+d*(Math.abs(Math.cos(I.r+l))*(n.w/2)+Math.abs(Math.sin(I.r+l))*(n.dp/2))}if(Number.isFinite(z))for(const n of e){const b=w(n);if(!b)continue;const{w:q,cx:v,cz:y}=x(n),S=z+d*q/2,L=S*u+N*f,_=S*m+N*A;g.set(n,{position:[L-(v*Math.cos(c)+y*Math.sin(c)),b.y,_-(-v*Math.sin(c)+y*Math.cos(c))],rotation:[0,c,0]}),z+=d*q}}}{const x=t=>{const o=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,M=W(t),i=o?.width>.05&&o?.depth>.05;return{w:i?o.width:M?.width>0?M.width*.0254:.9,dp:i?o.depth:M?.depth>0?M.depth*.0254:.6,cx:i&&o.cx||0,cz:i&&o.cz||0}},w=t=>{const o=g.get(t);if(!o)return null;const[M,,i]=o.position,h=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,{w:e,dp:r,cx:c,cz:l}=x(t),u=M+c*Math.cos(h)+l*Math.sin(h),m=i-c*Math.sin(h)+l*Math.cos(h),f=Math.abs(Math.cos(h)),A=Math.abs(Math.sin(h)),X=(e*f+r*A)/2,I=(e*A+r*f)/2;return{minX:u-X,maxX:u+X,minZ:m-I,maxZ:m+I}};let Z=0,a=0,s=0;for(const t of R){const o=g.get(t);o&&(Z+=o.position[0],a+=o.position[2],s+=1)}s&&(Z/=s,a/=s);for(const[,t]of G){const o=t.filter(e=>C(e)).map(e=>({b:w(e)})).filter(e=>e.b);if(!o.length)continue;const M=t.filter(e=>!C(e)).map(e=>({inst:e,b:w(e)})).filter(e=>e.b);for(const{b:e}of o){const r=(u,m)=>o.some(({b:f})=>f===e?!1:u==="x"?f.minZ<e.maxZ-.05&&f.maxZ>e.minZ+.05&&(m?f.minX>e.maxX:f.maxX<e.minX):f.minX<e.maxX-.05&&f.maxX>e.minX+.05&&(m?f.minZ>e.maxZ:f.maxZ<e.minZ)),c={xp:[],xn:[],zp:[],zn:[]};for(const{inst:u,b:m}of M){const f=m.minZ<e.maxZ-.05&&m.maxZ>e.minZ+.05,A=m.minX<e.maxX-.05&&m.maxX>e.minX+.05;f&&!A?m.minX>=e.maxX?c.xp.push({inst:u,gap:m.minX-e.maxX}):m.maxX<=e.minX&&c.xn.push({inst:u,gap:e.minX-m.maxX}):A&&!f&&(m.minZ>=e.maxZ?c.zp.push({inst:u,gap:m.minZ-e.maxZ}):m.maxZ<=e.minZ&&c.zn.push({inst:u,gap:e.minZ-m.maxZ}))}const l=(u,m,f,A)=>{if(!u.length||r(m,f))return;const X=Math.min(...u.map(N=>N.gap));if(X>.015&&X<.5){const N=A*X;for(const{inst:d}of u){const z=g.get(d);z&&g.set(d,{position:[z.position[0]+(m==="x"?N:0),z.position[1],z.position[2]+(m==="z"?N:0)],rotation:z.rotation})}}const I=m==="x"?"z":"x";for(const{inst:N}of u){const d=w(N),z=g.get(N);if(!(!d||!z))if(I==="z"){const n=mt((d.minZ+d.maxZ)/2,z.position[2],a),b=n?d.maxZ:d.minZ,v=(n?e.maxZ:e.minZ)-b;(n?v>0:v<0)&&Math.abs(v)>.015&&Math.abs(v)<.5&&g.set(N,{position:[z.position[0],z.position[1],z.position[2]+v],rotation:z.rotation})}else{const n=mt((d.minX+d.maxX)/2,z.position[0],Z),b=n?d.maxX:d.minX,v=(n?e.maxX:e.minX)-b;(n?v>0:v<0)&&Math.abs(v)>.015&&Math.abs(v)<.5&&g.set(N,{position:[z.position[0]+v,z.position[1],z.position[2]],rotation:z.rotation})}}};l(c.xp,"x",!0,-1),l(c.xn,"x",!1,1),l(c.zp,"z",!0,-1),l(c.zn,"z",!1,1)}const i=(e,r)=>r==="x"?(e.minX+e.maxX)/2:(e.minZ+e.maxZ)/2,h=(e,r)=>r==="x"?(e.minZ+e.maxZ)/2:(e.minX+e.maxX)/2;for(let e=0;e<o.length;e++)for(let r=e+1;r<o.length;r++){const c=o[e].b,l=o[r].b,u=Math.abs((c.minX+c.maxX)/2-(l.minX+l.maxX)/2),m=Math.abs((c.minZ+c.maxZ)/2-(l.minZ+l.maxZ)/2);let f=null;if(m<.35&&u>.5?f="x":u<.35&&m>.5&&(f="z"),!f)continue;const A=i(c,f)<i(l,f),X=A?c:l,I=A?l:c,N=f==="x"?X.maxX:X.maxZ,d=f==="x"?I.minX:I.minZ,z=h(X,f),n=t.filter(k=>!C(k)).map(k=>({inst:k,b:w(k)})).filter(({b:k})=>k&&i(k,f)>N-.15&&i(k,f)<d+.15&&Math.abs(h(k,f)-z)<.4).sort((k,V)=>i(k.b,f)-i(V.b,f));if(!n.length)continue;const b=n.map(({inst:k})=>x(k).w),q=b.reduce((k,V)=>k+V,0);if(q>d-N+.02)continue;const v=q/2;let y=0,S=n.length;for(let k=0;k<n.length;k++)if(y+=b[k],y>v){S=k;break}const L=(k,V)=>{const Y=g.get(k);if(!Y)return;const F=(Array.isArray(Y.rotation)?Y.rotation[1]:0)||0,{cx:D,cz:P}=x(k);f==="x"?g.set(k,{position:[V-(D*Math.cos(F)+P*Math.sin(F)),Y.position[1],Y.position[2]],rotation:Y.rotation}):g.set(k,{position:[Y.position[0],Y.position[1],V-(-D*Math.sin(F)+P*Math.cos(F))],rotation:Y.rotation})};let _=N;for(let k=0;k<S;k++)L(n[k].inst,_+b[k]/2),_+=b[k];_=d;for(let k=n.length-1;k>=S;k--)L(n[k].inst,_-b[k]/2),_-=b[k]}}}return dt(),R.map(p=>g.get(p)||{position:[0,0,0],rotation:[0,0,0]})}};import{appendTargetFor as Zt,neighborsFor as It,groupByPlacement as Nt}from"./dc812f3e14.js";function mt(E,O,H){const R=E-O;return R<-.01?!0:R>.01?!1:O>H}export{Zt as appendTargetFor,wt as default,Nt as groupByPlacement,It as neighborsFor};
|
package/dist/87bb469216.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as ne,jsx as g,jsxs as rt}from"react/jsx-runtime";import{useCallback as nt,useEffect as K,useMemo as X,useRef as te,useState as Pt,useSyncExternalStore as Ne}from"react";import{Html as un,useProgress as pn}from"@react-three/drei";import G from"./9c6c598569.js";import $ from"./872c4302e0.js";import R from"./be337ddda5.js";import mt from"./d94df858ea.js";import{normalizeMaterialTargets as hn}from"./dc2a1a0e13.js";import k from"./8f60e5059a.js";import mn from"./60d697292c.js";import fn from"./811b403d43.js";import{useUiToggles as gn}from"./d0f9681634.js";import{ProductInstance as ee,SelectionActionPanel as In,FreeMovable as Sn,PlacementGaps as yn,SceneStage as bn,SceneRoom as vn,SceneProductsSource as Pn}from"./8a3a57c008.js";import Mn from"./205827c5c8.js";import{computeTargets as xn,resolveTarget as wn,resolveTargetRenderer as Cn,resolveInsertSequence as _n}from"./58e6419ba8.js";import{disarmPlacement as Xe}from"./ab6c80484f.js";import{resolveComponent as Ze,useComponentRegistry as Tn}from"./882bc739c8.js";import{SlotHost as Gn}from"./73f7d65985.js";import{ModalHost as On}from"./09c4973968.js";import Fn from"./6c0a2572dd.js";import kn from"./20b0104576.js";import{getConfigState as An,subscribe as He,getVersion as Dt}from"./817d930a49.js";import{getPlacementStrategy as je}from"./281cf952fa.js";import{resolveAddMode as Dn,armPlacement as Rn}from"./ab6c80484f.js";import{resolveReplaceTarget as Ln}from"./4d7a0d1897.js";import{enforceCorners as zn}from"./388cadacbd.js";import{resolvePlacementStrategyConfig as Ve}from"./281cf952fa.js";import{getLabel as qn}from"./28d887bf8a.js";import{isAddFeature as En}from"./8c27edda0f.js";import{usePlacementInteraction as Nn}from"./4b8958aa4c.js";import{refreshCanonicalState as Xn,seedInitialState as Zn,addProduct as Rt}from"./a77b15c0d6.js";import{resolveLayout as Hn,hasLayout as jn,useLayoutRegistry as Vn,layoutOverride as Un,_publishResolvedLayoutKey as Wn}from"./31ea036f5c.js";import{themeLayoutKey as Yn,useSystemTheme as Bn}from"./5c9fd9201c.js";import"./1a2629800a.css";import{runIntent as Lt,INTENTS as zt}from"./6d238282c1.js";function Kn(){const x=mt(r=>r.sceneSelections),I=mt(r=>r.selectionOrder),h=G(r=>r.activeSceneConfigId),u=R(r=>r.defaultPresetId),i=R(r=>r.sceneConfigurations),O=R(r=>r.getSceneFeatures),S=Ne(He,Dt,Dt);return X(()=>{const r=h||u||Object.keys(i||{})[0],ft=r?O(r):[],U=$.getState(),b=[],Q=new Set,at=(c,F)=>{if(!c||c.id==null||Q.has(String(c.id))||F>4)return;Q.add(String(c.id)),b.push(c);const P=(U.features?.[c.id]||U.features?.[String(c.id)])?.childOptionSetIds||[];for(const M of P){const d=U.features?.[M]||U.features?.[String(M)];d&&at({id:M,type:d.type,sequence:d.sequence},F+1)}};for(const c of ft)at(c,0);const ct=b.filter(c=>/finish/i.test(c.type||"")&&x[c.id]!=null).sort((c,F)=>{const E=I?.[String(c.id)]??-1,P=I?.[String(F.id)]??-1;return E!==P?E-P:(c.sequence??0)-(F.sequence??0)}),y={};for(const c of ct){const F=x[c.id],E=U.options?.[F]?.value;if(E==null)continue;const P=U.features?.[c.id]||{},M=hn(P.materialTargets??P.material_targets??P.materials);for(const d of M)y[String(d).toLowerCase()]=E}return y},[x,I,h,u,i,O,S])}function $n(x,I){if(I==null)return null;const h=String(I);for(const u of Object.values(x.products||{})){const i=u?.components_configuration||u?.componentsConfiguration;if(!(!i||typeof i!="object"))for(const O of Object.values(i))for(const S of Array.isArray(O)?O:[O]){const r=S&&typeof S=="object"?S.componentId??S.component_id:S;if(r!=null&&String(r)===h)return u}}return null}function Qn(x){const I=mt(b=>b.sceneSelections),h=mt(b=>b.setSceneSelection),u=R(b=>b.getSceneFeatures),i=R(b=>b.sceneConfigurations),O=Ne(He,Dt,Dt),S=X(()=>new Set((x?u(x)||[]:[]).filter(b=>En(b)).map(b=>String(b.id))),[x,u,i,O]),r=te({}),ft=te(!1),U=mt(b=>b.sceneSelectionsSettled);K(()=>{if(!U){r.current={...I};return}if(!ft.current){ft.current=!0;let y=!1;for(const[c,F]of Object.entries(I||{}))F==null||!S.has(String(c))||(h(c,null),y=!0);if(y){r.current={...I};return}}const b=r.current,Q=[];for(const[y,c]of Object.entries(I||{}))b[y]===c||c==null||S.has(String(y))&&Q.push([y,c]);if(r.current={...I},!Q.length)return;const at=R.getState().systemId;let ct=!1;return(async()=>{const y=$.getState(),c=G.getState();for(const[F,E]of Q){const P=y.options?.[E];let M=P?.valueProductVariantId??P?.value_product_variant_id??P?.value_product_variant??P?.variantId??P?.variant_id??null,d=M!=null?y.getProduct?.(M):null;if(d==null){const m=P?.value??(y.optionToProducts?.[String(E)]||[])[0]??P?.product_id??P?.productId??null;d=m!=null?y.getProduct?.(m):null,d==null&&m!=null&&y.getComponent?.(m)&&(d=$n(y,m)),M=d?.id??M??m}else M=d?.id??M;if(M==null){h(F,null);continue}const it=d?.id??M,W=d?.placementGroup??d?.placement_group??null,J=d?.productGraph??d?.product_graph??null,lt=d?.compatibleSlots??d?.compatible_slots??null;if(Array.isArray(lt)&<.length){const m=new Set(lt.map(String));if(Object.values(c.productInstances||{}).some(Z=>{const f=y.getProduct?.(Z.variantId)||y.getProduct?.(Z.productId),It=f?.product_graph??f?.productGraph;return It!=null&&m.has(String(It))})){k.getState().setPendingSlotPlacement?.({productId:it,variantId:M,name:d?.name??d?.displayName??d?.variantName??"product",compatibleGraphIds:Array.from(m)}),h(F,null);continue}}if(Dn(at,d)==="arm"){Rn({productId:it,variantId:M});const m=je(),wt=typeof m?.computeTargets=="function",Z=Object.prototype.hasOwnProperty.call(m??{},"armHint")?m.armHint:qn(wt?"placement.armedPickTarget":"placement.armedPickGap",wt?"":"Click a + between pieces to insert it.");Z&&k.getState().showInfo?.(Z),h(F,null);continue}const z=G.getState(),Mt=z.selectedInstanceId,Y=Mt!=null?(z.productInstances||{})[Mt]:null,qt=Y&&Number.isFinite(Number(Y.sequence))?Number(Y.sequence):void 0,gt=Ln({placementGroup:W}),dt=gt!=null?(z.productInstances||{})[gt]:null,oe=dt&&Number.isFinite(Number(dt.sequence))?Number(dt.sequence):qt,se=Array.isArray(dt?.position)?dt.position:[0,0,0];let xt=null;try{xt=await Lt({type:zt.PRODUCT_ADD,productGraphId:J,variantId:M,placementGroup:W,sequence:oe,replacePlacementId:gt??void 0},m=>Rt({productGraphId:m.productGraphId,variantId:m.variantId,placementGroup:m.placementGroup,position:se,sequence:m.sequence,replace:m.replacePlacementId!=null,replacePlacementId:m.replacePlacementId}))}catch{}if(h(F,null),ct)return}})(),()=>{ct=!0}},[I,S,x,h])}function Jn({position:x,onClick:I}){const[h,u]=Pt(!1);return g(un,{position:x,center:!0,style:{pointerEvents:"auto"},zIndexRange:[100,0],children:g("div",{onClick:I,onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),style:{width:22,height:22,borderRadius:"50%",background:h?"#ff8a65":"rgba(255, 87, 34, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--bg-primary, #fff)",fontSize:13,fontWeight:"bold",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",cursor:"pointer",transition:"transform 0.2s",transform:h?"scale(1.15)":"scale(1)"},children:"+"})})}function to({isMobile:x}={}){Tn();const I=Ze("SelectionActionPanel",In),h=G(t=>t.productInstances),u=$(t=>t.getProduct),i=$(t=>t.componentGroups),O=G(t=>t.clearSelection),S=G(t=>t.selectedInstanceId),r=G(t=>t.isFocusing),ft=G(t=>t.removeProductInstance),U=G(t=>t.addProductInstance),b=G(t=>t.updateInstancePosition),Q=G(t=>t.updateInstanceRotation),at=G(t=>t.activeSceneConfigId),ct=R(t=>t.defaultPresetId),y=R(t=>t.sceneConfigurations),c=R(t=>t.systemId),F=R(t=>t.useTransform),E=k(t=>t.sceneCapabilities),P=k(t=>t.showWalls),M=k(t=>t.showDimensions),d=k(t=>t.pendingSlotPlacement),it=Kn(),W=k(t=>t.hostMaterialOverrides),J=(An()||{}).room||null,lt=at||ct||Object.keys(y||{})[0]||null;Qn(lt);const[z,Mt]=Pt(!0),[Y,qt]=Pt(!1),gt=nt(async()=>{try{await Zn()}catch{}qt(!0)},[]),{edgeOf:dt,cornerOf:oe,isHostAnchored:se,isMovable:xt,rawFree:m,splitReliable:wt,freeInstances:Z,ordered:f,syntheticHosts:It,moveInFlightRef:no}=mn(),Ct=X(()=>new Map(It.map(t=>[t.hostedProductId,t])),[It]),[St,We]=Pt({}),Et=nt((t,e)=>{We(n=>{const o=n[t],a=e.full||null;return o&&o.width===e.width&&o.depth===e.depth&&o.height===e.height&&o.cx===e.cx&&o.cz===e.cz&&(o.full?.width??null)===(a?.width??null)&&(o.full?.height??null)===(a?.height??null)&&(o.full?.depth??null)===(a?.depth??null)?n:{...n,[t]:{width:e.width,depth:e.depth,height:e.height,cx:e.cx,cz:e.cz,full:a}}})},[]),ut=nt(t=>St[t]||null,[St]),re=$(t=>t.placementBoundsExcludeIds),ae=X(()=>new Set((re||[]).map(t=>String(t))),[re]),Nt=nt((t,e)=>{const n=t?.componentId??e?.id??e?.componentId??null;return n!=null&&ae.has(String(n))||/leg|arm/i.test(String(t?.slotKey||""))?!0:(e?.groups||e?.group_ids||[]).some(a=>{const l=i?.[a]||i?.[String(a)];return/leg|arm/i.test(String(l?.name??l?.slotKey??l?.slot_key??""))})},[i,ae]),yt=te(!1),L=f.length+Z.length,Xt=X(()=>[...f,...Z],[f,Z]),pt=L>0&&Xt.every(t=>St[t.productId]),_t=X(()=>Xt.filter(t=>St[t.productId]).length,[Xt,St]),{active:ce,loaded:ie,total:Zt}=pn(),le=k(t=>t.isEvaluating),Tt=k(t=>t.isLayoutLoading),de=k(t=>t.bootEvaluating);K(()=>{if(!Y)return;const t=!ce&&(Zt===0||ie>=Zt),e=(pt||L===0)&&t&&!le&&!de,n=()=>{Mt(!1),k.getState().endBootLoading()};if(e){const a=setTimeout(n,900);return()=>clearTimeout(a)}const o=setTimeout(n,15e3);return()=>clearTimeout(o)},[Y,pt,L,_t,ce,ie,Zt,le,de]);const[ue,pe]=Pt(!1);K(()=>{if(!z){pe(!1);return}(pt&&L>0||Y&&L===0)&&pe(!0)},[pt,L,Y,z]);const he=Y?ue||L===0?"Finishing up\u2026":`Loading products\u2026 ${Math.min(_t,L)}/${L}`:"Preparing your configurator\u2026",me=ue?100:L>0?Math.min(Math.round(_t/L*100),92):0;K(()=>{z&&k.getState().setBootPhase(he,me)},[z,he,me]),K(()=>(k.setState({initialSceneLoading:z}),()=>k.setState({initialSceneLoading:!1})),[z]),K(()=>{Tt&&(yt.current=!1)},[Tt]),K(()=>{if(L===0){yt.current=!1;return}if(yt.current||z||Tt||!pt)return;const t=setTimeout(()=>{yt.current||(G.getState().resetCameraToDefault?.({instant:!0}),yt.current=!0)},250);return()=>clearTimeout(t)},[L,_t,z,Tt,pt]);const bt=je(),Gt=X(()=>f.map(t=>{const e=Ct.get(t.id);return e?{...t,productId:e.hostVariantId}:t}),[f,Ct]),fe=F||!!y?.[lt]?.useTransform,N=G(t=>t.pendingPlacementPiece),ge=!!N&&typeof bt?.computeTargets=="function"&&!!Cn(),ot=X(()=>{const t={getProduct:u,getDims:ut,useTransform:fe,candidate:N,openSlots:ge,config:Ve()},e=bt.computeLayout?bt.computeLayout(Gt,t):Gt.map(()=>({position:[0,0,0],rotation:[0,0,0]}));return zn(e,Gt,t,bt)},[bt,Gt,u,ut,fe,N,ge]),H=X(()=>{const e=J?.height>0?J.height:2.7,n=.1,o=.05,a=new Map;let l=1/0,w=-1/0,A=1/0,p=-1/0,j=0,D=!1;if(f.forEach((s,V)=>{const C=ot[V];if(!C||xt(s))return;const v=C.position||[0,0,0],_=ut(s.productId),B=u(s.productId),q=_?.full||_,Kt=q?.height>0?q.height:B?.height>0?B.height*.0254:0,kt=(v[1]||0)+Kt;if(kt>j&&(j=kt),(s.positionedAbove??s.positioned_above)!=null)return;const $t=(v[1]||0)<=.01,At=-((Array.isArray(C.rotation)?C.rotation[1]:0)||0),Qt=_?.depth>0?_.depth:B?.depth>0?B.depth*.0254:.6,Jt=_?.width>0?_.width:B?.width>0?B.width*.0254:.9,tt=Math.cos(At),et=Math.sin(At),Me=_?.cx||0,xe=_?.cz||0,we=v[0]+tt*Me-et*xe,Ce=v[2]+et*Me+tt*xe,_e=(Jt*Math.abs(tt)+Qt*Math.abs(et))/2,Te=(Jt*Math.abs(et)+Qt*Math.abs(tt))/2,Ge=we-_e,Oe=we+_e,Fe=Ce-Te,ke=Ce+Te,Ae=q?.width>0?q.width:Jt,De=q?.depth>0?q.depth:Qt,Re=v[0]+tt*(q?.cx||0)-et*(q?.cz||0),Le=v[2]+et*(q?.cx||0)+tt*(q?.cz||0),ze=(Ae*Math.abs(tt)+De*Math.abs(et))/2,qe=(Ae*Math.abs(et)+De*Math.abs(tt))/2,an=Re-ze,cn=Re+ze,ln=Le-qe,dn=Le+qe,Ee=String((Math.round(At/(Math.PI/2))%4+4)%4),T=a.get(Ee)||{heading:At,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,fMinX:1/0,fMaxX:-1/0,fMinZ:1/0,fMaxZ:-1/0,hasFloor:!1};T.minX=Math.min(T.minX,Ge),T.maxX=Math.max(T.maxX,Oe),T.minZ=Math.min(T.minZ,Fe),T.maxZ=Math.max(T.maxZ,ke),$t&&(T.fMinX=Math.min(T.fMinX,Ge),T.fMaxX=Math.max(T.fMaxX,Oe),T.fMinZ=Math.min(T.fMinZ,Fe),T.fMaxZ=Math.max(T.fMaxZ,ke),T.hasFloor=!0),a.set(Ee,T),l=Math.min(l,an),w=Math.max(w,cn),A=Math.min(A,ln),p=Math.max(p,dn),D=!0}),!D)return null;const ht=Math.max(e,j>0?j+.02:e),Ot=[...a.values()].map(s=>{const V=Math.sin(s.heading),C=Math.cos(s.heading),v=V,_=-C,B=Math.abs(v)>Math.abs(_),q=s.hasFloor?s.fMinX:s.minX,Kt=s.hasFloor?s.fMaxX:s.maxX,kt=s.hasFloor?s.fMinZ:s.minZ,$t=s.hasFloor?s.fMaxZ:s.maxZ,Pe=B?(v>0?Kt:q)+(v>0?n/2:-n/2):(_>0?$t:kt)+(_>0?n/2:-n/2);return{g:s,isSide:B,plane:Pe}}),nn=Ot.filter(s=>s.isSide).map(s=>s.plane),on=Ot.filter(s=>!s.isSide).map(s=>s.plane),Vt=[];for(const s of Ot){const{g:V}=s;if(s.isSide){let C=V.minZ,v=V.maxZ;for(const _ of on)C=Math.min(C,_),v=Math.max(v,_);Vt.push({cx:s.plane,cz:(C+v)/2,cy:ht/2,length:v-C+o*2,thickness:n,height:ht,rotY:Math.PI/2})}else{let C=V.minX,v=V.maxX;for(const _ of nn)C=Math.min(C,_),v=Math.max(v,_);Vt.push({cx:(C+v)/2,cz:s.plane,cy:ht/2,length:v-C+o*2,thickness:n,height:ht,rotY:0})}}const Ft=.4,ve=w>l&&p>A;let Ut=l-Ft,Wt=w+Ft,Yt=A-Ft,Bt=p+Ft;for(const s of Ot){const V=Math.sin(s.g.heading),C=-Math.cos(s.g.heading);s.isSide?V<0?Ut=s.plane-n/2:Wt=s.plane+n/2:C<0?Yt=s.plane-n/2:Bt=s.plane+n/2}const sn=ve?{cx:(Ut+Wt)/2,cz:(Yt+Bt)/2,w:Wt-Ut,d:Bt-Yt}:null,rn=ve?{minX:l,maxX:w,minZ:A,maxZ:p,w:w-l,d:p-A,h:ht,height:j>0?j:ht}:null;return{segments:Vt,floor:sn,bbox:rn}},[f,ot,J,ut,u,xt]),Ye=P&&!!(H&&H.segments&&H.segments.length),Be=M&&!!(H&&H.bbox&&H.bbox.w>0),Ke=(t,e)=>{const n=ot[e]||{position:[0,0,0],rotation:[0,0,0]},o=Ct.get(t.id);if(!o)return n;const a=n.position||[0,0,0],l=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,w=Math.cos(l),A=Math.sin(l),p=o.offset||[0,0,0];return{position:[a[0]+(p[0]||0)*w+(p[2]||0)*A,a[1]+(p[1]||0),a[2]-(p[0]||0)*A+(p[2]||0)*w],rotation:[0,l+(o.rotDegY||0)*Math.PI/180,0]}},st=d,vt=!!st,Ie=X(()=>{if(!st)return new Set;const t=new Set((st.compatibleGraphIds||[]).map(String)),e=new Set;for(const n of Object.values(h||{})){const o=u(n.variantId)||u(n.productId),a=o?.product_graph??o?.productGraph;a!=null&&t.has(String(a))&&e.add(String(n.id))}return e},[st,h,u]),Ht=nt(()=>{k.getState().clearPendingSlotPlacement?.(),k.getState().clearPendingHostedProduct?.()},[]),Se=nt((t,e)=>{if(!e)return;const n=$.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=G.getState().productInstances?.[String(t)],w=o?.placementGroup??o?.placement_group??l?.placementGroup??null,A=Array.isArray(l?.position)?l.position:[0,0,0],p=l?.variantId??l?.productId??null,j=Number.isFinite(Number(l?.sequence))?Number(l.sequence):void 0;Ht(),Lt({type:zt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:w,sequence:j,hostPlacementId:String(t),hostVariantId:p},D=>Rt({productGraphId:D.productGraphId,variantId:D.variantId,placementGroup:D.placementGroup,position:A,sequence:D.sequence,hostPlacementId:D.hostPlacementId,hostVariantId:D.hostVariantId}).catch(()=>{}))},[Ht]),jt=nt((t,e)=>{const n=$.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,w=f[t-1]||f[t],A=Array.isArray(w?.position)?w.position:[0,0,0],p=f[t],j=p&&Number.isFinite(Number(p.sequence))?Number(p.sequence):void 0;Lt({type:zt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,sequence:j},D=>Rt({productGraphId:D.productGraphId,variantId:D.variantId,placementGroup:D.placementGroup,position:A,sequence:D.sequence}).catch(()=>{}))},[f]);K(()=>{if(!N||f.length>0)return;const t=N;Xe(),jt(0,t)},[N,f.length,jt]);const{gaps:$e,onInsert:Qe}=Nn({systemId:c,count:f.length,positionOf:t=>ot[t]?.position||[0,0,0],insertAt:jt}),ye=X(()=>{if(!N)return[];const t=$.getState();return xn(f,{candidate:N,getProduct:e=>t.getProduct?.(e),getDims:ut,config:Ve(),layout:ot})},[N,f,ot,ut]),Je=nt(t=>{const e=wn(t,{candidate:N});if(!e)return;const n=$.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,w=e.transform?.position??t.position??[0,0,0],A=_n(e,t,f);Lt({type:zt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,anchor:e.anchor??null,sequence:A},p=>Rt({productGraphId:p.productGraphId,variantId:p.variantId,placementGroup:p.placementGroup,position:w,sequence:p.sequence}).catch(()=>{})),Xe()},[N,f]),{selectedInst:oo,swapOrder:so,panelActions:be,priceInfo:tn}=fn(),en=gn()("selectionPanel");K(()=>{if(S==null)return;const t=h||{},e=String(S),n="__host";if(e.endsWith(n)){const o=e.slice(0,-n.length);if(t[o]||Object.values(t).some(a=>String(a?.id??a?.instanceId)===o))return}else if(t[S]||Object.values(t).some(o=>String(o?.instanceId??o?.id)===e))return;O?.()},[S,h,O]);const ao=mt(t=>t.placementPricing),co=R(t=>t.getChannelPriceConfig);return rt(ne,{children:[g(Pn,{onSeeded:gt}),rt(bn,{isMobile:x,camera:{position:[2.6,2.2,4],fov:45},controlsTarget:[0,.5,0],onPointerMissed:()=>O?.(),groundShadowCatcher:!0,overlay:rt(ne,{children:[!vt&&be&&en?g(I,{actions:be,priceInfo:tn}):null,vt&&g("div",{className:"placement-mode-overlay",children:rt("div",{className:"placement-mode-overlay__content",children:[rt("span",{className:"placement-mode-overlay__text",children:["Click on a highlighted slot to place ",g("strong",{children:st?.name})]}),g("button",{type:"button",className:"placement-mode-overlay__cancel",onClick:Ht,children:g("span",{className:"placement-mode-overlay__cancel-text",children:"Cancel"})})]})}),g(Gn,{name:"overlay"}),r&&g("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,zIndex:30,cursor:"default"}})]}),children:[Ye&&g(vn,{width:J?.width,depth:J?.depth,height:J?.height??H?.bbox?.h??2.7,showCeiling:E?.ceiling===!0,segments:H?.segments||null,floor:H?.floor||null}),Be&&(()=>{const t=Ze("SceneDimensions",kn);return g(t,{bbox:H.bbox})})(),f.map((t,e)=>{const n=Ct.get(t.id),o=ot[e]||{position:[0,0,0],rotation:[0,0,0]};return o.hidden?null:rt("group",{children:[n&&g(ee,{instance:{id:n.id,instanceId:n.id,productId:n.hostVariantId,variantId:n.hostVariantId,position:o.position||[0,0,0],rotation:o.rotation||[0,0,0]},slotMaterials:{...it,...W?.[n.hostedProductId]||{},...W?.[n.id]||{}},stateInstanceId:n.hostedProductId,onSelect:()=>G.getState().selectInstance(n.id),isSelected:String(S)===String(n.id),onMeasure:a=>Et(n.hostVariantId,a),footprintExcludeItem:Nt,hoverable:!0,focusable:!0},n.id),g(ee,{instance:{...t,...Ke(t,e)},slotMaterials:{...it,...W?.[t.id]||W?.[t.instanceId]||{}},onSelect:(a,l,w)=>{if(vt){Ie.has(String(t.id))&&Se(t.id,st);return}G.getState().selectInstance(a,w??null)},isSelected:!vt&&String(S)===String(t.instanceId??t.id),onMeasure:a=>Et(t.productId,a),footprintExcludeItem:Nt,hoverable:!0,focusable:!0}),vt&&Ie.has(String(t.id))&&g(Jn,{position:[o.position?.[0]||0,(o.position?.[1]||0)+.45,o.position?.[2]||0],onClick:()=>Se(t.id,st)})]},t.id??t.instanceId??e)}),Z.map((t,e)=>g(Sn,{selected:S===t.id,disabled:!!t.locked,position:t.position||[0,0,0],rotationY:(Array.isArray(t.rotation)&&t.rotation[1]||0)*Math.PI/180,onCommit:({position:n,rotationY:o})=>{b(t.id,n),Q(t.id,[0,o*180/Math.PI,0]),Xn({allowRevert:!0}).catch(()=>{})},children:g(ee,{instance:{...t,position:[0,0,0],rotation:[0,0,0]},slotMaterials:{...it,...W?.[t.id]||W?.[t.instanceId]||{}},onMeasure:n=>Et(t.productId,n),footprintExcludeItem:Nt})},t.id??t.instanceId??`free-${e}`)),ye.length>0?g(Mn,{targets:ye,onPick:Je}):g(yn,{gaps:$e,onInsert:Qe})]})]})}const Ue=new Set;function eo(){Vn();const x=R(r=>r.systemLayoutTemplate),I=R(r=>r.systemTheme),h=R(r=>r.systemThemeRecord);Bn(I,h);const u=Yn(h)||(I?String(I).trim().toLowerCase():null);let i=x;try{const r=new URLSearchParams(window.location.search);r.has("template")?i=r.get("template"):r.has("theme")&&(i=r.get("theme"))}catch{}i=i||x||u||null;const O=Un();O&&(i=O),!O&&!x&&i&&i===u&&!jn(i)&&!/^theme\d+$/.test(i)&&!Ue.has(i)&&Ue.add(i),Wn(i);const S=Hn(i);return rt(ne,{children:[g(S,{Scene:to,template:i}),g(On,{}),g(Fn,{})]})}export{to as SharedConfiguratorScene,eo as default};
|
|
1
|
+
import{Fragment as ue,jsx as f,jsxs as it}from"react/jsx-runtime";import{useCallback as Y,useEffect as N,useMemo as Z,useRef as Mt,useState as Pt,useSyncExternalStore as We}from"react";import{Html as bn,useProgress as yn}from"@react-three/drei";import O from"./9c6c598569.js";import K from"./872c4302e0.js";import z from"./be337ddda5.js";import ft from"./d94df858ea.js";import{normalizeMaterialTargets as vn}from"./dc2a1a0e13.js";import S from"./8f60e5059a.js";import Mn from"./60d697292c.js";import Pn from"./811b403d43.js";import{useUiToggles as xn}from"./d0f9681634.js";import{ProductInstance as le,SelectionActionPanel as wn,FreeMovable as Cn,PlacementGaps as _n,SceneStage as Tn,SceneRoom as Fn,SceneProductsSource as On}from"./8a3a57c008.js";import Gn from"./205827c5c8.js";import{computeTargets as Ln,resolveTarget as kn,resolveTargetRenderer as An,resolveInsertSequence as Dn}from"./58e6419ba8.js";import{disarmPlacement as Ye}from"./ab6c80484f.js";import{resolveComponent as de,useComponentRegistry as Ke}from"./882bc739c8.js";import Rn from"./88251d6671.js";import{useLabels as zn}from"./28d887bf8a.js";import{SlotHost as En}from"./73f7d65985.js";import{ModalHost as Nn}from"./09c4973968.js";import qn from"./6c0a2572dd.js";import Xn from"./20b0104576.js";import{getConfigState as Zn,subscribe as $e,getVersion as Et}from"./817d930a49.js";import{getPlacementStrategy as Qe}from"./281cf952fa.js";import{resolveAddMode as Hn,armPlacement as jn}from"./ab6c80484f.js";import{resolveReplaceTarget as Vn}from"./4d7a0d1897.js";import{enforceCorners as Un}from"./388cadacbd.js";import{resolvePlacementStrategyConfig as Je}from"./281cf952fa.js";import{getLabel as Bn}from"./28d887bf8a.js";import{isAddFeature as Wn}from"./8c27edda0f.js";import{usePlacementInteraction as Yn}from"./4b8958aa4c.js";import{refreshCanonicalState as Kn,seedInitialState as $n,addProduct as Nt}from"./a77b15c0d6.js";import{resolveLayout as Qn,hasLayout as Jn,useLayoutRegistry as to,layoutOverride as eo,_publishResolvedLayoutKey as no}from"./31ea036f5c.js";import{themeLayoutKey as oo,useSystemTheme as so}from"./5c9fd9201c.js";import"./1a2629800a.css";import{runIntent as qt,INTENTS as Xt}from"./6d238282c1.js";function ro(){const w=ft(r=>r.sceneSelections),g=ft(r=>r.selectionOrder),m=O(r=>r.activeSceneConfigId),u=z(r=>r.defaultPresetId),i=z(r=>r.sceneConfigurations),G=z(r=>r.getSceneFeatures),I=We($e,Et,Et);return Z(()=>{const r=m||u||Object.keys(i||{})[0],$=r?G(r):[],H=K.getState(),b=[],Q=new Set,lt=(c,L)=>{if(!c||c.id==null||Q.has(String(c.id))||L>4)return;Q.add(String(c.id)),b.push(c);const P=(H.features?.[c.id]||H.features?.[String(c.id)])?.childOptionSetIds||[];for(const y of P){const d=H.features?.[y]||H.features?.[String(y)];d&<({id:y,type:d.type,sequence:d.sequence},L+1)}};for(const c of $)lt(c,0);const mt=b.filter(c=>/finish/i.test(c.type||"")&&w[c.id]!=null).sort((c,L)=>{const q=g?.[String(c.id)]??-1,P=g?.[String(L.id)]??-1;return q!==P?q-P:(c.sequence??0)-(L.sequence??0)}),M={};for(const c of mt){const L=w[c.id],q=H.options?.[L]?.value;if(q==null)continue;const P=H.features?.[c.id]||{},y=vn(P.materialTargets??P.material_targets??P.materials);for(const d of y)M[String(d).toLowerCase()]=q}return M},[w,g,m,u,i,G,I])}function ao(w,g){if(g==null)return null;const m=String(g);for(const u of Object.values(w.products||{})){const i=u?.components_configuration||u?.componentsConfiguration;if(!(!i||typeof i!="object"))for(const G of Object.values(i))for(const I of Array.isArray(G)?G:[G]){const r=I&&typeof I=="object"?I.componentId??I.component_id:I;if(r!=null&&String(r)===m)return u}}return null}function co(w){const g=ft(b=>b.sceneSelections),m=ft(b=>b.setSceneSelection),u=z(b=>b.getSceneFeatures),i=z(b=>b.sceneConfigurations),G=We($e,Et,Et),I=Z(()=>new Set((w?u(w)||[]:[]).filter(b=>Wn(b)).map(b=>String(b.id))),[w,u,i,G]),r=Mt({}),$=Mt(!1),H=ft(b=>b.sceneSelectionsSettled);N(()=>{if(!H){r.current={...g};return}if(!$.current){$.current=!0;let M=!1;for(const[c,L]of Object.entries(g||{}))L==null||!I.has(String(c))||(m(c,null),M=!0);if(M){r.current={...g};return}}const b=r.current,Q=[];for(const[M,c]of Object.entries(g||{}))b[M]===c||c==null||I.has(String(M))&&Q.push([M,c]);if(r.current={...g},!Q.length)return;const lt=z.getState().systemId;let mt=!1;return(async()=>{const M=K.getState(),c=O.getState();for(const[L,q]of Q){const P=M.options?.[q];let y=P?.valueProductVariantId??P?.value_product_variant_id??P?.value_product_variant??P?.variantId??P?.variant_id??null,d=y!=null?M.getProduct?.(y):null;if(d==null){const p=P?.value??(M.optionToProducts?.[String(q)]||[])[0]??P?.product_id??P?.productId??null;d=p!=null?M.getProduct?.(p):null,d==null&&p!=null&&M.getComponent?.(p)&&(d=ao(M,p)),y=d?.id??y??p}else y=d?.id??y;if(y==null){m(L,null);continue}const xt=d?.id??y,wt=d?.placementGroup??d?.placement_group??null,Zt=d?.productGraph??d?.product_graph??null,gt=d?.compatibleSlots??d?.compatible_slots??null;if(Array.isArray(gt)&>.length){const p=new Set(gt.map(String));if(Object.values(c.productInstances||{}).some(pt=>{const Vt=M.getProduct?.(pt.variantId)||M.getProduct?.(pt.productId),St=Vt?.product_graph??Vt?.productGraph;return St!=null&&p.has(String(St))})){S.getState().setPendingSlotPlacement?.({productId:xt,variantId:y,name:d?.name??d?.displayName??d?.variantName??"product",compatibleGraphIds:Array.from(p)}),m(L,null);continue}}if(Hn(lt,d)==="arm"){jn({productId:xt,variantId:y});const p=Qe(),Ct=typeof p?.computeTargets=="function",pt=Object.prototype.hasOwnProperty.call(p??{},"armHint")?p.armHint:Bn(Ct?"placement.armedPickTarget":"placement.armedPickGap",Ct?"":"Click a + between pieces to insert it.");pt&&S.getState().showInfo?.(pt),m(L,null);continue}const It=O.getState(),dt=It.selectedInstanceId,j=dt!=null?(It.productInstances||{})[dt]:null,J=j&&Number.isFinite(Number(j.sequence))?Number(j.sequence):void 0,ut=Vn({placementGroup:wt}),A=ut!=null?(It.productInstances||{})[ut]:null,Ht=A&&Number.isFinite(Number(A.sequence))?Number(A.sequence):J,nt=Array.isArray(A?.position)?A.position:[0,0,0];let jt=null;try{jt=await qt({type:Xt.PRODUCT_ADD,productGraphId:Zt,variantId:y,placementGroup:wt,sequence:Ht,replacePlacementId:ut??void 0},p=>Nt({productGraphId:p.productGraphId,variantId:p.variantId,placementGroup:p.placementGroup,position:nt,sequence:p.sequence,replace:p.replacePlacementId!=null,replacePlacementId:p.replacePlacementId}))}catch{}if(m(L,null),mt)return}})(),()=>{mt=!0}},[g,I,w,m])}function io({position:w,onClick:g}){const[m,u]=Pt(!1);return f(bn,{position:w,center:!0,style:{pointerEvents:"auto"},zIndexRange:[100,0],children:f("div",{onClick:g,onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),style:{width:22,height:22,borderRadius:"50%",background:m?"#ff8a65":"rgba(255, 87, 34, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--bg-primary, #fff)",fontSize:13,fontWeight:"bold",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",cursor:"pointer",transition:"transform 0.2s",transform:m?"scale(1.15)":"scale(1)"},children:"+"})})}function lo({isMobile:w}={}){Ke();const g=de("SelectionActionPanel",wn),m=O(t=>t.productInstances),u=K(t=>t.getProduct),i=K(t=>t.componentGroups),G=O(t=>t.clearSelection),I=O(t=>t.selectedInstanceId),r=O(t=>t.isFocusing),$=S(t=>t.bootLoading),H=S(t=>t.bootDetail),b=S(t=>t.bootProgress);Ke();const Q=de("LoadingScreen",Rn),lt=zn();N(()=>{if(typeof document>"u")return;const t=document.documentElement;return $?t.setAttribute("data-scene-booting",""):t.removeAttribute("data-scene-booting"),()=>t.removeAttribute("data-scene-booting")},[$]),N(()=>{S.getState().markUiReady?.()},[]);const mt=O(t=>t.removeProductInstance),M=O(t=>t.addProductInstance),c=O(t=>t.updateInstancePosition),L=O(t=>t.updateInstanceRotation),q=O(t=>t.activeSceneConfigId),P=z(t=>t.defaultPresetId),y=z(t=>t.sceneConfigurations),d=z(t=>t.systemId),xt=z(t=>t.useTransform),wt=S(t=>t.sceneCapabilities),Zt=S(t=>t.showWalls),gt=S(t=>t.showDimensions),It=S(t=>t.pendingSlotPlacement),dt=ro(),j=S(t=>t.hostMaterialOverrides),J=(Zn()||{}).room||null,ut=q||P||Object.keys(y||{})[0]||null;co(ut);const[A,Ht]=Pt(!0),[nt,jt]=Pt(!1),p=Y(async()=>{try{await $n()}catch{}jt(!0)},[]),{edgeOf:Ct,cornerOf:pt,isHostAnchored:Vt,isMovable:St,rawFree:po,splitReliable:ho,freeInstances:_t,ordered:x,syntheticHosts:pe,moveInFlightRef:fo}=Mn(),Tt=Z(()=>new Map(pe.map(t=>[t.hostedProductId,t])),[pe]),[bt,en]=Pt({}),Ut=Y((t,e)=>{en(n=>{const o=n[t],a=e.full||null;return o&&o.width===e.width&&o.depth===e.depth&&o.height===e.height&&o.cx===e.cx&&o.cz===e.cz&&(o.full?.width??null)===(a?.width??null)&&(o.full?.height??null)===(a?.height??null)&&(o.full?.depth??null)===(a?.depth??null)?n:{...n,[t]:{width:e.width,depth:e.depth,height:e.height,cx:e.cx,cz:e.cz,full:a}}})},[]),ot=Y(t=>bt[t]||null,[bt]),he=K(t=>t.placementBoundsExcludeIds),fe=Z(()=>new Set((he||[]).map(t=>String(t))),[he]),Bt=Y((t,e)=>{const n=t?.componentId??e?.id??e?.componentId??null;return n!=null&&fe.has(String(n))||/leg|arm/i.test(String(t?.slotKey||""))?!0:(e?.groups||e?.group_ids||[]).some(a=>{const l=i?.[a]||i?.[String(a)];return/leg|arm/i.test(String(l?.name??l?.slotKey??l?.slot_key??""))})},[i,fe]),st=Mt(!1),Ft=Mt(!1),D=x.length+_t.length,Wt=Z(()=>[...x,..._t],[x,_t]),rt=D>0&&Wt.every(t=>bt[t.productId]),Ot=Z(()=>Wt.filter(t=>bt[t.productId]).length,[Wt,bt]),{active:Yt,loaded:me,total:Kt}=yn(),ge=S(t=>t.isEvaluating),Gt=S(t=>t.isLayoutLoading),Ie=S(t=>t.bootEvaluating),Se=Mt({pieceCount:0,allMeasured:!1});Se.current={pieceCount:D,allMeasured:rt};const Lt=Y(()=>{const{pieceCount:t,allMeasured:e}=Se.current;t>0&&!st.current&&!Ft.current&&(O.getState().resetCameraToDefault?.({instant:!0}),st.current=e,Ft.current=!e)},[]);N(()=>S.subscribe((t,e)=>{e?.bootLoading&&!t.bootLoading&&Lt()}),[Lt]),N(()=>{if(!nt)return;const t=!Yt&&(Kt===0||me>=Kt),e=(rt||D===0)&&t&&!ge&&!Ie,n=()=>{Lt(),Ht(!1),S.getState().endBootLoading()};if(e){const a=setTimeout(n,900);return()=>clearTimeout(a)}const o=setTimeout(n,Yt?12e4:15e3);return()=>clearTimeout(o)},[nt,rt,D,Ot,Yt,me,Kt,ge,Ie,Lt]);const[be,ye]=Pt(!1);N(()=>{if(!A){ye(!1);return}(rt&&D>0||nt&&D===0)&&ye(!0)},[rt,D,nt,A]);const ve=nt?be||D===0?"Finishing up\u2026":`Loading products\u2026 ${Math.min(Ot,D)}/${D}`:"Preparing your configurator\u2026",Me=be?100:D>0?Math.min(Math.round(Ot/D*100),92):0;N(()=>{A&&S.getState().setBootPhase(ve,Me)},[A,ve,Me]),N(()=>(S.setState({initialSceneLoading:A}),()=>S.setState({initialSceneLoading:!1})),[A]),N(()=>{Gt&&(st.current=!1)},[Gt]),N(()=>{if(D===0){st.current=!1;return}if(st.current||A||Gt||!rt)return;const t=setTimeout(()=>{st.current||(O.getState().resetCameraToDefault?.({instant:!Ft.current}),Ft.current=!1,st.current=!0)},250);return()=>clearTimeout(t)},[D,Ot,A,Gt,rt]);const yt=Qe(),kt=Z(()=>x.map(t=>{const e=Tt.get(t.id);return e?{...t,productId:e.hostVariantId}:t}),[x,Tt]),Pe=xt||!!y?.[ut]?.useTransform,X=O(t=>t.pendingPlacementPiece),xe=!!X&&typeof yt?.computeTargets=="function"&&!!An(),at=Z(()=>{const t={getProduct:u,getDims:ot,useTransform:Pe,candidate:X,openSlots:xe,config:Je()},e=yt.computeLayout?yt.computeLayout(kt,t):kt.map(()=>({position:[0,0,0],rotation:[0,0,0]}));return Un(e,kt,t,yt)},[yt,kt,u,ot,Pe,X,xe]),V=Z(()=>{const e=J?.height>0?J.height:2.7,n=.1,o=.05,a=new Map;let l=1/0,C=-1/0,k=1/0,h=-1/0,U=0,R=!1;if(x.forEach((s,B)=>{const _=at[B];if(!_||St(s))return;const v=_.position||[0,0,0],T=ot(s.productId),W=u(s.productId),E=T?.full||T,re=E?.height>0?E.height:W?.height>0?W.height*.0254:0,Rt=(v[1]||0)+re;if(Rt>U&&(U=Rt),(s.positionedAbove??s.positioned_above)!=null)return;const ae=(v[1]||0)<=.01,zt=-((Array.isArray(_.rotation)?_.rotation[1]:0)||0),ce=T?.depth>0?T.depth:W?.depth>0?W.depth*.0254:.6,ie=T?.width>0?T.width:W?.width>0?W.width*.0254:.9,tt=Math.cos(zt),et=Math.sin(zt),Ge=T?.cx||0,Le=T?.cz||0,ke=v[0]+tt*Ge-et*Le,Ae=v[2]+et*Ge+tt*Le,De=(ie*Math.abs(tt)+ce*Math.abs(et))/2,Re=(ie*Math.abs(et)+ce*Math.abs(tt))/2,ze=ke-De,Ee=ke+De,Ne=Ae-Re,qe=Ae+Re,Xe=E?.width>0?E.width:ie,Ze=E?.depth>0?E.depth:ce,He=v[0]+tt*(E?.cx||0)-et*(E?.cz||0),je=v[2]+et*(E?.cx||0)+tt*(E?.cz||0),Ve=(Xe*Math.abs(tt)+Ze*Math.abs(et))/2,Ue=(Xe*Math.abs(et)+Ze*Math.abs(tt))/2,mn=He-Ve,gn=He+Ve,In=je-Ue,Sn=je+Ue,Be=String((Math.round(zt/(Math.PI/2))%4+4)%4),F=a.get(Be)||{heading:zt,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,fMinX:1/0,fMaxX:-1/0,fMinZ:1/0,fMaxZ:-1/0,hasFloor:!1};F.minX=Math.min(F.minX,ze),F.maxX=Math.max(F.maxX,Ee),F.minZ=Math.min(F.minZ,Ne),F.maxZ=Math.max(F.maxZ,qe),ae&&(F.fMinX=Math.min(F.fMinX,ze),F.fMaxX=Math.max(F.fMaxX,Ee),F.fMinZ=Math.min(F.fMinZ,Ne),F.fMaxZ=Math.max(F.fMaxZ,qe),F.hasFloor=!0),a.set(Be,F),l=Math.min(l,mn),C=Math.max(C,gn),k=Math.min(k,In),h=Math.max(h,Sn),R=!0}),!R)return null;const ht=Math.max(e,U>0?U+.02:e),Jt=[...a.values()].map(s=>{const B=Math.sin(s.heading),_=Math.cos(s.heading),v=B,T=-_,W=Math.abs(v)>Math.abs(T),E=s.hasFloor?s.fMinX:s.minX,re=s.hasFloor?s.fMaxX:s.maxX,Rt=s.hasFloor?s.fMinZ:s.minZ,ae=s.hasFloor?s.fMaxZ:s.maxZ,Oe=W?(v>0?re:E)+(v>0?n/2:-n/2):(T>0?ae:Rt)+(T>0?n/2:-n/2);return{g:s,isSide:W,plane:Oe}}),At=Jt.some(s=>s.g.hasFloor)?Jt.filter(s=>s.g.hasFloor):Jt,un=At.filter(s=>s.isSide).map(s=>s.plane),pn=At.filter(s=>!s.isSide).map(s=>s.plane),te=[];for(const s of At){const{g:B}=s;if(s.isSide){let _=B.minZ,v=B.maxZ;for(const T of pn)_=Math.min(_,T),v=Math.max(v,T);te.push({cx:s.plane,cz:(_+v)/2,cy:ht/2,length:v-_+o*2,thickness:n,height:ht,rotY:Math.PI/2})}else{let _=B.minX,v=B.maxX;for(const T of un)_=Math.min(_,T),v=Math.max(v,T);te.push({cx:(_+v)/2,cz:s.plane,cy:ht/2,length:v-_+o*2,thickness:n,height:ht,rotY:0})}}const Dt=.4,Fe=C>l&&h>k;let ee=l-Dt,ne=C+Dt,oe=k-Dt,se=h+Dt;for(const s of At){const B=Math.sin(s.g.heading),_=-Math.cos(s.g.heading);s.isSide?B<0?ee=s.plane-n/2:ne=s.plane+n/2:_<0?oe=s.plane-n/2:se=s.plane+n/2}const hn=Fe?{cx:(ee+ne)/2,cz:(oe+se)/2,w:ne-ee,d:se-oe}:null,fn=Fe?{minX:l,maxX:C,minZ:k,maxZ:h,w:C-l,d:h-k,h:ht,height:U>0?U:ht}:null;return{segments:te,floor:hn,bbox:fn}},[x,at,J,ot,u,St]),nn=Zt&&!!(V&&V.segments&&V.segments.length),on=gt&&!!(V&&V.bbox&&V.bbox.w>0),sn=(t,e)=>{const n=at[e]||{position:[0,0,0],rotation:[0,0,0]},o=Tt.get(t.id);if(!o)return n;const a=n.position||[0,0,0],l=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,C=Math.cos(l),k=Math.sin(l),h=o.offset||[0,0,0];return{position:[a[0]+(h[0]||0)*C+(h[2]||0)*k,a[1]+(h[1]||0),a[2]-(h[0]||0)*k+(h[2]||0)*C],rotation:[0,l+(o.rotDegY||0)*Math.PI/180,0]}},ct=It,vt=!!ct,we=Z(()=>{if(!ct)return new Set;const t=new Set((ct.compatibleGraphIds||[]).map(String)),e=new Set;for(const n of Object.values(m||{})){const o=u(n.variantId)||u(n.productId),a=o?.product_graph??o?.productGraph;a!=null&&t.has(String(a))&&e.add(String(n.id))}return e},[ct,m,u]),$t=Y(()=>{S.getState().clearPendingSlotPlacement?.(),S.getState().clearPendingHostedProduct?.()},[]),Ce=Y((t,e)=>{if(!e)return;const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=O.getState().productInstances?.[String(t)],C=o?.placementGroup??o?.placement_group??l?.placementGroup??null,k=Array.isArray(l?.position)?l.position:[0,0,0],h=l?.variantId??l?.productId??null,U=Number.isFinite(Number(l?.sequence))?Number(l.sequence):void 0;$t(),qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:C,sequence:U,hostPlacementId:String(t),hostVariantId:h},R=>Nt({productGraphId:R.productGraphId,variantId:R.variantId,placementGroup:R.placementGroup,position:k,sequence:R.sequence,hostPlacementId:R.hostPlacementId,hostVariantId:R.hostVariantId}).catch(()=>{}))},[$t]),Qt=Y((t,e)=>{const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,C=x[t-1]||x[t],k=Array.isArray(C?.position)?C.position:[0,0,0],h=x[t],U=h&&Number.isFinite(Number(h.sequence))?Number(h.sequence):void 0;qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,sequence:U},R=>Nt({productGraphId:R.productGraphId,variantId:R.variantId,placementGroup:R.placementGroup,position:k,sequence:R.sequence}).catch(()=>{}))},[x]);N(()=>{if(!X||x.length>0)return;const t=X;Ye(),Qt(0,t)},[X,x.length,Qt]);const{gaps:rn,onInsert:an}=Yn({systemId:d,count:x.length,positionOf:t=>at[t]?.position||[0,0,0],insertAt:Qt}),_e=Z(()=>{if(!X)return[];const t=K.getState();return Ln(x,{candidate:X,getProduct:e=>t.getProduct?.(e),getDims:ot,config:Je(),layout:at})},[X,x,at,ot]),cn=Y(t=>{const e=kn(t,{candidate:X});if(!e)return;const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,C=e.transform?.position??t.position??[0,0,0],k=Dn(e,t,x);qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,anchor:e.anchor??null,sequence:k},h=>Nt({productGraphId:h.productGraphId,variantId:h.variantId,placementGroup:h.placementGroup,position:C,sequence:h.sequence}).catch(()=>{})),Ye()},[X,x]),{selectedInst:mo,swapOrder:go,panelActions:Te,priceInfo:ln}=Pn(),dn=xn()("selectionPanel");N(()=>{if(I==null)return;const t=m||{},e=String(I),n="__host";if(e.endsWith(n)){const o=e.slice(0,-n.length);if(t[o]||Object.values(t).some(a=>String(a?.id??a?.instanceId)===o))return}else if(t[I]||Object.values(t).some(o=>String(o?.instanceId??o?.id)===e))return;G?.()},[I,m,G]);const So=ft(t=>t.placementPricing),bo=z(t=>t.getChannelPriceConfig);return it(ue,{children:[f(On,{onSeeded:p}),it(Tn,{isMobile:w,camera:{position:[2.6,2.2,4],fov:45},controlsTarget:[0,.5,0],onPointerMissed:()=>G?.(),groundShadowCatcher:!0,overlay:it(ue,{children:[!vt&&Te&&dn?f(g,{actions:Te,priceInfo:ln}):null,vt&&f("div",{className:"placement-mode-overlay",children:it("div",{className:"placement-mode-overlay__content",children:[it("span",{className:"placement-mode-overlay__text",children:["Click on a highlighted slot to place ",f("strong",{children:ct?.name})]}),f("button",{type:"button",className:"placement-mode-overlay__cancel",onClick:$t,children:f("span",{className:"placement-mode-overlay__cancel-text",children:"Cancel"})})]})}),f(En,{name:"overlay"}),$&&f(Q,{scene:!0,message:lt("loading.message","Loading your configurator\u2026"),detail:H,progress:b}),r&&f("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,zIndex:30,cursor:"default"}})]}),children:[nn&&f(Fn,{width:J?.width,depth:J?.depth,height:J?.height??V?.bbox?.h??2.7,showCeiling:wt?.ceiling===!0,segments:V?.segments||null,floor:V?.floor||null}),on&&(()=>{const t=de("SceneDimensions",Xn);return f(t,{bbox:V.bbox})})(),x.map((t,e)=>{const n=Tt.get(t.id),o=at[e]||{position:[0,0,0],rotation:[0,0,0]};return o.hidden?null:it("group",{children:[n&&f(le,{instance:{id:n.id,instanceId:n.id,productId:n.hostVariantId,variantId:n.hostVariantId,position:o.position||[0,0,0],rotation:o.rotation||[0,0,0]},slotMaterials:{...dt,...j?.[n.hostedProductId]||{},...j?.[n.id]||{}},stateInstanceId:n.hostedProductId,onSelect:()=>O.getState().selectInstance(n.id),isSelected:String(I)===String(n.id),onMeasure:a=>Ut(n.hostVariantId,a),footprintExcludeItem:Bt,hoverable:!0,focusable:!0},n.id),f(le,{instance:{...t,...sn(t,e)},slotMaterials:{...dt,...j?.[t.id]||j?.[t.instanceId]||{}},onSelect:(a,l,C)=>{if(vt){we.has(String(t.id))&&Ce(t.id,ct);return}O.getState().selectInstance(a,C??null)},isSelected:!vt&&String(I)===String(t.instanceId??t.id),onMeasure:a=>Ut(t.productId,a),footprintExcludeItem:Bt,hoverable:!0,focusable:!0}),vt&&we.has(String(t.id))&&f(io,{position:[o.position?.[0]||0,(o.position?.[1]||0)+.45,o.position?.[2]||0],onClick:()=>Ce(t.id,ct)})]},t.id??t.instanceId??e)}),_t.map((t,e)=>f(Cn,{selected:I===t.id,disabled:!!t.locked,position:t.position||[0,0,0],rotationY:(Array.isArray(t.rotation)&&t.rotation[1]||0)*Math.PI/180,gizmoOffset:(()=>{const n=ot(t.productId);return[n?.cx||0,0,n?.cz||0]})(),onCommit:({position:n,rotationY:o})=>{c(t.id,n),L(t.id,[0,o*180/Math.PI,0]),Kn({allowRevert:!0}).catch(()=>{})},children:f(le,{instance:{...t,position:[0,0,0],rotation:[0,0,0]},slotMaterials:{...dt,...j?.[t.id]||j?.[t.instanceId]||{}},onMeasure:n=>Ut(t.productId,n),footprintExcludeItem:Bt})},t.id??t.instanceId??`free-${e}`)),_e.length>0?f(Gn,{targets:_e,onPick:cn}):f(_n,{gaps:rn,onInsert:an})]})]})}const tn=new Set;function uo(){to();const w=z(r=>r.systemLayoutTemplate),g=z(r=>r.systemTheme),m=z(r=>r.systemThemeRecord);so(g,m);const u=oo(m)||(g?String(g).trim().toLowerCase():null);let i=w;try{const r=new URLSearchParams(window.location.search);r.has("template")?i=r.get("template"):r.has("theme")&&(i=r.get("theme"))}catch{}i=i||w||u||null;const G=eo();G&&(i=G),!G&&!w&&i&&i===u&&!Jn(i)&&!/^theme\d+$/.test(i)&&!tn.has(i)&&tn.add(i),no(i);const I=Qn(i);return it(ue,{children:[f(I,{Scene:lo,template:i}),f(Nn,{}),f(qn,{})]})}export{lo as SharedConfiguratorScene,uo as default};
|
package/dist/88251d6671.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as a,jsxs as r}from"react/jsx-runtime";import{useLabels as
|
|
1
|
+
import{jsx as a,jsxs as r}from"react/jsx-runtime";import{useLabels as m}from"./28d887bf8a.js";function f({message:c,detail:i=null,progress:n=null,overlay:t=!1,translucent:d=!1,compact:o=!1,scene:u=!1}){const g=m(),p=c??g("loading.message","Loading Configurator..."),e=["loading-screen"];t&&e.push("loading-screen--overlay"),u&&e.push("loading-screen--scene"),d&&e.push("loading-screen--translucent"),o&&e.push("loading-screen--compact");const s=typeof n=="number"&&n>=0,l=s?Math.max(0,Math.min(100,Math.round(n))):0;return a("div",{className:e.join(" "),role:"status","aria-live":"polite","data-part":"loading","data-compact":o?"true":void 0,children:r("div",{className:"loading-screen__box",children:[a("div",{className:"loading-screen__spinner"}),a("p",{className:"loading-screen__text",children:p}),i&&a("p",{className:"loading-screen__detail",children:i}),s&&a("div",{className:"loading-screen__bar",role:"progressbar","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,children:a("div",{className:"loading-screen__bar-fill",style:{width:`${l}%`}})}),s&&r("p",{className:"loading-screen__pct",children:[l,"%"]})]})})}var v=f;export{v as default};
|
package/dist/8f60e5059a.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HOSTED_PLACEMENT_ID_PREFIX as V}from"./23dc0ccf32.js";import{create as k}from"zustand";import{devtools as E}from"./52436e0169.js";import R from"./d94df858ea.js";import T from"./872c4302e0.js";import{productRefsMatch as C,pieceKindOf as U}from"./9326c23506.js";import{getHostedProductShapeSuffix as j}from"./70dd811d74.js";let $=0;const L=()=>{const t=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const e=Math.random()*16|0;return(p==="x"?e:e&3|8).toString(16)});return`${V}${t}`},K=k(E((t,p)=>({guiVisible:!0,regions:{sidebar:!0,header:!0,toolbar:!0,panels:!0,chat:!0,notifications:!0},ownsSceneGraph:!1,sidebarOpen:!0,sidebarTab:"features",jsonPanelOpen:!0,chatPanelOpen:!1,debugPanelOpen:!1,activeModal:null,modalData:null,modalOpen:!1,notifications:[],constraintWarnings:[],inlineMessages:[],messageModal:null,isExporting:!1,isSharing:!1,isSceneLoading:!1,sceneLoadingMessage:"",isLayoutLoading:!1,isEvaluating:!1,isMobile:!1,mobileMenuOpen:!1,mobileActiveAccordion:"configurator",isLandscapeMode:!1,landscapeMethod:null,landscapeSidebarOpen:!0,liveStatusSummary:"",initialSceneLoading:!1,bootEvaluating:!1,bootLoading:!0,bootProgress:null,bootDetail:"",themeReady:!1,setBootPhase:(e,o=null)=>t(n=>n.bootDetail===e&&n.bootProgress===o?n:{bootDetail:e,bootProgress:o}),endBootLoading:()=>t(e=>e.bootLoading?{bootLoading:!1}:e),is3D:!0,showDimensions:!1,showWalls:!0,showFloor:!1,showCeiling:!1,wallOverflowDetected:!1,pieceOverlapDetected:!1,tallWallOverlapDetected:!1,wallPieceOverlapDetected:!1,wallPieceHostedOverlapDetected:!1,skipWallPieceOverlapCheck:!0,overlappingPieces:[],highlightOverlappingPieces:!0,islandOverlapDetected:!1,cornerOverflowDetected:!1,wallOverflowSide:null,wallOverflowRecenterMode:!1,wallOverflowSuppressUntil:0,showWallGuide:!1,captureMode:!1,showOptionLabels:!1,theme:"light",freePieceTier:"single",freePieceWidthOption:"6ft",freePiecePosition:null,freePieceRotation:null,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null,hostFinishes:{},hostMaterials:{},hostWidths:{},hostDoorTypes:{},hostStyles:{},sceneCapabilities:{dimensions:!0,walls:!0},globals:{},disabledOptions:new Set,hiddenOptions:new Set,currentVisibleOptionSets:null,managedOptionSets:new Set,featureToOptionsMap:{},hostHardwareFinishes:{},hostHandleTypes:{},hostProductOverrides:{},hostMaterialOverrides:{},sceneHostedProducts:[],pendingHostedProduct:null,showHostedProductSlots:!1,pendingSlotPlacement:null,pendingAutoPlacePieceIdx:null,deferredHostedProductPlacement:null,pendingPieceAdd:null,pendingPieceAddQueue:[],pendingPieceDelete:null,disabledWalls:[],currentLayoutType:"single_wall",currentPerpendicularWalls:[],validCornerSlots:[],pendingWallCornerAdd:null,wallCornerCount:0,validWallCornerSlots:[],occupiedPieceSlots:{},pieceConfigSnapshot:null,initialPieceConfigSnapshot:null,initialPerPieceOverrides:null,_snapshotOverridesOnLoadComplete:!1,basePiecePositions:{},sceneModelTransforms:[],setGuiVisible:e=>t({guiVisible:e}),setRegions:e=>t(o=>({regions:{...o.regions,...e&&typeof e=="object"?e:{}}})),toggleSidebar:()=>{t(e=>({sidebarOpen:!e.sidebarOpen}))},setSidebarOpen:e=>{t({sidebarOpen:e})},closeSidebar:()=>{t({sidebarOpen:!1})},openSidebar:()=>{t({sidebarOpen:!0})},setSidebarTab:e=>{t({sidebarTab:e})},setMobileActiveAccordion:e=>{t({mobileActiveAccordion:e})},toggleMobileAccordion:e=>{t(o=>({mobileActiveAccordion:o.mobileActiveAccordion===e?null:e}))},setLandscapeMode:(e,o=null)=>{t({isLandscapeMode:e,landscapeMethod:e?o:null})},toggleLandscapeSidebar:()=>{t(e=>({landscapeSidebarOpen:!e.landscapeSidebarOpen}))},setLiveStatusSummary:e=>{t({liveStatusSummary:e})},toggleView:()=>{t(e=>({is3D:!e.is3D}))},toggleDimensions:()=>{t(e=>({showDimensions:!e.showDimensions}))},toggleWalls:()=>{t(e=>({showWalls:!e.showWalls}))},toggleFloor:()=>{t(e=>({showFloor:!e.showFloor}))},toggleCeiling:()=>{t(e=>({showCeiling:!e.showCeiling}))},toggleOptionLabels:()=>{t(e=>({showOptionLabels:!e.showOptionLabels}))},toggleJsonPanel:()=>{t(e=>({jsonPanelOpen:!e.jsonPanelOpen}))},setJsonPanelOpen:e=>{t({jsonPanelOpen:e})},toggleChatPanel:()=>{t(e=>({chatPanelOpen:!e.chatPanelOpen}))},setChatPanelOpen:e=>{t({chatPanelOpen:e})},toggleDebugPanel:()=>{t(e=>({debugPanelOpen:!e.debugPanelOpen}))},setDebugPanelOpen:e=>{t({debugPanelOpen:e})},openModal:(e,o=null)=>{t({activeModal:e,modalData:o,modalOpen:!0})},closeModal:()=>{t({activeModal:null,modalData:null,modalOpen:!1})},addNotification:e=>{if(p().isLayoutLoading)return null;const o={type:"info",duration:5e3,...e},n=p().notifications.find(c=>c.type===o.type&&(c.title??"")===(o.title??"")&&c.message===o.message);if(n)return n.id;const s=`${Date.now()}-${++$}`,r={id:s,...o};return t(c=>({notifications:[...c.notifications,r]})),r.duration>0&&setTimeout(()=>{p().removeNotification(s)},r.duration),s},removeNotification:e=>{t(o=>({notifications:o.notifications.filter(n=>n.id!==e)}))},clearNotifications:()=>{t({notifications:[]})},setConstraintWarnings:e=>{t({constraintWarnings:Array.isArray(e)?e:[]})},setInlineMessages:e=>{t({inlineMessages:Array.isArray(e)?e:[]})},lastModalKeys:[],setMessageModal:e=>{t({messageModal:e??null})},dismissMessageModal:()=>{t({messageModal:null})},setExporting:e=>{t({isExporting:e})},setSharing:e=>{t({isSharing:e})},setSceneLoading:(e,o="")=>{t({isSceneLoading:e,sceneLoadingMessage:o})},clearSceneLoading:()=>{const e=p()._snapshotOverridesOnLoadComplete;t({isSceneLoading:!1,sceneLoadingMessage:""}),e&&(p().setInitialPerPieceOverrides(),t({_snapshotOverridesOnLoadComplete:!1,isLayoutLoading:!1,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null}),import("./1fac915f8b.js").then(o=>o.default.getState().clearHistory()))},setIsMobile:e=>{t({isMobile:e})},toggleMobileMenu:()=>{t(e=>({mobileMenuOpen:!e.mobileMenuOpen}))},setMobileMenuOpen:e=>{t({mobileMenuOpen:e})},setTheme:e=>{t({theme:e}),document.documentElement.setAttribute("data-theme",e)},toggleTheme:()=>{const e=p().theme==="light"?"dark":"light";t({theme:e}),document.documentElement.setAttribute("data-theme",e)},setFreePieceTier:e=>t({freePieceTier:e}),setFreePieceWidthOption:e=>t({freePieceWidthOption:e}),setFreePiecePosition:e=>t({freePiecePosition:e}),setFreePieceRotation:e=>t({freePieceRotation:e}),resetFreePiece:()=>t({freePieceTier:"single",freePieceWidthOption:"6ft",freePiecePosition:null,freePieceRotation:null}),setSelectedFeature:(e,o=null)=>{t({selectedFeatureId:e,selectedElementType:o})},setSelectedPieceIndex:e=>{const o=p().selectedPieceIndex;t({selectedPieceIndex:e});const n=c=>{if(c==null)return null;const l=p().hostProductOverrides?.[c];return l??p().basePiecePositions?.[c]?.productId??null},s=n(o),r=n(e);String(s)!==String(r)&&t({currentVisibleOptionSets:null})},clearSelectedFeature:()=>{t({selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})},setHostFinish:(e,o,n)=>{t(s=>({hostFinishes:{...s.hostFinishes,[e]:o},hostMaterials:{...s.hostMaterials,[e]:n}}))},clearHostFinishes:()=>{t({hostFinishes:{},hostMaterials:{}})},clearHostMaterials:()=>{t({hostMaterials:{}})},setHostStyle:(e,o)=>{t(n=>({hostStyles:{...n.hostStyles,[e]:o}}))},clearHostStyles:()=>{t({hostStyles:{}})},setGlobal:(e,o)=>{t(n=>({globals:{...n.globals,[e]:o}}))},roomFootprint:null,setRoomFootprint:e=>t(o=>{const n=o.roomFootprint;return n&&Math.abs(n.width-e.width)<1e-4&&Math.abs(n.depth-e.depth)<1e-4?o:{roomFootprint:{width:e.width,depth:e.depth}}}),setHostHandleType:(e,o)=>{t(n=>({hostHandleTypes:{...n.hostHandleTypes,[e]:o}}))},clearHostHandleTypes:()=>{t({hostHandleTypes:{}})},setHostHardwareFinish:(e,o)=>{t(n=>({hostHardwareFinishes:{...n.hostHardwareFinishes,[e]:o}}))},clearHostHardwareFinishes:()=>{t({hostHardwareFinishes:{}})},setHostMaterialOverride:(e,o,n)=>{!e||!o||t(s=>({hostMaterialOverrides:{...s.hostMaterialOverrides,[e]:{...s.hostMaterialOverrides[e]||{},[o]:n}}}))},clearHostMaterialOverrides:()=>{t({hostMaterialOverrides:{}})},setHostWidth:(e,o)=>{t(n=>({hostWidths:{...n.hostWidths,[e]:o}}))},clearHostWidths:()=>{t({hostWidths:{}})},setHostDoorType:(e,o,n,s)=>{t(r=>({hostDoorTypes:{...r.hostDoorTypes,[e]:{optionId:o,modelUrl:n,value:s}}}))},clearHostDoorTypes:()=>{t({hostDoorTypes:{}})},setHostProductOverride:(e,o)=>{t(n=>{const s=n.occupiedPieceSlots[e];if(s&&s.compatibleProductIds){const r=String(o);if(!s.compatibleProductIds.some(l=>String(l)===r)){const l={...n.occupiedPieceSlots};return delete l[e],{hostProductOverrides:{...n.hostProductOverrides,[e]:o},sceneHostedProducts:n.sceneHostedProducts.filter(u=>u.id!==s.hostedProductId),occupiedPieceSlots:l}}if(s.hostedProductSlots){const l=s.hostedProductSlots.find(u=>u.product_id!=null&&String(u.product_id)===String(o));if(l){const u={...n.occupiedPieceSlots};u[e]={...s,component_overrides:l.component_overrides||s.component_overrides,component_transforms:l.component_transforms||s.component_transforms};const m=l.position||null,P=l.rotation||null;return{hostProductOverrides:{...n.hostProductOverrides,[e]:o},occupiedPieceSlots:u,sceneHostedProducts:n.sceneHostedProducts.map(f=>f.id===s.hostedProductId?{...f,modelOffset:m,modelRotation:P}:f)}}}}return{hostProductOverrides:{...n.hostProductOverrides,[e]:o}}})},clearHostProductOverrides:()=>{t({hostProductOverrides:{}})},cleanupPieceState:e=>{t(o=>{const n={...o.hostWidths},s={...o.hostProductOverrides},r={...o.hostDoorTypes},c={...o.hostFinishes},l={...o.hostMaterials},u={...o.hostStyles},m={...o.hostHandleTypes},P={...o.occupiedPieceSlots},f=P[e],d=f?.pairedHostedProductId;let i=f?.pairedWith;if(delete n[e],delete s[e],delete r[e],delete c[e],delete l[e],delete u[e],delete m[e],delete P[e],i&&P[i]){const h=P[i];h.previousWidth!==void 0?n[i]=h.previousWidth:delete n[i],h.previousProductOverride!==void 0?s[i]=h.previousProductOverride:delete s[i],h.previousDoorType!==void 0?r[i]=h.previousDoorType:delete r[i],delete P[i]}let g=o.sceneHostedProducts.filter(h=>h.replacedPiece!==e);return d&&(g=g.filter(h=>h.id!==d)),{hostWidths:n,hostProductOverrides:s,hostDoorTypes:r,hostFinishes:c,hostMaterials:l,hostStyles:u,hostHandleTypes:m,occupiedPieceSlots:P,sceneHostedProducts:g}})},setPendingHostedProduct:(e,o={})=>{const n=o.autoPlacePieceIdx??null;t({pendingHostedProduct:e,showHostedProductSlots:!0,pendingAutoPlacePieceIdx:n,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})},clearPendingAutoPlacePieceIdx:()=>{t({pendingAutoPlacePieceIdx:null})},clearPendingHostedProduct:()=>{t({pendingHostedProduct:null,showHostedProductSlots:!1,pendingAutoPlacePieceIdx:null})},setPendingSlotPlacement:e=>t({pendingSlotPlacement:e||null}),clearPendingSlotPlacement:()=>t({pendingSlotPlacement:null}),setDeferredHostedProductPlacement:e=>t({deferredHostedProductPlacement:e}),clearDeferredHostedProductPlacement:()=>t({deferredHostedProductPlacement:null}),setPendingPieceAdd:e=>t(o=>o.pendingPieceAdd?{pendingPieceAddQueue:[...o.pendingPieceAddQueue,e]}:{pendingPieceAdd:e}),clearPendingPieceAdd:()=>t(e=>{const o=e.pendingPieceAddQueue;if(o.length>0){const[n,...s]=o;return{pendingPieceAdd:n,pendingPieceAddQueue:s}}return{pendingPieceAdd:null}}),setPendingPieceDelete:e=>t({pendingPieceDelete:e}),clearPendingPieceDelete:()=>t({pendingPieceDelete:null}),addDisabledWall:e=>t(o=>({disabledWalls:o.disabledWalls.includes(e)?o.disabledWalls:[...o.disabledWalls,e]})),removeDisabledWall:e=>t(o=>({disabledWalls:o.disabledWalls.filter(n=>n!==e)})),clearDisabledWalls:()=>t({disabledWalls:[]}),setSkipWallPieceOverlapCheck:e=>t({skipWallPieceOverlapCheck:e}),setCurrentLayoutType:e=>t({currentLayoutType:e}),setCurrentPerpendicularWalls:e=>t({currentPerpendicularWalls:e}),setValidCornerSlots:e=>t({validCornerSlots:e}),setWallCornerCount:e=>t({wallCornerCount:e}),setValidWallCornerSlots:e=>t({validWallCornerSlots:e}),clearPendingWallCornerAdd:()=>t({pendingWallCornerAdd:null}),placeHostedProductAtSlot:(e,o=[0,0,0])=>{const{pendingHostedProduct:n}=p();if(!n)return null;const s=L(),r={id:s,hostedProductId:n.id,name:n.name,modelUrl:n.modelUrl,position:e,rotation:o,scale:n.scale||[1,1,1]},c=p()._snapshotOverridesOnLoadComplete;return t(l=>({sceneHostedProducts:[...l.sceneHostedProducts,r],pendingHostedProduct:null,showHostedProductSlots:!1,...c?{sceneLoadingMessage:`Placing ${n.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${n.name}...`}})),s},addHostedProduct:e=>{const o=L(),n={id:o,hostedProductId:e.id,name:e.name,modelUrl:e.modelUrl,position:e.position||[0,0,0],rotation:e.rotation||[0,0,0],scale:e.scale||[1,1,1],...e.pairedWith?{pairedWith:e.pairedWith}:{}},s=p()._snapshotOverridesOnLoadComplete;return t(r=>({sceneHostedProducts:[...r.sceneHostedProducts,n],...s?{sceneLoadingMessage:`Adding ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Adding ${e.name}...`}})),o},setHostedProductLoaded:()=>{p()._snapshotOverridesOnLoadComplete||t({isSceneLoading:!1,sceneLoadingMessage:""})},removeHostedProduct:e=>{t(o=>{const n={...o.occupiedPieceSlots},s={...o.hostWidths},r={...o.hostProductOverrides},c={...o.hostDoorTypes};let l=null,u=null,m=!1;for(const[d,i]of Object.entries(n))i.surfaceHostedProductId===e&&(n[d]={...i},delete n[d].surfaceHostedProductId,m=!0);if(!m){for(const[d,i]of Object.entries(n))if(i.hostedProductId===e){i.surfaceHostedProductId&&(u=i.surfaceHostedProductId),i.previousWidth!==void 0?s[d]=i.previousWidth:delete s[d],i.previousProductOverride!==void 0?r[d]=i.previousProductOverride:delete r[d],i.previousDoorType!==void 0?c[d]=i.previousDoorType:delete c[d];try{const g=T.getState().products||{},h=r[d]??o.basePiecePositions?.[d]?.productId??null,b=h!=null?g[h]||g[String(h)]:null,W=v=>{const _=v?.components_configuration??v?.componentsConfiguration??{},y=_.comp_base_slab??_.comp_corner_slab??null;return String(y?.variant_key??y?.variantKey??"")};if(b){const v=W(b),_=b.product_graph??b.productGraph??null,y=v?Object.values(g).find(w=>{if(!w||w.id===b.id||b.width!=null&&Number(w.width)!==Number(b.width)||_!=null&&(w.product_graph??w.productGraph??null)!==_)return!1;const M=W(w);if(!M||M===v||!v.startsWith(M+"_"))return!1;const I=v.slice(M.length+1);return/^[a-z0-9]+$/i.test(I)}):null;y?.id!=null&&(r[d]=y.id)}}catch{}i.pairedHostedProductId&&(l=i.pairedHostedProductId),delete n[d]}else if(i.linkedToBase){const g=o.occupiedPieceSlots[i.linkedToBase];g&&g.hostedProductId===e&&delete n[d]}}if(!l){const d=o.sceneHostedProducts.find(i=>i.id===e);d?.pairedWithHostedProductId&&(l=d.pairedWithHostedProductId)}if(l)for(const[d,i]of Object.entries(n))i.hostedProductId===l&&i.pairedHostedProductId&&(n[d]={...i},delete n[d].pairedHostedProductId);const P=new Set([e,u].filter(Boolean));for(let d=!0;d;){d=!1;for(const i of o.sceneHostedProducts)P.has(i.id)||i.pairedWithHostedProductId!=null&&P.has(i.pairedWithHostedProductId)&&(P.add(i.id),d=!0)}for(const[d,i]of Object.entries(n))P.has(i.hostedProductId)&&delete n[d];let f=o.sceneHostedProducts.filter(d=>!P.has(d.id));return l&&!P.has(l)&&(f=f.map(d=>d.id===l?{...d,pairedWithHostedProductId:void 0,pairedWithPiece:void 0}:d)),{sceneHostedProducts:f,occupiedPieceSlots:n,hostWidths:s,hostProductOverrides:r,hostDoorTypes:c}})},moveHostedProductLeft:e=>{t(o=>{const n=o.sceneHostedProducts.findIndex(r=>r.id===e);if(n<=0)return o;const s=[...o.sceneHostedProducts];return[s[n-1],s[n]]=[s[n],s[n-1]],{sceneHostedProducts:s}})},moveHostedProductRight:e=>{t(o=>{const n=o.sceneHostedProducts.findIndex(r=>r.id===e);if(n===-1||n>=o.sceneHostedProducts.length-1)return o;const s=[...o.sceneHostedProducts];return[s[n],s[n+1]]=[s[n+1],s[n]],{sceneHostedProducts:s}})},updateHostedProductPosition:(e,o)=>{t(n=>({sceneHostedProducts:n.sceneHostedProducts.map(s=>s.id===e?{...s,position:o}:s)}))},updateHostedProductRotation:(e,o)=>{t(n=>({sceneHostedProducts:n.sceneHostedProducts.map(s=>s.id===e?{...s,rotation:o}:s)}))},clearHostedProducts:()=>{t({sceneHostedProducts:[],occupiedPieceSlots:{}})},occupyPieceSlot:(e,o,n,s)=>{t(r=>({occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:{hostedProductId:o,position:n,rotation:s}}}))},freePieceSlot:e=>{t(o=>{const n={...o.occupiedPieceSlots};return delete n[e],{occupiedPieceSlots:n}})},setHostedProductFeatureForSlot:(e,o,n)=>{t(s=>{const r=s.occupiedPieceSlots[e];return r?{occupiedPieceSlots:{...s.occupiedPieceSlots,[e]:{...r,featureSelections:{...r.featureSelections,[o]:n}}}}:s})},updateHostedProductSlotForProduct:(e,o)=>{const n=p().occupiedPieceSlots[e];if(!n)return;const s=n.hostedProductSlots?.find(r=>r.product_id===o);s&&t(r=>{const c={...r.occupiedPieceSlots[e]};s.component_overrides&&(c.component_overrides=s.component_overrides),s.component_transforms?c.component_transforms=s.component_transforms:delete c.component_transforms;const l=c.hostedProductId;return{occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:c},sceneHostedProducts:r.sceneHostedProducts.map(u=>u.id===l?{...u,modelOffset:s.position||null,modelRotation:s.rotation||null,additionalModels:s.additionalModels||u.additionalModels,...s.modelUrl?{modelUrl:s.modelUrl}:{}}:u)}})},setPieceConfigSnapshot:e=>{t({pieceConfigSnapshot:e})},setInitialPieceConfigSnapshot:e=>{t({initialPieceConfigSnapshot:e})},setInitialPerPieceOverrides:()=>{const e=p(),o=R.getState().sceneSelections;t({initialPerPieceOverrides:{hostFinishes:{...e.hostFinishes},hostStyles:{...e.hostStyles},hostHandleTypes:{...e.hostHandleTypes},hostWidths:{...e.hostWidths},hostDoorTypes:{...e.hostDoorTypes},hostProductOverrides:{...e.hostProductOverrides},hostHardwareFinishes:{...e.hostHardwareFinishes},sceneHostedProducts:[...e.sceneHostedProducts],sceneSelections:{...o}}})},setBasePiecePositions:e=>{const o=p().basePiecePositions||{},n=Object.keys(o),s=Object.keys(e||{});if(n.length===s.length){let r=!1;for(const c of s){const l=o[c],u=e[c];if(!l||!u){r=!0;break}const m=l.position,P=u.position,f=l.rotation||[0,0,0],d=u.rotation||[0,0,0];if(!Array.isArray(m)||!Array.isArray(P)){r=!0;break}if(Math.abs((m[0]||0)-(P[0]||0))>1e-6||Math.abs((m[1]||0)-(P[1]||0))>1e-6||Math.abs((m[2]||0)-(P[2]||0))>1e-6||Math.abs((f[1]||0)-(d[1]||0))>1e-6||String(l.productId??"")!==String(u.productId??"")){r=!0;break}}if(!r)return}t({basePiecePositions:e})},getBasePiecePosition:e=>p().basePiecePositions[e],setSceneModelTransforms:e=>{t({sceneModelTransforms:e})},placeHostedProductAtPiece:(e,o,n,s=[0,0,0],r=null)=>{const c=L();let l=e.placement_type||"replace_full";const u=r||p().basePiecePositions[o]?.productId,m=u!=null?String(u):null,P=T.getState().products||{},f=a=>{if(a==null)return null;const H=P[a]||P[String(a)];return H||Object.values(P).find(O=>O&&C(O.id,a))||null},d=(a,H)=>{const O=f(a),S=f(H);return!O||!S?!1:String(O.id)===String(S.id)};let i=e.slots?.find(a=>a.product_id!=null&&d(a.product_id,u))||e.slots?.find(a=>a.product_id==null)||e.slots?.find(a=>a.product_id!=null&&C(a.product_id,u))||(e.id==="oven_stove"?e.slots?.find(a=>a.product_id!=null&&C(a.product_id,e.target_product_id)):null);const g=U(o);if(g==="corner"||g==="wall_corner"){const a=j(e,P);if(a){const H=f(u),S=(H?.components_configuration??H?.componentsConfiguration??{}).comp_corner_slab,D=String(S?.variant_key??S?.variantKey??"");if(D){const A=T.getState().components||{},x=A.comp_corner_slab??A.comp_corner_slab,F=D+a;x?.variants?.[F]!=null&&(i={...i||{position:null,rotation:null},product_id:null,component_overrides:{...i?.component_overrides||{},comp_corner_slab:{variant_key:F}}},l="replace_components")}}}if(l==="replace_components"){const a=Array.isArray(e.slots)?e.slots:[],H=a.some(S=>S&&S.component_overrides&&Object.keys(S.component_overrides).length>0);!(i?.component_overrides&&Object.keys(i.component_overrides).length>0)&&(a.length===0||!H)&&(l="replace_full")}const b=i?.position||e.componentModelOffset||null,W=i?.rotation||e.componentModelRotation||null,v={id:c,hostedProductId:e.id,name:e.name,modelUrl:i?.modelUrl||e.modelUrl,position:n,rotation:s,scale:e.scale||[1,1,1],placement_type:l,modelOffset:b,modelRotation:W,replacedPiece:o,additionalModels:i?.additionalModels||e.additionalModels||[]},_=Array.isArray(e.hostVariants)&&e.hostVariants.length>0,y={hostedProductId:c,position:n,rotation:s,placement_type:l,isHostSwap:_,compatibleProductIds:e.slots?.map(a=>a.product_id)||[],hostedProductSlots:e.slots||[],featureSelections:(()=>{const a=e.features||[],H=e.feature_defaults||{},O={};for(const S of a){const D=T.getState().features[S];O[S]=H[S]||D?.default_option_id}return O})()};l==="replace_components"&&i?.component_overrides&&(y.component_overrides=i.component_overrides),l==="replace_components"&&i?.component_transforms&&(y.component_transforms=i.component_transforms);const w={},M=e?.target_width??e?.auto_target_width??null,I=p()._snapshotOverridesOnLoadComplete;return t(a=>({sceneHostedProducts:[...a.sceneHostedProducts,v],occupiedPieceSlots:{...a.occupiedPieceSlots,[o]:y,...w},...M!=null?{hostWidths:{...a.hostWidths,[o]:M}}:{},pendingHostedProduct:null,showHostedProductSlots:!1,...I?{sceneLoadingMessage:`Placing ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${e.name}...`},selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})),c},addSurfaceHostedProduct:(e,o)=>{const n=L(),s={id:n,hostedProductId:e.id,name:e.name,modelUrl:e.modelUrl,position:[0,0,0],rotation:[0,0,0],scale:e.scale||[1,1,1],placement_type:"countertop_overlay",replacedPiece:o},r=p()._snapshotOverridesOnLoadComplete;return t(c=>({sceneHostedProducts:[...c.sceneHostedProducts,s],occupiedPieceSlots:{...c.occupiedPieceSlots,[o]:{...c.occupiedPieceSlots[o],surfaceHostedProductId:n}},pendingHostedProduct:null,showHostedProductSlots:!1,...r?{sceneLoadingMessage:`Placing ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${e.name}...`},selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})),n},setPair:(e,o,n,s)=>{t(r=>({occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:{...r.occupiedPieceSlots[e],pairedWith:n,pairedHostedProductId:s},[n]:{...r.occupiedPieceSlots[n],pairedWith:e,pairedHostedProductId:o}}}))},setPairing:(e,o,n,s)=>p().setPair(e,o,n,s),showSuccess:e=>p().addNotification({type:"success",message:e}),showError:e=>p().addNotification({type:"error",message:e}),showWarning:e=>p().addNotification({type:"warning",message:e}),showInfo:e=>p().addNotification({type:"info",message:e})}),{name:"ui-store"}));var Z=K;export{Z as default};
|
|
1
|
+
import{HOSTED_PLACEMENT_ID_PREFIX as R}from"./23dc0ccf32.js";import{create as V}from"zustand";import{devtools as k}from"./52436e0169.js";import U from"./d94df858ea.js";import T from"./872c4302e0.js";import{productRefsMatch as C,pieceKindOf as E}from"./9326c23506.js";import{getHostedProductShapeSuffix as j}from"./70dd811d74.js";let $=0;const L=()=>{const t=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const e=Math.random()*16|0;return(p==="x"?e:e&3|8).toString(16)});return`${R}${t}`},K=V(k((t,p)=>({guiVisible:!0,regions:{sidebar:!0,header:!0,toolbar:!0,panels:!0,chat:!0,notifications:!0},ownsSceneGraph:!1,sidebarOpen:!0,sidebarTab:"features",jsonPanelOpen:!0,chatPanelOpen:!1,debugPanelOpen:!1,activeModal:null,modalData:null,modalOpen:!1,notifications:[],constraintWarnings:[],inlineMessages:[],messageModal:null,isExporting:!1,isSharing:!1,isSceneLoading:!1,sceneLoadingMessage:"",isLayoutLoading:!1,isEvaluating:!1,isMobile:!1,mobileMenuOpen:!1,mobileActiveAccordion:"configurator",isLandscapeMode:!1,landscapeMethod:null,landscapeSidebarOpen:!0,liveStatusSummary:"",initialSceneLoading:!1,bootEvaluating:!1,bootLoading:!0,uiReady:!1,markUiReady:()=>t(e=>e.uiReady?e:{uiReady:!0}),bootProgress:null,bootDetail:"",themeReady:!1,setBootPhase:(e,o=null)=>t(n=>n.bootDetail===e&&n.bootProgress===o?n:{bootDetail:e,bootProgress:o}),endBootLoading:()=>t(e=>e.bootLoading?{bootLoading:!1}:e),is3D:!0,showDimensions:!1,showWalls:!0,showFloor:!1,showCeiling:!1,wallOverflowDetected:!1,pieceOverlapDetected:!1,tallWallOverlapDetected:!1,wallPieceOverlapDetected:!1,wallPieceHostedOverlapDetected:!1,skipWallPieceOverlapCheck:!0,overlappingPieces:[],highlightOverlappingPieces:!0,islandOverlapDetected:!1,cornerOverflowDetected:!1,wallOverflowSide:null,wallOverflowRecenterMode:!1,wallOverflowSuppressUntil:0,showWallGuide:!1,captureMode:!1,showOptionLabels:!1,theme:"light",freePieceTier:"single",freePieceWidthOption:"6ft",freePiecePosition:null,freePieceRotation:null,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null,hostFinishes:{},hostMaterials:{},hostWidths:{},hostDoorTypes:{},hostStyles:{},sceneCapabilities:{dimensions:!0,walls:!0},globals:{},disabledOptions:new Set,hiddenOptions:new Set,currentVisibleOptionSets:null,managedOptionSets:new Set,featureToOptionsMap:{},hostHardwareFinishes:{},hostHandleTypes:{},hostProductOverrides:{},hostMaterialOverrides:{},sceneHostedProducts:[],pendingHostedProduct:null,showHostedProductSlots:!1,pendingSlotPlacement:null,pendingAutoPlacePieceIdx:null,deferredHostedProductPlacement:null,pendingPieceAdd:null,pendingPieceAddQueue:[],pendingPieceDelete:null,disabledWalls:[],currentLayoutType:"single_wall",currentPerpendicularWalls:[],validCornerSlots:[],pendingWallCornerAdd:null,wallCornerCount:0,validWallCornerSlots:[],occupiedPieceSlots:{},pieceConfigSnapshot:null,initialPieceConfigSnapshot:null,initialPerPieceOverrides:null,_snapshotOverridesOnLoadComplete:!1,basePiecePositions:{},sceneModelTransforms:[],setGuiVisible:e=>t({guiVisible:e}),setRegions:e=>t(o=>({regions:{...o.regions,...e&&typeof e=="object"?e:{}}})),toggleSidebar:()=>{t(e=>({sidebarOpen:!e.sidebarOpen}))},setSidebarOpen:e=>{t({sidebarOpen:e})},closeSidebar:()=>{t({sidebarOpen:!1})},openSidebar:()=>{t({sidebarOpen:!0})},setSidebarTab:e=>{t({sidebarTab:e})},setMobileActiveAccordion:e=>{t({mobileActiveAccordion:e})},toggleMobileAccordion:e=>{t(o=>({mobileActiveAccordion:o.mobileActiveAccordion===e?null:e}))},setLandscapeMode:(e,o=null)=>{t({isLandscapeMode:e,landscapeMethod:e?o:null})},toggleLandscapeSidebar:()=>{t(e=>({landscapeSidebarOpen:!e.landscapeSidebarOpen}))},setLiveStatusSummary:e=>{t({liveStatusSummary:e})},toggleView:()=>{t(e=>({is3D:!e.is3D}))},toggleDimensions:()=>{t(e=>({showDimensions:!e.showDimensions}))},toggleWalls:()=>{t(e=>({showWalls:!e.showWalls}))},toggleFloor:()=>{t(e=>({showFloor:!e.showFloor}))},toggleCeiling:()=>{t(e=>({showCeiling:!e.showCeiling}))},toggleOptionLabels:()=>{t(e=>({showOptionLabels:!e.showOptionLabels}))},toggleJsonPanel:()=>{t(e=>({jsonPanelOpen:!e.jsonPanelOpen}))},setJsonPanelOpen:e=>{t({jsonPanelOpen:e})},toggleChatPanel:()=>{t(e=>({chatPanelOpen:!e.chatPanelOpen}))},setChatPanelOpen:e=>{t({chatPanelOpen:e})},toggleDebugPanel:()=>{t(e=>({debugPanelOpen:!e.debugPanelOpen}))},setDebugPanelOpen:e=>{t({debugPanelOpen:e})},openModal:(e,o=null)=>{t({activeModal:e,modalData:o,modalOpen:!0})},closeModal:()=>{t({activeModal:null,modalData:null,modalOpen:!1})},addNotification:e=>{if(p().isLayoutLoading)return null;const o={type:"info",duration:5e3,...e},n=p().notifications.find(c=>c.type===o.type&&(c.title??"")===(o.title??"")&&c.message===o.message);if(n)return n.id;const s=`${Date.now()}-${++$}`,r={id:s,...o};return t(c=>({notifications:[...c.notifications,r]})),r.duration>0&&setTimeout(()=>{p().removeNotification(s)},r.duration),s},removeNotification:e=>{t(o=>({notifications:o.notifications.filter(n=>n.id!==e)}))},clearNotifications:()=>{t({notifications:[]})},setConstraintWarnings:e=>{t({constraintWarnings:Array.isArray(e)?e:[]})},setInlineMessages:e=>{t({inlineMessages:Array.isArray(e)?e:[]})},lastModalKeys:[],setMessageModal:e=>{t({messageModal:e??null})},dismissMessageModal:()=>{t({messageModal:null})},setExporting:e=>{t({isExporting:e})},setSharing:e=>{t({isSharing:e})},setSceneLoading:(e,o="")=>{t({isSceneLoading:e,sceneLoadingMessage:o})},clearSceneLoading:()=>{const e=p()._snapshotOverridesOnLoadComplete;t({isSceneLoading:!1,sceneLoadingMessage:""}),e&&(p().setInitialPerPieceOverrides(),t({_snapshotOverridesOnLoadComplete:!1,isLayoutLoading:!1,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null}),import("./1fac915f8b.js").then(o=>o.default.getState().clearHistory()))},setIsMobile:e=>{t({isMobile:e})},toggleMobileMenu:()=>{t(e=>({mobileMenuOpen:!e.mobileMenuOpen}))},setMobileMenuOpen:e=>{t({mobileMenuOpen:e})},setTheme:e=>{t({theme:e}),document.documentElement.setAttribute("data-theme",e)},toggleTheme:()=>{const e=p().theme==="light"?"dark":"light";t({theme:e}),document.documentElement.setAttribute("data-theme",e)},setFreePieceTier:e=>t({freePieceTier:e}),setFreePieceWidthOption:e=>t({freePieceWidthOption:e}),setFreePiecePosition:e=>t({freePiecePosition:e}),setFreePieceRotation:e=>t({freePieceRotation:e}),resetFreePiece:()=>t({freePieceTier:"single",freePieceWidthOption:"6ft",freePiecePosition:null,freePieceRotation:null}),setSelectedFeature:(e,o=null)=>{t({selectedFeatureId:e,selectedElementType:o})},setSelectedPieceIndex:e=>{const o=p().selectedPieceIndex;t({selectedPieceIndex:e});const n=c=>{if(c==null)return null;const l=p().hostProductOverrides?.[c];return l??p().basePiecePositions?.[c]?.productId??null},s=n(o),r=n(e);String(s)!==String(r)&&t({currentVisibleOptionSets:null})},clearSelectedFeature:()=>{t({selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})},setHostFinish:(e,o,n)=>{t(s=>({hostFinishes:{...s.hostFinishes,[e]:o},hostMaterials:{...s.hostMaterials,[e]:n}}))},clearHostFinishes:()=>{t({hostFinishes:{},hostMaterials:{}})},clearHostMaterials:()=>{t({hostMaterials:{}})},setHostStyle:(e,o)=>{t(n=>({hostStyles:{...n.hostStyles,[e]:o}}))},clearHostStyles:()=>{t({hostStyles:{}})},setGlobal:(e,o)=>{t(n=>({globals:{...n.globals,[e]:o}}))},roomFootprint:null,setRoomFootprint:e=>t(o=>{const n=o.roomFootprint;return n&&Math.abs(n.width-e.width)<1e-4&&Math.abs(n.depth-e.depth)<1e-4?o:{roomFootprint:{width:e.width,depth:e.depth}}}),setHostHandleType:(e,o)=>{t(n=>({hostHandleTypes:{...n.hostHandleTypes,[e]:o}}))},clearHostHandleTypes:()=>{t({hostHandleTypes:{}})},setHostHardwareFinish:(e,o)=>{t(n=>({hostHardwareFinishes:{...n.hostHardwareFinishes,[e]:o}}))},clearHostHardwareFinishes:()=>{t({hostHardwareFinishes:{}})},setHostMaterialOverride:(e,o,n)=>{!e||!o||t(s=>({hostMaterialOverrides:{...s.hostMaterialOverrides,[e]:{...s.hostMaterialOverrides[e]||{},[o]:n}}}))},clearHostMaterialOverrides:()=>{t({hostMaterialOverrides:{}})},setHostWidth:(e,o)=>{t(n=>({hostWidths:{...n.hostWidths,[e]:o}}))},clearHostWidths:()=>{t({hostWidths:{}})},setHostDoorType:(e,o,n,s)=>{t(r=>({hostDoorTypes:{...r.hostDoorTypes,[e]:{optionId:o,modelUrl:n,value:s}}}))},clearHostDoorTypes:()=>{t({hostDoorTypes:{}})},setHostProductOverride:(e,o)=>{t(n=>{const s=n.occupiedPieceSlots[e];if(s&&s.compatibleProductIds){const r=String(o);if(!s.compatibleProductIds.some(l=>String(l)===r)){const l={...n.occupiedPieceSlots};return delete l[e],{hostProductOverrides:{...n.hostProductOverrides,[e]:o},sceneHostedProducts:n.sceneHostedProducts.filter(u=>u.id!==s.hostedProductId),occupiedPieceSlots:l}}if(s.hostedProductSlots){const l=s.hostedProductSlots.find(u=>u.product_id!=null&&String(u.product_id)===String(o));if(l){const u={...n.occupiedPieceSlots};u[e]={...s,component_overrides:l.component_overrides||s.component_overrides,component_transforms:l.component_transforms||s.component_transforms};const m=l.position||null,P=l.rotation||null;return{hostProductOverrides:{...n.hostProductOverrides,[e]:o},occupiedPieceSlots:u,sceneHostedProducts:n.sceneHostedProducts.map(f=>f.id===s.hostedProductId?{...f,modelOffset:m,modelRotation:P}:f)}}}}return{hostProductOverrides:{...n.hostProductOverrides,[e]:o}}})},clearHostProductOverrides:()=>{t({hostProductOverrides:{}})},cleanupPieceState:e=>{t(o=>{const n={...o.hostWidths},s={...o.hostProductOverrides},r={...o.hostDoorTypes},c={...o.hostFinishes},l={...o.hostMaterials},u={...o.hostStyles},m={...o.hostHandleTypes},P={...o.occupiedPieceSlots},f=P[e],d=f?.pairedHostedProductId;let i=f?.pairedWith;if(delete n[e],delete s[e],delete r[e],delete c[e],delete l[e],delete u[e],delete m[e],delete P[e],i&&P[i]){const h=P[i];h.previousWidth!==void 0?n[i]=h.previousWidth:delete n[i],h.previousProductOverride!==void 0?s[i]=h.previousProductOverride:delete s[i],h.previousDoorType!==void 0?r[i]=h.previousDoorType:delete r[i],delete P[i]}let g=o.sceneHostedProducts.filter(h=>h.replacedPiece!==e);return d&&(g=g.filter(h=>h.id!==d)),{hostWidths:n,hostProductOverrides:s,hostDoorTypes:r,hostFinishes:c,hostMaterials:l,hostStyles:u,hostHandleTypes:m,occupiedPieceSlots:P,sceneHostedProducts:g}})},setPendingHostedProduct:(e,o={})=>{const n=o.autoPlacePieceIdx??null;t({pendingHostedProduct:e,showHostedProductSlots:!0,pendingAutoPlacePieceIdx:n,selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})},clearPendingAutoPlacePieceIdx:()=>{t({pendingAutoPlacePieceIdx:null})},clearPendingHostedProduct:()=>{t({pendingHostedProduct:null,showHostedProductSlots:!1,pendingAutoPlacePieceIdx:null})},setPendingSlotPlacement:e=>t({pendingSlotPlacement:e||null}),clearPendingSlotPlacement:()=>t({pendingSlotPlacement:null}),setDeferredHostedProductPlacement:e=>t({deferredHostedProductPlacement:e}),clearDeferredHostedProductPlacement:()=>t({deferredHostedProductPlacement:null}),setPendingPieceAdd:e=>t(o=>o.pendingPieceAdd?{pendingPieceAddQueue:[...o.pendingPieceAddQueue,e]}:{pendingPieceAdd:e}),clearPendingPieceAdd:()=>t(e=>{const o=e.pendingPieceAddQueue;if(o.length>0){const[n,...s]=o;return{pendingPieceAdd:n,pendingPieceAddQueue:s}}return{pendingPieceAdd:null}}),setPendingPieceDelete:e=>t({pendingPieceDelete:e}),clearPendingPieceDelete:()=>t({pendingPieceDelete:null}),addDisabledWall:e=>t(o=>({disabledWalls:o.disabledWalls.includes(e)?o.disabledWalls:[...o.disabledWalls,e]})),removeDisabledWall:e=>t(o=>({disabledWalls:o.disabledWalls.filter(n=>n!==e)})),clearDisabledWalls:()=>t({disabledWalls:[]}),setSkipWallPieceOverlapCheck:e=>t({skipWallPieceOverlapCheck:e}),setCurrentLayoutType:e=>t({currentLayoutType:e}),setCurrentPerpendicularWalls:e=>t({currentPerpendicularWalls:e}),setValidCornerSlots:e=>t({validCornerSlots:e}),setWallCornerCount:e=>t({wallCornerCount:e}),setValidWallCornerSlots:e=>t({validWallCornerSlots:e}),clearPendingWallCornerAdd:()=>t({pendingWallCornerAdd:null}),placeHostedProductAtSlot:(e,o=[0,0,0])=>{const{pendingHostedProduct:n}=p();if(!n)return null;const s=L(),r={id:s,hostedProductId:n.id,name:n.name,modelUrl:n.modelUrl,position:e,rotation:o,scale:n.scale||[1,1,1]},c=p()._snapshotOverridesOnLoadComplete;return t(l=>({sceneHostedProducts:[...l.sceneHostedProducts,r],pendingHostedProduct:null,showHostedProductSlots:!1,...c?{sceneLoadingMessage:`Placing ${n.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${n.name}...`}})),s},addHostedProduct:e=>{const o=L(),n={id:o,hostedProductId:e.id,name:e.name,modelUrl:e.modelUrl,position:e.position||[0,0,0],rotation:e.rotation||[0,0,0],scale:e.scale||[1,1,1],...e.pairedWith?{pairedWith:e.pairedWith}:{}},s=p()._snapshotOverridesOnLoadComplete;return t(r=>({sceneHostedProducts:[...r.sceneHostedProducts,n],...s?{sceneLoadingMessage:`Adding ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Adding ${e.name}...`}})),o},setHostedProductLoaded:()=>{p()._snapshotOverridesOnLoadComplete||t({isSceneLoading:!1,sceneLoadingMessage:""})},removeHostedProduct:e=>{t(o=>{const n={...o.occupiedPieceSlots},s={...o.hostWidths},r={...o.hostProductOverrides},c={...o.hostDoorTypes};let l=null,u=null,m=!1;for(const[d,i]of Object.entries(n))i.surfaceHostedProductId===e&&(n[d]={...i},delete n[d].surfaceHostedProductId,m=!0);if(!m){for(const[d,i]of Object.entries(n))if(i.hostedProductId===e){i.surfaceHostedProductId&&(u=i.surfaceHostedProductId),i.previousWidth!==void 0?s[d]=i.previousWidth:delete s[d],i.previousProductOverride!==void 0?r[d]=i.previousProductOverride:delete r[d],i.previousDoorType!==void 0?c[d]=i.previousDoorType:delete c[d];try{const g=T.getState().products||{},h=r[d]??o.basePiecePositions?.[d]?.productId??null,b=h!=null?g[h]||g[String(h)]:null,W=v=>{const _=v?.components_configuration??v?.componentsConfiguration??{},y=_.comp_base_slab??_.comp_corner_slab??null;return String(y?.variant_key??y?.variantKey??"")};if(b){const v=W(b),_=b.product_graph??b.productGraph??null,y=v?Object.values(g).find(w=>{if(!w||w.id===b.id||b.width!=null&&Number(w.width)!==Number(b.width)||_!=null&&(w.product_graph??w.productGraph??null)!==_)return!1;const M=W(w);if(!M||M===v||!v.startsWith(M+"_"))return!1;const I=v.slice(M.length+1);return/^[a-z0-9]+$/i.test(I)}):null;y?.id!=null&&(r[d]=y.id)}}catch{}i.pairedHostedProductId&&(l=i.pairedHostedProductId),delete n[d]}else if(i.linkedToBase){const g=o.occupiedPieceSlots[i.linkedToBase];g&&g.hostedProductId===e&&delete n[d]}}if(!l){const d=o.sceneHostedProducts.find(i=>i.id===e);d?.pairedWithHostedProductId&&(l=d.pairedWithHostedProductId)}if(l)for(const[d,i]of Object.entries(n))i.hostedProductId===l&&i.pairedHostedProductId&&(n[d]={...i},delete n[d].pairedHostedProductId);const P=new Set([e,u].filter(Boolean));for(let d=!0;d;){d=!1;for(const i of o.sceneHostedProducts)P.has(i.id)||i.pairedWithHostedProductId!=null&&P.has(i.pairedWithHostedProductId)&&(P.add(i.id),d=!0)}for(const[d,i]of Object.entries(n))P.has(i.hostedProductId)&&delete n[d];let f=o.sceneHostedProducts.filter(d=>!P.has(d.id));return l&&!P.has(l)&&(f=f.map(d=>d.id===l?{...d,pairedWithHostedProductId:void 0,pairedWithPiece:void 0}:d)),{sceneHostedProducts:f,occupiedPieceSlots:n,hostWidths:s,hostProductOverrides:r,hostDoorTypes:c}})},moveHostedProductLeft:e=>{t(o=>{const n=o.sceneHostedProducts.findIndex(r=>r.id===e);if(n<=0)return o;const s=[...o.sceneHostedProducts];return[s[n-1],s[n]]=[s[n],s[n-1]],{sceneHostedProducts:s}})},moveHostedProductRight:e=>{t(o=>{const n=o.sceneHostedProducts.findIndex(r=>r.id===e);if(n===-1||n>=o.sceneHostedProducts.length-1)return o;const s=[...o.sceneHostedProducts];return[s[n],s[n+1]]=[s[n+1],s[n]],{sceneHostedProducts:s}})},updateHostedProductPosition:(e,o)=>{t(n=>({sceneHostedProducts:n.sceneHostedProducts.map(s=>s.id===e?{...s,position:o}:s)}))},updateHostedProductRotation:(e,o)=>{t(n=>({sceneHostedProducts:n.sceneHostedProducts.map(s=>s.id===e?{...s,rotation:o}:s)}))},clearHostedProducts:()=>{t({sceneHostedProducts:[],occupiedPieceSlots:{}})},occupyPieceSlot:(e,o,n,s)=>{t(r=>({occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:{hostedProductId:o,position:n,rotation:s}}}))},freePieceSlot:e=>{t(o=>{const n={...o.occupiedPieceSlots};return delete n[e],{occupiedPieceSlots:n}})},setHostedProductFeatureForSlot:(e,o,n)=>{t(s=>{const r=s.occupiedPieceSlots[e];return r?{occupiedPieceSlots:{...s.occupiedPieceSlots,[e]:{...r,featureSelections:{...r.featureSelections,[o]:n}}}}:s})},updateHostedProductSlotForProduct:(e,o)=>{const n=p().occupiedPieceSlots[e];if(!n)return;const s=n.hostedProductSlots?.find(r=>r.product_id===o);s&&t(r=>{const c={...r.occupiedPieceSlots[e]};s.component_overrides&&(c.component_overrides=s.component_overrides),s.component_transforms?c.component_transforms=s.component_transforms:delete c.component_transforms;const l=c.hostedProductId;return{occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:c},sceneHostedProducts:r.sceneHostedProducts.map(u=>u.id===l?{...u,modelOffset:s.position||null,modelRotation:s.rotation||null,additionalModels:s.additionalModels||u.additionalModels,...s.modelUrl?{modelUrl:s.modelUrl}:{}}:u)}})},setPieceConfigSnapshot:e=>{t({pieceConfigSnapshot:e})},setInitialPieceConfigSnapshot:e=>{t({initialPieceConfigSnapshot:e})},setInitialPerPieceOverrides:()=>{const e=p(),o=U.getState().sceneSelections;t({initialPerPieceOverrides:{hostFinishes:{...e.hostFinishes},hostStyles:{...e.hostStyles},hostHandleTypes:{...e.hostHandleTypes},hostWidths:{...e.hostWidths},hostDoorTypes:{...e.hostDoorTypes},hostProductOverrides:{...e.hostProductOverrides},hostHardwareFinishes:{...e.hostHardwareFinishes},sceneHostedProducts:[...e.sceneHostedProducts],sceneSelections:{...o}}})},setBasePiecePositions:e=>{const o=p().basePiecePositions||{},n=Object.keys(o),s=Object.keys(e||{});if(n.length===s.length){let r=!1;for(const c of s){const l=o[c],u=e[c];if(!l||!u){r=!0;break}const m=l.position,P=u.position,f=l.rotation||[0,0,0],d=u.rotation||[0,0,0];if(!Array.isArray(m)||!Array.isArray(P)){r=!0;break}if(Math.abs((m[0]||0)-(P[0]||0))>1e-6||Math.abs((m[1]||0)-(P[1]||0))>1e-6||Math.abs((m[2]||0)-(P[2]||0))>1e-6||Math.abs((f[1]||0)-(d[1]||0))>1e-6||String(l.productId??"")!==String(u.productId??"")){r=!0;break}}if(!r)return}t({basePiecePositions:e})},getBasePiecePosition:e=>p().basePiecePositions[e],setSceneModelTransforms:e=>{t({sceneModelTransforms:e})},placeHostedProductAtPiece:(e,o,n,s=[0,0,0],r=null)=>{const c=L();let l=e.placement_type||"replace_full";const u=r||p().basePiecePositions[o]?.productId,m=u!=null?String(u):null,P=T.getState().products||{},f=a=>{if(a==null)return null;const H=P[a]||P[String(a)];return H||Object.values(P).find(O=>O&&C(O.id,a))||null},d=(a,H)=>{const O=f(a),S=f(H);return!O||!S?!1:String(O.id)===String(S.id)};let i=e.slots?.find(a=>a.product_id!=null&&d(a.product_id,u))||e.slots?.find(a=>a.product_id==null)||e.slots?.find(a=>a.product_id!=null&&C(a.product_id,u))||(e.id==="oven_stove"?e.slots?.find(a=>a.product_id!=null&&C(a.product_id,e.target_product_id)):null);const g=E(o);if(g==="corner"||g==="wall_corner"){const a=j(e,P);if(a){const H=f(u),S=(H?.components_configuration??H?.componentsConfiguration??{}).comp_corner_slab,D=String(S?.variant_key??S?.variantKey??"");if(D){const A=T.getState().components||{},x=A.comp_corner_slab??A.comp_corner_slab,F=D+a;x?.variants?.[F]!=null&&(i={...i||{position:null,rotation:null},product_id:null,component_overrides:{...i?.component_overrides||{},comp_corner_slab:{variant_key:F}}},l="replace_components")}}}if(l==="replace_components"){const a=Array.isArray(e.slots)?e.slots:[],H=a.some(S=>S&&S.component_overrides&&Object.keys(S.component_overrides).length>0);!(i?.component_overrides&&Object.keys(i.component_overrides).length>0)&&(a.length===0||!H)&&(l="replace_full")}const b=i?.position||e.componentModelOffset||null,W=i?.rotation||e.componentModelRotation||null,v={id:c,hostedProductId:e.id,name:e.name,modelUrl:i?.modelUrl||e.modelUrl,position:n,rotation:s,scale:e.scale||[1,1,1],placement_type:l,modelOffset:b,modelRotation:W,replacedPiece:o,additionalModels:i?.additionalModels||e.additionalModels||[]},_=Array.isArray(e.hostVariants)&&e.hostVariants.length>0,y={hostedProductId:c,position:n,rotation:s,placement_type:l,isHostSwap:_,compatibleProductIds:e.slots?.map(a=>a.product_id)||[],hostedProductSlots:e.slots||[],featureSelections:(()=>{const a=e.features||[],H=e.feature_defaults||{},O={};for(const S of a){const D=T.getState().features[S];O[S]=H[S]||D?.default_option_id}return O})()};l==="replace_components"&&i?.component_overrides&&(y.component_overrides=i.component_overrides),l==="replace_components"&&i?.component_transforms&&(y.component_transforms=i.component_transforms);const w={},M=e?.target_width??e?.auto_target_width??null,I=p()._snapshotOverridesOnLoadComplete;return t(a=>({sceneHostedProducts:[...a.sceneHostedProducts,v],occupiedPieceSlots:{...a.occupiedPieceSlots,[o]:y,...w},...M!=null?{hostWidths:{...a.hostWidths,[o]:M}}:{},pendingHostedProduct:null,showHostedProductSlots:!1,...I?{sceneLoadingMessage:`Placing ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${e.name}...`},selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})),c},addSurfaceHostedProduct:(e,o)=>{const n=L(),s={id:n,hostedProductId:e.id,name:e.name,modelUrl:e.modelUrl,position:[0,0,0],rotation:[0,0,0],scale:e.scale||[1,1,1],placement_type:"countertop_overlay",replacedPiece:o},r=p()._snapshotOverridesOnLoadComplete;return t(c=>({sceneHostedProducts:[...c.sceneHostedProducts,s],occupiedPieceSlots:{...c.occupiedPieceSlots,[o]:{...c.occupiedPieceSlots[o],surfaceHostedProductId:n}},pendingHostedProduct:null,showHostedProductSlots:!1,...r?{sceneLoadingMessage:`Placing ${e.name}...`}:{isSceneLoading:!0,sceneLoadingMessage:`Placing ${e.name}...`},selectedFeatureId:null,selectedElementType:null,selectedPieceIndex:null})),n},setPair:(e,o,n,s)=>{t(r=>({occupiedPieceSlots:{...r.occupiedPieceSlots,[e]:{...r.occupiedPieceSlots[e],pairedWith:n,pairedHostedProductId:s},[n]:{...r.occupiedPieceSlots[n],pairedWith:e,pairedHostedProductId:o}}}))},setPairing:(e,o,n,s)=>p().setPair(e,o,n,s),showSuccess:e=>p().addNotification({type:"success",message:e}),showError:e=>p().addNotification({type:"error",message:e}),showWarning:e=>p().addNotification({type:"warning",message:e}),showInfo:e=>p().addNotification({type:"info",message:e})}),{name:"ui-store"}));var Z=K;export{Z as default};
|
package/dist/9c6c598569.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{create as I}from"zustand";import{emitEvent as p,EVENTS as S}from"./2e366d7386.js";import{subscribeWithSelector as g}from"zustand/middleware";import{devtools as v}from"./52436e0169.js";import{v4 as h}from"uuid";import{FRONT_VIEW_POSITION as P,FRONT_VIEW_TARGET as C,PERSPECTIVE_VIEW_DIR_LEFT as T}from"./23dc0ccf32.js";import"./d94df858ea.js";import"./be337ddda5.js";import"./872c4302e0.js";import F from"./8f60e5059a.js";import{getR3FState as u}from"./e1cd279733.js";import{computeTopDownView as O,computeFitView as E,ORTHO_FOV as b,PERSP_FOV as _}from"./85af90fade.js";const N=I(v(g((c,f)=>({activeSceneId:null,activeSceneConfigId:null,productInstances:{},pendingPlacementPiece:null,componentStates:{},placementSelections:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null,hoveredInstanceId:null,hoveredComponentId:null,cameraPosition:[0,1.08,3.92],cameraTarget:[0,1,0],cameraFov:45,focusTarget:null,isFocusing:!1,isSceneLoading:!1,viewMode:"3d",initializeScene:e=>{c({activeSceneConfigId:e,isSceneLoading:!0,productInstances:{},componentStates:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null})},setActiveSceneId:e=>{c({activeSceneId:e})},addProductInstance:(e,t,o=[0,0,0],n=[0,0,0])=>{const a=h();return c(i=>({productInstances:{...i.productInstances,[a]:{id:a,productId:e,configId:t,position:o,rotation:n,scale:[1,1,1],createdAt:Date.now()}}})),a},removeProductInstance:e=>{c(t=>{const o=t.productInstances||{},n=new Set([String(e)]);let a=!0;for(;a;){a=!1;for(const s of Object.values(o)){const l=String(s?.id??s?.instanceId??"");if(!l||n.has(l))continue;const d=s?.positionedAbove??s?.positioned_above??null;d!=null&&n.has(String(d))&&(n.add(l),a=!0)}}const i={};for(const[s,l]of Object.entries(o))n.has(String(s))||(i[s]=l);const r={};for(const[s,l]of Object.entries(t.componentStates||{}))n.has(String(s))||(r[s]=l);const m=n.has(String(t.selectedInstanceId));return{productInstances:i,componentStates:r,selectedInstanceId:m?null:t.selectedInstanceId,selectedComponentId:m?null:t.selectedComponentId}})},updateInstancePosition:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],position:t}}}))},updateInstanceRotation:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],rotation:t}}}))},updateInstanceScale:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],scale:t}}}))},updateInstanceVariant:(e,t)=>{c(o=>{const n=o.productInstances[e];return n?{productInstances:{...o.productInstances,[e]:{...n,productId:t,variantId:t}}}:o})},setComponentMaterial:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],materialId:o}}}}))},setComponentVariant:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],variant:o}}}}))},setComponentVisibility:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],visible:o}}}}))},setPlacementSelections:(e,t)=>{!e||typeof t!="object"||c(o=>({placementSelections:{...o.placementSelections,[e]:t||{}}}))},setPlacementOverrides:(e,t)=>{e&&c(o=>({placementOverrides:{...o.placementOverrides,[e]:t||{}}}))},setComponentSwap:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],componentId:o}}}}))},initializeComponentStates:(e,t,o={})=>{const n={};t.forEach(a=>{n[a.id]={visible:!0,material:a.default_material,variant:null}}),c(a=>({componentStates:{...a.componentStates,[e]:n}}))},selectInstance:(e,t=null)=>{c({selectedInstanceId:e,selectedComponentId:t});try{p(S.SELECTION_CHANGED,{placementId:e,componentId:t})}catch{}},clearSelection:()=>{c({selectedInstanceId:null,selectedComponentId:null});try{p(S.SELECTION_CHANGED,{placementId:null,componentId:null})}catch{}},setPendingPlacementPiece:e=>c({pendingPlacementPiece:e}),clearPendingPlacementPiece:()=>c({pendingPlacementPiece:null}),setHoveredInstance:(e,t=null)=>{c({hoveredInstanceId:e,hoveredComponentId:t})},setCameraPosition:e=>{c({cameraPosition:e})},setCameraTarget:e=>{c({cameraTarget:e})},setCameraFov:e=>{c({cameraFov:e})},setCameraPreset:(e={})=>{const t=f(),o=Array.isArray(e.position)?e.position:t.cameraPosition,n=Array.isArray(e.target)?e.target:t.cameraTarget,a=Number.isFinite(Number(e.fov))?Number(e.fov):t.cameraFov;if(Number.isFinite(Number(e.fov))){const i=u()?.camera;i&&i.fov!==a&&(i.fov=a,i.updateProjectionMatrix?.())}c({cameraPosition:[...o],cameraTarget:[...n],cameraFov:a,focusTarget:{position:[...o],target:[...n],instant:!!e.instant},isFocusing:!0})},focusOnObject:(e,t,o)=>{const n=Math.max(t*2.5,.8);let a,i,r;if(o!=null){const m=Math.sin(o),s=Math.cos(o);a=e[0]+m*n,i=e[1]+n*.3,r=e[2]+s*n}else a=e[0],i=e[1]+n*.3,r=e[2]+n;c({focusTarget:{position:[a,i,r],target:[...e]},isFocusing:!0})},clearFocus:()=>{c({focusTarget:null,isFocusing:!1})},resetCameraToDefault:(e={})=>{const t=!!e.instant;if(!F.getState().is3D){const r=u(),m=r?.scene,s=r?.gl?.domElement;if(m&&s&&s.clientWidth&&s.clientHeight){const l=O({scene:m,aspect:s.clientWidth/s.clientHeight,fov:b});if(l){c({focusTarget:{position:l.position,target:l.target,instant:t},isFocusing:!0});return}}return}const n=u(),a=n?.scene,i=n?.gl?.domElement;if(a&&i&&i.clientWidth&&i.clientHeight){const r=E({scene:a,aspect:i.clientWidth/i.clientHeight,fov:_,dir:T});if(r){c({focusTarget:{position:r.position,target:r.target},isFocusing:!0});return}}c({focusTarget:{position:P,target:C,instant:t},isFocusing:!0})},setViewMode:e=>{c({viewMode:e})},setSceneLoading:e=>{c({isSceneLoading:e})},resetScene:()=>{c({productInstances:{},componentStates:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null,hoveredInstanceId:null,hoveredComponentId:null,isSceneLoading:!1})}})),{name:"scene-graph"}));var U=N;export{U as default};
|
|
1
|
+
import{create as I}from"zustand";import{emitEvent as p,EVENTS as S}from"./2e366d7386.js";import{subscribeWithSelector as g}from"zustand/middleware";import{devtools as v}from"./52436e0169.js";import{v4 as h}from"uuid";import{FRONT_VIEW_POSITION as P,FRONT_VIEW_TARGET as C,PERSPECTIVE_VIEW_DIR_LEFT as T}from"./23dc0ccf32.js";import"./d94df858ea.js";import"./be337ddda5.js";import"./872c4302e0.js";import F from"./8f60e5059a.js";import{getR3FState as u}from"./e1cd279733.js";import{computeTopDownView as O,computeFitView as E,ORTHO_FOV as b,PERSP_FOV as _}from"./85af90fade.js";const N=I(v(g((c,f)=>({activeSceneId:null,activeSceneConfigId:null,productInstances:{},pendingPlacementPiece:null,componentStates:{},placementSelections:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null,hoveredInstanceId:null,hoveredComponentId:null,cameraPosition:[0,1.08,3.92],cameraTarget:[0,1,0],cameraFov:45,focusTarget:null,isFocusing:!1,isSceneLoading:!1,viewMode:"3d",initializeScene:e=>{c({activeSceneConfigId:e,isSceneLoading:!0,productInstances:{},componentStates:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null})},setActiveSceneId:e=>{c({activeSceneId:e})},addProductInstance:(e,t,o=[0,0,0],n=[0,0,0])=>{const a=h();return c(i=>({productInstances:{...i.productInstances,[a]:{id:a,productId:e,configId:t,position:o,rotation:n,scale:[1,1,1],createdAt:Date.now()}}})),a},removeProductInstance:e=>{c(t=>{const o=t.productInstances||{},n=new Set([String(e)]);let a=!0;for(;a;){a=!1;for(const s of Object.values(o)){const l=String(s?.id??s?.instanceId??"");if(!l||n.has(l))continue;const d=s?.positionedAbove??s?.positioned_above??null;d!=null&&n.has(String(d))&&(n.add(l),a=!0)}}const i={};for(const[s,l]of Object.entries(o))n.has(String(s))||(i[s]=l);const r={};for(const[s,l]of Object.entries(t.componentStates||{}))n.has(String(s))||(r[s]=l);const m=n.has(String(t.selectedInstanceId));return{productInstances:i,componentStates:r,selectedInstanceId:m?null:t.selectedInstanceId,selectedComponentId:m?null:t.selectedComponentId}})},updateInstancePosition:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],position:t}}}))},updateInstanceRotation:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],rotation:t}}}))},updateInstanceScale:(e,t)=>{c(o=>({productInstances:{...o.productInstances,[e]:{...o.productInstances[e],scale:t}}}))},updateInstanceVariant:(e,t)=>{c(o=>{const n=o.productInstances[e];return n?{productInstances:{...o.productInstances,[e]:{...n,productId:t,variantId:t}}}:o})},setComponentMaterial:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],materialId:o}}}}))},setComponentVariant:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],variant:o}}}}))},setComponentVisibility:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],visible:o}}}}))},setPlacementSelections:(e,t)=>{!e||typeof t!="object"||c(o=>({placementSelections:{...o.placementSelections,[e]:t||{}}}))},setPlacementOverrides:(e,t)=>{e&&c(o=>({placementOverrides:{...o.placementOverrides,[e]:t||{}}}))},setComponentSwap:(e,t,o)=>{c(n=>({componentStates:{...n.componentStates,[e]:{...n.componentStates[e],[t]:{...n.componentStates[e]?.[t],componentId:o}}}}))},initializeComponentStates:(e,t,o={})=>{const n={};t.forEach(a=>{n[a.id]={visible:!0,material:a.default_material,variant:null}}),c(a=>({componentStates:{...a.componentStates,[e]:n}}))},selectInstance:(e,t=null)=>{c({selectedInstanceId:e,selectedComponentId:t});try{p(S.SELECTION_CHANGED,{placementId:e,componentId:t})}catch{}},clearSelection:()=>{c({selectedInstanceId:null,selectedComponentId:null});try{p(S.SELECTION_CHANGED,{placementId:null,componentId:null})}catch{}},setPendingPlacementPiece:e=>c({pendingPlacementPiece:e}),clearPendingPlacementPiece:()=>c({pendingPlacementPiece:null}),setHoveredInstance:(e,t=null)=>{c({hoveredInstanceId:e,hoveredComponentId:t})},setCameraPosition:e=>{c({cameraPosition:e})},setCameraTarget:e=>{c({cameraTarget:e})},setCameraFov:e=>{c({cameraFov:e})},setCameraPreset:(e={})=>{const t=f(),o=Array.isArray(e.position)?e.position:t.cameraPosition,n=Array.isArray(e.target)?e.target:t.cameraTarget,a=Number.isFinite(Number(e.fov))?Number(e.fov):t.cameraFov;if(Number.isFinite(Number(e.fov))){const i=u()?.camera;i&&i.fov!==a&&(i.fov=a,i.updateProjectionMatrix?.())}c({cameraPosition:[...o],cameraTarget:[...n],cameraFov:a,focusTarget:{position:[...o],target:[...n],instant:!!e.instant},isFocusing:!0})},focusOnObject:(e,t,o)=>{const n=Math.max(t*2.5,.8);let a,i,r;if(o!=null){const m=Math.sin(o),s=Math.cos(o);a=e[0]+m*n,i=e[1]+n*.3,r=e[2]+s*n}else a=e[0],i=e[1]+n*.3,r=e[2]+n;c({focusTarget:{position:[a,i,r],target:[...e]},isFocusing:!0})},clearFocus:()=>{c({focusTarget:null,isFocusing:!1})},resetCameraToDefault:(e={})=>{const t=!!e.instant;if(!F.getState().is3D){const r=u(),m=r?.scene,s=r?.gl?.domElement;if(m&&s&&s.clientWidth&&s.clientHeight){const l=O({scene:m,aspect:s.clientWidth/s.clientHeight,fov:b});if(l){c({focusTarget:{position:l.position,target:l.target,instant:t},isFocusing:!0});return}}return}const n=u(),a=n?.scene,i=n?.gl?.domElement;if(a&&i&&i.clientWidth&&i.clientHeight){const r=E({scene:a,aspect:i.clientWidth/i.clientHeight,fov:_,dir:T});if(r){c({focusTarget:{position:r.position,target:r.target,instant:t},isFocusing:!0});return}}c({focusTarget:{position:P,target:C,instant:t},isFocusing:!0})},setViewMode:e=>{c({viewMode:e})},setSceneLoading:e=>{c({isSceneLoading:e})},resetScene:()=>{c({productInstances:{},componentStates:{},placementOverrides:{},selectedInstanceId:null,selectedComponentId:null,hoveredInstanceId:null,hoveredComponentId:null,isSceneLoading:!1})}})),{name:"scene-graph"}));var U=N;export{U as default};
|
package/dist/c2a14a77ae.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as j,jsx as g,jsxs as C}from"react/jsx-runtime";import{useRef as v,useEffect as Y,useMemo as R}from"react";import{TransformControls as q}from"@react-three/drei";function w([c,r,o],s){const i=Math.cos(s),n=Math.sin(s);return[c*i+o*n,r,-c*n+o*i]}function M({objectRef:c,mode:r,rotationSnap:o,size:s,onChange:i,onDragEnd:n}){const f=v();Y(()=>{const a=f.current;if(!a)return;const h=d=>{d.value||n()};return a.addEventListener("dragging-changed",h),a.addEventListener("objectChange",i),()=>{a.removeEventListener("dragging-changed",h),a.removeEventListener("objectChange",i)}});const u=r==="rotate";return g(q,{ref:f,object:c,mode:r,showX:!u,showZ:!u,showY:u,...u&&o?{rotationSnap:o}:{},size:s})}function A({selected:c,position:r,rotationY:o=0,mode:s="both",rotationSnap:i=Math.PI/2,gizmoOffset:n,disabled:f=!1,onCommit:u,children:a}){const h=v(),d=v(),b=R(()=>Array.isArray(n)?[n[0]||0,n[1]||0,n[2]||0]:[0,0,0],[n]),z=R(()=>{const[t,e,l]=w(b,o),p=r||[0,0,0];return[(p[0]||0)+t,(p[1]||0)+e,(p[2]||0)+l]},[r,o,b]),m=()=>{const t=d.current;if(!t)return null;const e=t.quaternion,l=2*Math.atan2(e.y,e.w),[p,L,P]=w(b,l);return{position:[t.position.x-p,t.position.y-L,t.position.z-P],rotationY:l}},x=()=>{const t=h.current,e=m();!t||!e||(t.position.set(e.position[0],e.position[1],e.position[2]),t.rotation.set(0,e.rotationY,0))},E=()=>{const t=m();t&&u?.({position:[t.position[0],0,t.position[2]],rotationY:t.rotationY})},D=c&&!f,y=s==="both";return C(j,{children:[g("group",{ref:h,position:r,rotation:[0,o,0],children:a}),D&&C(j,{children:[g("object3D",{ref:d,position:z,rotation:[0,o,0]}),(y||s==="translate")&&g(M,{objectRef:d,mode:"translate",size:.8,onChange:x,onDragEnd:E}),(y||s==="rotate")&&g(M,{objectRef:d,mode:"rotate",rotationSnap:i,size:y?1.1:.8,onChange:x,onDragEnd:E})]})]})}export{A as default};
|
package/dist/c44d37da7a.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as r from"three";import T from"./872c4302e0.js";import F from"./d94df858ea.js";import R from"./8f60e5059a.js";import{deriveSceneFeatures as P}from"./be337ddda5.js";import{waitForAssetsIdle as _}from"./2774152dd2.js";const g=new Map,p=new Map,M=new Map,C=new r.TextureLoader(new r.LoadingManager),S=new Map;let w=!1;function Q(e){w=e}function L(e){if(!w||!e)return e;const t=e.lastIndexOf(".");return t===-1?e:e.slice(0,t)+"_mobile"+e.slice(t)}function x(e){if(e==null)return null;if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=e.trim().replace(/^#/,"");if(/^[0-9a-fA-F]{3}$/.test(t)){const n=t[0],i=t[1],a=t[2];return parseInt(n+n+i+i+a+a,16)}return/^[0-9a-fA-F]{6}$/.test(t)?parseInt(t,16):/^[0-9a-fA-F]{8}$/.test(t)?parseInt(t.slice(0,6),16):null}function B(e){if(!e||typeof e!="object")return e;const t=["color","emissive","specular","sheenColor","attenuationColor"];let n=null;for(const i of t){if(e[i]===void 0)continue;const a=x(e[i]);a!=null&&a!==e[i]&&(n||(n={...e}),n[i]=a)}return n||e}function d(e){if(e==null)return new r.Color(16777215);if(typeof e=="number")return new r.Color(e);if(typeof e=="string"){const t=e.trim();return/^[0-9a-fA-F]{3}$/.test(t)||/^[0-9a-fA-F]{6}$/.test(t)?new r.Color("#"+t):/^[0-9a-fA-F]{8}$/.test(t)?new r.Color("#"+t.slice(0,6)):new r.Color(t)}return new r.Color(16777215)}function G(e,t){return new Promise(n=>{C.load(encodeURI(e),i=>{i.colorSpace=r.SRGBColorSpace,i.wrapS=r.RepeatWrapping,i.wrapT=r.RepeatWrapping,n(i)},void 0,()=>{t&&t!==e?C.load(encodeURI(t),i=>{i.colorSpace=r.SRGBColorSpace,i.wrapS=r.RepeatWrapping,i.wrapT=r.RepeatWrapping,n(i)},void 0,()=>n(null)):n(null)})})}async function v(e){if(g.has(e))return g.get(e);try{const t=await fetch(encodeURI(e));if(!t.ok)throw new Error(`Failed to fetch ${e}`);const n=await t.json();return g.set(e,n),n}catch{return null}}const A={diffuse:{slot:"map",space:r.SRGBColorSpace},albedo:{slot:"map",space:r.SRGBColorSpace},normal:{slot:"normalMap",space:r.LinearSRGBColorSpace},roughness:{slot:"roughnessMap",space:r.LinearSRGBColorSpace},ao:{slot:"aoMap",space:r.LinearSRGBColorSpace},metalness:{slot:"metalnessMap",space:r.LinearSRGBColorSpace},emissive:{slot:"emissiveMap",space:r.SRGBColorSpace},map:{slot:"map",space:r.SRGBColorSpace},albedoMap:{slot:"map",space:r.SRGBColorSpace},normalMap:{slot:"normalMap",space:r.LinearSRGBColorSpace},roughnessMap:{slot:"roughnessMap",space:r.LinearSRGBColorSpace},metalnessMap:{slot:"metalnessMap",space:r.LinearSRGBColorSpace},aoMap:{slot:"aoMap",space:r.LinearSRGBColorSpace},emissiveMap:{slot:"emissiveMap",space:r.SRGBColorSpace}};function O(e){const t={};let n=!1;if(e.color!==void 0&&(t.color=d(e.color)),e.roughness!==void 0&&(t.roughness=e.roughness),e.metalness!==void 0&&(t.metalness=e.metalness),e.emissive!==void 0&&(t.emissive=d(e.emissive)),e.envMapIntensity!==void 0&&(t.envMapIntensity=e.envMapIntensity),e.sheen!==void 0&&e.sheen>0&&(t.sheen=e.sheen,n=!0),e.sheenColor!==void 0&&e.sheenColor!==0&&(t.sheenColor=d(e.sheenColor),n=!0),e.sheenRoughness!==void 0&&e.sheenRoughness!==1&&(t.sheenRoughness=e.sheenRoughness,n=!0),e.clearcoat!==void 0&&e.clearcoat>0&&(t.clearcoat=e.clearcoat,n=!0),e.clearcoatRoughness!==void 0&&e.clearcoatRoughness>0&&(t.clearcoatRoughness=e.clearcoatRoughness,n=!0),e.transmission!==void 0&&e.transmission>0&&(t.transmission=e.transmission,n=!0),e.thickness!==void 0&&e.thickness>0&&(t.thickness=e.thickness,n=!0),e.attenuationColor!==void 0&&e.attenuationColor!==16777215&&(t.attenuationColor=d(e.attenuationColor),n=!0),e.iridescence!==void 0&&e.iridescence>0&&(t.iridescence=e.iridescence,n=!0),e.iridescenceIOR!==void 0&&e.iridescenceIOR!==1.3&&(t.iridescenceIOR=e.iridescenceIOR,n=!0),e.iridescenceThicknessRange!==void 0){const i=e.iridescenceThicknessRange;(i[0]!==100||i[1]!==400)&&(t.iridescenceThicknessRange=i,n=!0)}if(e.specularIntensity!==void 0&&e.specularIntensity!==1&&(t.specularIntensity=e.specularIntensity,n=!0),e.specularColor!==void 0&&e.specularColor!==16777215&&(t.specularColor=d(e.specularColor),n=!0),e.reflectivity!==void 0&&e.reflectivity!==.5&&(t.reflectivity=e.reflectivity,n=!0),e.anisotropy!==void 0&&e.anisotropy!==0&&(t.anisotropy=e.anisotropy,n=!0),e.anisotropyRotation!==void 0&&e.anisotropyRotation!==0&&(t.anisotropyRotation=e.anisotropyRotation,n=!0),e.side!==void 0){const i={0:r.FrontSide,1:r.BackSide,2:r.DoubleSide};t.side=i[e.side]??r.FrontSide}return{params:t,needsPhysical:n}}async function E(e){if(!e)return null;const t=e.id;if(t!=null&&p.has(t))return p.get(t);if(t!=null&&S.has(t))return S.get(t);const n=k(e);if(t==null)return n;S.set(t,n);try{return await n}finally{S.delete(t)}}async function k(e){const t=e.id;let n=null,i=[1,1];if(e.materialJson)try{let a=B(e.materialJson);a.type||(a={...a,type:"MeshPhysicalMaterial"}),n=new r.MaterialLoader().parse(a),Array.isArray(e.materialJson.tiling)&&(i=e.materialJson.tiling)}catch{}if(!n&&e.materialFile){const a=await v(e.materialFile);if(a){const{params:c,needsPhysical:o}=O(a);Array.isArray(a.tiling)&&(i=a.tiling),n=o?new r.MeshPhysicalMaterial(c):new r.MeshStandardMaterial(c)}}if(!n&&(e.color!=null||e.roughness!=null||e.metalness!=null)){const a={};e.color!=null&&(a.color=d(e.color)),e.roughness!=null&&(a.roughness=e.roughness),e.metalness!=null&&(a.metalness=e.metalness),n=new r.MeshStandardMaterial(a)}if(!n&&e.textures&&(n=new r.MeshStandardMaterial),!n)return null;if(e.textures&&typeof e.textures=="object"){const a=[];for(const[c,o]of Object.entries(e.textures)){const l=A[c];if(!l||!o)continue;const u=String(o);a.push(G(L(u),u).then(s=>{s&&(s.colorSpace=l.space,s.repeat.set(i[0],i[1]),n[l.slot]=s)}))}await Promise.all(a),n.needsUpdate=!0}if(Array.isArray(i)&&(i[0]!==1||i[1]!==1)){const a=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap"];for(const c of a){const o=n[c];o&&(o.wrapS=r.RepeatWrapping,o.wrapT=r.RepeatWrapping,o.repeat.set(i[0],i[1]),o.needsUpdate=!0)}n.needsUpdate=!0}return t!=null&&p.set(t,n),n}function $(e){return e?!!(e.materialJson||e.materialFile||e.textures||e.color!=null||e.roughness!=null||e.metalness!=null):!1}function J(e){return!e||!e.id?null:p.get(e.id)||null}let b=[],m="idle",y=!1;function X(e){m=e==="never"?"never":"idle"}const I=e=>E(e).catch(()=>null);function Y(e){const t=T.getState(),n=t.materials,i=t.options||{};if(!n)return;const a=new Set,c=s=>{if(s==null)return;const f=i[s]??i[String(s)],h=f?.value??f?.valueMaterial??f?.value_material;h!=null&&(n[h]||n[String(h)])&&a.add(String(h))};try{for(const s of P(e)||[])s?.type==="finish_change"&&c(s.default_option_id??s.defaultOption)}catch{}try{const{sceneSelections:s}=F.getState();for(const f of Object.values(s||{}))c(f)}catch{}const o=["cabinet_finish","hardware_finish","countertop_finish"];o.forEach(s=>c(e?.[s])),e?.products?.forEach(s=>o.forEach(f=>c(s?.[f])));const l=Object.values(n).filter($),u=l.filter(s=>a.has(String(s.id)));b=l.filter(s=>!a.has(String(s.id))),y=!1,Promise.all(u.map(I))}const U=3;function V(){if(y||m==="never"||typeof navigator<"u"&&navigator.connection?.saveData)return;y=!0;const e=R.getState(),t=()=>_({quietMs:1e3,safetyMs:12e4}).then(W);if(e.bootLoading){let n=null;const i=()=>{n&&n(),n=null,t()};n=R.subscribe(a=>{a.bootLoading||i()}),setTimeout(()=>{n&&i()},2e4);return}t()}function W(){const e=b.slice(),t=()=>new Promise(i=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>i(),{timeout:2e3}):setTimeout(i,250)}),n=async()=>{for(;e.length;){if(m==="never")return;const i=e.shift();J(i)||(await t(),await I(i))}};for(let i=0;i<Math.min(U,e.length);i+=1)n()}function Z({color:e="#ffffff",roughness:t=.7,metalness:n=0,side:i}={}){const c=`${String(e).toLowerCase()}|${t}|${n}|${i??"def"}`,o=M.get(c);if(o)return o;const l={color:e,roughness:t,metalness:n};i!=null&&(l.side=i);const u=new r.MeshStandardMaterial(l);return M.set(c,u),u}function D(){p.forEach(e=>e.dispose()),p.clear(),g.clear(),M.forEach(e=>e.dispose()),M.clear()}export{D as clearMaterialCache,J as getCachedMaterial,Z as getFlatMaterial,$ as isPhysicalMaterial,E as loadPhysicalMaterial,V as prefetchRemainingMaterialsWhenIdle,Y as preloadMaterials,X as setFinishPrefetch,Q as setUseMobileTextures};
|
package/dist/c9a1656c62.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as A,jsxs as ot}from"react/jsx-runtime";import{useRef as H,useMemo as k,useEffect as G,useState as N,Suspense as $}from"react";import{useGLTF as q,Edges as J}from"@react-three/drei";import*as i from"three";import Q from"./9c6c598569.js";import F from"./872c4302e0.js";import Y from"./609e5e5d28.js";import{useComponentOverride as Z,_trackMount as K}from"./a3c983d431.js";import{getFlatMaterial as V}from"./c44d37da7a.js";import tt from"./983cbed22c.js";import{resolveMaterial as rt}from"./95a44ebec2.js";const et={"bottom-center":{x:"c",y:"min",z:"c"},"front-bottom-center":{x:"c",y:"min",z:"max"},"back-bottom-center":{x:"c",y:"min",z:"min"},"left-bottom-center":{x:"min",y:"min",z:"c"},"right-bottom-center":{x:"max",y:"min",z:"c"},"front-left-bottom-center":{x:"min",y:"min",z:"max"},"front-right-bottom-center":{x:"max",y:"min",z:"max"},"back-left-bottom-center":{x:"min",y:"min",z:"min"},"back-right-bottom-center":{x:"max",y:"min",z:"min"}};function nt({url:e,material:n,position:u,rotation:R,scale:W,skirt:w,onClick:p,isSelected:C,onMeasure:b,recalcPosition:D,slotName:y,slotKey:I,componentId:B,pivot:P,children:T}){const S=H(),{scene:d}=q(e,"/assets/draco/"),[E,z]=N(0),L=H(null);G(()=>{if(!D||!S.current){L.current=null,z(0);return}const r=S.current;r.updateWorldMatrix(!0,!0);const l=new i.Matrix4().copy(r.matrixWorld).invert(),a=r.parent?new i.Matrix4().copy(r.parent.matrixWorld).invert():new i.Matrix4,o=new i.Matrix4().multiplyMatrices(a,r.matrixWorld),s=new i.Box3,c=new i.Box3,v=new i.Matrix4;if(r.traverse(g=>{!g.isMesh||!g.geometry||(g.geometry.boundingBox||g.geometry.computeBoundingBox(),v.multiplyMatrices(o,new i.Matrix4().multiplyMatrices(l,g.matrixWorld)),c.copy(g.geometry.boundingBox).applyMatrix4(v),s.union(c))}),s.isEmpty())return;const t=(s.max.x-s.min.x)/2,x=(Array.isArray(u)&&u[0]||0)<0?-1:1;let f=L.current;if(L.current=t,f==null&&(f=.1),f==null){z(0);return}if(Math.abs(t-f)<1e-4)return;const h=x*(t-f);z(g=>g+h)},[d,D,u]),G(()=>{if(!b||!d)return;d.updateMatrixWorld(!0);const r=new i.Box3,l=new i.Box3;if(d.traverse(s=>{if(!s.isMesh||!s.geometry)return;const c=`${s.name||""} ${s.material?.name||""}`.toLowerCase();/shadow|contact[\s_-]?shadow|ao[\s_-]?(plane|map)|ground[\s_-]?plane/.test(c)||(s.geometry.boundingBox||s.geometry.computeBoundingBox(),l.copy(s.geometry.boundingBox).applyMatrix4(s.matrixWorld),r.union(l))}),r.isEmpty())return;const a=r.getSize(new i.Vector3),o=r.getCenter(new i.Vector3);(a.x>0||a.y>0||a.z>0)&&b({width:a.x,height:a.y,depth:a.z,cx:o.x,cy:o.y,cz:o.z})},[d,b]);const M=k(()=>{const r=d.clone(!0),l=y!=null&&String(y)!==""?String(y):null;l&&(r.name=l),r.userData={...r.userData,slotKey:I,componentId:B,slotName:l};let a=null;if(w){const o=new i.Box3().setFromObject(r);a=o.min.y+(o.max.y-o.min.y)*.12}return r.traverse(o=>{if(o.userData={...o.userData,slotKey:I,componentId:B,slotName:l},o.isMesh&&(o.castShadow=!0,o.receiveShadow=!0,n)){const s=n.clone();a!=null&&o.geometry?.attributes?.position&&s.color&&new i.Box3().setFromBufferAttribute(o.geometry.attributes.position).max.y<a&&s.color.multiplyScalar(.65),C&&(s.emissive=new i.Color("#ff6b35"),s.emissiveIntensity=1),o.material=s}}),r},[d,n,C,w,y,I,B]);G(()=>()=>{M.traverse(r=>{r.isMesh&&r.material&&r.material.dispose()})},[M]);const j=k(()=>{const r=et[P||"model-derived"];if(!r)return null;M.updateMatrixWorld(!0);const l=new i.Matrix4().copy(M.matrixWorld).invert(),a=new i.Box3,o=new i.Box3,s=new i.Matrix4;if(M.traverse(_=>{!_.isMesh||!_.geometry||(_.geometry.boundingBox||_.geometry.computeBoundingBox(),o.copy(_.geometry.boundingBox),s.multiplyMatrices(l,_.matrixWorld),o.applyMatrix4(s),a.union(o))}),a.isEmpty())return null;const{min:c,max:v}=a,t=(c.x+v.x)/2,m=(c.y+v.y)/2,x=(c.z+v.z)/2,f=r.x==="min"?c.x:r.x==="max"?v.x:t,h=r.y==="min"?c.y:m,g=r.z==="min"?c.z:r.z==="max"?v.z:x;return[-f,-h,-g]},[M,P]),O=D&&E&&Array.isArray(u)?[(u[0]||0)+E,u[1]||0,u[2]||0]:u;return ot("group",{ref:S,name:y!=null?String(y):void 0,userData:{slotKey:I,componentId:B,slotName:y!=null?String(y):void 0},position:O,rotation:R,scale:W,onClick:p,children:[j?A("group",{position:j,children:A("primitive",{object:M})}):A("primitive",{object:M}),T]})}function gt({geometry:e,material:n,position:u,onClick:R,isSelected:W}){const w=H(),p=k(()=>{if(W){const C=n.clone();return C.emissive=new i.Color("#ff6b35"),C.emissiveIntensity=1,C}return n},[n,W]);return G(()=>()=>{p!==n&&p.dispose()},[p,n]),A("mesh",{ref:w,geometry:e,material:p,position:u,onClick:R,castShadow:!0,receiveShadow:!0,children:W&&A(J,{scale:1.01,threshold:15,color:"#ff6b35",linewidth:3})})}const X={visible:!0,materialId:null};function U({component:e,componentState:n,instanceId:u,isSelected:R,onMeasure:W,onPick:w,slotName:p,slotKey:C,componentId:b,pivot:D,hiddenComponentIds:y,onDescendantMeasured:I,slotMaterials:B}){const P=Q(t=>t.selectInstance),T=F(t=>t.getMaterial),S=F(t=>t.getComponent),d=Z(p,e?.name??e?.componentName,b);d?.materialId&&(n={...n,materialId:d.materialId}),G(()=>K({name:e?.name??e?.componentName??null,slotName:p??null,componentId:b!=null?String(b):null,instanceId:u??null}),[e?.name,e?.componentName,p,b,u]);const{physicalMat:E}=Y(n.materialId,{getMaterial:T}),z=k(()=>{const t=n.variantId&&e.style_variants?e.style_variants[n.variantId]:null,m=e.variants,x=m&&typeof m=="object"?m.default||Object.values(m)[0]:null;return t||e.url||e.asset_url||e.modelPath||e.model_path||e.modelUrl||e.model_url||x||null},[e,n.variantId]),L=k(()=>{if(!z||typeof z!="string")return!1;const t=z.split(/[?#]/)[0].toLowerCase();return t.endsWith(".glb")||t.endsWith(".gltf")},[z]),M=k(()=>{if(E)return E;if(n.materialId){const t=T(n.materialId),m=rt({...n,materialId:n.materialId,definition:t},{THREE:i,Default:()=>t&&t.color?V({color:t.color||"#808080",roughness:t.roughness||.5,metalness:t.metalness||0}):null});if(m)return m;if(t&&t.color)return V({color:t.color||"#808080",roughness:t.roughness||.5,metalness:t.metalness||0})}return n.color?V({color:n.color,roughness:n.roughness??.5,metalness:n.metalness??0}):null},[n.materialId,n.color,n.roughness,n.metalness,T,E]),j=t=>{t.stopPropagation();const m=b??e?.id??null;if(w){w(m);return}P(u,m)},O=e.position||[0,0,0],r=e.rotation||e.orientation||[0,0,0],l=Math.PI/180,a=Array.isArray(r)&&r.length===3?e.rotationRad?[r[0],r[1],r[2]]:[r[0]*l,r[1]*l,r[2]*l]:[0,0,0];let o=e.scale||[1,1,1],s=O,c=a;if(d?.transform){const t=d.transform;t.position&&(s=[O[0]+t.position[0],O[1]+t.position[1],O[2]+t.position[2]]),t.rotation&&(c=[a[0]+t.rotation[0]*l,a[1]+t.rotation[1]*l,a[2]+t.rotation[2]*l]),t.scale&&(o=[o[0]*t.scale[0],o[1]*t.scale[1],o[2]*t.scale[2]])}const v=k(()=>{const t=Array.isArray(e.children)?e.children:[];if(!t.length)return null;const m=Array.isArray(y)&&y.length?new Set(y.map(x=>String(x))):null;return t.map(x=>{const f=x.componentId??x.component_id;if(m&&f!=null&&m.has(String(f)))return null;const h=f!=null?S(f):null;if(!h)return null;const g=String(h.materialSlot??h.material_slot??"").toLowerCase(),_=B&&g?B[g]:null;return A(U,{component:{...h,position:x.position,rotation:x.rotation,scale:x.scale},componentState:_?{...X,materialId:_}:X,instanceId:u,componentId:f,slotKey:h.materialSlot??h.name??String(f),slotName:h.name??null,onPick:w,hiddenComponentIds:y,slotMaterials:B,onMeasure:I,onDescendantMeasured:I},x.id??f)})},[e.children,S,u,w,y,I,B]);return d?.hidden?null:L?A(tt,{children:A($,{children:A(nt,{url:z,material:M,position:s,rotation:c,scale:o,skirt:e.skirt,onClick:j,isSelected:R,onMeasure:W,recalcPosition:e.recalcPosition,slotName:p,slotKey:C,componentId:b,pivot:D,children:v})})}):null}var dt=U;export{dt as default};
|
package/dist/d4378d9afa.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as g,jsx as e,jsxs as f}from"react/jsx-runtime";import{memo as T,useEffect as _,useMemo as p,useRef as O,lazy as m,Suspense as w}from"react";import*as A from"three";import{Environment as I}from"@react-three/drei";import{useThree as N}from"@react-three/fiber";import{RectAreaLightUniformsLib as z}from"three/examples/jsm/lights/RectAreaLightUniformsLib.js";import k from"./983cbed22c.js";import{applyEnvironmentToRenderer as P}from"./4e7d0a0d4a.js";import{getApiBaseUrl as U}from"./8ade32d067.js";const F=(()=>{let t=null;const o=()=>t||(t=import("@react-three/postprocessing"));return{EffectComposer:m(()=>o().then(n=>({default:n.EffectComposer}))),Bloom:m(()=>o().then(n=>({default:n.Bloom}))),SSAO:m(()=>o().then(n=>({default:n.SSAO}))),FXAA:m(()=>o().then(n=>({default:n.FXAA}))),N8AO:m(()=>o().then(n=>({default:n.N8AO})))}})(),{EffectComposer:W,Bloom:D,SSAO:X,FXAA:G,N8AO:H}=F,$=m(()=>Promise.all([import("@react-three/postprocessing"),import("postprocessing")]).then(([t,o])=>{const n={ACESFilmic:o.ToneMappingMode.ACES_FILMIC,Reinhard:o.ToneMappingMode.REINHARD,Linear:o.ToneMappingMode.LINEAR,Cineon:o.ToneMappingMode.OPTIMIZED_CINEON,AgX:o.ToneMappingMode.AGX,Neutral:o.ToneMappingMode.NEUTRAL};return{default:({name:d})=>{const i=d?n[d]:void 0;return i===void 0?null:e(t.ToneMapping,{mode:i})}}}));let M=!1;function j(){if(!M){try{z.init()}catch{}M=!0}}function x(t){if(!t||/^([a-z]+:)?\/\//i.test(t)||t.startsWith("data:")||t.startsWith("blob:"))return t;const o=U()||"";return t.startsWith("/")?`${o}${t}`:`${o}/${t}`}function S(t,o){return o?512:typeof t.shadow_map_size=="number"?t.shadow_map_size:2048}function Y({env:t,isMobile:o,is3D:n,reducedQuality:l,captureMode:d}){const{gl:i,invalidate:s}=N();_(()=>{t&&Object.keys(t).length>0&&(P(t,i),s())},[t,i,s]);const c=p(()=>{if(!t)return[];if(Array.isArray(t.lights))return t.lights;const a=[];if(t.ambient_light&&a.push({type:"ambient",...t.ambient_light}),Array.isArray(t.directional_lights))for(const u of t.directional_lights)a.push({type:"directional",...u});return a},[t]);p(()=>c.some(a=>a?.type==="rect_area"),[c])&&j();const h=p(()=>{if(!t?.hdr)return null;const a=t.hdr,u=o?a.url_1k??a.url1k??a.url??null:a.url_2k??a.url2k??a.url??null;return u?{url:x(u),intensity:typeof a.intensity=="number"?a.intensity:1,rotation_deg:typeof a.rotation_deg=="number"?a.rotation_deg:0,as_background:!!a.as_background}:null},[t?.hdr,o]),b=p(()=>[0,A.MathUtils.degToRad(h?.rotation_deg??0),0],[h?.rotation_deg]);if(!t||Object.keys(t).length===0)return null;let y=null;h?.as_background||(y=t.background?.color??"#ffffff");const E=t.background?.color??"#ffffff",R=typeof t.shadows?.bias=="number"?t.shadows.bias:15e-5,B=typeof t.shadows?.radius=="number"?t.shadows.radius:typeof t.ground?.shadow_blur=="number"?t.ground.shadow_blur:null,C=typeof t.shadows?.normal_bias=="number"?t.shadows.normal_bias:null;return f(g,{children:[h&&e(k,{children:e(w,{fallback:e("color",{attach:"background",args:[E]}),children:e(I,{files:h.url,background:h.as_background,environmentIntensity:h.intensity,environmentRotation:b,backgroundRotation:b})})}),y&&e("color",{attach:"background",args:[y]}),c.map((a,u)=>!a||a.enabled===!1?null:e(J,{light:a,is3D:n,reducedQuality:l,globalShadowBias:R,globalShadowRadius:B,globalShadowNormalBias:C},u)),e(q,{ground:t.ground,is3D:n,reducedQuality:l,captureMode:d}),e(Z,{postProcessing:t.post_processing,toneMapping:t.tone_mapping??t.toneMapping,is3D:n,reducedQuality:l,captureMode:d})]})}function q({ground:t,is3D:o,reducedQuality:n,captureMode:l}){if(l||!t||t.enabled!==!0)return null;const d=t.floor_color??t.color??"#ffffff",i=typeof t.size=="number"?t.size:21,s=n?-.05:o?-.005:-.02,c=typeof t.shadow_opacity=="number"?t.shadow_opacity:.5,r=t.shadow_color??"#000000";return f(g,{children:[f("mesh",{rotation:[-Math.PI/2,0,0],position:[0,s,0],renderOrder:n?-1:0,children:[e("circleGeometry",{args:[i,64]}),e("meshBasicMaterial",{color:d,toneMapped:!1,depthWrite:!n,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:2})]}),o&&c>0&&f("mesh",{rotation:[-Math.PI/2,0,0],position:[0,s+5e-4,0],receiveShadow:!0,children:[e("circleGeometry",{args:[i,64]}),e("shadowMaterial",{transparent:!0,opacity:c,color:r})]})]})}function Z({postProcessing:t,toneMapping:o,is3D:n,reducedQuality:l,captureMode:d}){if(d||!n||!t)return null;const i=t.bloom,s=t.ssao,c=t.fxaa,r=t.n8ao;return!i&&!s&&!c&&!r?null:e(k,{children:e(w,{fallback:null,children:f(W,{children:[i&&e(D,{intensity:typeof i?.intensity=="number"?i.intensity:.5,luminanceThreshold:typeof i?.threshold=="number"?i.threshold:.9,luminanceSmoothing:typeof i?.smoothing=="number"?i.smoothing:.025,mipmapBlur:!0}),r&&e(H,{aoRadius:typeof r?.radius=="number"?r.radius:l?.3:.5,intensity:typeof r?.intensity=="number"?r.intensity:l?1:1.5,distanceFalloff:typeof r?.falloff=="number"?r.falloff:.5,quality:l?"low":"medium"}),s&&!r&&e(X,{intensity:typeof s?.intensity=="number"?s.intensity:1,radius:typeof s?.radius=="number"?s.radius:.1,samples:l?9:16}),c&&e(G,{}),e($,{name:o})]})})})}function J({light:t,is3D:o,reducedQuality:n,globalShadowBias:l,globalShadowRadius:d,globalShadowNormalBias:i}){const s=O();_(()=>{t.target&&s.current&&s.current.position.set(t.target[0],t.target[1],t.target[2])},[t.target]);const c=r=>r?{"shadow-bias":typeof t.bias=="number"?t.bias:l,"shadow-normalBias":typeof t.normal_bias=="number"?t.normal_bias:i??.1,"shadow-radius":typeof t.radius=="number"?t.radius:d??4,"shadow-mapSize-width":S(t,n),"shadow-mapSize-height":S(t,n),"shadow-camera-far":t.shadow_camera_far??500,"shadow-camera-near":t.shadow_camera_near??.5,"shadow-camera-left":t.shadow_camera_left??-5,"shadow-camera-right":t.shadow_camera_right??5,"shadow-camera-top":t.shadow_camera_top??5,"shadow-camera-bottom":t.shadow_camera_bottom??-5}:{};switch(t.type){case"ambient":return e("ambientLight",{color:t.color,intensity:t.intensity??1});case"directional":{const r=o&&!!t.cast_shadow,h=t.position??[0,5,5];return f(g,{children:[e("directionalLight",{color:t.color,intensity:t.intensity??1,position:h,castShadow:r,...c(r)}),t.target&&e("object3D",{ref:s})]})}case"point":{const r=o&&!!t.cast_shadow;return e("pointLight",{color:t.color,intensity:t.intensity??1,position:t.position??[0,5,0],distance:t.distance??0,decay:t.decay??2,castShadow:r,...c(r)})}case"spot":{const r=o&&!!t.cast_shadow;return f(g,{children:[e("spotLight",{color:t.color,intensity:t.intensity??1,position:t.position??[0,5,0],distance:t.distance??0,angle:A.MathUtils.degToRad(t.angle_deg??30),penumbra:t.penumbra??0,decay:t.decay??2,castShadow:r,...c(r)}),t.target&&e("object3D",{ref:s})]})}case"hemisphere":return e("hemisphereLight",{color:t.sky_color??t.color,groundColor:t.ground_color,intensity:t.intensity??1,position:t.position??[0,5,0]});case"rect_area":return e("rectAreaLight",{color:t.color,intensity:t.intensity??1,width:t.width??1,height:t.height??1,position:t.position??[0,5,0],rotation:t.rotation??[0,0,0]});default:return null}}var nt=T(Y);export{nt as default};
|
package/dist/db4afd43c9.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerSlot as y}from"./73f7d65985.js";import{registerComponent as
|
|
1
|
+
import{registerSlot as y}from"./73f7d65985.js";import{registerComponent as d}from"./882bc739c8.js";import{registerAction as b,registerIcon as v,registerModal as R}from"./09c4973968.js";import{setLabels as m,unsetLabels as k,getLabels as j,setLocale as i,getLocale as A,setCurrency as f,getCurrency as E}from"./28d887bf8a.js";import{applyTheme as L}from"./5c9fd9201c.js";import{use as S}from"./6d238282c1.js";import{onEvent as w}from"./2e366d7386.js";import{onRequest as C,onResponse as O,setTransport as u}from"./a3f18e76fe.js";import{registerPlacementStrategy as F}from"./281cf952fa.js";import{registerTargetRenderer as I}from"./58e6419ba8.js";import{registerComponentRenderer as M,registerMaterialResolver as P,registerInteraction as T,onSceneReady as q}from"./95a44ebec2.js";import{on as x,registerEffectHandler as H}from"./970313b92b.js";import{setFinishPrefetch as h}from"./c44d37da7a.js";function s(e,t,r){if(!(!e||typeof e!="object"))for(const[n,o]of Object.entries(e)){const c=Array.isArray(o)?o:[o];for(const a of c){const l=t(n,a);typeof l=="function"&&r.push(l)}}}function p(e,t,r){if(Array.isArray(e))for(const n of e){const o=t(n);typeof o=="function"&&r.push(o)}}function _(e={}){const t=[];if(s(e.slots,y,t),s(e.components,d,t),s(e.icons,v,t),s(e.modals,R,t),s(e.actions,b,t),p(e.middleware,S,t),s(e.events,w,t),s(e.backendEvents,x,t),s(e.effectHandlers,H,t),e.http&&(p([].concat(e.http.onRequest||[]),C,t),p([].concat(e.http.onResponse||[]),O,t),typeof e.http.transport=="function"&&(u(e.http.transport),t.push(()=>u(null)))),p(e.placementStrategies,F,t),e.scene&&(s(e.scene.renderers,M,t),p([].concat(e.scene.materialResolvers||[]),P,t),s(e.scene.interactions,T,t),p([].concat(e.scene.onReady||[]),q,t),typeof e.scene.targetRenderer=="function"&&t.push(I(e.scene.targetRenderer)),e.scene.prefetchFinishes!=null&&(h(e.scene.prefetchFinishes),t.push(()=>h("idle")))),e.labels&&typeof e.labels=="object"){const r=j(),n=Object.keys(e.labels);m(e.labels),t.push(()=>{const o={},c=[];for(const a of n)Object.prototype.hasOwnProperty.call(r,a)?o[a]=r[a]:c.push(a);k(c),m(o)})}if(e.locale){const r=A();i(e.locale),t.push(()=>i(r))}if(e.currency){const r=E();f(e.currency),t.push(()=>f(r))}return e.theme&&L(e.theme),function(){for(const n of t.reverse())try{n()}catch{}t.length=0}}var Z=_;export{_ as configureSDK,Z as default};
|
package/dist/styles/globals.css
CHANGED
|
@@ -286,6 +286,34 @@ html[data-watermark="off"] .shell-chat-fab { bottom: 18px; }
|
|
|
286
286
|
/* Translucent variant — the scene is already visible and only its products are
|
|
287
287
|
still streaming in. A light, blurred scrim lets the scene show through while a
|
|
288
288
|
floating card presents the spinner + "Loading products…". */
|
|
289
|
+
/* The SCENE curtain: covers only the canvas area (its container is positioned), so the
|
|
290
|
+
header, toolbar and sidebar around it are already on screen while the models load. */
|
|
291
|
+
.loading-screen--scene {
|
|
292
|
+
position: absolute;
|
|
293
|
+
inset: 0;
|
|
294
|
+
width: 100%;
|
|
295
|
+
height: 100%;
|
|
296
|
+
z-index: 40;
|
|
297
|
+
background: var(--bg-primary, #ffffff);
|
|
298
|
+
color: var(--text-primary, inherit);
|
|
299
|
+
}
|
|
300
|
+
/* While the scene is still loading, the chrome is on screen, looks exactly as it will,
|
|
301
|
+
and is simply DISABLED — no pointer, no selection — because an option picked before
|
|
302
|
+
the seed has landed would race the boot. Every shell's top-level regions except the
|
|
303
|
+
one holding the canvas, plus the toolbars, sidebar and chat wherever they sit.
|
|
304
|
+
Released with the scene curtain (DefaultConfigurator clears the attribute). */
|
|
305
|
+
html[data-scene-booting] :is(.main-layout, .wizard-layout, .showroom-layout, .showcase-layout) > *:not(:has(.scene-canvas)),
|
|
306
|
+
html[data-scene-booting] .sidebar,
|
|
307
|
+
html[data-scene-booting] .sidebar-container,
|
|
308
|
+
html[data-scene-booting] .header__toolbar,
|
|
309
|
+
html[data-scene-booting] .mobile-toolbar,
|
|
310
|
+
html[data-scene-booting] .header__generate-btn,
|
|
311
|
+
html[data-scene-booting] .chat-bar {
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
user-select: none;
|
|
314
|
+
cursor: progress;
|
|
315
|
+
}
|
|
316
|
+
|
|
289
317
|
.loading-screen--translucent {
|
|
290
318
|
background: rgba(20, 20, 24, 0.28); /* fallback for no color-mix support */
|
|
291
319
|
background: color-mix(in srgb, var(--bg-primary) 35%, transparent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imagineio/configurator-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Configurator SDK — backend Configuration Engine client, state stores, shared 3D scene primitives, and pluggable placement (strategy + type). Drives every configurator (kitchen, sectional, …) from one self-contained surface.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|