@liveroom-tech/react-immersive 6.1.2 → 6.1.3

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 (41) hide show
  1. package/dist/{SequencesTab-JTIVIZJD.mjs → SequencesTab-66VBWTO5.mjs} +1 -1
  2. package/dist/binding-builder.css +1 -1
  3. package/dist/binding-builder.d.mts +3 -3
  4. package/dist/binding-builder.d.ts +3 -3
  5. package/dist/binding-builder.js +75 -34
  6. package/dist/binding-builder.mjs +1 -1
  7. package/dist/{chunk-DS5XNP7A.mjs → chunk-4RYMXBK6.mjs} +1 -1
  8. package/dist/chunk-5P7ETEAN.mjs +50 -0
  9. package/dist/{chunk-W7M2YD65.mjs → chunk-B75URXOE.mjs} +1 -1
  10. package/dist/chunk-EC542N4J.mjs +1 -0
  11. package/dist/{chunk-XBVAZFXW.mjs → chunk-JK7GRGRG.mjs} +1 -1
  12. package/dist/{chunk-5XII5XCD.mjs → chunk-LKKH4PO7.mjs} +1 -1
  13. package/dist/{chunk-35UERL2D.mjs → chunk-U3BQMOC3.mjs} +19 -19
  14. package/dist/{chunk-WJIICFV4.mjs → chunk-VMYNX63T.mjs} +2 -2
  15. package/dist/hosted.css +1 -1
  16. package/dist/hosted.d.mts +3 -3
  17. package/dist/hosted.d.ts +3 -3
  18. package/dist/hosted.js +74 -33
  19. package/dist/hosted.mjs +1 -1
  20. package/dist/index.css +1 -1
  21. package/dist/index.d.mts +4 -4
  22. package/dist/index.d.ts +4 -4
  23. package/dist/index.js +72 -31
  24. package/dist/index.mjs +1 -1
  25. package/dist/{modelFileResolver-pPzMl63D.d.mts → modelFileResolver-B2B3F3d1.d.mts} +1 -0
  26. package/dist/{modelFileResolver-pPzMl63D.d.ts → modelFileResolver-B2B3F3d1.d.ts} +1 -0
  27. package/dist/{modelViewerProps-07WgBVqm.d.ts → modelViewerProps-Bo48RDq6.d.ts} +1 -1
  28. package/dist/{modelViewerProps-CGgtm4Zb.d.mts → modelViewerProps-DkvYb1GH.d.mts} +1 -1
  29. package/dist/{publicProps-CEt3hxQU.d.ts → publicProps-DJSccx3b.d.ts} +1 -1
  30. package/dist/{publicProps-BylAVwPu.d.mts → publicProps-DN0-8tBm.d.mts} +1 -1
  31. package/dist/simple-model-viewer.d.mts +2 -2
  32. package/dist/simple-model-viewer.d.ts +2 -2
  33. package/dist/simple-model-viewer.js +1 -1
  34. package/dist/simple-model-viewer.mjs +1 -1
  35. package/dist/utils.d.mts +4 -4
  36. package/dist/utils.d.ts +4 -4
  37. package/dist/utils.js +50 -9
  38. package/dist/utils.mjs +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-M4LVNNVP.mjs +0 -1
  41. package/dist/chunk-Q4QPI5GG.mjs +0 -9
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{a as ce,b as se,c as pe}from"./chunk-F5QSXMME.mjs";import{Aa as Q,Fa as J,Ga as Y,Ia as Z,Ma as te,N as a,Na as oe,O as c,Oa as ne,P as s,Pa as re,Q as p,Qa as ie,Ua as ae,V as u,Wa as ue,X as d,Xa as de,Y as m,Ya as me,Za as Se,_a as le,ga as S,ia as l,ka as f,la as g,ma as C,na as y,oa as x,pa as P,qa as A,ra as H,sa as F,ta as K,ua as W,za as z}from"./chunk-Q4QPI5GG.mjs";import{b as $,c as ee}from"./chunk-CCBFMNAU.mjs";import"./chunk-7OWHW66D.mjs";import{a as e,b as t,e as o,f as n,g as r}from"./chunk-LX3GXQNU.mjs";import{b,c as E,d as h,e as j,f as R,g as T,h as V,i as I,j as L,k as w,l as D,m as _,n as N,o as q,p as k,q as v,r as U,s as G}from"./chunk-7JCFNZJM.mjs";import{b as O,c as B}from"./chunk-GV4ZRXL6.mjs";import{E as X}from"./chunk-6Q6YZ7O5.mjs";import{a as i}from"./chunk-M4LVNNVP.mjs";import{c as M}from"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";export{Y as ACTION_CATALOG,i as DEFAULT_MODEL_VIEWER_LABELS,c as DEFAULT_SCENE_CONFIG,a as DEFAULT_SECTION_CONFIG,de as MATERIAL_BLENDING_MODES,ue as MATERIAL_SIDES,H as MAX_VIEWER_STATE_BYTES,S as MEASUREMENT_UNITS,t as SEQUENCE_EASINGS,e as SEQUENCE_OBJECT_PROPERTIES,oe as applyIsolation,G as applyProductOptions,ee as applyStyleRules,ie as buildBindingsFromNodes,f as calibrateMeasurements,M as chooseMaterialVariant,me as collectObjectHierarchy,$ as colorScaleValue,ae as compareViewerConfigurations,Se as copyBindingStyle,z as createARHandoffUrl,re as createDefaultBinding,D as decodeProductSelections,j as defaultProductSelections,pe as defineObjectBindings,w as encodeProductSelections,R as evaluateProductConfiguration,J as exportConfiguredUSDZ,Z as findCatalogAction,I as formatProductPrice,_ as generateProductSkus,m as groundAsset,ne as inferType,X as inspectAsset,te as isolatedBindingKeys,E as material,C as measurementResult,l as measurementScale,g as measurementValue,P as measurementsToCsv,u as parseAssetTransform,y as parseMeasurements,U as parseProductConfiguration,h as parseProductDefinition,k as parseSceneProduct,s as parseSectionConfig,A as parseSelectionSets,o as parseSequences,K as parseViewerState,le as pasteBindingStyle,b as patchBindings,ce as patchSceneConfig,W as prepareViewerState,L as productCheckoutUrl,N as productDefinitionWarnings,q as productOptionStates,V as productPriceFromDefinition,Q as readARHandoffUrl,T as resolveProductSelections,n as sampleSequenceTrack,se as sceneLight,p as sectionSnapshot,O as selectBindingKeys,B as selectBindings,x as serializeMeasurements,v as serializeProductConfiguration,F as serializeViewerState,d as snapAssetToGrid,r as upsertSequenceKeyframe};
1
+ import{a as ce,b as se,c as pe}from"./chunk-F5QSXMME.mjs";import{Aa as Q,Fa as J,Ga as Y,Ia as Z,Ma as te,N as a,Na as oe,O as c,Oa as ne,P as s,Pa as re,Q as p,Qa as ie,Ua as ae,V as u,Wa as ue,X as d,Xa as de,Y as m,Ya as me,Za as Se,_a as le,ga as S,ia as l,ka as f,la as g,ma as C,na as y,oa as x,pa as P,qa as A,ra as H,sa as F,ta as K,ua as W,za as z}from"./chunk-5P7ETEAN.mjs";import{b as $,c as ee}from"./chunk-CCBFMNAU.mjs";import"./chunk-7OWHW66D.mjs";import{a as e,b as t,e as o,f as n,g as r}from"./chunk-LX3GXQNU.mjs";import{b,c as E,d as h,e as j,f as R,g as T,h as V,i as I,j as L,k as w,l as D,m as _,n as N,o as q,p as k,q as v,r as U,s as G}from"./chunk-7JCFNZJM.mjs";import{b as O,c as B}from"./chunk-GV4ZRXL6.mjs";import{E as X}from"./chunk-6Q6YZ7O5.mjs";import{a as i}from"./chunk-EC542N4J.mjs";import{c as M}from"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";export{Y as ACTION_CATALOG,i as DEFAULT_MODEL_VIEWER_LABELS,c as DEFAULT_SCENE_CONFIG,a as DEFAULT_SECTION_CONFIG,de as MATERIAL_BLENDING_MODES,ue as MATERIAL_SIDES,H as MAX_VIEWER_STATE_BYTES,S as MEASUREMENT_UNITS,t as SEQUENCE_EASINGS,e as SEQUENCE_OBJECT_PROPERTIES,oe as applyIsolation,G as applyProductOptions,ee as applyStyleRules,ie as buildBindingsFromNodes,f as calibrateMeasurements,M as chooseMaterialVariant,me as collectObjectHierarchy,$ as colorScaleValue,ae as compareViewerConfigurations,Se as copyBindingStyle,z as createARHandoffUrl,re as createDefaultBinding,D as decodeProductSelections,j as defaultProductSelections,pe as defineObjectBindings,w as encodeProductSelections,R as evaluateProductConfiguration,J as exportConfiguredUSDZ,Z as findCatalogAction,I as formatProductPrice,_ as generateProductSkus,m as groundAsset,ne as inferType,X as inspectAsset,te as isolatedBindingKeys,E as material,C as measurementResult,l as measurementScale,g as measurementValue,P as measurementsToCsv,u as parseAssetTransform,y as parseMeasurements,U as parseProductConfiguration,h as parseProductDefinition,k as parseSceneProduct,s as parseSectionConfig,A as parseSelectionSets,o as parseSequences,K as parseViewerState,le as pasteBindingStyle,b as patchBindings,ce as patchSceneConfig,W as prepareViewerState,L as productCheckoutUrl,N as productDefinitionWarnings,q as productOptionStates,V as productPriceFromDefinition,Q as readARHandoffUrl,T as resolveProductSelections,n as sampleSequenceTrack,se as sceneLight,p as sectionSnapshot,O as selectBindingKeys,B as selectBindings,x as serializeMeasurements,v as serializeProductConfiguration,F as serializeViewerState,d as snapAssetToGrid,r as upsertSequenceKeyframe};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveroom-tech/react-immersive",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- var i={verifyingLicense:"Verifying License",checkingYourLicenseKey:"Checking your license key...",invalidLicense:"Invalid License",licenseHasBeenRevokedOrHasExpired:"License has been revoked or has expired",failedToLoadPleaseContactTheSiteAdministrator:"Failed to load. Please contact the site administrator.",contextRestoringTitle:"Reloading viewer\u2026",contextLostTitle:"3D view interrupted",contextRestoringMessage:"Rebuilding the 3D view. Please wait\u2026",contextLostMessage:"The graphics connection was interrupted. The viewer will rebuild when it returns, or you can reload it now.",reloadViewer:"Reload viewer",texturePositioningHint:"Drag to move \xB7 Scroll to zoom \xB7 Click elsewhere to finish",texturePositioningStartHint:"Double-click to move or zoom",dismiss:"Dismiss",missingUVsAreShownInMagenta:"Missing UVs are shown in magenta.",viewThisModelInARWithAppleQuickLook:"View this model in AR with Apple Quick Look",sequencePlayer:"Sequence player",sequenceSelect:"Sequence",sequencePlay:"Play sequence",sequencePause:"Pause sequence",sequenceStop:"Stop and restore scene",sequencePlayhead:"Sequence playhead",sequenceTime:"Sequence time",sequenceIssues:"Unavailable sequence targets",arConfiguredButton:"AR handoff",arConfiguredTitle:"Take this configuration to AR",arConfiguredDescription:"Your current materials, visible models and placements are included.",arSnapshotStale:"Updating AR to include your latest changes\u2026",arPreparing:"Preparing your scene\u2026",arStart:"Start AR",arStarting:"Starting AR\u2026",arCheckingSupport:"Checking AR support\u2026",arUnavailable:"AR is unavailable in this browser. Open this link in an AR-capable browser on your phone.",arStartFailed:"Could not start AR. Check camera permissions and try again.",arAnimations:"AR animations",arAnimationSelect:"Animation",arAnimationClips:"Model clips",arAnimationSequences:"Sequences",arAnimationPlay:"Play animation",arAnimationPause:"Pause animation",arRefresh:"Refresh AR",arRetry:"Try again",arExportDetails:"Export details",arPrepare:"Prepare AR",arPrepareAgain:"Prepare again",arDownloadUSDZ:"Download USDZ for iPhone/iPad",arScanConfigured:"Scan to open this configuration on your phone.",arOpenConfiguredLink:"Open configuration link",viewInAR:"View in AR",openThisExperienceOnAPhoneForAR:"Open this experience on a phone for AR",openOnPhone:"Open on phone",viewThisModelInYourSpace:"View this model in your space",viewThisModelInVR:"View this model in VR",closePhoneHandoff:"Close phone handoff",arScanCode:"Scan the code and choose AR.",qrCodeToOpenThisModelOnAPhone:"QR code to open this model on a phone",disableUVChecker:"Disable UV checker",enableUVChecker:"Enable UV checker",explodedView:"Exploded view",explodeAmount:"Explode amount",removeSectionCut:"Remove section cut",sectionCut:"Section cut",sectionAxis:"Section axis",sectionPosition:"Section position",keepTheOtherSide:"Keep the other side",pauseCinematic:"Pause cinematic",playCinematic:"Play cinematic",stopCinematicAndResetCamera:"Stop cinematic and reset camera",cancel:"Cancel",annotationCategories:"Annotation categories",annotations:"Annotations",all:"All",uncategorized:"Uncategorized",decalDragHint:"Drag the decal on the object. Release to save; Escape to cancel.",showAll:"Show all",materialVariants:"Material variants",startGuidedTour:"Start guided tour",guidedTour:"Guided Tour",previousAnnotation:"Previous annotation",previous:"Prev",stopGuidedTour:"Stop guided tour",nextAnnotation:"Next annotation",next:"Next",exitFullscreen:"Exit fullscreen",enterFullscreen:"Enter fullscreen",resetCameraView:"Reset camera view",orbitControl:"Orbit Control",pointLock:"Pointer lock",cameraController:"Camera controller",cameraControllerSettings:"Camera controller settings",downloadGLB:"Download GLB",downloadGLBDescription:"All visible models, material edits and animations in one file. No annotations or separate editor model slots. Duplicate mesh names may change on reimport.",downloadCombinedGLB:"Download as one GLB",downloadSeparateGLBs:"Download separate GLBs",downloadSeparateGLBsDescription:"One GLB file per model",downloadPNG:"Download PNG",downloadUVLayout:"Download UV Layout",videoFormat:"Video format",auto:"Auto",recordTurntableVideo:"Record turntable video",recordCinematicVideo:"Record cinematic video",videoUnsupported:"Video recording is not supported in this browser.",downloadOptions:"Download options",exporting:"Exporting\u2026",download:"Download",annotationTitlePlaceholder:"Title *",description:"Description",ok:"OK",arRelocate:"Relocate",tapToPlace:"Tap to place",closeAnnotation:"Close annotation",learnMore:"Learn more",stopMeasuring:"Stop measuring",startMeasuring:"Start measuring",toggleBoundingDimensions:"Toggle bounding dimensions",measurementTool:"Measurement tool",distance:"Distance",angle:"Angle",area:"Area",pointToPlane:"Point to plane",wrap:"Circumference (Edge)",wrapHorizontal:"Circumference (Horizontal)",measurementSnapping:"Measurement snapping",noSnapping:"No snapping",snapAuto:"Snap: auto",snapVertex:"Snap: vertex",snapEdge:"Snap: edge",undoMeasurementPoint:"Undo measurement point",clearMeasurements:"Clear measurements",finishArea:"Finish area",savedMeasurements:"Saved measurements ({count})",noSavedMeasurements:"No saved measurements yet. Pick points in the preview, then save a measurement here.",measurementFiles:"Import / export",measurementSourceUnit:"Model units",measurementDisplayUnit:"Display units",measurementName:"Name",measurementNamePlaceholder:"e.g. Door width",saveMeasurement:"Save",knownMeasurementDistance:"Known length",calibrationUnit:"Calibration unit",calibrateMeasurement:"Calibrate",measurementCalibrationHint:"Pick two distance points, enter their known length, then calibrate.",measurementCalibratedScale:"Calibrated: 1 model unit = {scale} m",resetMeasurementCalibration:"Reset calibration",showSavedMeasurement:"Show {name}",renameSavedMeasurement:"Rename {name}",deleteSavedMeasurement:"Delete {name}",exportMeasurementJson:"Export JSON",exportMeasurementCsv:"Export CSV",importMeasurementJson:"Import JSON",measurementReady:"Ready",measurementApproximate:"Approximate LOD",measurementModelChanged:"Different model",measurementObjectMissing:"Object unavailable",measurementGeometryChanged:"Geometry changed \u2014 measure again",measurementPoseChanged:"Pose changed \u2014 measure again",measurementObjectHidden:"Object hidden",measurementInvalid:"Invalid measurement",measurementWaiting:"Waiting for model",openSceneObjectsPanel:"Open scene objects panel",sceneObjects:"Scene Objects",searchNodesLabels:"Search nodes, labels",closeSceneObjectsPanel:"Close scene objects panel",objectNavigator:"Objects in the 3D view",compareBefore:"Before",compareAfter:"After",compareDivider:"Comparison divider",viewIn3D:"View in 3D",objectNavigatorHint:"Arrow keys browse \xB7 Enter selects \xB7 Esc clears",selectionCleared:"Selection cleared",cameraKeyboardHelp:"3D view. Arrow keys orbit, Shift with Up or Down zooms, and W, A, S, D, Space and C move the camera.",isolate:"Isolate",hide:"Hide",show:"Show",closePanel:"Close panel",actions:"Actions",openPanel:"Open panel",close:"Close",position:"Position",decalNudgeHint:"Click to fine-tune \xB7 Hold to move",decalNudgeControls:"Move decal in small steps",text:"Text",yourText:"Your text",textToAdd:"Text to add",textColour:"Text color",addText:"Add text",image:"Image",chooseImage:"Choose image",imageToAdd:"Image to add",added:"Added",colour:"Color",size:"Size",turn:"Turn",rotation:"Rotation",dragTheDecalAcrossTheObjectsSurface:"Drag the decal across the object's surface",move:"Move",remove:"Remove",noneAddedYet:"None added yet",done:"Done",moveForward:"Move forward",moveLeft:"Move left",moveRight:"Move right",moveBackward:"Move backward",productOptions:"Options",productOptionsFor:"{product} options",productReset:"Reset",productOptional:"optional",productNone:"None",productAlsoChanges:"Also changes: {changes}",productUnavailable:"Currently unavailable.",productQuantity:"Quantity",productCheckingPrice:"Checking price and availability\u2026",productTotal:"Total",productAddToCart:"Add to cart",productAddingToCart:"Adding\u2026",productRequestQuote:"Request quote",productRequestingQuote:"Requesting\u2026",productRefresh:"Refresh",productBuy:"Buy now",productCopyLink:"Copy link",productLinkCopied:"Link copied",productShowOptions:"Show options",productHideOptions:"Hide options",productIssues:"Configuration issues",productRequestDone:"Request completed.",productSaved:"Saved: {id}",sceneSettings:"Scene Settings",background:"Background",backgroundColor:"Background Color",showEnvironmentAsBackground:"Show as background",backgroundBlur:"Background Blur",environmentPreset:"Preset",environmentIntensity:"Intensity",toneMapping:"Tone Mapping",toneMappingAces:"ACES Filmic",toneMappingAgx:"AgX",toneMappingNeutral:"Neutral",toneMappingNone:"None",ground:"Ground",groundShadow:"Ground Shadow",groundShadowOpacity:"Shadow Opacity",floorGrid:"Floor Grid",display:"Display",wireframe:"Wireframe",autoRotateSpeed:"Rotation Speed",fieldOfView:"Field of View",modelInfo:"Model",modelInfoObjects:"Objects",modelInfoTriangles:"Triangles",modelInfoMaterials:"Materials",resetSettings:"Reset Settings",environment:"Environment",autoRotate:"Auto Rotate",lighting:"Lighting",exposure:"Exposure",ambientLightIntensity:"Ambient Light Intensity",ambientLightColor:"Ambient Light Color",directLightIntensity:"Direct Light Intensity",directLightColor:"Direct Light Color",searchObjects:"Search objects",uploadedModel:"Uploaded model",clear:"Clear",chooseModel:"Choose model",loadingModel:"Loading model...",releaseToLoadYourModel:"Release to load your model",arFindSurface:"Move your device over a flat surface",arReleaseToPlace:"Release to place",arGestureHint:"Pinch to resize \xB7 Twist to rotate",angleFirstArmHint:"Pick the first arm",angleVertexHint:"Pick the angle's vertex",angleSecondArmHint:"Pick the second arm",angleNewHint:"Pick a point to start a new angle",areaNewHint:"Pick a point to start a new area",areaCornersHint:"Pick polygon corners in order, then Finish area",pointToPlaneFaceHint:"Pick the reference face",pointToPlanePointHint:"Pick a point to measure its perpendicular distance",pointToPlaneNewHint:"Pick a face to start a new measurement",distanceHint:"Pick points on the model to measure distances",wrapHint:"Click a point on the surface to measure its circumference, following the surface (best for limbs)",wrapHorizontalHint:"Click a point to measure a level circumference around it (best for the torso/waist)",visibleEntries:"{count} visible entries",objectCount:"{count} objects",annotationMarker:"Annotation {id}: {title}",recordingVideo:"Recording video \xB7 {progress}%",isolatedObjects:"Isolated: {count} objects",largeModelWarning:"Very large model ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the objects panel to select parts.",preparingLargeModel:"Preparing large model ({millions}M triangles) \u2014 the first display can take a while on this device...",enterAR:"Enter AR",enterVR:"Enter VR",decalImage:"Image {index}",decalText:"Text {index}",decalAdded:"{count} added",up:"up",down:"down",left:"left",right:"right",moveDecal:"Move decal {direction}",moveDecalOnSurface:"Move {direction} on the visible surface",showAllObject:"Show all {name}",isolateObject:"Isolate {name}",isolatedObject:"Isolated: {name}",hideObject:"Hide {name}",showObject:"Show {name}",objectSelected:"{name} selected",objectNavigatorPosition:"{position} of {count}",compareDividerValue:"{before} {percent}%, {after} {rest}%",bindingMismatchOne:"1 object binding doesn't match this model",bindingMismatchMany:"{count} object bindings don't match this model",simpleLargeModelWarning:"Very large model detected ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts.",dropModelHint:"Drag and drop {formats} here",loadErrorTitle:"This model couldn't be loaded",loadErrorNotFound:"Nothing was found at this address ({status}). Check that modelUrl points to the file.",loadErrorDenied:"The server refused access to the file ({status}). Check that the file is public, or that a signed URL hasn't expired.",loadErrorStatus:"The server responded with {status} when the file was requested.",loadErrorNetwork:"The download was blocked or failed. Check that the URL is correct and, if the file is on another domain, that its server allows cross-origin requests (CORS) from this site.",loadErrorHtml:"The server sent back a web page instead of a model. There's probably no file at this path: many servers answer a missing file with their index.html.",loadErrorInvalidFile:"The file couldn't be read as {format}. Check that it's a valid {format} file.",loadErrorInvalidExplicitFormat:"The file couldn't be read as {format}. Check that it's a valid {format} file and that modelFormat matches it.",loadErrorMissingFormat:"The file couldn't be read as {format}. The URL has no file extension, so set modelFormat to the file's format.",loadErrorPointCloud:"This PLY file is a point cloud: it has points but no faces, and the viewer shows meshes. Turn it into a mesh first, for example with MeshLab or Blender.",measurementReferenceFaceRequired:"Pick a triangle face to define the reference plane.",measurementTooManyPoints:"Finish or clear this measurement before adding more points.",measurementAngleDistinct:"Pick a point away from the angle's vertex.",areaMinimumPoints:"Pick at least three points to finish the area.",areaDistinctPoints:"Area points must be distinct.",areaStraightLine:"Area points must not lie on one straight line.",areaNotPlanar:"Area points must lie on one plane.",areaEdgesCross:"Area edges must not cross or touch each other.",areaZero:"The polygon has no measurable area.",decalSurfaceMissing:"Could not find a surface on this object for the decal.",decalDirectionMissing:"No visible surface in that direction. Try another arrow or rotate the view.",fullscreenExitFailed:"Could not exit fullscreen. Press Escape to exit.",fullscreenEnterFailed:"Could not enter fullscreen. Check your browser or iframe fullscreen permissions and try again.",uvCoordinatesMissing:"This model does not contain UV coordinates.",uvExportFailed:"Could not create the UV layout archive.",videoExportFailed:"Could not export the video.",videoNotReady:"Viewer not ready for video export.",videoExitXR:"Exit the XR session before recording a video.",videoAlreadyRecording:"A video export is already in progress.",videoPathRequired:"Enable a cinematic camera path before recording it.",videoDurationInvalid:"Video duration must be greater than 0 and at most 300 seconds.",videoFrameRateInvalid:"Video frame rate must be between 1 and 60.",videoBitrateInvalid:"Video bitrate must be a positive number.",videoContextLost:"Video export stopped because the WebGL context was lost.",videoTimedOut:"Video export timed out. Keep the viewer tab visible while recording.",videoEncodingFailed:"The browser could not encode the video.",videoEmpty:"The browser produced an empty video.",videoDidNotStart:"Video recording did not start.",videoWebMUnsupported:"Video recording as WEBM is not supported in this browser.",videoMP4Unsupported:"Video recording as MP4 is not supported in this browser.",videoGIFUnsupported:"Video recording as GIF is not supported in this browser.",videoGifWidthInvalid:"GIF width must be a whole number of pixels from 16 to 4096.",environmentApartment:"apartment",environmentCity:"city",environmentDawn:"dawn",environmentForest:"forest",environmentLobby:"lobby",environmentNight:"night",environmentPark:"park",environmentStudio:"studio",environmentSunset:"sunset",environmentWarehouse:"warehouse",color:"Color",material:"Material",texturePreview:"texture preview",noTextureApplied:"No texture applied",noTextureCoordinates:"This part has no texture coordinates, so an image can't be placed on it.",replaceImage:"Replace image",uploadImage:"Upload image",removeTexture:"Remove texture",texturePosition:"Texture position",offsetX:"Offset X",offsetY:"Offset Y",confirmTexturePosition:"Confirm this texture position and exit positioning mode",donePositioning:"Done positioning",textureOffsetHint:"Double-click the object in the preview to drag its texture directly (scroll to zoom), or edit its offset numerically.",actionToggleLight:"Toggle Light",actionChangeLightColor:"Change Light Color",actionSetBrightness:"Set Brightness",actionChangeColor:"Change Color",actionChangeMaterial:"Change Material",actionToggleVisibility:"Toggle Visibility"};function r(o,e,t={}){return(o?.[e]??i[e]).replace(/\{(\w+)\}/g,(a,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):a)}var s=new Map(Object.entries(i).map(([o,e])=>[e,o]));function l(o,e){let t=s.get(e);return t?r(o,t):e}export{i as a,r as b,l as c};
@@ -1,9 +0,0 @@
1
- import{f as ct,h as lt}from"./chunk-7OWHW66D.mjs";import{e as xe,f as at}from"./chunk-LX3GXQNU.mjs";import{p as bt}from"./chunk-7JCFNZJM.mjs";import{a as st,b as Ce}from"./chunk-GV4ZRXL6.mjs";import{a as we,b as ut,c as dt,d as mt,e as ft,g as pt,h as gt,j as yt,x as Ae,z as ht}from"./chunk-6Q6YZ7O5.mjs";import{useCallback as H,useRef as se,useState as At}from"react";import{Vector3 as Mt}from"three";var Le=new WeakSet;function ae(e){Le.add(e)}function Ko(e){let t=Le.has(e);return t&&Le.delete(e),t}var De=new WeakSet;function Yo(e,t){t?De.add(e):De.delete(e)}function St(e,t){return De.has(e)?0:t}import{Box3 as xt,Matrix4 as Bn,PerspectiveCamera as wt,Vector3 as Ue}from"three";function er(e,t){let n=ct(e);if(!(e.camera instanceof wt)||!t)return n;let o=t instanceof xt?t:new xt().setFromObject(t);return o.isEmpty()||(n.framing={aspect:e.camera.aspect,min:o.min.toArray(),max:o.max.toArray()}),n}function Ct(e,t){let n=t.camera,o=e.framing;if(!(n instanceof wt)||!o||!(n.aspect>0)||Math.abs(n.aspect-o.aspect)<1e-6)return[...e.position];let r=new Ue(...e.position),i=new Ue(...e.target),s=r.clone().sub(i).normalize(),a=new Bn().lookAt(r,i,n.up).invert(),c=Math.tan((e.fov??n.fov)*Math.PI/360)/(e.zoom??n.zoom);if(!(c>0)||!Number.isFinite(c))return[...e.position];let l=0;for(let p of[o.min[0],o.max[0]])for(let m of[o.min[1],o.max[1]])for(let u of[o.min[2],o.max[2]]){let f=new Ue(p,m,u).sub(r).applyMatrix4(a);l=Math.max(l,Math.abs(f.x)/(c*n.aspect)+f.z,Math.abs(f.y)/c+f.z)}return r.addScaledVector(s,l*1.02).toArray()}function Ot(e){return[e.x,e.y,e.z]}function Q(e,t){let n=new Mt,o=new Mt;return t.getPosition(n),t.getTarget(o),{position:Ot(n),target:Ot(o),fov:"fov"in e&&typeof e.fov=="number"?e.fov:null,zoom:"zoom"in e&&typeof e.zoom=="number"?e.zoom:1,azimuthAngle:t.azimuthAngle,polarAngle:t.polarAngle}}function Pn(e,t){return e?e.position[0]===t.position[0]&&e.position[1]===t.position[1]&&e.position[2]===t.position[2]&&e.target[0]===t.target[0]&&e.target[1]===t.target[1]&&e.target[2]===t.target[2]&&e.fov===t.fov&&e.zoom===t.zoom&&e.azimuthAngle===t.azimuthAngle&&e.polarAngle===t.polarAngle:!1}async function de(e,t,n=.6){let o=e.smoothTime;e.smoothTime=St(e,n);try{return await t()}finally{e.smoothTime=o}}function dr(e={}){let t=se(e);t.current=e;let n=se(null),[o,r]=At(null),[i,s]=At(()=>({...e.presets})),a=se(i);a.current=i;let c=H(g=>{r(d=>Pn(d,g)?d:g)},[]),l=H(g=>{c(g)},[c]),p=se(null),m=se(null),u=se(null),f=H(g=>{n.current=g;let d=Q(g.raw.controls.camera,g.raw.controls);c(d),g.raw.scene!==m.current&&(m.current=g.raw.scene,p.current=null,u.current=null),g.homeCameraState&&!p.current&&(p.current=g.homeCameraState);let{initialPosition:h,initialTarget:A,initialTransition:T=!1}=t.current;if((h||A)&&g.raw.scene&&(h||g.homeCameraState)&&u.current!==g.raw.controls){u.current=g.raw.controls,g.homeCameraState||ae(g.raw.controls);let E=h??d.position,D=A??d.target;g.raw.controls.setLookAt(E[0],E[1],E[2],D[0],D[1],D[2],T).then(()=>{if(n.current?.raw.controls!==g.raw.controls)return;let V=Q(g.raw.controls.camera,g.raw.controls);p.current={position:V.position,target:V.target},c(V)}).catch(()=>{})}},[c]),y=H(async()=>{let g=n.current,d=g?.raw.controls;if(!d)return!1;try{let h=p.current;if(h){lt(d,h);let A=Ct(h,d);await de(d,()=>d.setLookAt(A[0],A[1],A[2],h.target[0],h.target[1],h.target[2],!0))}else g?.raw.scene?await de(d,()=>d.fitToBox(g.raw.scene,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})):await de(d,()=>d.reset(!0));return!0}catch{return!1}},[]),M=H(async()=>{let g=n.current;if(!g?.raw.controls||!g.raw.scene)return!1;try{return await de(g.raw.controls,()=>g.raw.controls.fitToBox(g.raw.scene,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),S=H(async g=>{let d=n.current;if(!d?.raw.controls)return!1;let h=st(d.objectBindings,g);if(!h)return!1;let A=d.raw.nodes[h];if(!A)return!1;try{return await de(d.raw.controls,()=>d.raw.controls.fitToBox(A,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),x=H(async(g,d=!0)=>{let h=n.current?.raw.controls;if(!h)return!1;try{return n.current?.homeCameraState||ae(h),await h.setTarget(g[0],g[1],g[2],d),c(Q(h.camera,h)),!0}catch{return!1}},[c]),w=H(async(g,d=!0)=>{let h=n.current?.raw.controls;if(!h)return!1;try{n.current?.homeCameraState||ae(h);let A=[h.setLookAt(g.position[0],g.position[1],g.position[2],g.target[0],g.target[1],g.target[2],d)];g.azimuthAngle!=null&&g.polarAngle!=null&&A.push(h.rotateTo(g.azimuthAngle,g.polarAngle,d)),await Promise.all(A);let T=h.camera,E=!1;return g.fov!=null&&"fov"in T&&typeof T.fov=="number"&&(T.fov=g.fov,E=!0),g.zoom!=null&&"zoom"in T&&typeof T.zoom=="number"&&(T.zoom=g.zoom,E=!0),E&&"updateProjectionMatrix"in T&&T.updateProjectionMatrix(),c(Q(T,h)),!0}catch{return!1}},[c]),b=H((g,d=!0)=>w(g,d),[w]),C=H((g,d,h=!0)=>w({position:g,target:d},h),[w]),O=H(async(g,d,h=!0)=>{let A=n.current?.raw.controls;if(!A)return!1;try{return n.current?.homeCameraState||ae(A),await A.rotateTo(g*Math.PI/180,d*Math.PI/180,h),c(Q(A.camera,A)),!0}catch{return!1}},[c]),k=H(async(g,d=!0)=>{let h=n.current?.raw.controls;if(!h)return!1;try{return n.current?.homeCameraState||ae(h),await h.dollyTo(g,d),c(Q(h.camera,h)),!0}catch{return!1}},[c]),I=H(g=>{let d=n.current?.raw.controls,h=g.trim();if(!d||!h)return null;let A=Q(d.camera,d);return a.current={...a.current,[h]:A},s(T=>({...T,[h]:A})),c(A),A},[c]),R=H((g,d=!0)=>{let h=a.current[g];return h?w(h,d):Promise.resolve(!1)},[w]);return{cameraState:o,cameraPresets:i,resetView:y,focusObject:S,fitScene:M,setCameraTarget:x,setCameraState:b,lookAt:C,orbitTo:O,dollyTo:k,savePreset:I,goToPreset:R,handleCameraChange:l,handleViewerReady:f}}function fr(e){let t=e.trim();return t?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(t):!1}var pr=["none","directional","point","spot","hemisphere"],gr=["pbr","matcap","uv-checker"],br=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var yr=["sporadic","constantMild","constantWild"],hr=["linear","radial","mirroredLinear"],Sr=["verySmall","small","medium","large","veryLarge","huge"];var _e={enabled:!1,axis:"y",position:.5,flip:!1},Vn={clips:[],autoplayClip:null},Nn={autofocus:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6,target:[0,0,0],mouse:!0,debug:0,manual:!1,smoothTime:.25},toneMapping:{enabled:!1,mode:"aces",exposure:1,resolution:256,whitePoint:4,middleGrey:.6,minLuminance:.01,averageLuminance:1,adaptationRate:1},brightnessContrast:{enabled:!1,brightness:0,contrast:0},hueSaturation:{enabled:!1,hue:0,saturation:0},colorAverage:{enabled:!1},dotScreen:{enabled:!1,angle:Math.PI/2,scale:1},glitch:{enabled:!1,mode:"sporadic",delay:[1.5,3.5],duration:[.6,1],strength:[.3,1],chromaticAberrationOffset:[0,0],columns:.05,ratio:.85},ssao:{enabled:!1,samples:30,rings:4,intensity:8,radius:.25,bias:.025,luminanceInfluence:.6,fade:.01,minRadiusScale:.33,worldDistanceThreshold:20,worldDistanceFalloff:5,worldProximityThreshold:6,worldProximityFalloff:3},bloom:{enabled:!1,intensity:.3,luminanceThreshold:.9,luminanceSmoothing:.2,mipmapBlur:!0,radius:0,levels:8},godRays:{enabled:!1,sunPosition:[5,10,5],samples:60,density:.96,decay:.9,weight:.4,exposure:.6,clampMax:1,blur:!0,kernelSize:"small"},grid:{enabled:!1,scale:1,lineWidth:0},noise:{enabled:!1,opacity:1,premultiply:!1},depthOfField:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6},chromaticAberration:{enabled:!1,offsetX:.002,offsetY:.002,radialModulation:!1,modulationOffset:.15},lensflare:{enabled:!1,lensPosition:[-25,6,-60],smoothTime:.07,glareSize:.2,flareSize:.01,flareSpeed:.01,flareShape:.01,animated:!0,anamorphic:!1,colorGain:"#141414",haloScale:.5,secondaryGhosts:!0,aditionalStreaks:!0,ghostScale:0,opacity:1,starBurst:!1},vignette:{enabled:!1,offset:.3,darkness:.3,eskil:!1},smaa:{enabled:!1},sepia:{enabled:!1,intensity:0},scanline:{enabled:!1,density:1.25},pixelation:{enabled:!1,granularity:5},outline:{enabled:!1,selectionLayer:10,edgeStrength:2.5,pulseSpeed:0,visibleEdgeColor:"#ffffff",hiddenEdgeColor:"#22090a",kernelSize:"large",blur:!1,xRay:!0},selectiveBloom:{enabled:!1,selectionLayer:10,intensity:1,luminanceThreshold:.9,luminanceSmoothing:.025,kernelSize:"large",mipmapBlur:!0,inverted:!1,ignoreBackground:!1},ramp:{enabled:!1,rampType:"linear",rampStart:[.5,.5],rampEnd:[1,1],startColor:"#000000",endColor:"#ffffff",opacity:.5,rampBias:.5,rampGain:.5,rampMask:!1,rampInvert:!1}},ce={model:{rotation:[0,0,0],showAdvancedRotation:!1,renderer:"pbr",shading:"lit",autoRotate:!1,autoRotateSpeed:1},camera:{fieldOfView:50,showAdvancedSettings:!1},lighting:{ambient:{intensity:.25,color:"#ffffff"},lights:[{id:"light-hemi",type:"hemisphere",color:"#ffffff",intensity:.3,position:[0,1,0],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0},{id:"light-key",type:"directional",color:"#ffffff",intensity:2.5,position:[6,12,6],attachedToCamera:!1,castShadow:!0,shadowBias:-5e-4,visible:!0},{id:"light-fill",type:"directional",color:"#ffffff",intensity:0,position:[-6,8,-6],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0}]},shadows:{enabled:!0,mapSize:2048,bias:-5e-4,normalBias:.02,radius:3},environment:{source:"preset",preset:"apartment",customEnvironmentUrl:"",intensity:.25,rotation:0,shadowLight:{enabled:!1,intensity:2.5,bias:-5e-4}},wireframe:{enabled:!1,color:"#000000",opacity:1},background:{enabled:!1,type:"color",color:"#1c1c1d",imageUrl:""},groundShadows:{enabled:!1,mode:"shadowCatcher",intensity:.7,borderFade:1,height:0,size:10},postProcessing:Nn,animations:Vn,annotations:[]};function me(e){let t=p=>{throw new Error(`Invalid section: ${p}`)},n=p=>p&&typeof p=="object"&&!Array.isArray(p)?p:t("expected an object"),o=p=>typeof p=="string"&&p.trim().length>0&&p.length<=200?p:t("expected a nonempty name or id (up to 200 characters)"),r=p=>typeof p=="number"&&Number.isFinite(p)&&p>=0&&p<=1?p:t("position must be between 0 and 1"),i=p=>!Array.isArray(p)||p.length!==3||!p.every(m=>typeof m=="number"&&Number.isFinite(m))||Math.hypot(...p)<1e-8?t("normal must be a finite, nonzero vector"):[...p],s=p=>{let m=n(p);return!["x","y","z"].includes(m.axis)||typeof m.enabled!="boolean"||typeof m.flip!="boolean"?t("invalid plane"):{enabled:m.enabled,axis:m.axis,position:r(m.position),flip:m.flip,...m.normal!==void 0?{normal:i(m.normal)}:{}}},a=p=>{let m=n(p),u=s(m);if(m.mode!==void 0){if(!["plane","planes","box"].includes(m.mode))return t("invalid mode");u.mode=m.mode}if(m.planes!==void 0){if(!Array.isArray(m.planes)||m.planes.length>6)return t("at most six planes are supported");let f=new Set;u.planes=m.planes.map(y=>{let M=n(y),S=o(M.id);return f.has(S)?t("duplicate plane id"):(f.add(S),{...s(M),id:S,name:o(M.name)})})}if(m.activePlaneId!==void 0&&(u.activePlaneId=o(m.activePlaneId)),m.invertBox!==void 0){if(typeof m.invertBox!="boolean")return t("invalid box inversion");u.invertBox=m.invertBox}if(m.box!==void 0){let f=n(m.box),y=x=>!Array.isArray(x)||x.length!==3?t("invalid box bounds"):x.map(r),M=y(f.min),S=y(f.max);if(M.some((x,w)=>x>=S[w]))return t("box minimum must be below its maximum on every axis");u.box={min:M,max:S}}return u},c=n(e),l=a(c);if(c.presets!==void 0){if(!Array.isArray(c.presets)||c.presets.length>32)return t("at most 32 presets are supported");let p=new Set;l.presets=c.presets.map(m=>{let u=n(m),f=o(u.id);return p.has(f)?t("duplicate preset id"):(p.add(f),{id:f,name:o(u.name),settings:a(u.settings)})})}return l}function Cr(e){let{presets:t,...n}=me(e);return n}function Ar(e){try{return me(e)}catch{return _e}}function Mr(e,t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid section: expected an object");let n=["enabled","axis","position","flip"].every(o=>Object.prototype.hasOwnProperty.call(t,o));return me(n?t:{..._e,...e,...t})}import{Box3 as jt,Matrix4 as Oe,Quaternion as zn,Vector3 as Me,Euler as Ln}from"three";var vr={version:1,placements:{},gridSize:1};function $e(e){return e.id??e.url}function fe(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Expected an asset transform object.");let t={};for(let n of["position","rotation","scale"]){let o=e[n];if(o!==void 0){if(!Array.isArray(o)||o.length!==3||!o.every(r=>typeof r=="number"&&Number.isFinite(r))||n==="scale"&&o.some(r=>r===0))throw new Error(`Invalid asset ${n}: expected three finite ${n==="scale"?"nonzero ":""}numbers.`);t[n]=[...o]}}return t}function Tr(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid scene composition.");let t=e;if(t.version!==1||!Number.isFinite(t.gridSize)||t.gridSize<=0||!t.placements||typeof t.placements!="object"||Array.isArray(t.placements)||Object.keys(t.placements).length>256)throw new Error("Invalid scene composition version, grid size or placements (maximum 256).");let n={};for(let[o,r]of Object.entries(t.placements)){if(!o||["__proto__","constructor","prototype"].includes(o))throw new Error("Invalid asset instance ID.");let i=fe(r);if(r.label!==void 0&&(typeof r.label!="string"||r.label.length>512))throw new Error("Invalid asset label.");for(let s of["visible","deleted"])if(r[s]!==void 0&&typeof r[s]!="boolean")throw new Error(`Invalid asset ${s}.`);n[o]={...i,...r.label!==void 0?{label:r.label}:{},...r.visible!==void 0?{visible:r.visible}:{},...r.deleted!==void 0?{deleted:r.deleted}:{}}}return{version:1,gridSize:t.gridSize,placements:n}}function Ir(e,t){if(!Number.isFinite(t)||t<=0)throw new Error("Grid size must be positive.");let n=fe(e),[o,r,i]=n.position??[0,0,0];return{...n,position:[Math.round(o/t)*t,r,Math.round(i/t)*t]}}function kr(e,t){let n=fe(e),o=n.position??[0,0,0],r=new Oe().compose(new Me(...o),new zn().setFromEuler(new Ln(...n.rotation??[0,0,0])),new Me(...n.scale??[1,1,1])),i=new jt(new Me(...t.min),new Me(...t.max)).applyMatrix4(r);if(!Number.isFinite(i.min.y))throw new Error("Cannot place an asset with empty bounds.");return{...n,position:[o[0],o[1]-i.min.y,o[2]]}}function Rr(e){e.updateWorldMatrix(!0,!0);let t=new Oe().copy(e.parent?.parent?.matrixWorld??new Oe).invert(),n=new jt;return e.traverse(o=>{let r=o;r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&n.union(r.geometry.boundingBox.clone().applyMatrix4(new Oe().multiplyMatrices(t,r.matrixWorld))))}),n.isEmpty()||![...n.min.toArray(),...n.max.toArray()].every(Number.isFinite)?null:{min:n.min.toArray(),max:n.max.toArray()}}import{BufferGeometry as Dn,Float32BufferAttribute as Un,Matrix4 as Tt,Mesh as Fe,ShapeUtils as _n,Vector2 as It,Vector3 as q,Vector4 as $n}from"three";function kt(e){if(e.length!==3)return null;let t=new q(...e[0]).sub(new q(...e[1])),n=new q(...e[2]).sub(new q(...e[1]));return t.lengthSq()===0||n.lengthSq()===0?null:Math.acos(Math.max(-1,Math.min(1,t.normalize().dot(n.normalize()))))*180/Math.PI}function Rt(e,t){if(!e.normal)return null;let n=new q(...e.normal);if(n.lengthSq()===0)return null;n.normalize();let o=new q(...t),r=o.clone().sub(new q(...e.position)).dot(n);return{distance:Math.abs(r),projection:o.addScaledVector(n,-r).toArray()}}function Et(e){if(e.length<3)return{error:"Pick at least three points to finish the area."};let t=new q(...e[0]),n=e.map(S=>new q(...S).sub(t)),o=Math.max(...n.map(S=>S.length()));if(o===0)return{error:"Area points must be distinct."};let r=new q;for(let S=1;S<n.length-1;S+=1){let x=n[S].clone().cross(n[S+1]);x.lengthSq()>r.lengthSq()&&r.copy(x)}if(r.length()<=o*o*1e-10)return{error:"Area points must not lie on one straight line."};r.normalize();let i=Math.max(o*1e-5,Number.EPSILON*Math.max(...e.flat().map(Math.abs))*32);if(n.some(S=>Math.abs(S.dot(r))>i))return{error:"Area points must lie on one plane."};let s=n.find(S=>S.length()>o*1e-10).clone().normalize(),a=r.clone().cross(s).normalize(),c=n.map(S=>new It(S.dot(s),S.dot(a))),l=(S,x,w)=>(x.x-S.x)*(w.y-S.y)-(x.y-S.y)*(w.x-S.x),p=o*o*1e-10,m=(S,x,w)=>Math.abs(l(S,x,w))<=p&&w.x>=Math.min(S.x,x.x)-o*1e-10&&w.x<=Math.max(S.x,x.x)+o*1e-10&&w.y>=Math.min(S.y,x.y)-o*1e-10&&w.y<=Math.max(S.y,x.y)+o*1e-10;for(let S=0;S<c.length;S+=1){let x=c[S],w=c[(S+1)%c.length];if(x.distanceTo(w)<=o*1e-10)return{error:"Area points must be distinct."};for(let b=S+1;b<c.length;b+=1){if(b===S+1||S===0&&b===c.length-1)continue;let C=c[b],O=c[(b+1)%c.length],k=l(x,w,C),I=l(x,w,O),R=l(C,O,x),g=l(C,O,w);if(k*I<0&&R*g<0||m(x,w,C)||m(x,w,O)||m(C,O,x)||m(C,O,w))return{error:"Area edges must not cross or touch each other."}}}let u=0,f=0,y=0;for(let S=0;S<c.length;S+=1){let x=c[S],w=c[(S+1)%c.length],b=x.x*w.y-w.x*x.y;u+=b,f+=(x.x+w.x)*b,y+=(x.y+w.y)*b}if(Math.abs(u)<=p)return{error:"The polygon has no measurable area."};let M=t.clone().addScaledVector(s,f/(3*u)).addScaledVector(a,y/(3*u));return{area:Math.abs(u)/2,center:M.toArray(),triangles:_n.triangulateShape(c,[])}}function qe(e,t){if(e.length<2)return 0;let n=0;for(let o=1;o<e.length;o+=1)n+=new q(...e[o]).distanceTo(new q(...e[o-1]));return t&&(n+=new q(...e[e.length-1]).distanceTo(new q(...e[0]))),n}var Fn=1e-5;function qn(e,t){let n=e.getAttribute("position"),o=e.getIndex(),r=n.count,i=Math.max(t,1e-9),s=(y,M,S)=>`${Math.round(y/i)}_${Math.round(M/i)}_${Math.round(S/i)}`,a=new Int32Array(r),c=[],l=new Map;for(let y=0;y<r;y+=1){let M=n.getX(y),S=n.getY(y),x=n.getZ(y),w=s(M,S,x),b=l.get(w);b===void 0&&(b=c.length,c.push(new q(M,S,x)),l.set(w,b)),a[y]=b}let p=c.map(()=>new Map),m=(y,M)=>{if(y===M)return;let S=c[y].distanceTo(c[M]);p[y].has(M)||p[y].set(M,S),p[M].has(y)||p[M].set(y,S)},u=(o?o.count:r)/3,f=y=>o?o.getX(y):y;for(let y=0;y<u;y+=1)m(a[f(y*3)],a[f(y*3+1)]),m(a[f(y*3+1)],a[f(y*3+2)]),m(a[f(y*3+2)],a[f(y*3)]);return{weldedId:a,weldedPosition:c,neighbors:p}}function Wn(e,t,n){let o=new Map([[t,0]]),r=[t];for(let i=0;i<n&&r.length>0;i+=1){let s=[];for(let a of r){let c=o.get(a)??0;for(let[l,p]of e[a]??[])o.has(l)||(o.set(l,c+p),s.push(l))}r=s}return o}function Gn(e){let n=(Math.abs(e.y)<.9?new q(0,1,0):new q(1,0,0)).clone().cross(e).normalize(),o=e.clone().cross(n).normalize();return[n,o]}function Hn(e,t,n){let[o,r]=Gn(t),i=0,s=0,a=0;for(let M of n){let S=M.clone().sub(e),x=S.dot(o),w=S.dot(r);i+=x*x,s+=x*w,a+=w*w}let c=i+a,l=i*a-s*s,p=Math.sqrt(Math.max(0,c*c/4-l)),m=c/2+p,u=1,f=0;Math.abs(s)>1e-12?(u=m-a,f=s):a>i&&(u=0,f=1);let y=Math.hypot(u,f)||1;return o.clone().multiplyScalar(u/y).add(r.clone().multiplyScalar(f/y)).normalize()}function Kn(e,t,n,o){let r=e.getAttribute("position"),i=e.getIndex(),s=r.count,a=(i?i.count:s)/3,c=u=>i?i.getX(u):u,l=u=>new q(r.getX(u),r.getY(u),r.getZ(u)).applyMatrix4(t),p=u=>u.clone().sub(n).dot(o),m=[];for(let u=0;u<a;u+=1){let f=l(c(u*3)),y=l(c(u*3+1)),M=l(c(u*3+2)),S=p(f),x=p(y),w=p(M),b=[],C=(O,k,I,R)=>{k>0!=R>0&&b.push(O.clone().lerp(I,k/(k-R)))};C(f,S,y,x),C(y,x,M,w),C(M,w,f,S),b.length===2&&m.push([b[0],b[1]])}return m}function Xn(e,t){let n=Math.max(t,1e-9),o=u=>`${Math.round(u.x/n)}_${Math.round(u.y/n)}_${Math.round(u.z/n)}`,r=new Map,i=[],s=u=>{let f=o(u),y=r.get(f);return y===void 0&&(y=i.length,i.push(u),r.set(f,y)),y},a=[],c=u=>{for(;a.length<=u;)a.push(new Map)};for(let[u,f]of e){let y=s(u),M=s(f);y!==M&&(c(y),c(M),a[y].set(M,(a[y].get(M)??0)+1),a[M].set(y,(a[M].get(y)??0)+1))}let l=(u,f)=>u<f?`${u}_${f}`:`${f}_${u}`,p=new Set,m=[];for(let u=0;u<a.length;u+=1)for(let f of a[u]?.keys()??[]){if(p.has(l(u,f)))continue;let y=[u],M=u,S=f;p.add(l(M,S));let x=0;for(;S!==u&&S>=0&&x<a.length+4;){y.push(S);let w=[...a[S].keys()].filter(C=>C!==M),b;if(w.length<=1)b=w[0];else{let C=i[S].clone().sub(i[M]).normalize(),O=-1/0;for(let k of w){let I=i[k].clone().sub(i[S]).normalize(),R=C.dot(I);R>O&&(O=R,b=k)}}if(b===void 0){S=-1;break}p.add(l(S,b)),M=S,S=b,x+=1}S===u&&y.length>=3&&m.push(y.map(w=>i[w]))}return m}function vt(e,t){let n=1/0;for(let o of e)n=Math.min(n,o.distanceTo(t));return n}function Yn(e,t){let n=0,o=1/0;return e.forEach((r,i)=>{let s=r.distanceTo(t);s<o&&(o=s,n=i)}),[...e.slice(n),...e.slice(0,n)]}function Bt(e,t,n,o,r){let i=Kn(e,t,o,r);if(i.length===0)return{error:"Couldn't trace a loop around this point."};let s=Xn(i,n*t.getMaxScaleOnAxis());if(s.length===0)return{error:"The surface here doesn't form a closed loop around this point (it may be near an open edge)."};let a=s[0],c=vt(a,o);for(let p of s.slice(1)){let m=vt(p,o);m<c&&(c=m,a=p)}let l=Yn(a,o).map(p=>p.toArray());return{points:l,length:qe(l,!0)}}function Pt(e){if(!(e.object instanceof Fe)||!e.face)return null;let t=e.object,n=t.geometry;if(t.isSkinnedMesh||t.morphTargetInfluences?.some(i=>i!==0)){let i=n.getAttribute("position"),s=new Un(new Float32Array(i.count*3),3),a=new q;for(let c=0;c<i.count;c++)t.getVertexPosition(c,a),s.setXYZ(c,a.x,a.y,a.z);n=new Dn().setAttribute("position",s).setIndex(n.getIndex())}let o=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let i=new Tt;t.getMatrixAt(e.instanceId,i),o.multiply(i)}n.computeBoundingSphere();let r=n.boundingSphere&&n.boundingSphere.radius>0?n.boundingSphere.radius:1;return{face:e.face,geometry:n,matrix:o,weldTolerance:r*Fn}}function Pr(e,t=6){let n=Pt(e);if(!n)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{face:o,geometry:r,matrix:i,weldTolerance:s}=n,a=Vt(e);if(!a)return{error:"Pick a point on the mesh surface to trace a loop around it."};let c=a[1].clone().sub(a[0]).cross(a[2].clone().sub(a[0]));if(c.lengthSq()===0)return{error:"Couldn't determine the surface direction at this point."};c.normalize();let{weldedId:l,weldedPosition:p,neighbors:m}=qn(r,s),u=r.getAttribute("position"),f=e.point.clone().applyMatrix4(i.clone().invert()),y=[o.a,o.b,o.c],M=y[0],S=1/0;for(let k of y){let R=new q(u.getX(k),u.getY(k),u.getZ(k)).distanceTo(f);R<S&&(S=R,M=k)}let x=l[M],w=p[x].clone().applyMatrix4(i),b=Wn(m,x,t),C=[];for(let k of b.keys())C.push(p[k].clone().applyMatrix4(i));if(C.length<6)return{error:"Not enough surface detail near this point to trace a loop. Try a different spot."};let O=Hn(w,c,C);return Bt(r,i,s,e.point.clone(),O)}function Vr(e,t=new q(0,1,0)){let n=Pt(e);if(!n)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{geometry:o,matrix:r,weldTolerance:i}=n,s=t.clone().normalize();return s.lengthSq()===0?{error:"Couldn't determine a horizontal direction."}:Bt(o,r,i,e.point.clone(),s)}function Vt(e){if(!(e.object instanceof Fe)||!e.face)return null;let t=e.object,n=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let o=new Tt;t.getMatrixAt(e.instanceId,o),n.multiply(o)}return[e.face.a,e.face.b,e.face.c].map(o=>t.getVertexPosition(o,new q).applyMatrix4(n))}function Nr(e){if(!(e.object instanceof Fe))return!1;for(let n=e.object;n;n=n.parent)if(!n.visible||n.userData.riEditorGizmo||n.userData.riDecal)return!1;return(Array.isArray(e.object.material)?e.object.material:[e.object.material])[e.face?.materialIndex??0]?.visible!==!1}function zr(e,t,n,o,r,i=12){let s=Vt(e),a=s?s[1].clone().sub(s[0]).cross(s[2].clone().sub(s[0])).normalize():null,c={position:e.point.toArray(),...a&&a.lengthSq()>0?{normal:a.toArray()}:{},...s?{faceVertices:s.map(u=>u.toArray())}:{}};if(!s||r==="none")return c;let l=u=>{let f=new $n(u.x,u.y,u.z,1).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);return f.w<=0||f.z/f.w<-1||f.z/f.w>1?null:{screen:new It((f.x/f.w+1)*o.width/2,(1-f.y/f.w)*o.height/2),w:f.w}},p=s.map(l),m=i;if((r==="vertex"||r==="auto")&&(p.forEach((u,f)=>{let y=u?.screen.distanceTo(n)??1/0;y<=m&&(m=y,c.position=s[f].toArray(),c.snapped="vertex")}),c.snapped))return c;if(r==="edge"||r==="auto")for(let u=0;u<3;u+=1){let f=(u+1)%3,y=p[u],M=p[f];if(!y||!M)continue;let S=M.screen.clone().sub(y.screen);if(S.lengthSq()===0)continue;let x=Math.max(0,Math.min(1,n.clone().sub(y.screen).dot(S)/S.lengthSq())),w=y.screen.clone().addScaledVector(S,x).distanceTo(n);if(w<=m){m=w;let b=x*y.w/((1-x)*M.w+x*y.w);c.position=s[u].clone().lerp(s[f],b).toArray(),c.snapped="edge"}}return c}var Zn=["m","cm","mm","in","ft"],We={m:1,cm:.01,mm:.001,in:.0254,ft:.3048},Jn=["distance","angle","area","pointToPlane","wrap","wrapHorizontal"];function Ge(e){return Zn.includes(e)}function Qn(e={},t="m"){let n=e.displayUnit??t,o=e.metersPerUnit??We[e.sourceUnit??"m"];if(!Number.isFinite(o)||o<=0)throw new Error("Measurement scale must be a positive finite number.");return{displayUnit:n,metersPerUnit:o,factor:Ge(n)?o/We[n]:1}}function Ur(e){try{return new URL(e,typeof window<"u"?window.location?.href:void 0).href}catch{return e}}function _r(e,t,n,o={}){if(!Ge(n)||!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)throw new Error("Calibration needs two distinct points and a positive known distance.");let r=t*We[n]/e;if(!Number.isFinite(r)||r<=0)throw new Error("Calibration scale is outside the supported range.");return{...o,metersPerUnit:r}}function Nt(e,t){let n=t.map(o=>o.position);if(e==="angle"){let o=kt(n);return o===null?null:{value:o,dimension:0}}if(e==="area"){let o=Et(n);return"error"in o?null:{value:o.area,dimension:2}}if(e==="pointToPlane"){let o=t.length===2?Rt(t[0],t[1].position):null;return o?{value:o.distance,dimension:1}:null}return t.length<(e==="distance"?2:3)?null:{value:qe(n,e!=="distance"),dimension:1}}function eo(e,t={},n="m",o=e.points,r=e.approximate?"approximate":"ready"){let i=Nt(e.tool,o),{factor:s,displayUnit:a}=Qn(t,n),c=r==="ready"||r==="approximate",l=c&&i?i.value*s**i.dimension:null;return{id:e.id,status:c?i&&l!==null&&Number.isFinite(l)?r:"invalid":r,rawValue:c&&i&&Number.isFinite(i.value)?i.value:null,value:l!==null&&Number.isFinite(l)?l:null,unit:e.tool==="angle"?"\xB0":e.tool==="area"?`${a}\xB2`:a}}function pe(e){function t(){throw new Error("Invalid measurements: expected settings and valid named measurements with finite points.")}let n=a=>!!a&&typeof a=="object"&&!Array.isArray(a),o=a=>Array.isArray(a)&&a.length===3&&a.every(c=>typeof c=="number"&&Number.isFinite(c));typeof e=="string"&&(e.length>5*1024*1024&&t(),e=JSON.parse(e)),(!n(e)||e.version!==void 0&&e.version!==1||!n(e.settings)||!Array.isArray(e.items)||e.items.length>256)&&t();let r={};for(let a of["sourceUnit","displayUnit"])e.settings[a]!==void 0&&(Ge(e.settings[a])||t(),r[a]=e.settings[a]);e.settings.metersPerUnit!==void 0&&((typeof e.settings.metersPerUnit!="number"||!Number.isFinite(e.settings.metersPerUnit)||e.settings.metersPerUnit<=0)&&t(),r.metersPerUnit=e.settings.metersPerUnit);let i=new Set,s=e.items.map(a=>{(!n(a)||typeof a.id!="string"||!a.id||i.has(a.id)||typeof a.name!="string"||!a.name.trim()||typeof a.modelId!="string"||!a.modelId||!Jn.includes(a.tool)||!Array.isArray(a.points)||a.points.length>8192||typeof a.createdAt!="string"||!Number.isFinite(Date.parse(a.createdAt)))&&t(),i.add(a.id),a.tilesetUrl!==void 0&&a.tilesetUrl!==null&&typeof a.tilesetUrl!="string"&&t(),(a.visible!==void 0&&typeof a.visible!="boolean"||a.approximate!==void 0&&typeof a.approximate!="boolean")&&t();let c=new Set,l=a.points.map(m=>{if((!n(m)||typeof m.id!="number"||!Number.isFinite(m.id)||!o(m.position))&&t(),c.has(m.id)&&t(),c.add(m.id),m.normal!==void 0&&!o(m.normal)&&t(),m.faceVertices!==void 0&&(!Array.isArray(m.faceVertices)||m.faceVertices.length!==3||!m.faceVertices.every(o))&&t(),m.snapped!==void 0&&!["vertex","edge"].includes(m.snapped)&&t(),m.anchor!==void 0){let f=m.anchor;(!n(f)||typeof f.nodeId!="string"||!f.nodeId||!o(f.localPosition)||typeof f.geometrySignature!="string"||typeof f.poseSignature!="string")&&t(),f.localNormal!==void 0&&!o(f.localNormal)&&t(),f.localFaceVertices!==void 0&&(!Array.isArray(f.localFaceVertices)||f.localFaceVertices.length!==3||!f.localFaceVertices.every(o))&&t(),f.instanceId!==void 0&&(!Number.isInteger(f.instanceId)||f.instanceId<0)&&t()}let u=m.anchor;return{id:m.id,position:[...m.position],...m.normal?{normal:[...m.normal]}:{},...m.faceVertices?{faceVertices:m.faceVertices.map(f=>[...f])}:{},...m.snapped?{snapped:m.snapped}:{},...u?{anchor:{nodeId:u.nodeId,localPosition:[...u.localPosition],geometrySignature:u.geometrySignature,poseSignature:u.poseSignature,...u.localNormal?{localNormal:[...u.localNormal]}:{},...u.localFaceVertices?{localFaceVertices:u.localFaceVertices.map(f=>[...f])}:{},...u.instanceId!==void 0?{instanceId:u.instanceId}:{}}}:{}}}),p={id:a.id,name:a.name,modelId:a.modelId,tool:a.tool,points:l,createdAt:a.createdAt,...a.tilesetUrl!==void 0?{tilesetUrl:a.tilesetUrl}:{},...a.visible!==void 0?{visible:a.visible}:{},...a.approximate!==void 0?{approximate:a.approximate}:{}};return Nt(p.tool,l)||t(),p});return{settings:r,items:s}}function $r(e){return JSON.stringify({version:1,...pe(e)},null,2)}function Fr(e,t,n="m"){let o=pe(e),r=new Map(t?.map(s=>[s.id,s])),i=s=>{let a=String(s??"");return/^[=+@-]/.test(a)&&(a=`'${a}`),`"${a.replace(/"/g,'""')}"`};return[["id","name","modelId","type","status","value","unit","createdAt"],...o.items.map(s=>{let a=r.get(s.id)??eo(s,o.settings,n);return[s.id,s.name,s.modelId,s.tool,a.status,a.value,a.unit,s.createdAt]})].map(s=>s.map(i).join(",")).join(`\r
2
- `)}function zt(e){if(!Array.isArray(e)||e.length>128)throw new Error("Invalid selections: expected up to 128 named selection sets.");let t=new Set;return e.map(n=>{if(!n||typeof n!="object"||typeof n.id!="string"||!n.id||t.has(n.id)||typeof n.name!="string"||!n.name.trim()||n.name.length>200||!Array.isArray(n.objectIds)||n.objectIds.length>1e5||n.objectIds.some(o=>typeof o!="string"||!o))throw new Error("Invalid selections: each set needs a unique id, a name, and model object ids.");return t.add(n.id),{id:n.id,name:n.name.trim(),objectIds:[...new Set(n.objectIds)]}})}import{CanvasTexture as Lt,Color as Dt,ImageLoader as to,NoColorSpace as ve,RepeatWrapping as je,SRGBColorSpace as Ze,Texture as no}from"three";var te=new Map,Xe={color:"#93c5fd",intensity:.07},Hr=new Dt(Xe.color).multiplyScalar(Xe.intensity),Kr=new Dt(Xe.color),Xr=.28,le=new Map,Ye=new Map;function oo(e){return`${e.name}|${e.size}|${e.lastModified}`}function Yr(e){let t=oo(e),n=e.name.lastIndexOf("."),o=n>0?e.name.slice(0,n):e.name,r=n>0?e.name.slice(n):"",i=`materials/${e.name}`,s=2;for(;;){let a=Ye.get(i);if(a===void 0||a===t)return Ye.set(i,t),i;i=`materials/${o}-${s}${r}`,s+=1}}function Te(e){return le.get(e)}function Ut(e,t){let n=++e.loadGeneration;e.loaded=!1,e.failed=!1;let o=()=>{if(e.loadGeneration!==n)return;e.loaded=!0;let r=e.pending;e.pending=[];for(let i of r)i()};new to().load(t,r=>{e.loadGeneration===n&&(e.texture.image=r,e.texture.needsUpdate=!0,o())},void 0,()=>{e.loadGeneration===n&&(e.failed=!0,console.warn(`Failed to load texture: ${t}`),o())})}function _t(e,t){for(let n of[Ze,ve]){let o=te.get(ge(e,n));o&&Ut(o,t)}}function Zr(e,t){let n=le.get(e);n&&n!==t&&n.startsWith("blob:")&&URL.revokeObjectURL(n),le.set(e,t),_t(e,t)}function Jr(e){let t=le.get(e);t&&(t.startsWith("blob:")&&URL.revokeObjectURL(t),le.delete(e),Ye.delete(e),_t(e,e))}function ge(e,t){return`${t}|${e}`}function ro(e,t=ve,n){let o=ge(e,t),r=te.get(o);if(r)return n&&!r.loaded&&r.pending.push(n),r.texture;let i=le.get(e)??e,s={texture:new no,refCount:0,loaded:!1,pending:n?[n]:[],loadGeneration:0};return s.texture.flipY=!1,s.texture.colorSpace=t,te.set(o,s),Ut(s,i),s.texture}function Qr(e,t=ve,n){let o=ro(e,t,n);return te.get(ge(e,t)).refCount+=1,o}function ei(e,t=ve){let n=te.get(ge(e,t));n&&(n.refCount-=1,n.refCount<=0&&(n.loadGeneration+=1,n.pending=[],n.texture.dispose(),te.delete(ge(e,t))))}function ti(e,t,n,o,r,i=1,s=0){let a=e.offsetTextures??(e.offsetTextures={}),c=a[t],l=c;if(!l||l.sourcePath!==o||l.base!==n){c?.texture.dispose();let m=n.clone();m.wrapS=je,m.wrapT=je,m.center.set(.5,.5),m.needsUpdate=!0,l={texture:m,sourcePath:o,base:n},a[t]=l}let p=i>0?i:1;return l.texture.offset.set(r[0],r[1]),l.texture.repeat.set(1/p,1/p),l.texture.rotation=s,l.texture}function ni(e,t){let n=e.offsetTextures,o=n?.[t];o&&(o.texture.dispose(),delete n[t])}function oi(e){let t=e.offsetTextures;if(t){for(let n of Object.values(t))n.texture.dispose();delete e.offsetTextures}}var He=null;function ri(){if(He)return He;let e=256,t=document.createElement("canvas");t.width=e,t.height=e;let n=t.getContext("2d"),o=n.createRadialGradient(e*.35,e*.35,e*.02,e*.5,e*.5,e*.55);o.addColorStop(0,"#ffffff"),o.addColorStop(.4,"#b5b5b5"),o.addColorStop(1,"#3a3a3a"),n.fillStyle=o,n.fillRect(0,0,e,e);let r=new Lt(t);return r.colorSpace=Ze,He=r,r}var Ke=null;function ii(){if(Ke)return Ke;let e=1024,t=8,n=e/t,o=["#ef4444","#f59e0b","#22c55e","#6366f1"],r=document.createElement("canvas");r.width=e,r.height=e;let i=r.getContext("2d");i.textAlign="center",i.textBaseline="middle";for(let a=0;a<t;a+=1)for(let c=0;c<t;c+=1){let l=c*n,p=a*n,m=(Math.floor(c/2)+Math.floor(a/2))%4;i.fillStyle=o[m],i.fillRect(l,p,n,n),i.strokeStyle="rgba(0, 0, 0, 0.28)",i.lineWidth=2;for(let w=1;w<4;w+=1){let b=w*n/4;i.beginPath(),i.moveTo(l+b,p),i.lineTo(l+b,p+n),i.moveTo(l,p+b),i.lineTo(l+n,p+b),i.stroke()}i.strokeStyle="#09090b",i.lineWidth=7,i.strokeRect(l,p,n,n);let u=l+n*.23,f=p+n*.72,y=l+n*.72,M=p+n*.23;i.lineCap="round",i.lineJoin="round",i.beginPath(),i.moveTo(u,f),i.lineTo(y,M),i.lineTo(y-n*.2,M),i.moveTo(y,M),i.lineTo(y,M+n*.2),i.stroke();let S=a*t+c+1;i.font=`700 ${Math.round(n*.2)}px ui-monospace, SFMono-Regular, Menlo, monospace`,i.fillStyle="#ffffff",i.strokeStyle="rgba(0, 0, 0, 0.85)",i.lineWidth=6;let x=String(S).padStart(2,"0");i.strokeText(x,l+n/2,p+n*.82),i.fillText(x,l+n/2,p+n*.82)}let s=new Lt(r);return s.colorSpace=Ze,s.wrapS=je,s.wrapT=je,s.flipY=!1,s.anisotropy=8,s.needsUpdate=!0,Ke=s,s}function $t(e){for(let t of te.values())if(t.texture.source===e.source&&(!t.loaded||t.failed))return!0;return!1}var ne=5*1024*1024,io=["activeModelId","modelUrl","modelFormat","tilesetUrl","models","mergeModels","sceneConfig","isolation","multiSelectedKeys","activeAnnotation","annotationCategories","backgroundColor","shadows","cinematic","cameraControllerType","objectTransformSpace","arScaleMode","usdzUrl","measurements","measurementSettings","measurementUnit","measurementModelId"];function v(e,t){throw new Error(`Invalid viewer state at ${e}: ${t}`)}function W(e,t){(!e||typeof e!="object"||Array.isArray(e))&&v(t,"expected an object.")}function be(e,t){(!Array.isArray(e)||!e.every(n=>typeof n=="string"))&&v(t,"expected strings.")}function Y(e,t,n){(!Array.isArray(e)||e.length!==t||!e.every(o=>typeof o=="number"&&Number.isFinite(o)))&&v(n,`expected ${t} finite numbers.`)}function ao(e){let t=new Set,n=0;function o(r,i,s){if((++n>2e5||s>64)&&v(i,"configuration is too complex."),r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;(typeof r!="object"||!r)&&v(i,"expected JSON data (finite numbers, no functions)."),t.has(r)&&v(i,"cyclic data."),!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null&&v(i,"expected plain JSON data."),t.add(r);let a=Array.isArray(r)?[]:{};for(let[c,l]of Object.entries(r))["__proto__","constructor","prototype"].includes(c)&&v(`${i}.${c}`,"reserved property."),l!==void 0?a[c]=o(l,`${i}.${c}`,s+1):Array.isArray(r)&&v(i,"undefined array entry.");return t.delete(r),a}return o(e,"state",0)}function Z(e,t,n,o,r=!1,i){let s=e[t];if(s==null||s==="")return;typeof s!="string"&&v(n,"expected a URL.");let a=r?Te(s)??s:s;if(a.trim().startsWith("blob:")){if(r&&i){i.set(s,{source:a,path:n});return}v(n,r?"this image is temporary. Use getStateAsync() for JSON or createShareUrl() to include it.":"upload this model/environment asset to a durable URL before saving or sharing.")}if(a!==s&&(s=a,e[t]=a),r&&/^data:image\//i.test(s))return;let c;try{c=new URL(s,o??"https://relative.invalid/")}catch{v(n,"invalid asset URL.")}["http:","https:"].includes(c.protocol)||v(n,"use an HTTP(S) asset URL."),o&&(e[t]=c.href)}function so(e,t){W(e,t),Y(e.position,3,`${t}.position`),Y(e.target,3,`${t}.target`),(typeof e.zoom!="number"||e.zoom<=0)&&v(t,"zoom must be positive."),e.fov!==null&&(typeof e.fov!="number"||e.fov<=0||e.fov>=180)&&v(t,"fov must be null or between 0 and 180.");for(let n of["azimuthAngle","polarAngle"])e[n]!==void 0&&typeof e[n]!="number"&&v(t,`${n} must be a number.`)}function Wt(e,t,n,o){W(e,t),(typeof e.id!="number"||typeof e.title!="string"||typeof e.description!="string")&&v(t,"expected an annotation id, title and description.");for(let r of["worldPosition","localPosition"])Y(e[r],3,`${t}.${r}`);e.images!==void 0&&(Array.isArray(e.images)||v(t,"images must be an array."),e.images.forEach(r=>{W(r,t),Z(r,"src",t,n,!0,o)})),e.links!==void 0&&(Array.isArray(e.links)||v(t,"links must be an array."),e.links.forEach(r=>{W(r,t),Z(r,"href",t,n,!1,o)}))}function Gt(e,t){W(e,t),e.waypoints!==void 0&&(Array.isArray(e.waypoints)||v(t,"expected waypoints."),e.waypoints.forEach(n=>{W(n,t),Y(n.position,3,t),Y(n.target,3,t)}));for(let n of["enabled","loop","autoPlay"])e[n]!==void 0&&typeof e[n]!="boolean"&&v(t,`${n} must be boolean.`);e.duration!==void 0&&(typeof e.duration!="number"||e.duration<=0)&&v(t,"duration must be positive.")}function Je(e,t,n){if(t!==null)if(Array.isArray(t))Array.isArray(e)||v(n,"expected an array."),t.length&&e.forEach(o=>Je(o,t[0],n));else if(typeof t=="object"){W(e,n);for(let[o,r]of Object.entries(t))Je(e[o],r,`${n}.${o}`)}else typeof e!=typeof t&&v(n,`expected ${typeof t}.`)}function Ft(e,t,n,o){if(Je(e,ce,t),e.measurements!==void 0&&(e.measurements=pe(e.measurements)),e.sequences!==void 0&&(e.sequences=xe(e.sequences)),e.selectionSets!==void 0&&(e.selectionSets=zt(e.selectionSets)),e.product!==void 0&&(e.product=bt(e.product),e.product.definition.groups.forEach(r=>r.options.forEach(i=>i.appearance?.forEach(s=>{for(let[a,c]of Object.entries(s.material??{}))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&Z(c,"path",`${t}.product.material.${a}.path`,n,!0,o)})))),Y(e.model.rotation,3,`${t}.model.rotation`),e.lighting.lights.forEach(r=>Y(r.position,3,`${t}.lighting.lights`)),e.annotations.forEach(r=>Wt(r,`${t}.annotations`,n,o)),e.animations.autoplayClip!==null&&typeof e.animations.autoplayClip!="string"&&v(t,"invalid autoplay clip."),e.animations.clips.forEach(r=>{W(r,t),(typeof r.sourceName!="string"||typeof r.displayName!="string"||typeof r.hidden!="boolean"||typeof r.speed!="number"||!["repeat","once","ping-pong"].includes(r.loopMode))&&v(t,"invalid animation clip settings.")}),e.cinematic!==void 0&&Gt(e.cinematic,`${t}.cinematic`),e.styleRules!==void 0&&!Array.isArray(e.styleRules)&&v(t,"styleRules must be an array."),Z(e.environment,"customEnvironmentUrl",`${t}.environment`,n,!1,o),Z(e.background,"imageUrl",`${t}.background`,n,!0,o),e.model.activeVariants!==void 0&&be(e.model.activeVariants,t),e.section!==void 0)try{e.section=me(e.section)}catch(r){v(`${t}.section`,r.message)}}function Ht(e,t,n,o){W(e,t);for(let[r,i]of Object.entries(e)){let s=`${t}.${r}`;W(i,s),(typeof i.id!="string"||typeof i.modelObjectId!="string")&&v(s,"expected binding id and modelObjectId.");for(let a of["label","group","type","status"])i[a]!==void 0&&typeof i[a]!="string"&&v(s,`${a} must be a string.`);i.tags!==void 0&&be(i.tags,s),i.metadata!==void 0&&W(i.metadata,`${s}.metadata`),i.metrics!==void 0&&(W(i.metrics,s),Object.values(i.metrics).some(a=>typeof a!="number")&&v(s,"metrics must be numbers.")),i.actions!==void 0&&(Array.isArray(i.actions)||v(s,"actions must be an array."),i.actions.forEach(a=>{W(a,s),(typeof a.id!="string"||typeof a.label!="string"||a.type!=="command"||a.effects!==void 0&&!Array.isArray(a.effects))&&v(s,"invalid action.")}));for(let a of["visible","removed","selectable","hoverable"])i[a]!==void 0&&typeof i[a]!="boolean"&&v(s,`${a} must be boolean.`);if(i.transform!==void 0){W(i.transform,s);for(let a of["position","rotation","scale","shear"])i.transform[a]!==void 0&&Y(i.transform[a],3,`${s}.transform.${a}`);i.transform.pivot!==void 0&&(W(i.transform.pivot,s),Y(i.transform.pivot.point,3,s),Y(i.transform.pivot.offset,3,s))}if(i.style!==void 0&&(W(i.style,s),i.style.material!==void 0)){W(i.style.material,s);for(let[a,c]of Object.entries(i.style.material))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&Z(c,"path",`${s}.style.material.${a}.path`,n,!0,o)}i.decals!==void 0&&(Array.isArray(i.decals)||v(s,"decals must be an array."),i.decals.forEach(a=>{W(a,s),(typeof a.id!="string"||typeof a.size!="number"||a.size<=0)&&v(s,"invalid decal."),Y(a.position,3,s),Y(a.normal,3,s),Z(a,"image",s,n,!0,o)}))}}function qt(e,t,n,o){Array.isArray(e)||v(t,"expected merge sources."),e.forEach(r=>{W(r,t),(typeof r.url!="string"||!r.url||typeof r.namePrefix!="string")&&v(t,"expected source URL and prefix."),Z(r,"url",t,n,!1,o)})}function co(e,t,n){W(e,"configuration");let o=Object.fromEntries(io.filter(r=>e[r]!==void 0).map(r=>[r,e[r]]));(typeof o.modelUrl!="string"||!o.modelUrl)&&v("configuration.modelUrl","expected the active model URL.");for(let r of["modelUrl","tilesetUrl","usdzUrl"])Z(o,r,`configuration.${r}`,t,!1,n);if(o.sceneConfig!==void 0&&Ft(o.sceneConfig,"configuration.sceneConfig",t,n),o.mergeModels!==void 0&&qt(o.mergeModels,"configuration.mergeModels",t,n),o.models!==void 0){(!Array.isArray(o.models)||o.models.length===0)&&v("configuration.models","expected model entries.");let r=new Set,i=new Set;o.models.forEach(s=>{W(s,"model"),(typeof s.url!="string"||!s.url)&&v("model.url","expected a URL."),Z(s,"url","model.url",t,!1,n),s.id!==void 0&&(typeof s.id!="string"||!s.id.trim())&&v("model.id","expected a nonempty instance ID.");let a=$e({id:s.id,url:s.url});i.has(a)&&v("configuration.models","instance identities must be unique; assign IDs when reusing a URL."),i.add(a),s.transform!==void 0&&(s.transform=fe(s.transform)),s.visible!==void 0&&typeof s.visible!="boolean"&&v("model.visible","expected boolean."),r.add(s.url),Ht(s.objectBindings,"model.objectBindings",t,n),s.sceneConfig!==void 0&&Ft(s.sceneConfig,"model.sceneConfig",t,n),s.mergeModels!==void 0&&qt(s.mergeModels,"model.mergeModels",t,n)}),o.activeModelId!==void 0&&(typeof o.activeModelId!="string"||!i.has(o.activeModelId))&&v("configuration.activeModelId","active instance is not in models."),o.activeModelId!==void 0&&o.models.find(s=>$e(s)===o.activeModelId)?.url!==o.modelUrl&&v("configuration.modelUrl","source does not match the active instance."),r.has(o.modelUrl)||v("configuration.modelUrl","active model is not in models.")}if(o.multiSelectedKeys!==void 0&&be(o.multiSelectedKeys,"configuration.multiSelectedKeys"),o.annotationCategories!==void 0&&o.annotationCategories!==null&&be(o.annotationCategories,"configuration.annotationCategories"),o.activeAnnotation!==void 0&&o.activeAnnotation!==null&&Wt(o.activeAnnotation,"configuration.activeAnnotation",t,n),o.measurements!==void 0||o.measurementSettings!==void 0){let r=pe({items:o.measurements??[],settings:o.measurementSettings??{}});o.measurements!==void 0&&(o.measurements=r.items),o.measurementSettings!==void 0&&(o.measurementSettings=r.settings)}o.measurementModelId!==void 0&&typeof o.measurementModelId!="string"&&v("configuration.measurementModelId","expected a stable id."),o.measurementUnit!==void 0&&typeof o.measurementUnit!="string"&&v("configuration.measurementUnit","expected a unit label.");for(let r of["backgroundColor"])o[r]!==void 0&&typeof o[r]!="string"&&v(r,"expected a string.");o.shadows!==void 0&&typeof o.shadows!="boolean"&&v("shadows","expected boolean.");for(let[r,i]of Object.entries({modelFormat:["glb","gltf","obj","fbx","usdz","stl","ply"],cameraControllerType:["orbit","pointerLock"],objectTransformSpace:["world","local"],arScaleMode:["normalized","real-world"]}))o[r]!==void 0&&!i.includes(o[r])&&v(r,"unsupported value.");if(o.cinematic!==void 0&&Gt(o.cinematic,"cinematic"),o.isolation!==void 0&&o.isolation!==null){let{target:r,mode:i,ghostOpacity:s}=o.isolation;typeof r=="string"||Array.isArray(r)&&r.every(a=>typeof a=="string")||r&&typeof r=="object"&&["group","tag","type"].some(a=>typeof r[a]=="string")||v("configuration.isolation","invalid target."),i!==void 0&&!["ghost","hide"].includes(i)&&v("configuration.isolation","invalid mode."),s!==void 0&&(typeof s!="number"||s<0||s>1)&&v("configuration.isolation","opacity must be between 0 and 1.")}return o}function Kt(e,t,n,o){if(!(!e||typeof e!="object"))for(let[r,i]of Object.entries(e))r!=="metadata"&&(typeof i=="string"&&["url","modelUrl","tilesetUrl","usdzUrl","path","image","src","href","imageUrl","customEnvironmentUrl"].includes(r)?Z(e,r,`${t}.${r}`,n,["path","image","src","imageUrl"].includes(r),o):Kt(i,`${t}.${r}`,n,o))}function Xt(e,t,n){typeof e=="string"&&(new TextEncoder().encode(e).length>ne&&v("state","exceeds the 5 MiB limit."),e=JSON.parse(e));let o=ao(e);W(o,"state"),new TextEncoder().encode(JSON.stringify(o)).length>ne&&v("state","exceeds the 5 MiB limit."),o.version!==void 0&&o.version!==1&&v("version","unsupported version."),o.version===void 0&&(o.objectBindings!==void 0||o.configuration!==void 0)&&v("version","full configurations require version 1.");let r={};return o.version!==void 0&&(r.version=1),o.camera!==void 0&&(so(o.camera,"camera"),r.camera=o.camera),o.hidden!==void 0&&(be(o.hidden,"hidden"),r.hidden=o.hidden),o.selected!==void 0&&(o.selected!==null&&typeof o.selected!="string"&&v("selected","expected an object id or null."),r.selected=o.selected),o.objectBindings!==void 0&&(Ht(o.objectBindings,"objectBindings",t,n),r.objectBindings=o.objectBindings),o.configuration!==void 0&&(r.configuration=co(o.configuration,t,n)),Kt(r,"state",t,n),new TextEncoder().encode(JSON.stringify(r)).length>ne&&v("state","exceeds the 5 MiB limit."),r}function gi(e,t){return JSON.stringify(Ie(e,t))}function Ie(e,t){return Xt(e,t)}async function Yt(e,t){let n=new Map,o=Xt(e,t,n),r=new Map,i=new Map;for(let[a,{source:c,path:l}]of n){let p=r.get(c);p||(p=(async()=>{let m;try{m=await fetch(c)}catch{v(l,"this temporary image is no longer available. Reload or reselect it before saving.")}m.ok||v(l,"could not read the temporary image. Reload or reselect it before saving.");let u=await m.blob();u.size>ne*3/4&&v(l,"embedded image exceeds the 5 MiB configuration limit. Use a hosted image URL.");let f=new Uint8Array(await u.arrayBuffer()),y=u.type.split(";")[0].toLowerCase(),M=y.startsWith("image/")?y:lo(f);M||v(l,"temporary asset is not a supported image. Use a hosted asset URL.");let S="";for(let x=0;x<f.length;x+=32768)S+=String.fromCharCode(...f.subarray(x,x+32768));return`data:${M};base64,${btoa(S)}`})(),r.set(c,p)),i.set(a,await p)}function s(a){if(!(!a||typeof a!="object"))for(let[c,l]of Object.entries(a))c!=="metadata"&&(["path","image","src","imageUrl"].includes(c)&&typeof l=="string"&&i.has(l)?a[c]=i.get(l):s(l))}return s(o),Ie(o,t)}function lo(e){let t=(n,o)=>String.fromCharCode(...e.subarray(n,o));if(e[0]===137&&t(1,4)==="PNG")return"image/png";if(e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";if(t(0,3)==="GIF")return"image/gif";if(t(0,4)==="RIFF"&&t(8,12)==="WEBP")return"image/webp";if(t(4,8)==="ftyp"&&["avif","avis"].includes(t(8,12)))return"image/avif";if(/<svg[\s>]/i.test(new TextDecoder().decode(e.subarray(0,1024))))return"image/svg+xml"}import{strFromU8 as uo,strToU8 as Zt,unzlibSync as mo,zlibSync as fo}from"fflate";var ke="ri-ar",Re="ri-ar-id",Jt=4096,po=2200,go=Zt(JSON.stringify(ce)).byteLength;function Qt(e){return e==="localhost"||e.endsWith(".localhost")||/^127\./.test(e)||e==="[::1]"||e==="0.0.0.0"}function en(e){if(typeof e=="string"&&/^https?:\/\//i.test(e)&&Qt(new URL(e).hostname))throw new Error("An asset URL points to this computer. Use model and texture URLs reachable from the phone.");if(e&&typeof e=="object")for(let t of Object.values(e))en(t)}function wi(e){return e&&typeof e=="object"?e:void 0}function Ci(e){let t=new URLSearchParams(new URL(e,"https://viewer.invalid/").hash.slice(1));return t.has(ke)||t.has(Re)}function bo(e,t){let n=new URL(e,t);if(!["https:","http:"].includes(n.protocol))throw new Error("AR handoff requires an HTTP(S) URL.");return n.toString()}function Ai(e,t="",n=2048){let o=new Set,r=i=>{if(typeof i=="string")return Te(i)??i;if(i===null||typeof i!="object")return i;if(o.has(i))throw new Error("AR configuration cannot contain cycles.");o.add(i);let s=Array.isArray(i)?i.map(r):Object.fromEntries(Object.keys(i).sort().map(a=>[a,r(i[a])]));return o.delete(i),s};return JSON.stringify([t,n,r({...e,camera:void 0})])}function tn(e,t){if(JSON.stringify(e)!==JSON.stringify(t))return e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,tn(o,t[n])]).filter(([,n])=>n!==void 0)):e}function nn(e,t,n=0){if(n>64)throw new Error("AR configuration is too deeply nested.");if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let o=e,r=t;return Object.fromEntries([...new Set([...Object.keys(r),...Object.keys(o)])].map(i=>[i,Object.prototype.hasOwnProperty.call(o,i)?nn(o[i],r[i],n+1):r[i]]))}return e}function on(e,t){let n=structuredClone(e);if(n.configuration){n.configuration.sceneConfig&&(n.configuration.sceneConfig=t(n.configuration.sceneConfig));for(let o of n.configuration.models??[])o.sceneConfig&&(o.sceneConfig=t(o.sceneConfig))}return n}function ye(e){e?.throwIfAborted()}async function Mi(e,t,n,o){ye(o);let r=new URL(bo(t));if(Qt(r.hostname))throw new Error("Phone links need a viewer URL reachable from your phone. Download the USDZ for local uploads, or provide a public viewer URL.");let i=await Yt(e,r.toString());ye(o),en(i);let s=new URLSearchParams(r.hash.slice(1));if(s.delete(ke),s.delete(Re),s.delete("view"),s.delete("viewId"),s.delete("view-id"),n){let a=await n.save(i);if(ye(o),typeof a!="string"||!a||a.length>512)throw new Error("AR storage returned an invalid configuration ID.");s.set(Re,a)}else{let a=fo(Zt(JSON.stringify({ar:1,state:on(i,l=>tn(l,ce)??{})})),{level:9});if(a.byteLength>Jt)throw new Error("This configuration needs an AR storage adapter to share on a phone. The USDZ download is still available.");let c="";for(let l of a)c+=String.fromCharCode(l);s.set(ke,btoa(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""))}if(r.hash=s.toString(),r.toString().length>po)throw new Error("This configuration is too large for a reliable QR code. Use an AR storage adapter or download the USDZ.");return r.toString()}async function Oi(e,t,n){let o=new URL(e),r=new URLSearchParams(o.hash.slice(1)),i=r.get(Re),s=r.get(ke);if(i!==null&&s!==null)throw new Error("AR link contains conflicting configurations.");if(i===null&&s===null)return null;ye(n);let a;if(i!==null){if(!t)throw new Error("This AR link requires the application's configuration storage adapter.");if(!i||i.length>512)throw new Error("Invalid AR configuration ID.");a=await t.load(i)}else{if(!s||s.length>Math.ceil(Jt*4/3)||!/^[\w-]+$/.test(s))throw new Error("Invalid or oversized AR link.");let l=atob(s.replace(/-/g,"+").replace(/_/g,"/")),p=Uint8Array.from(l,f=>f.charCodeAt(0)),m=mo(p);if(m.byteLength>ne)throw new Error("AR configuration exceeds the 5 MiB limit.");let u=JSON.parse(uo(m));if(u?.ar===1&&u.state){let f=u.state.configuration,y=(f?.sceneConfig?1:0)+(Array.isArray(f?.models)?f.models.filter(M=>M?.sceneConfig).length:0);if(m.byteLength+y*go>ne)throw new Error("Expanded AR configuration exceeds the 5 MiB limit.");a=on(u.state,M=>nn(M,ce))}else a=u}ye(n);let c=Ie(a,o.toString());if(c.version!==1||!c.configuration)throw new Error("AR handoff requires a complete versioned viewer configuration.");return c}var Qe=new WeakMap;function vi(e,t){t?Qe.set(e,t):Qe.delete(e)}function rn(e){e.traverse(t=>{let n=Qe.get(t);if(n)throw new Error(n)})}import{Box3 as Bo,BufferAttribute as wn,BufferGeometry as Cn,Color as Po,DoubleSide as Vo,FrontSide as rt,Group as An,Matrix4 as No,Mesh as zo,Vector3 as Be}from"three";import{PropertyBinding as et}from"three";var tt=Symbol("react-immersive.model-node-id");function yo(e,t){Object.defineProperty(e,tt,{value:t,configurable:!0})}function oe(e){let t=new Map;e.traverse(c=>{if(!c.name)return;let l=t.get(c.name);l?l.push(c):t.set(c.name,[c])});let n=Object.create(null),o=new WeakMap,r=new Map,i=new Set(Array.from(t,([c,l])=>l.length===1?c:null).filter(c=>c!==null)),s=new Set,a=(c,l)=>{yo(c,l),n[l]=c,o.set(c,l),s.add(l)};for(let[c,l]of t)l.length===1&&a(l[0],c);for(let[c,l]of t){if(l.length<2)continue;let p=[];l.forEach((m,u)=>{let f=`${c} [${u+1}]`,y=f,M=2;for(;i.has(y)||s.has(y);)y=`${f}.${M++}`;a(m,y),p.push(y)}),r.set(c,p)}return{nodesById:n,idByNode:o,duplicateNames:r}}function he(e){return e[tt]??e.name??null}function ki(e,t){let n=t.replace(/\.[^./\\]+$/,"");e.traverse(o=>{o.name&&(o.name=et.sanitizeNodeName(`${n}_${o.name}`))})}function Ri(e,t){let n=t.replace(/\.[^./\\]+$/,""),o=e.clone();for(let r of o.tracks){let s=et.parseTrackName(r.name).nodeName??"",a=et.sanitizeNodeName(`${n}_${s}`);r.name=a+r.name.slice(s.length)}return o}function an(e,t){let n=null,o=[];return e.traverse(r=>{r[tt]===t&&(n=r),r.name===t&&o.push(r)}),n??(o.length===1?o[0]:null)}import{AnimationClip as Mo,Group as Oo,Matrix4 as jo,PropertyBinding as bn}from"three";import{clone as vo}from"three/examples/jsm/utils/SkeletonUtils.js";import{strFromU8 as To,strToU8 as yn,unzipSync as Io,zipSync as ko}from"fflate";import{AnimationMixer as ho,LoopOnce as So,LoopPingPong as sn,LoopRepeat as xo}from"three";function cn(e){let t=e._loopCount;return e.loop===sn&&(t&1)===1}function wo(e){return cn(e)?e.getClip().duration-e.time:e.time}function ln({root:e,clips:t,getClipConfig:n,onChange:o}){let r=new ho(e),i=new Map;for(let{clip:d,sourceName:h}of t)i.set(h,r.clipAction(d));let s=new Map,a=new Set,c=new Map,l=1,p=d=>typeof d=="string",m=d=>p(d)?s.has(d)?[d]:[]:[...s.keys()],u=(d,h)=>{let A=ht(n(h));A==="once"?d.setLoop(So,1):A==="ping-pong"?d.setLoop(sn,1/0):d.setLoop(xo,1/0),d.clampWhenFinished=A==="once"},f=d=>{d.action.setEffectiveTimeScale(d.reverse?-d.speed:d.speed)},y=d=>{let h=s.get(d);h&&(h.action.stop(),s.delete(d))},M=(d,h={})=>{let A=i.get(d);if(!A||n(d)?.hidden)return;let T=Number.isFinite(h.fade)&&h.fade>0?h.fade:0,E=h.reverse??!1;if(!h.alongside)for(let[j,N]of[...s])j!==d&&(T>0?(s.delete(j),N.action.fadeOut(T),a.add(N.action)):y(j));a.delete(A)&&A.stop();let D=A.getClip().duration,V=s.get(d),F=()=>{A.reset(),E&&(A.time=D),A.play()};if(!V)F(),T>0&&A.fadeIn(T);else{let j=E?A.time<=0:A.time>=D;V.finished&&j&&F(),A.paused=!1,A.enabled=!0,s.delete(d)}u(A,d),V={action:A,speed:n(d)?.speed??c.get(d)??l,reverse:E,finished:!1},V.speed=Ae(V.speed),f(V),s.set(d,V),o()},S=d=>{for(let h of m(d))s.get(h).action.paused=!0;o()},x=d=>{for(let h of m(d))y(h);if(!p(d)){for(let h of a)h.stop();a.clear()}o()},w=(d,h)=>{let A=Ae(d);p(h)?c.set(h,A):l=A;for(let T of m(h)){let E=s.get(T);c.set(T,A),E.speed=A,f(E)}o()},b=(d,h)=>{for(let A of m(h)){let T=s.get(A),E=T.action.getClip().duration,D=Math.min(Math.max(d,0),E);T.action.time=cn(T.action)?E-D:D,T.finished&&(T.finished=!1,T.action.paused=!0)}r.update(0),o()},C=()=>{for(let[d,h]of[...s]){let A=n(d);if(A?.hidden){y(d);continue}u(h.action,d),A?.speed!==void 0&&(h.speed=Ae(A.speed),f(h))}o()},O=d=>{for(let h of s.values())h.action===d.action&&(h.finished=!0);o()};return r.addEventListener("finished",O),{play:M,pause:S,stop:x,setSpeed:w,seek:b,getState:()=>{let d=[...s].map(([A,T])=>({clip:A,status:T.finished?"finished":T.action.paused?"paused":"playing",time:wo(T.action),duration:T.action.getClip().duration,speed:T.speed,reverse:T.reverse})),h=d[d.length-1];return{currentClip:h?.clip??null,isPlaying:d.some(A=>A.status==="playing"),speed:h?.speed??l,time:h?.time??0,duration:h?.duration??0,active:d}},applyClipConfigs:C,isRunning:()=>{if(a.size>0)return!0;for(let{action:d}of s.values())if(!d.paused&&d.enabled)return!0;return!1},update:d=>{r.update(d);for(let h of a)(!h.enabled||h.getEffectiveWeight()<=0)&&(h.stop(),a.delete(h))},dispose:()=>{r.removeEventListener("finished",O),r.stopAllAction(),r.uncacheRoot(e),s.clear(),a.clear()}}}import{Color as mn}from"three";import{Matrix4 as un,Quaternion as Co,Vector3 as Ee}from"three";function Ao(e){return new un().set(1,e[0],e[1],0,0,1,e[2],0,0,0,1,0,0,0,0,1)}function nt(e,t){e.matrixAutoUpdate=!t,e.updateMatrix(),t&&(e.matrix.makeRotationFromQuaternion(e.quaternion).multiply(Ao(t)).scale(e.scale).setPosition(e.position),e.matrixWorldNeedsUpdate=!0)}function dn(e,t,n){let o=new Ee().setFromMatrixColumn(e,0),r=new Ee().setFromMatrixColumn(e,1),i=new Ee().setFromMatrixColumn(e,2),s=(y,M)=>{let S=y*(M<0?-1:1);return Math.abs(S-M)<1e-10?M:S},a=s(o.length(),t.x);if(Math.abs(a)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};o.divideScalar(a);let c=o.dot(r);r.addScaledVector(o,-c);let l=s(r.length(),t.y);if(Math.abs(l)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};r.divideScalar(l);let p=o.dot(i);i.addScaledVector(o,-p);let m=r.dot(i);i.addScaledVector(r,-m);let u=s(i.length(),t.z);if(Math.abs(u)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};i.divideScalar(u);let f=[c/l,p/u,m/u].map(y=>Math.abs(y)<1e-10?0:y);return{rotation:new Co().setFromRotationMatrix(new un().makeBasis(o,r,i)).normalize(),scale:new Ee(a,l,u),shear:f.some(Boolean)?f:void 0}}var ot=e=>e==="baseColor"?"color":e;function fn(e){let t=new Set;return e.traverse(n=>{let o=n;if(o.isMesh)for(let r of Array.isArray(o.material)?o.material:[o.material])r&&t.add(r)}),[...t]}function pn({root:e,controls:t,animations:n,invalidate:o,cameraEnabled:r=()=>!0}){let i=new Map,s=new Map,a=new Map,c=new Set,l=new Map,p=null,m="",u=b=>e()?an(e(),b):null,f=b=>{if(b.kind==="camera"){let R=t();if(!R)return null;let g=Q(R.camera,R);return{position:g.position,target:g.target,fov:g.fov,zoom:g.zoom}}if(b.kind==="clip"){let R=n();return R?.clips.includes(b.clip)?R.getState?.().active.find(g=>g.clip===b.clip)?.time??0:null}let C=u(b.objectId);if(!C)return null;let O=b.property;if(O==="position"||O==="rotation"||O==="scale")return[C[O].x,C[O].y,C[O].z];if(O==="visible")return C.visible;let k=fn(C).find(R=>R[ot(O)]!==void 0),I=k?k[ot(O)]:void 0;return I?.isColor?`#${I.getHexString()}`:typeof I=="number"?I:null},y=b=>{if(!r())return;let C=t();C&&(C.stop(),C.setLookAt(...b.position,...b.target,!1),b.fov!==null&&"fov"in C.camera&&(C.camera.fov=b.fov,C.camera.updateProjectionMatrix()),C.zoomTo(b.zoom,!1),C.update(0))},M=b=>{if(i.has(b))return;b.updateWorldMatrix(!0,!0);let C=b.matrixAutoUpdate?void 0:dn(b.matrix,b.scale,b.quaternion).shear;i.set(b,{position:b.position.toArray(),rotation:[b.rotation.x,b.rotation.y,b.rotation.z],scale:b.scale.toArray(),matrix:b.matrix.clone(),auto:b.matrixAutoUpdate,shear:C});for(let O of ut(b))dt(O)||(mt(O,O.matrixWorld),c.add(O))},S=(b,C)=>{let O=n();O?.stop(b),C&&O&&(O.play(b,{alongside:!0,reverse:C.reverse}),O.setSpeed(C.speed,b),O.seek?.(C.time,b),C.status!=="playing"&&O.pause(b))};return{capture:f,restore:()=>{for(let[b,C]of l)S(b,C);l.clear();for(let[b,C]of i)b.position.fromArray(C.position),b.rotation.set(...C.rotation),b.scale.fromArray(C.scale),b.matrix.copy(C.matrix),b.matrixAutoUpdate=C.auto,b.matrixWorldNeedsUpdate=!0;i.clear(),s.forEach((b,C)=>C.visible=b),s.clear(),a.forEach((b,C)=>{b.forEach((O,k)=>{O instanceof mn?C[k].copy(O):C[k]=O}),C.needsUpdate=!0}),a.clear(),c.forEach(pt),c.clear(),p&&y(p),p=null,m="",e()?.updateWorldMatrix(!0,!0),o()},inspect:b=>b.tracks.filter(C=>!C.muted&&C.keyframes.length&&(C.target.kind!=="camera"||r())&&f(C.target)===null).map(C=>`Unavailable target: ${C.name}.`),invalidate:o,apply:({sequence:b,time:C,playing:O})=>{let k=b.tracks.filter(g=>g.target.kind!=="camera"||r()).map(g=>({track:g,value:at(g,C)})).filter(g=>g.value!==null);for(let[g,d]of l)k.some(({track:h})=>h.target.kind==="clip"&&h.target.clip===g)||(S(g,d),l.delete(g));for(let{track:g}of k)if(g.target.kind==="object"&&["position","rotation","scale"].includes(g.target.property)){let d=u(g.target.objectId);d&&M(d)}let I=new Map([...a.keys()].map(g=>[g,g.transparent]));s.forEach((g,d)=>d.visible=g),i.forEach((g,d)=>{d.position.fromArray(g.position),d.rotation.set(...g.rotation),d.scale.fromArray(g.scale),nt(d,g.shear)}),a.forEach((g,d)=>g.forEach((h,A)=>{h instanceof mn?d[A].copy(h):d[A]=h}));let R=n();for(let{track:g,value:d}of k){if(g.target.kind!=="clip"||!R?.seek||!R.clips.includes(g.target.clip))continue;let h=g.target.clip;l.has(h)||(l.set(h,R.getState?.().active.find(A=>A.clip===h)),R.play(h,{alongside:!0}),R.pause(h)),R.seek(d,h)}for(let{track:g,value:d}of k){let h=g.target;if(h.kind==="clip")continue;if(h.kind==="camera"){p||(p=f(h));let E=JSON.stringify(d);(O||E!==m)&&(y(d),m=E);continue}let A=u(h.objectId);if(!A)continue;let T=h.property;if(T==="visible")s.has(A)||s.set(A,A.visible),A.visible=d;else if(T==="position"||T==="rotation"||T==="scale")T==="rotation"?A.rotation.set(...d):A[T].fromArray(d),nt(A,i.get(A)?.shear);else for(let E of fn(A)){let D=ot(T),V=E[D];if(V===void 0)continue;let F=a.get(E);if(F||(F=new Map,a.set(E,F)),I.has(E)||I.set(E,E.transparent),F.has(D)||F.set(D,V?.isColor?V.clone():V),V?.isColor?V.set(d):E[D]=d,T==="opacity"){F.has("transparent")||F.set("transparent",E.transparent);let j=d<1||F.get("transparent")===!0;E.transparent=j}}}p&&!k.some(({track:g})=>g.target.kind==="camera")&&(y(p),m=""),I.forEach((g,d)=>{g!==d.transparent&&(d.needsUpdate=!0)}),e()?.updateWorldMatrix(!0,!0)}}}function gn(e){let t=new Map;return e.map((n,o)=>{let i=n.name.trim()||`Animation ${o+1}`,s=t.get(i)??0;return t.set(i,s+1),{clip:n,sourceName:s===0?i:`${i} (${s+1})`,duration:n.duration}})}var ue=30,Ro=12e4,hn=new Set(["position","quaternion","rotation","scale"]);function Eo(e){let t=xe(e.sceneConfig?.sequences??[]).find(l=>l.autoPlay),n=e.sceneConfig?.animations.autoplayClip,o=gn(e.scene.animations),r=o.find(l=>l.sourceName===n),i=e.sceneConfig?.animations.clips.find(l=>l.sourceName===n),s=i?.speed??1,a=Number.isFinite(s)&&s>0?s:1,c=r&&!i?.hidden?r.duration*(i?.loopMode==="ping-pong"?2:1)/a:0;return{sequence:t,autoplay:n,clips:o,duration:Math.max(c,t?.duration??0)}}function Sn(e,t,n){let o=new Set,r=new Map,i=0,s=0,a=e.map(Eo),c=Math.max(0,...a.map(l=>l.duration));for(let[l,p]of e.entries()){n?.throwIfAborted();let{sequence:m,autoplay:u}=a[l];if(!m&&!u)continue;let f=vo(p.scene),y=[],M=[];p.scene.traverse(j=>y.push(j)),f.traverse(j=>M.push(j));let S=new Map;y.forEach((j,N)=>{M[N].uuid=j.uuid,S.set(j,M[N])});let x=oe(f),w=new Oo;w.matrixAutoUpdate=!1,w.matrix.copy(p.scene.parent?.matrixWorld??new jo),w.add(f);let b=new Set(m?.tracks.filter(j=>!j.muted&&j.target.kind==="clip").map(j=>j.target.kind==="clip"?j.target.clip:"")??[]);u&&b.add(u);let C=a[l].clips.map(j=>{if(!b.has(j.sourceName))return j;let N=j.clip.tracks.filter(_=>{let L=bn.parseTrackName(_.name),K=bn.findNode(f,L.nodeName),$=!!K&&hn.has(L.propertyName)&&K?.type!=="Bone"&&!L.objectName;return $||o.add("Quick Look exports object motion. Skeletal, morph and other clip tracks keep their captured pose."),$});return{...j,clip:new Mo(j.clip.name,j.duration,N)}}),O=j=>p.sceneConfig?.animations.clips.find(N=>N.sourceName===j),k=ln({root:f,clips:C,getClipConfig:O,onChange(){}}),I={...k,clips:C.map(j=>j.sourceName)},R=pn({root:()=>f,controls:()=>null,animations:()=>I,invalidate(){},cameraEnabled:()=>!1}),g=m?.tracks.filter(j=>{if(j.target.kind==="object"&&x.nodesById[j.target.objectId]?.type==="Bone")return j.muted||o.add("Quick Look keeps skeletal deformation at its captured pose."),!1;let N=j.target.kind==="clip"||j.target.kind==="object"&&hn.has(j.target.property);return!N&&!j.muted&&o.add("Quick Look exports sequence object motion. Camera, visibility and appearance tracks stay in WebXR."),N}),d=m?{...m,tracks:g??[]}:void 0;d&&R.inspect(d).forEach(j=>o.add(j));let h=C.some(j=>b.has(j.sourceName)&&j.clip.tracks.length&&!O(j.sourceName)?.hidden),A=g?.some(j=>!j.muted&&j.keyframes.length&&j.target.kind==="object");if(!h&&!A){k.dispose();continue}let T=c,E=t.filter(j=>j.sourceIndex===l),D=Math.ceil(T*ue);if(s+=(D+1)*E.length,!Number.isFinite(T)||s>Ro)throw k.dispose(),new Error("This animation is too large for browser USDZ conversion. Use arHandoff.createUSDZ for this model.");let V=Object.entries(p.objectBindings??{}).flatMap(([j,N])=>{if(!N.transform)return[];let _=x.nodesById[N.modelObjectId??j];return _?[{node:_,matrix:_.matrix.clone(),position:_.position.clone(),quaternion:_.quaternion.clone(),scale:_.scale.clone()}]:[]}),F=E.map(j=>({target:j,node:S.get(j.source),inverse:j.bakedMatrix.clone().invert(),frames:[]}));try{u&&k.play(u);let j=0;for(let N=0;N<=D;N++){n?.throwIfAborted();let _=Math.min(N/ue,T);k.update(_-j),j=_;for(let L of V)L.node.position.copy(L.position),L.node.quaternion.copy(L.quaternion),L.node.scale.copy(L.scale),L.node.matrix.copy(L.matrix);if(d){let L=d.loop&&_>d.duration?_%d.duration:Math.min(_,d.duration);R.apply({sequence:d,time:L,playing:!1})}w.updateMatrixWorld(!0);for(let L of F){let K=L.node.matrixWorld.clone().multiply(L.target.instanceMatrix).multiply(L.inverse);if(!K.elements.every(Number.isFinite)||K.determinant()<=0)throw new Error("Quick Look animation cannot preserve a reflected or zero-scale transform. Use arHandoff.createUSDZ.");L.frames.push({time:_*ue,matrix:K.toArray()})}}for(let N of F){let _=N.frames[0]?.matrix;_&&N.frames.some(L=>L.matrix.some((K,$)=>Math.abs(K-_[$])>1e-8))&&(r.set(N.target.exported.name,N.frames),i=Math.max(i,T))}}finally{R.restore(),k.dispose()}}return{samples:r,duration:i,warnings:[...o]}}function xn(e,t){if(!t.samples.size)return e;let n=Io(e),o=To(n["model.usda"]);o=o.replace(" metersPerUnit = 1",` startTimeCode = 0
3
- endTimeCode = ${t.duration*ue}
4
- timeCodesPerSecond = ${ue}
5
- framesPerSecond = ${ue}
6
- metersPerUnit = 1`);for(let[s,a]of t.samples){let c=new RegExp(`(def Xform "${s}"[\\s\\S]*?\\n[\\t ]*)matrix4d xformOp:transform = [^\\n]+`);if(!c.test(o))throw new Error("The USDZ exporter produced an unsupported animation layout.");let l=a.map(p=>{let m=[0,4,8,12].map(u=>`(${p.matrix.slice(u,u+4).join(", ")})`);return`${p.time}: (${m.join(", ")})`}).join(`,
7
- `);o=o.replace(c,(p,m)=>`${m}matrix4d xformOp:transform.timeSamples = {
8
- ${l}
9
- }`)}n["model.usda"]=yn(o);let r={},i=0;for(let[s,a]of Object.entries(n)){i+=34+yn(s).length;let c=i&63;r[s]=c===4?a:[a,{extra:{12345:new Uint8Array(64-c)}}],i=a.length}return ko(r,{level:0})}function Lo(e,t={}){t.signal?.throwIfAborted();let n=new An,o=new An;n.add(o);let r=new Set,i=[],s=[],a=[],c=new Map,l=[],p=0,m=0,u=()=>{i.forEach(f=>f.dispose()),s.forEach(f=>f.dispose()),a.forEach(f=>f.dispose())};try{for(let[x,{scene:w,objectBindings:b={},materialOverrides:C={}}]of e.entries()){rn(w),w.updateWorldMatrix(!0,!0);let O=new Map(Object.entries(b).map(([k,I])=>[I.modelObjectId??k,k]));w.traverse(k=>{let I=k;if(!I.isMesh||!I.geometry)return;for(let T=k;T;T=T.parent){let E=he(T)??T.name??T.uuid;if(!T.visible||b[O.get(E)??E]?.visible===!1||b[O.get(E)??E]?.removed)return}let R=he(I)??I.name??I.uuid,g=C[O.get(R)??R]??I.material;if(!g)throw new Error(`Material for ${R} is not ready. Wait for the model to finish loading.`);let d=Array.isArray(g)?g:[g],h=I.isInstancedMesh?I.count:1;if(I.userData.riDecal&&we(I)&&I.parent){let T=ft(I.parent);T&&I.bindMatrixInverse.copy(T)}let A=we(I)?gt(I):I.geometry.clone();try{if(!we(I)&&I.morphTargetInfluences?.some(D=>D!==0)){let D=A.getAttribute("position"),V=new Be;for(let F=0;F<D.count;F++)I.getVertexPosition(F,V),D.setXYZ(F,V.x,V.y,V.z);A.morphAttributes={},A.computeVertexNormals()}if(!A.getAttribute("position"))throw new Error(`Mesh ${R} has no positions.`);let T=A.index?.count??A.getAttribute("position").count,E=Array.isArray(g)?A.groups:[{start:0,count:T,materialIndex:0}];if(!E.length)throw new Error(`Mesh ${R} has multiple materials without geometry groups.`);for(let D=0;D<h;D++){let V=I.matrixWorld.clone(),F=new No;I.isInstancedMesh&&(I.getMatrixAt(D,F),V.multiply(F));for(let j of E){let N=d[j.materialIndex??0];if(!N)throw new Error(`A material group on ${R} is missing its material.`);if(!N.visible)continue;let _=N;if(!_.isMeshStandardMaterial||_.wireframe||_.vertexColors)throw new Error(`AR snapshot cannot preserve ${N.type}${_.wireframe?" wireframe":_.vertexColors?" vertex colors":""} on ${R}. Use a PBR material or provide arHandoff.createUSDZ.`);let L=Math.max(j.start,A.drawRange.start),K=Math.min(T,j.start+j.count,A.drawRange.start+A.drawRange.count);if(K<=L)continue;if(L%3||(K-L)%3)throw new Error(`Mesh ${R} has an incomplete triangle range.`);let $=new Cn;i.push($);let J=Array.from({length:K-L},(B,z)=>A.index?A.index.getX(L+z):L+z);if(V.determinant()<0)for(let B=0;B<J.length;B+=3)[J[B+1],J[B+2]]=[J[B+2],J[B+1]];for(let[B,z]of Object.entries(A.attributes)){let P=new Float32Array(J.length*z.itemSize);for(let U=0;U<J.length;U++)for(let X=0;X<z.itemSize;X++)P[U*z.itemSize+X]=z.getComponent(J[U],X);$.setAttribute(B,new wn(P,z.itemSize))}$.setIndex(J.map((B,z)=>z)),$.applyMatrix4(V);let Se=$.getAttribute("position");for(let B=0;B<Se.count;B++)if(![Se.getX(B),Se.getY(B),Se.getZ(B)].every(Number.isFinite))throw new Error(`Mesh ${R} contains invalid coordinates.`);$.getAttribute("normal")||$.computeVertexNormals();let G=_.clone();s.push(G);let it=_.userData.reactImmersiveConfiguredEmissive;if(it?.isColor&&G.emissive.copy(it),G.side===Vo){let B=$.toNonIndexed();i.push(B);let z=B.getAttribute("position").count,P=new Cn;i.push(P);for(let[U,X]of Object.entries(B.attributes)){let ze=new Float32Array(z*X.itemSize*2);for(let ee=0;ee<z;ee++)for(let ie=0;ie<X.itemSize;ie++){ze[ee*X.itemSize+ie]=X.getComponent(ee,ie);let En=Math.floor(ee/3)*3+(2-ee%3);ze[(z+ee)*X.itemSize+ie]=X.getComponent(En,ie)*(U==="normal"?-1:1)}P.setAttribute(U,new wn(ze,X.itemSize))}G.side=rt,$.copy(P)}else if(G.side!==rt){let B=$.getIndex();for(let P=0;P<B.count;P+=3){let U=B.getX(P+1);B.setX(P+1,B.getX(P+2)),B.setX(P+2,U)}let z=$.getAttribute("normal");for(let P=0;P<z.count;P++)z.setXYZ(P,-z.getX(P),-z.getY(P),-z.getZ(P));G.side=rt}if(I.isInstancedMesh&&I.instanceColor){let B=new Po;I.getColorAt(D,B),G.color.multiply(B)}for(let[B,z]of Object.entries(G)){if(!z?.isTexture)continue;let P=z;if($t(P)||!P.image||P.image.complete===!1)throw new Error(`Texture on ${R} is not ready. Wait for image loading or replace failed textures before preparing AR.`);let U=c.get(P);if(U||(U=P.clone(),c.set(P,U),a.push(U)),G[B]=U,!$.getAttribute(U.channel?`uv${U.channel}`:"uv"))throw new Error(`Texture on ${R} needs UV coordinates missing from this geometry.`)}if(I.userData.riDecal){$.computeBoundingBox();let B=Math.max(1e-6,$.boundingBox.getSize(new Be).length()*1e-4),z=$.getAttribute("position"),P=$.getAttribute("normal");for(let U=0;U<z.count;U++)z.setXYZ(U,z.getX(U)+P.getX(U)*B,z.getY(U)+P.getY(U)*B,z.getZ(U)+P.getZ(U)*B)}let Ne=new zo($,G);Ne.name=`AR_${p++}`,o.add(Ne),l.push({sourceIndex:x,source:I,exported:Ne,bakedMatrix:V.clone(),instanceMatrix:F}),m+=($.index?.count??$.getAttribute("position").count)/3,(G.clearcoat||G.transmission||G.iridescence||G.anisotropy)&&r.add("Advanced PBR effects may look different in Quick Look.")}}}finally{A.dispose()}})}if(!p||!m)throw new Error("There is no visible model geometry to send to AR.");let f=new Bo().setFromObject(o),y=f.getSize(new Be),M=f.getCenter(new Be),S=t.scaleMode==="real-world"?1:1/Math.max(y.x,y.y,y.z,1e-9);return o.position.set(-M.x*S,-f.min.y*S,-M.z*S),o.scale.setScalar(S),n.updateMatrixWorld(!0),r.add("Viewer lighting, background, post-processing, annotations and measurement overlays stay in the web viewer."),{root:n,meshCount:p,triangleCount:m,scale:S,warnings:[...r],textures:a,motionMeshes:l,dispose:u}}catch(f){throw u(),f}}async function fa(e,t={}){let n=t.maxTextureSize??2048;if(!Number.isInteger(n)||n<256||n>4096)throw new Error("AR maxTextureSize must be an integer from 256 to 4096.");let o=Lo(e,t),r=[];try{let i=Sn(e,o.motionMeshes,t.signal),{USDZExporter:s}=await import("three/examples/jsm/exporters/USDZExporter.js");t.signal?.throwIfAborted();for(let l of o.textures){if(!l.isCompressedTexture)continue;let{decompress:p}=await import("three/examples/jsm/utils/WebGLTextureUtils.js"),m=p(l,n);r.push(m),o.root.traverse(u=>{let f=u.material;if(f)for(let y of Object.keys(f))f[y]===l&&(f[y]=m)})}let a=await new s().parseAsync(o.root,{onlyVisible:!0,quickLookCompatible:!0,maxTextureSize:n});t.signal?.throwIfAborted();let c=xn(a,i);return{blob:new Blob([new Uint8Array(c)],{type:"model/vnd.usdz+zip"}),meshCount:o.meshCount,triangleCount:o.triangleCount,scale:o.scale,warnings:[...o.warnings,...i.warnings]}}catch(i){if(t.signal?.aborted)throw i;let s=i instanceof Error&&i.name==="SecurityError"?" Textures must allow cross-origin canvas access.":"";throw new Error(`Could not prepare the configured USDZ: ${i instanceof Error?i.message:"export failed"}${s}`)}finally{o.dispose(),r.forEach(i=>i.dispose())}}var Pe=Object.freeze([{id:"change-color",label:"Change Color",handling:"viewer",description:"Opens a color picker docked under the action and commits the result to style.material.baseColor."},{id:"change-material",label:"Change Material",handling:"viewer",description:"Opens the material picker so the viewer can swap the object's texture."},{id:"add-text",label:"Add Text",handling:"viewer",description:"Opens a text box docked under the action; the viewer's user types, clicks the object to place it, and can resize, turn, move, or remove it. Saved to the binding's decals."},{id:"add-image",label:"Add Image",handling:"viewer",description:"Lets the viewer's user choose an image, click the object to place it, and resize, turn, move, or remove it. Saved to the binding's decals."},{id:"toggle-visibility",label:"Toggle Visibility",handling:"viewer",description:"Flips the binding's visible flag."},{id:"toggle-light",label:"Toggle Light",handling:"viewer",description:"Turns the scene lights attached to this object on or off, or the object's own glow when none is attached."},{id:"change-light-color",label:"Change Light Color",handling:"viewer",description:"Opens a color picker docked under the action for the scene lights attached to this object, or the object's own glow."},{id:"set-brightness",label:"Set Brightness",handling:"viewer",description:"Opens a brightness slider docked under the action for the scene lights attached to this object, or the object's own glow."}]),ga="__custom__";function Do(e){return Pe.find(t=>t.id===e)}var On=Pe.filter(e=>e.handling==="viewer").map(e=>e.id),Uo=new Set(["","New Action",...Pe.map(e=>e.label)]);function ba(e){return Uo.has(e.trim())}function Mn(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o+=1){let r=[o];for(let i=1;i<=t.length;i+=1){let s=n[i-1]+(e[o-1]===t[i-1]?0:1);r[i]=Math.min(r[i-1]+1,n[i]+1,s)}n=r}return n[t.length]}function ya(e){if(Do(e))return null;let t=e.trim().toLowerCase();if(!t)return null;let n=t.replace(/[^a-z0-9]/g,""),o=null;for(let r of Pe){let i=Math.min(Mn(t,r.id),Mn(n,r.id.replace(/[^a-z0-9]/g,"")));(!o||i<o.distance)&&(o={id:r.id,distance:i})}return o&&o.distance<=2?o.id:null}var _o=.12,jn=new Set;function $o(e,t){return t?new Set(Ce(e,t.target)):jn}function xa(e,t){let n=$o(e.bindings,t);if(!t||n.size===0)return{...e,setAside:jn};let o=Math.min(Math.max(t.ghostOpacity??_o,0),1),r={...e.bindings},i=new WeakMap,s=new Set;for(let[a,c]of Object.entries(e.bindings)){if(n.has(a))continue;s.add(a);let l=t.mode==="hide"?{...c,visible:!1}:{...c,style:{...c.style,material:{...c.style?.material,opacity:Math.min(c.style?.material?.opacity??1,o)}}};r[a]=l,i.set(l,e.sourceOf(c))}return{bindings:r,pulses:e.pulses,sourceOf:a=>i.get(a)??e.sourceOf(a),setAside:s}}function Fo(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function qo(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function Wo(e){let t=e.toLowerCase();return t.includes("light")?"light":t.includes("wheel")||t.includes("rim")||t.includes("tire")?"wheel":t.includes("glass")||t.includes("window")||t.includes("windshield")||t.includes("sunroof")?"glass":t.includes("seat")||t.includes("dashboard")||t.includes("console")||t.includes("doorpanel")?"interior":t.includes("floor")?"floor":t.includes("wall")?"wall":t.includes("door")?"door":t.includes("chair")||t.includes("table")||t.includes("sofa")||t.includes("bed")?"furniture":"other"}function vn(e,t=!0){return e==="light"||e.endsWith("light")?[{id:"toggle-light",label:"Toggle Light",type:"command"},{id:"change-light-color",label:"Change Light Color",type:"command"},{id:"set-brightness",label:"Set Brightness",type:"command"}]:[{id:"change-color",label:"Change Color",type:"command"},...t?[{id:"change-material",label:"Change Material",type:"command"}]:[],{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function Tn(e,t=!0){let n=Wo(e);return{id:Fo(e),modelObjectId:e,type:n,label:qo(e),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:vn(n,t),metrics:{},metadata:{}}}function Oa(e,t){return Object.fromEntries(e.map(n=>[n,Tn(n,!t?.has(n))]))}function ja(e,t){let n=new Set,o={};for(let r of e){let i=Tn(r,!t?.has(r)),s=i.id||"object",a=s;for(let l=2;n.has(a);l++)a=`${s}-${l}`;n.add(a),i.id=a;let c=(i.actions??[]).filter(l=>On.includes(l.id));i.actions=c.length>0?c:vn("other",!t?.has(r)),o[r]=i}return o}function va(e){let t=new Set;for(let[n,o]of Object.entries(oe(e).nodesById))yt(o)||t.add(n);return t}function Ta(e){let{nodesById:t}=oe(e),n=[];for(let[o,r]of Object.entries(t)){let i=r;i.isMesh&&i.geometry&&r.name&&n.push(o)}return n.sort((o,r)=>o.localeCompare(r))}var Rn={id:"identity",modelObjectId:"identity",label:"identity",type:"identity",group:"identity",tags:"identity",style:"appearance",decals:"appearance",transform:"transform",visible:"visibility",removed:"visibility",status:"visibility",selectable:"behavior",hoverable:"behavior",actions:"behavior",cameraState:"behavior",metadata:"data",metrics:"data"},Go=Object.keys(Rn),Ho=new Set(["__proto__","prototype","constructor"]);function re(e,t=new Set){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("Comparison values must be finite JSON data");return e}if(typeof e!="object"||t.has(e))throw new Error("Comparison values must be acyclic JSON data");t.add(e);let n=Array.isArray(e)?e.map(o=>re(o,t)):Object.fromEntries(Object.entries(e).filter(([o,r])=>!Ho.has(o)&&r!==void 0).map(([o,r])=>[o,re(r,t)]));return t.delete(e),n}var In=e=>e&&typeof e=="object"&&!Array.isArray(e)&&!Object.keys(e).length;function kn(e,t){let n=re(e);n.visible=e.visible??!0,n.selectable=e.selectable??!0,n.hoverable=e.hoverable??!0,n.status=e.status??"normal",n.type=e.type??"other",n.tags=[...new Set(e.tags??[])].sort(),In(n.transform)&&delete n.transform,n.metadata=Object.fromEntries(Object.entries(e.metadata??{}).filter(([o])=>!t.includes(o)));for(let o of["metrics","style","metadata"])In(n[o])&&delete n[o];for(let o of["actions","decals"])Array.isArray(n[o])&&!n[o].length&&delete n[o];return n}function Ve(e,t,n,o,r,i){let s=c=>c===void 0||Array.isArray(c)&&c.length===0;if(Object.is(e,t)||s(e)&&s(t)||typeof e=="number"&&typeof t=="number"&&Math.abs(e-t)<=r)return;let a=c=>!!c&&typeof c=="object"&&!Array.isArray(c);if(a(e)&&a(t)){for(let c of[...new Set([...Object.keys(e),...Object.keys(t)])].sort())Ve(e[c],t[c],`${n}.${c}`,o,r,i);return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let c=0;c<e.length;c++)Ve(e[c],t[c],`${n}[${c}]`,o,r,i);return}i.push({path:n,category:o,...e!==void 0?{before:re(e)}:{},...t!==void 0?{after:re(t)}:{}})}function ka(e,t,n={}){let o=n.tolerance??1e-6;if(!Number.isFinite(o)||o<0)throw new Error("Comparison tolerance must be finite and nonnegative");let r=Object.entries(e.objectBindings).filter(([,x])=>!x.removed),i=Object.entries(t.objectBindings).filter(([,x])=>!x.removed),s=new Map(r),a=new Map(i),c=new Set,l=new Set,p=[],m=x=>{let w=n.matchBy??"modelObjectId",b=typeof w=="object"?x.metadata?.[w.metadataKey]:x[w];return typeof b=="string"&&b.length>0||typeof b=="number"?`${typeof b}:${b}`:null};function u(x,w,b){let C=x===void 0?void 0:s.get(x),O=w===void 0?void 0:a.get(w),k=[];if(C||O){let R=C?kn(C,n.ignoreMetadataKeys??[]):{},g=O?kn(O,n.ignoreMetadataKeys??[]):{};for(let d of Go)Ve(R[d],g[d],d,Rn[d],o,k)}let I=C?O?k.length?"modified":"unchanged":"removed":"added";p.push({id:JSON.stringify([x??null,w??null]),identity:b,label:O?.label??C?.label??O?.modelObjectId??C?.modelObjectId??b,status:I,beforeKey:x,afterKey:w,beforeObjectId:C?.modelObjectId,afterObjectId:O?.modelObjectId,changes:k}),x!==void 0&&c.add(x),w!==void 0&&l.add(w)}let f=new Set;for(let[x,w]of Object.entries(n.mapping??{})){if(!s.has(x)||!a.has(w)||f.has(w))throw new Error("Comparison mapping must reference existing, unique binding keys");f.add(w),u(x,w,`mapped:${x}`)}let y=new Map;for(let[x,w,b]of[[r,c,"a"],[i,l,"b"]])for(let[C,O]of x){if(w.has(C))continue;let k=m(O);if(k===null){p.push({id:JSON.stringify([b,C]),identity:"",label:O.label??O.modelObjectId,status:"ambiguous",...b==="a"?{beforeKey:C,beforeObjectId:O.modelObjectId}:{afterKey:C,afterObjectId:O.modelObjectId},changes:[],message:"Missing match identity. Supply an explicit mapping or another match field."});continue}let I=y.get(k)??{a:[],b:[]};I[b].push(C),y.set(k,I)}for(let[x,w]of y){if(w.a.length<=1&&w.b.length<=1){u(w.a[0],w.b[0],x);continue}for(let b of["a","b"])for(let C of w[b]){let O=(b==="a"?s:a).get(C);p.push({id:JSON.stringify([b,C]),identity:x,label:O.label??O.modelObjectId,status:"ambiguous",...b==="a"?{beforeKey:C,beforeObjectId:O.modelObjectId}:{afterKey:C,afterObjectId:O.modelObjectId},changes:[],message:"Duplicate match identity. Supply an explicit one-to-one mapping."})}}p.sort((x,w)=>x.label.localeCompare(w.label)||x.id.localeCompare(w.id));let M=[];Ve(re(e.sceneConfig??{}),re(t.sceneConfig??{}),"sceneConfig","scene",o,M);let S={added:0,removed:0,modified:0,unchanged:0,ambiguous:0};for(let x of p)S[x.status]++;return{version:1,objects:p,counts:S,sceneChanges:M}}function Ra(e,t,n){let o={added:"#22c55e",removed:"#f87171",modified:"#fbbf24",unchanged:"#94a3b8",ambiguous:"#c084fc"};return e.objects.flatMap(r=>{let i=t==="before"?r.beforeObjectId:r.afterObjectId;return i&&(r.status!=="unchanged"||r.id===n)?[{objectId:i,color:r.id===n?"#22d3ee":o[r.status]}]:[]})}var Ba=["front","back","double"],Pa=["normal","additive"];function za(e){oe(e);let t=[],n=[{node:e,path:"0",parentId:null}];for(;n.length;){let{node:r,path:i,parentId:s}=n.pop(),a=`node:${i}`,c=r.isMesh&&r.name?he(r):null;t.push({id:a,parentId:s,name:r.name||r.type||"Group",...c?{objectId:c}:{}});for(let l=r.children.length-1;l>=0;l--)n.push({node:r.children[l],path:`${i}/${l}`,parentId:a})}let o=new Set;for(let r=t.length-1;r>=0;r--){let i=t[r];(i.objectId||o.has(i.id))&&(o.add(i.id),i.parentId&&o.add(i.parentId))}return t.filter(r=>o.has(r.id))}function Ua(e){return structuredClone(e.style??{})}function _a(e,t,n){let o=Ce(e,t).filter(i=>!e[i].removed);if(!o.length)return e;let r={...e};for(let i of o)r[i]={...e[i],style:structuredClone(n)};return r}export{oe as a,he as b,ki as c,Ri as d,an as e,Ko as f,Yo as g,St as h,er as i,Ct as j,Q as k,dr as l,Ao as m,nt as n,dn as o,pn as p,Xe as q,Hr as r,Kr as s,Xr as t,Yr as u,Te as v,Zr as w,Jr as x,ro as y,Qr as z,ei as A,ti as B,ni as C,oi as D,ri as E,ii as F,fr as G,pr as H,gr as I,br as J,yr as K,hr as L,Sr as M,_e as N,ce as O,me as P,Cr as Q,Ar as R,Mr as S,vr as T,$e as U,fe as V,Tr as W,Ir as X,kr as Y,Rr as Z,kt as _,Rt as $,Et as aa,qe as ba,Pr as ca,Vr as da,Nr as ea,zr as fa,Zn as ga,Ge as ha,Qn as ia,Ur as ja,_r as ka,Nt as la,eo as ma,pe as na,$r as oa,Fr as pa,zt as qa,ne as ra,gi as sa,Ie as ta,Yt as ua,wi as va,Ci as wa,bo as xa,Ai as ya,Mi as za,Oi as Aa,vi as Ba,rn as Ca,ln as Da,gn as Ea,fa as Fa,Pe as Ga,ga as Ha,Do as Ia,On as Ja,ba as Ka,ya as La,$o as Ma,xa as Na,Wo as Oa,Tn as Pa,Oa as Qa,ja as Ra,va as Sa,Ta,ka as Ua,Ra as Va,Ba as Wa,Pa as Xa,za as Ya,Ua as Za,_a};