@liveroom-tech/react-immersive 6.2.0 → 6.2.1

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 (61) hide show
  1. package/dist/DownloadedEnvironment-NHM4U2LJ.mjs +1 -0
  2. package/dist/{SequencesTab-ODR5IGDX.mjs → SequencesTab-VZKEKAUG.mjs} +1 -1
  3. package/dist/StreamingTilesModel-6Z7SIC2J.mjs +16 -0
  4. package/dist/binding-builder.css +1 -1
  5. package/dist/binding-builder.d.mts +3 -3
  6. package/dist/binding-builder.d.ts +3 -3
  7. package/dist/binding-builder.js +59 -58
  8. package/dist/binding-builder.mjs +1 -1
  9. package/dist/chunk-25WC5KDO.mjs +50 -0
  10. package/dist/chunk-2AJK643D.mjs +1 -0
  11. package/dist/chunk-3OCHN3CA.mjs +1 -0
  12. package/dist/{chunk-3XZKDTB2.mjs → chunk-7OVEHDDE.mjs} +1 -1
  13. package/dist/chunk-KFLS7GI6.mjs +1 -0
  14. package/dist/{chunk-EWNN4BBR.mjs → chunk-KYXJG3TX.mjs} +1 -1
  15. package/dist/{chunk-2CUPPOBW.mjs → chunk-LD7QWHB4.mjs} +2 -2
  16. package/dist/{chunk-GXY3VML4.mjs → chunk-NMRTI3NQ.mjs} +1 -1
  17. package/dist/chunk-RKDATTUM.mjs +1 -0
  18. package/dist/chunk-RXZ4Q7CY.mjs +1 -0
  19. package/dist/chunk-TUYVYSN5.mjs +1 -0
  20. package/dist/{chunk-IOLT2VXU.mjs → chunk-UAZ6I25Y.mjs} +1 -1
  21. package/dist/chunk-UCD76KQ6.mjs +1 -0
  22. package/dist/chunk-UHRJ2RBF.mjs +1 -0
  23. package/dist/chunk-UTVFRMYW.mjs +47 -0
  24. package/dist/chunk-YKDDNX2D.mjs +69 -0
  25. package/dist/exportSceneMesh-YJFOLFHS.mjs +1 -0
  26. package/dist/hosted.css +1 -1
  27. package/dist/hosted.d.mts +3 -3
  28. package/dist/hosted.d.ts +3 -3
  29. package/dist/hosted.js +58 -57
  30. package/dist/hosted.mjs +1 -1
  31. package/dist/index.css +1 -1
  32. package/dist/index.d.mts +4 -4
  33. package/dist/index.d.ts +4 -4
  34. package/dist/index.js +52 -51
  35. package/dist/index.mjs +1 -1
  36. package/dist/meshFormats-4C6NHYOA.mjs +1 -0
  37. package/dist/modelFileResolver-CVmON8hg.d.mts +1724 -0
  38. package/dist/modelFileResolver-CVmON8hg.d.ts +1724 -0
  39. package/dist/modelViewerProps-BBnZTFO-.d.ts +949 -0
  40. package/dist/modelViewerProps-CIY4nsNY.d.mts +949 -0
  41. package/dist/{publicProps-Cmh9JtzJ.d.ts → publicProps-BARVwXu7.d.ts} +1 -1
  42. package/dist/{publicProps-TMARX628.d.mts → publicProps-n0Yvr_Km.d.mts} +1 -1
  43. package/dist/simple-model-viewer.css +1 -1
  44. package/dist/simple-model-viewer.d.mts +22 -4
  45. package/dist/simple-model-viewer.d.ts +22 -4
  46. package/dist/simple-model-viewer.js +5 -5
  47. package/dist/simple-model-viewer.mjs +1 -1
  48. package/dist/utils.d.mts +4 -4
  49. package/dist/utils.d.ts +4 -4
  50. package/dist/utils.js +2 -2
  51. package/dist/utils.mjs +1 -1
  52. package/dist/xrRuntime-5S7KYUVB.mjs +1 -0
  53. package/package.json +1 -1
  54. package/dist/chunk-3MIILDHB.mjs +0 -83
  55. package/dist/chunk-6Q6YZ7O5.mjs +0 -1
  56. package/dist/chunk-7MN2TMY6.mjs +0 -47
  57. package/dist/chunk-X4WRTDO6.mjs +0 -50
  58. package/dist/modelFileResolver-ChKYsF21.d.mts +0 -495
  59. package/dist/modelFileResolver-ChKYsF21.d.ts +0 -495
  60. package/dist/modelViewerProps-Ch6pIZIE.d.ts +0 -2159
  61. package/dist/modelViewerProps-HazR2IE_.d.mts +0 -2159
@@ -1 +0,0 @@
1
- import{Box3 as F,Vector3 as O}from"three";var P=new Set(["KHR_binary_glTF","KHR_draco_mesh_compression","KHR_lights_punctual","KHR_materials_clearcoat","KHR_materials_dispersion","KHR_materials_ior","KHR_materials_sheen","KHR_materials_specular","KHR_materials_transmission","KHR_materials_iridescence","KHR_materials_anisotropy","KHR_materials_unlit","KHR_materials_volume","KHR_texture_basisu","KHR_texture_transform","KHR_mesh_quantization","KHR_materials_emissive_strength","KHR_materials_variants","EXT_materials_bump","EXT_texture_webp","EXT_texture_avif","EXT_meshopt_compression","EXT_mesh_gpu_instancing"]),K=new WeakMap;function ae(e,n){K.set(e,structuredClone(n))}function G(e){let n=K.get(e);return n?structuredClone(n):void 0}function U(e){if(/^(blob|data):/i.test(e))return"Local resource";let n=e.split(/[?#]/,1)[0].replace(/\\/g,"/");return n.slice(n.lastIndexOf("/")+1).slice(0,300)||"Resource"}function V(e){return/^(blob|data):/i.test(e)?"Local resource":e.split(/[?#]/,1)[0].replace(/\\/g,"/").replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i,"").replace(/^\/+/,"").slice(0,500)||"Resource"}function H(e){let n=t=>typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null;return{...e.format?{format:e.format}:{},...e.name?{name:U(e.name)}:{},sourceBytes:n(e.sourceBytes),loadDurationMs:n(e.loadDurationMs),extensionsUsed:[...new Set(e.extensionsUsed??[])].sort(),extensionsRequired:[...new Set(e.extensionsRequired??[])].sort(),failedResources:[...new Set((e.failedResources??[]).map(V))].slice(0,50)}}function L(e){let n=new Set(e.extensionsRequired);return[...new Set([...e.extensionsUsed??[],...n])].sort().map(t=>({name:t,required:n.has(t),recognized:P.has(t)}))}function X(e,n){let t=e.image,r=m=>typeof m=="number"&&Number.isSafeInteger(m)&&m>0?m:null,a=r(t?.naturalWidth??t?.width),u=r(t?.naturalHeight??t?.height),l=!!e.isCompressedTexture,y=e.mipmaps.reduce((m,g)=>m+(g.data?.byteLength??0),0),c=a&&u?Math.ceil(a*u*4*(e.generateMipmaps?4/3:1)):null;return{name:e.name?U(e.name):n,width:a,height:u,compressed:l,estimatedBytes:l?y||null:c!==null&&Number.isSafeInteger(c)?c:null}}function ue(e,n={}){let t=H({...G(e),...n.source}),r=[],a=new Set,u=new Map,l=new Set,y=new Map,c=new Map,m=new Set,g=new Map,v=0,R=0,T=0,B=0,I=0,b=(s,i)=>{let o=g.get(s)??{count:0,names:[]};o.count++,o.names.length<20&&o.names.push(i||"Unnamed object"),g.set(s,o)},w=s=>{let i=s?.array??s?.data?.array;i?.buffer&&!m.has(i.buffer)&&(m.add(i.buffer),I+=i.buffer.byteLength)};e.traverse(s=>{let i=s;if(!i.isMesh||!i.geometry)return;v++,R+=i.isInstancedMesh?Number.isSafeInteger(i.count)?Math.max(0,i.count??0):0:1;let o=i.geometry,d=o.getAttribute("position"),D=o.getAttribute("uv"),k=i.material?Array.isArray(i.material)?i.material:[i.material]:[];if(!u.has(o)){let p=!!d&&(!Number.isSafeInteger(d.count)||d.count<0);for(let f=0;!p&&d&&f<d.count;f++)if(!Number.isFinite(d.getX(f))||!Number.isFinite(d.getY(f))||!Number.isFinite(d.getZ(f))){p=!0;break}u.set(o,p)}if(u.get(o)&&b("invalid-positions",s.name),d?.count||b("empty-geometry",s.name),D||b("missing-uv",s.name),o.getAttribute("normal")||b("missing-normals",s.name),o.boundingBox&&[...o.boundingBox.min.toArray(),...o.boundingBox.max.toArray()].some(p=>!Number.isFinite(p))&&b("invalid-bounds",s.name),!a.has(o)){a.add(o),T+=Number.isSafeInteger(d?.count)?Math.max(0,d?.count??0):0;let p=o.index?.count??d?.count??0;B+=Number.isSafeInteger(p)?Math.floor(Math.max(0,p)/3):0,Object.values(o.attributes).forEach(w),Object.values(o.morphAttributes).flat().forEach(w),w(o.index)}let j=!1;for(let p of k){l.add(p);let f=y.get(p);if(!f){f=Object.values(p).filter(h=>!!h&&h.isTexture===!0),y.set(p,f);for(let h of f)c.has(h)||c.set(h,`Texture ${c.size+1}`)}for(let h of f){let E=h.channel??0;o.getAttribute(E===0?"uv":`uv${E}`)||(j=!0)}}j&&b("textured-missing-uv",s.name)});let S=(s,i,o,d,D)=>{let k=g.get(s);k&&r.push({code:s,severity:i,title:o,detail:d,suggestion:D,count:k.count,objects:k.names})};S("empty-geometry","error","Empty mesh geometry","Some meshes have no position data.","Remove empty meshes or export their geometry again."),S("invalid-positions","error","Invalid vertex coordinates","Some vertices contain non-finite coordinates.","Repair NaN or infinite vertex positions in the source application, then re-export."),S("invalid-bounds","error","Invalid geometry bounds","Some cached bounds contain non-finite values.","Repair invalid coordinates in the source application and re-export."),S("textured-missing-uv","warning","Textures have no matching UV coordinates","A texture references a UV channel that its mesh does not contain.","Unwrap the affected meshes and export the UV channel used by each texture."),S("missing-uv","info","Meshes without UVs","Solid colors can work without UVs; image textures and surface decals need them.","Add a UV map before applying image textures or decals."),S("missing-normals","info","Meshes without normals","Some loaded meshes lack vertex normals; generated shading may differ from the source.","Export vertex normals to preserve hard edges and smooth surfaces."),v||r.push({code:"no-meshes",severity:"warning",title:"No mesh geometry found",detail:"This scene contains no loaded meshes.",suggestion:"Check that meshes were included in the export. Streamed scenes may still be loading."});let A=[...c].map(([s,i])=>X(s,i)),_=A.filter(s=>(s.width??0)>4096||(s.height??0)>4096);_.length&&r.push({code:"large-textures",severity:"warning",title:"Large texture dimensions",detail:"Some textures exceed 4096 pixels on one side.",suggestion:"Resize textures for the visible detail needed; use KTX2/Basis where appropriate.",count:_.length,objects:_.slice(0,20).map(s=>s.name)}),B>1e6&&r.push({code:"high-triangle-count",severity:"warning",title:"High geometry count",detail:"The loaded geometry contains more than one million unique triangles.",suggestion:"Simplify hidden detail, create lower-detail exports, or use streamed assets for large scenes."}),l.size>100&&r.push({code:"many-materials",severity:"warning",title:"Many material definitions",detail:"More than 100 materials can increase rendering work.",suggestion:"Reuse materials and atlas compatible textures; inspect runtime draw calls to confirm the cost."});let N=L(t);for(let s of N.filter(i=>!i.recognized))r.push({code:"unrecognized-extension",severity:s.required?"error":"warning",title:`${s.required?"Required":"Optional"} extension not recognized`,detail:s.name,suggestion:"Export with extensions supported by the bundled loader, or verify the asset's fallback appearance."});t.failedResources?.length&&r.push({code:"failed-resources",severity:"error",title:"Some resources failed to load",detail:"The model may be missing textures or other referenced resources.",suggestion:"Include sidecar files in the ZIP, correct their paths, and check HTTP access and CORS.",count:t.failedResources.length,objects:t.failedResources.slice(0,20)});let z=null,M=[...u.values()].some(Boolean)?new F:new F().setFromObject(e);!M.isEmpty()&&[...M.min.toArray(),...M.max.toArray(),...M.getSize(new O).toArray()].every(Number.isFinite)&&(z={min:M.min.toArray(),max:M.max.toArray(),center:M.getCenter(new O).toArray(),size:M.getSize(new O).toArray()}),n.scope==="resident-tiles"&&r.unshift({code:"partial-stream",severity:"info",title:"Loaded tiles only",detail:"Geometry and texture counts cover the current resident tiles, not the entire source asset.",suggestion:"Use the live cache/detail statistics to inspect streaming pressure. Rescan after moving the camera."});let C=s=>s.code==="partial-stream"?-1:s.severity==="error"?0:s.severity==="warning"?1:2;return r.sort((s,i)=>C(s)-C(i)),{version:1,status:"ready",scope:n.scope??"asset",source:t,units:t.format==="glb"||t.format==="gltf"?"meters (glTF convention)":"unknown",bounds:z,statistics:{meshes:v,instances:R,geometries:a.size,materials:l.size,textures:c.size,vertices:T,triangles:B,geometryBytes:I,estimatedTextureBytes:A.reduce((s,i)=>s+(i.estimatedBytes??0),0),unknownTextureSizes:A.filter(s=>s.estimatedBytes===null).length,meshesWithoutUvs:g.get("missing-uv")?.count??0,meshesWithoutNormals:g.get("missing-normals")?.count??0},textures:A,extensions:N,issues:r}}function ce(e={}){return{version:1,status:"failed",scope:"asset",source:H(e),units:"unknown",bounds:null,statistics:null,textures:[],extensions:L(e),issues:[{code:"load-failed",severity:"error",title:"Asset could not be loaded",detail:"Geometry and textures could not be inspected.",suggestion:"Check the file format, required decoders, sidecar paths, HTTP access and CORS, then reload the asset."}]}}import{Matrix4 as q,Vector3 as Y}from"three";function Z(e){return e.isSkinnedMesh===!0}function fe(e){let n=[];return e.traverse(t=>{Z(t)&&n.push(t)}),n}var x="reactImmersiveSkinFreeze";function ge(e){return!!e.userData[x]}function Me(e,n,t=[n]){let r=e.userData,a=new q().copy(n).invert(),u=r[x];if(u){u.frozenInverse.copy(a),u.restWorldTransforms=t.map(c=>c.clone()),e.bindMatrixInverse.copy(a);return}let l={frozenInverse:a,restWorldTransforms:t.map(c=>c.clone()),previousOnBeforeRender:e.onBeforeRender,previousUpdateMatrixWorld:Object.prototype.hasOwnProperty.call(e,"updateMatrixWorld")?e.updateMatrixWorld:void 0};e.bindMatrixInverse.copy(a);let y=e.updateMatrixWorld;e.updateMatrixWorld=function(c){y.call(this,c),e.bindMatrixInverse.copy(l.frozenInverse)},e.onBeforeRender=function(c,m,g,v,R,T){l.previousOnBeforeRender.call(this,c,m,g,v,R,T),e.bindMatrixInverse.copy(l.frozenInverse)},r[x]=l}function $(e){return e.userData[x]?.frozenInverse??null}function he(e){return e.userData[x]?.restWorldTransforms??null}function xe(e){let n=e.userData,t=n[x];t&&(e.onBeforeRender=t.previousOnBeforeRender,t.previousUpdateMatrixWorld?e.updateMatrixWorld=t.previousUpdateMatrixWorld:delete e.updateMatrixWorld,delete n[x],e.updateMatrixWorld(!0))}function ye(e){let n=e,t=$(e);t&&n.bindMatrixInverse.copy(t),n.skeleton?.update?.();let r=n.geometry.clone(),a=r.getAttribute("position");if(a){let u=new Y;for(let l=0;l<a.count;l++)n.getVertexPosition(l,u),a.setXYZ(l,u.x,u.y,u.z);a.needsUpdate=!0}return r.deleteAttribute("skinIndex"),r.deleteAttribute("skinWeight"),r.morphAttributes={},r.morphTargetsRelative=!1,r.computeVertexNormals(),r.computeBoundingBox(),r.computeBoundingSphere(),r}function be(e){return e.matrixWorld.clone()}import{AdditiveBlending as J,BackSide as Q,DoubleSide as ee,FrontSide as te,NoColorSpace as ne,NormalBlending as re,SRGBColorSpace as se,Vector2 as W}from"three";function De(e){let n=!0;return e?.traverse(t=>{let r=t.isMesh?t.geometry:null;r&&!r.getAttribute("uv")&&(n=!1)}),n}function Oe(e){return!!(e&&typeof e=="object"&&"clone"in e&&"color"in e&&"metalness"in e&&"roughness"in e)}function Ie(e){return!!(e&&typeof e=="object"&&"isMeshPhysicalMaterial"in e&&e.isMeshPhysicalMaterial)}function Ne(e){return!!(e&&"isMesh"in e&&e.isMesh)}var ze=["texture","metalnessMap","roughnessMap","emissiveMap","alphaMap","normalMap","bumpMap","aoMap","displacementMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","anisotropyMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap"],Ce={texture:"map",metalnessMap:"metalnessMap",roughnessMap:"roughnessMap",emissiveMap:"emissiveMap",alphaMap:"alphaMap",normalMap:"normalMap",bumpMap:"bumpMap",aoMap:"aoMap",displacementMap:"displacementMap",clearcoatMap:"clearcoatMap",clearcoatRoughnessMap:"clearcoatRoughnessMap",clearcoatNormalMap:"clearcoatNormalMap",anisotropyMap:"anisotropyMap",transmissionMap:"transmissionMap",thicknessMap:"thicknessMap",sheenColorMap:"sheenColorMap",sheenRoughnessMap:"sheenRoughnessMap",specularIntensityMap:"specularIntensityMap",specularColorMap:"specularColorMap"},ie=new Set(["texture","emissiveMap","sheenColorMap","specularColorMap"]);function je(e){return ie.has(e)?se:ne}function Ee(e,n){return e?.[n]?.path}function Fe(e,n){let t=e?.[n]?.offset;if(!t)return;let[r,a]=t;if(!(!Number.isFinite(r)||!Number.isFinite(a)))return r===0&&a===0?void 0:[r,a]}function Ke(e,n){let t=e?.[n]?.scale;if(!(!Number.isFinite(t)||!t))return t===1?void 0:t}function Ue(e,n){let t=e?.[n]?.rotation;if(!(!Number.isFinite(t)||!t))return t}function He(e){return e==="back"?Q:e==="double"?ee:te}function Le(e){return e==="additive"?J:re}function We(e,n=1,t=n){if(e&&typeof e=="object"){let r=e;if(typeof r.x=="number"&&Number.isFinite(r.x)&&typeof r.y=="number"&&Number.isFinite(r.y))return new W(r.x,r.y)}return new W(n,t)}function Pe(e){return Number.isFinite(e)&&e>0?e:1}function Ge(e,n){return e?.animations.clips.find(t=>t.sourceName===n)}function Ve(e){return e?.loopMode??"repeat"}export{Z as a,fe as b,ge as c,Me as d,$ as e,he as f,xe as g,ye as h,be as i,De as j,Oe as k,Ie as l,Ne as m,ze as n,Ce as o,je as p,Ee as q,Fe as r,Ke as s,Ue as t,He as u,Le as v,We as w,Pe as x,Ge as y,Ve as z,ae as A,G as B,U as C,V as D,ue as E,ce as F};
@@ -1,47 +0,0 @@
1
- import{b as ie}from"./chunk-GXY3VML4.mjs";import{A as F,C as fe,D as me,a as oe,e as se,k as de,l as pe,w as R}from"./chunk-6Q6YZ7O5.mjs";import{b as ae}from"./chunk-IOLT2VXU.mjs";import{e as ue,f as le,g as ce}from"./chunk-BNKTI3CY.mjs";var be;function he(e){be=e}function M(e){be?.(e)}import{strFromU8 as Mt,strToU8 as wt,unzip as xt}from"fflate";var St=[".glb",".gltf",".obj",".fbx",".usdz",".stl",".ply",".zip"],Lt=["model/gltf-binary","model/gltf+json","model/vnd.usdz+zip","application/vnd.usdz+zip","application/zip","application/x-zip-compressed"],w=1024*1024,ge=128*w,ve=1024,ye=128*w,Me=256*w,we=200,Pt=w,b=new Map,An=".glb,.gltf,.obj,.fbx,.usdz,.stl,.ply,.zip,model/gltf-binary,model/gltf+json,model/vnd.usdz+zip,application/vnd.usdz+zip,application/zip";function x(e){let t=e.split(/[?#]/,1)[0].toLowerCase();return t.endsWith(".obj")?"obj":t.endsWith(".fbx")?"fbx":t.endsWith(".usdz")?"usdz":t.endsWith(".stl")?"stl":t.endsWith(".ply")?"ply":t.endsWith(".gltf")?"gltf":"glb"}function Pe(e){return b.get(e)??{format:x(e)}}function Rt(e){let t=e.name.toLowerCase();return St.some(r=>t.endsWith(r))||Lt.includes(e.type)}async function Dn(e){if(!Rt(e))throw new Error("Unsupported model file. Please upload a .glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, or .zip asset.");let t=e.name.toLowerCase();if(t.endsWith(".usdz")||e.type==="model/vnd.usdz+zip"||e.type==="application/vnd.usdz+zip")return xe(e,"usdz");if(t.endsWith(".zip")||At(e.type))return Dt(e);if(t.endsWith(".gltf")||e.type==="model/gltf+json")return Se(e);let r=x(e.name);return r==="gltf"?Se(e):xe(e,r)}function xe(e,t){let r=URL.createObjectURL(e);return b.set(r,{format:t,entryPath:e.name,sourceBytes:e.size}),{url:r,name:e.name,format:t,cleanup:()=>{M(r),b.delete(r),URL.revokeObjectURL(r)}}}function At(e){return e==="application/zip"||e==="application/x-zip-compressed"}async function Se(e){let t=await e.text(),r=Re(t,e.name);for(let o of Ae(r))if(!U(o))throw new Error(`${e.name} references external assets. Upload a .zip containing the .gltf file and its dependencies.`);let n=URL.createObjectURL(e);return b.set(n,{format:"gltf",entryPath:e.name,sourceBytes:e.size}),{url:n,name:e.name,format:"gltf",cleanup:()=>{M(n),b.delete(n),URL.revokeObjectURL(n)}}}async function Dt(e){if(e.size>ge)throw new Error(`Model zip is too large. The compressed archive must be ${I(ge)} or smaller.`);let t=await Et(new Uint8Array(await e.arrayBuffer())),r=new Map;for(let[i,a]of Object.entries(t)){let u=j(i);!u||De(u)||r.set(u,a)}let n=[...r.keys()].filter(i=>/\.(gltf|obj|fbx|stl|ply)$/i.test(i));if(n.length===0)throw new Error("Invalid model zip: no .gltf, .obj, .fbx, .stl, or .ply file found.");if(n.length>1)throw new Error("Invalid model zip: multiple model entry files found.");let o=n[0],s=x(o);if(s==="gltf")return Ct(e,o,r);if(s==="obj"||s==="fbx"||s==="stl"||s==="ply")return Bt(e,o,s,r);throw new Error(`Unsupported model entry ${o}.`)}function Et(e){return new Promise((t,r)=>{let n=0,o=0,s=null,i=u=>(s??(s=new Error(`Invalid model zip: ${u}`)),!1);xt(e,{filter:u=>{if(s)return!1;if(n+=1,n>ve)return i(`archive contains more than ${ve.toLocaleString()} entries.`);if(u.originalSize>ye)return i(`${u.name} expands beyond the ${I(ye)} per-file limit.`);if(o+=u.originalSize,o>Me)return i(`expanded contents exceed ${I(Me)}.`);if(u.originalSize>=Pt&&(u.size===0||u.originalSize/u.size>we))return i(`${u.name} exceeds the ${we}:1 compression-ratio limit.`);let l=j(u.name);return!!l&&!De(l)}},(u,l)=>{s?r(s):u?r(new Error(`Invalid model zip: ${u.message}`)):t(l)})})}function I(e){return`${e/w} MiB`}function Bt(e,t,r,n){let o=[],s={};for(let[a,u]of n){let l=URL.createObjectURL(new Blob([u],{type:Ee(a)}));o.push(l),s[a]=l}let i=s[t];if(!i)throw o.forEach(a=>URL.revokeObjectURL(a)),new Error(`Invalid model zip: could not read ${t}.`);return b.set(i,{format:r,entryPath:t,resourceUrls:s}),{url:i,name:e.name,format:r,cleanup:()=>{M(i),b.delete(i),o.forEach(a=>URL.revokeObjectURL(a))}}}function Ct(e,t,r){let n=r.get(t);if(!n)throw new Error("Invalid GLTF zip: no .gltf found.");let o=Re(Mt(n),t);Tt(o,t);let s=kt(t),i=[];try{Le(o.buffers,s,r,i),Le(o.images,s,r,i);let a=new Blob([wt(JSON.stringify(o))],{type:"model/gltf+json"}),u=URL.createObjectURL(a);return i.push(u),b.set(u,{format:"gltf",entryPath:t}),{url:u,name:e.name,format:"gltf",cleanup:()=>{M(u),b.delete(u),i.forEach(l=>URL.revokeObjectURL(l))}}}catch(a){throw i.forEach(u=>URL.revokeObjectURL(u)),a}}function Le(e,t,r,n){for(let o of e??[]){if(typeof o.uri!="string"||U(o.uri))continue;let s=Ot(t,o.uri),i=r.get(s);if(!i)throw new Error(`Invalid GLTF zip: missing referenced asset ${o.uri}.`);let a=URL.createObjectURL(new Blob([i],{type:Ee(s)}));n.push(a),o.uri=a}}function Re(e,t){try{return JSON.parse(e)}catch{throw new Error(`${t} is not a valid .gltf JSON file.`)}}function Ae(e){return[...e.buffers??[],...e.images??[]].map(t=>t.uri).filter(t=>typeof t=="string"&&t.length>0)}function Tt(e,t){for(let r of Ae(e)){if(U(r))continue;let n=/^[a-z][a-z0-9+.-]*:/i.test(r),o=r.startsWith("/")||r.startsWith("\\");if(n||o)throw new Error(`${t} references external assets. Include every dependency inside the uploaded .zip.`)}}function U(e){return e.startsWith("data:")}function j(e){let t=[];for(let r of e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(n=>n&&n!==".")){if(r===".."){t.pop();continue}t.push(r)}return t.join("/")}function De(e){let t=e.split("/");return e.endsWith("/")||t.includes("__MACOSX")||t.some(r=>r===".DS_Store"||r.startsWith("._"))}function kt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Ot(e,t){let r=t.split(/[?#]/)[0],n=zt(r);return j(e?`${e}/${n}`:n)}function zt(e){try{return decodeURI(e)}catch{return e}}function Ee(e){let t=e.toLowerCase();return t.endsWith(".obj")||t.endsWith(".mtl")?"text/plain":t.endsWith(".fbx")?"application/octet-stream":t.endsWith(".usdz")?"model/vnd.usdz+zip":t.endsWith(".bin")?"application/octet-stream":t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".webp")?"image/webp":t.endsWith(".avif")?"image/avif":t.endsWith(".ktx2")?"image/ktx2":"application/octet-stream"}import{Box3 as Gt,BufferAttribute as Ft,Mesh as It}from"three";import{acceleratedRaycast as Ut,computeBoundsTree as jt,disposeBoundsTree as Wt,MeshBVH as _t}from"three-mesh-bvh";var Be=!1,g=new WeakMap,S=new WeakMap;function Nt(){Be||(It.prototype.raycast=Ut,Be=!0)}function Vt(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;!n||!n.attributes?.position||t.add(n)}),[...t]}function Ce(e){let t=0;for(let r of e){let n=r.index?r.index.count:r.attributes.position.count;t+=n/3}return t}var Te=12e6;function Tn(e){return $t(e)>Te}function $t(e){let t=new Set;return e.traverse(r=>{let n=r.geometry;n?.attributes?.position&&t.add(n)}),Ce([...t])}function Ht(e,t){return new Promise((r,n)=>{let o=l=>{let c=l.data;if(!c||!c.error&&!c.serialized)return;if(e.removeEventListener("message",o),e.removeEventListener("error",s),c.error){n(new Error(String(c.error)));return}let{serialized:d}=c,p=_t.deserialize(d,t,{setIndex:!1});d.index&&(t.index?t.index.array=d.index:t.setIndex(new Ft(d.index,1,!1))),t.boundingBox=p.getBoundingBox(new Gt),r(p)},s=l=>{e.removeEventListener("message",o),e.removeEventListener("error",s),n(new Error(l.message||"BVH worker error"))};e.addEventListener("message",o),e.addEventListener("error",s);let i=t.index?t.index.array.slice():null,a=t.attributes.position.array.slice(),u=[a,...i?[i]:[]].map(l=>l.buffer);e.postMessage({index:i,position:a,options:{groups:[...t.groups]}},u)})}async function Xt(){if(typeof window>"u"||typeof Worker>"u")return null;try{let{bvhWorkerCode:e}=await import("./bvhWorkerCode-6366A3UC.mjs"),t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),n=new Worker(r);return{worker:n,dispose:()=>{n.terminate(),URL.revokeObjectURL(r)}}}catch{return null}}async function Zt(e,t){if(t)try{return await Ht(t,e)}catch{}let r=jt.call(e);return e.boundsTree=void 0,await new Promise(n=>setTimeout(n,0)),r}async function Kt(e,t,r){if(e.boundsTree)return;if(t.buildPromise)return t.buildPromise;let n=(async()=>{let o=await r();t.references>0&&!e.boundsTree&&(e.boundsTree=o,t.ownedTree=o)})();return t.buildPromise=n.finally(()=>{t.buildPromise=void 0,t.references===0&&g.delete(e)}),t.buildPromise}async function kn(e,t){if(t?.aborted)return;let r=S.get(e);if(!r){if(r=Vt(e),Ce(r)>Te){S.set(e,[]);return}S.set(e,r);for(let o of r){let s=g.get(o)??{references:0};s.references+=1,g.set(o,s)}}if(r.length===0)return;Nt();let n=await Xt();if(t?.aborted){n?.dispose();return}try{for(let o of r){if(t?.aborted)return;let s=g.get(o);s&&await Kt(o,s,()=>Zt(o,n?.worker))}}finally{n?.dispose()}}function On(e){let t=S.get(e);if(t){S.delete(e);for(let r of t){let n=g.get(r);n&&(n.references=Math.max(0,n.references-1),!(n.references>0)&&(n.ownedTree&&r.boundsTree===n.ownedTree&&(Wt.call(r),r.boundsTree=void 0),n.ownedTree=void 0,n.buildPromise||g.delete(r)))}}}import{useEffect as _,useMemo as Yt,useRef as Jt,useState as qt}from"react";import{Box3 as Ge,Color as N,DoubleSide as Qt,ShaderMaterial as er,Vector3 as tr}from"three";import{useThree as rr}from"@react-three/fiber";var ke="riEditorGizmo",W=new WeakMap;function Oe(e){return e.userData[ke]=!0,e}function In(e,t){let r=W.get(e);return r||(r=new Set,W.set(e,r)),r.add(t),()=>{r.delete(t)}}function Un(e){let t=[],r=n=>{n.visible=!1,t.push(n)};return e.traverse(n=>{n.visible&&n.userData[ke]&&r(n)}),W.get(e)?.forEach(n=>{n.visible&&r(n)}),()=>{for(let n of t)n.visible=!0}}function ze(e){return!Number.isFinite(e)||e<=0?1:10**Math.floor(Math.log10(e/10))}import{jsx as Fe}from"react/jsx-runtime";var nr=`
2
- varying vec3 vWorld;
3
- void main() {
4
- vec4 world = modelMatrix * vec4(position, 1.0);
5
- vWorld = world.xyz;
6
- gl_Position = projectionMatrix * viewMatrix * world;
7
- }
8
- `,or=`
9
- uniform float uCell;
10
- uniform float uMajor;
11
- uniform float uFade;
12
- uniform vec3 uLine;
13
- uniform vec3 uAxisX;
14
- uniform vec3 uAxisZ;
15
- uniform bool uLinearTarget;
16
- varying vec3 vWorld;
17
-
18
- float lines(vec2 position, float size, vec2 width) {
19
- vec2 scaled = position / size;
20
- vec2 pixels = width / size;
21
- vec2 distanceToLine = abs(fract(scaled - 0.5) - 0.5) / max(pixels, vec2(1e-6));
22
- return 1.0 - min(min(distanceToLine.x, distanceToLine.y), 1.0);
23
- }
24
-
25
- void main() {
26
- vec2 position = vWorld.xz;
27
- vec2 width = fwidth(position);
28
- float minorFade = 1.0 - smoothstep(0.15, 0.45, max(width.x, width.y) / uCell);
29
- float majorFade = 1.0 - smoothstep(0.15, 0.45, max(width.x, width.y) / uMajor);
30
- float alpha = max(lines(position, uCell, width) * 0.11 * minorFade,
31
- lines(position, uMajor, width) * 0.3 * majorFade);
32
- vec3 color = uLine;
33
-
34
- float onX = 1.0 - min(abs(position.y) / max(width.y, 1e-6), 1.0);
35
- float onZ = 1.0 - min(abs(position.x) / max(width.x, 1e-6), 1.0);
36
- if (onX > 0.0) { color = mix(color, uAxisX, onX); alpha = max(alpha, onX * 0.7); }
37
- if (onZ > 0.0) { color = mix(color, uAxisZ, onZ); alpha = max(alpha, onZ * 0.7); }
38
-
39
- alpha *= 1.0 - smoothstep(uFade * 0.15, uFade, distance(cameraPosition, vWorld));
40
- if (alpha < 0.004) discard;
41
- // Post-processing blends in linear color, where a faint line comes out far
42
- // brighter than the same alpha blended on the canvas. Selecting an object
43
- // turns that pipeline on, so without this the grid would jump in brightness.
44
- gl_FragColor = vec4(color, uLinearTarget ? pow(alpha, 2.2) : alpha);
45
- #include <colorspace_fragment>
46
- }
47
- `,sr=()=>{};function Zn({getTarget:e,revision:t,lineColor:r}){let n=rr(c=>c.invalidate),[o,s]=qt({y:0,size:10}),i=Jt(null);_(()=>{i.current&&Oe(i.current)},[]),_(()=>{let c=e();if(!c)return;let d=c instanceof Ge?c:new Ge().setFromObject(c);if(d.isEmpty())return;let p=d.getSize(new tr);s({y:d.min.y,size:Math.max(p.x,p.y,p.z)}),n()},[e,t,n]);let a=Yt(()=>new er({vertexShader:nr,fragmentShader:or,transparent:!0,depthWrite:!1,side:Qt,uniforms:{uCell:{value:1},uMajor:{value:5},uFade:{value:100},uLinearTarget:{value:!1},uLine:{value:new N},uAxisX:{value:new N("#e5484d")},uAxisZ:{value:new N("#3e8bff")}}}),[]);_(()=>()=>a.dispose(),[a]);let u=ze(o.size);a.uniforms.uCell.value=u,a.uniforms.uMajor.value=u*5,a.uniforms.uFade.value=o.size*12,a.uniforms.uLine.value.set(r);let l=o.size*40;return Fe("mesh",{ref:i,rotation:[-Math.PI/2,0,0],position:[0,o.y-o.size*5e-4,0],raycast:sr,renderOrder:-1,frustumCulled:!1,material:a,onBeforeRender:c=>{let d=c.getRenderTarget()!==null;a.uniforms.uLinearTarget.value!==d&&(a.uniforms.uLinearTarget.value=d,a.uniformsNeedUpdate=!0)},children:Fe("planeGeometry",{args:[l,l]})})}import{useThree as V}from"@react-three/fiber";import{useEffect as je}from"react";import{useEffect as ar,useState as ir}from"react";function A(e){return!!e?.isWebGPURenderer}var Ie;function ur(){return Ie??(Ie=(async()=>{let e=typeof navigator>"u"?void 0:navigator.gpu;if(!e)return!1;try{return!!await e.requestAdapter()}catch{return!1}})()),Ie}var Ue=!1;function qn(e){let[t,r]=ir(null);return ar(()=>{if(!e)return;let n=!1;return ur().then(o=>{n||(!o&&!Ue&&(Ue=!0,console.info("[react-immersive] WebGPU isn't available in this browser; using WebGL.")),r(o))}),()=>{n=!0}},[e]),e?t===null?null:t?"webgpu":"webgl":"webgl"}async function Qn(e){let{WebGPURenderer:t}=await import("three/webgpu"),r=new t({canvas:e.canvas,antialias:e.antialias??!0,alpha:e.alpha??!0});return await r.init(),r}function oo({captureRef:e}){let{gl:t,scene:r,camera:n,invalidate:o,get:s}=V();return je(()=>{if(!e)return;let i=()=>{let a=s();a.advance(a.frameloop==="never"?a.clock.elapsedTime:performance.now())};return e.current={gl:t,scene:r,camera:n,invalidate:o,drawNow:i},()=>{e.current=null}},[e,t,r,n,o,s]),null}function so(){let e=V(r=>r.frameloop),t=V(r=>r.invalidate);return je(()=>{e!=="never"&&t()},[e,t]),null}function ao(e){e.dispose(),"forceContextLoss"in e&&!A(e)&&(e.forceContextLoss(),e.forceContextLoss=()=>{})}function io(e){if(!e)return Promise.resolve(null);try{e.drawNow();let t=e.gl.domElement;return new Promise(r=>{t.toBlob(n=>r(n?URL.createObjectURL(n):null),"image/webp",.85)})}catch{return Promise.resolve(null)}}import{useEffect as vr,useState as yr}from"react";import{useEffect as lr,useState as We}from"react";var cr="200px",_e=new Map;function Ne(e,t,r){let n=_e.get(t);if(!n){let i=new Map;n={observer:new IntersectionObserver(u=>{for(let l of u)i.get(l.target)?.(l.isIntersecting)},{rootMargin:t}),watchers:i},_e.set(t,n)}let{observer:o,watchers:s}=n;return s.set(e,r),o.observe(e),()=>{s.delete(e),o.unobserve(e)}}function Ve(e){let t=typeof IntersectionObserver<"u",[r,n]=We(!t),[o,s]=We(!t);return lr(()=>{let i=e.current;if(!i||!t)return;let a=Ne(i,cr,n),u=Ne(i,"0px",s);return()=>{a(),u()}},[e,t]),{near:r,visible:o}}import{useEffect as $e,useRef as He,useState as fr}from"react";function $(){return typeof navigator>"u"?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function dr(){if(typeof navigator>"u")return!1;let e=navigator.userAgent;return/iPhone|iPad|iPod/i.test(e)?!0:navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1}function po(){return $()||dr()}function pr(){if(typeof window>"u"||typeof navigator>"u")return!1;let e=i=>typeof window.matchMedia=="function"&&window.matchMedia(i).matches,t=e("(pointer: coarse)")||e("(any-pointer: coarse)"),r=e("(hover: none)")||e("(any-hover: none)"),n=navigator.maxTouchPoints>0,o=typeof window.screen<"u"&&Math.min(window.screen.width,window.screen.height)<=1024,s=$();return t||s||n&&r||n&&o}function H(){if(!pr())return!1;if($())return!0;let e=navigator.deviceMemory;return!(typeof e=="number"&&e>=8)}function fo(e="auto"){switch(e){case"high":return!1;case"low":return!0;default:return H()}}function mr(e,t){let r=new Set,n=o=>{for(let s of o){if(r.size>=t)return;r.add(s.id)}};return n(e.filter(o=>o.wanted).sort((o,s)=>Number(s.visible)-Number(o.visible)||Number(s.live)-Number(o.live)||o.since-s.since)),n(e.filter(o=>!o.wanted&&o.live).sort((o,s)=>s.since-o.since)),r}var br=12,hr=6,D=new Map,gr=1,X=!1,Xe;function Ze(){X||(X=!0,queueMicrotask(()=>{X=!1,Xe??(Xe=H()?hr:br);let e=mr([...D.values()],Xe);for(let t of D.values()){let r=e.has(t.id);r!==t.live&&(t.live=r,t.onLiveChange(r))}}))}function Ke({managed:e,wanted:t,visible:r,onPark:n}){let[o,s]=fr(!1),i=He(n);i.current=n;let a=He(null);return $e(()=>{if(!e)return;let u={id:gr++,wanted:!1,visible:!1,live:!1,since:performance.now(),onLiveChange:l=>{l||i.current?.(),s(l)}};return D.set(u.id,u),a.current=u,()=>{D.delete(u.id),a.current=null,s(!1),Ze()}},[e]),$e(()=>{let u=a.current;!u||u.wanted===t&&u.visible===r||(u.wanted!==t&&(u.since=performance.now()),u.wanted=t,u.visible=r,Ze())},[e,t,r]),e?o:t}function wo({loading:e="lazy",reveal:t="auto",rootRef:r,onPark:n}){let{near:o,visible:s}=Ve(r),[i,a]=yr(t==="auto");return vr(()=>{t==="auto"&&a(!0)},[t]),{live:Ke({managed:e==="lazy",wanted:i&&(e==="eager"||o),visible:s,onPark:n}),visible:s,awaitingReveal:!i,reveal:()=>a(!0)}}import{Box as Mr}from"lucide-react";import{jsx as Z,jsxs as Ye}from"react/jsx-runtime";function wr({src:e,hidden:t=!1}){return e?Z("img",{className:`ri-poster${t?" ri-poster--hidden":""}`,src:e,alt:"","aria-hidden":"true",draggable:!1,decoding:"async"}):null}function Do({className:e,background:t,poster:r,onReveal:n}){let o=ie();return Ye("div",{className:`${e} ri-viewerPlaceholder`,style:{background:t},children:[Z(wr,{src:r}),n?Ye("button",{type:"button",className:"ri-revealButton",onClick:n,children:[Z(Mr,{size:16,"aria-hidden":"true"}),o("viewIn3D")]}):null]})}import{BufferGeometry as xr,Float32BufferAttribute as Sr,Group as qe,Mesh as K,MeshStandardMaterial as Lr}from"three";import{STLLoader as Pr}from"three/examples/jsm/loaders/STLLoader.js";import{PLYLoader as Rr}from"three/examples/jsm/loaders/PLYLoader.js";var Ar=12106948,Qe="This PLY file is a point cloud: it has vertices but no faces.",E=class extends Error{constructor(){super(Qe),this.name="PointCloudError"}};function et(e){return e instanceof E||e instanceof Error&&e.message.includes(Qe)}function tt(e,t){let r=e.split(/[?#]/,1)[0],n=r.slice(r.lastIndexOf("/")+1);try{n=decodeURIComponent(n)}catch{}return n.replace(/\.[^.]*$/,"").trim()||t}function Y(e){return new Lr({color:e?16777215:Ar,vertexColors:e,metalness:0,roughness:.6})}function Je(e,t,r){let n=e.itemSize;return new Sr(e.array.slice(t*n,(t+r)*n),n)}function rt(e,t){let r=new Pr().parse(e),n=!!r.hasColors,o=new qe;if(r.groups.length>1){let a=r.userData.groupNames??[],u=r.getAttribute("position"),l=r.getAttribute("normal");return r.groups.forEach((c,d)=>{let p=new xr;p.setAttribute("position",Je(u,c.start,c.count)),l&&p.setAttribute("normal",Je(l,c.start,c.count));let f=new K(p,Y(!1));f.name=a[d]?.trim()||`${t} ${d+1}`,o.add(f)}),r.dispose(),o}r.clearGroups();let s=Y(n);n&&r.alpha!==void 0&&r.alpha<1&&(s.opacity=r.alpha,s.transparent=!0);let i=new K(r,s);return i.name=t,o.add(i),o}function Dr(e){let r=new TextDecoder().decode(new Uint8Array(e,0,Math.min(e.byteLength,65536))).split("end_header",1)[0],n=/^\s*element\s+face\s+(\d+)/m.exec(r);return!!(n&&Number(n[1])>0)}function nt(e,t){if(!Dr(e))throw new E;let r=new Rr().parse(e);r.getAttribute("normal")||r.computeVertexNormals();let n=new K(r,Y(!!r.getAttribute("color")));n.name=t;let o=new qe;return o.add(n),o}var Er={glb:"GLB",gltf:"glTF",obj:"OBJ",fbx:"FBX",usdz:"USDZ",stl:"STL",ply:"PLY"},Br=/\.(glb|gltf|obj|fbx|usdz|stl|ply|zip)$/i;function Cr(e,t){let r=e?.response?.status;if(typeof r=="number")return r;let n=/responded with (\d{3})/.exec(t);return n?Number(n[1]):null}function Io(e,t,r,n){let o=e instanceof Error?e.message:e==null?"":String(e),s=(p,f)=>ae(n,p,f),i=s("loadErrorTitle"),a=o||null;if(et(e))return{title:i,detail:s("loadErrorPointCloud"),technical:a};let u=Cr(e,o);if(u===404||u===410)return{title:i,detail:s("loadErrorNotFound",{status:u}),technical:a};if(u===401||u===403)return{title:i,detail:s("loadErrorDenied",{status:u}),technical:a};if(u!==null)return{title:i,detail:s("loadErrorStatus",{status:u}),technical:a};if(/failed to fetch|networkerror|load failed|network error/i.test(o))return{title:i,detail:s("loadErrorNetwork"),technical:a};if(/<!doctype|<html/i.test(o))return{title:i,detail:s("loadErrorHtml"),technical:a};let l=t.split(/[?#]/,1)[0],c=Er[r??x(t)],d=Br.test(l);return{title:i,detail:d||r?s(r?"loadErrorInvalidExplicitFormat":"loadErrorInvalidFile",{format:c}):s("loadErrorMissingFormat",{format:c}),technical:a}}import{useEffect as Tr,useState as kr}from"react";var J=80,Or=99,zr=6e3,Gr=200;function Fr(e,t=0){let r=Math.min(Math.max(e,0),100);return r<100?r/100*J:J+(Or-J)*(1-Math.exp(-t/zr))}function Wo(e,t=!1){let r=e!==null&&e>=100&&!t,[n,o]=kr(0);return Tr(()=>{if(!r){o(0);return}let s=performance.now(),i=setInterval(()=>o(performance.now()-s),Gr);return()=>clearInterval(i)},[r]),e===null?null:t?100:Fr(e,n)}import{useFrame as L,useThree as h}from"@react-three/fiber";import{ContactShadows as Ir}from"@react-three/drei";import{useXR as ot}from"@react-three/xr";import{Color as Ur,PerspectiveCamera as jr}from"three";import{useEffect as v,useLayoutEffect as at,useRef as B}from"react";import{Fragment as _r,jsx as st,jsxs as Nr}from"react/jsx-runtime";function Ko({renderMode:e,suspended:t=!1}){let{scene:r}=h(),n=h(a=>a.setFrameloop),o=ot(a=>a.session!=null),s=ot(a=>a.mode==="immersive-ar"),i=B(void 0);return v(()=>{n(t?"never":o?"always":e)},[o,e,t,n]),v(()=>{s?(i.current=r.background,r.background=null):i.current!==void 0&&(r.background=i.current,i.current=void 0)},[s,r]),L(()=>{s&&r.background!==null&&(r.background=null)}),null}function Yo({onPresentingChange:e}){let t=h(o=>o.gl),r=B(null);v(()=>{let o=t.xr;if(!o)return;let s=u=>{u?(r.current=t.shadowMap.enabled,t.shadowMap.enabled=!1):r.current!==null&&(t.shadowMap.enabled=r.current,r.current=null),e(u)},i=()=>s(!0),a=()=>s(!1);return o.addEventListener("sessionstart",i),o.addEventListener("sessionend",a),s(o.isPresenting),()=>{o.removeEventListener("sessionstart",i),o.removeEventListener("sessionend",a)}},[t,e]);let n=B(0);return L(()=>{if(!t.xr.isPresenting)return;let o=performance.now();if(o-n.current<1e3)return;n.current=o;let s=t.xr}),null}function Jo({active:e}){let t=h(r=>r.invalidate);return v(()=>{e&&t()},[e,t]),L(()=>{e&&t()}),null}function qo(e){let t=h(n=>n.gl),r=B(t.autoClear);return L(()=>{r.current=t.autoClear,t.autoClear=!0},-1),Nr(_r,{children:[st(Ir,{...e}),st(Wr,{saved:r})]})}function Wr({saved:e}){let t=h(r=>r.gl);return L(()=>{t.autoClear=e.current}),null}function Qo({color:e}){let{scene:t,invalidate:r}=h();return at(()=>(t.background=e?new Ur(e):null,r(),()=>{t.background=null}),[t,e,r]),null}function es({rotation:e}){let{scene:t,invalidate:r}=h();return at(()=>{let n=e*Math.PI/180;t.environmentRotation.set(0,n,0),t.backgroundRotation.set(0,n,0)}),v(()=>{r()},[e,r]),null}function ts({cameraConfig:e}){let{camera:t,invalidate:r}=h();return v(()=>{if(!(t instanceof jr))return;let n=e?.fov;typeof n=="number"&&t.fov!==n&&(t.fov=n,t.updateProjectionMatrix(),r())},[t,e,r]),null}var C=e=>e*Math.PI/180;function os(e){return{minDistance:e?.minDistance??0,maxDistance:e?.maxDistance??1/0,minPolarAngle:C(e?.minPolarAngle??0),maxPolarAngle:C(e?.maxPolarAngle??180),minAzimuthAngle:C(e?.minAzimuthAngle??-1/0),maxAzimuthAngle:C(e?.maxAzimuthAngle??1/0),boundaryEnclosesCamera:e?.boundaryEnclosesCamera??!1,boundaryFriction:e?.boundaryFriction??0,panBoundary:e?.panBoundary}}function as(e){for(let t=e;t;t=t.parent)if(!t.visible)return!1;return!0}import{useLoader as dt,useThree as en}from"@react-three/fiber";import{FileLoader as pt,Loader as tn,LoadingManager as rn}from"three";import{GLTFLoader as nn}from"three-stdlib";import{useGLTF as ls}from"@react-three/drei";import{useThree as ds}from"@react-three/fiber";import{useMemo as fs}from"react";import{SRGBColorSpace as Vr}from"three";import{DRACOLoader as $r,KTX2Loader as Hr,MeshoptDecoder as Xr}from"three-stdlib";function Zr(e){return{name:"RI_unlit_emissive_texture",async afterRoot(t){let r=e.json.materials??[],n=new Map;if(r.forEach(s=>{let i=!!s?.extensions?.KHR_materials_unlit,a=!!s?.pbrMetallicRoughness?.baseColorTexture;i&&!a&&s?.emissiveTexture&&s.name&&n.set(s.name,s.emissiveTexture.index)}),n.size===0||!t.scene)return;let o=new Map;await Promise.all([...n].map(async([s,i])=>{let a=await e.getDependency("texture",i);a&&(a.colorSpace=Vr,o.set(s,a))})),t.scene.traverse(s=>{let i=Array.isArray(s.material)?s.material:s.material?[s.material]:[];for(let a of i){let u=a.name?o.get(a.name):void 0;u&&!a.map&&(a.map=u,a.needsUpdate=!0)}})}}}var Kr="https://assets.react-immersive.liveroom.dev/three-r184/draco/",Yr="https://assets.react-immersive.liveroom.dev/three-r184/basis/";function Jr(e,t){if(!A(t))return e.detectSupport(t);let r=t,n=o=>r.hasFeature(o);return e.workerConfig={astcSupported:n("texture-compression-astc"),etc1Supported:n("texture-compression-etc1"),etc2Supported:n("texture-compression-etc2"),dxtSupported:n("texture-compression-s3tc"),bptcSupported:n("texture-compression-bc"),pvrtcSupported:n("texture-compression-pvrtc")},e}var it=new Map,ut=new WeakMap;function qr(e){let t=it.get(e);return t||(t=new $r,t.setDecoderPath(e),it.set(e,t)),t}function Qr(e,t){let r=ut.get(t);r||(r=new Map,ut.set(t,r));let n=r.get(e);return n||(n=Jr(new Hr().setTranscoderPath(e),t),r.set(e,n)),n}function lt(e,t={},r){let{dracoDecoderPath:n=Kr,ktx2TranscoderPath:o=Yr,meshopt:s=!0}=t;n&&e.setDRACOLoader(qr(n)),s&&e.setMeshoptDecoder(Xr),o&&r&&e.setKTX2Loader(Qr(o,r)),e.register((i=>Zr(i)))}var k=class extends tn{constructor(){super(...arguments);this.options={source:{format:"glb"}}}configure(r){return this.options=r,this}load(r,n,o,s){let i=performance.now(),a={format:this.options.source.format,name:this.options.source.entryPath??fe(r),sourceBytes:this.options.source.sourceBytes??null,failedResources:[]},u=l=>{a.sourceBytes===null&&l.lengthComputable&&l.total>0&&(a.sourceBytes=l.total),o?.(l)};this.loadAsset(r,u,a).then(l=>{a.loadDurationMs=Math.max(0,performance.now()-i),F(l.scene,a),n(l)}).catch(l=>{a.loadDurationMs=Math.max(0,performance.now()-i),l&&typeof l=="object"&&F(l,a),s?.(l)})}async loadAsset(r,n,o){let s=an(this.options.source);s.onError=l=>{let c=Object.entries(this.options.source.resourceUrls??{}).find(([,p])=>p===l)?.[0],d=me(c??l);o.failedResources.includes(d)||o.failedResources.push(d)};let{format:i}=this.options.source;if(i==="obj")return on(r,s,this.options.source,n);if(i==="fbx"){let{FBXLoader:l}=await import("three/examples/jsm/loaders/FBXLoader.js"),c=q(this,new l(s)),d=cn(r,this.options.source);d&&c.setResourcePath(d);let p=await c.loadAsync(r,n);return T(p,"FBXMesh",!1),{scene:p,animations:p.animations??[]}}if(i==="stl"||i==="ply"){let l=await sn(r,s,n),c=tt(this.options.source.entryPath??r,i==="stl"?"STL model":"PLY model"),d=i==="stl"?rt(l,c):nt(l,c);return T(d,i==="stl"?"STLMesh":"PLYMesh",!0),{scene:d,animations:[]}}if(i==="usdz"){let{USDLoader:l}=await import("three/examples/jsm/loaders/USDLoader.js"),d=await q(this,new l(s)).loadAsync(r,n);return T(d,"USDZMesh",!1),{scene:d,animations:d.animations??[]}}let a=q(this,new nn(s));lt(a,this.options.decoderConfig,this.options.renderer),a.register(l=>{let c=l.json,d=p=>Array.isArray(p)?p.filter(f=>typeof f=="string"):[];return o.extensionsUsed=d(c.extensionsUsed),o.extensionsRequired=d(c.extensionsRequired),{name:"RI_asset_diagnostics",beforeRoot:()=>null}});let u=await a.loadAsync(r,n);return{scene:u.scene,animations:u.animations??[],materialVariants:ue(u)}}};he(e=>{dt.clear(k,e)});function As(e,t={},r,n){let o=en(a=>a.gl),s=Pe(e),i=r?{...s,format:r}:s;return dt(k,e,a=>{a.configure({source:i,decoderConfig:t,renderer:o})},n)}async function on(e,t,r,n){let[{OBJLoader:o},s]=await Promise.all([import("three/examples/jsm/loaders/OBJLoader.js"),ct(e,t,n)]),i=new o(t),a=un(s);if(a){let l=ln(a,e,r);if(l)try{let c=await ct(l.url,t),{MTLLoader:d}=await import("three/examples/jsm/loaders/MTLLoader.js"),f=new d(t).parse(c,l.basePath);f.preload(),i.setMaterials(f)}catch(c){console.warn(`[react-immersive] Could not load OBJ material ${a}; rendering geometry with fallback materials.`,c)}}let u=i.parse(s);return T(u,"OBJMesh",!0),{scene:u,animations:[]}}function T(e,t,r){let n=new Set,o=0;e.traverse(s=>{if(!("isMesh"in s&&s.isMesh===!0)){s.name&&n.add(s.name);return}let a=s.name||`${t}_${++o}`;if(!r&&s.name){n.add(s.name);return}let u=a,l=2;for(;n.has(u);)u=`${a}_${l++}`;s.name=u,n.add(u)})}function ct(e,t,r){let n=new pt(t);return n.setResponseType("text"),n.loadAsync(e,r)}function sn(e,t,r){let n=new pt(t);return n.setResponseType("arraybuffer"),n.loadAsync(e,r)}function q(e,t){return t.setCrossOrigin(e.crossOrigin),t.setWithCredentials(e.withCredentials),t.setRequestHeader(e.requestHeader),t}function an(e){let t=new rn,r=e.resourceUrls;return r&&t.setURLModifier(n=>{if(/^(?:blob:|data:)/i.test(n))return n;let o=z(mt(n).split(/[?#]/)[0]),s=r[o];if(s)return s;let i=O(e.entryPath??""),a=z(i?`${i}/${o}`:o);return r[a]??n}),t}function un(e){return/^\s*mtllib\s+(.+?)\s*$/im.exec(e)?.[1]?.trim()||null}function ln(e,t,r){if(r.resourceUrls&&r.entryPath){let n=z(`${O(r.entryPath)}/${mt(e)}`),o=r.resourceUrls[n];if(!o)return null;let s=O(n);return{url:o,basePath:s?`${s}/`:""}}try{let n=new URL(e,t).href;return{url:n,basePath:ft(n)}}catch{return null}}function cn(e,t){if(t.resourceUrls&&t.entryPath){let r=O(t.entryPath);return r?`${r}/`:""}return ft(e)}function ft(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t+1)}function O(e){let t=z(e),r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function z(e){let t=[];for(let r of e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(n=>n&&n!=="."))r===".."?t.pop():t.push(r);return t.join("/")}function mt(e){try{return decodeURI(e)}catch{return e}}import{Color as Q,MeshPhysicalMaterial as dn,MeshStandardMaterial as pn,Texture as ee}from"three";function Cs(e){if(de(e))return e;if(!e||typeof e!="object")return null;let t=e,r=new pn;typeof t.name=="string"&&(r.name=t.name),r.metalness=0,r.roughness=1,t.type==="MeshBasicMaterial"||t.isMeshBasicMaterial===!0?(r.color.set(0),r.emissiveIntensity=1,t.map instanceof ee?(r.emissiveMap=t.map,r.emissive.set(16777215)):t.color instanceof Q&&r.emissive.copy(t.color)):(t.color instanceof Q&&r.color.copy(t.color),t.map instanceof ee&&(r.map=t.map),t.emissive instanceof Q&&r.emissive.copy(t.emissive),t.emissiveMap instanceof ee&&(r.emissiveMap=t.emissiveMap));let o=["aoMap","aoMapIntensity","lightMap","lightMapIntensity","alphaMap","opacity","transparent","alphaTest","side","vertexColors","wireframe","depthTest","depthWrite","visible","toneMapped","fog"];for(let s of o)t[s]!==void 0&&(r[s]=t[s]);return r.needsUpdate=!0,r}function Ts(e){if(pe(e))return e.clone();let t=new dn;return t.name=e.name,t.color.copy(e.color),t.map=e.map,t.lightMap=e.lightMap,t.lightMapIntensity=e.lightMapIntensity,t.aoMap=e.aoMap,t.aoMapIntensity=e.aoMapIntensity,t.emissive.copy(e.emissive),t.emissiveIntensity=e.emissiveIntensity,t.emissiveMap=e.emissiveMap,t.bumpMap=e.bumpMap,t.bumpScale=e.bumpScale,t.normalMap=e.normalMap,t.normalMapType=e.normalMapType,t.normalScale.copy(R(e.normalScale)),t.displacementMap=e.displacementMap,t.displacementScale=e.displacementScale,t.displacementBias=e.displacementBias,t.roughness=e.roughness,t.roughnessMap=e.roughnessMap,t.metalness=e.metalness,t.metalnessMap=e.metalnessMap,t.alphaMap=e.alphaMap,t.envMap=e.envMap,t.envMapRotation.copy(e.envMapRotation),t.envMapIntensity=e.envMapIntensity,t.wireframe=e.wireframe,t.wireframeLinewidth=e.wireframeLinewidth,t.flatShading=e.flatShading,t.fog=e.fog,t.opacity=e.opacity,t.transparent=e.transparent,t.alphaHash=e.alphaHash,t.blendSrc=e.blendSrc,t.blendDst=e.blendDst,t.blendEquation=e.blendEquation,t.blendSrcAlpha=e.blendSrcAlpha,t.blendDstAlpha=e.blendDstAlpha,t.blendEquationAlpha=e.blendEquationAlpha,t.blending=e.blending,t.premultipliedAlpha=e.premultipliedAlpha,t.dithering=e.dithering,t.alphaTest=e.alphaTest,t.depthTest=e.depthTest,t.depthWrite=e.depthWrite,t.colorWrite=e.colorWrite,t.stencilWrite=e.stencilWrite,t.stencilWriteMask=e.stencilWriteMask,t.stencilFunc=e.stencilFunc,t.stencilRef=e.stencilRef,t.stencilFuncMask=e.stencilFuncMask,t.stencilFail=e.stencilFail,t.stencilZFail=e.stencilZFail,t.stencilZPass=e.stencilZPass,t.side=e.side,t.shadowSide=e.shadowSide,t.toneMapped=e.toneMapped,t.vertexColors=e.vertexColors,t.visible=e.visible,t.clippingPlanes=e.clippingPlanes,t.clipIntersection=e.clipIntersection,t.clipShadows=e.clipShadows,t.forceSinglePass=e.forceSinglePass,t.polygonOffset=e.polygonOffset,t.polygonOffsetFactor=e.polygonOffsetFactor,t.polygonOffsetUnits=e.polygonOffsetUnits,t}function ks(e){e.userData.baseColor=e.color.clone(),e.userData.baseMap=e.map??null,e.userData.baseVertexColors=e.vertexColors,e.userData.baseMetalness=e.metalness,e.userData.baseMetalnessMap=e.metalnessMap??null,e.userData.baseRoughness=e.roughness,e.userData.baseRoughnessMap=e.roughnessMap??null,e.userData.baseEmissive=e.emissive.clone(),e.userData.baseEmissiveIntensity=e.emissiveIntensity,e.userData.baseEmissiveMap=e.emissiveMap??null,e.userData.baseOpacity=e.opacity,e.userData.baseTransparent=e.transparent,e.userData.baseAlphaMap=e.alphaMap??null,e.userData.baseAlphaTest=e.alphaTest,e.userData.baseAlphaHash=e.alphaHash,e.userData.baseDithering=e.dithering,e.userData.baseBlending=e.blending,e.userData.baseDepthWrite=e.depthWrite,e.userData.baseSide=e.side,e.userData.baseNormalMap=e.normalMap??null,e.userData.baseNormalScale=R(e.normalScale),e.userData.baseBumpMap=e.bumpMap??null,e.userData.baseBumpScale=e.bumpScale,e.userData.baseAoMap=e.aoMap??null,e.userData.baseAoMapIntensity=e.aoMapIntensity,e.userData.baseDisplacementMap=e.displacementMap??null,e.userData.baseDisplacementScale=e.displacementScale,e.userData.baseDisplacementBias=e.displacementBias,e.userData.baseClearcoat=e.clearcoat,e.userData.baseClearcoatMap=e.clearcoatMap??null,e.userData.baseClearcoatRoughness=e.clearcoatRoughness,e.userData.baseClearcoatRoughnessMap=e.clearcoatRoughnessMap??null,e.userData.baseClearcoatNormalMap=e.clearcoatNormalMap??null,e.userData.baseClearcoatNormalScale=R(e.clearcoatNormalScale),e.userData.baseSheen=e.sheen,e.userData.baseSheenColor=e.sheenColor.clone(),e.userData.baseSheenColorMap=e.sheenColorMap??null,e.userData.baseSheenRoughness=e.sheenRoughness,e.userData.baseSheenRoughnessMap=e.sheenRoughnessMap??null,e.userData.baseAnisotropy=e.anisotropy,e.userData.baseAnisotropyRotation=e.anisotropyRotation,e.userData.baseAnisotropyMap=e.anisotropyMap??null,e.userData.baseTransmission=e.transmission,e.userData.baseTransmissionMap=e.transmissionMap??null,e.userData.baseThickness=e.thickness,e.userData.baseThicknessMap=e.thicknessMap??null,e.userData.baseAttenuationColor=e.attenuationColor.clone(),e.userData.baseAttenuationDistance=e.attenuationDistance,e.userData.baseReflectivity=e.reflectivity,e.userData.baseSpecularIntensity=e.specularIntensity,e.userData.baseSpecularIntensityMap=e.specularIntensityMap??null,e.userData.baseSpecularColor=e.specularColor.clone(),e.userData.baseSpecularColorMap=e.specularColorMap??null,e.userData.baseFlatShading=e.flatShading,e.userData.baseEnvMapIntensity=e.envMapIntensity}import{Box3 as te,Matrix4 as fn,Sphere as mn,Vector3 as re}from"three";var bt=new WeakMap,ht=new re,bn=new re,hn=new re,gn=new te,gt=new fn;function y(e){return"data"in e?e.data.version:e.version}function vn(e){var u;let{geometry:t,skeleton:r}=e,n=t.getAttribute("position"),o=t.getAttribute("skinIndex"),s=t.getAttribute("skinWeight"),i=bt.get(e);if(i?.geometry===t&&i.position===n&&i.indices===o&&i.weights===s&&i.skeleton===r&&i.bindMatrix.equals(e.bindMatrix)&&i.versions[0]===y(n)&&i.versions[1]===y(o)&&i.versions[2]===y(s)&&i.inverses.length===r.boneInverses.length&&i.inverses.every((l,c)=>l.equals(r.boneInverses[c])))return i;let a={geometry:t,position:n,indices:o,weights:s,skeleton:r,versions:[y(n),y(o),y(s)],bindMatrix:e.bindMatrix.clone(),inverses:r.boneInverses.map(l=>l.clone()),bones:[],weightDeviation:0};e:for(let l=0;l<n.count;l++){ht.fromBufferAttribute(n,l).applyMatrix4(e.bindMatrix);let c=0;for(let p=0;p<4;p++){let f=s.getComponent(l,p);if(f===0)continue;let m=o.getComponent(l,p);if(!Number.isFinite(f)||f<0||!Number.isInteger(m)||!r.bones[m]||!a.inverses[m]){a.bones=null;break e}c+=f,((u=a.bones)[m]??(u[m]=new te)).expandByPoint(bn.copy(ht).applyMatrix4(a.inverses[m]))}let d=Math.abs(c-1);if(d>1e-4){a.bones=null;break}a.weightDeviation=Math.max(a.weightDeviation,d)}return bt.set(e,a),a}function Fs(e,{precise:t=!1,updateFallbacks:r=!0}={}){e.updateMatrixWorld(!0),e.traverse(n=>{if(!oe(n))return;let o=n;if(!o.skeleton)return;let s=se(o);s&&o.bindMatrixInverse.copy(s);let a=!!o.geometry.morphAttributes.position?.length?null:vn(o);if(!t&&!a?.bones&&!r&&o.boundingBox&&o.boundingSphere)return;let u=o.boundingBox??(o.boundingBox=new te),l=o.boundingSphere??(o.boundingSphere=new mn);if(u.makeEmpty(),t||!a?.bones){let c=o.geometry.getAttribute("position");for(let d=0;d<c.count;d++)u.expandByPoint(o.getVertexPosition(d,hn))}else{for(let c=0;c<a.bones.length;c++){let d=a.bones[c];d&&(gt.multiplyMatrices(o.bindMatrixInverse,o.skeleton.bones[c].matrixWorld),u.union(gn.copy(d).applyMatrix4(gt)))}if(!u.isEmpty()){let c=u.min,d=u.max,p=o.bindMatrixInverse.elements,f=Math.max(1,Math.abs(c.x),Math.abs(c.y),Math.abs(c.z),Math.abs(d.x),Math.abs(d.y),Math.abs(d.z)),m=Math.max(Math.abs(c.x-p[12]),Math.abs(d.x-p[12]),Math.abs(c.y-p[13]),Math.abs(d.y-p[13]),Math.abs(c.z-p[14]),Math.abs(d.z-p[14]));u.expandByScalar(a.weightDeviation*m+f*1e-10)}}u.getBoundingSphere(l)})}import{useCallback as vt,useEffect as yn,useRef as Mn}from"react";import{useThree as wn}from"@react-three/fiber";function Ws(){let e=wn(o=>o.gl.domElement),t=Mn(void 0),r=vt(o=>{t.current===void 0&&(t.current=e.style.cursor),e.style.cursor=o},[e]),n=vt(()=>{let o=t.current;o!==void 0&&(e.style.cursor=o,t.current=void 0)},[e]);return yn(()=>()=>{n()},[n]),{setCanvasCursor:r,restoreCanvasCursor:n}}import{Box3 as xn,Vector3 as yt}from"three";function G(e){return[e.x,e.y,e.z]}function $s(e){let t=new xn().setFromObject(e),r=0;return e.traverse(n=>{n.isMesh&&(r+=1)}),{bounds:{min:G(t.min),max:G(t.max),center:G(t.getCenter(new yt)),size:G(t.getSize(new yt))},objectCount:r,materialVariants:le(e),materialVariantGroups:ce(e)}}import{jsx as P,jsxs as ne}from"react/jsx-runtime";function Ys({visible:e,title:t,message:r,progress:n}){if(!e)return null;let o=typeof n=="number"&&Number.isFinite(n),s=o?Math.round(Math.min(Math.max(n,0),100)):0;return P("div",{className:"bb-loadingOverlay",role:"status","aria-live":"polite",children:ne("div",{className:"bb-loadingCard",children:[ne("div",{className:"bb-loadingHeader",children:[P("span",{className:"bb-loadingTitle",title:t??r,children:t??r}),o?ne("span",{className:"bb-loadingPercent",children:[s,"%"]}):null]}),P("div",{className:`bb-loadingProgress ${o?"":"bb-loadingProgress--unknown"}`,role:"progressbar","aria-label":t??r,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o?s:void 0,children:P("div",{className:"bb-loadingProgress__bar",style:o?{width:`${s}%`}:void 0})}),t?P("span",{className:"bb-loadingMessage",children:r}):null]})})}export{Oe as a,In as b,Un as c,dr as d,po as e,H as f,fo as g,M as h,An as i,Pe as j,Dn as k,Te as l,Tn as m,$t as n,kn as o,On as p,A as q,qn as r,Qn as s,Zn as t,oo as u,so as v,ao as w,io as x,wo as y,wr as z,Do as A,et as B,Io as C,Wo as D,Ko as E,Yo as F,Jo as G,qo as H,Qo as I,es as J,ts as K,os as L,as as M,Kr as N,Yr as O,As as P,Cs as Q,Ts as R,ks as S,Fs as T,Ws as U,$s as V,Ys as W};
@@ -1,50 +0,0 @@
1
- import{f as jt,h as vt}from"./chunk-7OWHW66D.mjs";import{e as je,f as Ct}from"./chunk-LX3GXQNU.mjs";import{p as Et}from"./chunk-7JCFNZJM.mjs";import{a as Mt,b as Oe}from"./chunk-GV4ZRXL6.mjs";import{a as be,b as kt,c as Ot,d as ve,e as ke,f as Tt,g as It,h as Rt,j as Bt,x as Te,z as Pt}from"./chunk-6Q6YZ7O5.mjs";var Ie=new WeakMap;function Mr(e,t){return Ie.set(e,t),()=>{Ie.get(e)===t&&Ie.delete(e)}}function Vt(e){Ie.get(e)?.()}var Nt=new WeakMap;function Ge(e){let t=Nt.get(e);return t||(t={state:"active",listeners:new Set},Nt.set(e,t)),t}function qe(e){return e?Ge(e).state:"active"}function He(e){return qe(e)==="paused"}function Xe(e,t){let n=Ge(e);return n.listeners.add(t),()=>{n.listeners.delete(t)}}function kr(e,t){let n=Ge(e);n.state!==t&&(n.state=t,n.listeners.forEach(o=>o()))}async function re(e,t,n){if(qe(e)==="disconnected")throw new Error("The camera is disconnected from the viewer.");Vt(e);let o=async()=>{let i=await t(!1);return e.update(0),i};if(He(e))return o();if(!n)return t(!1);let r=()=>{};try{return await new Promise((i,a)=>{let s=!1,c=l=>{s||(s=!0,l())};r=Xe(e,()=>{let l=qe(e);l==="paused"?o().then(m=>c(()=>i(m)),m=>c(()=>a(m))):l==="disconnected"&&c(()=>a(new Error("The camera move was cancelled because the viewer disconnected.")))}),Promise.resolve().then(()=>t(!0)).then(l=>c(()=>i(l)),l=>c(()=>a(l)))})}finally{r()}}import{useCallback as Y,useRef as me,useState as Je,useSyncExternalStore as no}from"react";import{Vector3 as Ut}from"three";var Ke=new WeakSet;function de(e){Ke.add(e)}function Tr(e){let t=Ke.has(e);return t&&Ke.delete(e),t}var Ye=new WeakSet;function Rr(e,t){t?Ye.add(e):Ye.delete(e)}function zt(e,t){return Ye.has(e)?0:t}import{Box3 as Dt,Matrix4 as to,PerspectiveCamera as $t,Vector3 as Ze}from"three";function Vr(e,t){let n=jt(e);if(!(e.camera instanceof $t)||!t)return n;let o=t instanceof Dt?t:new Dt().setFromObject(t);return o.isEmpty()||(n.framing={aspect:e.camera.aspect,min:o.min.toArray(),max:o.max.toArray()}),n}function Lt(e,t){let n=t.camera,o=e.framing;if(!(n instanceof $t)||!o||!(n.aspect>0)||Math.abs(n.aspect-o.aspect)<1e-6)return[...e.position];let r=new Ze(...e.position),i=new Ze(...e.target),a=r.clone().sub(i).normalize(),s=new to().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 m of[o.min[0],o.max[0]])for(let f of[o.min[1],o.max[1]])for(let u of[o.min[2],o.max[2]]){let d=new Ze(m,f,u).sub(r).applyMatrix4(s);l=Math.max(l,Math.abs(d.x)/(c*n.aspect)+d.z,Math.abs(d.y)/c+d.z)}return r.addScaledVector(a,l*1.02).toArray()}function _t(e){return[e.x,e.y,e.z]}function ne(e,t){let n=new Ut,o=new Ut;return t.getPosition(n),t.getTarget(o),{position:_t(n),target:_t(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 oo(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 he(e,t,n=.6){let o=e.smoothTime;e.smoothTime=zt(e,n);try{return await re(e,t,!0)}finally{e.smoothTime=o}}function Hr(e={}){let t=me(e);t.current=e;let n=me(null),[o,r]=Je(null),i=Y(y=>o?Xe(o,y):()=>{},[o]),a=Y(()=>He(o),[o]),s=no(i,a,()=>!1),[c,l]=Je(null),[m,f]=Je(()=>({...e.presets})),u=me(m);u.current=m;let d=Y(y=>{l(C=>oo(C,y)?C:y)},[]),p=Y(y=>{d(y)},[d]),x=me(null),b=me(null),S=me(null),w=Y(y=>{n.current=y,r(y.raw.controls);let C=ne(y.raw.controls.camera,y.raw.controls);d(C),y.raw.scene!==b.current&&(b.current=y.raw.scene,x.current=null,S.current=null),y.homeCameraState&&!x.current&&(x.current=y.homeCameraState);let{initialPosition:v,initialTarget:B,initialTransition:W=!1}=t.current;if((v||B)&&y.raw.scene&&(v||y.homeCameraState)&&S.current!==y.raw.controls){S.current=y.raw.controls,y.homeCameraState||de(y.raw.controls);let X=v??C.position,K=B??C.target;re(y.raw.controls,ee=>y.raw.controls.setLookAt(X[0],X[1],X[2],K[0],K[1],K[2],ee),W).then(()=>{if(n.current?.raw.controls!==y.raw.controls)return;let ee=ne(y.raw.controls.camera,y.raw.controls);x.current={position:ee.position,target:ee.target},d(ee)}).catch(()=>{})}},[d]),g=Y(async()=>{let y=n.current,C=y?.raw.controls;if(!C)return!1;try{let v=x.current;if(v){vt(C,v);let B=Lt(v,C);await he(C,W=>C.setLookAt(B[0],B[1],B[2],v.target[0],v.target[1],v.target[2],W))}else y?.raw.scene?await he(C,B=>C.fitToBox(y.raw.scene,B,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})):await he(C,B=>C.reset(B));return!0}catch{return!1}},[]),A=Y(async()=>{let y=n.current;if(!y?.raw.controls||!y.raw.scene)return!1;try{return await he(y.raw.controls,C=>y.raw.controls.fitToBox(y.raw.scene,C,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),j=Y(async y=>{let C=n.current;if(!C?.raw.controls)return!1;let v=Mt(C.objectBindings,y);if(!v)return!1;let B=C.raw.nodes[v];if(!B)return!1;try{return await he(C.raw.controls,W=>C.raw.controls.fitToBox(B,W,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),P=Y(async(y,C=!0)=>{let v=n.current?.raw.controls;if(!v)return!1;try{return n.current?.homeCameraState||de(v),await re(v,B=>v.setTarget(y[0],y[1],y[2],B),C),d(ne(v.camera,v)),!0}catch{return!1}},[d]),R=Y(async(y,C=!0)=>{let v=n.current?.raw.controls;if(!v)return!1;try{n.current?.homeCameraState||de(v),await re(v,async X=>{let K=[v.setLookAt(y.position[0],y.position[1],y.position[2],y.target[0],y.target[1],y.target[2],X)];y.azimuthAngle!=null&&y.polarAngle!=null&&K.push(v.rotateTo(y.azimuthAngle,y.polarAngle,X)),await Promise.all(K)},C);let B=v.camera,W=!1;return y.fov!=null&&"fov"in B&&typeof B.fov=="number"&&(B.fov=y.fov,W=!0),y.zoom!=null&&"zoom"in B&&typeof B.zoom=="number"&&(B.zoom=y.zoom,W=!0),W&&"updateProjectionMatrix"in B&&B.updateProjectionMatrix(),d(ne(B,v)),!0}catch{return!1}},[d]),V=Y((y,C=!0)=>R(y,C),[R]),O=Y((y,C,v=!0)=>R({position:y,target:C},v),[R]),h=Y(async(y,C,v=!0)=>{let B=n.current?.raw.controls;if(!B)return!1;try{return n.current?.homeCameraState||de(B),await re(B,W=>B.rotateTo(y*Math.PI/180,C*Math.PI/180,W),v),d(ne(B.camera,B)),!0}catch{return!1}},[d]),M=Y(async(y,C=!0)=>{let v=n.current?.raw.controls;if(!v)return!1;try{return n.current?.homeCameraState||de(v),await re(v,B=>v.dollyTo(y,B),C),d(ne(v.camera,v)),!0}catch{return!1}},[d]),k=Y(y=>{let C={...y};u.current=C,f(C)},[]),E=Y(y=>{let C=n.current?.raw.controls,v=y.trim();if(!C||!v)return null;let B=ne(C.camera,C);return u.current={...u.current,[v]:B},f(W=>({...W,[v]:B})),d(B),B},[d]),N=Y((y,C=!0)=>{let v=u.current[y];return v?R(v,C):Promise.resolve(!1)},[R]);return{isRenderPaused:s,cameraState:c,cameraPresets:m,setCameraPresets:k,resetView:g,focusObject:j,fitScene:A,setCameraTarget:P,setCameraState:V,lookAt:O,orbitTo:h,dollyTo:M,savePreset:E,goToPreset:N,handleCameraChange:p,handleViewerReady:w}}function Kr(e){let t=e.trim();return t?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(t):!1}var Yr=["none","directional","point","spot","hemisphere"],Zr=["pbr","matcap","uv-checker"],Jr=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var Qr=["sporadic","constantMild","constantWild"],ei=["linear","radial","mirroredLinear"],ti=["verySmall","small","medium","large","veryLarge","huge"];var Qe={enabled:!1,axis:"y",position:.5,flip:!1},ro={clips:[],autoplayClip:null},io={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}},fe={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:io,animations:ro,annotations:[]};function ye(e){let t=m=>{throw new Error(`Invalid section: ${m}`)},n=m=>m&&typeof m=="object"&&!Array.isArray(m)?m:t("expected an object"),o=m=>typeof m=="string"&&m.trim().length>0&&m.length<=200?m:t("expected a nonempty name or id (up to 200 characters)"),r=m=>typeof m=="number"&&Number.isFinite(m)&&m>=0&&m<=1?m:t("position must be between 0 and 1"),i=m=>!Array.isArray(m)||m.length!==3||!m.every(f=>typeof f=="number"&&Number.isFinite(f))||Math.hypot(...m)<1e-8?t("normal must be a finite, nonzero vector"):[...m],a=m=>{let f=n(m);return!["x","y","z"].includes(f.axis)||typeof f.enabled!="boolean"||typeof f.flip!="boolean"?t("invalid plane"):{enabled:f.enabled,axis:f.axis,position:r(f.position),flip:f.flip,...f.normal!==void 0?{normal:i(f.normal)}:{}}},s=m=>{let f=n(m),u=a(f);if(f.mode!==void 0){if(!["plane","planes","box"].includes(f.mode))return t("invalid mode");u.mode=f.mode}if(f.planes!==void 0){if(!Array.isArray(f.planes)||f.planes.length>6)return t("at most six planes are supported");let d=new Set;u.planes=f.planes.map(p=>{let x=n(p),b=o(x.id);return d.has(b)?t("duplicate plane id"):(d.add(b),{...a(x),id:b,name:o(x.name)})})}if(f.activePlaneId!==void 0&&(u.activePlaneId=o(f.activePlaneId)),f.invertBox!==void 0){if(typeof f.invertBox!="boolean")return t("invalid box inversion");u.invertBox=f.invertBox}if(f.box!==void 0){let d=n(f.box),p=S=>!Array.isArray(S)||S.length!==3?t("invalid box bounds"):S.map(r),x=p(d.min),b=p(d.max);if(x.some((S,w)=>S>=b[w]))return t("box minimum must be below its maximum on every axis");u.box={min:x,max:b}}return u},c=n(e),l=s(c);if(c.presets!==void 0){if(!Array.isArray(c.presets)||c.presets.length>32)return t("at most 32 presets are supported");let m=new Set;l.presets=c.presets.map(f=>{let u=n(f),d=o(u.id);return m.has(d)?t("duplicate preset id"):(m.add(d),{id:d,name:o(u.name),settings:s(u.settings)})})}return l}function ri(e){let{presets:t,...n}=ye(e);return n}function ii(e){try{return ye(e)}catch{return Qe}}function si(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 ye(n?t:{...Qe,...e,...t})}import{Box3 as Ft,Matrix4 as Ee,Quaternion as so,Vector3 as Re,Euler as ao}from"three";var li={version:1,placements:{},gridSize:1};function et(e){return e.id??e.url}function Se(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 ui(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=Se(r);if(r.label!==void 0&&(typeof r.label!="string"||r.label.length>512))throw new Error("Invalid asset label.");for(let a of["visible","deleted"])if(r[a]!==void 0&&typeof r[a]!="boolean")throw new Error(`Invalid asset ${a}.`);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 di(e,t){if(!Number.isFinite(t)||t<=0)throw new Error("Grid size must be positive.");let n=Se(e),[o,r,i]=n.position??[0,0,0];return{...n,position:[Math.round(o/t)*t,r,Math.round(i/t)*t]}}function mi(e,t){let n=Se(e),o=n.position??[0,0,0],r=new Ee().compose(new Re(...o),new so().setFromEuler(new ao(...n.rotation??[0,0,0])),new Re(...n.scale??[1,1,1])),i=new Ft(new Re(...t.min),new Re(...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 fi(e){e.updateWorldMatrix(!0,!0);let t=new Ee().copy(e.parent?.parent?.matrixWorld??new Ee).invert(),n=new Ft;return e.traverse(o=>{let r=o;r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&n.union(r.geometry.boundingBox.clone().applyMatrix4(new Ee().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 co,Float32BufferAttribute as lo,Matrix4 as qt,Mesh as tt,ShapeUtils as uo,Vector2 as Gt,Vector3 as G,Vector4 as mo}from"three";function Ht(e){if(e.length!==3)return null;let t=new G(...e[0]).sub(new G(...e[1])),n=new G(...e[2]).sub(new G(...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 Xt(e,t){if(!e.normal)return null;let n=new G(...e.normal);if(n.lengthSq()===0)return null;n.normalize();let o=new G(...t),r=o.clone().sub(new G(...e.position)).dot(n);return{distance:Math.abs(r),projection:o.addScaledVector(n,-r).toArray()}}function Kt(e){if(e.length<3)return{error:"Pick at least three points to finish the area."};let t=new G(...e[0]),n=e.map(b=>new G(...b).sub(t)),o=Math.max(...n.map(b=>b.length()));if(o===0)return{error:"Area points must be distinct."};let r=new G;for(let b=1;b<n.length-1;b+=1){let S=n[b].clone().cross(n[b+1]);S.lengthSq()>r.lengthSq()&&r.copy(S)}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(b=>Math.abs(b.dot(r))>i))return{error:"Area points must lie on one plane."};let a=n.find(b=>b.length()>o*1e-10).clone().normalize(),s=r.clone().cross(a).normalize(),c=n.map(b=>new Gt(b.dot(a),b.dot(s))),l=(b,S,w)=>(S.x-b.x)*(w.y-b.y)-(S.y-b.y)*(w.x-b.x),m=o*o*1e-10,f=(b,S,w)=>Math.abs(l(b,S,w))<=m&&w.x>=Math.min(b.x,S.x)-o*1e-10&&w.x<=Math.max(b.x,S.x)+o*1e-10&&w.y>=Math.min(b.y,S.y)-o*1e-10&&w.y<=Math.max(b.y,S.y)+o*1e-10;for(let b=0;b<c.length;b+=1){let S=c[b],w=c[(b+1)%c.length];if(S.distanceTo(w)<=o*1e-10)return{error:"Area points must be distinct."};for(let g=b+1;g<c.length;g+=1){if(g===b+1||b===0&&g===c.length-1)continue;let A=c[g],j=c[(g+1)%c.length],P=l(S,w,A),R=l(S,w,j),V=l(A,j,S),O=l(A,j,w);if(P*R<0&&V*O<0||f(S,w,A)||f(S,w,j)||f(A,j,S)||f(A,j,w))return{error:"Area edges must not cross or touch each other."}}}let u=0,d=0,p=0;for(let b=0;b<c.length;b+=1){let S=c[b],w=c[(b+1)%c.length],g=S.x*w.y-w.x*S.y;u+=g,d+=(S.x+w.x)*g,p+=(S.y+w.y)*g}if(Math.abs(u)<=m)return{error:"The polygon has no measurable area."};let x=t.clone().addScaledVector(a,d/(3*u)).addScaledVector(s,p/(3*u));return{area:Math.abs(u)/2,center:x.toArray(),triangles:uo.triangulateShape(c,[])}}function nt(e,t){if(e.length<2)return 0;let n=0;for(let o=1;o<e.length;o+=1)n+=new G(...e[o]).distanceTo(new G(...e[o-1]));return t&&(n+=new G(...e[e.length-1]).distanceTo(new G(...e[0]))),n}var fo=1e-5;function po(e,t){let n=e.getAttribute("position"),o=e.getIndex(),r=n.count,i=Math.max(t,1e-9),a=(p,x,b)=>`${Math.round(p/i)}_${Math.round(x/i)}_${Math.round(b/i)}`,s=new Int32Array(r),c=[],l=new Map;for(let p=0;p<r;p+=1){let x=n.getX(p),b=n.getY(p),S=n.getZ(p),w=a(x,b,S),g=l.get(w);g===void 0&&(g=c.length,c.push(new G(x,b,S)),l.set(w,g)),s[p]=g}let m=c.map(()=>new Map),f=(p,x)=>{if(p===x)return;let b=c[p].distanceTo(c[x]);m[p].has(x)||m[p].set(x,b),m[x].has(p)||m[x].set(p,b)},u=(o?o.count:r)/3,d=p=>o?o.getX(p):p;for(let p=0;p<u;p+=1)f(s[d(p*3)],s[d(p*3+1)]),f(s[d(p*3+1)],s[d(p*3+2)]),f(s[d(p*3+2)],s[d(p*3)]);return{weldedId:s,weldedPosition:c,neighbors:m}}function go(e,t,n){let o=new Map([[t,0]]),r=[t];for(let i=0;i<n&&r.length>0;i+=1){let a=[];for(let s of r){let c=o.get(s)??0;for(let[l,m]of e[s]??[])o.has(l)||(o.set(l,c+m),a.push(l))}r=a}return o}function bo(e){let n=(Math.abs(e.y)<.9?new G(0,1,0):new G(1,0,0)).clone().cross(e).normalize(),o=e.clone().cross(n).normalize();return[n,o]}function ho(e,t,n){let[o,r]=bo(t),i=0,a=0,s=0;for(let x of n){let b=x.clone().sub(e),S=b.dot(o),w=b.dot(r);i+=S*S,a+=S*w,s+=w*w}let c=i+s,l=i*s-a*a,m=Math.sqrt(Math.max(0,c*c/4-l)),f=c/2+m,u=1,d=0;Math.abs(a)>1e-12?(u=f-s,d=a):s>i&&(u=0,d=1);let p=Math.hypot(u,d)||1;return o.clone().multiplyScalar(u/p).add(r.clone().multiplyScalar(d/p)).normalize()}function yo(e,t,n,o){let r=e.getAttribute("position"),i=e.getIndex(),a=r.count,s=(i?i.count:a)/3,c=u=>i?i.getX(u):u,l=u=>new G(r.getX(u),r.getY(u),r.getZ(u)).applyMatrix4(t),m=u=>u.clone().sub(n).dot(o),f=[];for(let u=0;u<s;u+=1){let d=l(c(u*3)),p=l(c(u*3+1)),x=l(c(u*3+2)),b=m(d),S=m(p),w=m(x),g=[],A=(j,P,R,V)=>{P>0!=V>0&&g.push(j.clone().lerp(R,P/(P-V)))};A(d,b,p,S),A(p,S,x,w),A(x,w,d,b),g.length===2&&f.push([g[0],g[1]])}return f}function So(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=[],a=u=>{let d=o(u),p=r.get(d);return p===void 0&&(p=i.length,i.push(u),r.set(d,p)),p},s=[],c=u=>{for(;s.length<=u;)s.push(new Map)};for(let[u,d]of e){let p=a(u),x=a(d);p!==x&&(c(p),c(x),s[p].set(x,(s[p].get(x)??0)+1),s[x].set(p,(s[x].get(p)??0)+1))}let l=(u,d)=>u<d?`${u}_${d}`:`${d}_${u}`,m=new Set,f=[];for(let u=0;u<s.length;u+=1)for(let d of s[u]?.keys()??[]){if(m.has(l(u,d)))continue;let p=[u],x=u,b=d;m.add(l(x,b));let S=0;for(;b!==u&&b>=0&&S<s.length+4;){p.push(b);let w=[...s[b].keys()].filter(A=>A!==x),g;if(w.length<=1)g=w[0];else{let A=i[b].clone().sub(i[x]).normalize(),j=-1/0;for(let P of w){let R=i[P].clone().sub(i[b]).normalize(),V=A.dot(R);V>j&&(j=V,g=P)}}if(g===void 0){b=-1;break}m.add(l(b,g)),x=b,b=g,S+=1}b===u&&p.length>=3&&f.push(p.map(w=>i[w]))}return f}function Wt(e,t){let n=1/0;for(let o of e)n=Math.min(n,o.distanceTo(t));return n}function xo(e,t){let n=0,o=1/0;return e.forEach((r,i)=>{let a=r.distanceTo(t);a<o&&(o=a,n=i)}),[...e.slice(n),...e.slice(0,n)]}function Yt(e,t,n,o,r){let i=yo(e,t,o,r);if(i.length===0)return{error:"Couldn't trace a loop around this point."};let a=So(i,n*t.getMaxScaleOnAxis());if(a.length===0)return{error:"The surface here doesn't form a closed loop around this point (it may be near an open edge)."};let s=a[0],c=Wt(s,o);for(let m of a.slice(1)){let f=Wt(m,o);f<c&&(c=f,s=m)}let l=xo(s,o).map(m=>m.toArray());return{points:l,length:nt(l,!0)}}function Zt(e){if(!(e.object instanceof tt)||!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"),a=new lo(new Float32Array(i.count*3),3),s=new G;for(let c=0;c<i.count;c++)t.getVertexPosition(c,s),a.setXYZ(c,s.x,s.y,s.z);n=new co().setAttribute("position",a).setIndex(n.getIndex())}let o=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let i=new qt;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*fo}}function bi(e,t=6){let n=Zt(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:a}=n,s=Jt(e);if(!s)return{error:"Pick a point on the mesh surface to trace a loop around it."};let c=s[1].clone().sub(s[0]).cross(s[2].clone().sub(s[0]));if(c.lengthSq()===0)return{error:"Couldn't determine the surface direction at this point."};c.normalize();let{weldedId:l,weldedPosition:m,neighbors:f}=po(r,a),u=r.getAttribute("position"),d=e.point.clone().applyMatrix4(i.clone().invert()),p=[o.a,o.b,o.c],x=p[0],b=1/0;for(let P of p){let V=new G(u.getX(P),u.getY(P),u.getZ(P)).distanceTo(d);V<b&&(b=V,x=P)}let S=l[x],w=m[S].clone().applyMatrix4(i),g=go(f,S,t),A=[];for(let P of g.keys())A.push(m[P].clone().applyMatrix4(i));if(A.length<6)return{error:"Not enough surface detail near this point to trace a loop. Try a different spot."};let j=ho(w,c,A);return Yt(r,i,a,e.point.clone(),j)}function hi(e,t=new G(0,1,0)){let n=Zt(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,a=t.clone().normalize();return a.lengthSq()===0?{error:"Couldn't determine a horizontal direction."}:Yt(o,r,i,e.point.clone(),a)}function Jt(e){if(!(e.object instanceof tt)||!e.face)return null;let t=e.object,n=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let o=new qt;t.getMatrixAt(e.instanceId,o),n.multiply(o)}return[e.face.a,e.face.b,e.face.c].map(o=>t.getVertexPosition(o,new G).applyMatrix4(n))}function yi(e){if(!(e.object instanceof tt))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 Si(e,t,n,o,r,i=12){let a=Jt(e),s=a?a[1].clone().sub(a[0]).cross(a[2].clone().sub(a[0])).normalize():null,c={position:e.point.toArray(),...s&&s.lengthSq()>0?{normal:s.toArray()}:{},...a?{faceVertices:a.map(u=>u.toArray())}:{}};if(!a||r==="none")return c;let l=u=>{let d=new mo(u.x,u.y,u.z,1).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);return d.w<=0||d.z/d.w<-1||d.z/d.w>1?null:{screen:new Gt((d.x/d.w+1)*o.width/2,(1-d.y/d.w)*o.height/2),w:d.w}},m=a.map(l),f=i;if((r==="vertex"||r==="auto")&&(m.forEach((u,d)=>{let p=u?.screen.distanceTo(n)??1/0;p<=f&&(f=p,c.position=a[d].toArray(),c.snapped="vertex")}),c.snapped))return c;if(r==="edge"||r==="auto")for(let u=0;u<3;u+=1){let d=(u+1)%3,p=m[u],x=m[d];if(!p||!x)continue;let b=x.screen.clone().sub(p.screen);if(b.lengthSq()===0)continue;let S=Math.max(0,Math.min(1,n.clone().sub(p.screen).dot(b)/b.lengthSq())),w=p.screen.clone().addScaledVector(b,S).distanceTo(n);if(w<=f){f=w;let g=S*p.w/((1-S)*x.w+S*p.w);c.position=a[u].clone().lerp(a[d],g).toArray(),c.snapped="edge"}}return c}var wo=["m","cm","mm","in","ft"],ot={m:1,cm:.01,mm:.001,in:.0254,ft:.3048},Ao=["distance","angle","area","pointToPlane","wrap","wrapHorizontal"];function rt(e){return wo.includes(e)}function Co(e={},t="m"){let n=e.displayUnit??t,o=e.metersPerUnit??ot[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:rt(n)?o/ot[n]:1}}function Ai(e){try{return new URL(e,typeof window<"u"?window.location?.href:void 0).href}catch{return e}}function Ci(e,t,n,o={}){if(!rt(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*ot[n]/e;if(!Number.isFinite(r)||r<=0)throw new Error("Calibration scale is outside the supported range.");return{...o,metersPerUnit:r}}function Qt(e,t){let n=t.map(o=>o.position);if(e==="angle"){let o=Ht(n);return o===null?null:{value:o,dimension:0}}if(e==="area"){let o=Kt(n);return"error"in o?null:{value:o.area,dimension:2}}if(e==="pointToPlane"){let o=t.length===2?Xt(t[0],t[1].position):null;return o?{value:o.distance,dimension:1}:null}return t.length<(e==="distance"?2:3)?null:{value:nt(n,e!=="distance"),dimension:1}}function Mo(e,t={},n="m",o=e.points,r=e.approximate?"approximate":"ready"){let i=Qt(e.tool,o),{factor:a,displayUnit:s}=Co(t,n),c=r==="ready"||r==="approximate",l=c&&i?i.value*a**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"?`${s}\xB2`:s}}function xe(e){function t(){throw new Error("Invalid measurements: expected settings and valid named measurements with finite points.")}let n=s=>!!s&&typeof s=="object"&&!Array.isArray(s),o=s=>Array.isArray(s)&&s.length===3&&s.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 s of["sourceUnit","displayUnit"])e.settings[s]!==void 0&&(rt(e.settings[s])||t(),r[s]=e.settings[s]);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,a=e.items.map(s=>{(!n(s)||typeof s.id!="string"||!s.id||i.has(s.id)||typeof s.name!="string"||!s.name.trim()||typeof s.modelId!="string"||!s.modelId||!Ao.includes(s.tool)||!Array.isArray(s.points)||s.points.length>8192||typeof s.createdAt!="string"||!Number.isFinite(Date.parse(s.createdAt)))&&t(),i.add(s.id),s.tilesetUrl!==void 0&&s.tilesetUrl!==null&&typeof s.tilesetUrl!="string"&&t(),(s.visible!==void 0&&typeof s.visible!="boolean"||s.approximate!==void 0&&typeof s.approximate!="boolean")&&t();let c=new Set,l=s.points.map(f=>{if((!n(f)||typeof f.id!="number"||!Number.isFinite(f.id)||!o(f.position))&&t(),c.has(f.id)&&t(),c.add(f.id),f.normal!==void 0&&!o(f.normal)&&t(),f.faceVertices!==void 0&&(!Array.isArray(f.faceVertices)||f.faceVertices.length!==3||!f.faceVertices.every(o))&&t(),f.snapped!==void 0&&!["vertex","edge"].includes(f.snapped)&&t(),f.anchor!==void 0){let d=f.anchor;(!n(d)||typeof d.nodeId!="string"||!d.nodeId||!o(d.localPosition)||typeof d.geometrySignature!="string"||typeof d.poseSignature!="string")&&t(),d.localNormal!==void 0&&!o(d.localNormal)&&t(),d.localFaceVertices!==void 0&&(!Array.isArray(d.localFaceVertices)||d.localFaceVertices.length!==3||!d.localFaceVertices.every(o))&&t(),d.instanceId!==void 0&&(!Number.isInteger(d.instanceId)||d.instanceId<0)&&t()}let u=f.anchor;return{id:f.id,position:[...f.position],...f.normal?{normal:[...f.normal]}:{},...f.faceVertices?{faceVertices:f.faceVertices.map(d=>[...d])}:{},...f.snapped?{snapped:f.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(d=>[...d])}:{},...u.instanceId!==void 0?{instanceId:u.instanceId}:{}}}:{}}}),m={id:s.id,name:s.name,modelId:s.modelId,tool:s.tool,points:l,createdAt:s.createdAt,...s.tilesetUrl!==void 0?{tilesetUrl:s.tilesetUrl}:{},...s.visible!==void 0?{visible:s.visible}:{},...s.approximate!==void 0?{approximate:s.approximate}:{}};return Qt(m.tool,l)||t(),m});return{settings:r,items:a}}function Mi(e){return JSON.stringify({version:1,...xe(e)},null,2)}function ji(e,t,n="m"){let o=xe(e),r=new Map(t?.map(a=>[a.id,a])),i=a=>{let s=String(a??"");return/^[=+@-]/.test(s)&&(s=`'${s}`),`"${s.replace(/"/g,'""')}"`};return[["id","name","modelId","type","status","value","unit","createdAt"],...o.items.map(a=>{let s=r.get(a.id)??Mo(a,o.settings,n);return[a.id,a.name,a.modelId,a.tool,s.status,s.value,s.unit,a.createdAt]})].map(a=>a.map(i).join(",")).join(`\r
2
- `)}function en(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 tn,Color as nn,ImageLoader as jo,NoColorSpace as Pe,RepeatWrapping as Be,SRGBColorSpace as lt,Texture as vo}from"three";var ie=new Map,at={color:"#93c5fd",intensity:.07},Ti=new nn(at.color).multiplyScalar(at.intensity),Ii=new nn(at.color),Ri=.28,pe=new Map,ct=new Map;function ko(e){return`${e.name}|${e.size}|${e.lastModified}`}function Ei(e){let t=ko(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}`,a=2;for(;;){let s=ct.get(i);if(s===void 0||s===t)return ct.set(i,t),i;i=`materials/${o}-${a}${r}`,a+=1}}function Ve(e){return pe.get(e)}function on(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 jo().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 rn(e,t){for(let n of[lt,Pe]){let o=ie.get(we(e,n));o&&on(o,t)}}function Bi(e,t){let n=pe.get(e);n&&n!==t&&n.startsWith("blob:")&&URL.revokeObjectURL(n),pe.set(e,t),rn(e,t)}function Pi(e){let t=pe.get(e);t&&(t.startsWith("blob:")&&URL.revokeObjectURL(t),pe.delete(e),ct.delete(e),rn(e,e))}function we(e,t){return`${t}|${e}`}function Oo(e,t=Pe,n){let o=we(e,t),r=ie.get(o);if(r)return n&&!r.loaded&&r.pending.push(n),r.texture;let i=pe.get(e)??e,a={texture:new vo,refCount:0,loaded:!1,pending:n?[n]:[],loadGeneration:0};return a.texture.flipY=!1,a.texture.colorSpace=t,ie.set(o,a),on(a,i),a.texture}function Vi(e,t=Pe,n){let o=Oo(e,t,n);return ie.get(we(e,t)).refCount+=1,o}function Ni(e,t=Pe){let n=ie.get(we(e,t));n&&(n.refCount-=1,n.refCount<=0&&(n.loadGeneration+=1,n.pending=[],n.texture.dispose(),ie.delete(we(e,t))))}function zi(e,t,n,o,r,i=1,a=0){let s=e.offsetTextures??(e.offsetTextures={}),c=s[t],l=c;if(!l||l.sourcePath!==o||l.base!==n){c?.texture.dispose();let f=n.clone();f.wrapS=Be,f.wrapT=Be,f.center.set(.5,.5),f.needsUpdate=!0,l={texture:f,sourcePath:o,base:n},s[t]=l}let m=i>0?i:1;return l.texture.offset.set(r[0],r[1]),l.texture.repeat.set(1/m,1/m),l.texture.rotation=a,l.texture}function Di(e,t){let n=e.offsetTextures,o=n?.[t];o&&(o.texture.dispose(),delete n[t])}function $i(e){let t=e.offsetTextures;if(t){for(let n of Object.values(t))n.texture.dispose();delete e.offsetTextures}}var it=null;function Li(){if(it)return it;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 tn(t);return r.colorSpace=lt,it=r,r}var st=null;function Ui(){if(st)return st;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 s=0;s<t;s+=1)for(let c=0;c<t;c+=1){let l=c*n,m=s*n,f=(Math.floor(c/2)+Math.floor(s/2))%4;i.fillStyle=o[f],i.fillRect(l,m,n,n),i.strokeStyle="rgba(0, 0, 0, 0.28)",i.lineWidth=2;for(let w=1;w<4;w+=1){let g=w*n/4;i.beginPath(),i.moveTo(l+g,m),i.lineTo(l+g,m+n),i.moveTo(l,m+g),i.lineTo(l+n,m+g),i.stroke()}i.strokeStyle="#09090b",i.lineWidth=7,i.strokeRect(l,m,n,n);let u=l+n*.23,d=m+n*.72,p=l+n*.72,x=m+n*.23;i.lineCap="round",i.lineJoin="round",i.beginPath(),i.moveTo(u,d),i.lineTo(p,x),i.lineTo(p-n*.2,x),i.moveTo(p,x),i.lineTo(p,x+n*.2),i.stroke();let b=s*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 S=String(b).padStart(2,"0");i.strokeText(S,l+n/2,m+n*.82),i.fillText(S,l+n/2,m+n*.82)}let a=new tn(r);return a.colorSpace=lt,a.wrapS=Be,a.wrapT=Be,a.flipY=!1,a.anisotropy=8,a.needsUpdate=!0,st=a,a}function sn(e){for(let t of ie.values())if(t.texture.source===e.source&&(!t.loaded||t.failed))return!0;return!1}var se=5*1024*1024,To=["activeModelId","modelUrl","modelFormat","tilesetUrl","models","mergeModels","sceneConfig","isolation","multiSelectedKeys","activeAnnotation","annotationCategories","backgroundColor","shadows","cinematic","cameraControllerType","objectTransformSpace","arScaleMode","usdzUrl","measurements","measurementSettings","measurementUnit","measurementModelId"];function I(e,t){throw new Error(`Invalid viewer state at ${e}: ${t}`)}function H(e,t){(!e||typeof e!="object"||Array.isArray(e))&&I(t,"expected an object.")}function Ae(e,t){(!Array.isArray(e)||!e.every(n=>typeof n=="string"))&&I(t,"expected strings.")}function Q(e,t,n){(!Array.isArray(e)||e.length!==t||!e.every(o=>typeof o=="number"&&Number.isFinite(o)))&&I(n,`expected ${t} finite numbers.`)}function Io(e){let t=new Set,n=0;function o(r,i,a){if((++n>2e5||a>64)&&I(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)&&I(i,"expected JSON data (finite numbers, no functions)."),t.has(r)&&I(i,"cyclic data."),!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null&&I(i,"expected plain JSON data."),t.add(r);let s=Array.isArray(r)?[]:{};for(let[c,l]of Object.entries(r))["__proto__","constructor","prototype"].includes(c)&&I(`${i}.${c}`,"reserved property."),l!==void 0?s[c]=o(l,`${i}.${c}`,a+1):Array.isArray(r)&&I(i,"undefined array entry.");return t.delete(r),s}return o(e,"state",0)}function te(e,t,n,o,r=!1,i){let a=e[t];if(a==null||a==="")return;typeof a!="string"&&I(n,"expected a URL.");let s=r?Ve(a)??a:a;if(s.trim().startsWith("blob:")){if(r&&i){i.set(a,{source:s,path:n});return}I(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(s!==a&&(a=s,e[t]=s),r&&/^data:image\//i.test(a))return;let c;try{c=new URL(a,o??"https://relative.invalid/")}catch{I(n,"invalid asset URL.")}["http:","https:"].includes(c.protocol)||I(n,"use an HTTP(S) asset URL."),o&&(e[t]=c.href)}function Ro(e,t){H(e,t),Q(e.position,3,`${t}.position`),Q(e.target,3,`${t}.target`),(typeof e.zoom!="number"||e.zoom<=0)&&I(t,"zoom must be positive."),e.fov!==null&&(typeof e.fov!="number"||e.fov<=0||e.fov>=180)&&I(t,"fov must be null or between 0 and 180.");for(let n of["azimuthAngle","polarAngle"])e[n]!==void 0&&typeof e[n]!="number"&&I(t,`${n} must be a number.`)}function ln(e,t,n,o){H(e,t),(typeof e.id!="number"||typeof e.title!="string"||typeof e.description!="string")&&I(t,"expected an annotation id, title and description.");for(let r of["worldPosition","localPosition"])Q(e[r],3,`${t}.${r}`);e.images!==void 0&&(Array.isArray(e.images)||I(t,"images must be an array."),e.images.forEach(r=>{H(r,t),te(r,"src",t,n,!0,o)})),e.links!==void 0&&(Array.isArray(e.links)||I(t,"links must be an array."),e.links.forEach(r=>{H(r,t),te(r,"href",t,n,!1,o)}))}function un(e,t){H(e,t),e.waypoints!==void 0&&(Array.isArray(e.waypoints)||I(t,"expected waypoints."),e.waypoints.forEach(n=>{H(n,t),Q(n.position,3,t),Q(n.target,3,t)}));for(let n of["enabled","loop","autoPlay"])e[n]!==void 0&&typeof e[n]!="boolean"&&I(t,`${n} must be boolean.`);e.duration!==void 0&&(typeof e.duration!="number"||e.duration<=0)&&I(t,"duration must be positive.")}function ut(e,t,n){if(t!==null)if(Array.isArray(t))Array.isArray(e)||I(n,"expected an array."),t.length&&e.forEach(o=>ut(o,t[0],n));else if(typeof t=="object"){H(e,n);for(let[o,r]of Object.entries(t))ut(e[o],r,`${n}.${o}`)}else typeof e!=typeof t&&I(n,`expected ${typeof t}.`)}function an(e,t,n,o){if(ut(e,fe,t),e.measurements!==void 0&&(e.measurements=xe(e.measurements)),e.sequences!==void 0&&(e.sequences=je(e.sequences)),e.selectionSets!==void 0&&(e.selectionSets=en(e.selectionSets)),e.product!==void 0&&(e.product=Et(e.product),e.product.definition.groups.forEach(r=>r.options.forEach(i=>i.appearance?.forEach(a=>{for(let[s,c]of Object.entries(a.material??{}))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&te(c,"path",`${t}.product.material.${s}.path`,n,!0,o)})))),Q(e.model.rotation,3,`${t}.model.rotation`),e.lighting.lights.forEach(r=>Q(r.position,3,`${t}.lighting.lights`)),e.annotations.forEach(r=>ln(r,`${t}.annotations`,n,o)),e.animations.autoplayClip!==null&&typeof e.animations.autoplayClip!="string"&&I(t,"invalid autoplay clip."),e.animations.clips.forEach(r=>{H(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))&&I(t,"invalid animation clip settings.")}),e.cinematic!==void 0&&un(e.cinematic,`${t}.cinematic`),e.styleRules!==void 0&&!Array.isArray(e.styleRules)&&I(t,"styleRules must be an array."),te(e.environment,"customEnvironmentUrl",`${t}.environment`,n,!1,o),te(e.background,"imageUrl",`${t}.background`,n,!0,o),e.model.activeVariants!==void 0&&Ae(e.model.activeVariants,t),e.section!==void 0)try{e.section=ye(e.section)}catch(r){I(`${t}.section`,r.message)}}function dn(e,t,n,o){H(e,t);for(let[r,i]of Object.entries(e)){let a=`${t}.${r}`;H(i,a),(typeof i.id!="string"||typeof i.modelObjectId!="string")&&I(a,"expected binding id and modelObjectId.");for(let s of["label","group","type","status"])i[s]!==void 0&&typeof i[s]!="string"&&I(a,`${s} must be a string.`);i.tags!==void 0&&Ae(i.tags,a),i.metadata!==void 0&&H(i.metadata,`${a}.metadata`),i.metrics!==void 0&&(H(i.metrics,a),Object.values(i.metrics).some(s=>typeof s!="number")&&I(a,"metrics must be numbers.")),i.actions!==void 0&&(Array.isArray(i.actions)||I(a,"actions must be an array."),i.actions.forEach(s=>{H(s,a),(typeof s.id!="string"||typeof s.label!="string"||s.type!=="command"||s.effects!==void 0&&!Array.isArray(s.effects))&&I(a,"invalid action.")}));for(let s of["visible","removed","selectable","hoverable"])i[s]!==void 0&&typeof i[s]!="boolean"&&I(a,`${s} must be boolean.`);if(i.transform!==void 0){H(i.transform,a);for(let s of["position","rotation","scale","shear"])i.transform[s]!==void 0&&Q(i.transform[s],3,`${a}.transform.${s}`);i.transform.pivot!==void 0&&(H(i.transform.pivot,a),Q(i.transform.pivot.point,3,a),Q(i.transform.pivot.offset,3,a))}if(i.style!==void 0&&(H(i.style,a),i.style.material!==void 0)){H(i.style.material,a);for(let[s,c]of Object.entries(i.style.material))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&te(c,"path",`${a}.style.material.${s}.path`,n,!0,o)}i.decals!==void 0&&(Array.isArray(i.decals)||I(a,"decals must be an array."),i.decals.forEach(s=>{H(s,a),(typeof s.id!="string"||typeof s.size!="number"||s.size<=0)&&I(a,"invalid decal."),Q(s.position,3,a),Q(s.normal,3,a),te(s,"image",a,n,!0,o)}))}}function cn(e,t,n,o){Array.isArray(e)||I(t,"expected merge sources."),e.forEach(r=>{H(r,t),(typeof r.url!="string"||!r.url||typeof r.namePrefix!="string")&&I(t,"expected source URL and prefix."),te(r,"url",t,n,!1,o)})}function Eo(e,t,n){H(e,"configuration");let o=Object.fromEntries(To.filter(r=>e[r]!==void 0).map(r=>[r,e[r]]));(typeof o.modelUrl!="string"||!o.modelUrl)&&I("configuration.modelUrl","expected the active model URL.");for(let r of["modelUrl","tilesetUrl","usdzUrl"])te(o,r,`configuration.${r}`,t,!1,n);if(o.sceneConfig!==void 0&&an(o.sceneConfig,"configuration.sceneConfig",t,n),o.mergeModels!==void 0&&cn(o.mergeModels,"configuration.mergeModels",t,n),o.models!==void 0){(!Array.isArray(o.models)||o.models.length===0)&&I("configuration.models","expected model entries.");let r=new Set,i=new Set;o.models.forEach(a=>{H(a,"model"),(typeof a.url!="string"||!a.url)&&I("model.url","expected a URL."),te(a,"url","model.url",t,!1,n),a.id!==void 0&&(typeof a.id!="string"||!a.id.trim())&&I("model.id","expected a nonempty instance ID.");let s=et({id:a.id,url:a.url});i.has(s)&&I("configuration.models","instance identities must be unique; assign IDs when reusing a URL."),i.add(s),a.transform!==void 0&&(a.transform=Se(a.transform)),a.visible!==void 0&&typeof a.visible!="boolean"&&I("model.visible","expected boolean."),r.add(a.url),dn(a.objectBindings,"model.objectBindings",t,n),a.sceneConfig!==void 0&&an(a.sceneConfig,"model.sceneConfig",t,n),a.mergeModels!==void 0&&cn(a.mergeModels,"model.mergeModels",t,n)}),o.activeModelId!==void 0&&(typeof o.activeModelId!="string"||!i.has(o.activeModelId))&&I("configuration.activeModelId","active instance is not in models."),o.activeModelId!==void 0&&o.models.find(a=>et(a)===o.activeModelId)?.url!==o.modelUrl&&I("configuration.modelUrl","source does not match the active instance."),r.has(o.modelUrl)||I("configuration.modelUrl","active model is not in models.")}if(o.multiSelectedKeys!==void 0&&Ae(o.multiSelectedKeys,"configuration.multiSelectedKeys"),o.annotationCategories!==void 0&&o.annotationCategories!==null&&Ae(o.annotationCategories,"configuration.annotationCategories"),o.activeAnnotation!==void 0&&o.activeAnnotation!==null&&ln(o.activeAnnotation,"configuration.activeAnnotation",t,n),o.measurements!==void 0||o.measurementSettings!==void 0){let r=xe({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"&&I("configuration.measurementModelId","expected a stable id."),o.measurementUnit!==void 0&&typeof o.measurementUnit!="string"&&I("configuration.measurementUnit","expected a unit label.");for(let r of["backgroundColor"])o[r]!==void 0&&typeof o[r]!="string"&&I(r,"expected a string.");o.shadows!==void 0&&typeof o.shadows!="boolean"&&I("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])&&I(r,"unsupported value.");if(o.cinematic!==void 0&&un(o.cinematic,"cinematic"),o.isolation!==void 0&&o.isolation!==null){let{target:r,mode:i,ghostOpacity:a}=o.isolation;typeof r=="string"||Array.isArray(r)&&r.every(s=>typeof s=="string")||r&&typeof r=="object"&&["group","tag","type"].some(s=>typeof r[s]=="string")||I("configuration.isolation","invalid target."),i!==void 0&&!["ghost","hide"].includes(i)&&I("configuration.isolation","invalid mode."),a!==void 0&&(typeof a!="number"||a<0||a>1)&&I("configuration.isolation","opacity must be between 0 and 1.")}return o}function mn(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)?te(e,r,`${t}.${r}`,n,["path","image","src","imageUrl"].includes(r),o):mn(i,`${t}.${r}`,n,o))}function fn(e,t,n){typeof e=="string"&&(new TextEncoder().encode(e).length>se&&I("state","exceeds the 5 MiB limit."),e=JSON.parse(e));let o=Io(e);H(o,"state"),new TextEncoder().encode(JSON.stringify(o)).length>se&&I("state","exceeds the 5 MiB limit."),o.version!==void 0&&o.version!==1&&I("version","unsupported version."),o.version===void 0&&(o.objectBindings!==void 0||o.configuration!==void 0)&&I("version","full configurations require version 1.");let r={};return o.version!==void 0&&(r.version=1),o.camera!==void 0&&(Ro(o.camera,"camera"),r.camera=o.camera),o.hidden!==void 0&&(Ae(o.hidden,"hidden"),r.hidden=o.hidden),o.selected!==void 0&&(o.selected!==null&&typeof o.selected!="string"&&I("selected","expected an object id or null."),r.selected=o.selected),o.objectBindings!==void 0&&(dn(o.objectBindings,"objectBindings",t,n),r.objectBindings=o.objectBindings),o.configuration!==void 0&&(r.configuration=Eo(o.configuration,t,n)),mn(r,"state",t,n),new TextEncoder().encode(JSON.stringify(r)).length>se&&I("state","exceeds the 5 MiB limit."),r}function Zi(e,t){return JSON.stringify(Ne(e,t))}function Ne(e,t){return fn(e,t)}async function pn(e,t){let n=new Map,o=fn(e,t,n),r=new Map,i=new Map;for(let[s,{source:c,path:l}]of n){let m=r.get(c);m||(m=(async()=>{let f;try{f=await fetch(c)}catch{I(l,"this temporary image is no longer available. Reload or reselect it before saving.")}f.ok||I(l,"could not read the temporary image. Reload or reselect it before saving.");let u=await f.blob();u.size>se*3/4&&I(l,"embedded image exceeds the 5 MiB configuration limit. Use a hosted image URL.");let d=new Uint8Array(await u.arrayBuffer()),p=u.type.split(";")[0].toLowerCase(),x=p.startsWith("image/")?p:Bo(d);x||I(l,"temporary asset is not a supported image. Use a hosted asset URL.");let b="";for(let S=0;S<d.length;S+=32768)b+=String.fromCharCode(...d.subarray(S,S+32768));return`data:${x};base64,${btoa(b)}`})(),r.set(c,m)),i.set(s,await m)}function a(s){if(!(!s||typeof s!="object"))for(let[c,l]of Object.entries(s))c!=="metadata"&&(["path","image","src","imageUrl"].includes(c)&&typeof l=="string"&&i.has(l)?s[c]=i.get(l):a(l))}return a(o),Ne(o,t)}function Bo(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 Po,strToU8 as gn,unzlibSync as Vo,zlibSync as No}from"fflate";var ze="ri-ar",De="ri-ar-id",bn=4096,zo=2200,Do=gn(JSON.stringify(fe)).byteLength;function hn(e){return e==="localhost"||e.endsWith(".localhost")||/^127\./.test(e)||e==="[::1]"||e==="0.0.0.0"}function yn(e){if(typeof e=="string"&&/^https?:\/\//i.test(e)&&hn(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))yn(t)}function os(e){return e&&typeof e=="object"?e:void 0}function rs(e){let t=new URLSearchParams(new URL(e,"https://viewer.invalid/").hash.slice(1));return t.has(ze)||t.has(De)}function $o(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 is(e,t="",n=2048){let o=new Set,r=i=>{if(typeof i=="string")return Ve(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 a=Array.isArray(i)?i.map(r):Object.fromEntries(Object.keys(i).sort().map(s=>[s,r(i[s])]));return o.delete(i),a};return JSON.stringify([t,n,r({...e,camera:void 0})])}function Sn(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,Sn(o,t[n])]).filter(([,n])=>n!==void 0)):e}function xn(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)?xn(o[i],r[i],n+1):r[i]]))}return e}function wn(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 Ce(e){e?.throwIfAborted()}async function ss(e,t,n,o){Ce(o);let r=new URL($o(t));if(hn(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 pn(e,r.toString());Ce(o),yn(i);let a=new URLSearchParams(r.hash.slice(1));if(a.delete(ze),a.delete(De),a.delete("view"),a.delete("viewId"),a.delete("view-id"),n){let s=await n.save(i);if(Ce(o),typeof s!="string"||!s||s.length>512)throw new Error("AR storage returned an invalid configuration ID.");a.set(De,s)}else{let s=No(gn(JSON.stringify({ar:1,state:wn(i,l=>Sn(l,fe)??{})})),{level:9});if(s.byteLength>bn)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 s)c+=String.fromCharCode(l);a.set(ze,btoa(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""))}if(r.hash=a.toString(),r.toString().length>zo)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 as(e,t,n){let o=new URL(e),r=new URLSearchParams(o.hash.slice(1)),i=r.get(De),a=r.get(ze);if(i!==null&&a!==null)throw new Error("AR link contains conflicting configurations.");if(i===null&&a===null)return null;Ce(n);let s;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.");s=await t.load(i)}else{if(!a||a.length>Math.ceil(bn*4/3)||!/^[\w-]+$/.test(a))throw new Error("Invalid or oversized AR link.");let l=atob(a.replace(/-/g,"+").replace(/_/g,"/")),m=Uint8Array.from(l,d=>d.charCodeAt(0)),f=Vo(m);if(f.byteLength>se)throw new Error("AR configuration exceeds the 5 MiB limit.");let u=JSON.parse(Po(f));if(u?.ar===1&&u.state){let d=u.state.configuration,p=(d?.sceneConfig?1:0)+(Array.isArray(d?.models)?d.models.filter(x=>x?.sceneConfig).length:0);if(f.byteLength+p*Do>se)throw new Error("Expanded AR configuration exceeds the 5 MiB limit.");s=wn(u.state,x=>xn(x,fe))}else s=u}Ce(n);let c=Ne(s,o.toString());if(c.version!==1||!c.configuration)throw new Error("AR handoff requires a complete versioned viewer configuration.");return c}var dt=new WeakMap;function ls(e,t){t?dt.set(e,t):dt.delete(e)}function An(e){e.traverse(t=>{let n=dt.get(t);if(n)throw new Error(n)})}import{Box3 as lr,BufferAttribute as Le,BufferGeometry as Wn,Color as ur,DoubleSide as dr,FrontSide as At,Group as qn,Matrix4 as mr,Mesh as fr,Vector3 as Ue}from"three";import{PropertyBinding as mt}from"three";var ft=Symbol("react-immersive.model-node-id");function Lo(e,t){Object.defineProperty(e,ft,{value:t,configurable:!0})}function ae(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)),a=new Set,s=(c,l)=>{Lo(c,l),n[l]=c,o.set(c,l),a.add(l)};for(let[c,l]of t)l.length===1&&s(l[0],c);for(let[c,l]of t){if(l.length<2)continue;let m=[];l.forEach((f,u)=>{let d=`${c} [${u+1}]`,p=d,x=2;for(;i.has(p)||a.has(p);)p=`${d}.${x++}`;s(f,p),m.push(p)}),r.set(c,m)}return{nodesById:n,idByNode:o,duplicateNames:r}}function Me(e){return e[ft]??e.name??null}function ms(e,t){let n=t.replace(/\.[^./\\]+$/,"");e.traverse(o=>{o.name&&(o.name=mt.sanitizeNodeName(`${n}_${o.name}`))})}function fs(e,t){let n=t.replace(/\.[^./\\]+$/,""),o=e.clone();for(let r of o.tracks){let a=mt.parseTrackName(r.name).nodeName??"",s=mt.sanitizeNodeName(`${n}_${a}`);r.name=s+r.name.slice(a.length)}return o}function Cn(e,t){let n=null,o=[];return e.traverse(r=>{r[ft]===t&&(n=r),r.name===t&&o.push(r)}),n??(o.length===1?o[0]:null)}import{AnimationClip as Jo,Group as Qo,Matrix4 as er,Vector3 as tr,PropertyBinding as Ln}from"three";import{clone as nr}from"three/examples/jsm/utils/SkeletonUtils.js";import{strFromU8 as or,strToU8 as wt,unzipSync as rr,zipSync as ir}from"fflate";import{AnimationMixer as Uo,LoopOnce as _o,LoopPingPong as Mn,LoopRepeat as Fo}from"three";function jn(e){let t=e._loopCount;return e.loop===Mn&&(t&1)===1}function Wo(e){return jn(e)?e.getClip().duration-e.time:e.time}function vn({root:e,clips:t,getClipConfig:n,onChange:o}){let r=new Uo(e),i=new Map;for(let{clip:h,sourceName:M}of t)i.set(M,r.clipAction(h));let a=new Map,s=new Set,c=new Map,l=1,m=h=>typeof h=="string",f=h=>m(h)?a.has(h)?[h]:[]:[...a.keys()],u=(h,M)=>{let k=Pt(n(M));k==="once"?h.setLoop(_o,1):k==="ping-pong"?h.setLoop(Mn,1/0):h.setLoop(Fo,1/0),h.clampWhenFinished=k==="once"},d=h=>{h.action.setEffectiveTimeScale(h.reverse?-h.speed:h.speed)},p=h=>{let M=a.get(h);M&&(M.action.stop(),a.delete(h))},x=(h,M={})=>{let k=i.get(h);if(!k||n(h)?.hidden)return;let E=Number.isFinite(M.fade)&&M.fade>0?M.fade:0,N=M.reverse??!1;if(!M.alongside)for(let[B,W]of[...a])B!==h&&(E>0?(a.delete(B),W.action.fadeOut(E),s.add(W.action)):p(B));s.delete(k)&&k.stop();let y=k.getClip().duration,C=a.get(h),v=()=>{k.reset(),N&&(k.time=y),k.play()};if(!C)v(),E>0&&k.fadeIn(E);else{let B=N?k.time<=0:k.time>=y;C.finished&&B&&v(),k.paused=!1,k.enabled=!0,a.delete(h)}u(k,h),C={action:k,speed:n(h)?.speed??c.get(h)??l,reverse:N,finished:!1},C.speed=Te(C.speed),d(C),a.set(h,C),o()},b=h=>{for(let M of f(h))a.get(M).action.paused=!0;o()},S=h=>{for(let M of f(h))p(M);if(!m(h)){for(let M of s)M.stop();s.clear()}o()},w=(h,M)=>{let k=Te(h);m(M)?c.set(M,k):l=k;for(let E of f(M)){let N=a.get(E);c.set(E,k),N.speed=k,d(N)}o()},g=(h,M)=>{for(let k of f(M)){let E=a.get(k),N=E.action.getClip().duration,y=Math.min(Math.max(h,0),N);E.action.time=jn(E.action)?N-y:y,E.finished&&(E.finished=!1,E.action.paused=!0)}r.update(0),o()},A=()=>{for(let[h,M]of[...a]){let k=n(h);if(k?.hidden){p(h);continue}u(M.action,h),k?.speed!==void 0&&(M.speed=Te(k.speed),d(M))}o()},j=h=>{for(let M of a.values())M.action===h.action&&(M.finished=!0);o()};return r.addEventListener("finished",j),{play:x,pause:b,stop:S,setSpeed:w,seek:g,getState:()=>{let h=[...a].map(([k,E])=>({clip:k,status:E.finished?"finished":E.action.paused?"paused":"playing",time:Wo(E.action),duration:E.action.getClip().duration,speed:E.speed,reverse:E.reverse})),M=h[h.length-1];return{currentClip:M?.clip??null,isPlaying:h.some(k=>k.status==="playing"),speed:M?.speed??l,time:M?.time??0,duration:M?.duration??0,active:h}},applyClipConfigs:A,isRunning:()=>{if(s.size>0)return!0;for(let{action:h}of a.values())if(!h.paused&&h.enabled)return!0;return!1},update:h=>{r.update(h);for(let M of s)(!M.enabled||M.getEffectiveWeight()<=0)&&(M.stop(),s.delete(M))},dispose:()=>{r.removeEventListener("finished",j),r.stopAllAction(),r.uncacheRoot(e),a.clear(),s.clear()}}}import{Color as Tn}from"three";import{Matrix4 as kn,Quaternion as qo,Vector3 as $e}from"three";function Go(e){return new kn().set(1,e[0],e[1],0,0,1,e[2],0,0,0,1,0,0,0,0,1)}function pt(e,t){e.matrixAutoUpdate=!t,e.updateMatrix(),t&&(e.matrix.makeRotationFromQuaternion(e.quaternion).multiply(Go(t)).scale(e.scale).setPosition(e.position),e.matrixWorldNeedsUpdate=!0)}function On(e,t,n){let o=new $e().setFromMatrixColumn(e,0),r=new $e().setFromMatrixColumn(e,1),i=new $e().setFromMatrixColumn(e,2),a=(p,x)=>{let b=p*(x<0?-1:1);return Math.abs(b-x)<1e-10?x:b},s=a(o.length(),t.x);if(Math.abs(s)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};o.divideScalar(s);let c=o.dot(r);r.addScaledVector(o,-c);let l=a(r.length(),t.y);if(Math.abs(l)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};r.divideScalar(l);let m=o.dot(i);i.addScaledVector(o,-m);let f=r.dot(i);i.addScaledVector(r,-f);let u=a(i.length(),t.z);if(Math.abs(u)<1e-12)return{rotation:n.clone(),scale:t.clone(),shear:void 0};i.divideScalar(u);let d=[c/l,m/u,f/u].map(p=>Math.abs(p)<1e-10?0:p);return{rotation:new qo().setFromRotationMatrix(new kn().makeBasis(o,r,i)).normalize(),scale:new $e(s,l,u),shear:d.some(Boolean)?d:void 0}}var gt=e=>e==="baseColor"?"color":e;function In(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 Rn({root:e,controls:t,animations:n,invalidate:o,cameraEnabled:r=()=>!0}){let i=new Map,a=new Map,s=new Map,c=new Set,l=new Map,m=null,f="",u=g=>e()?Cn(e(),g):null,d=g=>{if(g.kind==="camera"){let V=t();if(!V)return null;let O=ne(V.camera,V);return{position:O.position,target:O.target,fov:O.fov,zoom:O.zoom}}if(g.kind==="clip"){let V=n();return V?.clips.includes(g.clip)?V.getState?.().active.find(O=>O.clip===g.clip)?.time??0:null}let A=u(g.objectId);if(!A)return null;let j=g.property;if(j==="position"||j==="rotation"||j==="scale")return[A[j].x,A[j].y,A[j].z];if(j==="visible")return A.visible;let P=In(A).find(V=>V[gt(j)]!==void 0),R=P?P[gt(j)]:void 0;return R?.isColor?`#${R.getHexString()}`:typeof R=="number"?R:null},p=g=>{if(!r())return;let A=t();A&&(A.stop(),A.setLookAt(...g.position,...g.target,!1),g.fov!==null&&"fov"in A.camera&&(A.camera.fov=g.fov,A.camera.updateProjectionMatrix()),A.zoomTo(g.zoom,!1),A.update(0))},x=g=>{if(i.has(g))return;g.updateWorldMatrix(!0,!0);let A=g.matrixAutoUpdate?void 0:On(g.matrix,g.scale,g.quaternion).shear;i.set(g,{position:g.position.toArray(),rotation:[g.rotation.x,g.rotation.y,g.rotation.z],scale:g.scale.toArray(),matrix:g.matrix.clone(),auto:g.matrixAutoUpdate,shear:A});for(let j of kt(g))Ot(j)||(ve(j,j.matrixWorld),c.add(j))},b=(g,A)=>{let j=n();j?.stop(g),A&&j&&(j.play(g,{alongside:!0,reverse:A.reverse}),j.setSpeed(A.speed,g),j.seek?.(A.time,g),A.status!=="playing"&&j.pause(g))};return{capture:d,restore:()=>{for(let[g,A]of l)b(g,A);l.clear();for(let[g,A]of i)g.position.fromArray(A.position),g.rotation.set(...A.rotation),g.scale.fromArray(A.scale),g.matrix.copy(A.matrix),g.matrixAutoUpdate=A.auto,g.matrixWorldNeedsUpdate=!0;i.clear(),a.forEach((g,A)=>A.visible=g),a.clear(),s.forEach((g,A)=>{g.forEach((j,P)=>{j instanceof Tn?A[P].copy(j):A[P]=j}),A.needsUpdate=!0}),s.clear(),c.forEach(It),c.clear(),m&&p(m),m=null,f="",e()?.updateWorldMatrix(!0,!0),o()},inspect:g=>g.tracks.filter(A=>!A.muted&&A.keyframes.length&&(A.target.kind!=="camera"||r())&&d(A.target)===null).map(A=>`Unavailable target: ${A.name}.`),invalidate:o,apply:({sequence:g,time:A,playing:j})=>{let P=g.tracks.filter(O=>O.target.kind!=="camera"||r()).map(O=>({track:O,value:Ct(O,A)})).filter(O=>O.value!==null);for(let[O,h]of l)P.some(({track:M})=>M.target.kind==="clip"&&M.target.clip===O)||(b(O,h),l.delete(O));for(let{track:O}of P)if(O.target.kind==="object"&&["position","rotation","scale"].includes(O.target.property)){let h=u(O.target.objectId);h&&x(h)}let R=new Map([...s.keys()].map(O=>[O,O.transparent]));a.forEach((O,h)=>h.visible=O),i.forEach((O,h)=>{h.position.fromArray(O.position),h.rotation.set(...O.rotation),h.scale.fromArray(O.scale),pt(h,O.shear)}),s.forEach((O,h)=>O.forEach((M,k)=>{M instanceof Tn?h[k].copy(M):h[k]=M}));let V=n();for(let{track:O,value:h}of P){if(O.target.kind!=="clip"||!V?.seek||!V.clips.includes(O.target.clip))continue;let M=O.target.clip;l.has(M)||(l.set(M,V.getState?.().active.find(k=>k.clip===M)),V.play(M,{alongside:!0}),V.pause(M)),V.seek(h,M)}for(let{track:O,value:h}of P){let M=O.target;if(M.kind==="clip")continue;if(M.kind==="camera"){m||(m=d(M));let N=JSON.stringify(h);(j||N!==f)&&(p(h),f=N);continue}let k=u(M.objectId);if(!k)continue;let E=M.property;if(E==="visible")a.has(k)||a.set(k,k.visible),k.visible=h;else if(E==="position"||E==="rotation"||E==="scale")E==="rotation"?k.rotation.set(...h):k[E].fromArray(h),pt(k,i.get(k)?.shear);else for(let N of In(k)){let y=gt(E),C=N[y];if(C===void 0)continue;let v=s.get(N);if(v||(v=new Map,s.set(N,v)),R.has(N)||R.set(N,N.transparent),v.has(y)||v.set(y,C?.isColor?C.clone():C),C?.isColor?C.set(h):N[y]=h,E==="opacity"){v.has("transparent")||v.set("transparent",N.transparent);let B=h<1||v.get("transparent")===!0;N.transparent=B}}}m&&!P.some(({track:O})=>O.target.kind==="camera")&&(p(m),f=""),R.forEach((O,h)=>{O!==h.transparent&&(h.needsUpdate=!0)}),e()?.updateWorldMatrix(!0,!0)}}}function En(e){let t=new Map;return e.map((n,o)=>{let i=n.name.trim()||`Animation ${o+1}`,a=t.get(i)??0;return t.set(i,a+1),{clip:n,sourceName:a===0?i:`${i} (${a+1})`,duration:n.duration}})}import{Box3 as bt,Group as Ho,BufferAttribute as Xo,Matrix4 as Bn,Mesh as Ko,Quaternion as Yo,Vector3 as ge}from"three";function Zo(e){let t=e.getAttribute("arSourceVertex"),n=e.getAttribute("arNormalSign");if(!t)return;let o=new Map,r=[],i=[];for(let s=0;s<t.count;s++){let c=`${t.getX(s)}:${n?.getX(s)??1}`,l=o.get(c);l===void 0&&(l=r.length,r.push(s),o.set(c,l)),i.push(l)}let a=e.index?Array.from(e.index.array,s=>i[s]):i;for(let[s,c]of Object.entries(e.attributes)){let l=new Float32Array(r.length*c.itemSize);r.forEach((m,f)=>{for(let u=0;u<c.itemSize;u++)l[f*c.itemSize+u]=c.getComponent(m,u)}),e.setAttribute(s,new Xo(l,c.itemSize))}e.setIndex(a)}function Pn(e,t,n,o){let r=[],i=[],a=new Map;for(let s of e){let c=s.source;if(!c.isSkinnedMesh)continue;let l=t.get(c),m=c.skeleton,f=JSON.stringify(m.bones.map((O,h)=>[O.uuid,m.boneInverses[h].elements])),u=a.get(f);if(!u){let O=new Map(m.bones.map((C,v)=>[C,v])),h=m.bones.map(C=>{for(let v=C.parent;v;v=v.parent)if(O.has(v))return O.get(v);return-1}),M=[],k=C=>{M.includes(C)||(h[C]>=0&&k(h[C]),M.push(C))};m.bones.forEach((C,v)=>k(v));let E=M.map(C=>M.indexOf(h[C])),N=[];M.forEach((C,v)=>N.push(`${E[v]<0?"":N[E[v]]+"/"}J_${C}`));let y={name:`${o}_${r.length}`,joints:N,parents:E,bones:M.map(C=>t.get(m.bones[C])),bindTransforms:M.map(C=>m.boneInverses[C].clone().invert()),restTransforms:[],worlds:M.map(()=>new Bn),referenceInverse:n.clone().invert(),frames:[]};if(y.bones.some(C=>!C))throw new Error("The AR skeleton has joints outside the exported scene.");u={rig:y,order:M},a.set(f,u),r.push(y)}Zo(s.exported.geometry);let d=s.exported.geometry.getAttribute("arSourceVertex"),p=c.geometry.getAttribute("skinIndex"),x=c.geometry.getAttribute("skinWeight");if(!d||!p||!x||p.itemSize!==4||x.itemSize!==4)throw new Error("AR skeletal animation needs four joint indices and weights per vertex.");let b={target:s,node:l,rig:u.rig,reference:n,geomBind:c.bindMatrix.clone(),jointIndices:[],jointWeights:[],jointBounds:u.order.map(()=>new bt),extent:new bt},S=s.exported.geometry.getAttribute("position"),w=s.exported.geometry.getAttribute("normal"),g=c.geometry.getAttribute("normal"),A=s.exported.geometry.getAttribute("arNormalSign"),j=new ge,P=new ge,R=new Map(u.order.map((O,h)=>[O,h])),V=b.rig.bindTransforms.map(O=>O.clone().invert().multiply(c.bindMatrix));for(let O=0;O<d.count;O++){let h=d.getX(O);if(Ko.prototype.getVertexPosition.call(c,h,j),S.setXYZ(O,j.x,j.y,j.z),g&&w){P.fromBufferAttribute(g,h);let k=P.clone();c.geometry.morphAttributes.normal?.forEach((E,N)=>{let y=c.morphTargetInfluences?.[N]??0;y&&P.addScaledVector(new ge().fromBufferAttribute(E,h).sub(c.geometry.morphTargetsRelative?new ge:k),y)}),P.normalize().multiplyScalar(A?.getX(O)??1),w.setXYZ(O,P.x,P.y,P.z)}let M=[0,1,2,3].reduce((k,E)=>k+x.getComponent(h,E),0);if(!Number.isFinite(M)||M<=0)throw new Error("The AR skin has a vertex without valid joint weights.");for(let k=0;k<4;k++){let E=x.getComponent(h,k)/M,N=E?R.get(p.getComponent(h,k))??-1:0;if(N<0||!Number.isFinite(E)||E<0)throw new Error("The AR skin has invalid joint indices or weights.");b.jointIndices.push(N),b.jointWeights.push(E),E&&b.jointBounds[N].expandByPoint(j.clone().applyMatrix4(V[N]))}}S.needsUpdate=!0,w?w.needsUpdate=!0:s.exported.geometry.computeVertexNormals(),s.exported.geometry.computeBoundingBox(),s.exported.matrixAutoUpdate=!1,s.exported.matrix.copy(St(b)),i.push(b)}return{rigs:r,skins:i}}function St(e){return e.node.matrixWorld.clone().multiply(e.node.bindMatrixInverse).multiply(e.reference)}function Vn(e,t,n){let o=new ge,r=new Yo,i=new ge,a=new Bn;for(let s of e){let c={time:n,translations:[],rotations:[],scales:[]};s.bones.forEach((l,m)=>s.worlds[m].multiplyMatrices(s.referenceInverse,l.matrixWorld)),s.worlds.forEach((l,m)=>{let f=s.parents[m],u=f<0?l.clone():s.worlds[f].clone().invert().multiply(l);u.decompose(o,r,i),r.normalize(),a.compose(o,r,i);let d=1e-5*Math.max(1,...u.elements.map(Math.abs));if(!u.elements.every(Number.isFinite)||u.elements.some((p,x)=>Math.abs(p-a.elements[x])>d)||Math.abs(u.determinant())<1e-15)throw new Error("The AR skeleton contains a sheared or zero-scale joint that Quick Look cannot preserve. Use arHandoff.createUSDZ for this rig.");c.translations.push(...o.toArray()),c.rotations.push(r.w,r.x,r.y,r.z),c.scales.push(...i.toArray()),s.frames.length||s.restTransforms.push(u)}),s.frames.push(c)}for(let s of t)s.jointBounds.forEach((c,l)=>{c.isEmpty()||s.extent.union(c.clone().applyMatrix4(s.rig.worlds[l]))})}var xt=e=>String(Number(e.toPrecision(9))),ht=e=>{let t=Array.isArray(e)?e:e.elements;return`(${[0,4,8,12].map(n=>`(${t.slice(n,n+4).map(xt).join(", ")})`).join(", ")})`},yt=(e,t)=>Array.from({length:e.length/t},(n,o)=>`(${e.slice(o*t,(o+1)*t).map(xt).join(", ")})`).join(", ");function Nn(e){let t=(a,s,c=1e-7)=>Math.abs(a-s)>c*Math.max(1,Math.abs(a),Math.abs(s)),n=[["translations",3,"float3"],["rotations",4,"quatf"],["scales",3,"half3"]],o=e.frames[0],r=e.joints.map((a,s)=>s).filter(a=>n.some(([s,c])=>e.frames.some(l=>l[s].slice(a*c,(a+1)*c).some((m,f)=>t(m,o[s][a*c+f])))));r.length||(r=e.joints.map((a,s)=>s));let i=n.map(([a,s,c])=>{let l=e.frames.map(f=>r.flatMap(u=>f[a].slice(u*s,(u+1)*s)));return l.some(f=>f.some((u,d)=>t(u,l[0][d],c==="half3"?1e-4:1e-7)))?`${c}[] ${a}.timeSamples = {${e.frames.map((f,u)=>`${f.time}: [${yt(l[u],s)}]`).join(`,
3
- `)}}`:`${c}[] ${a} = [${yt(l[0],s)}]`}).join(`
4
- `);return`#usda 1.0
5
- (
6
- defaultPrim = "Skeleton"
7
- metersPerUnit = 1
8
- upAxis = "Y"
9
- timeCodesPerSecond = 30
10
- framesPerSecond = 30
11
- )
12
- def Skeleton "Skeleton" (prepend apiSchemas = ["SkelBindingAPI"]) {
13
- uniform token[] joints = ${JSON.stringify(e.joints)}
14
- uniform matrix4d[] bindTransforms = [${e.bindTransforms.map(ht).join(", ")}]
15
- uniform matrix4d[] restTransforms = [${e.restTransforms.map(ht).join(", ")}]
16
- rel skel:animationSource = <Animation>
17
- def SkelAnimation "Animation" {
18
- uniform token[] joints = ${JSON.stringify(r.map(a=>e.joints[a]))}
19
- ${i}
20
- }
21
- }
22
- `}function zn(e,t){let n=new Map;for(let o of e){let r=o.target.exported,i=t.get(r.name),a=l=>Math.round(l*1e7)/1e7,s=JSON.stringify([o.rig.name,i?.map(l=>l.matrix.map(a))??r.matrix.elements.map(a)]),c=n.get(s);if(!c){let l=new Ho;l.name=`AR_Rig_${n.size}`,l.matrixAutoUpdate=!1,l.matrix.copy(r.matrix),r.parent.add(l),c={node:l,rig:o.rig,skins:[],extent:new bt},n.set(s,c),i&&t.set(l.name,i)}c.node.add(r),r.matrix.identity(),t.delete(r.name),c.skins.push(o),c.extent.union(o.extent)}return[...n.values()]}function Dn(e){return`
23
- rel skel:skeleton = <Skeleton>
24
- rel skel:animationSource = <Skeleton/Animation>
25
- float3[] extent = [${yt([...e.extent.min.toArray(),...e.extent.max.toArray()],3)}]
26
- def Skeleton "Skeleton" (prepend references = @./rigs/${e.rig.name}.usda@</Skeleton>) {}
27
- `}function $n(e){return`
28
- over "Geometry" (prepend apiSchemas = ["SkelBindingAPI"]) {
29
- rel skel:skeleton = <../../Skeleton>
30
- uniform token[] skel:joints = ${JSON.stringify(e.rig.joints)}
31
- uniform token primvars:skel:skinningMethod = "classicLinear"
32
- matrix4d primvars:skel:geomBindTransform = ${ht(e.geomBind)}
33
- int[] primvars:skel:jointIndices = [${e.jointIndices.join(", ")}] (
34
- interpolation = "vertex"
35
- elementSize = 4
36
- )
37
- float[] primvars:skel:jointWeights = [${e.jointWeights.map(xt).join(", ")}] (
38
- interpolation = "vertex"
39
- elementSize = 4
40
- )
41
- }
42
- `}var ce=30,sr=12e4,ar=1e6,Un=new Set(["position","quaternion","rotation","scale"]);function cr(e){let t=je(e.sceneConfig?.sequences??[]).find(l=>l.autoPlay),n=e.sceneConfig?.animations.autoplayClip,o=En(e.scene.animations),r=o.find(l=>l.sourceName===n),i=e.sceneConfig?.animations.clips.find(l=>l.sourceName===n),a=i?.speed??1,s=Number.isFinite(a)&&a>0?a:1,c=r&&!i?.hidden?r.duration*(i?.loopMode==="ping-pong"?2:1)/s:0;return{sequence:t,autoplay:n,clips:o,duration:Math.max(c,t?.duration??0)}}function _n(e,t,n){let o=new Set,r=new Map,i=0,a=0,s=0,c=[],l=[],m=e.map(cr),f=Math.max(0,...m.map(u=>u.duration));for(let[u,d]of e.entries()){n?.throwIfAborted();let{sequence:p,autoplay:x}=m[u];if(!p&&!x)continue;let b=nr(d.scene),S=[],w=[];d.scene.traverse(T=>S.push(T)),b.traverse(T=>w.push(T));let g=new Map;S.forEach((T,L)=>{w[L].uuid=T.uuid,g.set(T,w[L]);let $=ke(T);$&&T.isSkinnedMesh&&(delete w[L].userData.reactImmersiveSkinFreeze,ve(w[L],$.clone().invert(),Tt(T)??void 0))});let A=ae(b),j=new Qo;j.matrixAutoUpdate=!1,j.matrix.copy(d.scene.parent?.matrixWorld??new er),j.add(b),j.updateMatrixWorld(!0);let P=t.filter(T=>T.sourceIndex===u),R=P.some(T=>T.source.isSkinnedMesh),V=new Set(p?.tracks.filter(T=>!T.muted&&T.target.kind==="clip").map(T=>T.target.kind==="clip"?T.target.clip:"")??[]);x&&V.add(x);let O=m[u].clips.map(T=>{if(!V.has(T.sourceName))return T;let L=T.clip.tracks.filter($=>{let F=Ln.parseTrackName($.name),J=Ln.findNode(b,F.nodeName),D=!!J&&Un.has(F.propertyName)&&(J?.type!=="Bone"||R)&&!F.objectName;return D||o.add(J?.type==="Bone"?"Skeletal tracks without an exported skinned mesh are omitted.":"Quick Look exports object and skeletal motion. Morph and other unsupported clip tracks keep their captured pose."),D});return{...T,clip:new Jo(T.clip.name,T.duration,L)}}),h=T=>d.sceneConfig?.animations.clips.find(L=>L.sourceName===T),M=vn({root:b,clips:O,getClipConfig:h,onChange(){}}),k={...M,clips:O.map(T=>T.sourceName)},E=Rn({root:()=>b,controls:()=>null,animations:()=>k,invalidate(){},cameraEnabled:()=>!1}),N=p?.tracks.filter(T=>{if(!R&&T.target.kind==="object"&&A.nodesById[T.target.objectId]?.type==="Bone")return T.muted||o.add("Quick Look keeps skeletal deformation at its captured pose."),!1;let L=T.target.kind==="clip"||T.target.kind==="object"&&Un.has(T.target.property);return!L&&!T.muted&&o.add("Quick Look exports sequence object motion. Camera, visibility and appearance tracks stay in WebXR."),L}),y=p?{...p,tracks:N??[]}:void 0;y&&E.inspect(y).forEach(T=>o.add(T));let C=O.some(T=>V.has(T.sourceName)&&T.clip.tracks.length&&!h(T.sourceName)?.hidden),v=N?.some(T=>!T.muted&&T.keyframes.length&&T.target.kind==="object");if(!C&&!v){M.dispose();continue}let B=Pn(P,g,j.matrix,`Skin_${u}`),W=new Map(B.skins.map(T=>[T.target,T])),X=f,K=Math.ceil(X*ce);if(a+=(K+1)*P.length,s+=(K+1)*B.rigs.reduce((T,L)=>T+L.joints.length,0),!Number.isFinite(X)||a>sr||s>ar)throw M.dispose(),new Error("This animation is too large for browser USDZ conversion. Use arHandoff.createUSDZ for this model.");let ee=Object.entries(d.objectBindings??{}).flatMap(([T,L])=>{if(!L.transform)return[];let $=A.nodesById[L.modelObjectId??T];return $?[{node:$,matrix:$.matrix.clone(),position:$.position.clone(),quaternion:$.quaternion.clone(),scale:$.scale.clone()}]:[]}),_=P.map(T=>({target:T,node:g.get(T.source),inverse:T.bakedMatrix.clone().invert(),frames:[]}));try{x&&M.play(x);let T=0;for(let L=0;L<=K;L++){n?.throwIfAborted();let $=Math.min(L/ce,X);M.update($-T),T=$;for(let F of ee)F.node.position.copy(F.position),F.node.quaternion.copy(F.quaternion),F.node.scale.copy(F.scale),F.node.matrix.copy(F.matrix);if(y){let F=y.loop&&$>y.duration?$%y.duration:Math.min($,y.duration);E.apply({sequence:y,time:F,playing:!1})}j.updateMatrixWorld(!0),Vn(B.rigs,B.skins,$*ce);for(let F of _){let J=W.get(F.target),D=J?St(J):F.node.matrixWorld.clone().multiply(F.target.instanceMatrix).multiply(F.inverse);if(!D.elements.every(Number.isFinite)||D.determinant()<=0)throw new Error("Quick Look animation cannot preserve a reflected or zero-scale transform. Use arHandoff.createUSDZ.");F.frames.push({time:$*ce,matrix:D.toArray()})}}for(let L of _){let $=L.frames[0]?.matrix;$&&L.frames.some(F=>F.matrix.some((J,D)=>Math.abs(J-$[D])>1e-8))&&(r.set(L.target.exported.name,L.frames),i=Math.max(i,X))}if(B.skins.length){for(let L of B.skins)L.extent.expandByScalar(Math.max(1e-6,L.extent.getSize(new tr).length()*.001));c.push(...B.rigs),l.push(...B.skins),i=Math.max(i,X)}}finally{E.restore(),M.dispose()}}return{samples:r,rigs:c,skins:l,duration:i,warnings:[...o]}}function Fn(e,t,n){if(!t.samples.size&&!t.skins.length)return e;let o=rr(e),r=or(o["model.usda"]);r=r.replace(" metersPerUnit = 1",` startTimeCode = 0
43
- endTimeCode = ${t.duration*ce}
44
- timeCodesPerSecond = ${ce}
45
- framesPerSecond = ${ce}
46
- autoPlay = true
47
- metersPerUnit = 1`);for(let[s,c]of t.samples){let l=new RegExp(`(def Xform "${s}"[\\s\\S]*?\\n[\\t ]*)matrix4d xformOp:transform = [^\\n]+`);if(!l.test(r))throw new Error("The USDZ exporter produced an unsupported animation layout.");let m=c.map(f=>{let u=[0,4,8,12].map(d=>`(${f.matrix.slice(d,d+4).join(", ")})`);return`${f.time}: (${u.join(", ")})`}).join(`,
48
- `);r=r.replace(l,(f,u)=>`${u}matrix4d xformOp:transform.timeSamples = {
49
- ${m}
50
- }`)}for(let s of t.rigs)o[`rigs/${s.name}.usda`]=wt(Nn(s));for(let s of n){let c=new RegExp(`def Xform "${s.node.name}"(\\s*\\{)`);if(!c.test(r))throw new Error("The USDZ exporter produced an unsupported skeleton root layout.");r=r.replace(c,`def SkelRoot "${s.node.name}" (prepend apiSchemas = ["SkelBindingAPI"]) $1${Dn(s)}`)}for(let s of t.skins){let c=new RegExp(`def Xform "${s.target.exported.name}"(\\s*\\([\\s\\S]*?\\)\\s*\\{)`);if(!c.test(r))throw new Error("The USDZ exporter produced an unsupported skeleton layout.");r=r.replace(c,(l,m)=>`def Xform "${s.target.exported.name}"${m}${$n(s)}`)}o["model.usda"]=wt(r);let i={},a=0;for(let[s,c]of Object.entries(o)){a+=34+wt(s).length;let l=a&63;i[s]=l===4?c:[c,{extra:{12345:new Uint8Array(64-l)}}],a=c.length}return ir(i,{level:0})}function pr(e,t={}){t.signal?.throwIfAborted();let n=new qn,o=new qn;n.add(o);let r=new Set,i=[],a=[],s=[],c=new Map,l=[],m=0,f=0,u=()=>{i.forEach(d=>d.dispose()),a.forEach(d=>d.dispose()),s.forEach(d=>d.dispose())};try{for(let[S,{scene:w,objectBindings:g={},materialOverrides:A={}}]of e.entries()){An(w),w.updateWorldMatrix(!0,!0);let j=new Map(Object.entries(g).map(([P,R])=>[R.modelObjectId??P,P]));w.traverse(P=>{let R=P;if(!R.isMesh||!R.geometry)return;for(let E=P;E;E=E.parent){let N=Me(E)??E.name??E.uuid;if(!E.visible||g[j.get(N)??N]?.visible===!1||g[j.get(N)??N]?.removed)return}let V=Me(R)??R.name??R.uuid,O=A[j.get(V)??V]??R.material;if(!O)throw new Error(`Material for ${V} is not ready. Wait for the model to finish loading.`);let h=Array.isArray(O)?O:[O],M=R.isInstancedMesh?R.count:1;if(R.userData.riDecal&&be(R)&&R.parent){let E=ke(R.parent);E&&R.bindMatrixInverse.copy(E)}let k=be(R)?Rt(R):R.geometry.clone();try{if(!be(R)&&R.morphTargetInfluences?.some(y=>y!==0)){let y=k.getAttribute("position"),C=new Ue;for(let v=0;v<y.count;v++)R.getVertexPosition(v,C),y.setXYZ(v,C.x,C.y,C.z);k.morphAttributes={},k.computeVertexNormals()}if(!k.getAttribute("position"))throw new Error(`Mesh ${V} has no positions.`);let E=k.index?.count??k.getAttribute("position").count,N=Array.isArray(O)?k.groups:[{start:0,count:E,materialIndex:0}];if(!N.length)throw new Error(`Mesh ${V} has multiple materials without geometry groups.`);for(let y=0;y<M;y++){let C=R.matrixWorld.clone(),v=new mr;R.isInstancedMesh&&(R.getMatrixAt(y,v),C.multiply(v));for(let B of N){let W=h[B.materialIndex??0];if(!W)throw new Error(`A material group on ${V} is missing its material.`);if(!W.visible)continue;let X=W;if(!X.isMeshStandardMaterial||X.wireframe||X.vertexColors)throw new Error(`AR snapshot cannot preserve ${W.type}${X.wireframe?" wireframe":X.vertexColors?" vertex colors":""} on ${V}. Use a PBR material or provide arHandoff.createUSDZ.`);let K=Math.max(B.start,k.drawRange.start),ee=Math.min(E,B.start+B.count,k.drawRange.start+k.drawRange.count);if(ee<=K)continue;if(K%3||(ee-K)%3)throw new Error(`Mesh ${V} has an incomplete triangle range.`);let _=new Wn;i.push(_);let T=Array.from({length:ee-K},(D,U)=>k.index?k.index.getX(K+U):K+U);if(C.determinant()<0)for(let D=0;D<T.length;D+=3)[T[D+1],T[D+2]]=[T[D+2],T[D+1]];for(let[D,U]of Object.entries(k.attributes)){let q=new Float32Array(T.length*U.itemSize);for(let z=0;z<T.length;z++)for(let Z=0;Z<U.itemSize;Z++)q[z*U.itemSize+Z]=U.getComponent(T[z],Z);_.setAttribute(D,new Le(q,U.itemSize))}be(R)&&(_.setAttribute("arSourceVertex",new Le(new Float32Array(T),1)),_.setAttribute("arNormalSign",new Le(new Float32Array(T.length).fill(1),1))),_.setIndex(T.map((D,U)=>U)),_.applyMatrix4(C);let L=_.getAttribute("position");for(let D=0;D<L.count;D++)if(![L.getX(D),L.getY(D),L.getZ(D)].every(Number.isFinite))throw new Error(`Mesh ${V} contains invalid coordinates.`);_.getAttribute("normal")||_.computeVertexNormals();let $=X.clone();a.push($);let F=X.userData.reactImmersiveConfiguredEmissive;if(F?.isColor&&$.emissive.copy(F),$.side===dr){let D=_.toNonIndexed();i.push(D);let U=D.getAttribute("position").count,q=new Wn;i.push(q);for(let[z,Z]of Object.entries(D.attributes)){let We=new Float32Array(U*Z.itemSize*2);for(let oe=0;oe<U;oe++)for(let ue=0;ue<Z.itemSize;ue++){We[oe*Z.itemSize+ue]=Z.getComponent(oe,ue);let eo=Math.floor(oe/3)*3+(2-oe%3);We[(U+oe)*Z.itemSize+ue]=Z.getComponent(eo,ue)*(z==="normal"||z==="arNormalSign"?-1:1)}q.setAttribute(z,new Le(We,Z.itemSize))}$.side=At,_.copy(q)}else if($.side!==At){let D=_.getIndex();for(let z=0;z<D.count;z+=3){let Z=D.getX(z+1);D.setX(z+1,D.getX(z+2)),D.setX(z+2,Z)}let U=_.getAttribute("normal");for(let z=0;z<U.count;z++)U.setXYZ(z,-U.getX(z),-U.getY(z),-U.getZ(z));let q=_.getAttribute("arNormalSign");if(q)for(let z=0;z<q.count;z++)q.setX(z,-q.getX(z));$.side=At}if(R.isInstancedMesh&&R.instanceColor){let D=new ur;R.getColorAt(y,D),$.color.multiply(D)}for(let[D,U]of Object.entries($)){if(!U?.isTexture)continue;let q=U;if(sn(q)||!q.image||q.image.complete===!1)throw new Error(`Texture on ${V} is not ready. Wait for image loading or replace failed textures before preparing AR.`);let z=c.get(q);if(z||(z=q.clone(),c.set(q,z),s.push(z)),$[D]=z,!_.getAttribute(z.channel?`uv${z.channel}`:"uv"))throw new Error(`Texture on ${V} needs UV coordinates missing from this geometry.`)}if(R.userData.riDecal){_.computeBoundingBox();let D=Math.max(1e-6,_.boundingBox.getSize(new Ue).length()*1e-4),U=_.getAttribute("position"),q=_.getAttribute("normal");for(let z=0;z<U.count;z++)U.setXYZ(z,U.getX(z)+q.getX(z)*D,U.getY(z)+q.getY(z)*D,U.getZ(z)+q.getZ(z)*D)}let J=new fr(_,$);J.name=`AR_${m++}`,o.add(J),l.push({sourceIndex:S,source:R,exported:J,bakedMatrix:C.clone(),instanceMatrix:v}),f+=(_.index?.count??_.getAttribute("position").count)/3,($.clearcoat||$.transmission||$.iridescence||$.anisotropy)&&r.add("Advanced PBR effects may look different in Quick Look.")}}}finally{k.dispose()}})}if(!m||!f)throw new Error("There is no visible model geometry to send to AR.");let d=new lr().setFromObject(o),p=d.getSize(new Ue),x=d.getCenter(new Ue),b=t.scaleMode==="real-world"?1:1/Math.max(p.x,p.y,p.z,1e-9);return o.position.set(-x.x*b,-d.min.y*b,-x.z*b),o.scale.setScalar(b),n.updateMatrixWorld(!0),r.add("Viewer lighting, background, post-processing, annotations and measurement overlays stay in the web viewer."),{root:n,meshCount:m,triangleCount:f,scale:b,warnings:[...r],textures:s,motionMeshes:l,dispose:u}}catch(d){throw u(),d}}async function ea(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=pr(e,t),r=[];try{let i=_n(e,o.motionMeshes,t.signal),a=zn(i.skins,i.samples);o.root.updateMatrixWorld(!0);let{USDZExporter:s}=await import("three/examples/jsm/exporters/USDZExporter.js");t.signal?.throwIfAborted();for(let m of o.textures){if(!m.isCompressedTexture)continue;let{decompress:f}=await import("three/examples/jsm/utils/WebGLTextureUtils.js"),u=f(m,n);r.push(u),o.root.traverse(d=>{let p=d.material;if(p)for(let x of Object.keys(p))p[x]===m&&(p[x]=u)})}let c=await new s().parseAsync(o.root,{onlyVisible:!0,quickLookCompatible:!0,maxTextureSize:n});t.signal?.throwIfAborted();let l=Fn(c,i,a);return{blob:new Blob([new Uint8Array(l)],{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 a=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"}${a}`)}finally{o.dispose(),r.forEach(i=>i.dispose())}}var _e=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."}]),na="__custom__";function gr(e){return _e.find(t=>t.id===e)}var Hn=_e.filter(e=>e.handling==="viewer").map(e=>e.id),br=new Set(["","New Action",..._e.map(e=>e.label)]);function oa(e){return br.has(e.trim())}function Gn(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 a=n[i-1]+(e[o-1]===t[i-1]?0:1);r[i]=Math.min(r[i-1]+1,n[i]+1,a)}n=r}return n[t.length]}function ra(e){if(gr(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 _e){let i=Math.min(Gn(t,r.id),Gn(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 hr=.12,Xn=new Set;function yr(e,t){return t?new Set(Oe(e,t.target)):Xn}function aa(e,t){let n=yr(e.bindings,t);if(!t||n.size===0)return{...e,setAside:Xn};let o=Math.min(Math.max(t.ghostOpacity??hr,0),1),r={...e.bindings},i=new WeakMap,a=new Set;for(let[s,c]of Object.entries(e.bindings)){if(n.has(s))continue;a.add(s);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[s]=l,i.set(l,e.sourceOf(c))}return{bindings:r,pulses:e.pulses,sourceOf:s=>i.get(s)??e.sourceOf(s),setAside:a}}function Sr(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 xr(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 wr(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 Kn(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 Yn(e,t=!0){let n=wr(e);return{id:Sr(e),modelObjectId:e,type:n,label:xr(e),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:Kn(n,t),metrics:{},metadata:{}}}function ma(e,t){return Object.fromEntries(e.map(n=>[n,Yn(n,!t?.has(n))]))}function fa(e,t){let n=new Set,o={};for(let r of e){let i=Yn(r,!t?.has(r)),a=i.id||"object",s=a;for(let l=2;n.has(s);l++)s=`${a}-${l}`;n.add(s),i.id=s;let c=(i.actions??[]).filter(l=>Hn.includes(l.id));i.actions=c.length>0?c:Kn("other",!t?.has(r)),o[r]=i}return o}function pa(e){let t=new Set;for(let[n,o]of Object.entries(ae(e).nodesById))Bt(o)||t.add(n);return t}function ga(e){let{nodesById:t}=ae(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 Qn={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"},Ar=Object.keys(Qn),Cr=new Set(["__proto__","prototype","constructor"]);function le(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=>le(o,t)):Object.fromEntries(Object.entries(e).filter(([o,r])=>!Cr.has(o)&&r!==void 0).map(([o,r])=>[o,le(r,t)]));return t.delete(e),n}var Zn=e=>e&&typeof e=="object"&&!Array.isArray(e)&&!Object.keys(e).length;function Jn(e,t){let n=le(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(),Zn(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"])Zn(n[o])&&delete n[o];for(let o of["actions","decals"])Array.isArray(n[o])&&!n[o].length&&delete n[o];return n}function Fe(e,t,n,o,r,i){let a=c=>c===void 0||Array.isArray(c)&&c.length===0;if(Object.is(e,t)||a(e)&&a(t)||typeof e=="number"&&typeof t=="number"&&Math.abs(e-t)<=r)return;let s=c=>!!c&&typeof c=="object"&&!Array.isArray(c);if(s(e)&&s(t)){for(let c of[...new Set([...Object.keys(e),...Object.keys(t)])].sort())Fe(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++)Fe(e[c],t[c],`${n}[${c}]`,o,r,i);return}i.push({path:n,category:o,...e!==void 0?{before:le(e)}:{},...t!==void 0?{after:le(t)}:{}})}function ha(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(([,S])=>!S.removed),i=Object.entries(t.objectBindings).filter(([,S])=>!S.removed),a=new Map(r),s=new Map(i),c=new Set,l=new Set,m=[],f=S=>{let w=n.matchBy??"modelObjectId",g=typeof w=="object"?S.metadata?.[w.metadataKey]:S[w];return typeof g=="string"&&g.length>0||typeof g=="number"?`${typeof g}:${g}`:null};function u(S,w,g){let A=S===void 0?void 0:a.get(S),j=w===void 0?void 0:s.get(w),P=[];if(A||j){let V=A?Jn(A,n.ignoreMetadataKeys??[]):{},O=j?Jn(j,n.ignoreMetadataKeys??[]):{};for(let h of Ar)Fe(V[h],O[h],h,Qn[h],o,P)}let R=A?j?P.length?"modified":"unchanged":"removed":"added";m.push({id:JSON.stringify([S??null,w??null]),identity:g,label:j?.label??A?.label??j?.modelObjectId??A?.modelObjectId??g,status:R,beforeKey:S,afterKey:w,beforeObjectId:A?.modelObjectId,afterObjectId:j?.modelObjectId,changes:P}),S!==void 0&&c.add(S),w!==void 0&&l.add(w)}let d=new Set;for(let[S,w]of Object.entries(n.mapping??{})){if(!a.has(S)||!s.has(w)||d.has(w))throw new Error("Comparison mapping must reference existing, unique binding keys");d.add(w),u(S,w,`mapped:${S}`)}let p=new Map;for(let[S,w,g]of[[r,c,"a"],[i,l,"b"]])for(let[A,j]of S){if(w.has(A))continue;let P=f(j);if(P===null){m.push({id:JSON.stringify([g,A]),identity:"",label:j.label??j.modelObjectId,status:"ambiguous",...g==="a"?{beforeKey:A,beforeObjectId:j.modelObjectId}:{afterKey:A,afterObjectId:j.modelObjectId},changes:[],message:"Missing match identity. Supply an explicit mapping or another match field."});continue}let R=p.get(P)??{a:[],b:[]};R[g].push(A),p.set(P,R)}for(let[S,w]of p){if(w.a.length<=1&&w.b.length<=1){u(w.a[0],w.b[0],S);continue}for(let g of["a","b"])for(let A of w[g]){let j=(g==="a"?a:s).get(A);m.push({id:JSON.stringify([g,A]),identity:S,label:j.label??j.modelObjectId,status:"ambiguous",...g==="a"?{beforeKey:A,beforeObjectId:j.modelObjectId}:{afterKey:A,afterObjectId:j.modelObjectId},changes:[],message:"Duplicate match identity. Supply an explicit one-to-one mapping."})}}m.sort((S,w)=>S.label.localeCompare(w.label)||S.id.localeCompare(w.id));let x=[];Fe(le(e.sceneConfig??{}),le(t.sceneConfig??{}),"sceneConfig","scene",o,x);let b={added:0,removed:0,modified:0,unchanged:0,ambiguous:0};for(let S of m)b[S.status]++;return{version:1,objects:m,counts:b,sceneChanges:x}}function ya(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 xa=["front","back","double"],wa=["normal","additive"];function Ma(e){ae(e);let t=[],n=[{node:e,path:"0",parentId:null}];for(;n.length;){let{node:r,path:i,parentId:a}=n.pop(),s=`node:${i}`,c=r.isMesh&&r.name?Me(r):null;t.push({id:s,parentId:a,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:s})}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 ka(e){return structuredClone(e.style??{})}function Oa(e,t,n){let o=Oe(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{ae as a,Me as b,ms as c,fs as d,Cn as e,Mr as f,kr as g,Tr as h,Rr as i,zt as j,Vr as k,Lt as l,ne as m,Hr as n,Go as o,pt as p,On as q,Rn as r,at as s,Ti as t,Ii as u,Ri as v,Ei as w,Ve as x,Bi as y,Pi as z,Oo as A,Vi as B,Ni as C,zi as D,Di as E,$i as F,Li as G,Ui as H,Kr as I,Yr as J,Zr as K,Jr as L,Qr as M,ei as N,ti as O,Qe as P,fe as Q,ye as R,ri as S,ii as T,si as U,li as V,et as W,Se as X,ui as Y,di as Z,mi as _,fi as $,Ht as aa,Xt as ba,Kt as ca,nt as da,bi as ea,hi as fa,yi as ga,Si as ha,wo as ia,rt as ja,Co as ka,Ai as la,Ci as ma,Qt as na,Mo as oa,xe as pa,Mi as qa,ji as ra,en as sa,se as ta,Zi as ua,Ne as va,pn as wa,os as xa,rs as ya,$o as za,is as Aa,ss as Ba,as as Ca,ls as Da,An as Ea,vn as Fa,En as Ga,ea as Ha,_e as Ia,na as Ja,gr as Ka,Hn as La,oa as Ma,ra as Na,yr as Oa,aa as Pa,wr as Qa,Yn as Ra,ma as Sa,fa as Ta,pa as Ua,ga as Va,ha as Wa,ya as Xa,xa as Ya,wa as Za,Ma as _a,ka as $a,Oa as ab};