@selvajs/compute 3.0.1-beta.0 → 3.0.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.
- package/dist/chunk-6LCAIDQV.cjs +4 -0
- package/dist/chunk-6LCAIDQV.cjs.map +1 -0
- package/dist/chunk-CFBKO3HX.cjs +2 -0
- package/dist/chunk-CFBKO3HX.cjs.map +1 -0
- package/dist/chunk-JF5MZTOU.cjs +55 -0
- package/dist/{chunk-MBCMFI2R.cjs.map → chunk-JF5MZTOU.cjs.map} +1 -1
- package/dist/chunk-LUP3B2DK.js +55 -0
- package/dist/{chunk-G3SQHFDY.js.map → chunk-LUP3B2DK.js.map} +1 -1
- package/dist/chunk-O55PTKMV.js +4 -0
- package/dist/chunk-O55PTKMV.js.map +1 -0
- package/dist/chunk-UAL4YXRX.js +2 -0
- package/dist/chunk-UAL4YXRX.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -10
- package/dist/core.d.ts +1 -10
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.d.cts +2 -2
- package/dist/grasshopper.d.ts +2 -2
- package/dist/grasshopper.js +1 -1
- package/dist/{handle-files-9pkEgDIp.d.ts → handle-files-Bu2qmaPj.d.cts} +2 -2
- package/dist/{handle-files-9pkEgDIp.d.cts → handle-files-Bu2qmaPj.d.ts} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/visualization-LZ4XZPYZ.cjs +2 -0
- package/dist/visualization-LZ4XZPYZ.cjs.map +1 -0
- package/dist/visualization-SV4BTHXJ.js +2 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-AUAMZCIL.cjs +0 -2
- package/dist/chunk-AUAMZCIL.cjs.map +0 -1
- package/dist/chunk-FMMK2QTR.js +0 -4
- package/dist/chunk-FMMK2QTR.js.map +0 -1
- package/dist/chunk-G3SQHFDY.js +0 -55
- package/dist/chunk-G5XWFITM.js +0 -2
- package/dist/chunk-G5XWFITM.js.map +0 -1
- package/dist/chunk-LBRCTJ7W.cjs +0 -4
- package/dist/chunk-LBRCTJ7W.cjs.map +0 -1
- package/dist/chunk-MBCMFI2R.cjs +0 -55
- package/dist/visualization-LTWBUHLN.cjs +0 -2
- package/dist/visualization-LTWBUHLN.cjs.map +0 -1
- package/dist/visualization-SU3XQ35P.js +0 -2
- /package/dist/{visualization-SU3XQ35P.js.map → visualization-SV4BTHXJ.js.map} +0 -0
package/dist/chunk-G3SQHFDY.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import{a as Ve,c as re,d as oe,e as C,j as ce}from"./chunk-FMMK2QTR.js";import*as z from"three";var W={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function zn(e,r,t,n,a){if(Fe(e),r.length===0)return;r.forEach(d=>{e.add(d)});let o=J(r),i=o.getCenter(new z.Vector3),l=o.getSize(new z.Vector3),s=Math.max(l.x,l.y,l.z);if(s/Math.min(l.x||1,l.y||1,l.z||1)>W.SCALE_RATIO_THRESHOLD||s>W.HUGE_THRESHOLD?(t.near=s*W.NEAR_PLANE_FACTOR.TINY,t.far=s*W.FAR_PLANE_FACTOR.HUGE):s>W.LARGE_THRESHOLD?(t.near=s*W.NEAR_PLANE_FACTOR.SMALL,t.far=s*W.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,s*W.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,s*W.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),a)n.minDistance=t.near*2,n.maxDistance=t.far*.9;else{let d=s*W.INITIAL_DISTANCE_MULTIPLIER;t.position.set(i.x+d*.8,i.y+d,i.z+d*1.2),n.target.copy(i),n.minDistance=t.near*2,n.maxDistance=t.far*.9,n.update()}}function ue(e){if(!e||typeof e!="string")return C().warn(`Invalid color input: ${e}, using white`),new z.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let t=r.startsWith("#")?r:`#${r}`;return new z.Color(t)}catch{return C().warn(`Invalid hex color: ${e}, using white`),new z.Color(16777215)}if(r.includes(",")){let t=r.split(",").map(n=>parseInt(n.trim(),10));if(t.length===3&&t.every(n=>!isNaN(n)&&n>=0&&n<=255))return new z.Color(t[0]/255,t[1]/255,t[2]/255)}try{return new z.Color(r.toLowerCase())}catch{return C().warn(`Invalid color string: ${e}, using white`),new z.Color(16777215)}}function de(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function J(e){let r=new z.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new z.Box3().setFromObject(t);r.union(n)}),r}var Be=new Set(["floor","grid","label-layer"]);function Fe(e){[...e.children].forEach(t=>{Be.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(n=>{let a=n;if(!a.geometry&&!a.material)return;a.geometry?.dispose();let o=a.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(l=>{for(let s of Object.values(l))s instanceof z.Texture&&s.dispose();l.dispose()})}),t.removeFromParent())})}import*as j from"three";function ze(e){let r=e.clone().normalize(),t=new j.Vector3(0,0,1),n=new j.Vector3(0,1,0),a=Math.abs(r.dot(t))>.9?n:t,o=new j.Vector3().crossVectors(r,a).normalize(),i=new j.Vector3().crossVectors(o,r).normalize();return{top:r.clone(),bottom:r.clone().negate(),front:i.clone(),back:i.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(o.clone()).add(r.clone()).normalize()}}function me(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:a}=e,o=(e.up??t.up).clone().normalize(),i=ze(o),l=new j.OrthographicCamera(-1,1,1,-1,t.near,t.far);l.up.copy(o);let s="perspective",c=t.aspect,d=()=>s==="perspective"?t:l,u=()=>{let R=t.position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),y=R*c;l.left=-y,l.right=y,l.top=R,l.bottom=-R,l.near=t.near,l.far=t.far,l.updateProjectionMatrix()},m=g=>{g!==s&&(g==="orthographic"?(l.position.copy(t.position),l.up.copy(t.up),l.lookAt(n.target),u()):t.position.copy(l.position),s=g,n.object=d(),n.update(),a(d()))},p=(g,R=!0)=>{let y=ke(r),H=y.isEmpty()?n.target.clone():y.getCenter(new j.Vector3),O=y.isEmpty()?new j.Vector3(1,1,1):y.getSize(new j.Vector3),b=Math.max(O.x,O.y,O.z)||1,T=t.fov*(Math.PI/180),x=b/(2*Math.tan(T/2))*1.5,P=_e(g,o),D=H.clone().add(P.clone().multiplyScalar(x)),F=d();R?Ne(F,n,D,H,()=>{s==="orthographic"&&u()}):(F.position.copy(D),n.target.copy(H),s==="orthographic"&&u(),n.update())};return{getActiveCamera:d,getProjection:()=>s,setProjection:m,toggleProjection:()=>(m(s==="perspective"?"orthographic":"perspective"),s),setView:(g,R=!0)=>{p(i[g],R)},setViewDirection:p,setRotateEnabled:g=>{n.enableRotate=g},isRotateEnabled:()=>n.enableRotate,updateAspect:(g,R)=>{c=R===0?c:g/R,s==="orthographic"&&u()}}}var Ue=new Set(["grid","floor","label-layer","measure"]);function je(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Ue.has(r.userData.id))return!0;r=r.parent}return!1}function ke(e){let r=[];return e.traverse(t=>{let n=t;t.visible&&!je(t)&&n.geometry&&r.push(t)}),J(r)}function _e(e,r){let t=r.clone().normalize(),n=e.clone().normalize();if(Math.abs(n.dot(t))<.9999)return e;let a=Math.abs(t.dot(new j.Vector3(0,0,1)))>.9?new j.Vector3(0,1,0):new j.Vector3(0,0,1),o=new j.Vector3().crossVectors(t,a).normalize(),i=.5*Math.PI/180;return n.multiplyScalar(Math.cos(i)).add(o.multiplyScalar(Math.sin(i))).normalize()}var Ge=e=>1-Math.pow(1-e,3);function Ne(e,r,t,n,a,o=250){let i=e.position.clone(),l=r.target.clone(),s=performance.now(),c=()=>{let d=Ge(Math.min((performance.now()-s)/o,1));e.position.lerpVectors(i,t,d),r.target.lerpVectors(l,n,d),a(),r.update(),d<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}import*as I from"three";var We=`
|
|
2
|
-
varying vec3 vWorldPos;
|
|
3
|
-
void main() {
|
|
4
|
-
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
5
|
-
vWorldPos = world.xyz;
|
|
6
|
-
gl_Position = projectionMatrix * viewMatrix * world;
|
|
7
|
-
}
|
|
8
|
-
`,$e=`
|
|
9
|
-
precision highp float;
|
|
10
|
-
varying vec3 vWorldPos;
|
|
11
|
-
|
|
12
|
-
uniform vec2 uAxes; // indices (0=x,1=y,2=z) of the two in-plane world axes
|
|
13
|
-
uniform float uCell;
|
|
14
|
-
uniform float uMajor;
|
|
15
|
-
uniform vec3 uCellColor;
|
|
16
|
-
uniform vec3 uMajorColor;
|
|
17
|
-
uniform vec3 uCenter; // fade center (camera position), projected onto plane
|
|
18
|
-
uniform float uFade;
|
|
19
|
-
|
|
20
|
-
// Antialiased grid line intensity for a given spacing, using screen-space derivatives so lines
|
|
21
|
-
// stay ~1px regardless of zoom (the standard "pristine grid" technique).
|
|
22
|
-
float gridLine(vec2 coord, float spacing) {
|
|
23
|
-
vec2 c = coord / spacing;
|
|
24
|
-
vec2 d = fwidth(c);
|
|
25
|
-
vec2 g = abs(fract(c - 0.5) - 0.5) / max(d, 1e-6);
|
|
26
|
-
float line = min(g.x, g.y);
|
|
27
|
-
return 1.0 - clamp(line, 0.0, 1.0);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Index a vec3 by a float axis id (0/1/2) without dynamic indexing (WebGL1-safe).
|
|
31
|
-
float axis(vec3 v, float i) {
|
|
32
|
-
return i < 0.5 ? v.x : (i < 1.5 ? v.y : v.z);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
void main() {
|
|
36
|
-
// Pick the two in-plane world coordinates.
|
|
37
|
-
vec2 coord = vec2(axis(vWorldPos, uAxes.x), axis(vWorldPos, uAxes.y));
|
|
38
|
-
|
|
39
|
-
float minor = gridLine(coord, uCell);
|
|
40
|
-
float major = gridLine(coord, uCell * uMajor);
|
|
41
|
-
|
|
42
|
-
vec3 color = mix(uCellColor, uMajorColor, major);
|
|
43
|
-
float alpha = max(minor, major);
|
|
44
|
-
|
|
45
|
-
// Radial fade from the camera-projected center.
|
|
46
|
-
float dist = distance(vWorldPos, uCenter);
|
|
47
|
-
float fade = 1.0 - clamp(dist / uFade, 0.0, 1.0);
|
|
48
|
-
alpha *= fade * fade;
|
|
49
|
-
|
|
50
|
-
if (alpha < 0.001) discard;
|
|
51
|
-
gl_FragColor = vec4(color, alpha);
|
|
52
|
-
}
|
|
53
|
-
`;function pe(e={}){let{cellSize:r=1,majorEvery:t=10,cellColor:n=8947848,majorColor:a=4473924,fadeDistance:o=100,plane:i="y"}=e,l=i==="y"?new I.Vector2(0,2):i==="z"?new I.Vector2(0,1):new I.Vector2(1,2),s=o*2.5,c=new I.PlaneGeometry(s,s);i==="y"?c.rotateX(-Math.PI/2):i==="x"&&c.rotateY(Math.PI/2);let d=new I.ShaderMaterial({vertexShader:We,fragmentShader:$e,transparent:!0,depthWrite:!1,side:I.DoubleSide,uniforms:{uAxes:{value:l},uCell:{value:r},uMajor:{value:t},uCellColor:{value:new I.Color(n)},uMajorColor:{value:new I.Color(a)},uCenter:{value:new I.Vector3},uFade:{value:o}}}),u=new I.Mesh(c,d);u.name="grid",u.userData.id="grid",u.renderOrder=-1;let m=new I.Vector3;return{object:u,update:p=>{i==="y"?(u.position.set(p.x,0,p.z),m.set(p.x,0,p.z)):i==="z"?(u.position.set(p.x,p.y,0),m.set(p.x,p.y,0)):(u.position.set(0,p.y,p.z),m.set(0,p.y,p.z)),d.uniforms.uCenter.value.copy(m)},setVisible:p=>{u.visible=p},dispose:()=>{c.dispose(),d.dispose()}}}import*as k from"three";import{ViewHelper as Ye}from"three/addons/helpers/ViewHelper.js";function fe(e){let{camera:r,domElement:t,controller:n}=e,a=new Ye(r,t);a.setLabels("X","Y","Z");let o=!0,i=128,l=new k.Raycaster,s=new k.OrthographicCamera(-2,2,2,-2,0,4);s.position.set(0,0,2);let c={posX:new k.Vector3(1,0,0),negX:new k.Vector3(-1,0,0),posY:new k.Vector3(0,1,0),negY:new k.Vector3(0,-1,0),posZ:new k.Vector3(0,0,1),negZ:new k.Vector3(0,0,-1)},d=m=>{let p=t.getBoundingClientRect(),E=p.left+t.offsetWidth-i-a.location.right,A=p.top+t.offsetHeight-i-a.location.bottom,v=new k.Vector2((m.clientX-E)/i*2-1,-((m.clientY-A)/i)*2+1);if(Math.abs(v.x)>1||Math.abs(v.y)>1)return null;a.quaternion.copy(r.quaternion).invert(),a.updateMatrixWorld(),l.setFromCamera(v,s);let g=l.intersectObjects(a.children,!1);for(let R of g){let y=R.object.userData?.type;if(typeof y=="string"&&y in c)return y}return null};return{render:m=>{if(!o)return;let p=m.autoClear;m.autoClear=!1,a.render(m),m.autoClear=p},update:m=>{a.animating&&a.update(m)},handleClick:m=>{if(!o)return!1;let p=d(m);return p?(n.getProjection()==="orthographic"&&n.setProjection("perspective"),n.setViewDirection(c[p],!1),!0):!1},get isAnimating(){return a.animating},setVisible:m=>{o=m},isVisible:()=>o,dispose:()=>a.dispose()}}import*as Z from"three";import{LineSegmentsGeometry as Xe}from"three/addons/lines/LineSegmentsGeometry.js";import{LineSegments2 as Ee}from"three/addons/lines/LineSegments2.js";import{LineMaterial as qe}from"three/addons/lines/LineMaterial.js";var ee="edge-overlay",Ze=2236962,Je=1.5,Ke=30;function he(e,r={}){let t=new Z.Color(r.color??Ze),n=r.width??Je,a=r.thresholdAngle??Ke,o=[];return e.traverse(i=>{if(!(i instanceof Z.Mesh)||i.userData.id==="floor"||i.userData.id==="grid"||i.userData.kind===ee||i.children.some(s=>s.userData?.kind===ee)||!i.geometry)return;let l=Qe(i.geometry,t,n,a);i.add(l),o.push(l)}),o}function Qe(e,r,t,n){let a=new Z.EdgesGeometry(e,n),o=new Xe;o.setPositions(Array.from(a.attributes.position.array)),a.dispose();let i=new qe({color:r});i.linewidth=t,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-1;let l=new Ee(o,i);return l.userData.kind=ee,l.raycast=()=>{},l}function et(e){return e.userData?.kind===ee}function Xn(e){let r=[];e.traverse(t=>{t instanceof Ee&&et(t)&&r.push(t)});for(let t of r)t.geometry.dispose(),t.material.dispose(),t.removeFromParent();return r.length}import{EffectComposer as tt}from"three/addons/postprocessing/EffectComposer.js";import{RenderPass as nt}from"three/addons/postprocessing/RenderPass.js";import{GTAOPass as rt}from"three/addons/postprocessing/GTAOPass.js";import{OutputPass as ot}from"three/addons/postprocessing/OutputPass.js";function ge(e,r,t,n,a,o){let i=new tt(e),l=new nt(r,t);i.addPass(l);let s=new rt(r,t,n,a);s.blendIntensity=o.aoIntensity??1,s.updateGtaoMaterial({screenSpaceRadius:!0}),i.addPass(s);let c=new ot;return i.addPass(c),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure,i.setSize(n,a),{render:d=>i.render(d),setSize:(d,u,m)=>{i.setPixelRatio(m),i.setSize(d,u),s.setSize(d,u)},setCamera:d=>{l.camera=d,s.camera=d},dispose:()=>{i.dispose(),s.dispose(),c.dispose()}}}import*as ye from"three";import{CSS2DRenderer as at,CSS2DObject as it}from"three/addons/renderers/CSS2DRenderer.js";function be(e,r){let t=new at,n=t.domElement;n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.overflow="hidden",n.style.pointerEvents="none",n.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(n);let a={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(a.width,a.height);let o=new ye.Group;o.name="label-layer",o.userData.id="label-layer",r.add(o);let i=new Set;return{addLabel:(s,c,d)=>{let u=document.createElement("div");u.textContent=s,d?u.className=d:Object.assign(u.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),u.style.pointerEvents="none";let m=new it(u);return m.position.copy(c),o.add(m),i.add(m),{object:m,setPosition:p=>m.position.copy(p),setText:p=>{u.textContent=p},remove:()=>{m.removeFromParent(),u.remove(),i.delete(m)}}},render:(s,c)=>t.render(s,c),setSize:(s,c)=>t.setSize(s,c),dispose:()=>{i.forEach(s=>{s.removeFromParent(),s.element.remove()}),i.clear(),o.removeFromParent(),n.remove()}}}import*as S from"three";import{Line2 as st}from"three/addons/lines/Line2.js";import{LineGeometry as lt}from"three/addons/lines/LineGeometry.js";import{LineMaterial as ct}from"three/addons/lines/LineMaterial.js";var ut=12,dt=16763904,mt=.015,Re={Millimeters:{metersPerUnit:1/1e3,suffix:"mm"},Centimeters:{metersPerUnit:1/100,suffix:"cm"},Meters:{metersPerUnit:1,suffix:"m"},Inches:{metersPerUnit:1/39.37,suffix:"in"},Feet:{metersPerUnit:1/3.28084,suffix:"ft"}};function pt(e){let r=e&&Re[e]||Re.Meters;return t=>`${(t/r.metersPerUnit).toPrecision(3)} ${r.suffix}`}function ft(e){let r=e.object;return r instanceof S.Mesh?e.face?[e.face.a,e.face.b,e.face.c]:null:r instanceof S.Points?e.index!=null?[e.index]:null:r instanceof S.Line&&e.index!=null?[e.index,e.index+1]:null}function Et(e,r,t,n){let a=e.point.clone(),o=e.object,i=ft(e);if(!i||!o.geometry)return a;let l=o.geometry.attributes.position;if(!l)return a;let s=m=>{let p=m.clone().project(r);return new S.Vector2((p.x+1)/2*t.width,(1-p.y)/2*t.height)},c=s(a),d=a,u=n;for(let m of i){if(m>=l.count)continue;let E=new S.Vector3().fromBufferAttribute(l,m).applyMatrix4(o.matrixWorld),A=s(E).distanceTo(c);A<u&&(u=A,d=E)}return d}function Te(e){let{canvas:r,scene:t,getActiveCamera:n,labelLayer:a,options:o={}}=e,i=o.snapPixels??ut,l=new S.Color(o.color??dt),s=pt(o.displayUnit),c=(h,w)=>`${s(h)}
|
|
54
|
-
\u0394x ${s(w.x)} \u0394y ${s(w.y)} \u0394z ${s(w.z)}`,d=o.format??c,u=new S.Raycaster,m=new S.Vector2,p=!1,E=[],A=[],v=null,g=null,R=new S.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),y=new S.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),H=null,O=h=>{if(!h){H&&(H.visible=!1);return}if(!H){let w=new S.BufferGeometry;w.setAttribute("position",new S.Float32BufferAttribute([0,0,0],3)),H=new S.Points(w,y),H.renderOrder=1e3,H.userData.id="measure",H.raycast=()=>{},t.add(H)}H.position.copy(h),H.visible=!0},b=h=>{let w=new S.BufferGeometry;w.setAttribute("position",new S.Float32BufferAttribute([h.x,h.y,h.z],3));let V=new S.Points(w,R);return V.renderOrder=999,V.userData.id="measure",V.raycast=()=>{},t.add(V),V},T=()=>{E.length=0,A.forEach(h=>{h.geometry.dispose(),h.removeFromParent()}),A.length=0,v&&(v.geometry.dispose(),v.material.dispose(),v.removeFromParent(),v=null),g?.remove(),g=null},x=()=>{if(E.length!==2)return;let[h,w]=E,V=new lt;V.setPositions([h.x,h.y,h.z,w.x,w.y,w.z]);let Y=new ct({color:l});Y.linewidth=2,Y.depthTest=!1,v=new st(V,Y),v.renderOrder=998,v.userData.id="measure",v.raycast=()=>{},t.add(v);let X=h.clone().add(w).multiplyScalar(.5),$=new S.Vector3(Math.abs(w.x-h.x),Math.abs(w.y-h.y),Math.abs(w.z-h.z));g=a.addLabel(d(h.distanceTo(w),$),X,o.labelClassName)},P=h=>{let w=r.getBoundingClientRect();m.x=(h.clientX-w.left)/w.width*2-1,m.y=-((h.clientY-w.top)/w.height)*2+1;let V=n();u.setFromCamera(m,V);let X=V.position.length()*mt;u.params.Line.threshold=X,u.params.Points.threshold=X;let $=u.intersectObjects(t.children,!0).filter(q=>q.object.userData.id!=="measure"&&q.object.userData.id!=="grid");return $.length===0?null:Et($[0],V,{width:w.width,height:w.height},i)};return{setEnabled:h=>{p=h,h||(T(),O(null))},isEnabled:()=>p,handleClick:h=>{if(!p)return!1;E.length===2&&T();let w=P(h);return w===null||(E.push(w),A.push(b(w)),E.length===2&&x()),!0},handleMove:h=>{p&&O(P(h))},clear:T,dispose:()=>{T(),H&&(H.geometry.dispose(),H.removeFromParent(),H=null),R.dispose(),y.dispose()}}}import*as f from"three";import{OrbitControls as ht}from"three/addons/controls/OrbitControls.js";import{HDRLoader as gt}from"three/addons/loaders/HDRLoader.js";var te=new f.Vector3(0,0,1);function yt(e){let r=Math.abs(e.x),t=Math.abs(e.y),n=Math.abs(e.z);return n>=r&&n>=t?"z":t>=r&&t>=n?"y":"x"}var gr=function(e,r){let t=bt(r||{}),n=t.environment?.sceneUp||te,a=Ht(t),o=St(t,e);o.up.copy(n);let i=Dt(e,t),l=Pt(o,e,t),s=me({scene:a,perspective:o,controls:l,onActiveCameraChange:()=>{},up:n}),c=()=>s.getActiveCamera();xt(a,t);let d=Ct(a,t),u=()=>{d&&wt(d,ae(a))};t.floor?.enabled&&At(a,t);let m=t.grid.enabled?pe({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;m&&a.add(m.object);let p=t.gizmo.enabled?fe({camera:o,domElement:e,controller:s}):null,E=e.parentElement??e,A=t.measure.enabled?be(E,a):null,v=t.measure.enabled&&A?Te({canvas:e,scene:a,getActiveCamera:c,labelLayer:A,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,g=t.events.enableEventHandlers!==!1?Lt(e,a,c,o,l,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},R=5,y=0,H=0,O=M=>{y=M.clientX,H=M.clientY},b=M=>Math.hypot(M.clientX-y,M.clientY-H)>R,T=M=>{if(!b(M)){if(v?.handleClick(M)){M.stopImmediatePropagation();return}p?.handleClick(M)&&M.stopImmediatePropagation()}};(p||v)&&(e.addEventListener("mousedown",O,{capture:!0}),e.addEventListener("click",T,{capture:!0}));let x=M=>v?.handleMove(M);v&&e.addEventListener("mousemove",x,{passive:!0});let P=M=>{he(M,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle})},D=e.parentElement,F=()=>D?{width:D.clientWidth,height:D.clientHeight}:{width:window.innerWidth,height:window.innerHeight},h=null,w=()=>{let{width:M,height:B}=F(),N=Math.min(window.devicePixelRatio,2),Q=ge(i,a,c(),Math.max(1,M),Math.max(1,B),{toneMapping:t.render.toneMapping??f.NeutralToneMapping,toneMappingExposure:t.render.toneMappingExposure??1,aoIntensity:t.render.aoIntensity});return Q.setSize(Math.max(1,M),Math.max(1,B),N),Q},V=M=>{M&&!h?h=w():!M&&h&&(h.dispose(),h=null)};t.render.ambientOcclusion&&(h=w());let{animate:Y,dispose:X}=Mt(i,a,o,c,s,l,F,t.events.onFrame,m,p,()=>h,A);Y(),a.up.set(n.x,n.y,n.z),u();let $=M=>{M.traverse(B=>{let N=B;!N.geometry&&!N.material||(N.geometry?.dispose(),Array.isArray(N.material)?N.material.forEach(Q=>Q.dispose()):N.material?.dispose())})},q=M=>{M.userData.source="user",a.add(M)},Oe=M=>{M.removeFromParent(),$(M)},Ie=()=>{a.children.filter(B=>B.userData.source==="user").forEach(B=>{B.removeFromParent(),$(B)})};return{scene:a,camera:o,controls:l,renderer:i,cameraController:s,grid:m,gizmo:p,measureTool:v,applyEdges:P,setAmbientOcclusion:V,updateShadowBounds:u,dispose:()=>{X(),g.dispose(),(p||v)&&(e.removeEventListener("mousedown",O,{capture:!0}),e.removeEventListener("click",T,{capture:!0})),v&&e.removeEventListener("mousemove",x),v?.dispose(),A?.dispose(),p?.dispose(),m?.dispose(),h?.dispose(),l.dispose(),i.dispose(),a.traverse(M=>{let B=M;!B.geometry&&!B.material||(B.geometry?.dispose(),Array.isArray(B.material)?B.material.forEach(N=>N.dispose()):B.material?.dispose())}),a.environment?.dispose(),a.background instanceof f.Texture&&a.background.dispose()},fitToView:g.fitToView,clearSelection:g.clearSelection,addUserGeometry:q,removeUserGeometry:Oe,clearUserGeometry:Ie}};function bt(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r];return{sceneScale:r,camera:{position:e.camera?.position||new f.Vector3(-n.cameraDistance,-n.cameraDistance,n.cameraDistance),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new f.Vector3(0,0,0)},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??1,sunlightPosition:e.lighting?.sunlightPosition||new f.Vector3(n.lightDistance,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new f.Color(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??1,sunlightColor:e.lighting?.sunlightColor||16777215},environment:{hdrPath:e.environment?.hdrPath||"/baseHDR.hdr",backgroundColor:e.environment?.backgroundColor||new f.Color(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||te,showEnvironment:e.environment?.showEnvironment??!1},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new f.Color(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||2048,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping||f.NeutralToneMapping,toneMappingExposure:e.render?.toneMappingExposure??1,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,ambientOcclusion:e.render?.ambientOcclusion??!1,aoIntensity:e.render?.aoIntensity??1},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??yt(e.environment?.sceneUp??te)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color??2236962,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??30},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||"#ff0000",enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame}}}var Rt=new Set(["grid","floor","label-layer","measure"]);function Tt(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&Rt.has(r.userData.id))return!0;r=r.parent}return!1}function ae(e){let r=new f.Box3;return e.traverse(t=>{let n=t;t.visible&&!Tt(t)&&n.geometry&&r.expandByObject(t)}),r}function wt(e,r){if(r.isEmpty())return;let t=r.getCenter(new f.Vector3),n=r.getSize(new f.Vector3).length()*.5*1.2,a=e.shadow.camera;a.left=-n,a.right=n,a.top=n,a.bottom=-n,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);a.near=Math.max(n*.01,o-n),a.far=o+n,a.updateProjectionMatrix()}function Ht(e){let r=new f.Scene,t=typeof e.environment.backgroundColor=="string"?new f.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function vt(e,r,t,n,a=200){let o=e.position.clone(),i=r.target.clone(),l=performance.now(),s=d=>1-Math.pow(1-d,3),c=()=>{let d=performance.now()-l,u=s(Math.min(d/a,1));e.position.lerpVectors(o,t,u),r.target.lerpVectors(i,n,u),r.update(),u<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}function Mt(e,r,t,n,a,o,i,l,s,c,d,u){let m=null,p=performance.now(),E=()=>{let{width:g,height:R}=i();if(g===0||R===0)return;let y=Math.min(window.devicePixelRatio,2),H=Math.round(g*y),O=Math.round(R*y);(e.domElement.width!==H||e.domElement.height!==O)&&(e.setPixelRatio(y),e.setSize(g,R,!1),t.aspect=g/R,t.updateProjectionMatrix(),a.updateAspect(g,R),d?.()?.setSize(g,R,y),u?.setSize(g,R))},A=function(){m=requestAnimationFrame(A);let g=performance.now(),R=(g-p)/1e3;p=g,E(),(o.enableDamping||o.autoRotate)&&o.update(),s&&s.update(n().position),c&&c.update(R),l?.(R);let y=n(),H=d?.();H?(H.setCamera(y),H.render(R)):e.render(r,y),u&&u.render(r,y),c&&c.render(e)};return{animate:A,dispose:()=>{m!==null&&(cancelAnimationFrame(m),m=null)}}}function xt(e,r){r.environment.enableEnvironmentLighting?new gt().load(r.environment.hdrPath||"/baseHDR.hdr",function(t){if(!t?.image){C().warn("HDR loaded without image data; skipping environment map."),r.events.onReady?.();return}t.mapping=f.EquirectangularReflectionMapping,e.environment=t,r.environment.showEnvironment&&(e.background=t),r.events.onReady?.()},void 0,function(t){C().warn("HDR texture could not be loaded, falling back to basic lighting:",t),r.events.onReady?.()}):r.events.onReady?.()}function Ct(e,r){let t=new f.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);if(e.add(t),!r.lighting.enableSunlight)return null;let n=new f.DirectionalLight(r.lighting.sunlightColor??16777215,r.lighting.sunlightIntensity),a=r.lighting.sunlightPosition;return a&&n.position.set(a.x,a.y,a.z),r.render.enableShadows?(n.castShadow=!0,n.shadow.mapSize.width=r.render.shadowMapSize||2048,n.shadow.mapSize.height=r.render.shadowMapSize||2048,n.shadow.bias=-1e-4,n.shadow.normalBias=.02,n.shadow.radius=4,e.add(n),e.add(n.target),n):(e.add(n),null)}function At(e,r){let t=r.floor.size,n=new f.PlaneGeometry(t,t),a=typeof r.floor.color=="string"?new f.Color(r.floor.color):r.floor.color,o=new f.MeshStandardMaterial({color:a,roughness:r.floor.roughness,metalness:r.floor.metalness,side:f.DoubleSide}),i=new f.Mesh(n,o);i.userData.id="floor",i.name="floor";let l=(r.environment?.sceneUp||te).clone().normalize();i.quaternion.setFromUnitVectors(new f.Vector3(0,0,1),l),i.position.set(0,0,0),r.floor.receiveShadow&&r.render.enableShadows&&(i.receiveShadow=!0),e.add(i)}function St(e,r){let t=r.parentElement,n=t?t.clientWidth:window.innerWidth,a=t?t.clientHeight:window.innerHeight,o=new f.PerspectiveCamera(e.camera.fov,n/a,e.camera.near,e.camera.far),i=e.camera.position;return i&&o.position.set(i.x,i.y,i.z),o}function Dt(e,r){let t=new f.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!0}),n=e.parentElement,a=n?n.clientWidth:window.innerWidth,o=n?n.clientHeight:window.innerHeight;return n&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),t.setSize(a,o,!1),t.setPixelRatio(r.render.pixelRatio||Math.min(window.devicePixelRatio,2)),r.render.enableShadows&&(t.shadowMap.enabled=!0,t.shadowMap.type=f.VSMShadowMap),t.toneMapping=r.render.toneMapping,t.toneMappingExposure=r.render.toneMappingExposure??1,t.outputColorSpace=f.SRGBColorSpace,t.sortObjects=!0,t}function Lt(e,r,t,n,a,o){let i=new Set,l=new Map,s=new f.Raycaster,c=new f.Vector2,d=new f.Vector2,u=b=>{let T=b;for(;T;){if(!T.visible)return!1;T=T.parent}return!0},m=()=>{let b=ae(r);if(b.isEmpty()){C().warn("No objects to fit to view");return}let T=b.getCenter(new f.Vector3),x=b.getSize(new f.Vector3),P=Math.max(x.x,x.y,x.z),D=n.fov*(Math.PI/180),F=P/(2*Math.tan(D/2));F*=1.5;let h=n.position.clone().sub(a.target);h.lengthSq()<1e-12&&h.set(.8,1,1.2),h.normalize(),n.position.copy(T.clone().add(h.multiplyScalar(F))),a.target.copy(T),a.update()},p=typeof o.events.selectionColor=="string"?new f.Color(o.events.selectionColor):o.events.selectionColor instanceof f.Color?o.events.selectionColor:new f.Color("#ff0000"),E=()=>{i.forEach(b=>{let T=b;if(l.has(b)){let x=l.get(b),P=T.material;P instanceof f.Material?P.dispose():Array.isArray(P)&&P.forEach(D=>D.dispose()),T.material=x,l.delete(b)}}),i.clear()},A=b=>{let T=b;if(!(T.material instanceof f.Material))return!1;l.set(b,T.material);let x=T.material.clone();return b instanceof f.Mesh&&"emissive"in x?x.emissive=p.clone():"color"in x&&(x.color=p.clone()),T.material=x,!0},v=()=>{let b=ae(r),T=b.isEmpty()?1:b.getSize(new f.Vector3).length();s.params.Points.threshold=T*.01},g=b=>{d.set(b.clientX,b.clientY)},R=b=>{let T=new f.Vector2(b.clientX,b.clientY);if(d.distanceTo(T)>5)return;let x=e.getBoundingClientRect();c.x=(b.clientX-x.left)/x.width*2-1,c.y=-((b.clientY-x.top)/x.height)*2+1,v(),s.setFromCamera(c,t());let P=s.intersectObjects(r.children,!0).filter(D=>u(D.object));if(P.length>0){let D=P[0].object;i.has(D)||(E(),i.add(D),A(D),o.events?.onObjectSelected?.(D),D instanceof f.Mesh&&Object.keys(D.userData).length>0&&o.events?.onMeshMetadataClicked?.(D.userData))}else E(),o.events?.onBackgroundClicked?.({x:c.x,y:c.y})},y=b=>{let T=e.getBoundingClientRect();c.x=(b.clientX-T.left)/T.width*2-1,c.y=-((b.clientY-T.top)/T.height)*2+1,v(),s.setFromCamera(c,t());let x=s.intersectObjects(r.children,!0).filter(q=>u(q.object));if(x.length===0)return;let P=x[0].object;if(o.events?.onMeshDoubleClicked?.(P),!o.events?.enableDoubleClickZoom)return;let D=new f.Box3().setFromObject(P);if(D.isEmpty())return;let F=D.getCenter(new f.Vector3),h=D.getSize(new f.Vector3),w=Math.max(h.x,h.y,h.z),V=n.fov*(Math.PI/180),Y=w/(2*Math.tan(V/2))*1.5,X=n.position.clone().sub(a.target).normalize(),$=F.clone().add(X.multiplyScalar(Y));vt(n,a,$,F)},H=b=>{if(o.events?.enableKeyboardControls)switch(b.key.toLowerCase()){case"f":b.preventDefault(),m();break;case"escape":b.preventDefault(),E();break;case" ":b.preventDefault(),m();break}};return o.events?.enableClickToFocus&&(e.addEventListener("mousedown",g),e.addEventListener("click",R),e.addEventListener("dblclick",y)),o.events?.enableKeyboardControls&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",H)),{dispose:()=>{e.removeEventListener("mousedown",g),e.removeEventListener("click",R),e.removeEventListener("dblclick",y),e.removeEventListener("keydown",H),E()},fitToView:m,clearSelection:E}}function Pt(e,r,t){let n=new ht(e,r),a=t.camera.target;return a&&n.target.set(a.x,a.y,a.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=t.controls.enableZoom??!0,n.enablePan=t.controls.enablePan??!0,n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}var jt={};Ve(jt,{CONCRETE_MATERIAL:()=>Vt,EMISSIVE_MATERIAL:()=>Ot,GLASS_MATERIAL:()=>Ft,METAL_MATERIAL:()=>It,PLASTIC_MATERIAL:()=>Bt,RUBBER_MATERIAL:()=>zt,WOOD_MATERIAL:()=>Ut});import*as L from"three";var Ot=new L.MeshPhysicalMaterial({color:0,emissive:new L.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),It=new L.MeshPhysicalMaterial({color:new L.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),Vt=new L.MeshPhysicalMaterial({color:new L.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:.5,depthTest:!0,polygonOffset:!0,side:L.FrontSide,dithering:!0}),Bt=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ft=new L.MeshPhysicalMaterial({color:new L.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,opacity:.3,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:L.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),zt=new L.MeshPhysicalMaterial({color:new L.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ut=new L.MeshPhysicalMaterial({color:new L.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:L.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});import*as _ from"three";import{Line2 as kt}from"three/addons/lines/Line2.js";import{LineGeometry as _t}from"three/addons/lines/LineGeometry.js";import{LineMaterial as Gt}from"three/addons/lines/LineMaterial.js";function ne(e,r,t,n=!0){return{x:e,y:r,z:t}}var Nt="#ffffff",we=12,Wt=4e-4,$t=12,Yt=.05;function He(e,r={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:n=!0}=r,a=[];for(let o of e)switch(o.kind){case"curve":{let i=qt(o,t,n);i&&a.push(i);break}case"point":{a.push(Zt(o,n));break}default:{let i=o;C().warn(`Skipping unknown display item kind: ${String(i.kind)}`);break}}return a}var Xt=2;function qt(e,r,t){if(!r)return C().warn("No rhino3dm instance provided; skipping curve display item."),null;let n=Jt(e.json,r);if(!n)return null;let a=Kt(n,t);if(a.length<2)return null;let o=[];for(let u of a)o.push(u.x,u.y,u.z);let i=new _t;i.setPositions(o);let l=ve(e.color,e.opacity),s=new Gt({color:l.color}),c=s;c.linewidth=e.width??Xt,c.transparent=l.transparent,c.opacity=l.opacity;let d=new kt(i,s);return d.computeLineDistances(),d.name=e.name,d.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},d}function Zt(e,r){let{x:t,y:n,z:a}=ne(e.position.X,e.position.Y,e.position.Z,r),o=new _.BufferGeometry;o.setAttribute("position",new _.Float32BufferAttribute([t,n,a],3));let i=new _.PointsMaterial({...ve(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new _.Points(o,i);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function Jt(e,r){try{let t=JSON.parse(e),n=r.CommonObject.decode(t);return n&&typeof n.pointAt=="function"?n:(C().warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return C().warn("Failed to decode curve display item JSON:",t),null}}function Kt(e,r){let t=Qt(e,r);return t||en(e,r)}function Qt(e,r){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),n=Array.isArray(t)?t[1]:t;if(!n||typeof n.count!="number"||n.count<2)return null;let a=[];for(let o=0;o<n.count;o++){let i=n.get(o),{x:l,y:s,z:c}=ne(i[0],i[1],i[2],r);a.push(new _.Vector3(l,s,c))}return a}function en(e,r){let t=e.domain,n=t[0],o=t[1]-n,i=u=>{let m=e.pointAt(u),{x:p,y:E,z:A}=ne(m[0],m[1],m[2],r);return new _.Vector3(p,E,A)},l=tn(e),s=n,c=i(n),d=[c];for(let u=0;u<we;u++){let m=n+o*(u+1)/we,p=i(m);ie(s,c,m,p,i,l,$t,d),d.push(p),s=m,c=p}return d}function ie(e,r,t,n,a,o,i,l){if(i<=0)return;let s=(e+t)/2,c=a(s),d=rn(c,r,n),u=nn(r,c,n);d<=o&&u<=Yt||(ie(e,r,s,c,a,o,i-1,l),l.push(c),ie(s,c,t,n,a,o,i-1,l))}function tn(e){let r=e.getBoundingBox(),t=r.min,n=r.max,a=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]);return Math.max(a*Wt,1e-6)}function nn(e,r,t){let n=r.clone().sub(e),a=t.clone().sub(r),o=n.length(),i=a.length();if(o===0||i===0)return 0;let l=Math.max(-1,Math.min(1,n.dot(a)/(o*i)));return Math.acos(l)}function rn(e,r,t){let n=t.clone().sub(r),a=n.lengthSq();if(a===0)return e.distanceTo(r);let o=Math.max(0,Math.min(1,e.clone().sub(r).dot(n)/a)),i=r.clone().addScaledVector(n,o);return e.distanceTo(i)}function ve(e,r){let t=r??1;return{color:new _.Color(e??Nt),transparent:t<1,opacity:t}}import{inflateSync as on}from"fflate";var Me=1096174675,an=1515605075,xe=3,Ce=1,se=1,sn=2,ln=4,Ae=12,Se=56;function le(e){let r=un(cn(e)),t=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<Ae)throw G("Blob too small to contain SLVA header.",{expectedBytes:Ae,availableBytes:r.byteLength});let n=0,a=t.getUint32(n,!0);if(n+=4,a!==Me)throw G(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${Me.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=t.getUint32(n,!0);if(n+=4,o<Ce||o>xe)throw G(`Unsupported SLVA version: ${o}`,{minSupportedVersion:Ce,maxSupportedVersion:xe,actualVersion:o});let i=t.getUint32(n,!0);if(n+=4,n+i>r.byteLength)throw G("Insufficient data to read metadata JSON.",{expectedBytes:i,availableBytes:r.byteLength-n,offset:n});let l=r.subarray(n,n+i);n+=i;let s;try{s=JSON.parse(dn(l))}catch(w){throw G(`Failed to parse metadata JSON: ${w instanceof Error?w.message:String(w)}`,{metadataLen:i})}if(n+Se>r.byteLength)throw G("Insufficient data to read geometry header.",{expectedBytes:Se,availableBytes:r.byteLength-n,offset:n});let c=t.getUint32(n,!0);n+=4;let d=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let m=t.getFloat64(n,!0);n+=8;let p=t.getFloat64(n,!0);n+=8;let E=t.getFloat64(n,!0);n+=8;let A=t.getFloat64(n,!0);n+=8;let v=t.getUint32(n,!0);n+=4;let g=(c&se)!==0,R=(c&ln)!==0,y=v*3,O=y*(g?4:2);if(n+O>r.byteLength)throw G("Insufficient data to read vertices.",{expectedBytes:O,availableBytes:r.byteLength-n,offset:n,useFloat32:g,vertexCount:v});let b=r.byteOffset+n,T;if(g?T=pn(r.buffer,b,y):R?T=En(De(r.buffer,b,y)):T=mn(r.buffer,b,y),n+=O,n+4>r.byteLength)throw G("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-n,offset:n});let x=t.getUint32(n,!0);n+=4;let P=(c&sn)!==0,F=x*(P?2:4);if(n+F>r.byteLength)throw G("Insufficient data to read indices.",{expectedBytes:F,availableBytes:r.byteLength-n,offset:n,indexCount:x,useUint16Indices:P});let h=P?De(r.buffer,r.byteOffset+n,x):fn(r.buffer,r.byteOffset+n,x);return R&&(h=h instanceof Uint16Array?hn(h):gn(h)),{metadata:s,flags:c,vertices:T,indices:h,origin:[d,u,m],scale:[p,E,A]}}function cn(e){return typeof e=="string"?ce(e):e instanceof Uint8Array?e:new Uint8Array(e)}function un(e){if(e.byteLength<8)return e;let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r.getUint32(0,!0)!==an)return e;let t=r.getUint32(4,!0),n=e.subarray(8),a=Math.max(n.byteLength*1032+1024,1<<20);if(t>a)throw G("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:a});try{return on(n,{out:new Uint8Array(t)})}catch(o){throw G(`Failed to inflate SLVZ blob: ${o instanceof Error?o.message:String(o)}`,{uncompressedLen:t,deflatedBytes:n.byteLength})}}function dn(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new oe("No UTF-8 decoder available in this environment.",re.INVALID_STATE)}function mn(e,r,t){if(t===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Int16Array(n.buffer)}function pn(e,r,t){if(t===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Float32Array(n.buffer)}function De(e,r,t){if(t===0)return new Uint16Array(0);if(r%2===0)return new Uint16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Uint16Array(n.buffer)}function fn(e,r,t){if(t===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Uint32Array(n.buffer)}function K(e){return e>>>1^-(e&1)}function En(e){let r=new Int16Array(e.length),t=0,n=0,a=0;for(let o=0;o<e.length;o+=3)t=t+K(e[o])<<16>>16,n=n+K(e[o+1])<<16>>16,a=a+K(e[o+2])<<16>>16,r[o]=t,r[o+1]=n,r[o+2]=a;return r}function hn(e){let r=new Uint16Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+K(e[n])&65535,r[n]=t;return r}function gn(e){let r=new Uint32Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+K(e[n])>>>0,r[n]=t;return r}function G(e,r){return new oe(e,re.VALIDATION_ERROR,{context:r})}import*as U from"three";async function Le(e,r){let{debug:t=!1}=r??{},n=t?performance.now():0;try{let a=performance.now(),o=JSON.parse(e),i=performance.now()-a;return await yn(o,r,{parseTime:i,perfStart:n})}catch(a){return C().error("Error parsing mesh batch:",a),[]}}async function yn(e,r,t){let{mergeByMaterial:n=!0,applyTransforms:a=!0,debug:o=!1}=r??{},{parseTime:i=0,perfStart:l=o?performance.now():0}=t??{};try{let s=performance.now(),c=le(e.compressedData),d=performance.now()-s,u=o?vn(e.compressedData):0;return Pe(c,{mergeByMaterial:n,applyTransforms:a,debug:o,parseTime:i,decodeTime:d,perfStart:l,blobBytes:u,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}catch(s){return C().error("Error parsing mesh batch object:",s),[]}}async function Or(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:a=!1}=r??{},o=a?performance.now():0;try{let i=performance.now(),l=le(e),s=performance.now()-i,c=e.byteLength;return Pe(l,{mergeByMaterial:t,applyTransforms:n,debug:a,parseTime:0,decodeTime:s,perfStart:o,blobBytes:c})}catch(i){return C().error("Error parsing mesh batch blob:",i),[]}}function Pe(e,r){let{mergeByMaterial:t,applyTransforms:n,debug:a,parseTime:o,decodeTime:i,perfStart:l,blobBytes:s,fallback:c}=r,d=e.metadata.materials??c?.materials??[],u=e.metadata.groups??c?.groups??[],m=c?.sourceComponentId??e.metadata.sourceComponentId,p=(e.flags&se)!==0,E=p?Rn(e.vertices,n):bn(e.vertices,e.origin,e.scale,n);if(a){let y=e.vertices.byteLength+e.indices.byteLength;C().debug("Mesh Batch Stats:"),C().debug(` Materials: ${d.length} | Groups: ${u.length}`),C().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),C().debug(` Format: ${p?"float32":"int16 quantized"}`),C().debug(` Blob: ${(s/1024/1024).toFixed(2)} MB | Geometry on wire: ${(y/1024/1024).toFixed(2)} MB`)}let A=performance.now(),v=d.map(Tn),g=[];for(let y of u)if(t&&y.meshes.length>1){let H=wn(y,E,e.indices,v);H.userData.sourceComponentId=m??null,g.push(H)}else{let H=Hn(y,E,e.indices,v);for(let O of H)O.userData.sourceComponentId=m??null;g.push(...H)}let R=performance.now()-A;if(a){let y=performance.now()-l;C().debug("Performance:"),o>0&&C().debug(` Parse JSON: ${o.toFixed(2)}ms`),C().debug(` Decode binary: ${i.toFixed(2)}ms`),C().debug(` Create Meshes: ${R.toFixed(2)}ms`),C().debug(` Total: ${y.toFixed(2)}ms`)}return Promise.resolve(g)}function bn(e,r,t,n){let a=new Float32Array(e.length),o=r[0],i=r[1],l=r[2],s=t[0],c=t[1],d=t[2];for(let u=0;u<e.length;u+=3)a[u]=o+(e[u]+32767)*s,a[u+1]=i+(e[u+1]+32767)*c,a[u+2]=l+(e[u+2]+32767)*d;return a}function Rn(e,r){return e}function Tn(e){let r=ue(e.color);return new U.MeshPhysicalMaterial({color:r,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,side:U.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0})}function wn(e,r,t,n){let a=0,o=0;for(let E of e.meshes)a+=E.vertexCount,o+=E.indexCount;let i=new Float32Array(a*3),l=new Uint32Array(o),s=0,c=0;for(let E of e.meshes){let A=E.vertexStart*3,v=E.vertexCount*3;i.set(r.subarray(A,A+v),s*3);let g=t.subarray(E.indexStart,E.indexStart+E.indexCount),R=s-E.vertexStart;if(R===0)l.set(g,c);else for(let y=0;y<g.length;y++)l[c+y]=g[y]+R;s+=E.vertexCount,c+=E.indexCount}let d=new U.BufferGeometry;d.setAttribute("position",new U.BufferAttribute(i,3)),d.setIndex(new U.BufferAttribute(l,1)),d.computeVertexNormals();let u=new U.Mesh(d,n[e.materialId]),m=e.meshes[0],p=e.meshes.map(E=>E.name).filter(E=>E&&E.length>0);return u.name=p.length>0?p[0]:`merged_material_${e.materialId}`,u.castShadow=!0,u.receiveShadow=!0,u.userData={source:"compute",name:u.name,layer:m?.layer??"",originalIndex:m?.originalIndex??0,metadata:m?.metadata??{},mergedFrom:e.meshes.slice(1).map(E=>({name:E.name,layer:E.layer,originalIndex:E.originalIndex}))},u}function Hn(e,r,t,n){let a=[];for(let o of e.meshes){let i=o.vertexStart*3,l=o.vertexCount*3,s=r.slice(i,i+l),c=t.subarray(o.indexStart,o.indexStart+o.indexCount),d=new Uint32Array(c.length),u=o.vertexStart;for(let E=0;E<c.length;E++)d[E]=c[E]-u;let m=new U.BufferGeometry;m.setAttribute("position",new U.BufferAttribute(s,3)),m.setIndex(new U.BufferAttribute(d,1)),m.computeVertexNormals();let p=new U.Mesh(m,n[e.materialId]);p.name=o.name,p.userData={source:"compute",name:o.name,layer:o.layer??"",originalIndex:o.originalIndex,metadata:o.metadata??{}},p.castShadow=!0,p.receiveShadow=!0,a.push(p)}return a}function vn(e){return Math.floor(e.length*3/4)}var Mn={Millimeters:1/1e3,Centimeters:1/100,Meters:1,Inches:1/39.37,Feet:1/3.28084},xn="Display";async function Ur(e,r){let t=performance.now(),n=[],{allowScaling:a=!0,allowAutoPosition:o=!0,rhino:i,debug:l=!1,parsing:s={}}=r??{};try{let c=a?Cn(e.modelunits):1;return await An(e,n,c,s,i,l),o&&Pn(n),n}catch(c){throw On(c,n),c}finally{l&&Vn(t)}}function Cn(e){return Mn[e]??1}async function An(e,r,t,n,a,o){for(let i of e.values){let l=i.InnerTree;for(let s in l){let c=l[s];c&&await Sn(c,r,t,n,a,o)}}}async function Sn(e,r,t,n,a,o){for(let i of e){if(!i.type.includes(xn))continue;let l={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},s=await Le(i.data,l),c=He(Dn(i.data),{rhino:a,applyTransforms:l.applyTransforms}),d=[...s,...c];if(t!==1)for(let u of d)u.scale.set(t,t,t);r.push(...d),o&&C().debug(`Extracted ${s.length} meshes and ${c.length} items from batch`)}}function Dn(e){return(typeof e=="string"?Ln(e):e)?.items}function Ln(e){try{return JSON.parse(e)}catch{return}}function Pn(e){if(e.length===0)return;let r=J(e);de(e,r.min.z,"z")}function On(e,r){C().error("An unexpected error occurred:",e),In(r)}function In(e){for(let r of e){let t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}}function Vn(e){let r=performance.now()-e;C().info("Time to process meshes:",`${r.toFixed(2)}ms`)}export{zn as a,ue as b,de as c,J as d,me as e,pe as f,fe as g,ee as h,he as i,et as j,Xn as k,ge as l,be as m,Et as n,Te as o,gr as p,jt as q,He as r,Me as s,xe as t,se as u,ln as v,le as w,Le as x,yn as y,Or as z,Mn as A,Ur as B};
|
|
55
|
-
//# sourceMappingURL=chunk-G3SQHFDY.js.map
|
package/dist/chunk-G5XWFITM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as l,c as h,d as f,e as d,h as U,i as z,k as $,l as A,m as _,n as q,r as N}from"./chunk-FMMK2QTR.js";function p(t,e){if(!t||typeof t!="object")return;let r=t;if(e in r)return r[e];let n=J(r).get(e.toLowerCase());return n===void 0?void 0:r[n]}function L(t,e){if(!t||typeof t!="object")return!1;let r=t;return e in r?!0:J(r).has(e.toLowerCase())}var H=new WeakMap;function J(t){let e=H.get(t);if(!e){e=new Map;for(let r of Object.keys(t)){let n=r.toLowerCase();e.has(n)||e.set(n,r)}H.set(t,e)}return e}function C(t,e){e||typeof window<"u"&&d().warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`)}var Ie="Unable to load grasshopper definition";function xe(t){return t instanceof f?t.code===h.DEFINITION_NOT_CACHED||t.message.includes(Ie):!1}function Y(t,e){if(!e)return;let r=p(t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let o of r){let a=p(o,"innerTree");(!a||Object.keys(a).length===0)&&n.push(p(o,"paramName")??"<unnamed>")}if(n.length===0)return;let s=n.length===r.length?"all":`${n.length}/${r.length}`;d().warn(`Solve returned empty output(s) (${s}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function D(t,e,r){r.debug&&C("solveGrasshopperDefinition",r.suppressBrowserWarning??r.suppressClientSideWarning);let{response:n}=await O(P(e,t),r);return n}async function Q(t,e,r){return r.debug&&C("solveGrasshopperDefinitionWithCacheKey",r.suppressBrowserWarning??r.suppressClientSideWarning),O(P(e,t),r)}async function X(t,e,r,n){n.debug&&C("solveByCacheKey",n.suppressBrowserWarning??n.suppressClientSideWarning);let s={algo:null,pointer:e,values:t};try{return{...await O(s,n),missed:!1}}catch(o){if(!xe(o))throw o;return{...await O(P(r,t),n),missed:!0}}}async function O(t,e){De(t,e);let r=await A("grasshopper",t,e);if("pointer"in r){let{pointer:n,...s}=r,o=s;return Y(o,e.debug),{response:o,cacheKey:typeof n=="string"?n:null}}return Y(r,e.debug),{response:r,cacheKey:null}}function P(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=$(t):/^https?:\/\//i.test(t)?r.pointer=t:z(t)?r.algo=t:r.algo=U(t),r}function De(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function Pe(t){let e=new WeakSet,r=n=>{if(n==null)return JSON.stringify(n);if(typeof n=="number")return Number.isFinite(n)?String(n):JSON.stringify(null);if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return JSON.stringify(n.toString());if(n instanceof Uint8Array){let s=n.length>64?Array.from(n.slice(0,32)).concat(Array.from(n.slice(-32))):Array.from(n);return JSON.stringify({__u8:!0,len:n.length,sample:s})}return Array.isArray(n)?`[${n.map(r).join(",")}]`:typeof n=="object"?e.has(n)?JSON.stringify("[Circular]"):(e.add(n),`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`):JSON.stringify(null)};return r(t)}function Z(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ee(t){return Z(t.length,e=>t.charCodeAt(e))}function Re(t){return Z(t.length,e=>t[e])}function te(t,e){return ee(`${W(t)}|${Pe(e)}`)}function W(t){return typeof t=="string"?`s:${t.length}:${ee(t)}`:`u8:${t.length}:${Re(t)}`}var we=100;function Ee(t){return t instanceof Uint8Array?!0:!/^https?:\/\//i.test(t)}var S=class{constructor(e,r,n={},s){l(this,"executor");l(this,"baseConfig");l(this,"mode");l(this,"maxConcurrent");l(this,"timeoutMs");l(this,"retry");l(this,"cacheEnabled");l(this,"cacheMax");l(this,"cacheTtl");l(this,"cache",new Map);l(this,"cacheKeyExecutor");l(this,"reuseServerDefinitionCache");l(this,"serverCacheKeys",new Map);l(this,"onStart");l(this,"onSettle");l(this,"onSuperseded");l(this,"subscribers",new Set);l(this,"inFlight",new Set);l(this,"pendingForLatestWins",null);l(this,"fifoQueue",[]);l(this,"_lastResult",null);l(this,"_lastError",null);l(this,"_lastDurationMs",null);l(this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=s,this.baseConfig=r,this.mode=n.mode??"latest-wins",this.maxConcurrent=Math.max(1,n.maxConcurrent??(this.mode==="parallel"?4:1)),this.timeoutMs=n.timeoutMs,this.retry=n.retry;let o=n.cache;this.cacheEnabled=o!==void 0&&o!==!1;let a=typeof o=="object"?o:{};this.cacheMax=a.maxEntries??50,this.cacheTtl=a.ttlMs??0,this.reuseServerDefinitionCache=!!s&&(n.reuseServerDefinitionCache??!0),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){d().error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new f("SolveScheduler has been disposed and cannot be used",h.INVALID_STATE));let s=te(e,r),o={key:s,enqueuedAt:Date.now(),startedAt:null};if(this.cacheEnabled){let a=this.readCache(s);if(a){let i={status:"success",response:a,durationMs:0,fromCache:!0};return this._lastResult=a,this._lastError=null,this._lastDurationMs=0,this.runHook(this.onStart,o),this.runHook(this.onSettle,o,i),this.notify(),Promise.resolve(a)}}return new Promise((a,i)=>{let u={definition:e,dataTree:r,ctx:o,resolve:a,reject:i,externalSignal:n?.signal};if(u.externalSignal?.aborted){this.settleError(u,this.makeAbortError(o));return}this.enqueue(u)})}enqueue(e){switch(this.mode){case"latest-wins":{this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let r of this.inFlight)this.supersede(r),r.controller.abort();this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.fifoQueue.push(e);break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now();let s=()=>r.abort();e.externalSignal?.addEventListener("abort",s,{once:!0}),this.runHook(this.onStart,e.ctx),this.notify();let o=performance.now();try{let a={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:i,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,a),c=performance.now()-o;if(this.cacheEnabled&&this.writeCache(e.ctx.key,i),!this.settleSuccess(e,i))return;this._lastResult=i,this._lastError=null,this._lastDurationMs=c,this.runHook(this.onSettle,e.ctx,{status:"success",response:i,durationMs:c,fromCache:!1,definitionReuploaded:u})}catch(a){let i=performance.now()-o,u=this.normalizeExecutionError(a,n);this._lastError=u,this._lastDurationMs=i,this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:i})}finally{e.externalSignal?.removeEventListener("abort",s),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Ee(e))return{response:await this.executor(e,r,n)};let s=W(e),o=this.serverCacheKeys.get(s)??null,a=await this.cacheKeyExecutor(e,r,o,n);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>we;){let i=this.serverCacheKeys.keys().next().value;if(i===void 0)break;this.serverCacheKeys.delete(i)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new f("Superseded by newer solve",h.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new f("Request aborted by caller",h.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},e.resolve(r),!0)}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof f?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new f(e instanceof Error?e.message:String(e),h.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?performance.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){this.settleError(e,this.makeAbortError(e.ctx))}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled)for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){d().error("[SolveScheduler] hook threw:",n)}}};var R=class t{constructor(e){l(this,"config");l(this,"serverStats");l(this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new q(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(e.retry?.attempts??2)+1),s=e.retry?.baseDelayMs??250,o=e.retry?.maxDelayMs??1e3;for(let a=0;a<n;a++){if(await r.serverStats.isServerOnline())return r;if(a<n-1){let i=Math.min(s*2**a,o);await new Promise(u=>setTimeout(u,i))}}throw await r.dispose(),new f("Rhino Compute server is not online",h.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),F(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),w(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!e?.trim())throw new f("Definition URL/content is required",h.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new f("Definition content is empty",h.INVALID_INPUT);let s={...this.config,...n?.signal!==void 0&&{signal:n.signal},...n?.timeoutMs!==void 0&&{timeoutMs:n.timeoutMs},...n?.retry!==void 0&&{retry:n.retry}},o=await D(r,e,s);if(o?.errors&&o.errors.length>0)throw new f(o.errors.join("; ")||"Computation failed",h.COMPUTATION_ERROR,{context:{definition:typeof e=="string"&&e.length<200?e:"...content...",inputs:r,errors:o.errors,warnings:o.warnings}});return o}catch(s){throw this.config.debug&&d().error("Compute failed:",s),s instanceof f?s:new f(s instanceof Error?s.message:String(s),h.COMPUTATION_ERROR,{context:{definition:typeof e=="string"&&e.length<200?e:"...content...",inputs:r},originalError:s instanceof Error?s:new Error(String(s))})}}createScheduler(e){this.ensureNotDisposed();let r=(s,o,a)=>D(o,s,a),n=(s,o,a,i)=>a===null?Q(o,s,i).then(u=>({...u,missed:!1})):X(o,a,s,i);return new S(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new f("GrasshopperClient has been disposed and cannot be used",h.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:_(e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:e.debug??!1,suppressBrowserWarning:e.suppressBrowserWarning??e.suppressClientSideWarning}}};var G=new Map;function re(t,e){G.set(t,e)}re("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});re("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function ve(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function Ae(t){return!t||typeof t!="object"?null:t.data??t.value??null}function ne(t,e,r){let n=ve(e);if(n)try{return n(r,t)}catch(s){d().warn(`Failed to decode Rhino type ${e}:`,s)}try{let s=Ae(t);if(s)return r.CommonObject.decode(s)}catch(s){return d().warn(`Failed to decode ${e} with CommonObject:`,s),{__decodeError:!0,type:e,raw:t}}return t}var I={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ne="Rhino.Geometry.",Oe=["WebDisplay"],Fe="FileData";function se(t){return Oe.some(e=>t.includes(e))}function oe(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n}catch{return t}}function Ge(t,e,r){switch(e){case I.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case I.INT:return Number.parseInt(t,10);case I.DOUBLE:return Number.parseFloat(t);case I.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ne)?ne(t,e,r):t}}function ae(t,e,r,n){if(typeof t!="string")return t;let s=r?oe(t):t;return Ge(s,e,n)}function ke(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function k(t,e){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)e(n)}function ie(t,e=!1,r={}){let{parseValues:n=!0,rhino:s,stringOnly:o=!1}=r,a={},i=new Set;for(let u of t.values)k(u.InnerTree,c=>{if(se(c.type)||o&&c.type!==I.STRING)return;let m=e?c.id:u.ParamName;if(!m)return;let y=ae(c.data,c.type,n,s);m in a?i.has(m)?a[m].push(y):(a[m]=[a[m],y],i.add(m)):a[m]=y});return{values:a}}function ue(t){let e=[];for(let r of t.values)k(r.InnerTree,n=>{if(!n.type.includes(Fe))return;let s=oe(n.data);ke(s)&&e.push(s)});return e}function pe(t,e,r={}){let{parseValues:n=!0,rhino:s,stringOnly:o=!1}=r,a;if("byName"in e?a=t.values.find(u=>u.ParamName===e.byName):a=t.values.find(u=>{let c=!1;return k(u.InnerTree,m=>{m.id===e.byId&&(c=!0)}),c}),!a)return;let i=[];if(k(a.InnerTree,u=>{if("byId"in e&&u.id!==e.byId||se(u.type)||o&&u.type!==I.STRING)return;let c=ae(u.data,u.type,n,s);i.push(c)}),i.length!==0)return i.length===1?i[0]:i}var E=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return ie(this.response,e,r)}getValue(e,r){return pe(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await import("./visualization-SU3XQ35P.js"))}catch(s){throw new f("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",h.INVALID_STATE,{context:{originalError:s instanceof Error?s.message:String(s)}})}return n(this.response,r)}getFileData(){return ue(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await N(n,e,r)}};function le(t){return p(t,"data")}function Me(t){return p(t,"type")}function ce(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(!L(t.default,"innerTree")){let n=`Input "${t.name??"unknown"}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return d().warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=p(t.default,"innerTree")??{};if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={};for(let[s,o]of Object.entries(e))n[s]=o.map(a=>{let i=le(a),u=Me(a);if(typeof i=="string"){if(u==="System.Double"||u==="System.Int32"){let c=Number(i);return Number.isNaN(c)?i:c}if(u==="System.Boolean")return i.toLowerCase()==="true";if(u?.startsWith("Rhino.Geometry"))try{return JSON.parse(i)}catch{return i}}return i});return{schema:{...t,default:n}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(s=>{s&&typeof s=="object"&&L(s,"data")&&r.push(le(s))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var B=/^\{(\d+(?:;\d+)*)?\}$/;function v(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>B.test(r)&&Array.isArray(n))}function x(t,e,r){if(t==null)return t;if(Array.isArray(t)){let s=t.map(e).filter(o=>o!==null);return s.length>0?s:void 0}let n=e(t);return n!==null?n:r?void 0:t}var Ve=t=>{if(typeof t=="number")return t;if(typeof t=="string"){let e=t.trim();if(e==="")return null;let r=Number(e);return Number.isNaN(r)?null:r}return null},Le=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.toLowerCase();if(e==="true")return!0;if(e==="false")return!1;throw new Error(`Invalid boolean string: "${t}"`)}return null},We=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Be=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function me(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(d().warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return d().warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function fe(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function je(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),T=Math.pow(10,-b),K=Number(T.toFixed(b));return Math.abs(K-T)<e?K:T}return 1}let n=String(t),s=n.toLowerCase().match(/e(-?\d+)/);if(s){let y=Number(s[1]);if(y<0||n.toLowerCase().includes("e-")){let g=Math.abs(y),b=Math.pow(10,-g),T=Number(b.toFixed(g));return Math.abs(T-b)<e?T:b}return .1}let o=12,i=r.toFixed(o).replace(/0+$/,""),u=Math.min((i.split(".")[1]||"").length,o);if(u===0)return .1;let c=Math.pow(10,-u),m=Number(c.toFixed(u));return Math.abs(m-c)<e?m:c}function Ke(t,e=1e-8){let r=t.paramType==="Integer";if(v(t.default))return{default:t.default,stepSize:r?1:.1};let n=x(t.default,Ve,!0);if(r)return Array.isArray(n)?n=n.map(m=>typeof m=="number"?Math.round(m):m):typeof n=="number"&&(n=Math.round(n)),{default:n,stepSize:1};let s=Array.isArray(n)?n[0]:n,o;typeof s=="number"&&Number.isFinite(s)&&s!==0?o=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?o=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(o=t.maximum);let a=o!==void 0?je(o,e):.1,i=0,u=String(a),c=u.toLowerCase().match(/e(-?\d+)/);if(c?i=Math.abs(Number(c[1])):i=u.split(".")[1]?.length??0,i===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(i=m)}return i=Math.min(Math.max(i,0),12),Array.isArray(n)?n=n.map(m=>typeof m=="number"?fe(m,i,e):m):typeof n=="number"&&(n=fe(n,i,e)),{default:n,stepSize:a}}var Ue={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ke(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,default:r?[0]:0}}},ze={types:["Boolean"],parse(t,e){let r;try{r=x(t.default,Le,!1)}catch(n){throw n instanceof Error?new f(n.message):n}return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},$e={types:["Text"],parse(t,e){let r=x(t.default,We,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Text",default:r?[""]:""}}},_e={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw f.missingValues(t.nickname||"unnamed","ValueList");if(t.default!==void 0&&t.default!==null){let r=String(t.default).toLowerCase();Object.keys(t.values).some(s=>s.toLowerCase()===r)||d().warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:t.default}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"ValueList",values:t.values??{},default:r?[t.default]:t.default}}},de={types:["Geometry"],parse(t,e){let r=x(t.default,me(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},qe={types:["File"],parse(t,e){let r=x(t.default,me(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"File",default:r?[null]:null}}},He={types:["Color"],parse(t,e){let r=x(t.default,Be,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(t.atMost??1)>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},Je=[Ue,ze,$e,_e,de,qe,He],j=new Map(Je.flatMap(t=>t.types.map(e=>[e,t]))),he=de;var Ye=new Map([...j.keys()].map(t=>[t.toLowerCase(),t]));function Qe(t){return Ye.get(t?.toLowerCase())??t}function ye(t){return ge(t).input}function ge(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:t.groupName??"",id:t.id},r=Qe(t.paramType),{schema:n,warning:s}=ce({...t,paramType:r}),o=s&&{inputName:t.name||"unknown",paramType:r,message:s.message,code:s.code},a=j.get(r);try{if(!a)throw f.unknownParamType(r,t.name);return{input:a.parse(n,e),error:o}}catch(i){if(i instanceof f)return d().error(`Validation error for input ${t.name||"unknown"}:`,i.message),{input:(a??he).fallback(n,e),error:{inputName:t.name||"unknown",paramType:r,message:i.message,code:i.code}};throw new f(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function be(t){return M(t).inputs}function M(t){let e=[],r=[];for(let n of t){let{input:s,error:o}=ge(n);e.push(s),o&&r.push(o)}return{inputs:e,parseErrors:r}}function Te(t){return{id:p(t,"id"),name:p(t,"name"),nickname:p(t,"nickname")??null,description:p(t,"description"),paramType:p(t,"paramType"),treeAccess:p(t,"treeAccess"),minimum:p(t,"minimum")??null,maximum:p(t,"maximum")??null,atLeast:p(t,"atLeast"),atMost:p(t,"atMost"),stepSize:p(t,"stepSize"),default:p(t,"default"),values:p(t,"values"),acceptedFormats:p(t,"acceptedFormats"),groupName:p(t,"groupName")??""}}function Ce(t){return{name:p(t,"name"),nickname:p(t,"nickname")??null,paramType:p(t,"paramType"),id:p(t,"id")}}async function w(t,e){let r=P(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new f("Definition must resolve to either a URL pointer or base64 algo",h.INVALID_INPUT,{context:{definition:t}});let s=await A("io",n,e);if(!s||typeof s!="object")throw new f("Invalid IO response structure",h.INVALID_INPUT,{context:{response:s,definition:t}});let o=Se(p(s,"warnings")),a=Se(p(s,"errors")),i=p(s,"inputs"),u=p(s,"outputs");return{inputs:Array.isArray(i)?i.map(Te):[],outputs:Array.isArray(u)?u.map(Ce):[],...o&&{loadWarnings:o},...a&&{loadErrors:a}}}function Se(t){if(!Array.isArray(t))return;let e=t.filter(r=>typeof r=="string"&&r.trim().length>0);return e.length>0?e:void 0}async function F(t,e){C("fetchParsedDefinitionIO",e.suppressBrowserWarning??e.suppressClientSideWarning);let{inputs:r,outputs:n,loadWarnings:s,loadErrors:o}=await w(t,e),{inputs:a,parseErrors:i}=M(r);return{inputs:a,outputs:n,...i.length>0&&{parseErrors:i},...s&&{loadWarnings:s},...o&&{loadErrors:o}}}var V=class t{constructor(e){l(this,"innerTree");l(this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let s=r.map(o=>({data:t.serializeValue(o)}));return this.innerTree[n].push(...s),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let s=t.parsePathString(r);this.append(s,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(s=>t.deserializeValue(s.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),s=r.default;if(r.treeAccess&&v(s))n.fromDataTreeDefault(s),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let o=Array.isArray(s)?s:[s],a=t.processValues(o,r);n.appendFlat(a)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let s=e.length>0&&e[0]instanceof t,o=t.buildFromValue(r,n);if(s){let c=e,m=c.findIndex(y=>y.getParamName()===r);return m!==-1?c[m]=o:c.push(o),c}let a=e,i=o.toComputeFormat(),u=a.findIndex(c=>c.ParamName===r);return u!==-1?a[u]=i:a.push(i),a}static buildFromValue(e,r){let n=new t(e);return v(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let s=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return s===null||s.length===0?null:s.length===1?s[0]:s}static readFromBuilders(e,r){let n=e.find(s=>s.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(a=>a.ParamName===r);if(!n?.InnerTree)return null;let s=Object.keys(n.InnerTree)[0];if(!s)return null;let o=n.InnerTree[s];return Array.isArray(o)?o.map(a=>a?.data!==void 0?t.deserializeValue(a.data):null).filter(a=>a!==null):o?.data!==void 0?[t.deserializeValue(o.data)]:o!==void 0?[o]:null}static parsePathString(e){let r=e.match(B);return r?r[1]?r[1].split(";").map(Number):[]:(d().warn(`Invalid TreeBuilder path format: ${e}, using [0]`),[0])}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let s of Object.values(this.innerTree))if(Array.isArray(s))for(let o of s){let a=t.deserializeValue(o.data);if(typeof a=="number"){let i=t.clampValue(a,e,r,n);o.data=t.serializeValue(i)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch{return e}return e.trim()!==""&&!isNaN(Number(e))?Number(e):e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,s){let o=e;return r!=null&&o<r&&(d().warn(`${s}: ${e} below min ${r}, clamping`),o=r),n!=null&&o>n&&(d().warn(`${s}: ${e} above max ${n}, clamping`),o=n),o}};export{D as a,S as b,R as c,E as d,ye as e,be as f,w as g,F as h,V as i};
|
|
2
|
-
//# sourceMappingURL=chunk-G5XWFITM.js.map
|