@epigraph/configurator 2.2.1-alpha.1 → 2.2.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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4793,4 +4793,4 @@ ${zt.join(`
4793
4793
  There was a problem while trying to initialise the configurator.
4794
4794
  </div>
4795
4795
  </div>
4796
- `;const createCoreSceneStore=kt=>{const _e=coreStoreCreator();return _e.setState({stores:kt}),_e},coreStoreCreator=()=>create((kt,_e)=>({stores:null,shadowRefreshKey:0,CORE_API:null,coreReady:void 0,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,sceneHasDefaultConfigurationID:!1,configurationLoaded:!0,preconfigurationLoaded:!1,configurationLoadedOnRestart:!0,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:{center:new Vector3(0,0,0),size:new Vector3(0,0,0)},showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],currentAlertData:null,alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{usdzMaxTextureSize:1024,usdzPrecision:7,swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",arPlacement:"floor",arTransforms:{position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]},currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:10,g:10,b:10,a:.2},technicalRequirements:{minIosVersion:"11"},ghostScale:[1,1,1],ghostAsWireframe:!1,draggableUI:!1,addFromInfoModal:!1,clickToAddUi:!0,accordionInBuildUi:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:null,emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,comboPlugDistanceThreshold:.05,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",outlineSettings:{multisampling:10,visibleEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),hiddenEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),blur:3,width:1e3,edgeStrength:1e3,blendFunction:BlendFunction.ALPHA,pulseSpeed:0,xRay:!0},textSettings:{arButtonLabel:"AR",arHoverLabel:"View In Your Space",restartButtonLabel:"Restart",restartHoverLabel:"Restart",saveButtonLabel:"Save",saveHoverLabel:"Save",shareButtonLabel:"Share",shareHoverLabel:"Share",sizeButtonLabel:"Size",sizeHoverLabel:"Size",hotspotsButtonLabel:"Hotspots",hotspotsHoverLabel:"Hotspots",instructionsButtonLabel:"Instructions",instructionsHoverLabel:"Instructions",cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",featuresTabEmptyText:"*Please add an item to the scene to see the features",tooltipEmptySceneText:"",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:2999,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0,unvisualizedItemSpawn:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},actions:{refreshShadows:()=>{const{shadowRefreshKey:Dt}=_e();kt({shadowRefreshKey:Dt+1})},popFromAlertQueue:()=>{const{alertQueue:Dt}=_e();return Dt.shift(),kt({alertQueue:Dt}),Dt},addToAlertQueue:Dt=>{const{alertQueue:Vt,currentAlertData:Gt}=_e();return Vt.length>0&&Vt[Vt.length-1].alertId&&Dt.alertId===Vt[Vt.length-1].alertId||Vt.length==0&&Gt&&Gt.alertId&&Gt.alertId==Dt.alertId||(Vt.push(Dt),kt({alertQueue:Vt})),Vt},getDeviceState:()=>{const{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}=_e();return{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}},enableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!1,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!0,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:Dt}=_e();return Dt},sendAlert:Dt=>{kt({alertData:{...Dt}})},switchCursor(Dt){const{cursorParentRef:Vt}=_e();if(!Vt)return;let Gt="";switch(Dt){default:case CURSORS.GRAB:Gt="grabCursor";break;case CURSORS.GRABBING:Gt="grabbingCursor";break;case CURSORS.BLOCKED:Gt="blockedCursor";break;case CURSORS.POINTER:Gt="pointerCursor";break;case CURSORS.MOVE:Gt="moveCursor";break}for(let zt=0;zt<Vt.classList.length;zt++)Vt.classList[zt].includes("Cursor")&&Vt.classList.remove(Vt.classList[zt]);Vt.classList.add(Gt)},setAlertSettings:Dt=>{kt({alertSettings:Dt})},async completeDropItem(){const{draggingOnDropCollisionData:Dt,CORE_API:Vt,stores:Gt}=_e(),zt=Gt.attachmentStore.getState().attachmentSystem,{node:jt,attachedChildrenGuids:Ht,collidingStatus:Wt,intersectingGhostObject:qt,initPosition:Xt,initRotation:Kt,detachedPlugs:Yt,attachedNodesToCurrentNode:Zt}=Dt;Vt.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[Qt,en]of Ht.entries())Wt[Qt]===!0&&await Gt.itemStore.getState().actions.removeItemByGUID(en);const Jt=qt.userData;let nn=jt.getPlugByName(Jt.incomingPlugName),rn=zt.currentStructure.getPlugByGUID(Jt.receiverPlugGUID);jt.ref.position.set(qt.position.x,qt.position.y,qt.position.z),jt.ref.setRotationFromEuler(qt.rotation),jt.transform={position:qt.position,rotation:qt.quaternion},zt.currentStructure.connectPlugs({incomingPlug:nn,receiverPlug:rn}),Gt.ghostStore.getState().actions.clearAllGhosts(),Gt.itemStore.getState().actions.deselectItem(),Zt.map(Qt=>{jt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},jt.dragging=!1,Qt.dragging=!1}),await Gt.attachmentStore.getState().actions.updateFittingSkuIds()},async revertDropItem(){const{draggingOnDropCollisionData:Dt,stores:Vt}=_e(),Gt=Vt.attachmentStore.getState().attachmentSystem,{node:zt,attachedChildrenGuids:jt,collidingStatus:Ht,intersectingGhostObject:Wt,initPosition:qt,initRotation:Xt,detachedPlugs:Kt,attachedNodesToCurrentNode:Yt}=Dt;CORE_API.alert({alertMsg:"Position of item"+zt.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const Zt=Kt.neighbourDetachedPlugs;Zt&&(Kt.neighbourNode.detachNodeFromReceiver(),Gt.currentStructure.connectPlugs({incomingPlug:Zt.incomingPlug,receiverPlug:Zt.receiverPlug}));let Jt=Kt.rootDetachedPlugs.incomingPlug,nn=Kt.rootDetachedPlugs.receiverPlug;zt.ref.position.set(qt.x,qt.y,qt.z),zt.ref.setRotationFromEuler(Xt);let rn=new Quaternion().identity();zt.ref.getWorldQuaternion(rn),zt.transform={position:qt,rotation:rn},Gt.currentStructure.connectPlugs({incomingPlug:Jt,receiverPlug:nn}),Vt.ghostStore.getState().actions.clearAllGhosts(),Vt.itemStore.getState().actions.deselectItem(),Yt.map(Qt=>{zt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},zt.dragging=!1,Qt.dragging=!1}),await Vt.attachmentStore.getState().actions.updateFittingSkuIds()},setCoreSettings:Dt=>{const{sceneSettings:Vt,isMobile:Gt,isTouchDevice:zt,isLandscape:jt,actions:Ht}=_e(),Wt=Gt===!0?"mobile":"desktop",qt=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","clickToAddUi","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const Xt of qt)if(Xt==="draggableUI"||Xt==="clickToAddUi"||Xt==="emptySceneTextFontSize"||Xt==="showInstructionsOnStartup"||Xt==="showInstructionsBtn"||Xt==="instructionsSettings"){const Yt=`${Xt}_${jt===!1&&zt===!0?"mobile":"desktop"}`;Dt[Yt]!==void 0?Vt[Xt]=Dt[Yt]:Vt[Yt]!==void 0&&(Vt[Xt]=Vt[Yt])}else if(Xt==="textSettings"||Xt==="variantsTabOrder"||Xt==="alertControl"||Xt==="outlineSettings"){if(Dt.hasOwnProperty(Xt)){let Kt=Vt[Xt];Object.keys(Kt).map(Yt=>{let Zt=Dt[Xt];Zt.hasOwnProperty(Yt)?(Yt==="visibleEdgeColor"||Yt==="hiddenEdgeColor")&&(Zt[Yt]=new Color$1(Zt[Yt]).convertSRGBToLinear()):Zt[Yt]=Kt[Yt]})}}else{const Kt=`${Xt}_${Wt}`;if(Dt[Kt]!==void 0){let Yt=`${Xt}Btn`;Xt=="showContextMenu"&&(Yt=`${Xt}`),Vt[Yt]=Dt[Kt]}}Dt.disableCart===!0&&Ht.disableCart(),Object.keys(Dt).map(Xt=>Vt[Xt]=Dt[Xt]),Vt.emptySceneText===null&&(Vt.emptySceneTextFontSize=Gt?"1.2rem":"1.5rem",Vt.draggableUI===!0?Vt.emptySceneText="Drag an item here to get started":Vt.emptySceneText="Select an item to get started"),kt({sceneSettings:{...Vt,ghostThreeColor:{r:Vt.ghostColor.r/255,g:Vt.ghostColor.g/255,b:Vt.ghostColor.b/255,a:Vt.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:Vt.ghostColorOnHoverWithDraggableUi.r/255,g:Vt.ghostColorOnHoverWithDraggableUi.g/255,b:Vt.ghostColorOnHoverWithDraggableUi.b/255,a:Vt.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(Dt=null)=>kt(Vt=>({autoFocusRef:Dt,autoFocusTrigger:Vt.autoFocusTrigger+1})),requestNewScreenshot:async(Dt,Vt)=>{const{CORE_API:Gt}=_e();return new Promise(async(zt,jt)=>{LOGGER.info({title:"Taking a screenshot"});const{screenshotRenderer:Ht,sceneRef:Wt,screenshotCamera:qt,canvasSize:Xt}=_e(),Kt=await Gt.getCurrentCameraDetails();if(Ht.setClearColor(16777215),qt.copy(Kt),Dt!==null&&(qt.position.copy(Dt.position),qt.rotation.copy(new Euler(Dt.rotation.x,Dt.rotation.y,Dt.rotation.z))),Vt==null?Ht.setSize(Xt.width,Xt.height):Ht.setSize(Vt.width,Vt.height),Ht.render(Wt.parent,qt),Ht.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),jt({success:!1,imageData:null});else{LOGGER.info({title:"Downloading the screenshot"});const Yt=Ht.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");zt({success:!0,imageData:Yt})}})}}})),createProductDataStore=kt=>{const _e=productDataStoreCreator();return _e.setState({stores:kt}),_e},productDataStoreCreator=()=>create((kt,_e)=>({stores:null,productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentCompareAtPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].compareAtPrice)}),Vt[Gt]=jt}),Vt},getCurrentPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].price)}),Vt[Gt]=jt}),Vt},updateCompareAtPricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updateCompareAtPricingForProduct(Gt,jt,zt[jt])})})},updatePricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updatePricingForProduct(Gt,jt,zt[jt])})})},updateCompareAtPricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.compareAtPrice=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updateCompareAtPricing())},updatePricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.price=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updatePricing())},setProductData:Dt=>{const{stores:Vt}=_e();let Gt={};Dt&&Object.keys(Dt).map(zt=>{const jt=Dt[zt];if(jt.skuID=zt,jt.skuID.toLowerCase()==="root"){jt.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},jt.defaultVariant="default";return}if(jt?.lookDetails){const Ht=jt.lookDetails;let Wt=Object.keys(jt.lookDetails);if(Wt.includes("default")){const Xt=Wt.indexOf("default");Wt.splice(Xt,1)}jt.looks=Wt,Object.keys(jt.lookDetails).map(Xt=>{let Kt=jt.lookDetails[Xt];Kt.inventory===void 0&&(Kt.inventory=DEFAULT_INVENTORY),Kt.price===void 0&&(Kt.price=DEFAULT_PRODUCT_PRICE),Kt.compareAtPrice===void 0&&(Kt.compareAtPrice=DEFAULT_PRODUCT_COMPARE_AT_PRICE),Gt[zt]={...Gt[zt],[Xt]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let qt=jt?.defaultVariant;qt||(LOGGER.warn({title:`No defaultVariant set for ${jt.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),qt=Object.keys(jt.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+qt})),Wt.includes(qt)?(jt.lookDetails.default=Ht[qt],jt.lookDetails.default.id=qt):(LOGGER.error({title:`Default look [ ${qt} ] doesn't exist for: ${zt}. Please make sure to select a default variant in Input Data for this project`}),jt.lookDetails.default=null)}}),LOGGER.info({title:"PRODUCT DATA: ",details:Dt}),Vt.inventoryStore.setState({inventoryData:Gt}),kt({productData:Dt})},setCategoryData:Dt=>{const{productData:Vt}=_e();Dt.geometryVariants!==void 0&&Dt.geometryVariants.map(Gt=>{Gt.defaultVariant===void 0&&Object.keys(Gt.variants).length>0&&(Gt.defaultVariant=Object.keys(Gt.variants)[0])}),Dt.color!==void 0&&Dt.color.map(Gt=>{(Gt.defaultLook===void 0&&Gt.looks.length>0||!Gt.looks.includes(Gt.defaultLook))&&(Gt.defaultLook=Gt.looks[0])}),kt({categoryData:Dt}),Dt.build!==void 0&&Dt.build.map(Gt=>{Gt.skus.map(zt=>{Vt[zt].categoryID=Gt.categoryID,Vt[zt].categoryLabel=Gt.label,Vt[zt].swappable=Gt.swappable?Gt.swappable:!1,Vt[zt].replace=Gt.replace})})},getProductDataById:Dt=>{const{productData:Vt}=_e();let Gt=null;return Vt[Dt]&&(Gt=Vt[Dt]),Gt},setLookData:Dt=>kt({lookData:Dt}),setHotspotsData:Dt=>{const{categoryData:Vt,productData:Gt}=_e();Vt.geometryVariants&&Object.keys(Dt).map(zt=>{Dt[zt].map(jt=>{jt.geometryVariantID&&Vt.geometryVariants.map(Ht=>{Object.keys(Ht.variants).map(Wt=>{jt.geometryVariantID==Wt&&Ht.productsInCategory.map(qt=>{let Xt=null;qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)&&(Xt=Dt[Kt])}),qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)||(Dt[Kt]=Xt)})})})})})}),kt({hotspotsData:Dt})},setAssetsData:Dt=>kt({assetsData:Dt})}})),createItemStore=kt=>{const _e=itemStoreCreator();return _e.setState({stores:kt}),_e},itemStoreCreator=()=>create((kt,_e)=>({stores:null,variantChangeAlert:!1,focusedGUID:null,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],fittingSkuIds:[],filteredCollidersRef:[],selectedItemData:null,defaultSceneItemCount:0,busySpawningItem:!1,busyReplacingItem:!1,busySpawningDependency:!1,busyDraggingItem:!1,busyRemovingItem:!1,isBusy:()=>{const{busySpawningItem:Dt,busyReplacingItem:Vt,busySpawningDependency:Gt,busyDraggingItem:zt,busyRemovingItem:jt}=_e();return Dt||Vt||Gt||zt||jt},actions:{triggerModelLoaded:()=>{kt(Dt=>({modelLoadedAlert:Dt.modelLoadedAlert+1}))},triggerRemoveItem:()=>{kt(Dt=>({removeItemTrigger:!Dt.removeItemTrigger}))},addToRemoveItems:Dt=>{const{removeItems:Vt}=_e();Vt.push(Dt)},switchToVariant:async(Dt,Vt,Gt=!1)=>{const{variantChangeAlert:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().categoryData;let qt=jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt.guid);const Xt=jt.assetStore.getState().assets.items,Kt=qt.ref.getObjectByName("GRP_RenderGeometry");Xt[Dt.skuID].data||Ht.geometryVariants&&Ht.geometryVariants.map(Yt=>{Yt.productsInCategory.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{nn==Dt.skuID&&(Jt=!0)}),Jt&&Zt.products.map(nn=>{const rn=jt.assetStore.getState().assets.items[nn].data;rn&&(jt.assetStore.getState().assets.items[Dt.skuID].data=rn)})})}),qt.modelFunctions&&(await qt.modelFunctions.selectVariant(Kt,Vt),Gt?(qt.overrideVariant=Vt,jt.coreSceneStore.getState().CORE_API.fireEvent(jt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):qt.currentVariant=Vt,kt({variantChangeAlert:!zt}))},clearAllItems:()=>{kt({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:Dt=>{kt({itemsSpawned:Dt,itemsCount:Object.keys(Dt).length})},setHoveredItemRef:Dt=>kt({hoveredItemRef:Dt}),setCollidersRef:Dt=>{const{stores:Vt}=_e();kt({collidersRef:Dt});let Gt=[];for(let zt=0;zt<Dt.length;zt++)Dt[zt].current&&Gt.push(Dt[zt]);Vt.itemStore.setState({filteredCollidersRef:[...Gt]})},setSelectedItemData:Dt=>{const{selectedItemData:Vt,hoveredItemRef:Gt,actions:zt,stores:jt}=_e();Vt&&(delete Gt[Vt.itemData.guid],zt.setHoveredItemRef({...Gt})),kt({selectedItemData:{...Dt}}),jt.hotspotStore.getState().actions.switchHotspotsVisibility(!1,!0),jt.cameraStore.getState().actions.canCameraRotate(!1)},deselectItem:()=>{const{selectedItemData:Dt,stores:Vt}=_e();Dt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.UI.ContextMenu_Hide,Dt),kt(()=>({selectedItemData:null})),Vt.hotspotStore.getState().actions.switchHotspotsVisibility(!0,!0),Vt.cameraStore.getState().actions.canCameraRotate(!0),Vt.itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async Dt=>{const{itemsSpawned:Vt,actions:Gt,stores:zt}=_e();if(Vt.hasOwnProperty(Dt))return kt({busyRemovingItem:!0}),new Promise(async(jt,Ht)=>{const Wt=qt=>{Dt===qt.data.itemData.guid&&(kt({busyRemovingItem:!1}),jt(Dt))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Item_Removed,Wt,{once:!0}),Gt.addToRemoveItems(Dt),Gt.triggerRemoveItem()})},addItemBySkuID:async(Dt,Vt=0,Gt=!1,zt)=>{kt({busySpawningItem:!0});const{actions:jt,itemsSpawned:Ht,stores:Wt}=_e(),qt=Wt.productDataStore.getState().productData,Xt=Wt.productDataStore.getState().hotspotsData,Kt=Wt.attachmentStore.getState().attachmentSystem;let Yt=!0;const Zt=await new Promise(async(Jt,nn)=>{if(LOGGER.info({title:`Spawning item: ${Dt}`}),jt.deselectItem(),!qt[Dt]){LOGGER.warn({title:`Product not found: ${Dt}`}),Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:Dt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Yt=!1,nn(Dt+": product not found!");return}const rn=[...Wt.ghostStore.getState().ghostsTransform],Qt={...Wt.ghostStore.getState().ghostData};if(rn.length<=0){Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),Yt=!1,nn("No available connections for this product to attach to");return}const en=tn=>{Dt===tn.data&&Jt(Qt.newNodes[Vt].guid)};if(Wt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,en,{once:!0}),Qt.addItemOrSwap[Vt]=="replace")await replaceItem(kt,Wt,Ht,Qt.skuID,rn[Vt],Qt.newNodes[Vt]);else{Wt.ghostStore.getState().actions.clearAllGhosts();const tn=Qt.newNodes[Vt];tn.isDependent=Gt;let sn=!0;if(qt[Qt.skuID].hasOwnProperty("disableInteraction")){const fn=qt[Qt.skuID].disableInteraction;(fn==!0||fn==!1)&&(sn=!fn)}zt!=null&&(sn=zt),tn.isInteractive=sn;const{position:cn,rotation:un}=rn[Vt];tn.transform={position:cn,rotation:un},Kt.currentStructure.addNode(tn),Qt.connectablePlugs[Vt].receiverPlug.type=="unvisualizedPlug"&&Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"This product is not shown in your 3D configuration but can be found in your shopping list.",alertTime:3e3,alertType:"warn",alertLabel:"Internal Storage",persistant:!1,alertId:"unvisualizedItemSpawn"}),Qt.comboPlugs[Vt].length>0&&Qt.connectablePlugs[Vt].incomingPlug.type=="comboPlug"&&Qt.comboPlugs[Vt].map(fn=>{Kt.currentStructure.connectPlugs(fn)}),Qt.connectablePlugs[Vt].incomingPlug.comboPlugConnector=!0,Kt.currentStructure.connectPlugs(Qt.connectablePlugs[Vt]);const hn=await Wt.assetStore.getState().actions.loadProxyAsset(Qt.skuID,!0);LOGGER.info({title:"GHOST NEW NODE: ",details:tn}),Ht[tn.guid]={itemData:{proxyScene:hn.proxy.data.scene,guid:Qt.newNodes[Vt].guid,...qt[Qt.skuID],position:cn,rotation:un,hasItemLoaded:!1,isDependent:Gt,isInteractive:sn},hotspotsData:Xt[Qt.skuID],hotspotSpawned:!1},await wait(1),jt.setItemsSpawned({...Ht})}}).catch(Jt=>{LOGGER.error({title:Jt}),Yt=!1});if(Yt===!1)return kt({busySpawningItem:!1}),Zt;if(Wt.coreSceneStore.getState().preconfigurationLoaded&&Wt.coreSceneStore.getState().configurationLoaded){const Jt=await Kt.getCartItemsAsync();Jt&&Wt.coreSceneStore.getState().CORE_API.fireEvent(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Jt)}if(await jt.resolvePlugDependencyOnGUID(Zt),kt({busySpawningItem:!1}),!Gt){const Jt=Kt.currentStructure,nn=Jt.getNodeByGUID(Zt);Wt.dynamicHookStore.getState().hookOnSceneItemAdded(nn,Jt.nodes,Wt.coreSceneStore.getState().CORE_API),await Wt.attachmentStore.getState().actions.updateFittingSkuIds()}return Zt},async addItemWithTransform(Dt,Vt,Gt,zt=!0){const{actions:jt,itemsSpawned:Ht,defaultSceneItemCount:Wt,stores:qt}=_e(),Xt=qt.productDataStore.getState().productData,Kt=qt.productDataStore.getState().hotspotsData;return await new Promise(async(Zt,Jt)=>{if(jt.deselectItem(),!Xt[Vt]){qt.coreSceneStore.getState().CORE_API.alert({alertMsg:Vt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Jt(Vt+": product not found!");return}const{position:nn,rotation:rn}=Dt;Ht[Gt]!=null&&(qt.hotspotStore.getState().actions.removeHotspotForItem({...Ht[Gt]}),delete Ht[Gt]);const Qt=tn=>{Vt.toLowerCase()==tn.data.toLowerCase()&&Zt(Gt)};qt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(qt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Qt,{once:!0});const en=await qt.assetStore.getState().actions.loadProxyAsset(Vt,!0);if(en==null){Jt(Vt+": Asset not found!");return}await wait(1),Vt.toLowerCase()==="root"&&kt({defaultSceneItemCount:Wt+1}),Ht[Gt]={itemData:{proxyScene:en.proxy.data.scene,guid:Gt,...Xt[Vt],position:nn,rotation:rn,hasItemLoaded:!1,isInteractive:zt},hotspotsData:Kt[Vt],hotspotSpawned:!1},kt({itemsSpawned:{...Ht}})}).catch(Zt=>{LOGGER.info({title:Zt})})},async resolvePlugDependencyOnGUID(Dt){const{actions:Vt,itemsSpawned:Gt,defaultSceneItemCount:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().productData,Wt=jt.attachmentStore.getState().attachmentSystem,qt=Gt[Dt].itemData.skuID,Xt=Ht[qt]?.plugs;if(!Xt)return;let Kt=!1;for(const Yt of Xt)Yt?.dependencySku&&(Kt=!0);Kt&&(kt({busySpawningDependency:!0}),await new Promise(async(Yt,Zt)=>{const Jt=[];for(const nn of Xt){const rn=nn?.dependencySku;if(!rn)continue;const Qt=async()=>{LOGGER.info({title:`Found a dependency: ${rn} on the plug: ${nn.name}`});let en=!0;Ht[rn]&&Ht[rn].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(en=Ht[rn].ignoreSpawningCollisionAsDependency),nn.hasOwnProperty("ignoreSpawningCollision")&&(en=nn.ignoreSpawningCollision);let tn=jt.coreSceneStore.getState().sceneSettings.ignoreSpawningCollision;Ht[rn].hasOwnProperty("ignoreSpawningCollision")&&(tn=Ht[rn].ignoreSpawningCollision),Ht[rn].ignoreSpawningCollision=en,jt.ghostStore.setState({ghostVisibility:!1});const sn=await jt.ghostStore.getState().actions.spawnGhostsForSkuID(rn,en);if(Ht[rn].ignoreSpawningCollision=tn,!sn)return;const cn=Wt.currentStructure.getNodeByGUID(Dt),un=cn.getPlugByName(nn.name)?.guid,hn=nn?.isDependencySkuInteractive?nn.isDependencySkuInteractive===1:!1,fn=sn.connectablePlugs;let pn=-1;for(const mn of fn)mn.receiverPlug.guid===un&&(pn=fn.indexOf(mn));if(pn==-1){jt.ghostStore.getState().actions.clearAllGhosts();return}const dn=await Vt.addItemBySkuID(rn,pn,!0,hn);qt.toLowerCase()==="root"&&Ht[rn].ignoreInCart&&kt({defaultSceneItemCount:zt+1}),dn!==null&&cn.addMyDependenciesGUID(dn)};Jt.push(await Qt())}await Promise.all(Jt),Yt(!0)}),kt({busySpawningDependency:!1}))},async replaceGuidItemBySkuId(Dt,Vt){const{itemsSpawned:Gt,stores:zt}=_e();if(Gt[Dt]==null)return!1;const jt=zt.attachmentStore.getState().attachmentSystem.currentStructure,Ht=jt.getNodeByGUID(Dt);if(!Ht||!Ht.isReplaceableWithSkuId(Vt))return!1;LOGGER.info({title:"Replacing Item"});const qt=zt.productDataStore.getState().productData,Xt=zt.productDataStore.getState().hotspotsData;kt({busyReplacingItem:!0}),await new Promise(async(Kt,Yt)=>{const Zt=async()=>{LOGGER.info({title:"Removed old item with guid: "+Dt});const Jt=async Qt=>{Vt===Qt.data&&(jt.recalculateStructureFromNode(Ht.whichNodeAreWeAttachedTo()),await zt.attachmentStore.getState().actions.toggleStructureUpdated(),kt({busyReplacingItem:!1}),Kt(Ht.guid))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Jt,{once:!0});const nn=await zt.assetStore.getState().actions.loadProxyAsset(Vt,!0),rn={receiverPlug:Ht.whichPlugAreWeAttachedTo(),incomingPlug:Ht.whichPlugAreWeAttachedUsing()};jt.findItemTransform(rn),Gt[Dt]={itemData:{proxyScene:nn.proxy.data.scene,guid:Dt,...qt[Vt],position:Ht.transform.position,rotation:Ht.transform.rotation,hasItemLoaded:!1},hotspotsData:Xt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:Ht.currentVariant}),zt.itemStore.setState({itemsSpawned:{...Gt}})};zt.hotspotStore.getState().actions.removeHotspotForItem({...Gt[Dt]}),delete Gt[Dt],Ht.update(Vt),zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}}}));async function replaceItem(kt,_e,Dt,Vt,Gt,zt){LOGGER.info({title:"Replacing Item"});const{position:jt,rotation:Ht}=Gt,Wt=_e.productDataStore.getState().productData,qt=_e.productDataStore.getState().hotspotsData,Xt=_e.attachmentStore.getState().attachmentSystem.currentStructure;return kt({busyReplacingItem:!0}),new Promise(async(Kt,Yt)=>{const Zt=async()=>{const Jt=await _e.assetStore.getState().actions.loadProxyAsset(Vt,!0),nn=async rn=>{Vt===rn.data&&(Xt.recalculateStructureFromNode(zt),await _e.attachmentStore.getState().actions.toggleStructureUpdated(),_e.ghostStore.getState().actions.clearAllGhosts(),kt({busyReplacingItem:!1}),Kt(zt.guid))};_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,nn,{once:!0}),Dt[zt.guid]={itemData:{proxyScene:Jt.proxy.data.scene,guid:zt.guid,...Wt[Vt],position:jt,rotation:Ht,hasItemLoaded:!1},hotspotsData:qt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:zt.currentVariant}),zt.currentVariant=zt.currentVariant,zt.transform=Gt,_e.itemStore.setState({itemsSpawned:{...Dt}})};_e.hotspotStore.getState().actions.removeHotspotForItem({...Dt[zt.guid]}),delete Dt[zt.guid],zt.update(Vt),_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}const createInventoryStore=kt=>{const _e=inventoryStoreCreator();return _e.setState({stores:kt}),_e},inventoryStoreCreator=()=>create((kt,_e)=>({stores:null,inventoryData:{},actions:{updateInventoryForAllProducts:Dt=>{const{actions:Vt,stores:Gt}=_e();Object.keys(Dt).map(zt=>{let jt=Dt[zt];Object.keys(jt).map(Ht=>{Vt.updateInventoryForProduct(zt,Ht,jt[Ht].inventory)})}),Vt.refreshInventory(Gt.itemStore.getState().itemsSpawned)},updateInventoryForProduct:(Dt,Vt,Gt)=>{const{inventoryData:zt}=_e();let jt=zt[Dt],Ht=jt[Vt];!jt||!Ht||(Ht.inventory=Gt)},_clearInScene:()=>{const{inventoryData:Dt}=_e();Object.keys(Dt).map(Vt=>{const Gt=Dt[Vt];Object.keys(Gt).map(zt=>{Gt[zt].inScene=[]})})},refreshInventory:Dt=>{if(!Dt)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:Vt,inventoryData:Gt,stores:zt}=_e();Vt._clearInScene();const jt=zt.attachmentStore.getState().attachmentSystem;if(jt===null)return;const Ht=jt.currentStructure;if(Ht===null)return;Object.keys(Dt).map(Kt=>{const Yt=Ht.getNodeByGUID(Kt);if(!Yt)return;const Zt=Yt.overrideVariant?Yt.overrideVariant:Yt.currentVariant;if(!Zt)return;const Jt=Gt[Yt.skuID];if(!Jt||!Jt[Zt].inScene)return;Jt[Zt].inScene.push(Kt),zt.coreSceneStore.getState().sceneSettings.disableCart===!0?Yt.inStock={variantName:Zt,newValue:!0}:Jt[Zt].inScene.length>Jt[Zt].inventory?Yt.inStock={variantName:Zt,newValue:!1}:Yt.inStock={variantName:Zt,newValue:!0}});let Wt=!1;Object.keys(Gt).map(Kt=>{const Yt=Gt[Kt];Object.keys(Yt).map(Zt=>{Yt[Zt].countAvailable=Yt[Zt].inventory-Yt[Zt].inScene.length,Yt[Zt].countAvailable<0?(Yt[Zt].countUnavailable=Yt[Zt].countAvailable*-1,Yt[Zt].countAvailable=0,Wt=!0):Yt[Zt].countUnavailable=0})});const qt={alertMsg:"Some item(s) in configuration are out of stock",alertTime:7e3,alertType:"warn",alertLabel:"Stock Alert",persistant:!0,alertId:"outOfStock"},Xt=compareObjects(zt.coreSceneStore.getState().persistantAlertData,qt);Wt===!1&&Xt===!0&&zt.coreSceneStore.getState().CORE_API.removePersistantAlert(),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Inventory_Updated,Gt)}}})),createAssetStore=kt=>{const _e=assetStoreCreator();return _e.setState({stores:kt}),_e},assetStoreCreator=()=>create((kt,_e)=>({stores:null,assets:{items:{}},gltfLoader:null,dracoLoader:null,actions:{init(){const Dt=new DRACOLoader;Dt.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`),Dt.setDecoderConfig({type:"js"});const Vt=new GLTFLoader;Vt.register(Gt=>new GLTFMaterialsVariantsExtension(Gt)),Vt.setDRACOLoader(Dt),kt({dracoLoader:Dt,gltfLoader:Vt})},async loadProxyAsset(Dt){const{assets:Vt,gltfLoader:Gt,stores:zt}=_e(),jt="proxy",Ht=Vt.items[Dt]=Vt.items[Dt]||{isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}},Wt=Ht.proxy;if(Wt.isLoaded)return Ht;if(Wt.errorLoading)throw new Error(`${jt} loading failed for: ${Dt}`);const qt=zt.productDataStore.getState().productData[Dt];if(!qt)throw new Error(`Data doesn't exist for ${Dt}`);const Xt=zt.coreSceneStore.getState().CORE_API.getResolvedAssetUrl(qt.colliderProxyGLTF);if(!Xt)return null;try{const Kt=await Gt.loadAsync(Xt,Yt=>{Wt.progress=Yt.loaded/Yt.total*100});return Wt.data=Kt,Wt.isLoaded=!0,Ht}catch(Kt){throw Wt.isLoaded=!1,Wt.errorLoading=!0,Wt.error=Kt,LOGGER.info({title:Xt}),new Error(`Couldn't load ${Dt}`)}},isProxyLoaded(Dt){const Vt=_e().assets.items[Dt];return Vt?Vt.proxy.isLoaded:!1}}}));class Structure{#t=!1;constructor(_e,Dt=null,Vt,Gt){if(this.stores=_e,this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:Dt}),this.setupHookOnSceneItemsUpdated(),Dt){LOGGER.info({title:"PRELOAD Length-----------------:"+Dt.length});for(let zt=0;zt<Dt.length;zt++){LOGGER.info({title:"FOUND PRELOAD-----------------"});const jt=Dt[zt].skuID;if(jt.toLowerCase()=="root"){const Wt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Wt).length>0&&(Dt[zt].guid=Object.keys(Wt)[0])}let Ht=new Node$1(_e,jt,Dt[zt],Vt,Gt);jt.toLowerCase()=="root"&&(this._rootNode=Ht),this._nodes.push(Ht)}}else{const zt=new Node$1(_e,"Root",null,Vt,Gt);this._rootNode=zt,this._nodes.push(zt),this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1)}this._boundingBoxLeeway=this.stores.coreSceneStore.getState().sceneSettings.boundingBoxLeeway}async setupHookOnSceneItemsUpdated(){const _e=this.stores.coreSceneStore.getState().CORE_API;this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.stores.dynamicHookStore.getState().hookOnSceneItemsUpdated(this._nodes,_e)})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let _e=0;_e<this._nodes.length;_e++)this._nodes[_e].updatePricing()}getCurrentItemsInReplaceableCategory(){let _e={};for(const Dt of this._nodes)Dt.replace&&(_e[Dt.categoryID]=Dt.skuID);return _e}recalculateStructureFromNode(_e){for(let Dt=0;Dt<_e.plugs.length;Dt++)if(!_e.plugs[Dt].isOpen&&_e.plugs[Dt].isReceiverPlug){const Vt=_e.plugs[Dt].attachedPlug.node,Gt={receiverPlug:_e.plugs[Dt],incomingPlug:_e.plugs[Dt].attachedPlug};if(Gt){const zt=this.findItemTransform(Gt);zt&&(Vt.ref.position.set(zt.position.x,zt.position.y,zt.position.z),zt.rotation.isQuaternion===!0?Vt.ref.setRotationFromQuaternion(zt.rotation):zt.rotation.isEuler===!0&&Vt.ref.setRotationFromEuler(zt.rotation),Vt.transform={position:zt.position,rotation:zt.rotation})}this.recalculateStructureFromNode(Vt)}}rotateNode(_e){const Dt=this.getNodeByGUID(_e);let Vt=null,Gt=null;for(let Ht=0;Ht<Dt.plugs.length;Ht++)if(!Gt&&!Dt.plugs[Ht].isOpen&&Dt.plugs[Ht].attachedPlug.isReceiverPlug){const Wt=Dt.plugs[Ht].attachedPlug.acceptedPlugTypes;Gt=Dt.plugs[Ht].attachedPlug;let qt=[];for(let Xt=Ht+1;Xt<Dt.plugs.length;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<Ht;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<qt.length;Xt++)for(let Kt=0;Kt<qt[Xt].connectsToPlugTypes.length;Kt++)Wt.includes(qt[Xt].connectsToPlugTypes[Kt])&&(Vt=qt[Xt])}if(!Vt)return;Dt.detachNodeFromReceiver();const{position:zt,rotation:jt}=this.findItemTransform({receiverPlug:Gt,incomingPlug:Vt});Dt.ref.position.set(zt.x,zt.y,zt.z),jt.isQuaternion===!0?Dt.ref.setRotationFromQuaternion(jt):jt.isEuler===!0&&Dt.ref.setRotationFromEuler(jt),Dt.transform={position:Dt.ref.position,rotation:jt},this.connectPlugs({receiverPlug:Gt,incomingPlug:Vt}),this.recalculateStructureFromNode(Dt)}async load(_e){this.resolvePlugConnections(_e),await this.respawnItems()}materialOverrideExists(){let _e=!1;return this.nodes.map(Dt=>{if(Dt.overrideVariant)return _e=!0,!0}),_e}async findGhostTransformForReplacement(_e,Dt){let Vt=[],Gt=[],zt=[];for(const Ht of Dt){if(Ht.skuID==_e)continue;const Wt=this.stores.attachmentStore.getState().attachmentSystem,qt=Ht.whichPlugAreWeAttachedTo(),Xt=Ht.whichPlugAreWeAttachedUsing(),Yt=new Node$1(this.stores,_e,null,Wt.globalVariants,Wt.globalGeometryVariants).getPlugByName(Xt.name);if(!Yt)continue;const Zt={incomingPlug:Yt,receiverPlug:qt},{position:Jt,rotation:nn}=this.findItemTransform(Zt);Jt&&nn&&(Gt.push({position:Jt,rotation:nn,incomingPlugName:Zt.incomingPlug.name,receiverPlugName:Zt.receiverPlug.name,incomingPlugGUID:Zt.incomingPlug.guid,receiverPlugGUID:Zt.receiverPlug.guid}),zt.push(Zt),Vt.push(Ht))}let jt={transforms:Gt,connectablePlugs:zt,newNodes:Vt};return jt=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollectedForReplacement(jt,this.stores.coreSceneStore.getState().CORE_API),jt}async findGhostTransforms(_e,Dt){const Vt=this.getOpenPlugs(),Gt=this.stores.coreSceneStore.getState().sceneSettings.comboPlugDistanceThreshold;if(Vt.length<=0)return{transforms:[]};const zt=this.stores.attachmentStore.getState().attachmentSystem,jt=this.stores.productDataStore.getState().productData,Ht=new Node$1(this.stores,_e,null,zt.globalVariants,zt.globalGeometryVariants),Wt=this.getConnectablePlugs(Ht,Vt);let qt=[];if(Wt.length<=0)return{transforms:[]};let Xt=[],Kt=[];const Yt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene;if(!Yt)return!1;let Zt=Yt.clone();for(let rn=0;rn<Wt.length;rn++){let Qt=Dt,{incomingPlug:en,receiverPlug:tn}=Wt[rn],sn=this.findItemTransform(Wt[rn]);if(!sn)continue;let{position:cn,rotation:un}=sn;if(!cn||!un)continue;Zt.position.set(cn.x,cn.y,cn.z),un.isQuaternion===!0?Zt.setRotationFromQuaternion(un):un.isEuler===!0&&Zt.setRotationFromEuler(un);let hn=[],fn=[];if(en.type=="comboPlug"){if(en.connectsToPlugTypes.length<=0)continue;const vn=en.connectsToPlugTypes[0];let _n=!1;if(Kt.map(Cn=>{_n===!0||Cn.length<=0||Cn.map(yn=>{_n===!0||yn.incomingPlug.guid!==en.guid||yn.incomingPlug.connectsToPlugTypes.includes(vn)&&(_n=!0)})}),_n===!0)continue;const An=en.node.plugs;let Tn=!0;if(An.map(Cn=>{if(Cn.type!=="comboPlug"||Cn.guid===en.guid||!Cn.connectsToPlugTypes.includes(vn))return;let yn=!1;if(Vt.map(Sn=>{if(tn.guid===Sn.guid||!Sn.acceptedPlugTypes.includes(vn)||!Sn.node.ref)return;let wn=new Vector3(0,0,0);const xn=Sn.node.ref.getObjectByName(""+Sn.name);if(!xn)return;xn.getWorldPosition(wn);let Rn=new Vector3(0,0,0);const Dn=Zt.getObjectByName(""+Cn.name);if(!Dn)return;Dn.getWorldPosition(Rn);const kn=wn.distanceTo(Rn);Math.abs(kn)<Gt&&(hn.push(tn.node.guid),hn.push(Sn.node.guid),fn.push({receiverPlug:Sn,incomingPlug:Cn}),yn=!0)}),yn==!1){Tn=!1;return}}),!Tn)continue}let pn=Qt;Array.isArray(Qt)===!0&&(pn=!1),hn.length>0&&(pn=!1,Array.isArray(Qt)===!0?hn.map(vn=>{Qt.push(vn)}):Qt=hn),jt[_e].hasOwnProperty("ignoreSpawningCollision")&&(pn=jt[_e].ignoreSpawningCollision),Wt[rn].receiverPlug.type=="unvisualizedPlug"&&(pn=!0),(pn?!1:this.isColliding(Ht.skuID,sn,Wt[rn].receiverPlug,Qt))||(Xt.push({position:cn,rotation:un,incomingPlugName:Wt[rn].incomingPlug.name,receiverPlugName:Wt[rn].receiverPlug.name,incomingPlugGUID:Wt[rn].incomingPlug.guid,receiverPlugGUID:Wt[rn].receiverPlug.guid}),qt.push(Wt[rn]),Kt.push(fn))}let Jt=[];for(let rn=0;rn<Xt.length;rn++)Jt.push(Ht);dispose3(Zt);let nn={transforms:Xt,newNodes:Jt,connectablePlugs:qt,comboPlugs:Kt};return nn=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollected(nn,this.stores.coreSceneStore.getState().CORE_API),nn}resolvePlugConnections(_e){for(let Dt=0;Dt<_e.length;Dt++)Object.keys(_e[Dt].plugs).map(Vt=>{let Gt=_e[Dt].plugs[Vt].guid,zt=this.getPlugInNodesByGUID(Gt);if(!zt||zt.attachedPlug)return;let jt=_e[Dt].plugs[Vt].attachedPlugGUID,Ht=this.getPlugInNodesByGUID(jt);Ht&&(Ht.attachedPlug||(zt.attachPlug(Ht,_e[Dt].plugs[Vt].isReceiverPlug),Ht.attachPlug(zt,!_e[Dt].plugs[Vt].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let _e=[this.rootNode];for(let zt=0;zt<_e.length;zt++){let Ht=_e[zt].whichPlugsAreAttachedToUs();for(let Wt=0;Wt<Ht.length;Wt++){if(Ht[Wt].incomingPlug.type=="comboPlug"&&Ht[Wt].incomingPlug.connectsToPlugTypes.length>0&&!Ht[Wt].incomingPlug.comboPlugConnector)continue;let qt=this.findItemTransformForPreload(Ht[Wt],Ht[Wt].receiverPlug.node.transform);qt?await this.stores.itemStore.getState().actions.addItemWithTransform(qt,Ht[Wt].incomingPlug.node.skuID,Ht[Wt].incomingPlug.node.guid):LOGGER.warn({title:"Problem finding plug transform! "+Ht[Wt].name}),Ht[Wt].incomingPlug.node.transform=qt,_e.push(Ht[Wt].incomingPlug.node)}}const Dt=await this.stores.coreSceneStore.getState().CORE_API.getCartItemsAsync();this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded,{...Dt}),this.stores.coreSceneStore.getState().actions.triggerAutoFocus(),this.stores.hotspotStore.getState().actions.checkHotspotHealth();const Vt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,Gt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Vt||Gt){let zt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);zt.parameters={project_id:`${this.stores.coreSceneStore.getState().CORE_API.projectId}`,...Dt},this.stores.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(zt)}}getPlugInNodesByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].getPlugByGUID(_e);if(Vt)return Vt}return null}export(){let _e=[];for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].export();Vt&&_e.push(Vt)}return _e}async clear(){return new Promise(async(_e,Dt)=>{!this._rootNode&&this._rootNode.isEndNode&&_e(!0);let Vt=null;const Gt=this._rootNode.whichNodesAreAttachedToUs();Gt.length>0&&(Vt=Gt[0]),this.#t=!0,this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,zt=>_e(zt.data),{once:!0}),Vt?this.stores.coreSceneStore.getState().CORE_API.removeItemByGUID(Vt.guid,!0):(await wait(500),_e(!0))})}getNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e)return this._nodes[Dt];return null}getPlugByGUID(_e){for(const Dt of this._nodes){const Vt=Dt.getPlugByGUID(_e);if(Vt)return Vt}return null}findItemTransformForPreload(_e,Dt){let{receiverPlug:Vt,incomingPlug:Gt}=_e,zt=Vt,jt=Gt;if(zt.node.skuID=="Root")return this.findItemTransformRoot(_e);let Ht=null,Wt=null,qt=new Object3D,Xt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();qt.add(Xt);let{position:Kt,rotation:Yt}=Dt;if(Xt.position.set(Kt.x,Kt.y,Kt.z),Yt.isQuaternion===!0?Xt.setRotationFromQuaternion(Yt):Yt.isEuler===!0&&Xt.setRotationFromEuler(Yt),Wt=Xt,!Wt||(Ht=Wt.getObjectByName(zt.name),!Ht))return;let Zt=new Vector3(0,0,0);Ht.getWorldPosition(Zt);let Jt=new Quaternion().identity();Ht.getWorldQuaternion(Jt);let nn=new Object3D;Ht.add(nn);let rn=this.stores.assetStore.getState().assets.items[jt.node.skuID].proxy.data.scene.clone();rn.position.set(Zt.x,Zt.y,Zt.z),rn.applyQuaternion(Jt);let Qt=new Vector3;Qt.copy(Xt.up).applyQuaternion(Wt.quaternion);let en=new Vector3;en.copy(rn.up).applyQuaternion(Jt),en.negate();let tn=new Quaternion().setFromUnitVectors(Qt,en);Qt.round(),en.round();let sn=Qt.dot(en);sn!==1&&sn!==-1&&rn.applyQuaternion(tn);let cn=rn.getObjectByName(jt.name),un=new Quaternion().identity();cn.getWorldQuaternion(un);let hn=new Vector3(0,1,0);hn.applyQuaternion(un);let fn=new Vector3(0,1,0);fn.applyQuaternion(Jt),fn.negate();let pn=new Quaternion().setFromUnitVectors(hn,fn);if(hn.round(),fn.round(),hn.dot(fn)!==-1)rn.applyQuaternion(pn);else{let An=new Vector3(0,1,0),Tn=fn.dot(An);if(Tn!==1&&Tn!==-1)rn.rotateOnAxis(An,Math.PI);else{let Cn=new Vector3(0,0,1),yn=fn.dot(Cn);if(yn!==1&&yn!==-1)rn.rotateOnAxis(Cn,Math.PI);else{let Sn=new Vector3(1,0,0),wn=fn.dot(Sn);wn!==1&&wn!==-1&&rn.rotateOnAxis(Sn,Math.PI)}}}let mn=rn.getObjectByName(jt.name),vn=new Vector3(mn.position.x,mn.position.y,mn.position.z);rn.translateX(-vn.x),rn.translateY(-vn.y),rn.translateZ(-vn.z);let _n=new Vector3(0,0,0);rn.getWorldPosition(_n);let En=new Quaternion().identity();return rn.getWorldQuaternion(En),rn=null,{position:_n,rotation:En}}findItemTransformRoot(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Vt;const zt=new Object3D;let jt=zt,Ht=new Vector3(0,0,0);jt.getWorldPosition(Ht);let Wt=new Quaternion().identity(),qt=new Object3D;qt.position.set(0,0,0),zt.add(qt);let Xt=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone();qt.attach(Xt),Xt.translateX(Ht.x),Xt.translateY(Ht.y),Xt.translateZ(Ht.z);let Kt=Xt.getObjectByName(Gt.name),Yt=new Quaternion().identity();Kt&&Kt.getWorldQuaternion(Yt);const Zt=new Vector3(0,1,0);Zt.applyQuaternion(Yt);const Jt=new Vector3(0,1,0);Jt.applyQuaternion(Wt);const nn=Jt.angleTo(Zt),rn=new Vector3(0,0,0);rn.crossVectors(Jt,Zt),rn.round(),rn.length()!==0&&Xt.rotateOnAxis(rn,nn);let Qt=new Matrix4().extractRotation(Xt.matrixWorld),en=new Vector3(0,0,0);Kt&&en.set(Kt.position.x,Kt.position.y,Kt.position.z),en.applyMatrix4(Qt),Xt.translateX(-en.x),Xt.translateY(-en.y),Xt.translateZ(-en.z);let tn=new Vector3(0,0,0);Xt.getWorldPosition(tn);let sn=new Quaternion().identity();return Xt.getWorldQuaternion(sn),qt.remove(Xt),qt=null,Xt=null,{position:tn,rotation:sn}}findItemTransform(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Dt,zt=Vt;if(Gt.node.isRoot)return this.findItemTransformRoot(_e);const jt=Gt.node.transform;if(!jt)return;const Ht=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone(),Wt=new Object3D;Wt.position.set(jt.position.x,jt.position.y,jt.position.z),jt.rotation.isQuaternion===!0?Wt.setRotationFromQuaternion(jt.rotation):jt.rotation.isEuler===!0&&Wt.setRotationFromEuler(jt.rotation),Wt.add(Ht);let qt=Wt.getObjectByName(""+Gt.name);if(!qt){LOGGER.error({title:"Plug: "+Gt.name+" doesn't exist in "+Gt.node.skuID});return}let Xt=new Vector3(0,1,0);qt.getWorldPosition(Xt);let Kt=new Quaternion().identity();qt.getWorldQuaternion(Kt);let Yt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();Yt.position.set(Xt.x,Xt.y,Xt.z),Yt.applyQuaternion(Kt);let Zt=new Vector3;Zt.copy(Ht.up).applyQuaternion(Wt.quaternion);let Jt=new Vector3;Jt.copy(Yt.up).applyQuaternion(Kt),Jt.negate();let nn=new Quaternion().setFromUnitVectors(Zt,Jt);Zt.round(),Jt.round();let rn=Zt.dot(Jt);rn!==1&&rn!==-1&&Yt.applyQuaternion(nn);let Qt=Yt.getObjectByName(zt.name);if(!Qt){LOGGER.error({title:"Plug: "+zt.name+" doesn't exist in "+zt.node.skuID});return}let en=new Quaternion().identity();Qt.getWorldQuaternion(en);let tn=new Vector3(0,1,0);tn.applyQuaternion(en);let sn=new Vector3(0,1,0);sn.applyQuaternion(Kt),sn.negate();let cn=new Quaternion().setFromUnitVectors(tn,sn);if(tn.round(),sn.round(),tn.dot(sn)!==-1)Yt.applyQuaternion(cn);else{let mn=new Vector3(0,1,0),vn=sn.dot(mn);if(vn!==1&&vn!==-1)Yt.rotateOnAxis(mn,Math.PI);else{let _n=new Vector3(0,0,1),En=sn.dot(_n);if(En!==1&&En!==-1)Yt.rotateOnAxis(_n,Math.PI);else{let An=new Vector3(1,0,0),Tn=sn.dot(An);Tn!==1&&Tn!==-1&&Yt.rotateOnAxis(An,Math.PI)}}}let hn=Yt.getObjectByName(zt.name),fn=new Vector3(hn.position.x,hn.position.y,hn.position.z);Yt.translateX(-fn.x),Yt.translateY(-fn.y),Yt.translateZ(-fn.z);let pn=new Vector3(0,0,0);Yt.getWorldPosition(pn);let dn=new Quaternion().identity();return Yt.getWorldQuaternion(dn),Wt.remove(Ht),Yt=null,{position:pn,rotation:dn}}getSpawningRequirementForSkuID(_e){let Dt=[];const Vt=this.stores.productDataStore.getState().productData,Gt=Vt[_e];if(!Gt)return Dt;const zt=[];return Gt.plugs.map(jt=>{jt.connectsToPlugTypes.map(Ht=>{zt.push(Ht)})}),Object.keys(Vt).map(jt=>{for(let Ht=0;Ht<Vt[jt].plugs.length;Ht++){const Wt=Vt[jt].plugs[Ht].acceptedPlugTypes;for(let qt=0;qt<Wt.length;qt++)zt.map(Xt=>{Xt==Wt[qt]&&!Dt.includes(jt)&&Dt.push(jt)})}}),Dt}getConnectablePlugs(_e,Dt){let Vt=[],Gt=_e.getOpenPlugsWeCanAttachFrom();for(let zt=0;zt<Gt.length;zt++)for(let jt=0;jt<Dt.length;jt++){let Ht=!1;for(let qt=0;qt<Vt.length;qt++)if(Vt[qt].receiverPlug.guid==Dt[jt].guid&&Vt[qt].incomingPlug.type!="comboPlug"){Ht=!0;break}if(Ht)continue;Gt[zt].canAttachToPlug(Dt[jt])&&Vt.push({incomingPlug:Gt[zt],receiverPlug:Dt[jt]})}return Vt}getOpenPlugs(){let _e=[];return this._nodes.map(Dt=>{if(Dt.dragging===!0)return;let Vt=Dt.getOpenPlugsFromNode();_e=_e.concat(Vt)}),_e}checkCollisionForGUID(_e,Dt=[]){if(this.stores.coreSceneStore.getState().sceneSettings.disableCollider)return!1;const Vt=this.stores.itemStore.getState().itemsSpawned,Gt=this.stores.productDataStore.getState().productData;if(!Vt[_e])return!1;const jt=this.getNodeByGUID(_e);if(!jt||!jt.ref||Gt[jt.skuID].disableCollider)return!1;let Ht=new Vector3;jt.ref.getWorldPosition(Ht);let Wt=new Quaternion;jt.ref.getWorldQuaternion(Wt);const qt={position:Ht,rotation:Wt},Xt=jt.whichPlugAreWeAttachedTo();return Xt==null?!1:this.isColliding(jt.skuID,qt,Xt,Dt)}isColliding(_e,{position:Dt,rotation:Vt},Gt,zt=[]){const jt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene,Ht=this.stores.productDataStore.getState().productData;if(!jt)return!1;let Wt=jt.clone();Wt.position.set(Dt.x,Dt.y,Dt.z),Vt.isQuaternion===!0?Wt.setRotationFromQuaternion(Vt):Vt.isEuler===!0&&Wt.setRotationFromEuler(Vt);let qt=new Box3().setFromObject(Wt),Xt=new Vector3;qt.getCenter(Xt);let Kt=new Object3D;Kt.position.set(Xt.x,Xt.y,Xt.z),Kt.attach(Wt),Kt.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),qt=new Box3().setFromObject(Kt);const Yt=[];if(this._nodes.forEach(Jt=>{if(Gt.node.guid==Jt.guid||Array.isArray(zt)===!0&&zt.includes(Jt.guid)||!Jt.ref||(Ht[Jt.skuID].hasOwnProperty("disableCollider")?Ht[Jt.skuID].disableCollider:this.stores.coreSceneStore.getState().sceneSettings.disableCollider))return;const nn=Jt.ref.getObjectByName("GRP_ProxyMesh");nn&&Yt.push(nn)}),Yt.length<=0)return!1;let Zt=!1;return Yt.forEach(Jt=>{if(Zt)return;let nn=new Box3().setFromObject(Jt);if(qt.intersectsBox(nn)){Zt=!0;return}}),Kt.clear(),Wt=null,Kt=null,qt=null,Zt}boxOverlapPercent(_e,Dt){if(_e.containsBox(Dt)||Dt.containsBox(_e))return 100;if(!(_e.min.x<Dt.max.x||Dt.min.x<_e.max.x))return 0;let Vt=new Vector3(0,0,0);_e.getSize(Vt),Vt.x*Vt.y*Vt.z;let Gt=new Vector3(0,0,0);Dt.getSize(Gt),Gt.x*Gt.y*Gt.z}checkInsideOutCollision(_e,Dt,Vt){let Gt=Dt.position.clone(),zt=new Float32Array(Vt.attributes.position.array),jt=zt.length/3;for(let Ht=0;Ht<jt;Ht++){let Wt=new Vector3(zt[Ht*3],zt[Ht*3+1],zt[Ht*3+2]),qt=Wt.add(Dt.position);qt=Wt.applyQuaternion(Dt.quaternion);let Xt=qt.sub(Dt.position);const Yt=new Raycaster(Gt,Xt.clone().normalize()).intersectObjects(_e),Zt=Yt.length>0,Jt=Yt[0].distance<Xt.length();if(Zt&&Jt)return!0}return!1}addNode(_e){this._nodes.push(_e)}getFirstNodeByCategoryID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt]._categoryID==_e)return this._nodes[Dt];return null}getNodesBySKUID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt].skuID==_e&&Dt.push(this._nodes[Vt]);return Dt}getNodesByCategoryID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt]._categoryID==_e&&Dt.push(this._nodes[Vt]);return Dt}async connectPlugs({incomingPlug:_e,receiverPlug:Dt}){_e.attachPlug(Dt,!1),Dt.attachPlug(_e,!0),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}removeNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e){this._nodes[Dt].removeNode(),this._nodes.splice(Dt,1);break}this._nodes.length==1&&this.#t&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,!0),this.stores.attachmentStore.getState().actions.updateFittingSkuIds(),this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}async removeNodeFromStructure(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e.guid){this._nodes.splice(Dt,1);break}await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(_e){this._globalVariants={},this._globalGeometryVariants={},this.stores=_e,this.stores.productDataStore.getState().categoryData.geometryVariants.map(Dt=>{this._globalGeometryVariants[Dt.id]=Dt.defaultVariant}),this.stores.productDataStore.getState().categoryData.color.map(Dt=>{this._globalVariants[Dt.id]=Dt.defaultLook}),this._currentStructure=new Structure(this.stores,null,this._globalVariants,this._globalGeometryVariants);for(const[Dt,Vt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Dt,Vt);for(const[Dt,Vt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Dt,Vt)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(_e,Dt){let Vt;return Vt=this.stores.productDataStore.getState()?.productData[_e]?.lookDetails[Dt],Vt?.clientProductId?Vt?.clientProductId:""}getCartItems(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,Ht.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)});let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt}}}async getCartItemsAsync(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,qt.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)}),_e=await this.stores.dynamicHookStore.getState().hookOnCartItemsCollected(_e,this.stores.coreSceneStore.getState().CORE_API);let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt.toFixed(2)}}}async getFittingSKUIDs(){if(!this.currentStructure)return[];const{productData:_e}=this.stores.productDataStore.getState(),{sceneSettings:Dt}=this.stores.coreSceneStore.getState(),{draggableUI:Vt,ignoreSpawningCollision:Gt}=Dt;if(!this.currentStructure)return[];const{openPlugTypes:zt,closedPlugTypes:jt,existingSkuids:Ht}=this.analyzeCurrentStructure();if(zt.size===0&&jt.size===0)return[];const Wt=this.findFittingSkuids(_e,zt,jt,Ht,Vt);return this.filterNonBlockedSkuids(Wt,_e,Gt)}analyzeCurrentStructure(){const _e=this.currentStructure.nodes,Dt=new Set,Vt=new Set,Gt=new Set;for(const zt of _e){Gt.add(zt.skuID);for(const jt of zt.plugs)jt.isOpen?jt.acceptedPlugTypes.forEach(Ht=>Dt.add(Ht)):jt.attachedPlug.node.replace&&jt.acceptedPlugTypes.forEach(Ht=>Vt.add(Ht))}return{openPlugTypes:Dt,closedPlugTypes:Vt,existingSkuids:Gt}}findFittingSkuids(_e,Dt,Vt,Gt,zt){const jt=new Set;for(const[Ht,Wt]of Object.entries(_e))if(Wt.plugs)for(const qt of Wt.plugs){for(const Xt of qt.connectsToPlugTypes)if((this.isClosedPlugFitting(Ht,Wt,Xt,Vt,Gt,zt)||this.isOpenPlugFitting(Wt,Xt,Dt))&&jt.add(Ht),jt.has(Ht))break;if(jt.has(Ht))break}return jt}isClosedPlugFitting(_e,Dt,Vt,Gt,zt,jt){if(!Gt.has(Vt)||!jt&&zt.has(_e))return!1;const Ht=this.currentStructure.getNodesByCategoryID(Dt.categoryID);for(const Wt of Ht)if(Wt.skuID!==_e&&this.isNodeCompatible(Wt,Dt))return!0;return!1}isNodeCompatible(_e,Dt){let Vt=!1;for(const Gt of _e.plugs)if(!Gt.isOpen&&Gt.isReceiverPlug&&(Vt=!0,this.isPlugCompatible(Gt,Dt.plugs)))return!0;return!Vt}isPlugCompatible(_e,Dt){return Dt.some(Vt=>Vt.name===_e.name&&_e.attachedPlug.connectsToPlugTypes.some(Gt=>Vt.acceptedPlugTypes.includes(Gt)))}isOpenPlugFitting(_e,Dt,Vt){if(!Vt.has(Dt))return!1;const Gt=this.currentStructure.getFirstNodeByCategoryID(_e.categoryID);return!Gt||!Gt.replace}async filterNonBlockedSkuids(_e,Dt,Vt){const Gt=[];for(const zt of _e)if(Dt[zt].replace)Gt.push(zt);else{const jt=await this.currentStructure.findGhostTransforms(zt,Vt);jt&&jt.transforms.length>0&&Gt.push(zt)}return Gt}async removeAllVariantOverrides(){let _e=this._currentStructure.nodes,Dt=this.stores.productDataStore.getState().productData,Vt=this.stores.itemStore.getState().itemsSpawned;return await _e.map(async Gt=>{if(!Gt.overrideVariant||(Gt.overrideVariant=null,!Dt[Gt.skuID].looks))return;let zt=null;Object.keys(this._globalVariants).map(jt=>{Dt[Gt.skuID].looks.includes(this._globalVariants[jt])&&zt==null&&(zt=this._globalVariants[jt])}),zt&&await this.stores.itemStore.getState().actions.switchToVariant(Vt[Gt.guid].itemData,zt)}),this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1),!0}async switchGlobalGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Yt=>{Yt.id==_e&&(zt=Yt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;let Xt=this.stores.productDataStore.getState().categoryData;Wt.map(Yt=>{jt.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{Yt==nn&&(Jt=!0)}),Jt&&Xt.build.map(nn=>{Zt.products.map(rn=>{nn.skus.map((Qt,en)=>{nn.skus[en]==rn&&(nn.skus[en]=Yt)})})})})}),this._currentStructure.nodes.map(Yt=>{jt.map(Zt=>{Zt.products.map(Jt=>{Yt.skuID==Jt&&Yt.ref!==null&&Zt.products.map(nn=>{Wt.map(rn=>{if(rn==nn){const Qt=this.stores.productDataStore.getState().actions.getProductDataById(rn);let en=Qt.geometriesToHide;Yt.plugs.map(sn=>{!sn.isOpen&&sn.attachedPlug&&sn.type=="weighted_hider"&&sn.attachedPlug.weight>sn.weight&&(en=en.concat(sn.affectedNodes))}),Yt.showNodes(Qt.geometriesToShow),Yt.hideNodes(en),Yt.skuID=rn;const tn=qt[Yt.guid];tn&&tn.itemData&&Object.keys(Qt).map(sn=>{tn.itemData[sn]=Qt[sn]}),Yt.resetInStock(),Yt.updatePricing()}})})})})}),this._globalGeometryVariants[_e]=Dt,this.stores.hotspotStore.getState().actions.checkHotspotHealth(),this.stores.inventoryStore.getState().actions.refreshInventory(qt),this.stores.productDataStore.setState({categoryData:Xt}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CategoryData_Updated,Xt),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const Kt=await this.getCartItemsAsync();Kt&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Kt)}async switchGlobalVariant(_e,Dt){this._globalVariants[_e]=Dt;const Vt=this.stores.itemStore.getState().actions;let Gt=this.stores.itemStore.getState().itemsSpawned;for(let Wt=0;Wt<Object.keys(Gt).length;Wt++){let qt=Gt[Object.keys(Gt)[Wt]];if(qt.itemData.looks&&qt.itemData.looks.includes(Dt)){let Xt=this._currentStructure.getNodeByGUID(qt.itemData.guid);Xt&&!Xt.overrideVariant&&await Vt.switchToVariant(qt.itemData,Dt)}}const zt=this.stores.productDataStore.getState().lookData;this.stores.lightStore.getState().actions.processLookEnvMapOverride(Dt);const jt=_e;Object.keys(Gt).length>0&&this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:jt.charAt(0).toUpperCase()+jt.slice(1)+" was successfully switched to "+zt[Dt].label+".",alertTime:3e3,alertType:"success",alertLabel:`${jt} Changed`,alertId:"materialVariantChanged"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),this.stores.itemStore.setState({variantChangeAlert:!this.stores.itemStore.getState().variantChangeAlert});const Ht=await this.getCartItemsAsync();Ht&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Ht)}async#t(_e){if(!_e)return;LOGGER.info({title:"Structure to load",details:_e}),delete this._currentStructure,this._globalVariants={..._e.globalVariants},this._globalGeometryVariants=_e.globalGeometryVariants?{..._e.globalGeometryVariants}:{};const Dt=[..._e.structure];this._currentStructure=new Structure(this.stores,Dt,this._globalVariants,this._globalGeometryVariants);for(const[Vt,Gt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Vt,Gt);for(const[Vt,Gt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Vt,Gt);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(Dt),LOGGER.info({title:"Structure Loaded."})}async loadStructure(_e){if(!_e)return;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),this.stores.coreSceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(_e),this.stores.coreSceneStore.getState().preconfigurationLoaded?this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide):this.stores.coreSceneStore.setState({preconfigurationLoaded:!0}),this.stores.coreSceneStore.getState().configurationLoadedOnRestart||this.stores.coreSceneStore.setState({configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.setState({configurationLoaded:!0}),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated();const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}export(){return{experienceId:this.stores.coreSceneStore.getState().CORE_API.experienceId,structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await this._currentStructure.clear(),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem();const _e=this.stores.attachmentStore.getState().defaultConfig;this.stores.coreSceneStore.setState({configurationLoaded:!1,configurationLoadedOnRestart:!1}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear(),await this.#t(_e),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated(),this.stores.coreSceneStore.setState({configurationLoaded:!0,configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide);const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}}const createAttachmentStore=kt=>{const _e=attachmentStoreCreator();return _e.setState({stores:kt}),_e},attachmentStoreCreator=()=>create((kt,_e)=>({stores:null,attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async Dt=>{const{actions:Vt,defaultConfig:Gt}=_e();LOGGER.info({title:"Initializing Attachment System!"});const zt=await new AttachmentSystem(Dt);kt({attachmentSystem:zt}),await Vt.updateFittingSkuIds(),await Vt.toggleStructureUpdated()},loadSavedStructureFromConfigID:async Dt=>{const{stores:Vt}=_e();LOGGER.info({title:"Fetching Structure Using ConfigID!"});let Gt="";Dt.length==20&&(Gt=FETCH_CONFIG_ENDPOINT_FB+Dt);let zt=null;return Gt!=""?zt=await getJSONFromEndpoint(Gt):zt=await Vt.nexusApiInstance.getExperienceSaveAndShare(Vt.experienceId,Dt),zt.success===!1?null:Dt.length==20?zt.data:zt.payload.save_data},loadDefaultStructure:async()=>{const{actions:Dt,defaultConfig:Vt}=_e();LOGGER.info({title:"Loading Default Structure!"}),await Dt.loadStructure(Vt)},updateFittingSkuIds:async()=>{const{stores:Dt,attachmentSystem:Vt}=_e();if(!Dt.coreSceneStore.getState().preconfigurationLoaded||!Dt.coreSceneStore.getState().configurationLoaded)return;const Gt=await Vt.getFittingSKUIDs();Gt&&(Dt.itemStore.setState({fittingSkuIds:[...Gt]}),Dt.coreSceneStore.getState().CORE_API.fireEvent(Dt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:Gt}))},toggleStructureUpdated:async()=>{const{attachmentSystem:Dt,stores:Vt}=_e();if(kt(zt=>({structureUpdated:!zt.structureUpdated})),!Vt.coreSceneStore.getState().preconfigurationLoaded||!Vt.coreSceneStore.getState().configurationLoaded)return;Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,Dt.currentStructure.getCurrentItemsInReplaceableCategory());const Gt=await Dt.getCartItemsAsync();Gt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Gt)},loadStructure:async Dt=>{const{attachmentSystem:Vt,stores:Gt}=_e();LOGGER.info({title:"Loading Structure!"}),Vt&&Gt.coreSceneStore.getState().configurationLoaded!==!1&&await Vt.loadStructure(Dt)},export:()=>{const{attachmentSystem:Dt}=_e();if(Dt)return Dt.export()}}})),createInfoStore=kt=>{const _e=infoStoreCreator();return _e.setState({stores:kt}),_e},infoStoreCreator=()=>create((kt,_e)=>({stores:null,infoObject:{},populateInfoObject:Dt=>{kt(Vt=>({infoObject:Dt}))},infoModalOpen:!1,updateInfoModalOpen:Dt=>{kt(Vt=>({infoModalOpen:Dt}))}})),createUIHotspotStore=kt=>{const _e=uiHotspotStoreCreator();return _e.setState({stores:kt}),_e},uiHotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,activeFeatureID:"",actions:{enterHotspotInFeaturesTab(Vt){const{stores:Gt}=_e();Gt.uiSceneStore.getState().sideMenuState!==2&&Gt.uiSceneStore.setState({sideMenuState:2}),kt({activeFeatureID:Vt})},exitHotspot(){kt({activeFeatureID:null})}}})),createColorStore=kt=>{const _e=colorStoreCreator();return _e.setState({stores:kt}),_e},colorStoreCreator=()=>create((kt,_e)=>({stores:null,allActiveVariants:{},allActiveGeometryVariants:{}})),arrayWithoutElementAtIndex=function(kt,_e){return kt.filter(function(Dt,Vt){return _e!==Vt})},updateQuantityAtIndex=function(kt,_e,Dt){let Vt=kt.slice();return Vt[_e].quantity=Dt,Vt},createCartStore=kt=>{const _e=cartStoreCreator();return _e.setState({stores:kt}),_e},cartStoreCreator=()=>create((kt,_e)=>({stores:null,cart:[],cartTotalPrice:0,cartTotalCompareAtPrice:0,deleteCartItem:Dt=>{kt(Vt=>({cart:arrayWithoutElementAtIndex(Vt.cart,Dt)}))},addToCart:Dt=>{kt(Vt=>({cart:[...Vt.cart,Dt]}))},updateQuantity:(Dt,Vt)=>{kt(Gt=>({cart:updateQuantityAtIndex(Gt.cart,Dt,Vt)}))},previewCartModalOpen:!1,togglePreviewCartModal:()=>{const{previewCartModalOpen:Dt,stores:Vt}=_e();Dt===!0?(Vt.uiSceneStore.getState().CORE_API.reviewCartHidden(),kt({previewCartModalOpen:!1,previewCartMinimized:!1})):(Vt.uiSceneStore.getState().CORE_API.reviewCartShown(),kt({previewCartModalOpen:!0}))},previewCartMinimized:!1,togglePreviewCartMinimized:()=>{const{previewCartMinimized:Dt,stores:Vt}=_e(),Gt=!Dt;kt({previewCartMinimized:Gt}),Vt&&Vt.uiSceneStore&&Vt.uiSceneStore.getState().setSideMenuOpen(!Gt)},actions:{setCartTotalPrice:(Dt,Vt)=>{kt(()=>({cartTotalPrice:Dt,cartTotalCompareAtPrice:Vt}))}}})),createLightStore=kt=>{const _e=lightStoreCreator();return _e.setState({stores:kt}),_e},lightStoreCreator=()=>create((kt,_e)=>({stores:null,defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:Dt=>{kt(Vt=>({envMapUrl:Dt}))},processLookEnvMapOverride:Dt=>{const{envMapUrl:Vt,defaultEnvMapUrl:Gt,actions:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().lookData[Dt],Wt=Ht?.envMapOverride;if(!Ht||!Wt){zt.setEnvLightMap(Gt);return}if(Wt===Vt){LOGGER.info({title:`New Env Map Url is the same as the current ${Wt}`});return}zt.setEnvLightMap(Wt)}}})),createHotspotStore=kt=>{const _e=hotspotStoreCreator();return _e.setState({stores:kt}),_e},hotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>kt({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(Dt){const{hotspotsSpawned:Vt}=_e();Object.keys(Vt).map(Gt=>{Vt[Gt].itemData.guid==Dt.itemData.guid&&delete Vt[Gt]}),kt({hotspotsSpawned:{...Vt}})},checkHotspotHealth(){const{hotspotsHealthCheck:Dt}=_e();kt({hotspotsHealthCheck:!Dt})},toggleHotspotVisibility(){const{hotspotsVisibility:Dt}=_e();kt({hotspotsVisibility:!Dt})},switchHotspotsVisibility(Dt,Vt=!1){kt(Vt===!0?{hotspotsTempVisibility:Dt}:{hotspotsVisibility:Dt})},clickHotspot(Dt,Vt,Gt,zt=!1){const{activeHotspotData:jt,stores:Ht}=_e();kt({lastActiveHotspotData:jt}),hotspotEnter(Ht,Dt,Vt,Gt);let qt=Ht.itemStore.getState().itemsSpawned[Gt].itemData.skuID;zt===!1&&(Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(qt,Dt),hotspot:jt}),Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(Dt=!1){const{activeHotspotData:Vt,isAnyHotspotActive:Gt,stores:zt}=_e();if(Gt&&kt({isAnyHotspotActive:!1}),!!Vt&&(kt({lastActiveHotspotData:Vt}),hotspotExit(zt),Dt===!1)){const jt=Math.round((performance.now()-_e().lastActiveHotspotData.hotspotEnterTime)/1e3);zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:_e().lastActiveHotspotData,hotspotTimeSpent:jt}),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(kt){kt.hotspotStore.setState({activeHotspotData:null}),kt.coreSceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(kt,_e,Dt,Vt){let Gt=kt.hotspotStore.getState();const jt=kt.itemStore.getState().itemsSpawned;let Ht=Gt.visitedHotspotsID;const Wt=jt[Vt].hotspotsData.filter(un=>un.hotspotID==_e);if(!Wt||Wt.length<=0)return;const qt=Wt[0],Xt=jt[Vt].itemData.skuID+"_"+_e;let Yt=kt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Vt),Zt=new Vector3(0,0,0);Yt&&Yt.ref&&Yt.ref.getWorldPosition(Zt);let Jt=new Quaternion().identity();Yt&&Yt.ref&&Yt.ref.getWorldQuaternion(Jt);let nn=qt.focusPointTransform,rn=ArrToVec3(nn);rn.applyQuaternion(Jt);let Qt=qt.viewPointTransform,en=ArrToVec3(Qt);en.applyQuaternion(Jt);let tn=addVector(Vec3ToArr(rn),Vec3ToArr(Zt)),sn=addVector(Vec3ToArr(en),Vec3ToArr(Zt));kt.cameraStore.setState({focusPointPosition:tn,viewPointPosition:sn}),kt.hotspotStore.setState({activeHotspotData:{hotspotData:{guid:Dt,...qt},itemData:{...jt[Vt],guid:Vt},domID:"rd_"+Xt,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),Ht.includes(Xt)||(Ht.push(Xt),kt.hotspotStore.setState({visitedIDs:{...Ht}}))}var replacingNodes=null,swappableNodes=[];const createGhostStore=kt=>{const _e=ghostStoreCreator();return _e.setState({stores:kt}),_e},ghostStoreCreator=()=>create((kt,_e)=>({stores:null,ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(Dt,Vt=!1,Gt)=>{const{ghostData:zt,ghostsTransform:jt,stores:Ht}=_e();if(zt!==null||jt.length>0){LOGGER.info({title:"ghosts are already spawned for: "+zt.skuID});return}return await new Promise(async(qt,Xt)=>{let Kt={};const Yt=()=>{qt(Kt)};Ht.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Ghost_Loaded,Yt,{once:!0});const Zt=Ht.productDataStore.getState().productData,Jt=Ht.attachmentStore.getState().attachmentSystem.currentStructure;replacingNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const nn=Ht.coreSceneStore.getState().sceneSettings.draggableUI,rn=await Jt.findGhostTransforms(Dt,Vt),Qt=nn?rn&&rn.transforms&&rn.transforms.length===0:!0;if(Zt[Dt].replace&&replacingNodes.length>0&&Qt)if(nn){const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null||cn==null||sn.length<=0){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null&&cn==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{transforms:tn,newNodes:sn,connectablePlugs:cn,comboPlugs:un}=rn;let hn=tn,fn=cn,pn=sn,dn=[];for(let mn=0;mn<tn.length;mn++)dn.push("add");if(Zt[Dt].swappable&&!Ht.coreSceneStore.getState().dragging){swappableNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const mn=await Jt.findGhostTransformForReplacement(Dt,swappableNodes);if(mn.transforms)for(let vn=0;vn<mn.transforms.length;vn++)hn.push(mn.transforms[vn]),fn.push(mn.connectablePlugs[vn]),pn.push(mn.newNodes[vn]),dn.push("replace"),mn.newNodes[vn].setModelVisibility(!1)}Kt.transforms=hn,Kt.newNodes=pn,Kt.connectablePlugs=fn,Kt.comboPlugs=un,Kt.addItemOrSwap=dn}if(Kt.transforms.length<=0){Xt();return}const en=await Ht.assetStore.getState().actions.loadProxyAsset(Dt,!0);kt({ghostsTransform:Kt.transforms,ghostData:{proxyScene:en.proxy.data.scene,skuID:Dt,newNodes:Kt.newNodes,addItemOrSwap:Kt.addItemOrSwap,connectablePlugs:Kt.connectablePlugs,comboPlugs:Kt.comboPlugs,count:Gt||Kt.transforms.length}})})},clearAllGhosts:()=>{const{ghostsTransform:Dt}=_e();if(replacingNodes)for(const Vt of replacingNodes)Vt.setModelVisibility(!0);if(swappableNodes)for(let Vt=0;Vt<swappableNodes.length;Vt++)swappableNodes[Vt].setModelVisibility(!0);Dt.length<=0||kt({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),createCameraStore=kt=>{const _e=cameraStoreCreator();return _e.setState({stores:kt}),_e},cameraStoreCreator=()=>create((kt,_e)=>({stores:null,focusPointPosition:new Vector3(0,0,0),sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,cameraControlsRef:null,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{canCameraRotate:Dt=>{const{cameraControlsRef:Vt}=_e();Vt&&(Dt===!0?(Vt.mouseButtons.left=CAMERA_ACTION.ROTATE,Vt.touches.one=CAMERA_ACTION.TOUCH_ROTATE):(Vt.mouseButtons.left=CAMERA_ACTION.NONE,Vt.touches.one=CAMERA_ACTION.NONE))},triggerFetchingCamera:()=>{kt(Dt=>({sendCameraDetailsTrigger:!Dt.sendCameraDetailsTrigger}))},setCameraSettings:Dt=>{const{cameraSettings:Vt,stores:Gt}=_e();Gt.coreSceneStore.getState().isMobile===!0&&Dt.zoomingMultiplier_mobile!==void 0?Dt.zoomingMultiplier=Dt.zoomingMultiplier_mobile:Dt.zoomingMultiplier_desktop!==void 0&&(Dt.zoomingMultiplier=Dt.zoomingMultiplier_desktop),Object.keys(Dt).map(jt=>Vt[jt]=Dt[jt]),kt({cameraSettings:{...Vt},viewPointPosition:ArrToVec3(Vt.initialViewPointPosition)})}}})),createUISceneStore=kt=>{const _e=uiSceneStoreCreator();return _e.setState({stores:kt}),_e},uiSceneStoreCreator=()=>create((kt,_e)=>({stores:null,CORE_API:null,sideMenuState:0,sideMenuOpen:!0,setSideMenuOpen:Dt=>kt({sideMenuOpen:Dt}),cssLoaded:!1,isScreenPortrait:!0,materialOverrideExists:!1,tabSpawnCount:[],coreWCRef:null,removeModalOpen:!1,outOfStockModalOpen:!1,disableCart:!1,inventoryData:{},cartMessage:"",loadConfigId:"",dialogPopupOpen:!1,viewInYourSpaceMenuBtnVisible:!1,loadConfigModalOpen:!1,setLoadConfigModalOpen:Dt=>kt({loadConfigModalOpen:Dt}),setOutOfStockModalOpen:Dt=>kt({outOfStockModalOpen:Dt}),setRemoveModalOpen:Dt=>kt({removeModalOpen:Dt}),moveModalOpen:!1,setMoveModalOpen:Dt=>kt({moveModalOpen:Dt}),setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},setSideMenuState:Dt=>{kt(()=>({sideMenuState:Dt}));const{CORE_API:Vt}=_e();Dt!==2?Vt.exitHotspot():Vt.showAllHotspots()}})),createDynamicHookStore=kt=>{const _e=dynamicHookStoreCreator();return _e.setState({stores:kt}),_e},dynamicHookStoreCreator=()=>create((kt,_e)=>({hookOnCartItemsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnCartItemsCollected"}),Promise.resolve(Dt)),hookOnSceneItemsUpdated:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemsUpdated"}),Promise.resolve()),hookOnNewItemGhostsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnNewItemGhostsCollectedForReplacement:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnSceneItemAdded:async(Dt,Vt,Gt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve()),hookOnCheckout:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve(Dt))}));class STORES{experienceId="";uuid=null;wcRef=null;nexusApiResponseEnvironment="production";nexusApiInstance=null;productDataStore=null;coreSceneStore=null;inventoryStore=null;itemStore=null;assetStore=null;attachmentStore=null;lightStore=null;hotspotStore=null;ghostStore=null;cameraStore=null;infoStore=null;uiHotspotStore=null;colorStore=null;cartStore=null;uiSceneStore=null;constructor(_e){this.wcRef=_e,this.uuid=v4(),this.dynamicHookStore=createDynamicHookStore(this),this.productDataStore=createProductDataStore(this),this.coreSceneStore=createCoreSceneStore(this),this.inventoryStore=createInventoryStore(this),this.itemStore=createItemStore(this),this.assetStore=createAssetStore(this),this.attachmentStore=createAttachmentStore(this),this.lightStore=createLightStore(this),this.hotspotStore=createHotspotStore(this),this.ghostStore=createGhostStore(this),this.cameraStore=createCameraStore(this),this.infoStore=createInfoStore(this),this.uiHotspotStore=createUIHotspotStore(this),this.colorStore=createColorStore(this),this.cartStore=createCartStore(this),this.uiSceneStore=createUISceneStore(this)}setupNexusApiInstance(_e){let Dt=p$5.PRODUCTION;_e=="local"?Dt=p$5.LOCAL:_e==="staging"&&(Dt=p$5.STAGING);const Vt=window.location.href,Gt=window.epigraph?window.epigraph.epigraphSessionId:"no-session-id",zt="2.2.1-alpha.1",jt=g$3.generateXPath(this.wcRef);this.nexusApiInstance=new P$2(Dt,Vt,Gt,zt,jt)}}class EpigraphConfigurator extends h$5{#t=void 0;#i=null;#n=null;clientAccessKey=null;validationPassed=!1;projectID="";configID="default";customVersionId="";experienceId="";apiMode="production";gaMeasurementId="";#s=getUrlParameterByName("launchInAR")==="true";#r=!1;api={core:null,ui:null};stores=null;constructor(){let _e=s$2.PRODUCTION;super("2.2.1-alpha.1",_e),this.stores=new STORES(this),this.api.ui=this,this.shadowRoot||this.attachShadow({mode:"open"}),this.hasAttribute("launch-in-ar")&&(this.#s=!0),this.#c(),this.#o()}#c(){this.preloadDiv=document.createElement("div"),this.preloadDiv.id="preloadMainContainer",this.preloadDiv.classList.add("preload-main-container"),this.preloadDiv.classList.add("showPreload"),this.preloadDiv.appendChild(PRELOAD_MUTED_CSS.content.cloneNode(!0)),this.preloadDiv.appendChild(PRELOAD_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.preloadDiv);const _e=this.shadowRoot;this.#n=Dt=>{if(Dt.code=="Enter"){let Vt=_e.activeElement;Vt&&Vt.click()}},this.shadowRoot.addEventListener("keyup",this.#n)}#o(){this.hiccupUi=document.createElement("div"),this.hiccupUi.id="hiccupMainContainer",this.hiccupUi.classList.add("hiccup-ui-main-container"),this.hiccupUi.appendChild(HICCUP_MUTED_CSS.content.cloneNode(!0)),this.hiccupUi.appendChild(HICCUP_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.hiccupUi)}get configuratorWcId(){return this.#t}get launchInAr(){return this.#s}#a(){if(this.hasAttribute("id")?this.#t=this.getAttribute("id"):(this.setAttribute("id","epigraphConfiguratorWc"),this.#t=this.getAttribute("id")),this.hasAttribute("custom-version-id")&&(this.customVersionId=this.getAttribute("custom-version-id")),this.hasAttribute("experience-id")&&(this.experienceId=this.getAttribute("experience-id")),this.hasAttribute("api-mode")){const _e=this.getAttribute("api-mode");["local","staging","production"].includes(_e)&&(this.apiMode=_e)}this.stores.setupNexusApiInstance(this.apiMode),(this.hasAttribute("ga-measurement-id")||this.hasAttribute("ga-code"))&&(this.gaMeasurementId=this.getAttribute("ga-measurement-id")??this.getAttribute("ga-code")),this.clientAccessKey=this.getAttribute("client-access-key"),this.initialConfigId=this.getAttribute("initial-config-id"),this.consentPlugin=this.getAttribute("consent-plugin"),this.consentIdentifier=this.getAttribute("consent-identifier"),this.initialConfigId||(this.initialConfigId="default")}async connectedCallback(){if(this.#r===!0){console.warn("Tried to remount configurator. Blocking the process.");return}this.#a(),this.style.maxWidth="1440px",this.style.maxHeight="800px",this.style.overflow="hidden",this.style.width="100%",this.style.height="100%",this.style.position="relative",this.style.visibility="visible",this.style.display="flex";const _e=document.createElement("div");_e.id="configuratorContainer",_e.style.width="100%",_e.style.height="100%",_e.style.userSelect="none",_e.style.overflow="hidden",this.shadowRoot.appendChild(_e),this.#i=createRoot(_e),this.#i.render(jsxRuntimeExports.jsx(App,{stores:this.stores,customVersionId:this.customVersionId,experienceId:this.experienceId,disableUI:this.hasAttribute("disable-ui"),disableCart:this.hasAttribute("disable-cart"),configuratorWcRef:this,gaMeasurementId:this.gaMeasurementId},"Configurator-App")),this.#r=!0}disconnectedCallback(){for(this.#i&&(this.#i.unmount(),this.#i=null),this.#n&&(this.shadowRoot.removeEventListener("keyup",this.#n),this.#n=null),this.#t=void 0,this.clientAccessKey=null,this.validationPassed=!1,this.projectID="",this.configID="default",this.customVersionId="",this.gaMeasurementId="",this.#s=!1,this.#r=!1,this.api={core:null,ui:null},this.preloadDiv&&(this.preloadDiv.remove(),this.preloadDiv=null),this.hiccupUi&&(this.hiccupUi.remove(),this.hiccupUi=null);this.shadowRoot.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild)}showPreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("no-pointer-events"),this.preloadDiv.classList.add("showPreload"))}async hidePreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("showPreload"),await wait(1e3),this.preloadDiv.classList.add("no-pointer-events"))}showHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("no-pointer-events"),this.hiccupUi.classList.add("show-hiccup"))}async hideHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("show-hiccup"),await wait(1e3),this.hiccupUi.classList.add("no-pointer-events"))}}window.customElements.define("epigraph-configurator",EpigraphConfigurator);
4796
+ `;const createCoreSceneStore=kt=>{const _e=coreStoreCreator();return _e.setState({stores:kt}),_e},coreStoreCreator=()=>create((kt,_e)=>({stores:null,shadowRefreshKey:0,CORE_API:null,coreReady:void 0,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,sceneHasDefaultConfigurationID:!1,configurationLoaded:!0,preconfigurationLoaded:!1,configurationLoadedOnRestart:!0,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:{center:new Vector3(0,0,0),size:new Vector3(0,0,0)},showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],currentAlertData:null,alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{usdzMaxTextureSize:1024,usdzPrecision:7,swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",arPlacement:"floor",arTransforms:{position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]},currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:10,g:10,b:10,a:.2},technicalRequirements:{minIosVersion:"11"},ghostScale:[1,1,1],ghostAsWireframe:!1,draggableUI:!1,addFromInfoModal:!1,clickToAddUi:!0,accordionInBuildUi:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:null,emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,comboPlugDistanceThreshold:.05,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",outlineSettings:{multisampling:10,visibleEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),hiddenEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),blur:3,width:1e3,edgeStrength:1e3,blendFunction:BlendFunction.ALPHA,pulseSpeed:0,xRay:!0},textSettings:{arButtonLabel:"AR",arHoverLabel:"View In Your Space",restartButtonLabel:"Restart",restartHoverLabel:"Restart",saveButtonLabel:"Save",saveHoverLabel:"Save",shareButtonLabel:"Share",shareHoverLabel:"Share",sizeButtonLabel:"Size",sizeHoverLabel:"Size",hotspotsButtonLabel:"Hotspots",hotspotsHoverLabel:"Hotspots",instructionsButtonLabel:"Instructions",instructionsHoverLabel:"Instructions",cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",featuresTabEmptyText:"*Please add an item to the scene to see the features",tooltipEmptySceneText:"",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:2999,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0,unvisualizedItemSpawn:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},actions:{refreshShadows:()=>{const{shadowRefreshKey:Dt}=_e();kt({shadowRefreshKey:Dt+1})},popFromAlertQueue:()=>{const{alertQueue:Dt}=_e();return Dt.shift(),kt({alertQueue:Dt}),Dt},addToAlertQueue:Dt=>{const{alertQueue:Vt,currentAlertData:Gt}=_e();return Vt.length>0&&Vt[Vt.length-1].alertId&&Dt.alertId===Vt[Vt.length-1].alertId||Vt.length==0&&Gt&&Gt.alertId&&Gt.alertId==Dt.alertId||(Vt.push(Dt),kt({alertQueue:Vt})),Vt},getDeviceState:()=>{const{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}=_e();return{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}},enableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!1,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!0,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:Dt}=_e();return Dt},sendAlert:Dt=>{kt({alertData:{...Dt}})},switchCursor(Dt){const{cursorParentRef:Vt}=_e();if(!Vt)return;let Gt="";switch(Dt){default:case CURSORS.GRAB:Gt="grabCursor";break;case CURSORS.GRABBING:Gt="grabbingCursor";break;case CURSORS.BLOCKED:Gt="blockedCursor";break;case CURSORS.POINTER:Gt="pointerCursor";break;case CURSORS.MOVE:Gt="moveCursor";break}for(let zt=0;zt<Vt.classList.length;zt++)Vt.classList[zt].includes("Cursor")&&Vt.classList.remove(Vt.classList[zt]);Vt.classList.add(Gt)},setAlertSettings:Dt=>{kt({alertSettings:Dt})},async completeDropItem(){const{draggingOnDropCollisionData:Dt,CORE_API:Vt,stores:Gt}=_e(),zt=Gt.attachmentStore.getState().attachmentSystem,{node:jt,attachedChildrenGuids:Ht,collidingStatus:Wt,intersectingGhostObject:qt,initPosition:Xt,initRotation:Kt,detachedPlugs:Yt,attachedNodesToCurrentNode:Zt}=Dt;Vt.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[Qt,en]of Ht.entries())Wt[Qt]===!0&&await Gt.itemStore.getState().actions.removeItemByGUID(en);const Jt=qt.userData;let nn=jt.getPlugByName(Jt.incomingPlugName),rn=zt.currentStructure.getPlugByGUID(Jt.receiverPlugGUID);jt.ref.position.set(qt.position.x,qt.position.y,qt.position.z),jt.ref.setRotationFromEuler(qt.rotation),jt.transform={position:qt.position,rotation:qt.quaternion},zt.currentStructure.connectPlugs({incomingPlug:nn,receiverPlug:rn}),Gt.ghostStore.getState().actions.clearAllGhosts(),Gt.itemStore.getState().actions.deselectItem(),Zt.map(Qt=>{jt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},jt.dragging=!1,Qt.dragging=!1}),await Gt.attachmentStore.getState().actions.updateFittingSkuIds()},async revertDropItem(){const{draggingOnDropCollisionData:Dt,stores:Vt}=_e(),Gt=Vt.attachmentStore.getState().attachmentSystem,{node:zt,attachedChildrenGuids:jt,collidingStatus:Ht,intersectingGhostObject:Wt,initPosition:qt,initRotation:Xt,detachedPlugs:Kt,attachedNodesToCurrentNode:Yt}=Dt;CORE_API.alert({alertMsg:"Position of item"+zt.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const Zt=Kt.neighbourDetachedPlugs;Zt&&(Kt.neighbourNode.detachNodeFromReceiver(),Gt.currentStructure.connectPlugs({incomingPlug:Zt.incomingPlug,receiverPlug:Zt.receiverPlug}));let Jt=Kt.rootDetachedPlugs.incomingPlug,nn=Kt.rootDetachedPlugs.receiverPlug;zt.ref.position.set(qt.x,qt.y,qt.z),zt.ref.setRotationFromEuler(Xt);let rn=new Quaternion().identity();zt.ref.getWorldQuaternion(rn),zt.transform={position:qt,rotation:rn},Gt.currentStructure.connectPlugs({incomingPlug:Jt,receiverPlug:nn}),Vt.ghostStore.getState().actions.clearAllGhosts(),Vt.itemStore.getState().actions.deselectItem(),Yt.map(Qt=>{zt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},zt.dragging=!1,Qt.dragging=!1}),await Vt.attachmentStore.getState().actions.updateFittingSkuIds()},setCoreSettings:Dt=>{const{sceneSettings:Vt,isMobile:Gt,isTouchDevice:zt,isLandscape:jt,actions:Ht}=_e(),Wt=Gt===!0?"mobile":"desktop",qt=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","clickToAddUi","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const Xt of qt)if(Xt==="draggableUI"||Xt==="clickToAddUi"||Xt==="emptySceneTextFontSize"||Xt==="showInstructionsOnStartup"||Xt==="showInstructionsBtn"||Xt==="instructionsSettings"){const Yt=`${Xt}_${jt===!1&&zt===!0?"mobile":"desktop"}`;Dt[Yt]!==void 0?Vt[Xt]=Dt[Yt]:Vt[Yt]!==void 0&&(Vt[Xt]=Vt[Yt])}else if(Xt==="textSettings"||Xt==="variantsTabOrder"||Xt==="alertControl"||Xt==="outlineSettings"){if(Dt.hasOwnProperty(Xt)){let Kt=Vt[Xt];Object.keys(Kt).map(Yt=>{let Zt=Dt[Xt];Zt.hasOwnProperty(Yt)?(Yt==="visibleEdgeColor"||Yt==="hiddenEdgeColor")&&(Zt[Yt]=new Color$1(Zt[Yt]).convertSRGBToLinear()):Zt[Yt]=Kt[Yt]})}}else{const Kt=`${Xt}_${Wt}`;if(Dt[Kt]!==void 0){let Yt=`${Xt}Btn`;Xt=="showContextMenu"&&(Yt=`${Xt}`),Vt[Yt]=Dt[Kt]}}Dt.disableCart===!0&&Ht.disableCart(),Object.keys(Dt).map(Xt=>Vt[Xt]=Dt[Xt]),Vt.emptySceneText===null&&(Vt.emptySceneTextFontSize=Gt?"1.2rem":"1.5rem",Vt.draggableUI===!0?Vt.emptySceneText="Drag an item here to get started":Vt.emptySceneText="Select an item to get started"),kt({sceneSettings:{...Vt,ghostThreeColor:{r:Vt.ghostColor.r/255,g:Vt.ghostColor.g/255,b:Vt.ghostColor.b/255,a:Vt.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:Vt.ghostColorOnHoverWithDraggableUi.r/255,g:Vt.ghostColorOnHoverWithDraggableUi.g/255,b:Vt.ghostColorOnHoverWithDraggableUi.b/255,a:Vt.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(Dt=null)=>kt(Vt=>({autoFocusRef:Dt,autoFocusTrigger:Vt.autoFocusTrigger+1})),requestNewScreenshot:async(Dt,Vt)=>{const{CORE_API:Gt}=_e();return new Promise(async(zt,jt)=>{LOGGER.info({title:"Taking a screenshot"});const{screenshotRenderer:Ht,sceneRef:Wt,screenshotCamera:qt,canvasSize:Xt}=_e(),Kt=await Gt.getCurrentCameraDetails();if(Ht.setClearColor(16777215),qt.copy(Kt),Dt!==null&&(qt.position.copy(Dt.position),qt.rotation.copy(new Euler(Dt.rotation.x,Dt.rotation.y,Dt.rotation.z))),Vt==null?Ht.setSize(Xt.width,Xt.height):Ht.setSize(Vt.width,Vt.height),Ht.render(Wt.parent,qt),Ht.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),jt({success:!1,imageData:null});else{LOGGER.info({title:"Downloading the screenshot"});const Yt=Ht.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");zt({success:!0,imageData:Yt})}})}}})),createProductDataStore=kt=>{const _e=productDataStoreCreator();return _e.setState({stores:kt}),_e},productDataStoreCreator=()=>create((kt,_e)=>({stores:null,productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentCompareAtPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].compareAtPrice)}),Vt[Gt]=jt}),Vt},getCurrentPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].price)}),Vt[Gt]=jt}),Vt},updateCompareAtPricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updateCompareAtPricingForProduct(Gt,jt,zt[jt])})})},updatePricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updatePricingForProduct(Gt,jt,zt[jt])})})},updateCompareAtPricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.compareAtPrice=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updateCompareAtPricing())},updatePricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.price=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updatePricing())},setProductData:Dt=>{const{stores:Vt}=_e();let Gt={};Dt&&Object.keys(Dt).map(zt=>{const jt=Dt[zt];if(jt.skuID=zt,jt.skuID.toLowerCase()==="root"){jt.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},jt.defaultVariant="default";return}if(jt?.lookDetails){const Ht=jt.lookDetails;let Wt=Object.keys(jt.lookDetails);if(Wt.includes("default")){const Xt=Wt.indexOf("default");Wt.splice(Xt,1)}jt.looks=Wt,Object.keys(jt.lookDetails).map(Xt=>{let Kt=jt.lookDetails[Xt];Kt.inventory===void 0&&(Kt.inventory=DEFAULT_INVENTORY),Kt.price===void 0&&(Kt.price=DEFAULT_PRODUCT_PRICE),Kt.compareAtPrice===void 0&&(Kt.compareAtPrice=DEFAULT_PRODUCT_COMPARE_AT_PRICE),Gt[zt]={...Gt[zt],[Xt]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let qt=jt?.defaultVariant;qt||(LOGGER.warn({title:`No defaultVariant set for ${jt.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),qt=Object.keys(jt.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+qt})),Wt.includes(qt)?(jt.lookDetails.default=Ht[qt],jt.lookDetails.default.id=qt):(LOGGER.error({title:`Default look [ ${qt} ] doesn't exist for: ${zt}. Please make sure to select a default variant in Input Data for this project`}),jt.lookDetails.default=null)}}),LOGGER.info({title:"PRODUCT DATA: ",details:Dt}),Vt.inventoryStore.setState({inventoryData:Gt}),kt({productData:Dt})},setCategoryData:Dt=>{const{productData:Vt}=_e();Dt.geometryVariants!==void 0&&Dt.geometryVariants.map(Gt=>{Gt.defaultVariant===void 0&&Object.keys(Gt.variants).length>0&&(Gt.defaultVariant=Object.keys(Gt.variants)[0])}),Dt.color!==void 0&&Dt.color.map(Gt=>{(Gt.defaultLook===void 0&&Gt.looks.length>0||!Gt.looks.includes(Gt.defaultLook))&&(Gt.defaultLook=Gt.looks[0])}),kt({categoryData:Dt}),Dt.build!==void 0&&Dt.build.map(Gt=>{Gt.skus.map(zt=>{Vt[zt].categoryID=Gt.categoryID,Vt[zt].categoryLabel=Gt.label,Vt[zt].swappable=Gt.swappable?Gt.swappable:!1,Vt[zt].replace=Gt.replace})})},getProductDataById:Dt=>{const{productData:Vt}=_e();let Gt=null;return Vt[Dt]&&(Gt=Vt[Dt]),Gt},setLookData:Dt=>kt({lookData:Dt}),setHotspotsData:Dt=>{const{categoryData:Vt,productData:Gt}=_e();Vt.geometryVariants&&Object.keys(Dt).map(zt=>{Dt[zt].map(jt=>{jt.geometryVariantID&&Vt.geometryVariants.map(Ht=>{Object.keys(Ht.variants).map(Wt=>{jt.geometryVariantID==Wt&&Ht.productsInCategory.map(qt=>{let Xt=null;qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)&&(Xt=Dt[Kt])}),qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)||(Dt[Kt]=Xt)})})})})})}),kt({hotspotsData:Dt})},setAssetsData:Dt=>kt({assetsData:Dt})}})),createItemStore=kt=>{const _e=itemStoreCreator();return _e.setState({stores:kt}),_e},itemStoreCreator=()=>create((kt,_e)=>({stores:null,variantChangeAlert:!1,focusedGUID:null,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],fittingSkuIds:[],filteredCollidersRef:[],selectedItemData:null,defaultSceneItemCount:0,busySpawningItem:!1,busyReplacingItem:!1,busySpawningDependency:!1,busyDraggingItem:!1,busyRemovingItem:!1,isBusy:()=>{const{busySpawningItem:Dt,busyReplacingItem:Vt,busySpawningDependency:Gt,busyDraggingItem:zt,busyRemovingItem:jt}=_e();return Dt||Vt||Gt||zt||jt},actions:{triggerModelLoaded:()=>{kt(Dt=>({modelLoadedAlert:Dt.modelLoadedAlert+1}))},triggerRemoveItem:()=>{kt(Dt=>({removeItemTrigger:!Dt.removeItemTrigger}))},addToRemoveItems:Dt=>{const{removeItems:Vt}=_e();Vt.push(Dt)},switchToVariant:async(Dt,Vt,Gt=!1)=>{const{variantChangeAlert:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().categoryData;let qt=jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt.guid);const Xt=jt.assetStore.getState().assets.items,Kt=qt.ref.getObjectByName("GRP_RenderGeometry");Xt[Dt.skuID].data||Ht.geometryVariants&&Ht.geometryVariants.map(Yt=>{Yt.productsInCategory.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{nn==Dt.skuID&&(Jt=!0)}),Jt&&Zt.products.map(nn=>{const rn=jt.assetStore.getState().assets.items[nn].data;rn&&(jt.assetStore.getState().assets.items[Dt.skuID].data=rn)})})}),qt.modelFunctions&&(await qt.modelFunctions.selectVariant(Kt,Vt),Gt?(qt.overrideVariant=Vt,jt.coreSceneStore.getState().CORE_API.fireEvent(jt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):qt.currentVariant=Vt,kt({variantChangeAlert:!zt}))},clearAllItems:()=>{kt({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:Dt=>{kt({itemsSpawned:Dt,itemsCount:Object.keys(Dt).length})},setHoveredItemRef:Dt=>kt({hoveredItemRef:Dt}),setCollidersRef:Dt=>{const{stores:Vt}=_e();kt({collidersRef:Dt});let Gt=[];for(let zt=0;zt<Dt.length;zt++)Dt[zt].current&&Gt.push(Dt[zt]);Vt.itemStore.setState({filteredCollidersRef:[...Gt]})},setSelectedItemData:Dt=>{const{selectedItemData:Vt,hoveredItemRef:Gt,actions:zt,stores:jt}=_e();Vt&&(delete Gt[Vt.itemData.guid],zt.setHoveredItemRef({...Gt})),kt({selectedItemData:{...Dt}}),jt.hotspotStore.getState().actions.switchHotspotsVisibility(!1,!0),jt.cameraStore.getState().actions.canCameraRotate(!1)},deselectItem:()=>{const{selectedItemData:Dt,stores:Vt}=_e();Dt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.UI.ContextMenu_Hide,Dt),kt(()=>({selectedItemData:null})),Vt.hotspotStore.getState().actions.switchHotspotsVisibility(!0,!0),Vt.cameraStore.getState().actions.canCameraRotate(!0),Vt.itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async Dt=>{const{itemsSpawned:Vt,actions:Gt,stores:zt}=_e();if(Vt.hasOwnProperty(Dt))return kt({busyRemovingItem:!0}),new Promise(async(jt,Ht)=>{const Wt=qt=>{Dt===qt.data.itemData.guid&&(kt({busyRemovingItem:!1}),jt(Dt))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Item_Removed,Wt,{once:!0}),Gt.addToRemoveItems(Dt),Gt.triggerRemoveItem()})},addItemBySkuID:async(Dt,Vt=0,Gt=!1,zt)=>{kt({busySpawningItem:!0});const{actions:jt,itemsSpawned:Ht,stores:Wt}=_e(),qt=Wt.productDataStore.getState().productData,Xt=Wt.productDataStore.getState().hotspotsData,Kt=Wt.attachmentStore.getState().attachmentSystem;let Yt=!0;const Zt=await new Promise(async(Jt,nn)=>{if(LOGGER.info({title:`Spawning item: ${Dt}`}),jt.deselectItem(),!qt[Dt]){LOGGER.warn({title:`Product not found: ${Dt}`}),Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:Dt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Yt=!1,nn(Dt+": product not found!");return}const rn=[...Wt.ghostStore.getState().ghostsTransform],Qt={...Wt.ghostStore.getState().ghostData};if(rn.length<=0){Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),Yt=!1,nn("No available connections for this product to attach to");return}const en=tn=>{Dt===tn.data&&Jt(Qt.newNodes[Vt].guid)};if(Wt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,en,{once:!0}),Qt.addItemOrSwap[Vt]=="replace")await replaceItem(kt,Wt,Ht,Qt.skuID,rn[Vt],Qt.newNodes[Vt]);else{Wt.ghostStore.getState().actions.clearAllGhosts();const tn=Qt.newNodes[Vt];tn.isDependent=Gt;let sn=!0;if(qt[Qt.skuID].hasOwnProperty("disableInteraction")){const fn=qt[Qt.skuID].disableInteraction;(fn==!0||fn==!1)&&(sn=!fn)}zt!=null&&(sn=zt),tn.isInteractive=sn;const{position:cn,rotation:un}=rn[Vt];tn.transform={position:cn,rotation:un},Kt.currentStructure.addNode(tn),Qt.connectablePlugs[Vt].receiverPlug.type=="unvisualizedPlug"&&Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"This product is not shown in your 3D configuration but can be found in your shopping list.",alertTime:3e3,alertType:"warn",alertLabel:"Internal Storage",persistant:!1,alertId:"unvisualizedItemSpawn"}),Qt.comboPlugs[Vt].length>0&&Qt.connectablePlugs[Vt].incomingPlug.type=="comboPlug"&&Qt.comboPlugs[Vt].map(fn=>{Kt.currentStructure.connectPlugs(fn)}),Qt.connectablePlugs[Vt].incomingPlug.comboPlugConnector=!0,Kt.currentStructure.connectPlugs(Qt.connectablePlugs[Vt]);const hn=await Wt.assetStore.getState().actions.loadProxyAsset(Qt.skuID,!0);LOGGER.info({title:"GHOST NEW NODE: ",details:tn}),Ht[tn.guid]={itemData:{proxyScene:hn.proxy.data.scene,guid:Qt.newNodes[Vt].guid,...qt[Qt.skuID],position:cn,rotation:un,hasItemLoaded:!1,isDependent:Gt,isInteractive:sn},hotspotsData:Xt[Qt.skuID],hotspotSpawned:!1},await wait(1),jt.setItemsSpawned({...Ht})}}).catch(Jt=>{LOGGER.error({title:Jt}),Yt=!1});if(Yt===!1)return kt({busySpawningItem:!1}),Zt;if(Wt.coreSceneStore.getState().preconfigurationLoaded&&Wt.coreSceneStore.getState().configurationLoaded){const Jt=await Kt.getCartItemsAsync();Jt&&Wt.coreSceneStore.getState().CORE_API.fireEvent(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Jt)}if(await jt.resolvePlugDependencyOnGUID(Zt),kt({busySpawningItem:!1}),!Gt){const Jt=Kt.currentStructure,nn=Jt.getNodeByGUID(Zt);Wt.dynamicHookStore.getState().hookOnSceneItemAdded(nn,Jt.nodes,Wt.coreSceneStore.getState().CORE_API),await Wt.attachmentStore.getState().actions.updateFittingSkuIds()}return Zt},async addItemWithTransform(Dt,Vt,Gt,zt=!0){const{actions:jt,itemsSpawned:Ht,defaultSceneItemCount:Wt,stores:qt}=_e(),Xt=qt.productDataStore.getState().productData,Kt=qt.productDataStore.getState().hotspotsData;return await new Promise(async(Zt,Jt)=>{if(jt.deselectItem(),!Xt[Vt]){qt.coreSceneStore.getState().CORE_API.alert({alertMsg:Vt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Jt(Vt+": product not found!");return}const{position:nn,rotation:rn}=Dt;Ht[Gt]!=null&&(qt.hotspotStore.getState().actions.removeHotspotForItem({...Ht[Gt]}),delete Ht[Gt]);const Qt=tn=>{Vt.toLowerCase()==tn.data.toLowerCase()&&Zt(Gt)};qt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(qt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Qt,{once:!0});const en=await qt.assetStore.getState().actions.loadProxyAsset(Vt,!0);if(en==null){Jt(Vt+": Asset not found!");return}await wait(1),Vt.toLowerCase()==="root"&&kt({defaultSceneItemCount:Wt+1}),Ht[Gt]={itemData:{proxyScene:en.proxy.data.scene,guid:Gt,...Xt[Vt],position:nn,rotation:rn,hasItemLoaded:!1,isInteractive:zt},hotspotsData:Kt[Vt],hotspotSpawned:!1},kt({itemsSpawned:{...Ht}})}).catch(Zt=>{LOGGER.info({title:Zt})})},async resolvePlugDependencyOnGUID(Dt){const{actions:Vt,itemsSpawned:Gt,defaultSceneItemCount:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().productData,Wt=jt.attachmentStore.getState().attachmentSystem,qt=Gt[Dt].itemData.skuID,Xt=Ht[qt]?.plugs;if(!Xt)return;let Kt=!1;for(const Yt of Xt)Yt?.dependencySku&&(Kt=!0);Kt&&(kt({busySpawningDependency:!0}),await new Promise(async(Yt,Zt)=>{const Jt=[];for(const nn of Xt){const rn=nn?.dependencySku;if(!rn)continue;const Qt=async()=>{LOGGER.info({title:`Found a dependency: ${rn} on the plug: ${nn.name}`});let en=!0;Ht[rn]&&Ht[rn].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(en=Ht[rn].ignoreSpawningCollisionAsDependency),nn.hasOwnProperty("ignoreSpawningCollision")&&(en=nn.ignoreSpawningCollision);let tn=jt.coreSceneStore.getState().sceneSettings.ignoreSpawningCollision;Ht[rn].hasOwnProperty("ignoreSpawningCollision")&&(tn=Ht[rn].ignoreSpawningCollision),Ht[rn].ignoreSpawningCollision=en,jt.ghostStore.setState({ghostVisibility:!1});const sn=await jt.ghostStore.getState().actions.spawnGhostsForSkuID(rn,en);if(Ht[rn].ignoreSpawningCollision=tn,!sn)return;const cn=Wt.currentStructure.getNodeByGUID(Dt),un=cn.getPlugByName(nn.name)?.guid,hn=nn?.isDependencySkuInteractive?nn.isDependencySkuInteractive===1:!1,fn=sn.connectablePlugs;let pn=-1;for(const mn of fn)mn.receiverPlug.guid===un&&(pn=fn.indexOf(mn));if(pn==-1){jt.ghostStore.getState().actions.clearAllGhosts();return}const dn=await Vt.addItemBySkuID(rn,pn,!0,hn);qt.toLowerCase()==="root"&&Ht[rn].ignoreInCart&&kt({defaultSceneItemCount:zt+1}),dn!==null&&cn.addMyDependenciesGUID(dn)};Jt.push(await Qt())}await Promise.all(Jt),Yt(!0)}),kt({busySpawningDependency:!1}))},async replaceGuidItemBySkuId(Dt,Vt){const{itemsSpawned:Gt,stores:zt}=_e();if(Gt[Dt]==null)return!1;const jt=zt.attachmentStore.getState().attachmentSystem.currentStructure,Ht=jt.getNodeByGUID(Dt);if(!Ht||!Ht.isReplaceableWithSkuId(Vt))return!1;LOGGER.info({title:"Replacing Item"});const qt=zt.productDataStore.getState().productData,Xt=zt.productDataStore.getState().hotspotsData;kt({busyReplacingItem:!0}),await new Promise(async(Kt,Yt)=>{const Zt=async()=>{LOGGER.info({title:"Removed old item with guid: "+Dt});const Jt=async Qt=>{Vt===Qt.data&&(jt.recalculateStructureFromNode(Ht.whichNodeAreWeAttachedTo()),await zt.attachmentStore.getState().actions.toggleStructureUpdated(),kt({busyReplacingItem:!1}),Kt(Ht.guid))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Jt,{once:!0});const nn=await zt.assetStore.getState().actions.loadProxyAsset(Vt,!0),rn={receiverPlug:Ht.whichPlugAreWeAttachedTo(),incomingPlug:Ht.whichPlugAreWeAttachedUsing()};jt.findItemTransform(rn),Gt[Dt]={itemData:{proxyScene:nn.proxy.data.scene,guid:Dt,...qt[Vt],position:Ht.transform.position,rotation:Ht.transform.rotation,hasItemLoaded:!1},hotspotsData:Xt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:Ht.currentVariant}),zt.itemStore.setState({itemsSpawned:{...Gt}})};zt.hotspotStore.getState().actions.removeHotspotForItem({...Gt[Dt]}),delete Gt[Dt],Ht.update(Vt),zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}}}));async function replaceItem(kt,_e,Dt,Vt,Gt,zt){LOGGER.info({title:"Replacing Item"});const{position:jt,rotation:Ht}=Gt,Wt=_e.productDataStore.getState().productData,qt=_e.productDataStore.getState().hotspotsData,Xt=_e.attachmentStore.getState().attachmentSystem.currentStructure;return kt({busyReplacingItem:!0}),new Promise(async(Kt,Yt)=>{const Zt=async()=>{const Jt=await _e.assetStore.getState().actions.loadProxyAsset(Vt,!0),nn=async rn=>{Vt===rn.data&&(Xt.recalculateStructureFromNode(zt),await _e.attachmentStore.getState().actions.toggleStructureUpdated(),_e.ghostStore.getState().actions.clearAllGhosts(),kt({busyReplacingItem:!1}),Kt(zt.guid))};_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,nn,{once:!0}),Dt[zt.guid]={itemData:{proxyScene:Jt.proxy.data.scene,guid:zt.guid,...Wt[Vt],position:jt,rotation:Ht,hasItemLoaded:!1},hotspotsData:qt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:zt.currentVariant}),zt.currentVariant=zt.currentVariant,zt.transform=Gt,_e.itemStore.setState({itemsSpawned:{...Dt}})};_e.hotspotStore.getState().actions.removeHotspotForItem({...Dt[zt.guid]}),delete Dt[zt.guid],zt.update(Vt),_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}const createInventoryStore=kt=>{const _e=inventoryStoreCreator();return _e.setState({stores:kt}),_e},inventoryStoreCreator=()=>create((kt,_e)=>({stores:null,inventoryData:{},actions:{updateInventoryForAllProducts:Dt=>{const{actions:Vt,stores:Gt}=_e();Object.keys(Dt).map(zt=>{let jt=Dt[zt];Object.keys(jt).map(Ht=>{Vt.updateInventoryForProduct(zt,Ht,jt[Ht].inventory)})}),Vt.refreshInventory(Gt.itemStore.getState().itemsSpawned)},updateInventoryForProduct:(Dt,Vt,Gt)=>{const{inventoryData:zt}=_e();let jt=zt[Dt],Ht=jt[Vt];!jt||!Ht||(Ht.inventory=Gt)},_clearInScene:()=>{const{inventoryData:Dt}=_e();Object.keys(Dt).map(Vt=>{const Gt=Dt[Vt];Object.keys(Gt).map(zt=>{Gt[zt].inScene=[]})})},refreshInventory:Dt=>{if(!Dt)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:Vt,inventoryData:Gt,stores:zt}=_e();Vt._clearInScene();const jt=zt.attachmentStore.getState().attachmentSystem;if(jt===null)return;const Ht=jt.currentStructure;if(Ht===null)return;Object.keys(Dt).map(Kt=>{const Yt=Ht.getNodeByGUID(Kt);if(!Yt)return;const Zt=Yt.overrideVariant?Yt.overrideVariant:Yt.currentVariant;if(!Zt)return;const Jt=Gt[Yt.skuID];if(!Jt||!Jt[Zt].inScene)return;Jt[Zt].inScene.push(Kt),zt.coreSceneStore.getState().sceneSettings.disableCart===!0?Yt.inStock={variantName:Zt,newValue:!0}:Jt[Zt].inScene.length>Jt[Zt].inventory?Yt.inStock={variantName:Zt,newValue:!1}:Yt.inStock={variantName:Zt,newValue:!0}});let Wt=!1;Object.keys(Gt).map(Kt=>{const Yt=Gt[Kt];Object.keys(Yt).map(Zt=>{Yt[Zt].countAvailable=Yt[Zt].inventory-Yt[Zt].inScene.length,Yt[Zt].countAvailable<0?(Yt[Zt].countUnavailable=Yt[Zt].countAvailable*-1,Yt[Zt].countAvailable=0,Wt=!0):Yt[Zt].countUnavailable=0})});const qt={alertMsg:"Some item(s) in configuration are out of stock",alertTime:7e3,alertType:"warn",alertLabel:"Stock Alert",persistant:!0,alertId:"outOfStock"},Xt=compareObjects(zt.coreSceneStore.getState().persistantAlertData,qt);Wt===!1&&Xt===!0&&zt.coreSceneStore.getState().CORE_API.removePersistantAlert(),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Inventory_Updated,Gt)}}})),createAssetStore=kt=>{const _e=assetStoreCreator();return _e.setState({stores:kt}),_e},assetStoreCreator=()=>create((kt,_e)=>({stores:null,assets:{items:{}},gltfLoader:null,dracoLoader:null,actions:{init(){const Dt=new DRACOLoader;Dt.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`),Dt.setDecoderConfig({type:"js"});const Vt=new GLTFLoader;Vt.register(Gt=>new GLTFMaterialsVariantsExtension(Gt)),Vt.setDRACOLoader(Dt),kt({dracoLoader:Dt,gltfLoader:Vt})},async loadProxyAsset(Dt){const{assets:Vt,gltfLoader:Gt,stores:zt}=_e(),jt="proxy",Ht=Vt.items[Dt]=Vt.items[Dt]||{isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}},Wt=Ht.proxy;if(Wt.isLoaded)return Ht;if(Wt.errorLoading)throw new Error(`${jt} loading failed for: ${Dt}`);const qt=zt.productDataStore.getState().productData[Dt];if(!qt)throw new Error(`Data doesn't exist for ${Dt}`);const Xt=zt.coreSceneStore.getState().CORE_API.getResolvedAssetUrl(qt.colliderProxyGLTF);if(!Xt)return null;try{const Kt=await Gt.loadAsync(Xt,Yt=>{Wt.progress=Yt.loaded/Yt.total*100});return Wt.data=Kt,Wt.isLoaded=!0,Ht}catch(Kt){throw Wt.isLoaded=!1,Wt.errorLoading=!0,Wt.error=Kt,LOGGER.info({title:Xt}),new Error(`Couldn't load ${Dt}`)}},isProxyLoaded(Dt){const Vt=_e().assets.items[Dt];return Vt?Vt.proxy.isLoaded:!1}}}));class Structure{#t=!1;constructor(_e,Dt=null,Vt,Gt){if(this.stores=_e,this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:Dt}),this.setupHookOnSceneItemsUpdated(),Dt){LOGGER.info({title:"PRELOAD Length-----------------:"+Dt.length});for(let zt=0;zt<Dt.length;zt++){LOGGER.info({title:"FOUND PRELOAD-----------------"});const jt=Dt[zt].skuID;if(jt.toLowerCase()=="root"){const Wt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Wt).length>0&&(Dt[zt].guid=Object.keys(Wt)[0])}let Ht=new Node$1(_e,jt,Dt[zt],Vt,Gt);jt.toLowerCase()=="root"&&(this._rootNode=Ht),this._nodes.push(Ht)}}else{const zt=new Node$1(_e,"Root",null,Vt,Gt);this._rootNode=zt,this._nodes.push(zt),this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1)}this._boundingBoxLeeway=this.stores.coreSceneStore.getState().sceneSettings.boundingBoxLeeway}async setupHookOnSceneItemsUpdated(){const _e=this.stores.coreSceneStore.getState().CORE_API;this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.stores.dynamicHookStore.getState().hookOnSceneItemsUpdated(this._nodes,_e)})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let _e=0;_e<this._nodes.length;_e++)this._nodes[_e].updatePricing()}getCurrentItemsInReplaceableCategory(){let _e={};for(const Dt of this._nodes)Dt.replace&&(_e[Dt.categoryID]=Dt.skuID);return _e}recalculateStructureFromNode(_e){for(let Dt=0;Dt<_e.plugs.length;Dt++)if(!_e.plugs[Dt].isOpen&&_e.plugs[Dt].isReceiverPlug){const Vt=_e.plugs[Dt].attachedPlug.node,Gt={receiverPlug:_e.plugs[Dt],incomingPlug:_e.plugs[Dt].attachedPlug};if(Gt){const zt=this.findItemTransform(Gt);zt&&(Vt.ref.position.set(zt.position.x,zt.position.y,zt.position.z),zt.rotation.isQuaternion===!0?Vt.ref.setRotationFromQuaternion(zt.rotation):zt.rotation.isEuler===!0&&Vt.ref.setRotationFromEuler(zt.rotation),Vt.transform={position:zt.position,rotation:zt.rotation})}this.recalculateStructureFromNode(Vt)}}rotateNode(_e){const Dt=this.getNodeByGUID(_e);let Vt=null,Gt=null;for(let Ht=0;Ht<Dt.plugs.length;Ht++)if(!Gt&&!Dt.plugs[Ht].isOpen&&Dt.plugs[Ht].attachedPlug.isReceiverPlug){const Wt=Dt.plugs[Ht].attachedPlug.acceptedPlugTypes;Gt=Dt.plugs[Ht].attachedPlug;let qt=[];for(let Xt=Ht+1;Xt<Dt.plugs.length;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<Ht;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<qt.length;Xt++)for(let Kt=0;Kt<qt[Xt].connectsToPlugTypes.length;Kt++)Wt.includes(qt[Xt].connectsToPlugTypes[Kt])&&(Vt=qt[Xt])}if(!Vt)return;Dt.detachNodeFromReceiver();const{position:zt,rotation:jt}=this.findItemTransform({receiverPlug:Gt,incomingPlug:Vt});Dt.ref.position.set(zt.x,zt.y,zt.z),jt.isQuaternion===!0?Dt.ref.setRotationFromQuaternion(jt):jt.isEuler===!0&&Dt.ref.setRotationFromEuler(jt),Dt.transform={position:Dt.ref.position,rotation:jt},this.connectPlugs({receiverPlug:Gt,incomingPlug:Vt}),this.recalculateStructureFromNode(Dt)}async load(_e){this.resolvePlugConnections(_e),await this.respawnItems()}materialOverrideExists(){let _e=!1;return this.nodes.map(Dt=>{if(Dt.overrideVariant)return _e=!0,!0}),_e}async findGhostTransformForReplacement(_e,Dt){let Vt=[],Gt=[],zt=[];for(const Ht of Dt){if(Ht.skuID==_e)continue;const Wt=this.stores.attachmentStore.getState().attachmentSystem,qt=Ht.whichPlugAreWeAttachedTo(),Xt=Ht.whichPlugAreWeAttachedUsing(),Yt=new Node$1(this.stores,_e,null,Wt.globalVariants,Wt.globalGeometryVariants).getPlugByName(Xt.name);if(!Yt)continue;const Zt={incomingPlug:Yt,receiverPlug:qt},{position:Jt,rotation:nn}=this.findItemTransform(Zt);Jt&&nn&&(Gt.push({position:Jt,rotation:nn,incomingPlugName:Zt.incomingPlug.name,receiverPlugName:Zt.receiverPlug.name,incomingPlugGUID:Zt.incomingPlug.guid,receiverPlugGUID:Zt.receiverPlug.guid}),zt.push(Zt),Vt.push(Ht))}let jt={transforms:Gt,connectablePlugs:zt,newNodes:Vt};return jt=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollectedForReplacement(jt,this.stores.coreSceneStore.getState().CORE_API),jt}async findGhostTransforms(_e,Dt){const Vt=this.getOpenPlugs(),Gt=this.stores.coreSceneStore.getState().sceneSettings.comboPlugDistanceThreshold;if(Vt.length<=0)return{transforms:[]};const zt=this.stores.attachmentStore.getState().attachmentSystem,jt=this.stores.productDataStore.getState().productData,Ht=new Node$1(this.stores,_e,null,zt.globalVariants,zt.globalGeometryVariants),Wt=this.getConnectablePlugs(Ht,Vt);let qt=[];if(Wt.length<=0)return{transforms:[]};let Xt=[],Kt=[];const Yt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene;if(!Yt)return!1;let Zt=Yt.clone();for(let rn=0;rn<Wt.length;rn++){let Qt=Dt,{incomingPlug:en,receiverPlug:tn}=Wt[rn],sn=this.findItemTransform(Wt[rn]);if(!sn)continue;let{position:cn,rotation:un}=sn;if(!cn||!un)continue;Zt.position.set(cn.x,cn.y,cn.z),un.isQuaternion===!0?Zt.setRotationFromQuaternion(un):un.isEuler===!0&&Zt.setRotationFromEuler(un);let hn=[],fn=[];if(en.type=="comboPlug"){if(en.connectsToPlugTypes.length<=0)continue;const vn=en.connectsToPlugTypes[0];let _n=!1;if(Kt.map(Cn=>{_n===!0||Cn.length<=0||Cn.map(yn=>{_n===!0||yn.incomingPlug.guid!==en.guid||yn.incomingPlug.connectsToPlugTypes.includes(vn)&&(_n=!0)})}),_n===!0)continue;const An=en.node.plugs;let Tn=!0;if(An.map(Cn=>{if(Cn.type!=="comboPlug"||Cn.guid===en.guid||!Cn.connectsToPlugTypes.includes(vn))return;let yn=!1;if(Vt.map(Sn=>{if(tn.guid===Sn.guid||!Sn.acceptedPlugTypes.includes(vn)||!Sn.node.ref)return;let wn=new Vector3(0,0,0);const xn=Sn.node.ref.getObjectByName(""+Sn.name);if(!xn)return;xn.getWorldPosition(wn);let Rn=new Vector3(0,0,0);const Dn=Zt.getObjectByName(""+Cn.name);if(!Dn)return;Dn.getWorldPosition(Rn);const kn=wn.distanceTo(Rn);Math.abs(kn)<Gt&&(hn.push(tn.node.guid),hn.push(Sn.node.guid),fn.push({receiverPlug:Sn,incomingPlug:Cn}),yn=!0)}),yn==!1){Tn=!1;return}}),!Tn)continue}let pn=Qt;Array.isArray(Qt)===!0&&(pn=!1),hn.length>0&&(pn=!1,Array.isArray(Qt)===!0?hn.map(vn=>{Qt.push(vn)}):Qt=hn),jt[_e].hasOwnProperty("ignoreSpawningCollision")&&(pn=jt[_e].ignoreSpawningCollision),Wt[rn].receiverPlug.type=="unvisualizedPlug"&&(pn=!0),(pn?!1:this.isColliding(Ht.skuID,sn,Wt[rn].receiverPlug,Qt))||(Xt.push({position:cn,rotation:un,incomingPlugName:Wt[rn].incomingPlug.name,receiverPlugName:Wt[rn].receiverPlug.name,incomingPlugGUID:Wt[rn].incomingPlug.guid,receiverPlugGUID:Wt[rn].receiverPlug.guid}),qt.push(Wt[rn]),Kt.push(fn))}let Jt=[];for(let rn=0;rn<Xt.length;rn++)Jt.push(Ht);dispose3(Zt);let nn={transforms:Xt,newNodes:Jt,connectablePlugs:qt,comboPlugs:Kt};return nn=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollected(nn,this.stores.coreSceneStore.getState().CORE_API),nn}resolvePlugConnections(_e){for(let Dt=0;Dt<_e.length;Dt++)Object.keys(_e[Dt].plugs).map(Vt=>{let Gt=_e[Dt].plugs[Vt].guid,zt=this.getPlugInNodesByGUID(Gt);if(!zt||zt.attachedPlug)return;let jt=_e[Dt].plugs[Vt].attachedPlugGUID,Ht=this.getPlugInNodesByGUID(jt);Ht&&(Ht.attachedPlug||(zt.attachPlug(Ht,_e[Dt].plugs[Vt].isReceiverPlug),Ht.attachPlug(zt,!_e[Dt].plugs[Vt].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let _e=[this.rootNode];for(let zt=0;zt<_e.length;zt++){let Ht=_e[zt].whichPlugsAreAttachedToUs();for(let Wt=0;Wt<Ht.length;Wt++){if(Ht[Wt].incomingPlug.type=="comboPlug"&&Ht[Wt].incomingPlug.connectsToPlugTypes.length>0&&!Ht[Wt].incomingPlug.comboPlugConnector)continue;let qt=this.findItemTransformForPreload(Ht[Wt],Ht[Wt].receiverPlug.node.transform);qt?await this.stores.itemStore.getState().actions.addItemWithTransform(qt,Ht[Wt].incomingPlug.node.skuID,Ht[Wt].incomingPlug.node.guid):LOGGER.warn({title:"Problem finding plug transform! "+Ht[Wt].name}),Ht[Wt].incomingPlug.node.transform=qt,_e.push(Ht[Wt].incomingPlug.node)}}const Dt=await this.stores.coreSceneStore.getState().CORE_API.getCartItemsAsync();this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded,{...Dt}),this.stores.coreSceneStore.getState().actions.triggerAutoFocus(),this.stores.hotspotStore.getState().actions.checkHotspotHealth();const Vt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,Gt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Vt||Gt){let zt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);zt.parameters={project_id:`${this.stores.coreSceneStore.getState().CORE_API.projectId}`,...Dt},this.stores.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(zt)}}getPlugInNodesByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].getPlugByGUID(_e);if(Vt)return Vt}return null}export(){let _e=[];for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].export();Vt&&_e.push(Vt)}return _e}async clear(){return new Promise(async(_e,Dt)=>{!this._rootNode&&this._rootNode.isEndNode&&_e(!0);let Vt=null;const Gt=this._rootNode.whichNodesAreAttachedToUs();Gt.length>0&&(Vt=Gt[0]),this.#t=!0,this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,zt=>_e(zt.data),{once:!0}),Vt?this.stores.coreSceneStore.getState().CORE_API.removeItemByGUID(Vt.guid,!0):(await wait(500),_e(!0))})}getNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e)return this._nodes[Dt];return null}getPlugByGUID(_e){for(const Dt of this._nodes){const Vt=Dt.getPlugByGUID(_e);if(Vt)return Vt}return null}findItemTransformForPreload(_e,Dt){let{receiverPlug:Vt,incomingPlug:Gt}=_e,zt=Vt,jt=Gt;if(zt.node.skuID=="Root")return this.findItemTransformRoot(_e);let Ht=null,Wt=null,qt=new Object3D,Xt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();qt.add(Xt);let{position:Kt,rotation:Yt}=Dt;if(Xt.position.set(Kt.x,Kt.y,Kt.z),Yt.isQuaternion===!0?Xt.setRotationFromQuaternion(Yt):Yt.isEuler===!0&&Xt.setRotationFromEuler(Yt),Wt=Xt,!Wt||(Ht=Wt.getObjectByName(zt.name),!Ht))return;let Zt=new Vector3(0,0,0);Ht.getWorldPosition(Zt);let Jt=new Quaternion().identity();Ht.getWorldQuaternion(Jt);let nn=new Object3D;Ht.add(nn);let rn=this.stores.assetStore.getState().assets.items[jt.node.skuID].proxy.data.scene.clone();rn.position.set(Zt.x,Zt.y,Zt.z),rn.applyQuaternion(Jt);let Qt=new Vector3;Qt.copy(Xt.up).applyQuaternion(Wt.quaternion);let en=new Vector3;en.copy(rn.up).applyQuaternion(Jt),en.negate();let tn=new Quaternion().setFromUnitVectors(Qt,en);Qt.round(),en.round();let sn=Qt.dot(en);sn!==1&&sn!==-1&&rn.applyQuaternion(tn);let cn=rn.getObjectByName(jt.name),un=new Quaternion().identity();cn.getWorldQuaternion(un);let hn=new Vector3(0,1,0);hn.applyQuaternion(un);let fn=new Vector3(0,1,0);fn.applyQuaternion(Jt),fn.negate();let pn=new Quaternion().setFromUnitVectors(hn,fn);if(hn.round(),fn.round(),hn.dot(fn)!==-1)rn.applyQuaternion(pn);else{let An=new Vector3(0,1,0),Tn=fn.dot(An);if(Tn!==1&&Tn!==-1)rn.rotateOnAxis(An,Math.PI);else{let Cn=new Vector3(0,0,1),yn=fn.dot(Cn);if(yn!==1&&yn!==-1)rn.rotateOnAxis(Cn,Math.PI);else{let Sn=new Vector3(1,0,0),wn=fn.dot(Sn);wn!==1&&wn!==-1&&rn.rotateOnAxis(Sn,Math.PI)}}}let mn=rn.getObjectByName(jt.name),vn=new Vector3(mn.position.x,mn.position.y,mn.position.z);rn.translateX(-vn.x),rn.translateY(-vn.y),rn.translateZ(-vn.z);let _n=new Vector3(0,0,0);rn.getWorldPosition(_n);let En=new Quaternion().identity();return rn.getWorldQuaternion(En),rn=null,{position:_n,rotation:En}}findItemTransformRoot(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Vt;const zt=new Object3D;let jt=zt,Ht=new Vector3(0,0,0);jt.getWorldPosition(Ht);let Wt=new Quaternion().identity(),qt=new Object3D;qt.position.set(0,0,0),zt.add(qt);let Xt=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone();qt.attach(Xt),Xt.translateX(Ht.x),Xt.translateY(Ht.y),Xt.translateZ(Ht.z);let Kt=Xt.getObjectByName(Gt.name),Yt=new Quaternion().identity();Kt&&Kt.getWorldQuaternion(Yt);const Zt=new Vector3(0,1,0);Zt.applyQuaternion(Yt);const Jt=new Vector3(0,1,0);Jt.applyQuaternion(Wt);const nn=Jt.angleTo(Zt),rn=new Vector3(0,0,0);rn.crossVectors(Jt,Zt),rn.round(),rn.length()!==0&&Xt.rotateOnAxis(rn,nn);let Qt=new Matrix4().extractRotation(Xt.matrixWorld),en=new Vector3(0,0,0);Kt&&en.set(Kt.position.x,Kt.position.y,Kt.position.z),en.applyMatrix4(Qt),Xt.translateX(-en.x),Xt.translateY(-en.y),Xt.translateZ(-en.z);let tn=new Vector3(0,0,0);Xt.getWorldPosition(tn);let sn=new Quaternion().identity();return Xt.getWorldQuaternion(sn),qt.remove(Xt),qt=null,Xt=null,{position:tn,rotation:sn}}findItemTransform(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Dt,zt=Vt;if(Gt.node.isRoot)return this.findItemTransformRoot(_e);const jt=Gt.node.transform;if(!jt)return;const Ht=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone(),Wt=new Object3D;Wt.position.set(jt.position.x,jt.position.y,jt.position.z),jt.rotation.isQuaternion===!0?Wt.setRotationFromQuaternion(jt.rotation):jt.rotation.isEuler===!0&&Wt.setRotationFromEuler(jt.rotation),Wt.add(Ht);let qt=Wt.getObjectByName(""+Gt.name);if(!qt){LOGGER.error({title:"Plug: "+Gt.name+" doesn't exist in "+Gt.node.skuID});return}let Xt=new Vector3(0,1,0);qt.getWorldPosition(Xt);let Kt=new Quaternion().identity();qt.getWorldQuaternion(Kt);let Yt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();Yt.position.set(Xt.x,Xt.y,Xt.z),Yt.applyQuaternion(Kt);let Zt=new Vector3;Zt.copy(Ht.up).applyQuaternion(Wt.quaternion);let Jt=new Vector3;Jt.copy(Yt.up).applyQuaternion(Kt),Jt.negate();let nn=new Quaternion().setFromUnitVectors(Zt,Jt);Zt.round(),Jt.round();let rn=Zt.dot(Jt);rn!==1&&rn!==-1&&Yt.applyQuaternion(nn);let Qt=Yt.getObjectByName(zt.name);if(!Qt){LOGGER.error({title:"Plug: "+zt.name+" doesn't exist in "+zt.node.skuID});return}let en=new Quaternion().identity();Qt.getWorldQuaternion(en);let tn=new Vector3(0,1,0);tn.applyQuaternion(en);let sn=new Vector3(0,1,0);sn.applyQuaternion(Kt),sn.negate();let cn=new Quaternion().setFromUnitVectors(tn,sn);if(tn.round(),sn.round(),tn.dot(sn)!==-1)Yt.applyQuaternion(cn);else{let mn=new Vector3(0,1,0),vn=sn.dot(mn);if(vn!==1&&vn!==-1)Yt.rotateOnAxis(mn,Math.PI);else{let _n=new Vector3(0,0,1),En=sn.dot(_n);if(En!==1&&En!==-1)Yt.rotateOnAxis(_n,Math.PI);else{let An=new Vector3(1,0,0),Tn=sn.dot(An);Tn!==1&&Tn!==-1&&Yt.rotateOnAxis(An,Math.PI)}}}let hn=Yt.getObjectByName(zt.name),fn=new Vector3(hn.position.x,hn.position.y,hn.position.z);Yt.translateX(-fn.x),Yt.translateY(-fn.y),Yt.translateZ(-fn.z);let pn=new Vector3(0,0,0);Yt.getWorldPosition(pn);let dn=new Quaternion().identity();return Yt.getWorldQuaternion(dn),Wt.remove(Ht),Yt=null,{position:pn,rotation:dn}}getSpawningRequirementForSkuID(_e){let Dt=[];const Vt=this.stores.productDataStore.getState().productData,Gt=Vt[_e];if(!Gt)return Dt;const zt=[];return Gt.plugs.map(jt=>{jt.connectsToPlugTypes.map(Ht=>{zt.push(Ht)})}),Object.keys(Vt).map(jt=>{for(let Ht=0;Ht<Vt[jt].plugs.length;Ht++){const Wt=Vt[jt].plugs[Ht].acceptedPlugTypes;for(let qt=0;qt<Wt.length;qt++)zt.map(Xt=>{Xt==Wt[qt]&&!Dt.includes(jt)&&Dt.push(jt)})}}),Dt}getConnectablePlugs(_e,Dt){let Vt=[],Gt=_e.getOpenPlugsWeCanAttachFrom();for(let zt=0;zt<Gt.length;zt++)for(let jt=0;jt<Dt.length;jt++){let Ht=!1;for(let qt=0;qt<Vt.length;qt++)if(Vt[qt].receiverPlug.guid==Dt[jt].guid&&Vt[qt].incomingPlug.type!="comboPlug"){Ht=!0;break}if(Ht)continue;Gt[zt].canAttachToPlug(Dt[jt])&&Vt.push({incomingPlug:Gt[zt],receiverPlug:Dt[jt]})}return Vt}getOpenPlugs(){let _e=[];return this._nodes.map(Dt=>{if(Dt.dragging===!0)return;let Vt=Dt.getOpenPlugsFromNode();_e=_e.concat(Vt)}),_e}checkCollisionForGUID(_e,Dt=[]){if(this.stores.coreSceneStore.getState().sceneSettings.disableCollider)return!1;const Vt=this.stores.itemStore.getState().itemsSpawned,Gt=this.stores.productDataStore.getState().productData;if(!Vt[_e])return!1;const jt=this.getNodeByGUID(_e);if(!jt||!jt.ref||Gt[jt.skuID].disableCollider)return!1;let Ht=new Vector3;jt.ref.getWorldPosition(Ht);let Wt=new Quaternion;jt.ref.getWorldQuaternion(Wt);const qt={position:Ht,rotation:Wt},Xt=jt.whichPlugAreWeAttachedTo();return Xt==null?!1:this.isColliding(jt.skuID,qt,Xt,Dt)}isColliding(_e,{position:Dt,rotation:Vt},Gt,zt=[]){const jt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene,Ht=this.stores.productDataStore.getState().productData;if(!jt)return!1;let Wt=jt.clone();Wt.position.set(Dt.x,Dt.y,Dt.z),Vt.isQuaternion===!0?Wt.setRotationFromQuaternion(Vt):Vt.isEuler===!0&&Wt.setRotationFromEuler(Vt);let qt=new Box3().setFromObject(Wt),Xt=new Vector3;qt.getCenter(Xt);let Kt=new Object3D;Kt.position.set(Xt.x,Xt.y,Xt.z),Kt.attach(Wt),Kt.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),qt=new Box3().setFromObject(Kt);const Yt=[];if(this._nodes.forEach(Jt=>{if(Gt.node.guid==Jt.guid||Array.isArray(zt)===!0&&zt.includes(Jt.guid)||!Jt.ref||(Ht[Jt.skuID].hasOwnProperty("disableCollider")?Ht[Jt.skuID].disableCollider:this.stores.coreSceneStore.getState().sceneSettings.disableCollider))return;const nn=Jt.ref.getObjectByName("GRP_ProxyMesh");nn&&Yt.push(nn)}),Yt.length<=0)return!1;let Zt=!1;return Yt.forEach(Jt=>{if(Zt)return;let nn=new Box3().setFromObject(Jt);if(qt.intersectsBox(nn)){Zt=!0;return}}),Kt.clear(),Wt=null,Kt=null,qt=null,Zt}boxOverlapPercent(_e,Dt){if(_e.containsBox(Dt)||Dt.containsBox(_e))return 100;if(!(_e.min.x<Dt.max.x||Dt.min.x<_e.max.x))return 0;let Vt=new Vector3(0,0,0);_e.getSize(Vt),Vt.x*Vt.y*Vt.z;let Gt=new Vector3(0,0,0);Dt.getSize(Gt),Gt.x*Gt.y*Gt.z}checkInsideOutCollision(_e,Dt,Vt){let Gt=Dt.position.clone(),zt=new Float32Array(Vt.attributes.position.array),jt=zt.length/3;for(let Ht=0;Ht<jt;Ht++){let Wt=new Vector3(zt[Ht*3],zt[Ht*3+1],zt[Ht*3+2]),qt=Wt.add(Dt.position);qt=Wt.applyQuaternion(Dt.quaternion);let Xt=qt.sub(Dt.position);const Yt=new Raycaster(Gt,Xt.clone().normalize()).intersectObjects(_e),Zt=Yt.length>0,Jt=Yt[0].distance<Xt.length();if(Zt&&Jt)return!0}return!1}addNode(_e){this._nodes.push(_e)}getFirstNodeByCategoryID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt]._categoryID==_e)return this._nodes[Dt];return null}getNodesBySKUID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt].skuID==_e&&Dt.push(this._nodes[Vt]);return Dt}getNodesByCategoryID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt]._categoryID==_e&&Dt.push(this._nodes[Vt]);return Dt}async connectPlugs({incomingPlug:_e,receiverPlug:Dt}){_e.attachPlug(Dt,!1),Dt.attachPlug(_e,!0),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}removeNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e){this._nodes[Dt].removeNode(),this._nodes.splice(Dt,1);break}this._nodes.length==1&&this.#t&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,!0),this.stores.attachmentStore.getState().actions.updateFittingSkuIds(),this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}async removeNodeFromStructure(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e.guid){this._nodes.splice(Dt,1);break}await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(_e){this._globalVariants={},this._globalGeometryVariants={},this.stores=_e,this.stores.productDataStore.getState().categoryData.geometryVariants.map(Dt=>{this._globalGeometryVariants[Dt.id]=Dt.defaultVariant}),this.stores.productDataStore.getState().categoryData.color.map(Dt=>{this._globalVariants[Dt.id]=Dt.defaultLook}),this._currentStructure=new Structure(this.stores,null,this._globalVariants,this._globalGeometryVariants);for(const[Dt,Vt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Dt,Vt);for(const[Dt,Vt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Dt,Vt)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(_e,Dt){let Vt;return Vt=this.stores.productDataStore.getState()?.productData[_e]?.lookDetails[Dt],Vt?.clientProductId?Vt?.clientProductId:""}getCartItems(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,Ht.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)});let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt}}}async getCartItemsAsync(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,qt.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)}),_e=await this.stores.dynamicHookStore.getState().hookOnCartItemsCollected(_e,this.stores.coreSceneStore.getState().CORE_API);let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt.toFixed(2)}}}async getFittingSKUIDs(){if(!this.currentStructure)return[];const{productData:_e}=this.stores.productDataStore.getState(),{sceneSettings:Dt}=this.stores.coreSceneStore.getState(),{draggableUI:Vt,ignoreSpawningCollision:Gt}=Dt;if(!this.currentStructure)return[];const{openPlugTypes:zt,closedPlugTypes:jt,existingSkuids:Ht}=this.analyzeCurrentStructure();if(zt.size===0&&jt.size===0)return[];const Wt=this.findFittingSkuids(_e,zt,jt,Ht,Vt);return this.filterNonBlockedSkuids(Wt,_e,Gt)}analyzeCurrentStructure(){const _e=this.currentStructure.nodes,Dt=new Set,Vt=new Set,Gt=new Set;for(const zt of _e){Gt.add(zt.skuID);for(const jt of zt.plugs)jt.isOpen?jt.acceptedPlugTypes.forEach(Ht=>Dt.add(Ht)):jt.attachedPlug.node.replace&&jt.acceptedPlugTypes.forEach(Ht=>Vt.add(Ht))}return{openPlugTypes:Dt,closedPlugTypes:Vt,existingSkuids:Gt}}findFittingSkuids(_e,Dt,Vt,Gt,zt){const jt=new Set;for(const[Ht,Wt]of Object.entries(_e))if(Wt.plugs)for(const qt of Wt.plugs){for(const Xt of qt.connectsToPlugTypes)if((this.isClosedPlugFitting(Ht,Wt,Xt,Vt,Gt,zt)||this.isOpenPlugFitting(Wt,Xt,Dt))&&jt.add(Ht),jt.has(Ht))break;if(jt.has(Ht))break}return jt}isClosedPlugFitting(_e,Dt,Vt,Gt,zt,jt){if(!Gt.has(Vt)||!jt&&zt.has(_e))return!1;const Ht=this.currentStructure.getNodesByCategoryID(Dt.categoryID);for(const Wt of Ht)if(Wt.skuID!==_e&&this.isNodeCompatible(Wt,Dt))return!0;return!1}isNodeCompatible(_e,Dt){let Vt=!1;for(const Gt of _e.plugs)if(!Gt.isOpen&&Gt.isReceiverPlug&&(Vt=!0,this.isPlugCompatible(Gt,Dt.plugs)))return!0;return!Vt}isPlugCompatible(_e,Dt){return Dt.some(Vt=>Vt.name===_e.name&&_e.attachedPlug.connectsToPlugTypes.some(Gt=>Vt.acceptedPlugTypes.includes(Gt)))}isOpenPlugFitting(_e,Dt,Vt){if(!Vt.has(Dt))return!1;const Gt=this.currentStructure.getFirstNodeByCategoryID(_e.categoryID);return!Gt||!Gt.replace}async filterNonBlockedSkuids(_e,Dt,Vt){const Gt=[];for(const zt of _e)if(Dt[zt].replace)Gt.push(zt);else{const jt=await this.currentStructure.findGhostTransforms(zt,Vt);jt&&jt.transforms.length>0&&Gt.push(zt)}return Gt}async removeAllVariantOverrides(){let _e=this._currentStructure.nodes,Dt=this.stores.productDataStore.getState().productData,Vt=this.stores.itemStore.getState().itemsSpawned;return await _e.map(async Gt=>{if(!Gt.overrideVariant||(Gt.overrideVariant=null,!Dt[Gt.skuID].looks))return;let zt=null;Object.keys(this._globalVariants).map(jt=>{Dt[Gt.skuID].looks.includes(this._globalVariants[jt])&&zt==null&&(zt=this._globalVariants[jt])}),zt&&await this.stores.itemStore.getState().actions.switchToVariant(Vt[Gt.guid].itemData,zt)}),this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1),!0}async switchGlobalGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Yt=>{Yt.id==_e&&(zt=Yt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;let Xt=this.stores.productDataStore.getState().categoryData;Wt.map(Yt=>{jt.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{Yt==nn&&(Jt=!0)}),Jt&&Xt.build.map(nn=>{Zt.products.map(rn=>{nn.skus.map((Qt,en)=>{nn.skus[en]==rn&&(nn.skus[en]=Yt)})})})})}),this._currentStructure.nodes.map(Yt=>{jt.map(Zt=>{Zt.products.map(Jt=>{Yt.skuID==Jt&&Yt.ref!==null&&Zt.products.map(nn=>{Wt.map(rn=>{if(rn==nn){const Qt=this.stores.productDataStore.getState().actions.getProductDataById(rn);let en=Qt.geometriesToHide;Yt.plugs.map(sn=>{!sn.isOpen&&sn.attachedPlug&&sn.type=="weighted_hider"&&sn.attachedPlug.weight>sn.weight&&(en=en.concat(sn.affectedNodes))}),Yt.showNodes(Qt.geometriesToShow),Yt.hideNodes(en),Yt.skuID=rn;const tn=qt[Yt.guid];tn&&tn.itemData&&Object.keys(Qt).map(sn=>{tn.itemData[sn]=Qt[sn]}),Yt.resetInStock(),Yt.updatePricing()}})})})})}),this._globalGeometryVariants[_e]=Dt,this.stores.hotspotStore.getState().actions.checkHotspotHealth(),this.stores.inventoryStore.getState().actions.refreshInventory(qt),this.stores.productDataStore.setState({categoryData:Xt}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CategoryData_Updated,Xt),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const Kt=await this.getCartItemsAsync();Kt&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Kt)}async switchGlobalVariant(_e,Dt){this._globalVariants[_e]=Dt;const Vt=this.stores.itemStore.getState().actions;let Gt=this.stores.itemStore.getState().itemsSpawned;for(let Wt=0;Wt<Object.keys(Gt).length;Wt++){let qt=Gt[Object.keys(Gt)[Wt]];if(qt.itemData.looks&&qt.itemData.looks.includes(Dt)){let Xt=this._currentStructure.getNodeByGUID(qt.itemData.guid);Xt&&!Xt.overrideVariant&&await Vt.switchToVariant(qt.itemData,Dt)}}const zt=this.stores.productDataStore.getState().lookData;this.stores.lightStore.getState().actions.processLookEnvMapOverride(Dt);const jt=_e;Object.keys(Gt).length>0&&this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:jt.charAt(0).toUpperCase()+jt.slice(1)+" was successfully switched to "+zt[Dt].label+".",alertTime:3e3,alertType:"success",alertLabel:`${jt} Changed`,alertId:"materialVariantChanged"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),this.stores.itemStore.setState({variantChangeAlert:!this.stores.itemStore.getState().variantChangeAlert});const Ht=await this.getCartItemsAsync();Ht&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Ht)}async#t(_e){if(!_e)return;LOGGER.info({title:"Structure to load",details:_e}),delete this._currentStructure,this._globalVariants={..._e.globalVariants},this._globalGeometryVariants=_e.globalGeometryVariants?{..._e.globalGeometryVariants}:{};const Dt=[..._e.structure];this._currentStructure=new Structure(this.stores,Dt,this._globalVariants,this._globalGeometryVariants);for(const[Vt,Gt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Vt,Gt);for(const[Vt,Gt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Vt,Gt);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(Dt),LOGGER.info({title:"Structure Loaded."})}async loadStructure(_e){if(!_e)return;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),this.stores.coreSceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(_e),this.stores.coreSceneStore.getState().preconfigurationLoaded?this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide):this.stores.coreSceneStore.setState({preconfigurationLoaded:!0}),this.stores.coreSceneStore.getState().configurationLoadedOnRestart||this.stores.coreSceneStore.setState({configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.setState({configurationLoaded:!0}),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated();const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}export(){return{experienceId:this.stores.coreSceneStore.getState().CORE_API.experienceId,structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await this._currentStructure.clear(),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem();const _e=this.stores.attachmentStore.getState().defaultConfig;this.stores.coreSceneStore.setState({configurationLoaded:!1,configurationLoadedOnRestart:!1}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear(),await this.#t(_e),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated(),this.stores.coreSceneStore.setState({configurationLoaded:!0,configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide);const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}}const createAttachmentStore=kt=>{const _e=attachmentStoreCreator();return _e.setState({stores:kt}),_e},attachmentStoreCreator=()=>create((kt,_e)=>({stores:null,attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async Dt=>{const{actions:Vt,defaultConfig:Gt}=_e();LOGGER.info({title:"Initializing Attachment System!"});const zt=await new AttachmentSystem(Dt);kt({attachmentSystem:zt}),await Vt.updateFittingSkuIds(),await Vt.toggleStructureUpdated()},loadSavedStructureFromConfigID:async Dt=>{const{stores:Vt}=_e();LOGGER.info({title:"Fetching Structure Using ConfigID!"});let Gt="";Dt.length==20&&(Gt=FETCH_CONFIG_ENDPOINT_FB+Dt);let zt=null;return Gt!=""?zt=await getJSONFromEndpoint(Gt):zt=await Vt.nexusApiInstance.getExperienceSaveAndShare(Vt.experienceId,Dt),zt.success===!1?null:Dt.length==20?zt.data:zt.payload.save_data},loadDefaultStructure:async()=>{const{actions:Dt,defaultConfig:Vt}=_e();LOGGER.info({title:"Loading Default Structure!"}),await Dt.loadStructure(Vt)},updateFittingSkuIds:async()=>{const{stores:Dt,attachmentSystem:Vt}=_e();if(!Dt.coreSceneStore.getState().preconfigurationLoaded||!Dt.coreSceneStore.getState().configurationLoaded)return;const Gt=await Vt.getFittingSKUIDs();Gt&&(Dt.itemStore.setState({fittingSkuIds:[...Gt]}),Dt.coreSceneStore.getState().CORE_API.fireEvent(Dt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:Gt}))},toggleStructureUpdated:async()=>{const{attachmentSystem:Dt,stores:Vt}=_e();if(kt(zt=>({structureUpdated:!zt.structureUpdated})),!Vt.coreSceneStore.getState().preconfigurationLoaded||!Vt.coreSceneStore.getState().configurationLoaded)return;Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,Dt.currentStructure.getCurrentItemsInReplaceableCategory());const Gt=await Dt.getCartItemsAsync();Gt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Gt)},loadStructure:async Dt=>{const{attachmentSystem:Vt,stores:Gt}=_e();LOGGER.info({title:"Loading Structure!"}),Vt&&Gt.coreSceneStore.getState().configurationLoaded!==!1&&await Vt.loadStructure(Dt)},export:()=>{const{attachmentSystem:Dt}=_e();if(Dt)return Dt.export()}}})),createInfoStore=kt=>{const _e=infoStoreCreator();return _e.setState({stores:kt}),_e},infoStoreCreator=()=>create((kt,_e)=>({stores:null,infoObject:{},populateInfoObject:Dt=>{kt(Vt=>({infoObject:Dt}))},infoModalOpen:!1,updateInfoModalOpen:Dt=>{kt(Vt=>({infoModalOpen:Dt}))}})),createUIHotspotStore=kt=>{const _e=uiHotspotStoreCreator();return _e.setState({stores:kt}),_e},uiHotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,activeFeatureID:"",actions:{enterHotspotInFeaturesTab(Vt){const{stores:Gt}=_e();Gt.uiSceneStore.getState().sideMenuState!==2&&Gt.uiSceneStore.setState({sideMenuState:2}),kt({activeFeatureID:Vt})},exitHotspot(){kt({activeFeatureID:null})}}})),createColorStore=kt=>{const _e=colorStoreCreator();return _e.setState({stores:kt}),_e},colorStoreCreator=()=>create((kt,_e)=>({stores:null,allActiveVariants:{},allActiveGeometryVariants:{}})),arrayWithoutElementAtIndex=function(kt,_e){return kt.filter(function(Dt,Vt){return _e!==Vt})},updateQuantityAtIndex=function(kt,_e,Dt){let Vt=kt.slice();return Vt[_e].quantity=Dt,Vt},createCartStore=kt=>{const _e=cartStoreCreator();return _e.setState({stores:kt}),_e},cartStoreCreator=()=>create((kt,_e)=>({stores:null,cart:[],cartTotalPrice:0,cartTotalCompareAtPrice:0,deleteCartItem:Dt=>{kt(Vt=>({cart:arrayWithoutElementAtIndex(Vt.cart,Dt)}))},addToCart:Dt=>{kt(Vt=>({cart:[...Vt.cart,Dt]}))},updateQuantity:(Dt,Vt)=>{kt(Gt=>({cart:updateQuantityAtIndex(Gt.cart,Dt,Vt)}))},previewCartModalOpen:!1,togglePreviewCartModal:()=>{const{previewCartModalOpen:Dt,stores:Vt}=_e();Dt===!0?(Vt.uiSceneStore.getState().CORE_API.reviewCartHidden(),kt({previewCartModalOpen:!1,previewCartMinimized:!1})):(Vt.uiSceneStore.getState().CORE_API.reviewCartShown(),kt({previewCartModalOpen:!0}))},previewCartMinimized:!1,togglePreviewCartMinimized:()=>{const{previewCartMinimized:Dt,stores:Vt}=_e(),Gt=!Dt;kt({previewCartMinimized:Gt}),Vt&&Vt.uiSceneStore&&Vt.uiSceneStore.getState().setSideMenuOpen(!Gt)},actions:{setCartTotalPrice:(Dt,Vt)=>{kt(()=>({cartTotalPrice:Dt,cartTotalCompareAtPrice:Vt}))}}})),createLightStore=kt=>{const _e=lightStoreCreator();return _e.setState({stores:kt}),_e},lightStoreCreator=()=>create((kt,_e)=>({stores:null,defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:Dt=>{kt(Vt=>({envMapUrl:Dt}))},processLookEnvMapOverride:Dt=>{const{envMapUrl:Vt,defaultEnvMapUrl:Gt,actions:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().lookData[Dt],Wt=Ht?.envMapOverride;if(!Ht||!Wt){zt.setEnvLightMap(Gt);return}if(Wt===Vt){LOGGER.info({title:`New Env Map Url is the same as the current ${Wt}`});return}zt.setEnvLightMap(Wt)}}})),createHotspotStore=kt=>{const _e=hotspotStoreCreator();return _e.setState({stores:kt}),_e},hotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>kt({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(Dt){const{hotspotsSpawned:Vt}=_e();Object.keys(Vt).map(Gt=>{Vt[Gt].itemData.guid==Dt.itemData.guid&&delete Vt[Gt]}),kt({hotspotsSpawned:{...Vt}})},checkHotspotHealth(){const{hotspotsHealthCheck:Dt}=_e();kt({hotspotsHealthCheck:!Dt})},toggleHotspotVisibility(){const{hotspotsVisibility:Dt}=_e();kt({hotspotsVisibility:!Dt})},switchHotspotsVisibility(Dt,Vt=!1){kt(Vt===!0?{hotspotsTempVisibility:Dt}:{hotspotsVisibility:Dt})},clickHotspot(Dt,Vt,Gt,zt=!1){const{activeHotspotData:jt,stores:Ht}=_e();kt({lastActiveHotspotData:jt}),hotspotEnter(Ht,Dt,Vt,Gt);let qt=Ht.itemStore.getState().itemsSpawned[Gt].itemData.skuID;zt===!1&&(Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(qt,Dt),hotspot:jt}),Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(Dt=!1){const{activeHotspotData:Vt,isAnyHotspotActive:Gt,stores:zt}=_e();if(Gt&&kt({isAnyHotspotActive:!1}),!!Vt&&(kt({lastActiveHotspotData:Vt}),hotspotExit(zt),Dt===!1)){const jt=Math.round((performance.now()-_e().lastActiveHotspotData.hotspotEnterTime)/1e3);zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:_e().lastActiveHotspotData,hotspotTimeSpent:jt}),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(kt){kt.hotspotStore.setState({activeHotspotData:null}),kt.coreSceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(kt,_e,Dt,Vt){let Gt=kt.hotspotStore.getState();const jt=kt.itemStore.getState().itemsSpawned;let Ht=Gt.visitedHotspotsID;const Wt=jt[Vt].hotspotsData.filter(un=>un.hotspotID==_e);if(!Wt||Wt.length<=0)return;const qt=Wt[0],Xt=jt[Vt].itemData.skuID+"_"+_e;let Yt=kt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Vt),Zt=new Vector3(0,0,0);Yt&&Yt.ref&&Yt.ref.getWorldPosition(Zt);let Jt=new Quaternion().identity();Yt&&Yt.ref&&Yt.ref.getWorldQuaternion(Jt);let nn=qt.focusPointTransform,rn=ArrToVec3(nn);rn.applyQuaternion(Jt);let Qt=qt.viewPointTransform,en=ArrToVec3(Qt);en.applyQuaternion(Jt);let tn=addVector(Vec3ToArr(rn),Vec3ToArr(Zt)),sn=addVector(Vec3ToArr(en),Vec3ToArr(Zt));kt.cameraStore.setState({focusPointPosition:tn,viewPointPosition:sn}),kt.hotspotStore.setState({activeHotspotData:{hotspotData:{guid:Dt,...qt},itemData:{...jt[Vt],guid:Vt},domID:"rd_"+Xt,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),Ht.includes(Xt)||(Ht.push(Xt),kt.hotspotStore.setState({visitedIDs:{...Ht}}))}var replacingNodes=null,swappableNodes=[];const createGhostStore=kt=>{const _e=ghostStoreCreator();return _e.setState({stores:kt}),_e},ghostStoreCreator=()=>create((kt,_e)=>({stores:null,ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(Dt,Vt=!1,Gt)=>{const{ghostData:zt,ghostsTransform:jt,stores:Ht}=_e();if(zt!==null||jt.length>0){LOGGER.info({title:"ghosts are already spawned for: "+zt.skuID});return}return await new Promise(async(qt,Xt)=>{let Kt={};const Yt=()=>{qt(Kt)};Ht.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Ghost_Loaded,Yt,{once:!0});const Zt=Ht.productDataStore.getState().productData,Jt=Ht.attachmentStore.getState().attachmentSystem.currentStructure;replacingNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const nn=Ht.coreSceneStore.getState().sceneSettings.draggableUI,rn=await Jt.findGhostTransforms(Dt,Vt),Qt=nn?rn&&rn.transforms&&rn.transforms.length===0:!0;if(Zt[Dt].replace&&replacingNodes.length>0&&Qt)if(nn){const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null||cn==null||sn.length<=0){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null&&cn==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{transforms:tn,newNodes:sn,connectablePlugs:cn,comboPlugs:un}=rn;let hn=tn,fn=cn,pn=sn,dn=[];for(let mn=0;mn<tn.length;mn++)dn.push("add");if(Zt[Dt].swappable&&!Ht.coreSceneStore.getState().dragging){swappableNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const mn=await Jt.findGhostTransformForReplacement(Dt,swappableNodes);if(mn.transforms)for(let vn=0;vn<mn.transforms.length;vn++)hn.push(mn.transforms[vn]),fn.push(mn.connectablePlugs[vn]),pn.push(mn.newNodes[vn]),dn.push("replace"),mn.newNodes[vn].setModelVisibility(!1)}Kt.transforms=hn,Kt.newNodes=pn,Kt.connectablePlugs=fn,Kt.comboPlugs=un,Kt.addItemOrSwap=dn}if(Kt.transforms.length<=0){Xt();return}const en=await Ht.assetStore.getState().actions.loadProxyAsset(Dt,!0);kt({ghostsTransform:Kt.transforms,ghostData:{proxyScene:en.proxy.data.scene,skuID:Dt,newNodes:Kt.newNodes,addItemOrSwap:Kt.addItemOrSwap,connectablePlugs:Kt.connectablePlugs,comboPlugs:Kt.comboPlugs,count:Gt||Kt.transforms.length}})})},clearAllGhosts:()=>{const{ghostsTransform:Dt}=_e();if(replacingNodes)for(const Vt of replacingNodes)Vt.setModelVisibility(!0);if(swappableNodes)for(let Vt=0;Vt<swappableNodes.length;Vt++)swappableNodes[Vt].setModelVisibility(!0);Dt.length<=0||kt({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),createCameraStore=kt=>{const _e=cameraStoreCreator();return _e.setState({stores:kt}),_e},cameraStoreCreator=()=>create((kt,_e)=>({stores:null,focusPointPosition:new Vector3(0,0,0),sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,cameraControlsRef:null,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{canCameraRotate:Dt=>{const{cameraControlsRef:Vt}=_e();Vt&&(Dt===!0?(Vt.mouseButtons.left=CAMERA_ACTION.ROTATE,Vt.touches.one=CAMERA_ACTION.TOUCH_ROTATE):(Vt.mouseButtons.left=CAMERA_ACTION.NONE,Vt.touches.one=CAMERA_ACTION.NONE))},triggerFetchingCamera:()=>{kt(Dt=>({sendCameraDetailsTrigger:!Dt.sendCameraDetailsTrigger}))},setCameraSettings:Dt=>{const{cameraSettings:Vt,stores:Gt}=_e();Gt.coreSceneStore.getState().isMobile===!0&&Dt.zoomingMultiplier_mobile!==void 0?Dt.zoomingMultiplier=Dt.zoomingMultiplier_mobile:Dt.zoomingMultiplier_desktop!==void 0&&(Dt.zoomingMultiplier=Dt.zoomingMultiplier_desktop),Object.keys(Dt).map(jt=>Vt[jt]=Dt[jt]),kt({cameraSettings:{...Vt},viewPointPosition:ArrToVec3(Vt.initialViewPointPosition)})}}})),createUISceneStore=kt=>{const _e=uiSceneStoreCreator();return _e.setState({stores:kt}),_e},uiSceneStoreCreator=()=>create((kt,_e)=>({stores:null,CORE_API:null,sideMenuState:0,sideMenuOpen:!0,setSideMenuOpen:Dt=>kt({sideMenuOpen:Dt}),cssLoaded:!1,isScreenPortrait:!0,materialOverrideExists:!1,tabSpawnCount:[],coreWCRef:null,removeModalOpen:!1,outOfStockModalOpen:!1,disableCart:!1,inventoryData:{},cartMessage:"",loadConfigId:"",dialogPopupOpen:!1,viewInYourSpaceMenuBtnVisible:!1,loadConfigModalOpen:!1,setLoadConfigModalOpen:Dt=>kt({loadConfigModalOpen:Dt}),setOutOfStockModalOpen:Dt=>kt({outOfStockModalOpen:Dt}),setRemoveModalOpen:Dt=>kt({removeModalOpen:Dt}),moveModalOpen:!1,setMoveModalOpen:Dt=>kt({moveModalOpen:Dt}),setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},setSideMenuState:Dt=>{kt(()=>({sideMenuState:Dt}));const{CORE_API:Vt}=_e();Dt!==2?Vt.exitHotspot():Vt.showAllHotspots()}})),createDynamicHookStore=kt=>{const _e=dynamicHookStoreCreator();return _e.setState({stores:kt}),_e},dynamicHookStoreCreator=()=>create((kt,_e)=>({hookOnCartItemsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnCartItemsCollected"}),Promise.resolve(Dt)),hookOnSceneItemsUpdated:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemsUpdated"}),Promise.resolve()),hookOnNewItemGhostsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnNewItemGhostsCollectedForReplacement:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnSceneItemAdded:async(Dt,Vt,Gt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve()),hookOnCheckout:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve(Dt))}));class STORES{experienceId="";uuid=null;wcRef=null;nexusApiResponseEnvironment="production";nexusApiInstance=null;productDataStore=null;coreSceneStore=null;inventoryStore=null;itemStore=null;assetStore=null;attachmentStore=null;lightStore=null;hotspotStore=null;ghostStore=null;cameraStore=null;infoStore=null;uiHotspotStore=null;colorStore=null;cartStore=null;uiSceneStore=null;constructor(_e){this.wcRef=_e,this.uuid=v4(),this.dynamicHookStore=createDynamicHookStore(this),this.productDataStore=createProductDataStore(this),this.coreSceneStore=createCoreSceneStore(this),this.inventoryStore=createInventoryStore(this),this.itemStore=createItemStore(this),this.assetStore=createAssetStore(this),this.attachmentStore=createAttachmentStore(this),this.lightStore=createLightStore(this),this.hotspotStore=createHotspotStore(this),this.ghostStore=createGhostStore(this),this.cameraStore=createCameraStore(this),this.infoStore=createInfoStore(this),this.uiHotspotStore=createUIHotspotStore(this),this.colorStore=createColorStore(this),this.cartStore=createCartStore(this),this.uiSceneStore=createUISceneStore(this)}setupNexusApiInstance(_e){let Dt=p$5.PRODUCTION;_e=="local"?Dt=p$5.LOCAL:_e==="staging"&&(Dt=p$5.STAGING);const Vt=window.location.href,Gt=window.epigraph?window.epigraph.epigraphSessionId:"no-session-id",zt="2.2.2",jt=g$3.generateXPath(this.wcRef);this.nexusApiInstance=new P$2(Dt,Vt,Gt,zt,jt)}}class EpigraphConfigurator extends h$5{#t=void 0;#i=null;#n=null;clientAccessKey=null;validationPassed=!1;projectID="";configID="default";customVersionId="";experienceId="";apiMode="production";gaMeasurementId="";#s=getUrlParameterByName("launchInAR")==="true";#r=!1;api={core:null,ui:null};stores=null;constructor(){let _e=s$2.PRODUCTION;super("2.2.2",_e),this.stores=new STORES(this),this.api.ui=this,this.shadowRoot||this.attachShadow({mode:"open"}),this.hasAttribute("launch-in-ar")&&(this.#s=!0),this.#c(),this.#o()}#c(){this.preloadDiv=document.createElement("div"),this.preloadDiv.id="preloadMainContainer",this.preloadDiv.classList.add("preload-main-container"),this.preloadDiv.classList.add("showPreload"),this.preloadDiv.appendChild(PRELOAD_MUTED_CSS.content.cloneNode(!0)),this.preloadDiv.appendChild(PRELOAD_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.preloadDiv);const _e=this.shadowRoot;this.#n=Dt=>{if(Dt.code=="Enter"){let Vt=_e.activeElement;Vt&&Vt.click()}},this.shadowRoot.addEventListener("keyup",this.#n)}#o(){this.hiccupUi=document.createElement("div"),this.hiccupUi.id="hiccupMainContainer",this.hiccupUi.classList.add("hiccup-ui-main-container"),this.hiccupUi.appendChild(HICCUP_MUTED_CSS.content.cloneNode(!0)),this.hiccupUi.appendChild(HICCUP_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.hiccupUi)}get configuratorWcId(){return this.#t}get launchInAr(){return this.#s}#a(){if(this.hasAttribute("id")?this.#t=this.getAttribute("id"):(this.setAttribute("id","epigraphConfiguratorWc"),this.#t=this.getAttribute("id")),this.hasAttribute("custom-version-id")&&(this.customVersionId=this.getAttribute("custom-version-id")),this.hasAttribute("experience-id")&&(this.experienceId=this.getAttribute("experience-id")),this.hasAttribute("api-mode")){const _e=this.getAttribute("api-mode");["local","staging","production"].includes(_e)&&(this.apiMode=_e)}this.stores.setupNexusApiInstance(this.apiMode),(this.hasAttribute("ga-measurement-id")||this.hasAttribute("ga-code"))&&(this.gaMeasurementId=this.getAttribute("ga-measurement-id")??this.getAttribute("ga-code")),this.clientAccessKey=this.getAttribute("client-access-key"),this.initialConfigId=this.getAttribute("initial-config-id"),this.consentPlugin=this.getAttribute("consent-plugin"),this.consentIdentifier=this.getAttribute("consent-identifier"),this.initialConfigId||(this.initialConfigId="default")}async connectedCallback(){if(this.#r===!0){console.warn("Tried to remount configurator. Blocking the process.");return}this.#a(),this.style.maxWidth="1440px",this.style.maxHeight="800px",this.style.overflow="hidden",this.style.width="100%",this.style.height="100%",this.style.position="relative",this.style.visibility="visible",this.style.display="flex";const _e=document.createElement("div");_e.id="configuratorContainer",_e.style.width="100%",_e.style.height="100%",_e.style.userSelect="none",_e.style.overflow="hidden",this.shadowRoot.appendChild(_e),this.#i=createRoot(_e),this.#i.render(jsxRuntimeExports.jsx(App,{stores:this.stores,customVersionId:this.customVersionId,experienceId:this.experienceId,disableUI:this.hasAttribute("disable-ui"),disableCart:this.hasAttribute("disable-cart"),configuratorWcRef:this,gaMeasurementId:this.gaMeasurementId},"Configurator-App")),this.#r=!0}disconnectedCallback(){for(this.#i&&(this.#i.unmount(),this.#i=null),this.#n&&(this.shadowRoot.removeEventListener("keyup",this.#n),this.#n=null),this.#t=void 0,this.clientAccessKey=null,this.validationPassed=!1,this.projectID="",this.configID="default",this.customVersionId="",this.gaMeasurementId="",this.#s=!1,this.#r=!1,this.api={core:null,ui:null},this.preloadDiv&&(this.preloadDiv.remove(),this.preloadDiv=null),this.hiccupUi&&(this.hiccupUi.remove(),this.hiccupUi=null);this.shadowRoot.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild)}showPreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("no-pointer-events"),this.preloadDiv.classList.add("showPreload"))}async hidePreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("showPreload"),await wait(1e3),this.preloadDiv.classList.add("no-pointer-events"))}showHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("no-pointer-events"),this.hiccupUi.classList.add("show-hiccup"))}async hideHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("show-hiccup"),await wait(1e3),this.hiccupUi.classList.add("no-pointer-events"))}}window.customElements.define("epigraph-configurator",EpigraphConfigurator);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epigraph/configurator",
3
- "version": "2.2.1-alpha.1",
3
+ "version": "2.2.2",
4
4
  "description": "Epigraph Configurator web component.",
5
5
  "keywords": [],
6
6
  "main": "./dist/index.js",