brep-io-kernel 1.0.126 → 1.0.128

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 (24) hide show
  1. package/dist/apiExamples/BREP_Booleans.html +2 -2
  2. package/dist/apiExamples/BREP_Export.html +2 -2
  3. package/dist/apiExamples/BREP_Primitives.html +2 -2
  4. package/dist/apiExamples/BREP_Transforms.html +2 -2
  5. package/dist/apiExamples/Embeded_2D_Sketcher.html +2 -2
  6. package/dist/apiExamples/Embeded_CAD.html +2 -2
  7. package/dist/apiExamples/Embeded_CAD_Integration_Test.html +2 -2
  8. package/dist/assets/{apiExample_BREP_Booleans-C1UfuQjY.js → apiExample_BREP_Booleans-D4kgtViy.js} +1 -1
  9. package/dist/assets/{apiExample_BREP_Export-Piw0SMm4.js → apiExample_BREP_Export-DpMK1JkS.js} +1 -1
  10. package/dist/assets/{apiExample_BREP_Primitives-COMnVA66.js → apiExample_BREP_Primitives-BwOo3cRE.js} +1 -1
  11. package/dist/assets/{apiExample_BREP_Transforms-CqabAhPy.js → apiExample_BREP_Transforms-DMlj9lD8.js} +1 -1
  12. package/dist/assets/{apiExample_Embeded_2D_Sketcher-CWkFuZrK.js → apiExample_Embeded_2D_Sketcher-iRRFKiIs.js} +1 -1
  13. package/dist/assets/{apiExample_Embeded_CAD-BwGc1rq6.js → apiExample_Embeded_CAD-noXGj9pZ.js} +1 -1
  14. package/dist/assets/{apiExample_Embeded_CAD_Integration_Test-jiVEB7AJ.js → apiExample_Embeded_CAD_Integration_Test-Dc_ZxSJ0.js} +1 -1
  15. package/dist/assets/{brep-kernel-DL1UVMTK.js → brep-kernel-B-jYf5J_.js} +1 -1
  16. package/dist/assets/{browserTests-BOgX87Mt.js → browserTests-DRjrmODD.js} +1 -1
  17. package/dist/assets/{main-cad-nX6QBya6.js → main-cad-nInwQVGl.js} +34 -34
  18. package/dist/assets/{test-BRpTlm1Z.js → test-BUMOHzem.js} +3 -3
  19. package/dist/cad.html +1 -1
  20. package/dist/test.html +1 -1
  21. package/dist/viewer.html +1 -1
  22. package/dist-kernel/brep-kernel.js +31 -31
  23. package/package.json +1 -1
  24. package/src/UI/sketcher/SketchMode3D.js +10 -0
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>BREP API Example: Booleans</title>
8
- <script type="module" crossorigin src="/assets/apiExample_BREP_Booleans-C1UfuQjY.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Booleans-D4kgtViy.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
11
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
13
13
  </head>
14
14
  <body>
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>BREP API Example: Export</title>
8
- <script type="module" crossorigin src="/assets/apiExample_BREP_Export-Piw0SMm4.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Export-DpMK1JkS.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
11
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
13
13
  </head>
14
14
  <body>
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>BREP API Example: Primitives</title>
8
- <script type="module" crossorigin src="/assets/apiExample_BREP_Primitives-COMnVA66.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Primitives-BwOo3cRE.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
11
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
13
13
  </head>
14
14
  <body>
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>BREP API Example: Transforms</title>
8
- <script type="module" crossorigin src="/assets/apiExample_BREP_Transforms-CqabAhPy.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Transforms-DMlj9lD8.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
11
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
13
13
  </head>
14
14
  <body>
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>BREP API Example: Embeded 2D Sketcher</title>
8
- <script type="module" crossorigin src="/assets/apiExample_Embeded_2D_Sketcher-CWkFuZrK.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_2D_Sketcher-iRRFKiIs.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
11
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
12
12
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
13
13
  </head>
14
14
  <body>
@@ -31,10 +31,10 @@
31
31
  background: #fff;
32
32
  }
33
33
  </style>
34
- <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD-BwGc1rq6.js"></script>
34
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD-noXGj9pZ.js"></script>
35
35
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
36
36
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
37
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
37
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
38
38
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
39
39
  </head>
40
40
  <body>
@@ -92,10 +92,10 @@
92
92
  }
93
93
  }
94
94
  </style>
95
- <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD_Integration_Test-jiVEB7AJ.js"></script>
95
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD_Integration_Test-Dc_ZxSJ0.js"></script>
96
96
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
98
- <link rel="modulepreload" crossorigin href="/assets/brep-kernel-DL1UVMTK.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-B-jYf5J_.js">
99
99
  <link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
100
100
  </head>
101
101
  <body>
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var o=(e,t)=>E(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as i}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),b=document.getElementById("log"),f=document.getElementById("btn-run"),c=o((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),g=o(e=>Number(e).toFixed(6),"fmt"),u=o((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");b.textContent+=`${t}
1
+ var E=Object.defineProperty;var o=(e,t)=>E(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as i}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),b=document.getElementById("log"),f=document.getElementById("btn-run"),c=o((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),g=o(e=>Number(e).toFixed(6),"fmt"),u=o((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");b.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),s=o(e=>({volume:e.volume(),surfaceArea:e.surfaceArea(),triangles:e.getTriangleCount()}),"summarize"),d=o(()=>{b.textContent="",c("Running...","pending");const e=new i.Cube({x:2.2,y:2.2,z:2.2,name:"Cube"}),t=new i.Sphere({r:1.35,resolution:40,name:"Sphere"}),r=e.union(t),h=e.subtract(t),p=e.intersect(t),n={cube:s(e),sphere:s(t),union:s(r),subtract:s(h),intersect:s(p)};u("--- Boolean Results ---");for(const[v,l]of Object.entries(n))u(`${v.padEnd(10)} volume=${g(l.volume)} area=${g(l.surfaceArea)} triangles=${l.triangles}`);const a=1e-6;if(n.union.volume+a<Math.max(n.cube.volume,n.sphere.volume))throw new Error("Union volume is unexpectedly smaller than both source solids.");if(n.intersect.volume-a>Math.min(n.cube.volume,n.sphere.volume))throw new Error("Intersection volume is unexpectedly larger than a source solid.");if(n.subtract.volume-a>n.cube.volume)throw new Error("Subtract volume is unexpectedly larger than the original cube.");c("Completed","ok")},"runExample");f.addEventListener("click",()=>{try{d()}catch(e){console.error(e),u("ERROR:",e?.stack||e?.message||String(e)),c("Failed","err")}});try{d()}catch(e){console.error(e),u("ERROR:",e?.stack||e?.message||String(e)),c("Failed","err")}
@@ -1,4 +1,4 @@
1
- var g=Object.defineProperty;var r=(t,n)=>g(t,"name",{value:n,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as c}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const l=document.getElementById("status"),d=document.getElementById("log"),p=document.getElementById("btn-run"),s=r((t,n)=>{l.textContent=t,l.className=`status ${n}`},"setStatus"),e=r((...t)=>{const n=t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");d.textContent+=`${n}
1
+ var g=Object.defineProperty;var r=(t,n)=>g(t,"name",{value:n,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as c}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const l=document.getElementById("status"),d=document.getElementById("log"),p=document.getElementById("btn-run"),s=r((t,n)=>{l.textContent=t,l.className=`status ${n}`},"setStatus"),e=r((...t)=>{const n=t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");d.textContent+=`${n}
2
2
  `,console.log(...t)},"write"),u=r((t,n=8)=>t.split(`
3
3
  `).slice(0,n).join(`
4
4
  `),"firstLines"),m=r(()=>{d.textContent="",s("Running...","pending");const t=new c.Cylinder({radius:1,height:3,resolution:48,name:"Shaft"}).bakeTRS({position:[0,0,.6],rotationEuler:[90,0,0],scale:[1,1,1]}),n=new c.Cone({radius:1.55,height:1.6,resolution:48,name:"Head"}).bakeTRS({position:[0,1.65,.6],rotationEuler:[-90,0,0],scale:[1,1,1]}),o=t.union(n),i=o.toSTL("api_example_part",4),a=o.toSTEP("api_example_part",{precision:4});if(e("--- Export Summary ---"),e("Volume:",o.volume()),e("Surface area:",o.surfaceArea()),e("Triangles:",o.getTriangleCount()),e("STL characters:",i.length),e("STEP characters:",a.length),e(""),e("--- STL Preview ---"),e(u(i)),e(""),e("--- STEP Preview ---"),e(u(a)),!i.startsWith("solid"))throw new Error('STL output did not start with "solid".');if(!a.includes("ISO-10303-21"))throw new Error("STEP output did not contain expected ISO header.");s("Completed","ok")},"runExample");p.addEventListener("click",()=>{try{m()}catch(t){console.error(t),e("ERROR:",t?.stack||t?.message||String(t)),s("Failed","err")}});try{m()}catch(t){console.error(t),e("ERROR:",t?.stack||t?.message||String(t)),s("Failed","err")}
@@ -1,2 +1,2 @@
1
- var g=Object.defineProperty;var n=(e,t)=>g(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as o}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),u=document.getElementById("log"),y=document.getElementById("btn-run"),s=n((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),l=n(e=>Number(e).toFixed(6),"fmt"),a=n((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");u.textContent+=`${t}
1
+ var g=Object.defineProperty;var n=(e,t)=>g(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as o}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const m=document.getElementById("status"),u=document.getElementById("log"),y=document.getElementById("btn-run"),s=n((e,t)=>{m.textContent=e,m.className=`status ${t}`},"setStatus"),l=n(e=>Number(e).toFixed(6),"fmt"),a=n((...e)=>{const t=e.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" ");u.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),C=n(e=>({volume:e.volume(),area:e.surfaceArea(),triangles:e.getTriangleCount()}),"summarize"),c=n(()=>{u.textContent="",s("Running...","pending");const e=[["Cube",()=>new o.Cube({x:2,y:3,z:4,name:"Cube"})],["Sphere",()=>new o.Sphere({r:1.2,resolution:32,name:"Sphere"})],["Cylinder",()=>new o.Cylinder({radius:1,height:2.4,resolution:48,name:"Cylinder"})],["Cone",()=>new o.Cone({radius:1.1,height:2.1,resolution:48,name:"Cone"})],["Torus",()=>new o.Torus({mR:2,tR:.55,resolution:64,name:"Torus"})],["Pyramid",()=>new o.Pyramid({bL:2,s:4,h:2.7,name:"Pyramid"})]];a("--- Primitive Summary ---");for(const[t,r]of e){const d=r(),i=C(d);a(`${t.padEnd(10)} volume=${l(i.volume)} area=${l(i.area)} triangles=${i.triangles}`)}s("Completed","ok")},"runExample");y.addEventListener("click",()=>{try{c()}catch(e){console.error(e),a("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}});try{c()}catch(e){console.error(e),a("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as g}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const c=document.getElementById("status"),l=document.getElementById("log"),b=document.getElementById("btn-run"),s=n((e,t)=>{c.textContent=e,c.className=`status ${t}`},"setStatus"),i=n(e=>Number(e).toFixed(6),"fmt"),m=n((...e)=>{const t=e.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");l.textContent+=`${t}
1
+ var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{BREP as g}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const c=document.getElementById("status"),l=document.getElementById("log"),b=document.getElementById("btn-run"),s=n((e,t)=>{c.textContent=e,c.className=`status ${t}`},"setStatus"),i=n(e=>Number(e).toFixed(6),"fmt"),m=n((...e)=>{const t=e.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ");l.textContent+=`${t}
2
2
  `,console.log(...e)},"write"),r=n((e,t)=>{m(`${e.padEnd(16)} volume=${i(t.volume())} area=${i(t.surfaceArea())} triangles=${t.getTriangleCount()}`)},"describe"),d=n(()=>{l.textContent="",s("Running...","pending");const e=new g.Cube({x:2.2,y:1.4,z:1,name:"BaseCube"}),t=e.clone().bakeTRS({position:[2,.4,.3],rotationEuler:[0,35,20],scale:[1.1,.85,1.25]}),o=t.mirrorAcrossPlane([0,0,0],[1,0,0]),a=t.union(o);if(m("--- Transform Summary ---"),r("base",e),r("moved",t),r("mirrored",o),r("combined",a),a.volume()<=t.volume())throw new Error("Combined solid volume should be greater than a single moved solid.");s("Completed","ok")},"runExample");b.addEventListener("click",()=>{try{d()}catch(e){console.error(e),m("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}});try{d()}catch(e){console.error(e),m("ERROR:",e?.stack||e?.message||String(e)),s("Failed","err")}
@@ -1,4 +1,4 @@
1
- var H=Object.defineProperty;var s=(e,o)=>H(e,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{Sketcher2DEmbed as J}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const k=document.getElementById("btn-create"),C=document.getElementById("btn-destroy"),I=document.getElementById("btn-apply-css"),w=document.getElementById("btn-apply-theme"),B=document.getElementById("btn-export-svg"),$=document.getElementById("btn-export-dxf"),r=document.getElementById("btn-download-dxf"),D=document.getElementById("btn-export-polylines"),F=document.getElementById("geometry-color"),L=document.getElementById("point-color"),N=document.getElementById("constraint-color"),G=document.getElementById("background-color"),T=document.getElementById("point-size-px"),A=document.getElementById("curve-thickness-px"),f=document.getElementById("sidebar-expanded"),u=document.getElementById("grid-visible"),V=document.getElementById("grid-spacing"),W=document.getElementById("curve-resolution"),R=document.getElementById("css-input"),Y=document.getElementById("sketch-status"),q=document.getElementById("sketch-host"),d=document.getElementById("event-output"),g=document.getElementById("svg-preview"),O=document.getElementById("path-output"),P=document.getElementById("dxf-output"),M=document.getElementById("polyline-output");let t=null,i=null,m=0,h=0,y=0,c=null;const K=6,n=s(e=>{Y.textContent=e},"setSketchStatus"),b=s(()=>{c&&(URL.revokeObjectURL(c),c=null)},"revokeDxfDownload"),Q=s(e=>{if(b(),typeof e!="string"||!e.length){r.disabled=!0;return}const o=new Blob([e],{type:"application/dxf"});c=URL.createObjectURL(o),r.disabled=!1},"setDxfDownload"),E=s(e=>{k.disabled=e,C.disabled=!e,I.disabled=!e,w.disabled=!e,B.disabled=!e,$.disabled=!e,D.disabled=!e,r.disabled=!e||!c},"setSketchButtons"),p=s((e,o=null)=>{const a=new Date().toLocaleTimeString(),j=o==null?`[${a}] ${e}`:`[${a}] ${e} ${JSON.stringify(o)}`,z=d.textContent==="(No sketch events yet)"?[]:d.textContent.split(`
1
+ var H=Object.defineProperty;var s=(e,o)=>H(e,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{Sketcher2DEmbed as J}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const k=document.getElementById("btn-create"),C=document.getElementById("btn-destroy"),I=document.getElementById("btn-apply-css"),w=document.getElementById("btn-apply-theme"),B=document.getElementById("btn-export-svg"),$=document.getElementById("btn-export-dxf"),r=document.getElementById("btn-download-dxf"),D=document.getElementById("btn-export-polylines"),F=document.getElementById("geometry-color"),L=document.getElementById("point-color"),N=document.getElementById("constraint-color"),G=document.getElementById("background-color"),T=document.getElementById("point-size-px"),A=document.getElementById("curve-thickness-px"),f=document.getElementById("sidebar-expanded"),u=document.getElementById("grid-visible"),V=document.getElementById("grid-spacing"),W=document.getElementById("curve-resolution"),R=document.getElementById("css-input"),Y=document.getElementById("sketch-status"),q=document.getElementById("sketch-host"),d=document.getElementById("event-output"),g=document.getElementById("svg-preview"),O=document.getElementById("path-output"),P=document.getElementById("dxf-output"),M=document.getElementById("polyline-output");let t=null,i=null,m=0,h=0,y=0,c=null;const K=6,n=s(e=>{Y.textContent=e},"setSketchStatus"),b=s(()=>{c&&(URL.revokeObjectURL(c),c=null)},"revokeDxfDownload"),Q=s(e=>{if(b(),typeof e!="string"||!e.length){r.disabled=!0;return}const o=new Blob([e],{type:"application/dxf"});c=URL.createObjectURL(o),r.disabled=!1},"setDxfDownload"),E=s(e=>{k.disabled=e,C.disabled=!e,I.disabled=!e,w.disabled=!e,B.disabled=!e,$.disabled=!e,D.disabled=!e,r.disabled=!e||!c},"setSketchButtons"),p=s((e,o=null)=>{const a=new Date().toLocaleTimeString(),j=o==null?`[${a}] ${e}`:`[${a}] ${e} ${JSON.stringify(o)}`,z=d.textContent==="(No sketch events yet)"?[]:d.textContent.split(`
2
2
  `).filter(Boolean),S=[j,...z].slice(0,K);d.textContent=S.length?S.join(`
3
3
  `):"(No sketch events yet)"},"pushEvent"),U=s(()=>({geometryColor:F.value,pointColor:L.value,constraintColor:N.value,backgroundColor:G.value,pointSizePx:Math.max(1,Number(T.value)||10),curveThicknessPx:Math.max(.5,Number(A.value)||2)}),"currentTheme"),x=s(()=>{const e=Number(V.value);return Number.isFinite(e)&&e>0?e:1},"currentGridSpacing"),v=s(()=>{const e=Number(W.value);return Number.isFinite(e)?Math.max(3,Math.min(2048,Math.floor(e))):64},"currentCurveResolution"),Z=s(async()=>{t||(t=new J({cssText:R.value,...U(),sidebarExpanded:f.checked,gridVisible:u.checked,gridSpacing:x(),onChange:s(e=>{i=e,m+=1;const o=Array.isArray(e?.geometries)?e.geometries.length:0;n(`Sketch updated (${m}). Geometries: ${o}`),p("onChange",{geometries:o})},"onChange"),onFinished:s(e=>{i=e,h+=1;const o=Array.isArray(e?.geometries)?e.geometries.length:0;n(`Sketch finished (${h}). Geometries: ${o}`),p("onFinished",{geometries:o}),X().catch(a=>{console.error(a),n(`Failed to export SVG after Finish: ${a?.message||String(a)}`)})},"onFinished"),onCancelled:s(()=>{y+=1,n(`Sketch cancelled (${y}).`),p("onCancelled")},"onCancelled")}),await t.mount(q),i=await t.getSketch(),E(!0),n("Sketcher iframe mounted. Draw geometry and run any export action."))},"attachSketcher"),_=s(async()=>{t&&(await t.destroy(),t=null,i=null,m=0,h=0,y=0,E(!1),n("Sketcher destroyed."),d.textContent="(No sketch events yet)",g.innerHTML="",O.textContent="(No SVG exported yet)",P.textContent="(No DXF exported yet)",M.textContent="(No 3D polylines exported yet)",b())},"detachSketcher"),ee=s(async()=>{t&&(await t.setCss(R.value),n("Custom CSS applied to iframe."))},"applySketchCss"),l=s(async()=>{t&&(await t.setTheme(U()),await t.setSidebarExpanded(f.checked),typeof t.setGrid=="function"?await t.setGrid({visible:u.checked,spacing:x()}):(typeof t.setGridVisible=="function"&&await t.setGridVisible(u.checked),typeof t.setGridSpacing=="function"&&await t.setGridSpacing(x())),n("Theme + sidebar + grid state applied to iframe."))},"applySketchTheme"),X=s(async()=>{if(!t)return;const e=await t.exportSVG({flipY:!0,precision:3,stroke:"#111111",strokeWidth:1.5,fill:"none",padding:12,curveResolution:v()});i=await t.getSketch({preferCached:!0}),g.innerHTML=e.svg,O.textContent=e.paths.length?e.paths.map(o=>`id=${o.id} type=${o.type} d="${o.d}"`).join(`
4
4
  `):"(No sketch geometry to export)",n(`Exported ${e.paths.length} SVG paths.`),g.scrollIntoView({behavior:"smooth",block:"start"})},"exportSvg"),te=s(async()=>{if(!t)return;const e=await t.exportDXF({units:"mm",curveResolution:v(),includeConstruction:!1});P.textContent=e?.dxf||"(No DXF payload returned)",Q(e?.dxf||""),n(`Exported DXF with ${e?.polylines?.length||0} polylines.`)},"exportDxf"),ne=s(async()=>{if(!t)return;const e=await t.export3DPolylines({curveResolution:v(),includeConstruction:!1,origin:[0,0,0],xAxis:[1,0,0],yAxis:[0,1,0]});M.textContent=JSON.stringify(e,null,2),n(`Exported ${e?.polylines?.length||0} 3D polylines.`)},"export3DPolylines");k.addEventListener("click",()=>{Z().catch(e=>{console.error(e),n(`Failed to create sketcher: ${e?.message||String(e)}`)})});C.addEventListener("click",()=>{_().catch(e=>{console.error(e),n(`Failed to destroy sketcher: ${e?.message||String(e)}`)})});I.addEventListener("click",()=>{ee().catch(e=>{console.error(e),n(`Failed to apply CSS: ${e?.message||String(e)}`)})});w.addEventListener("click",()=>{l().catch(e=>{console.error(e),n(`Failed to apply theme: ${e?.message||String(e)}`)})});B.addEventListener("click",()=>{X().catch(e=>{console.error(e),n(`Failed to export SVG: ${e?.message||String(e)}`)})});$.addEventListener("click",()=>{te().catch(e=>{console.error(e),n(`Failed to export DXF: ${e?.message||String(e)}`)})});r.addEventListener("click",()=>{if(!c)return;const e=document.createElement("a");e.href=c,e.download="sketch-export.dxf",e.click()});D.addEventListener("click",()=>{ne().catch(e=>{console.error(e),n(`Failed to export 3D polylines: ${e?.message||String(e)}`)})});[F,L,N,G,T,A].forEach(e=>{e.addEventListener("input",()=>{t&&l().catch(o=>{console.error(o),n(`Failed to apply theme: ${o?.message||String(o)}`)})})});f.addEventListener("change",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply sidebar state: ${e?.message||String(e)}`)})});u.addEventListener("change",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply grid visibility: ${e?.message||String(e)}`)})});V.addEventListener("input",()=>{t&&l().catch(e=>{console.error(e),n(`Failed to apply grid spacing: ${e?.message||String(e)}`)})});window.addEventListener("beforeunload",()=>{t&&t.destroy().catch(()=>{}),b()});E(!1);i&&!Array.isArray(i?.geometries)&&console.warn("Unexpected sketch payload shape",i);
@@ -1,3 +1,3 @@
1
- var B=Object.defineProperty;var n=(t,o)=>B(t,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as v}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const u=document.getElementById("btn-create"),y=document.getElementById("btn-destroy"),p=document.getElementById("btn-state"),g=document.getElementById("btn-history"),b=document.getElementById("btn-sample"),E=document.getElementById("btn-reset"),h=document.getElementById("btn-css"),S=document.getElementById("viewer-only"),i=document.getElementById("sidebar-expanded"),x=document.getElementById("model-path"),w=document.getElementById("model-source"),$=document.getElementById("model-repo"),k=document.getElementById("model-branch"),C=document.getElementById("css-input"),F=document.getElementById("cad-status"),H=document.getElementById("cad-host"),I=document.getElementById("state-output"),f=document.getElementById("history-output");let e=null;const D={features:[{type:"Primitive Cube",inputParams:{id:"sample_cube_1",sizeX:24,sizeY:18,sizeZ:14,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
1
+ var B=Object.defineProperty;var n=(t,o)=>B(t,"name",{value:o,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as v}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const u=document.getElementById("btn-create"),y=document.getElementById("btn-destroy"),p=document.getElementById("btn-state"),g=document.getElementById("btn-history"),b=document.getElementById("btn-sample"),E=document.getElementById("btn-reset"),h=document.getElementById("btn-css"),S=document.getElementById("viewer-only"),i=document.getElementById("sidebar-expanded"),x=document.getElementById("model-path"),w=document.getElementById("model-source"),$=document.getElementById("model-repo"),k=document.getElementById("model-branch"),C=document.getElementById("css-input"),F=document.getElementById("cad-status"),H=document.getElementById("cad-host"),I=document.getElementById("state-output"),f=document.getElementById("history-output");let e=null;const D={features:[{type:"Primitive Cube",inputParams:{id:"sample_cube_1",sizeX:24,sizeY:18,sizeZ:14,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
2
2
  x = 10 + 6;
3
3
  y = x * 2;`,pmiViews:[],metadata:{},assemblyConstraints:[],assemblyConstraintIdCounter:0},s=n(t=>{F.textContent=t},"setStatus"),r=n(t=>{u.disabled=t,y.disabled=!t,p.disabled=!t,g.disabled=!t,b.disabled=!t,E.disabled=!t,h.disabled=!t,S.disabled=t},"setButtons"),L=n(()=>{const t=String(x.value||"").trim();if(!t)return null;const o=String(w.value||"local").trim()||"local",a=String($.value||"").trim(),d=String(k.value||"").trim(),l={modelPath:t,source:o};return a&&(l.repoFull=a),d&&(l.branch=d),l},"currentModelRequest"),c=n((t,o="State updated")=>{I.textContent=JSON.stringify(t||{},null,2);const a=Number(t?.featureCount||0),d=t?.model?.name||"(unsaved/new)";s(`${o}. Features: ${a}. Model: ${d}`)},"renderState"),N=n(async()=>{if(e)return;const t=L();e=new v({mountTo:H,viewerOnlyMode:S.checked,sidebarExpanded:i.checked,cssText:C.value,initialModel:t,onReady:n(a=>{c(a,"CAD ready")},"onReady"),onHistoryChanged:n(a=>{c(a,`History changed (${a?.reason||"update"})`)},"onHistoryChanged")}),await e.mount(),r(!0);const o=await e.getState();c(o,"CAD iframe mounted")},"createCad"),O=n(async()=>{e&&(await e.destroy(),e=null,r(!1),s("CAD iframe destroyed."),I.textContent="(No state yet)",f.textContent="(No history exported yet)")},"destroyCad"),m=n(async()=>{if(!e)return;const t=await e.getState();c(t,"State fetched")},"refreshState"),A=n(async()=>{if(!e)return;const t=await e.getPartHistoryJSON();f.textContent=t||"(History is empty)",s(`History exported (${t?t.length:0} chars).`)},"exportHistory"),M=n(async()=>{e&&(await e.setPartHistory(D),await m(),s("Sample cube history loaded."))},"loadSampleCube"),P=n(async()=>{e&&(await e.reset(),await m(),s("Model reset complete."))},"resetModel"),R=n(async()=>{e&&(await e.setCss(C.value),await e.setSidebarExpanded(i.checked),s("Custom CSS and sidebar state applied."))},"applyCss");u.addEventListener("click",()=>{N().catch(t=>{console.error(t),s(`Failed to create CAD iframe: ${t?.message||String(t)}`)})});y.addEventListener("click",()=>{O().catch(t=>{console.error(t),s(`Failed to destroy CAD iframe: ${t?.message||String(t)}`)})});p.addEventListener("click",()=>{m().catch(t=>{console.error(t),s(`Failed to get state: ${t?.message||String(t)}`)})});g.addEventListener("click",()=>{A().catch(t=>{console.error(t),s(`Failed to export history: ${t?.message||String(t)}`)})});b.addEventListener("click",()=>{M().catch(t=>{console.error(t),s(`Failed to load sample history: ${t?.message||String(t)}`)})});E.addEventListener("click",()=>{P().catch(t=>{console.error(t),s(`Failed to reset model: ${t?.message||String(t)}`)})});h.addEventListener("click",()=>{R().catch(t=>{console.error(t),s(`Failed to apply CSS: ${t?.message||String(t)}`)})});i.addEventListener("change",()=>{e&&e.setSidebarExpanded(i.checked).catch(t=>{console.error(t),s(`Failed to set sidebar state: ${t?.message||String(t)}`)})});r(!1);
@@ -1,4 +1,4 @@
1
- var O=Object.defineProperty;var i=(t,s)=>O(t,"name",{value:s,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as S}from"./brep-kernel-DL1UVMTK.js";import"./preload-helper-ZNr0Qq7Q.js";const h=document.getElementById("btn-run"),u=document.getElementById("btn-destroy"),P=document.getElementById("viewer-only"),H=document.getElementById("sidebar-expanded"),M=document.getElementById("model-path"),A=document.getElementById("model-source"),j=document.getElementById("model-repo"),B=document.getElementById("model-branch"),x=document.getElementById("css-input"),R=document.getElementById("run-status"),$=document.getElementById("cad-host"),C=document.getElementById("results"),g=document.getElementById("log-output");let n=null,w=!1;const v={features:[{type:"Primitive Cube",inputParams:{id:"integration_sample_cube_1",sizeX:16,sizeY:12,sizeZ:10,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
1
+ var O=Object.defineProperty;var i=(t,s)=>O(t,"name",{value:s,configurable:!0});import"./modulepreload-polyfill-BdX5DvLD.js";/* empty css */import{CADEmbed as S}from"./brep-kernel-B-jYf5J_.js";import"./preload-helper-ZNr0Qq7Q.js";const h=document.getElementById("btn-run"),u=document.getElementById("btn-destroy"),P=document.getElementById("viewer-only"),H=document.getElementById("sidebar-expanded"),M=document.getElementById("model-path"),A=document.getElementById("model-source"),j=document.getElementById("model-repo"),B=document.getElementById("model-branch"),x=document.getElementById("css-input"),R=document.getElementById("run-status"),$=document.getElementById("cad-host"),C=document.getElementById("results"),g=document.getElementById("log-output");let n=null,w=!1;const v={features:[{type:"Primitive Cube",inputParams:{id:"integration_sample_cube_1",sizeX:16,sizeY:12,sizeZ:10,transform:{position:[0,0,0],rotationEuler:[0,0,0],scale:[1,1,1]},boolean:{targets:[],operation:"NONE"}},persistentData:{},timestamp:null}],idCounter:1,expressions:`//Examples:
2
2
  x = 10 + 6;
3
3
  y = x * 2;`,pmiViews:[],metadata:{},assemblyConstraints:[],assemblyConstraintIdCounter:0};function l(t){const a=`[${new Date().toLocaleTimeString()}] ${t}`,o=g.textContent==="(No logs yet)"?[]:g.textContent.split(`
4
4
  `).filter(Boolean);o.unshift(a),g.textContent=o.slice(0,120).join(`
@@ -10256,7 +10256,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
10256
10256
  <div class="sk-row" style="display:flex;align-items:center;gap:6px;margin:2px 0">
10257
10257
  <button data-act="${t}" style="flex:1;text-align:left;background:transparent;color:#ddd;border:1px solid #364053;border-radius:4px;padding:3px 6px">${e}</button>
10258
10258
  <button data-del="${B}" title="Delete" style="color:#ff8b8b;background:transparent;border:1px solid #5b2b2b;border-radius:4px;padding:3px 6px">✕</button>
10259
- </div>`,"row");this._secConstraints&&(this._secConstraints.uiElement.innerHTML=(g.constraints||[]).map(e=>A(`${e.id} ${e.type} ${e.value??""} [${e.points?.join(",")}]`,`c:${e.id}`,`c:${e.id}`)).join("")),this._secCurves&&(this._secCurves.uiElement.innerHTML=(g.geometries||[]).map(e=>{const t=e?.construction?" ◐":"";return A(`${e.type}:${e.id}${t} [${e.points?.join(",")}]`,`g:${e.id}`,`g:${e.id}`)}).join("")),this._secPoints&&(this._secPoints.uiElement.innerHTML=(g.points||[]).map(e=>{const t=x(this,lA,wy).call(this,e?.id),B=Number(e?.id)===0,i=t?" 🔗":"",I=e?.fixed&&!t&&!B?" ⏚":"",s=e?.construction?" ◐":"";return A(`P${e.id} (${e.x.toFixed(2)}, ${e.y.toFixed(2)})${i}${s}${I}`,`p:${e.id}`,`p:${e.id}`)}).join("")),this._acc.uiElement.onclick=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const B=t.getAttribute("data-del");if(B){const[C,o]=B.split(":");if(C==="p")try{this._solver.removePointById?.(parseInt(o))}catch{}if(C==="g")try{this._solver.removeGeometryById?.(parseInt(o))}catch{}if(C==="c")try{this._solver.removeConstraintById?.(parseInt(o))}catch{}if(!x(this,lA,xn).call(this)){try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}try{XU(this)}catch{}return}const i=t.getAttribute("data-act");if(!i)return;const[I,s]=i.split(":");I==="p"&&x(this,lA,Vi).call(this,{type:"point",id:parseInt(s)}),I==="g"&&x(this,lA,Vi).call(this,{type:"geometry",id:parseInt(s)}),I==="c"&&x(this,lA,Vi).call(this,{type:"constraint",id:parseInt(s)}),x(this,lA,sg).call(this)},this._acc.uiElement.onmousemove=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const B=t.getAttribute("data-act");if(!B)return x(this,lA,As).call(this,null);const[i,I]=B.split(":");i==="p"?x(this,lA,As).call(this,{type:"point",id:parseInt(I)}):i==="g"?x(this,lA,As).call(this,{type:"geometry",id:parseInt(I)}):i==="c"&&x(this,lA,As).call(this,{type:"constraint",id:parseInt(I)})},this._acc.uiElement.onmouseleave=()=>x(this,lA,As).call(this,null);try{XU(this)}catch{}},"#refreshLists"),r7=E(function(){try{$R(this)}catch{}},"#applyHoverAndSelectionColors"),sg=E(function(){if(!this._ctxBar||!this._solver)return;const g=Array.from(this._selection),A=this._solver.sketchObject,e=new Set(g.filter(r=>r.type==="point").map(r=>r.id)),t=g.filter(r=>r.type==="point").map(r=>parseInt(r.id)).filter(r=>Number.isFinite(r)),B=g.filter(r=>r.type==="geometry").map(r=>A.geometries.find(a=>a.id===parseInt(r.id))).filter(Boolean);for(const r of B)(r.type==="arc"?r.points.slice(0,2):r.points).forEach(a=>e.add(a));const i=e.size;this._ctxBar.innerHTML="";const I=E(({label:r,tooltip:a,variant:w="default",onClick:c})=>{const h=document.createElement("button");return h.textContent=r,a&&(h.title=a,h.setAttribute("aria-label",a)),h.style.background="transparent",h.style.borderRadius="6px",h.style.padding="4px 8px",h.style.width="100%",h.style.minHeight="34px",h.style.boxSizing="border-box",w==="danger"?(h.style.color="#ff8b8b",h.style.border="1px solid #5b2b2b"):(h.style.color="#ddd",h.style.border="1px solid #364053"),h.onclick=c,this._ctxBar.appendChild(h),h},"appendButton"),s=E(({label:r,type:a,tooltip:w})=>I({label:r,tooltip:w,onClick:E(()=>{this._solver.createConstraint(a,g),x(this,lA,Gi).call(this),x(this,lA,sg).call(this)},"onClick")}),"addConstraintButton"),C=E(()=>I({label:"🧹",tooltip:"Remove unused points",onClick:E(()=>x(this,lA,EL).call(this),"onClick")}),"addCleanupButton"),o=E(()=>I({label:"🗑",tooltip:"Delete selection",variant:"danger",onClick:E(()=>x(this,lA,oz).call(this),"onClick")}),"addDeleteButton");if(C(),t.length){const r=t.every(c=>x(this,lA,nL).call(this,c));I({label:r?"Unfix":"Fix",tooltip:r?"Remove ground constraint":"Add ground constraint",onClick:E(()=>x(this,lA,w7).call(this,t,r),"onClick")});const a=t.map(c=>A.points?.find(h=>Number(h?.id)===Number(c))).filter(Boolean),w=a.length>0&&a.every(c=>c.construction===!0);I({label:"◐",tooltip:w?"Include selected points in 3D result":"Exclude selected points from 3D result (construction points)",onClick:E(()=>x(this,lA,l7).call(this,t,w),"onClick")})}const Q=g.filter(r=>r.type==="constraint");let n=null;if(Q.length===1&&Array.isArray(A?.constraints)){const r=Number(Q[0].id);n=A.constraints.find(a=>Number(a.id)===r)||null}if(n&&n.type==="∠"&&(I({label:"Reverse Angle",tooltip:"Swap the angle measurement to the opposite side",onClick:E(()=>{x(this,lA,h7).call(this,Number(n.id))},"onClick")}),I({label:"Alternative Angle",tooltip:"Flip the first line direction and measure the other arc",onClick:E(()=>{x(this,lA,D7).call(this,Number(n.id))},"onClick")})),B.length>0){const r=B.every(a=>!!a.construction);I({label:"◐",tooltip:r?"Convert to regular geometry":"Convert to construction geometry",onClick:E(()=>{try{this._solver.toggleConstruction()}catch{}try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,Gi).call(this),x(this,lA,sg).call(this)},"onClick")})}if(B.length===1&&(B[0]?.type==="arc"||B[0]?.type==="circle")){const r=E((a,w,c)=>I({label:a,tooltip:c,onClick:E(()=>{x(this,lA,M7).call(this,w,g)},"onClick")}),"mkAct");r("R","radius","Create radius dimension"),r("⌀","diameter","Create diameter dimension"),o();return}if(B.length===2&&B.every(r=>r?.type==="line")){s({label:"∥",type:"∥",tooltip:"Parallel"}),s({label:"⟂",type:"⟂",tooltip:"Perpendicular"}),s({label:"∠",type:"∠",tooltip:"Angle"}),s({label:"⇌",type:"⇌",tooltip:"Equal distance"}),s({label:"⏛",type:"⏛",tooltip:"Point on line"}),g.length&&o();return}if(B.length===2&&B.every(r=>r&&(r.type==="arc"||r.type==="circle"))){s({label:"⇌",type:"⇌",tooltip:"Equal radius"}),g.length&&o();return}if(B.length===2&&(B[0]?.type==="line"&&(B[1]?.type==="arc"||B[1]?.type==="circle")||B[1]?.type==="line"&&(B[0]?.type==="arc"||B[0]?.type==="circle"))){s({label:"⟠",type:"⟂",tooltip:"Tangent"}),g.length&&o();return}i===1&&s({label:"⏚",type:"⏚",tooltip:"Ground (fix point)"}),i===2&&(s({label:"━",type:"━",tooltip:"Horizontal"}),s({label:"│",type:"│",tooltip:"Vertical"}),s({label:"≡",type:"≡",tooltip:"Coincident"}),s({label:"⟺",type:"⟺",tooltip:"Distance"})),i===3&&(s({label:"⋯",type:"⋯",tooltip:"Midpoint"}),s({label:"⏛",type:"⏛",tooltip:"Point on line"}),s({label:"↥",type:ny,tooltip:"Line to point distance"}),s({label:"∠",type:"∠",tooltip:"Angle"})),g.length&&o()},"#refreshContextBar"),oz=E(function(){try{const g=this._solver;if(!g)return;const A=Array.from(this._selection||[]);for(const e of A)if(e?.type==="constraint")try{g.removeConstraintById?.(parseInt(e.id))}catch{}for(const e of A)if(e?.type==="geometry")try{g.removeGeometryById?.(parseInt(e.id))}catch{}for(const e of A)if(e?.type==="point")try{g.removePointById?.(parseInt(e.id))}catch{}if(this._selection.clear(),!x(this,lA,xn).call(this)){try{g.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}}catch{}},"#deleteSelection"),a7=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t))return console.warn("[SketchTrim] delete point blocked",{pointId:g??null,reason:"invalid solver/sketch/point id"}),!1;if(!(Array.isArray(e.points)&&e.points.some(B=>parseInt(B?.id)===t)))return console.warn("[SketchTrim] delete point blocked",{pointId:t,reason:"point not found"}),!1;try{A.removePointById?.(t)}catch{return console.error("[SketchTrim] delete point failed",{pointId:t,reason:"solver.removePointById threw"}),!1}if((A.sketchObject?.points||[]).some(B=>parseInt(B?.id)===t))return console.warn("[SketchTrim] delete point failed",{pointId:t,reason:"point still present after remove"}),!1;if(console.log("[SketchTrim] delete point succeeded",{pointId:t}),this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deletePointById"),QL=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t)||!(Array.isArray(e.geometries)&&e.geometries.some(B=>parseInt(B?.id)===t)))return!1;try{A.removeGeometryById?.(t)}catch{return!1}if((A.sketchObject?.geometries||[]).some(B=>parseInt(B?.id)===t))return!1;if(this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deleteGeometryById"),Qz=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t))return console.warn("[SketchTrim] delete constraint blocked",{constraintId:g??null,reason:"invalid solver/sketch/constraint id"}),!1;if(!(Array.isArray(e.constraints)&&e.constraints.some(B=>parseInt(B?.id)===t)))return console.warn("[SketchTrim] delete constraint blocked",{constraintId:t,reason:"constraint not found"}),!1;try{A.removeConstraintById?.(t)}catch{return console.error("[SketchTrim] delete constraint failed",{constraintId:t,reason:"solver.removeConstraintById threw"}),!1}if((A.sketchObject?.constraints||[]).some(B=>parseInt(B?.id)===t))return console.warn("[SketchTrim] delete constraint failed",{constraintId:t,reason:"constraint still present after remove"}),!1;if(console.log("[SketchTrim] delete constraint succeeded",{constraintId:t}),this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deleteConstraintById"),EL=E(function(){const g=this._solver,A=g?.sketchObject;if(!g||!A)return 0;const e=new Set;for(const i of A.geometries||[])if(!(!i||!Array.isArray(i.points)))for(const I of i.points)e.add(parseInt(I));const t=new Map;for(const i of A.constraints||[])if(!(!i||i.temporary||!Array.isArray(i.points)))for(const I of i.points){const s=parseInt(I);if(!Number.isFinite(s))continue;const C=t.get(s);C?C.push(i):t.set(s,[i])}const B=[];for(const i of A.points||[]){const I=parseInt(i.id);if(!Number.isFinite(I)||I===0||e.has(I))continue;const s=t.get(I)||[];if(s.length===0){B.push(I);continue}if(s.length===1){const C=s[0]?.type;(C==="≡"||C==="⏛")&&B.push(I)}}if(!B.length)return 0;for(const i of B)try{g.removePointById?.(i)}catch{}try{g.solveSketch("full")}catch{}return this._selection.clear(),x(this,lA,Cg).call(this),x(this,lA,Gi).call(this),x(this,lA,sg).call(this),B.length},"#cleanupUnusedPoints"),c7=E(function(){const g=this._solver?.sketchObject;if(!g||!Array.isArray(g.constraints))return 0;const A=g.constraints,e=new Map,t=E(Q=>{let n=e.get(Q);return n==null?(e.set(Q,Q),Q):(n!==Q&&(n=t(n),e.set(Q,n)),n)},"find"),B=E((Q,n)=>{const r=t(Q),a=t(n);r!==a&&(r<a?e.set(a,r):e.set(r,a))},"union"),i=E(Q=>{const n=parseInt(Q);return Number.isFinite(n)?e.has(n)?t(n):n:null},"canonical"),I=E((Q,n)=>Q<=n?`${Q},${n}`:`${n},${Q}`,"pairKey");for(const Q of A){if(!Q||Q.temporary||Q.type!=="≡"||!Array.isArray(Q.points)||Q.points.length<2)continue;const n=parseInt(Q.points[0]),r=parseInt(Q.points[1]);!Number.isFinite(n)||!Number.isFinite(r)||B(n,r)}const s=new Set,C=[];let o=0;for(const Q of A){if(!Q||Q.temporary||Q.type!=="⏛"||!Array.isArray(Q.points)||Q.points.length<3){C.push(Q);continue}const n=i(Q.points[0]),r=i(Q.points[1]),a=i(Q.points[2]);if(![n,r,a].every(Number.isFinite)){C.push(Q);continue}if(a===n||a===r){o+=1;continue}const w=`${I(n,r)}|${a}`;if(s.has(w)){o+=1;continue}s.add(w),C.push(Q)}return o?(g.constraints=C,o):0},"#cleanupRedundantPointOnLineConstraints"),xn=E(function(){return this._solverSettings?.autoCleanupOrphans?x(this,lA,EL).call(this):0},"#maybeAutoCleanupPoints"),nL=E(function(g){const A=this._solver?.sketchObject;return!A||!Array.isArray(A.constraints)?!1:A.constraints.some(e=>e?.type==="⏚"&&Array.isArray(e.points)&&parseInt(e.points[0])===g)},"#pointHasGround"),w7=E(function(g,A){const e=this._solver,t=e?.sketchObject;if(!e||!t||!Array.isArray(g)||!g.length)return;const B=g.map(i=>parseInt(i)).filter(i=>Number.isFinite(i)&&i!==0);if(B.length){if(A){t.constraints=(t.constraints||[]).filter(i=>i?.type!=="⏚"||!Array.isArray(i.points)?!0:!B.includes(parseInt(i.points[0])));for(const i of B){const I=t.points?.find(s=>parseInt(s.id)===i);I&&(I.fixed=!1)}}else{const i=E(()=>Math.max(0,...(t.constraints||[]).map(I=>+I.id||0))+1,"nextId");for(const I of B){if(x(this,lA,nL).call(this,I))continue;const s=i();t.constraints=t.constraints||[],t.constraints.push({id:s,type:"⏚",points:[I]});const C=t.points?.find(o=>parseInt(o.id)===I);C&&(C.fixed=!0)}}try{e.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}},"#toggleGroundConstraints"),l7=E(function(g,A){const e=this._solver,t=e?.sketchObject;if(!e||!t||!Array.isArray(g)||!g.length)return;const B=g.map(s=>parseInt(s)).filter(s=>Number.isFinite(s));if(!B.length)return;const i=!A;let I=!1;for(const s of B){const C=t.points?.find(o=>parseInt(o?.id)===s);C&&C.construction!==i&&(C.construction=i,I=!0)}if(I){try{e.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}},"#togglePointConstruction"),h7=E(function(g){const A=this._solver,e=A?.sketchObject;if(!A||!e||!Array.isArray(e.constraints))return;const t=Number(g),B=e.constraints.find(C=>Number(C.id)===t);if(!B||B.type!=="∠"||!Array.isArray(B.points)||B.points.length<4)return;const i=B.points.slice(),I=[i[3],i[2],i[0],i[1],...i.slice(4)];B.points=I;const s=this._dimOffsets.get(B.id);s&&(typeof s.du=="number"||typeof s.dv=="number")&&this._dimOffsets.set(B.id,{...s,du:typeof s.du=="number"?-s.du:s.du,dv:typeof s.dv=="number"?-s.dv:s.dv}),B.value=null,"valueExpr"in B&&delete B.valueExpr;try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)},"#reverseAngleConstraint"),D7=E(function(g){const A=this._solver,e=A?.sketchObject;if(!A||!e||!Array.isArray(e.constraints))return;const t=Number(g),B=e.constraints.find(s=>Number(s.id)===t);if(!B||B.type!=="∠"||!Array.isArray(B.points)||B.points.length<2)return;const i=B.points.slice(),I=[i[0],i[1],i[3],i[2]];B.points=I,B.value=null,"valueExpr"in B&&delete B.valueExpr;try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)},"#alternativeAngleConstraint"),M7=E(function(g,A){try{this._solver.createConstraint("⟺",A);const e=this._solver.sketchObject,t=(e.constraints||[]).reduce((C,o)=>+(C?.id||0)>+o.id?C:o,null);if(!t)return;t.displayStyle=g==="diameter"?"diameter":"radius";const B=Array.isArray(A)?parseInt(A.find(C=>C?.type==="geometry")?.id):NaN,i=Number.isFinite(B)?(e.geometries||[]).find(C=>parseInt(C?.id)===B):null;i&&(i.type==="arc"||i.type==="circle")&&(t.radialGeometryType=i.type);const I=e.points.find(C=>C.id===t.points?.[0])||null,s=e.points.find(C=>C.id===t.points?.[1])||null;if(I&&s){const C=s.x-I.x,o=s.y-I.y,Q=Math.hypot(C,o),n=Q>1e-9?C/Q:1,r=Q>1e-9?o/Q:0,a=-r,w=n,c=Math.max(.2,Q*.35);this._dimOffsets.set(t.id,{du:C+n*c+a*c*.35,dv:o+r*c+w*c*.35})}this._solver.solveSketch("full"),x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}catch{}},"#addRadialDimension"),Vi=E(function(g){const A=g.type+":"+g.id,e=Array.from(this._selection).find(t=>t.type+":"+t.id===A);e?this._selection.delete(e):this._selection.add(g);try{XU(this)}catch{}try{$R(this)}catch{}try{x(this,lA,MC).call(this)}catch{}try{this.revealListForItem?.(g.type,g.id)}catch{}},"#toggleSelection"),As=E(function(g){const A=this._hover?this._hover.type+":"+this._hover.id:null,e=g?g.type+":"+g.id:null;if(A!==e){this._hover=g;try{XU(this)}catch{}try{$R(this)}catch{}if(g&&g.type&&g.id!=null)try{this.revealListForItem?.(g.type,g.id)}catch{}}},"#setHover"),Fo=E(function(g){if(!this._sketchGroup||!this._solver)return null;const A=this.viewer,e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject,{width:B,height:i}=x(this,lA,zi).call(this,A.renderer.domElement),I=x(this,lA,XK).call(this,g),s=x(this,lA,Ln).call(this,B,i)*I*1.2;let C=null,o=1/0;for(const Q of t.points||[]){const n=Math.hypot(e.u-Q.x,e.v-Q.y);n<o&&(o=n,C=Q.id)}return C!=null&&o<=s?C:null},"#hitTestPoint"),F7=E(function(g,A=null){if(!this._solver||g==null)return!1;const e=this._solver.sketchObject;if(!e||!Array.isArray(e.points))return!1;const t=this._solver.getPointById?.(g)||e.points.find(c=>c.id===g);if(!t)return!1;const B=this.viewer;if(!B?.renderer||!B?.camera)return!1;const{width:i,height:I}=x(this,lA,zi).call(this,B.renderer.domElement),s=x(this,lA,wI).call(this,B.camera,i,I),C=x(this,lA,Ln).call(this,i,I),o=Number(this._solverSettings?.pointConstraintPx),Q=Math.max(C*1.2,s*(Number.isFinite(o)?o:12)),n=A?x(this,lA,MB).call(this,A):null,r=Number.isFinite(n?.u)?n.u:t.x,a=Number.isFinite(n?.v)?n.v:t.y,w=[];for(const c of e.points){if(!c||c.id===g)continue;const h=Math.hypot(r-c.x,a-c.y);h<=Q&&w.push({id:c.id,d:h})}if(!w.length)return!1;w.sort((c,h)=>c.d-h.d);for(const c of w)if(!x(this,lA,d7).call(this,g,c.id))return this._solver.createConstraint("≡",[{type:"point",id:g},{type:"point",id:c.id}]),x(this,lA,Gi).call(this),x(this,lA,sg).call(this),!0;return!0},"#maybeAddCoincidentOnDrop"),d7=E(function(g,A){const e=parseInt(g),t=parseInt(A);if(!Number.isFinite(e)||!Number.isFinite(t))return!1;if(e===t)return!0;const B=this._solver?.sketchObject?.constraints||[],i=new Map;for(const C of B){if(C?.type!=="≡"||!Array.isArray(C.points)||C.points.length<2)continue;const o=parseInt(C.points[0]),Q=parseInt(C.points[1]);!Number.isFinite(o)||!Number.isFinite(Q)||(i.has(o)||i.set(o,new Set),i.has(Q)||i.set(Q,new Set),i.get(o).add(Q),i.get(Q).add(o))}const I=new Set([e]),s=[e];for(;s.length;){const C=s.shift(),o=i.get(C);if(o)for(const Q of o){if(Q===t)return!0;I.has(Q)||(I.add(Q),s.push(Q))}}return!1},"#arePointsCoincident"),u7=E(function(g,A=null){if(!this._solver||g==null)return!1;const e=this._solver.sketchObject;if(!e||!Array.isArray(e.points)||!Array.isArray(e.geometries))return!1;const t=this._solver.getPointById?.(g)||e.points.find(h=>h.id===g);if(!t)return!1;const B=this.viewer;if(!B?.renderer||!B?.camera)return!1;const{width:i,height:I}=x(this,lA,zi).call(this,B.renderer.domElement),s=x(this,lA,wI).call(this,B.camera,i,I),C=x(this,lA,Ln).call(this,i,I),o=Number(this._solverSettings?.pointConstraintPx),Q=Math.max(C*1.2,s*(Number.isFinite(o)?o:12)),n=A?x(this,lA,MB).call(this,A):null,r=Number.isFinite(n?.u)?n.u:t.x,a=Number.isFinite(n?.v)?n.v:t.y;let w=null,c=1/0;for(const h of e.geometries){if(!h||h.type!=="line"||!Array.isArray(h.points)||h.points.length<2)continue;const l=e.points.find(d=>d.id===h.points[0]),M=e.points.find(d=>d.id===h.points[1]);if(!l||!M||l.id===g||M.id===g)continue;const F=x(this,lA,p7).call(this,l.x,l.y,M.x,M.y,r,a);F<c&&(c=F,w=h)}if(!w||c>Q||!x(this,lA,wL).call(this,w,g,null))return!1;try{this._solver.solveSketch("full")}catch{}return x(this,lA,Cg).call(this),x(this,lA,sg).call(this),!0},"#maybeAddPointOnLineOnDrop"),hy=E(function(g){const A=this.viewer;if(!A||!this._solver||!this._lock)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject;if(!t)return null;const{width:B,height:i}=x(this,lA,zi).call(this,A.renderer.domElement),I=x(this,lA,wI).call(this,A.camera,B,i),s=Math.max(.05,I*6)*x(this,lA,XK).call(this,g);let C=null,o=1/0;const Q=E((r,a,w,c,h,l)=>{const M=w-r,F=c-a,d=h-r,Y=l-a,u=M*M+F*F||1e-12;let G=(d*M+Y*F)/u;G<0?G=0:G>1&&(G=1);const y=r+M*G,U=a+F*G,N=h-y,f=l-U;return Math.hypot(N,f)},"distToSeg"),n=E(r=>{const a=Math.PI*2;return r=r%a,r<0&&(r+=a),r},"normAng");for(const r of t.geometries||[])if(r.type==="line"&&Array.isArray(r.points)&&r.points.length>=2){const a=t.points.find(h=>h.id===r.points[0]),w=t.points.find(h=>h.id===r.points[1]);if(!a||!w)continue;const c=Q(a.x,a.y,w.x,w.y,e.u,e.v);c<o&&(o=c,C={id:r.id,type:"line"})}else if(r.type==="circle"&&Array.isArray(r.points)&&r.points.length>=2){const a=t.points.find(l=>l.id===r.points[0]),w=t.points.find(l=>l.id===r.points[1]);if(!a||!w)continue;const c=Math.hypot(w.x-a.x,w.y-a.y),h=Math.abs(Math.hypot(e.u-a.x,e.v-a.y)-c);h<o&&(o=h,C={id:r.id,type:"circle"})}else if(r.type==="arc"&&Array.isArray(r.points)&&r.points.length>=3){const a=t.points.find(u=>u.id===r.points[0]),w=t.points.find(u=>u.id===r.points[1]),c=t.points.find(u=>u.id===r.points[2]);if(!a||!w||!c)continue;const h=a.x,l=a.y,M=Math.hypot(w.x-h,w.y-l);let F=Math.atan2(w.y-l,w.x-h),d=Math.atan2(c.y-l,c.x-h);F=n(F),d=n(d);let Y=d-F;if(Y<0&&(Y+=Math.PI*2),Math.abs(Y)<1e-6){const u=Math.abs(Math.hypot(e.u-h,e.v-l)-M);u<o&&(o=u,C={id:r.id,type:"arc"})}else{let u=n(Math.atan2(e.v-l,e.u-h))-F;u<0&&(u+=Math.PI*2),u=u/Y,u<0?u=0:u>1&&(u=1);const G=h+M*Math.cos(F+u*Y),y=l+M*Math.sin(F+u*Y),U=Math.hypot(e.u-G,e.v-y);U<o&&(o=U,C={id:r.id,type:"arc"})}}else if(r.type==="bezier"&&Array.isArray(r.points)&&r.points.length>=4){const a=r.points||[],w=Math.floor((a.length-1)/3);for(let c=0;c<w;c++){const h=c*3,l=t.points.find(u=>u.id===a[h]),M=t.points.find(u=>u.id===a[h+1]),F=t.points.find(u=>u.id===a[h+2]),d=t.points.find(u=>u.id===a[h+3]);if(!l||!M||!F||!d)continue;const Y=x(this,lA,AL).call(this,l,M,F,d,e,64);Y&&Y.dist<o&&(o=Y.dist,C={id:r.id,type:"bezier",segmentIndex:c,t:Y.t})}}return C&&o<=s?C:null},"#hitTestGeometry"),Y7=E(function(g,A){if(!this._solver)return!1;const e=this._solver.sketchObject;if(!e)return!1;const t=(e.geometries||[]).find(r=>r&&r.id===parseInt(g.id));if(!t)return!1;const B=x(this,lA,MB).call(this,A);if(!B)return!1;const i=new Map((e.points||[]).map(r=>[r.id,r])),I=x(this,lA,aL).call(this,t,i);if(!I||!Array.isArray(I.samples)||I.samples.length<2)return!1;const s=x(this,lA,m7).call(this,B,I.samples);if(!s||!Number.isFinite(s.param))return!1;const C=[],o=new Map;for(const r of e.geometries||[]){if(!r||r.id===t.id)continue;let a=o.get(r.id);a||(a=x(this,lA,aL).call(this,r,i),o.set(r.id,a)),a&&x(this,lA,R7).call(this,I,a,C,r,i)}const Q=x(this,lA,k7).call(this,C,s.param,I);if(!Q)return x(this,lA,QL).call(this,t.id);let n=!1;if(t.type==="line"?n=x(this,lA,y7).call(this,t,Q):t.type==="circle"?n=x(this,lA,rL).call(this,t,Q):t.type==="arc"?I.closed?n=x(this,lA,rL).call(this,t,Q):n=x(this,lA,U7).call(this,t,Q):t.type==="bezier"&&(n=x(this,lA,G7).call(this,t,Q,I)),n){if(this._selection.clear(),x(this,lA,c7).call(this),!x(this,lA,xn).call(this)){try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0}return x(this,lA,QL).call(this,t.id)},"#trimGeometry"),y7=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<2)return!1;const B=e.points.find(w=>w.id===t[0]),i=e.points.find(w=>w.id===t[1]);if(!B||!i)return!1;const I=1e-5,s=A.prev&&A.prev.param>I,C=A.next&&A.next.param<1-I;if(!s&&!C||s&&C&&A.next.param-A.prev.param<=I)return!1;const o=E(w=>{const c=B.x+(i.x-B.x)*w,h=B.y+(i.y-B.y)*w;return{x:c,y:h}},"pointAt"),Q=s?x(this,lA,bn).call(this,o(A.prev.param)):t[0],n=C?x(this,lA,bn).call(this,o(A.next.param)):t[1],r=E((w,c)=>{if(w==null||c==null||w===c)return!1;const h=e.points.find(M=>M.id===w),l=e.points.find(M=>M.id===c);return!h||!l||Math.hypot(h.x-l.x,h.y-l.y)<1e-7?!1:(x(this,lA,Ni).call(this,"line",[w,c],g),!0)},"addLine");let a=!1;return s&&(a=r(t[0],Q)||a),C&&(a=r(n,t[1])||a),s&&x(this,lA,Kn).call(this,Q,A.prev),C&&x(this,lA,Kn).call(this,n,A.next),a&&this._solver.removeGeometryById?.(g.id),a},"#trimLineGeometry"),U7=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<3)return!1;const B=e.points.find(h=>h.id===t[0]),i=e.points.find(h=>h.id===t[1]),I=e.points.find(h=>h.id===t[2]);if(!B||!i||!I)return!1;const s=Math.hypot(i.x-B.x,i.y-B.y);if(!Number.isFinite(s)||s<1e-9)return!1;const C=1e-5,o=A.prev&&A.prev.param>C,Q=A.next&&A.next.param<1-C;if(!o&&!Q||o&&Q&&A.next.param-A.prev.param<=C)return!1;const n=E(h=>{const l=Math.atan2(h.y-B.y,h.x-B.x);return{x:B.x+s*Math.cos(l),y:B.y+s*Math.sin(l)}},"pointOnCircle"),r=o?x(this,lA,bn).call(this,n(A.prev)):t[1],a=Q?x(this,lA,bn).call(this,n(A.next)):t[2],w=E((h,l)=>{if(h==null||l==null||h===l)return!1;const M=e.points.find(d=>d.id===h),F=e.points.find(d=>d.id===l);return!M||!F||Math.hypot(M.x-F.x,M.y-F.y)<1e-7?!1:(x(this,lA,Ni).call(this,"arc",[t[0],h,l],g),!0)},"addArc");let c=!1;return o&&(c=w(t[1],r)||c),Q&&(c=w(a,t[2])||c),o&&(x(this,lA,Kn).call(this,r,A.prev),x(this,lA,Wc).call(this,g,r)),Q&&(x(this,lA,Kn).call(this,a,A.next),x(this,lA,Wc).call(this,g,a)),c&&this._solver.removeGeometryById?.(g.id),c},"#trimArcGeometry"),rL=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<2)return!1;const B=e.points.find(r=>r.id===t[0]),i=e.points.find(r=>r.id===t[1]);if(!B||!i)return!1;const I=Math.hypot(i.x-B.x,i.y-B.y);if(!Number.isFinite(I)||I<1e-9||!A.prev||!A.next)return!1;const s=A.maxParam||1,C=(A.next.param-A.prev.param+s)%s;if(C<1e-5||C>s-1e-5)return!1;const o=E(r=>{const a=Math.atan2(r.y-B.y,r.x-B.x);return{x:B.x+I*Math.cos(a),y:B.y+I*Math.sin(a)}},"pointOnCircle"),Q=x(this,lA,bn).call(this,o(A.prev)),n=x(this,lA,bn).call(this,o(A.next));return Q==null||n==null||Q===n||!x(this,lA,Ni).call(this,"arc",[t[0],n,Q],g)?!1:(x(this,lA,Kn).call(this,Q,A.prev),x(this,lA,Kn).call(this,n,A.next),x(this,lA,Wc).call(this,g,Q),x(this,lA,Wc).call(this,g,n),this._solver.removeGeometryById?.(g.id),!0)},"#trimCircleGeometry"),G7=E(function(g,A,e){if(!this._solver?.sketchObject||!g||!Array.isArray(g.points))return!1;const t=e?.segCount||Math.floor((g.points.length-1)/3);if(t<1)return!1;const B=A.prev||null,i=A.next||null;if(!B&&!i||B&&i&&i.param-B.param<=1e-5)return!1;const I=[];if(B){const c=Math.min(t-1,Math.max(0,Math.floor(B.param))),h=B.param-c;I.push({kind:"prev",segIndex:c,t:h,pos:B.param})}if(i){const c=Math.min(t-1,Math.max(0,Math.floor(i.param))),h=i.param-c;I.push({kind:"next",segIndex:c,t:h,pos:i.param})}I.sort((c,h)=>c.pos-h.pos);let s=0;if(I.length===2&&I[0].segIndex===I[1].segIndex){const c=I[0],h=I[1];if(h.t-c.t<1e-5)return!1;const l=x(this,lA,Mm).call(this,g,c.segIndex+s,c.t);if(!l)return!1;c.anchorIndex=l.anchorIndex,s+=1;const M=(h.t-c.t)/(1-c.t),F=x(this,lA,Mm).call(this,g,c.segIndex+s,M);if(!F)return!1;h.anchorIndex=F.anchorIndex}else for(const c of I){const h=x(this,lA,Mm).call(this,g,c.segIndex+s,c.t);if(!h)return!1;c.anchorIndex=h.anchorIndex,s+=1}const C=Math.floor((g.points.length-1)/3),o=I.find(c=>c.kind==="prev"),Q=I.find(c=>c.kind==="next"),n=o?Math.floor(o.anchorIndex/3):0,r=Q?Math.floor(Q.anchorIndex/3):C;if(r<=n)return!1;const a=[];n>0&&a.push([0,n]),r<C&&a.push([r,C]);let w=!1;for(const[c,h]of a){if(h-c<1)continue;const l=c*3,M=h*3,F=g.points.slice(l,M+1);F.length>=4&&(x(this,lA,Ni).call(this,"bezier",F,g),w=!0)}return w&&this._solver.removeGeometryById?.(g.id),w},"#trimBezierGeometry"),N7=E(function(g,A){if(!g||!A||!Array.isArray(g.points))return[];if(g.type==="line"&&g.points.length>=2){const e=A.get(g.points[0]),t=A.get(g.points[1]);return[e?{point:e,param:0}:null,t?{point:t,param:1}:null].filter(Boolean)}if(g.type==="arc"&&g.points.length>=3){const e=A.get(g.points[1]),t=A.get(g.points[2]);return[e?{point:e,param:0}:null,t?{point:t,param:1}:null].filter(Boolean)}if(g.type==="bezier"&&g.points.length>=4){const e=Math.floor((g.points.length-1)/3);if(e<1)return[];const t=A.get(g.points[0]),B=A.get(g.points[g.points.length-1]);return[t?{point:t,param:0}:null,B?{point:B,param:e}:null].filter(Boolean)}return[]},"#getGeometryEndpointInfos"),f7=E(function(g){if(!Array.isArray(g)||g.length===0)return .001;let A=1/0,e=1/0,t=-1/0,B=-1/0;for(const C of g)C&&(C.x<A&&(A=C.x),C.y<e&&(e=C.y),C.x>t&&(t=C.x),C.y>B&&(B=C.y));const i=t-A,I=B-e,s=Math.hypot(i,I);return!Number.isFinite(s)||s<1e-9?.001:Math.max(1e-5,Math.min(.01,s*.001))},"#sampleTol"),p7=E(function(g,A,e,t,B,i){const I=e-g,s=t-A,C=B-g,o=i-A,Q=I*I+s*s||1e-12;let n=(C*I+o*s)/Q;n<0?n=0:n>1&&(n=1);const r=g+I*n,a=A+s*n;return Math.hypot(B-r,i-a)},"#distancePointToSeg"),Mm=E(function(g,A,e){const t=this._solver?.sketchObject;if(!t||!g||!Array.isArray(g.points))return null;const B=g.points,i=Math.floor((B.length-1)/3);if(A<0||A>=i)return null;const I=A*3,s=t.points.find(N=>N.id===B[I]),C=t.points.find(N=>N.id===B[I+1]),o=t.points.find(N=>N.id===B[I+2]),Q=t.points.find(N=>N.id===B[I+3]);if(!s||!C||!o||!Q)return null;const n=Math.min(.9999,Math.max(1e-4,e)),r=E((N,f,m)=>({x:N.x+(f.x-N.x)*m,y:N.y+(f.y-N.y)*m}),"lerp"),a={x:s.x,y:s.y},w={x:C.x,y:C.y},c={x:o.x,y:o.y},h={x:Q.x,y:Q.y},l=r(a,w,n),M=r(w,c,n),F=r(c,h,n),d=r(l,M,n),Y=r(M,F,n),u=r(d,Y,n);C.x=l.x,C.y=l.y,o.x=F.x,o.y=F.y;const G=x(this,lA,Yt).call(this,d.x,d.y,!1),y=x(this,lA,Yt).call(this,u.x,u.y,!1),U=x(this,lA,Yt).call(this,Y.x,Y.y,!1);return G==null||y==null||U==null?null:(g.points.splice(I+2,0,G,y,U),x(this,lA,Ni).call(this,"line",[y,G],null,{construction:!0}),x(this,lA,Ni).call(this,"line",[y,U],null,{construction:!0}),{anchorIndex:I+3,anchorId:y})},"#splitBezierAt"),aL=E(function(g,A){if(!g||!A)return null;const e=E(t=>A.get(t),"get");if(g.type==="line"&&Array.isArray(g.points)&&g.points.length>=2){const t=e(g.points[0]),B=e(g.points[1]);return!t||!B?null:{type:"line",closed:!1,maxParam:1,segCount:1,samples:[{x:t.x,y:t.y,param:0},{x:B.x,y:B.y,param:1}]}}if(g.type==="circle"&&Array.isArray(g.points)&&g.points.length>=2){const t=e(g.points[0]),B=e(g.points[1]);if(!t||!B)return null;const i=Math.hypot(B.x-t.x,B.y-t.y);if(!Number.isFinite(i)||i<1e-9)return null;const I=96,s=[];for(let C=0;C<=I;C++){const o=C/I,Q=o*Math.PI*2;s.push({x:t.x+i*Math.cos(Q),y:t.y+i*Math.sin(Q),param:o})}return{type:"circle",closed:!0,maxParam:1,segCount:1,samples:s}}if(g.type==="arc"&&Array.isArray(g.points)&&g.points.length>=3){const t=e(g.points[0]),B=e(g.points[1]),i=e(g.points[2]);if(!t||!B||!i)return null;const I=Math.hypot(B.x-t.x,B.y-t.y);if(!Number.isFinite(I)||I<1e-9)return null;let s=Math.atan2(B.y-t.y,B.x-t.x),C=Math.atan2(i.y-t.y,i.x-t.x)-s;C=(C%(2*Math.PI)+2*Math.PI)%(2*Math.PI);const o=C<1e-6;o&&(C=2*Math.PI);const Q=Math.max(8,Math.ceil(96*(C/(2*Math.PI)))),n=[];for(let r=0;r<=Q;r++){const a=r/Q,w=s+C*a;n.push({x:t.x+I*Math.cos(w),y:t.y+I*Math.sin(w),param:a})}return{type:"arc",closed:o,maxParam:1,segCount:1,samples:n}}if(g.type==="bezier"&&Array.isArray(g.points)&&g.points.length>=4){const t=g.points,B=Math.floor((t.length-1)/3);if(B<1)return null;const i=24,I=[];for(let s=0;s<B;s++){const C=s*3,o=e(t[C]),Q=e(t[C+1]),n=e(t[C+2]),r=e(t[C+3]);if(!(!o||!Q||!n||!r))for(let a=0;a<=i;a++){if(s>0&&a===0)continue;const w=a/i,c=1-w,h=c*c*c*o.x+3*c*c*w*Q.x+3*c*w*w*n.x+w*w*w*r.x,l=c*c*c*o.y+3*c*c*w*Q.y+3*c*w*w*n.y+w*w*w*r.y;I.push({x:h,y:l,param:s+w})}}return{type:"bezier",closed:!1,maxParam:B,segCount:B,samples:I}}return null},"#sampleGeometry"),m7=E(function(g,A){if(!g||!Array.isArray(A)||A.length<2)return null;const e=x(this,lA,cL).call(this,g.u,g.v,A);return e?{param:e.param,dist:e.dist}:null},"#closestParamOnSamples"),cL=E(function(g,A,e){if(!Array.isArray(e)||e.length<2)return null;let t={param:e[0].param,x:e[0].x,y:e[0].y,dist:1/0};for(let B=0;B<e.length-1;B++){const i=e[B],I=e[B+1],s=I.x-i.x,C=I.y-i.y,o=g-i.x,Q=A-i.y,n=s*s+C*C||1e-12;let r=(o*s+Q*C)/n;r<0?r=0:r>1&&(r=1);const a=i.x+s*r,w=i.y+C*r,c=Math.hypot(g-a,A-w),h=i.param+(I.param-i.param)*r;c<t.dist&&(t={param:h,x:a,y:w,dist:c})}return t},"#closestPointOnSamples"),R7=E(function(g,A,e,t,B){const i=g?.samples,I=A?.samples;if(!Array.isArray(i)||!Array.isArray(I)||i.length<2||I.length<2)return;for(let C=0;C<i.length-1;C++){const o=i[C],Q=i[C+1];for(let n=0;n<I.length-1;n++){const r=I[n],a=I[n+1],w=x(this,lA,H7).call(this,o,Q,r,a);if(!w)continue;const c=o.param+(Q.param-o.param)*w.ta,h=r.param+(a.param-r.param)*w.tb;e.push({param:c,x:w.x,y:w.y,otherParam:h,otherGeoId:t?.id??null,otherType:t?.type??null})}}const s=x(this,lA,N7).call(this,t,B);s.length&&x(this,lA,S7).call(this,g,s,e,t)},"#collectIntersections"),S7=E(function(g,A,e,t){const B=g?.samples;if(!Array.isArray(B)||B.length<2||!Array.isArray(A)||A.length<1)return;const i=x(this,lA,f7).call(this,B);for(const I of A){const s=I?.point;if(!s)continue;const C=x(this,lA,cL).call(this,s.x,s.y,B);!C||!Number.isFinite(C.param)||!Number.isFinite(C.dist)||C.dist>i||e.push({param:C.param,x:s.x,y:s.y,otherParam:Number.isFinite(I.param)?I.param:null,otherGeoId:t?.id??null,otherType:t?.type??null,endpointSnap:!0})}},"#collectEndpointIntersectionsOnTarget"),H7=E(function(g,A,e,t,B=1e-9){const i=A.x-g.x,I=A.y-g.y,s=t.x-e.x,C=t.y-e.y,o=i*C-I*s;if(Math.abs(o)<B)return null;const Q=((e.x-g.x)*C-(e.y-g.y)*s)/o,n=((e.x-g.x)*I-(e.y-g.y)*i)/o;if(Q<-B||Q>1+B||n<-B||n>1+B)return null;const r=Math.min(1,Math.max(0,Q));return{x:g.x+i*r,y:g.y+I*r,ta:r,tb:Math.min(1,Math.max(0,n))}},"#segmentIntersection"),k7=E(function(g,A,e){const t=e?.maxParam||1,B=Math.max(1e-5,t*1e-4),i=[];for(const o of g||[]){if(!o||!Number.isFinite(o.param))continue;let Q=o.param;if(e?.closed)Q=(Q%t+t)%t,(Q<B||Q>t-B)&&(Q=0);else if(Q<=B||Q>=t-B)continue;i.push({...o,param:Q,x:o.x,y:o.y})}i.sort((o,Q)=>o.param-Q.param);const I=[];for(const o of i){const Q=I[I.length-1];!Q||Math.abs(o.param-Q.param)>B?I.push(o):!Q.endpointSnap&&o.endpointSnap&&(I[I.length-1]=o)}if(e?.closed){if(I.length<2)return null;let o=null,Q=null,n=1/0,r=-1/0;for(const a of I){let w=a.param-A;w=(w%t+t)%t,!(w<B)&&(w<n&&(n=w,Q=a),w>r&&(r=w,o=a))}return!o||!Q?null:{prev:o,next:Q,closed:!0,maxParam:t}}if(!I.length)return null;let s=null,C=null;for(const o of I)if(o.param<A-B)s=o;else if(o.param>A+B){C=o;break}return!s&&!C?null:{prev:s,next:C,closed:!1,maxParam:t}},"#selectTrimBounds"),J7=E(function(g,A,e=1e-6){const t=this._solver?.sketchObject;if(!t||!Array.isArray(t.points))return null;for(const B of t.points)if(Math.hypot(B.x-g,B.y-A)<=e)return B.id;return null},"#findExistingPointId"),bn=E(function(g){return x(this,lA,J7).call(this,g.x,g.y)??x(this,lA,Yt).call(this,g.x,g.y,!1)},"#getOrCreatePointId"),Kn=E(function(g,A){if(!A||g==null)return!1;const e=this._solver?.sketchObject;if(!e)return!1;const t=A.otherGeoId;if(t==null)return!1;const B=(e.geometries||[]).find(i=>i&&i.id===parseInt(t));return!B||!B.type?!1:B.type==="line"?x(this,lA,wL).call(this,B,g,A):B.type==="arc"||B.type==="circle"?x(this,lA,Wc).call(this,B,g):!1},"#applyTrimIntersectionConstraint"),wL=E(function(g,A,e){const t=this._solver?.sketchObject;if(!t||!g)return!1;const B=Array.isArray(g.points)?g.points:[];if(B.length<2)return!1;const i=B[0],I=B[1],s=t.points.find(h=>h.id===i),C=t.points.find(h=>h.id===I),o=t.points.find(h=>h.id===A);if(!s||!C||!o)return!1;const Q=Math.hypot(C.x-s.x,C.y-s.y)||1,n=.001,r=Math.max(1e-5,Math.min(.01,Q*.001)),a=Number.isFinite(e?.otherParam)?e.otherParam:null,w=a!=null&&a<=n||Math.hypot(o.x-s.x,o.y-s.y)<=r,c=a!=null&&a>=1-n||Math.hypot(o.x-C.x,o.y-C.y)<=r;return w&&A!==i?x(this,lA,VQ).call(this,"≡",[i,A]):c&&A!==I?x(this,lA,VQ).call(this,"≡",[I,A]):A===i||A===I?!1:x(this,lA,VQ).call(this,"⏛",[i,I,A])},"#ensurePointOnLineConstraint"),Wc=E(function(g,A){if(!this._solver?.sketchObject||!g)return!1;const e=Array.isArray(g.points)?g.points:[];if(e.length<2)return!1;const t=e[0],B=e[1];return t==null||B==null||A===t||A===B?!1:x(this,lA,VQ).call(this,"⇌",[t,B,t,A])},"#ensurePointOnArcConstraint"),VQ=E(function(g,A){const e=this._solver?.sketchObject;if(!e||!Array.isArray(A)||(Array.isArray(e.constraints)||(e.constraints=[]),e.constraints.some(B=>x(this,lA,T7).call(this,B,g,A))))return!1;const t=Math.max(0,...e.constraints.map(B=>+B.id||0))+1;return e.constraints.push({id:t,type:g,points:A.slice(),labelX:0,labelY:0,displayStyle:"",value:null,valueNeedsSetup:!0}),!0},"#addConstraintIfMissing"),T7=E(function(g,A,e){if(!g||g.type!==A||!Array.isArray(g.points))return!1;if(A==="≡"){if(e.length<2||g.points.length<2)return!1;const[t,B]=e,[i,I]=g.points;return i===t&&I===B||i===B&&I===t}if(A==="⏛"){if(e.length<3||g.points.length<3)return!1;const[t,B,i]=e,[I,s,C]=g.points;return(I===t&&s===B||I===B&&s===t)&&C===i}if(A==="⇌"){if(e.length<4||g.points.length<4)return!1;const[t,B,i,I]=e,[s,C,o,Q]=g.points,n=E((w,c,h,l)=>w===h&&c===l||w===l&&c===h,"samePair"),r=n(s,C,t,B)&&n(o,Q,i,I),a=n(s,C,i,I)&&n(o,Q,t,B);return r||a}return!1},"#constraintMatches"),Ni=E(function(g,A,e=null,t={}){const B=this._solver?.sketchObject;if(!B)return null;const i=Math.max(0,...B.geometries.map(s=>+s.id||0))+1,I=typeof t.construction=="boolean"?t.construction:!!e?.construction;return B.geometries.push({id:i,type:g,points:A,construction:I}),i},"#addGeometry"),lL=E(function(g){const A=this.viewer;if(!A)return null;const e=A.renderer.domElement.getBoundingClientRect(),t=new LA((g.clientX-e.left)/e.width*2-1,-((g.clientY-e.top)/e.height*2-1));x(this,lA,hm).call(this,t);try{const{width:I,height:s}=x(this,lA,zi).call(this,A.renderer.domElement),C=x(this,lA,wI).call(this,A.camera,I,s);this._raycaster.params.Line=this._raycaster.params.Line||{},this._raycaster.params.Line.threshold=Math.max(.05,C*6);const o=window.devicePixelRatio||1;this._raycaster.params.Line2=this._raycaster.params.Line2||{},this._raycaster.params.Line2.threshold=Math.max(1,2*o)}catch{}const B=[];try{A.scene.traverse(I=>{I&&I.type==="EDGE"&&I.visible!==!1&&B.push(I)})}catch{}const i=B.length?this._raycaster.intersectObjects(B,!0):[];return i&&i.length?i[0]:null},"#hitTestSceneEdge"),hL=E(function(g){const A=this.viewer;if(!A||!this._solver||!this._lock)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject;if(!t)return null;const B=E(h=>t.points.find(l=>l.id===h),"P"),{width:i,height:I}=x(this,lA,zi).call(this,A.renderer.domElement),s=x(this,lA,wI).call(this,A.camera,i,I),C=Math.max(.05,s*10),o=E((h,l,M,F,d,Y)=>{const u=M-h,G=F-l,y=d-h,U=Y-l,N=u*u+G*G||1e-12;let f=(y*u+U*G)/N;f<0?f=0:f>1&&(f=1);const m=h+u*f,R=l+G*f;return Math.hypot(d-m,Y-R)},"distToSeg"),Q=E((h,l,M)=>{const F=Number(h?.du),d=Number(h?.dv);if(Number.isFinite(F)||Number.isFinite(d))return{du:Number.isFinite(F)?F:0,dv:Number.isFinite(d)?d:0};const Y=(M?.x??0)-(l?.x??0),u=(M?.y??0)-(l?.y??0),G=Math.hypot(Y,u),y=G>1e-9?Y/G:1,U=G>1e-9?u/G:0,N=-U,f=y;if(h&&(h.dr!==void 0||h.dp!==void 0)){const R=Number(h.dr)||0,p=Number(h.dp)||0;return{du:Y+y*R+N*p,dv:u+U*R+f*p}}const m=Math.max(.2,G*.35);return{du:Y+y*m+N*m*.35,dv:u+U*m+f*m*.35}},"radialOffsetToPlane"),n=E(h=>{const l=h?.radialGeometryType;if(l==="arc"||l==="circle")return l;if(!Array.isArray(t?.geometries)||!Array.isArray(h?.points)||h.points.length<2)return null;const M=parseInt(h.points[0]),F=parseInt(h.points[1]);if(!Number.isFinite(M)||!Number.isFinite(F))return null;let d=!1;for(const Y of t.geometries||[])if(!(!Y||!Array.isArray(Y.points)||Y.points.length<2)){if(Y.type==="arc"&&Y.points.length>=3){const u=parseInt(Y.points[0]),G=parseInt(Y.points[1]),y=parseInt(Y.points[2]);if(u===M&&(G===F||y===F))return"arc"}else if(Y.type==="circle"){const u=parseInt(Y.points[0]),G=parseInt(Y.points[1]);u===M&&G===F&&(d=!0)}}return d?"circle":null},"resolveRadialGeometryType"),r=E((h,l,M,F)=>{const d=(h.x-l.x)*(M.y-F.y)-(h.y-l.y)*(M.x-F.x);if(Math.abs(d)<1e-9)return{x:l.x,y:l.y};const Y=((h.x*h.y-l.x*l.y)*(M.x-F.x)-(h.x-l.x)*(M.x*M.y-F.x*F.y))/d,u=((h.x*h.y-l.x*l.y)*(M.y-F.y)-(h.y-l.y)*(M.x*M.y-F.x*F.y))/d;return{x:Y,y:u}},"intersect"),a=E(h=>{if(!h||!Array.isArray(h.points))return null;if(h.type==="⟺"&&h.points.length>=2&&h.displayStyle!=="radius"&&h.displayStyle!=="diameter"){const l=B(h.points[0]),M=B(h.points[1]);return!l||!M?null:{a:l,b:M}}if(h.type===ny&&h.points.length>=3){const l=B(h.points[0]),M=B(h.points[1]),F=B(h.points[2]);if(!l||!M||!F)return null;const d=M.x-l.x,Y=M.y-l.y,u=d*d+Y*Y;if(!(u>1e-12))return{a:l,b:F};let G=((F.x-l.x)*d+(F.y-l.y)*Y)/u;return Number.isFinite(G)||(G=0),{a:{x:l.x+G*d,y:l.y+G*Y},b:{x:F.x,y:F.y}}}return null},"linearDistanceEndpoints");let w=null,c=1/0;for(const h of t.constraints||[])if((h.type==="⟺"||h.type===ny)&&Array.isArray(h.points))if(h.type==="⟺"&&(h.displayStyle==="radius"||h.displayStyle==="diameter")){const l=B(h.points[0]),M=B(h.points[1]);if(!l||!M)continue;const F=Q(this._dimOffsets.get(h.id)||{},l,M),d=l.x+F.du,Y=l.y+F.dv,u=M.x-l.x,G=M.y-l.y,y=Math.hypot(u,G);if(!(y>1e-9))continue;let U=d-l.x,N=Y-l.y,f=Math.hypot(U,N);f>1e-9||(U=u,N=G,f=Math.hypot(U,N)||1),U/=f,N/=f;const m=l.x+U*y,R=l.y+N*y,p=l.x-U*y,k=l.y-N*y;let H=o(m,R,d,Y,e.u,e.v);h.displayStyle==="diameter"?(H=Math.min(H,o(p,k,m,R,e.u,e.v)),n(h)==="arc"&&(H=Math.min(H,Math.abs(Math.hypot(e.u-l.x,e.v-l.y)-y)))):H=Math.min(H,o(l.x,l.y,m,R,e.u,e.v)),H<c&&(c=H,w=h.id)}else{const l=a(h);if(!l)continue;const M=o(l.a.x,l.a.y,l.b.x,l.b.y,e.u,e.v);M<c&&(c=M,w=h.id)}else if(h.type==="∠"&&Array.isArray(h.points)&&h.points.length>=4){const l=B(h.points[0]),M=B(h.points[1]),F=B(h.points[2]),d=B(h.points[3]);if(!l||!M||!F||!d)continue;const Y=r(l,M,F,d),u=Math.max(.2,s*12),G=Math.abs(Math.hypot(e.u-Y.x,e.v-Y.y)-u);G<c&&(c=G,w=h.id)}return w!=null&&c<=C?{cid:w}:null},"#hitTestDim"),Fm=E(function(g){const A=this.viewer;if(!A||!this._lock||!this._glyphCenters)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const{width:t,height:B}=x(this,lA,zi).call(this,A.renderer.domElement),i=x(this,lA,wI).call(this,A.camera,t,B),I=Math.max(.05,i*8);let s=null,C=1/0;try{for(const[o,Q]of this._glyphCenters.entries()){const n=Math.hypot(e.u-Q.u,e.v-Q.v);n<C&&(C=n,s=o)}}catch{}return s!=null&&C<=I?{cid:s}:null},"#hitTestGlyph"),dm=E(function(g,A){const e=this._theme?.[g];if(e==null)return A;try{return new se(e).getHex()}catch{return A}},"#themeColor"),DL=E(function(g,A,e=-1/0,t=1/0){const B=this._theme?.[g],i=Number(B),I=Number.isFinite(i)?i:A;return Number.isFinite(I)?Math.max(e,Math.min(t,I)):A},"#themeNumber"),Ln=E(function(g,A){const e=x(this,lA,wI).call(this,this.viewer.camera,g,A),t=x(this,lA,DL).call(this,"pointSizePx",8,1,128);return Math.max(.02,e*t*.5)},"#pointRadiusWorld"),Cg=E(function(){const g=this._sketchGroup;if(!g||!this._solver)return;for(let u=g.children.length-1;u>=0;u--){const G=g.children[u];g.remove(G);try{G.geometry?.dispose(),G.material?.dispose?.()}catch{}}const A=this._solver.sketchObject,e=this._lock?.basis;if(!e)return;x(this,lA,bo).call(this);const t=new Set;try{for(const u of A.constraints||[])if(!(!u||u.temporary||!Array.isArray(u.points)))for(const G of u.points)t.add(parseInt(G))}catch{}const B=e.origin,i=e.x,I=e.y,s=x(this,lA,dm).call(this,"geometryColor",16777096),C=x(this,lA,dm).call(this,"pointColor",10406399),o=x(this,lA,dm).call(this,"constructionPointColor",16754794),Q=x(this,lA,DL).call(this,"curveThicknessPx",1,.5,48),n=this._useFatCurveLines===!0||Q>1,r=E((u,G)=>new K().copy(B).addScaledVector(i,u).addScaledVector(I,G),"to3"),a=new hg({color:s,linewidth:Q,depthTest:!1,depthWrite:!1,transparent:!0}),w=new r0({color:s,linewidth:Q,depthTest:!1,depthWrite:!1,transparent:!0,dashSize:.1,gapSize:.08});let c=.05,h=1,l=1;try{const{width:u,height:G}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);h=Math.max(1,u||1),l=Math.max(1,G||1),c=x(this,lA,wI).call(this,this.viewer.camera,u,G)}catch{}const M=E((u,G,y)=>{if(!Array.isArray(u)||u.length<2||!G)return;const U=Array.from(this._selection).some(m=>m.type==="geometry"&&m.id===G.id)?7332463:s,N=G.construction===!0;let f=null;if(!N&&n){const m=[];for(const k of u)m.push(k.x,k.y,k.z);const R=new YB;R.setPositions(m);const p=new ri({color:U,linewidth:Q,worldUnits:!1,dashed:!1,transparent:!0,depthTest:!1,depthWrite:!1,toneMapped:!1});try{p.resolution?.set?.(h,l)}catch{}f=new Lw(R,p)}else{const m=new ce().setFromPoints(u),R=N?w.clone():a.clone();if(N)try{R.dashSize=Math.max(.02,8*c),R.gapSize=Math.max(.01,6*c)}catch{}try{R.color.set(U)}catch{}if(f=new lt(m,R),N)try{f.computeLineDistances()}catch{}}f&&(f.renderOrder=1e4,f.userData={kind:"geometry",id:G.id,type:y},g.add(f))},"addCurveObject");for(const u of A.geometries||[])if(u.type==="line"&&u.points?.length===2){const G=A.points.find(U=>U.id===u.points[0]),y=A.points.find(U=>U.id===u.points[1]);if(!G||!y)continue;M([r(G.x,G.y),r(y.x,y.y)],u,"line")}else if(u.type==="circle"){const G=u.points||[],y=A.points.find(R=>R.id===G[0]),U=A.points.find(R=>R.id===G[1]);if(!y||!U)continue;const N=Math.hypot(U.x-y.x,U.y-y.y),f=64,m=[];for(let R=0;R<=f;R++){const p=R/f*Math.PI*2;m.push(r(y.x+N*Math.cos(p),y.y+N*Math.sin(p)))}M(m,u,u.type)}else if(u.type==="arc"){const G=u.points||[],y=A.points.find(z=>z.id===G[0]),U=A.points.find(z=>z.id===G[1]),N=A.points.find(z=>z.id===G[2]);if(!y||!U||!N)continue;const f=y.x,m=y.y,R=Math.hypot(U.x-f,U.y-m);let p=Math.atan2(U.y-m,U.x-f),k=Math.atan2(N.y-m,N.x-f)-p;k=(k%(2*Math.PI)+2*Math.PI)%(2*Math.PI),Math.abs(k)<1e-6&&(k=2*Math.PI);const H=Math.max(8,Math.ceil(64*k/(2*Math.PI))),S=[];for(let z=0;z<=H;z++){const v=p+k*(z/H);S.push(r(f+R*Math.cos(v),m+R*Math.sin(v)))}M(S,u,u.type)}else if(u.type==="bezier"){const G=u.points||[],y=Math.floor((G.length-1)/3);if(y<1)continue;const U=64,N=[];for(let f=0;f<y;f++){const m=f*3,R=A.points.find(S=>S.id===G[m]),p=A.points.find(S=>S.id===G[m+1]),k=A.points.find(S=>S.id===G[m+2]),H=A.points.find(S=>S.id===G[m+3]);if(!(!R||!p||!k||!H))for(let S=0;S<=U;S++){if(f>0&&S===0)continue;const z=S/U,v=1-z,X=v*v*v*R.x+3*v*v*z*p.x+3*v*z*z*k.x+z*z*z*H.x,b=v*v*v*R.y+3*v*v*z*p.y+3*v*z*z*k.y+z*z*z*H.y;N.push(r(X,b))}}M(N,u,u.type)}const{width:F,height:d}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);c=x(this,lA,wI).call(this,this.viewer.camera,F,d);const Y=x(this,lA,Ln).call(this,F,d);for(const u of A.points||[]){const G=Array.from(this._selection).some(p=>p.type==="point"&&p.id===u.id),y=u?.construction===!0,U=!G&&!u.fixed&&!t.has(u.id),N=y?o:C,f=this._uniformPointColor||y?N:U?16757575:N,m=new Pg({color:G?7332463:f,depthTest:!1,depthWrite:!1,transparent:!0}),R=new Bg(this._handleGeom,m);R.renderOrder=10001,R.position.copy(r(u.x,u.y)),R.userData={kind:"point",id:u.id,underConstrained:U,isConstructionPoint:y,isExternalReference:x(this,lA,wy).call(this,u.id)},R.scale.setScalar(G?Y*2:Y),g.add(R)}x(this,lA,Gi).call(this),x(this,lA,MC).call(this),x(this,lA,r7).call(this),x(this,lA,iL).call(this)},"#rebuildSketchGraphics"),iGA=E(function(){if(!this._sketchGroup)return;const{width:g,height:A}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);x(this,lA,x7).call(this,g,A);const e=x(this,lA,Ln).call(this,g,A);if(!(Math.abs(e-this._lastHandleScale)<1e-4)){this._lastHandleScale=e;for(const t of this._sketchGroup.children)if(t?.userData?.kind==="point"){const B=Array.from(this._selection).some(i=>i.type==="point"&&i.id===t.userData.id);t.scale.setScalar(B?e*2:e)}}},"#updateHandleSizes"),x7=E(function(g,A){const e=Math.max(1,Number(g)||1),t=Math.max(1,Number(A)||1);for(const B of this._sketchGroup?.children||[]){const i=B?.material;if(!(!i||typeof i!="object"))try{i.resolution&&typeof i.resolution.set=="function"&&i.resolution.set(e,t)}catch{}}},"#updateFatLineResolutions"),IGA=E(function(){const g=this.viewer?.container;if(!g)return;const A=document.createElement("div");A.className="sketch-dims",A.style.position="absolute",A.style.left="0",A.style.top="0",A.style.right="0",A.style.bottom="0",A.style.pointerEvents="none";const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",A.appendChild(e),this._dimSVG=e,g.appendChild(A),this._dimRoot=A},"#mountDimRoot"),MC=E(function(){try{h3(this)}catch{}},"#renderDimensions"),b7=E(function(g){const A=this._solver?.sketchObject;if(!A)return null;const e=parseInt(g);return(A.constraints||[]).find(t=>parseInt(t.id)===e)||null},"#getConstraintById"),K7=E(function(g){if(!this._dragDim.active)return;const A=x(this,lA,MB).call(this,g);if(!A)return;const e=x(this,lA,b7).call(this,this._dragDim.cid);if(!e)return;const t=this._solver.sketchObject;if(e.type==="⟺"&&e.displayStyle==="radius"&&(e.points||[]).length>=2){const B=t.points.find(l=>l.id===e.points[0]),i=t.points.find(l=>l.id===e.points[1]);if(!B||!i)return;const I=i.x-B.x,s=i.y-B.y,C=Math.hypot(I,s)||1,o=I/C,Q=s/C,n=-Q,r=o,a=A.u-i.x,w=A.v-i.y,c=this._dragDim.start.dr+(a*o+w*Q),h=this._dragDim.start.dp+(a*n+w*r);this._dimOffsets.set(this._dragDim.cid,{dr:c,dp:h})}else if((e.type==="⟺"||e.type===ny)&&(e.points||[]).length>=2){let B=null,i=null;if(e.type===ny&&(e.points||[]).length>=3){const a=t.points.find(F=>F.id===e.points[0]),w=t.points.find(F=>F.id===e.points[1]),c=t.points.find(F=>F.id===e.points[2]);if(!a||!w||!c)return;const h=w.x-a.x,l=w.y-a.y,M=h*h+l*l;if(!(M>1e-12))B=a,i=c;else{let F=((c.x-a.x)*h+(c.y-a.y)*l)/M;Number.isFinite(F)||(F=0),B={x:a.x+F*h,y:a.y+F*l},i={x:c.x,y:c.y}}}else B=t.points.find(a=>a.id===e.points[0]),i=t.points.find(a=>a.id===e.points[1]);if(!B||!i)return;const I=i.x-B.x,s=i.y-B.y,C=Math.hypot(I,s)||1,o=-(s/C),Q=I/C,n=(A.u-this._dragDim.sx)*o+(A.v-this._dragDim.sy)*Q,r=this._dragDim.start.d+n;this._dimOffsets.set(this._dragDim.cid,{d:r})}x(this,lA,MC).call(this),g.preventDefault(),g.stopPropagation()},"#moveDimDrag"),L7=E(function(g){this._dragDim.active=!1,this._dragDim.last=null;try{g.target.releasePointerCapture?.(g.pointerId)}catch{}g.preventDefault(),g.stopPropagation();try{this.viewer?.controls&&(this.viewer.controls.enabled=!0)}catch{}x(this,lA,iL).call(this),setTimeout(()=>{x(this,lA,um).call(this,g)},30)},"#endDimDrag"),um=E(function(g){try{this.viewer?.controls?.dispatchEvent?.({type:"end"})}catch{}},"#notifyControlsEnd"),E(sGA,"SketchMode3D");let CGA=sGA;const Y3="__embed_sketch_feature__",BJ=!1,iJ=1,G8A=100,N8A=1e-4,f8A=300,oGA={geometryColor:null,pointColor:null,constraintColor:null,backgroundColor:null,pointSizePx:null,curveThicknessPx:null};function RN(g={}){const A=Number(g?.pointSizePx??g?.pointSize),e=Number(g?.curveThicknessPx??g?.curveThickness);return{geometryColor:g?.geometryColor??null,pointColor:g?.pointColor??null,constraintColor:g?.constraintColor??null,backgroundColor:g?.backgroundColor??null,pointSizePx:Number.isFinite(A)&&A>0?A:null,curveThicknessPx:Number.isFinite(e)&&e>0?e:null}}D(RN,"_y");E(RN,"normalizeTheme$1");function QGA(g,A=!1){return g==null?A:g!==!1}D(QGA,"CkA");E(QGA,"normalizeSidebarExpanded$2");function IJ(g,A=BJ){if(g==null)return A;if(typeof g=="string"){const e=g.trim().toLowerCase();if(e==="false"||e==="0"||e==="off"||e==="no")return!1;if(e==="true"||e==="1"||e==="on"||e==="yes")return!0}return g!==!1&&g!==0}D(IJ,"jT");E(IJ,"normalizeGridVisible$1");function sJ(g,A=iJ){const e=Number(g);return!Number.isFinite(e)||e<=0?A:Math.max(1e-4,Math.min(1e6,e))}D(sJ,"VT");E(sJ,"normalizeGridSpacing$1");function CJ(g,A){return typeof g=="number"&&Number.isFinite(g)?`#${Math.max(0,Math.min(16777215,g|0)).toString(16).padStart(6,"0")}`:typeof g=="string"&&g.trim()?g.trim():A}D(CJ,"WT");E(CJ,"toCssColor");var ar,j7,EGA,nGA,rGA,aGA,qu;const cGA=(qu=class extends AC{constructor(A,e){super(),Og(this,ar),this.camera=A,this.domElement=e,this.enabled=!0,this.target=new K(0,0,0),this._panning=!1,this._lastX=0,this._lastY=0,this._boundPointerDown=t=>x(this,ar,EGA).call(this,t),this._boundPointerMove=t=>x(this,ar,nGA).call(this,t),this._boundPointerUp=()=>x(this,ar,rGA).call(this),this._boundWheel=t=>x(this,ar,aGA).call(this,t),this._boundContextMenu=t=>t.preventDefault(),e.addEventListener("pointerdown",this._boundPointerDown,{passive:!1}),window.addEventListener("pointermove",this._boundPointerMove,{passive:!1}),window.addEventListener("pointerup",this._boundPointerUp,{passive:!1}),e.addEventListener("wheel",this._boundWheel,{passive:!1}),e.addEventListener("contextmenu",this._boundContextMenu,{passive:!1})}update(){}updateMatrixState(){}dispose(){const A=this.domElement;A&&(A.removeEventListener("pointerdown",this._boundPointerDown),window.removeEventListener("pointermove",this._boundPointerMove),window.removeEventListener("pointerup",this._boundPointerUp),A.removeEventListener("wheel",this._boundWheel),A.removeEventListener("contextmenu",this._boundContextMenu))}},D(qu,"mV"),qu);ar=new WeakSet,j7=E(function(){const g=this.domElement,A=Math.max(1,g.clientWidth||g.width||1),e=Math.max(1,g.clientHeight||g.height||1);if(!this.camera?.isOrthographicCamera)return{x:.05,y:.05};const t=this.camera.zoom>0?this.camera.zoom:1;return{x:(this.camera.right-this.camera.left)/(A*t),y:(this.camera.top-this.camera.bottom)/(e*t)}},"#worldPerPixel"),EGA=E(function(g){this.enabled&&(g.button!==1&&g.button!==2||(g.preventDefault(),this._panning=!0,this._lastX=g.clientX,this._lastY=g.clientY))},"#onPointerDown"),nGA=E(function(g){if(!this.enabled||!this._panning)return;g.preventDefault();const A=g.clientX-this._lastX,e=g.clientY-this._lastY;this._lastX=g.clientX,this._lastY=g.clientY;const t=x(this,ar,j7).call(this),B=A*t.x,i=e*t.y;this.camera.position.x-=B,this.camera.position.y+=i,this.target.x-=B,this.target.y+=i,this.camera.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})},"#onPointerMove"),rGA=E(function(){this._panning&&(this._panning=!1,this.dispatchEvent({type:"end"}))},"#onPointerUp"),aGA=E(function(g){if(!this.enabled||!this.camera?.isOrthographicCamera)return;g.preventDefault();const A=Math.exp(g.deltaY*.0015),e=this.camera.zoom/A;this.camera.zoom=Math.max(N8A,Math.min(f8A,e)),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})},"#onWheel"),E(cGA,"Simple2DControls");let p8A=cGA;var aB,jG,Ez,nz,P7,oJ,wGA,rz,az,lGA,_u;const hGA=(_u=class{constructor({container:A,sidebar:e,theme:t=oGA,gridVisible:B=BJ,gridSpacing:i=iJ,featureID:I=Y3,onSketchChange:s=null,onSketchFinished:C=null,onSketchCancelled:o=null}){if(Og(this,aB),this.container=A,this.sidebar=e,this.theme=RN(t),this._dragThreshold=5,this._featureID=I,this._onSketchChange=s,this._onSketchFinished=C,this._onSketchCancelled=o,this._gridVisible=IJ(B,BJ),this._gridSpacing=sJ(i,iJ),this._gridHelper=null,this.scene=new Za,this.camera=new vC(-20,20,20,-20,.01,5e3),this.camera.position.set(0,0,80),this.camera.up.set(0,1,0),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.renderer=new sT({antialias:!0,alpha:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.setClearColor(CJ(this.theme.backgroundColor,"#ffffff"),1),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.display="block",this.renderer.domElement.style.touchAction="none",this.container.appendChild(this.renderer.domElement),this.controls=new p8A(this.camera,this.renderer.domElement),this._boundControlsChange=()=>{try{this._sketchMode?.onCameraChanged?.()}catch{}},this.controls.addEventListener("change",this._boundControlsChange),this.controls.addEventListener("end",this._boundControlsChange),x(this,aB,az).call(this),this.mainToolbar=new UUA(this),this._feature={inputParams:{featureID:this._featureID,sketchPlane:null},persistentData:{sketch:null,externalRefs:[]}},this.partHistory={scene:this.scene,features:[this._feature],runHistory:E(async()=>null,"runHistory"),queueHistorySnapshot:E(()=>null,"queueHistorySnapshot"),getObjectByName:E(Q=>this.scene.getObjectByName(Q)||null,"getObjectByName")},this._raf=0,this._running=!1,this._sketchMode=null,this._disposed=!1,this._resizeRaf=0,this._boundResize=()=>x(this,aB,oJ).call(this),this._boundResizeQueued=()=>x(this,aB,wGA).call(this),window.addEventListener("resize",this._boundResize),typeof ResizeObserver<"u"){this._resizeObserver=new ResizeObserver(this._boundResizeQueued);try{this._resizeObserver.observe(this.container)}catch{}}else this._resizeObserver=null;x(this,aB,oJ).call(this)}_getSidebarShouldShow(){return!0}render(){this.renderer.render(this.scene,this.camera)}start(A=null){A&&x(this,aB,jG).call(this,A),x(this,aB,Ez).call(this),x(this,aB,lGA).call(this)}stop(){this._running=!1,this._raf&&cancelAnimationFrame(this._raf),this._raf=0;try{this._sketchMode?.close?.()}catch{}this._sketchMode=null}dispose(){this._disposed=!0,this.stop(),this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=0,window.removeEventListener("resize",this._boundResize);try{this._resizeObserver?.disconnect?.()}catch{}this._resizeObserver=null;try{this.controls?.dispose?.()}catch{}try{this.controls?.removeEventListener?.("change",this._boundControlsChange)}catch{}try{this.controls?.removeEventListener?.("end",this._boundControlsChange)}catch{}try{this.mainToolbar?._ro?.disconnect?.()}catch{}try{this.mainToolbar?.root?.parentNode?.removeChild(this.mainToolbar.root)}catch{}x(this,aB,rz).call(this);try{this.renderer?.dispose?.()}catch{}try{this.renderer?.domElement?.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}catch{}}getSketch(){const A=this._sketchMode?.getSketchData?.()||this._feature?.persistentData?.sketch||null;return de(A)}setSketch(A){const e=de(A||null);return x(this,aB,jG).call(this,e),this._sketchMode?.setSketchData&&this._sketchMode.setSketchData(e),this.getSketch()}setTheme(A){this.theme=RN({...this.theme,...A||{}});try{this.renderer.setClearColor(CJ(this.theme.backgroundColor,"#ffffff"),1)}catch{}if(this._sketchMode){this._sketchMode._theme=this.theme;const e=this._sketchMode.getSketchData?.()||null;this._sketchMode.setSketchData?.(e)}}setGridOptions(A={}){const e=A?.gridVisible??A?.visible,t=A?.gridSpacing??A?.spacing;this._gridVisible=IJ(e,this._gridVisible),this._gridSpacing=sJ(t,this._gridSpacing),x(this,aB,az).call(this)}onSketchFinished(A,e){x(this,aB,jG).call(this,e);try{this._onSketchFinished&&this._onSketchFinished(de(e||null))}catch{}x(this,aB,nz).call(this)}onSketchCancelled(A){try{this._onSketchCancelled&&this._onSketchCancelled()}catch{}x(this,aB,nz).call(this)}},D(_u,"RV"),_u);aB=new WeakSet,jG=E(function(g){this._feature.persistentData=this._feature.persistentData||{},this._feature.persistentData.sketch=de(g||null)},"#setFeatureSketch"),Ez=E(function(){if(!this._disposed){try{this._sketchMode?.dispose?.()}catch{}this._sketchMode=new CGA(this,this._featureID,{theme:this.theme,uniformPointColor:!0,useFatCurveLines:!0,onSketchChange:E(g=>{x(this,aB,jG).call(this,g);try{this._onSketchChange&&this._onSketchChange(de(g))}catch{}},"onSketchChange")}),this._sketchMode.open()}},"#openSketchMode"),nz=E(function(){this._disposed||setTimeout(()=>{this._disposed||x(this,aB,Ez).call(this)},0)},"#reopenSketchModeSoon"),P7=E(function(g,A){const e=Math.max(1,g||1),t=Math.max(1,A||1),B=e/t,i=40*.5,I=i*B;this.camera.left=-I,this.camera.right=I,this.camera.top=i,this.camera.bottom=-i,this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0)},"#updateCameraFrustum"),oJ=E(function(){if(this._disposed)return;const g=this.container.getBoundingClientRect(),A=Math.max(1,Math.floor(g.width)),e=Math.max(1,Math.floor(g.height));this.renderer.setSize(A,e,!1),x(this,aB,P7).call(this,A,e),this.render()},"#onResize"),wGA=E(function(){this._disposed||this._resizeRaf||(this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=0,x(this,aB,oJ).call(this)}))},"#queueResize"),rz=E(function(){if(this._gridHelper){try{this.scene.remove(this._gridHelper)}catch{}try{const g=Array.isArray(this._gridHelper.material)?this._gridHelper.material:[this._gridHelper.material];for(const A of g)try{A?.dispose?.()}catch{}try{this._gridHelper.geometry?.dispose?.()}catch{}}catch{}this._gridHelper=null}},"#clearGrid"),az=E(function(){if(x(this,aB,rz).call(this),!this._gridVisible)return;const g=200*G8A,A=this._gridSpacing*g,e=new IT(A,g,6055026,4015444);e.rotation.x=Math.PI/2,e.position.z=-.001,e.renderOrder=9e3,e.frustumCulled=!1;const t=Array.isArray(e.material)?e.material:[e.material];for(let B=0;B<t.length;B+=1){const i=t[B];i&&(i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=B===0?.38:.2,i.toneMapped=!1)}this.scene.add(e),this._gridHelper=e},"#rebuildGrid"),lGA=E(function(){if(this._running)return;this._running=!0;const g=E(()=>{this._running&&(this.controls.update(),this.render(),this._raf=requestAnimationFrame(g))},"tick");g()},"#startRenderLoop"),E(hGA,"EmbeddedSketchViewer");let m8A=hGA;var St,DGA,MGA,qU,ML,FGA,z7,v7,FL,dL,uL,Dy,$u;const dGA=($u=class{constructor({channel:A,instanceId:e}){Og(this,St),this._channel=A,this._instanceId=e,this._viewer=null,this._customCssEl=null,this._root=null,this._canvasHost=null,this._sidebarHost=null,this._disposed=!1,this._theme=RN(oGA),this._sidebarExpanded=!1,this._gridVisible=BJ,this._gridSpacing=iJ,this._boundMessage=t=>x(this,St,FGA).call(this,t)}boot(){this._disposed||(x(this,St,DGA).call(this),x(this,St,MGA).call(this),window.addEventListener("message",this._boundMessage),x(this,St,qU).call(this,"ready",{version:1}))}dispose(){if(!this._disposed){this._disposed=!0,window.removeEventListener("message",this._boundMessage);try{this._viewer?.dispose?.()}catch{}this._viewer=null;try{this._root?.parentNode&&this._root.parentNode.removeChild(this._root)}catch{}this._root=null,this._canvasHost=null,this._sidebarHost=null}}},D($u,"SV"),$u);St=new WeakSet,DGA=E(function(){if(document.getElementById("sk2d-base-styles"))return;const g=document.createElement("style");g.id="sk2d-base-styles",g.textContent=`
10259
+ </div>`,"row");this._secConstraints&&(this._secConstraints.uiElement.innerHTML=(g.constraints||[]).map(e=>A(`${e.id} ${e.type} ${e.value??""} [${e.points?.join(",")}]`,`c:${e.id}`,`c:${e.id}`)).join("")),this._secCurves&&(this._secCurves.uiElement.innerHTML=(g.geometries||[]).map(e=>{const t=e?.construction?" ◐":"";return A(`${e.type}:${e.id}${t} [${e.points?.join(",")}]`,`g:${e.id}`,`g:${e.id}`)}).join("")),this._secPoints&&(this._secPoints.uiElement.innerHTML=(g.points||[]).map(e=>{const t=x(this,lA,wy).call(this,e?.id),B=Number(e?.id)===0,i=t?" 🔗":"",I=e?.fixed&&!t&&!B?" ⏚":"",s=e?.construction?" ◐":"";return A(`P${e.id} (${e.x.toFixed(2)}, ${e.y.toFixed(2)})${i}${s}${I}`,`p:${e.id}`,`p:${e.id}`)}).join("")),this._acc.uiElement.onclick=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const B=t.getAttribute("data-del");if(B){const[C,o]=B.split(":");if(C==="p")try{this._solver.removePointById?.(parseInt(o))}catch{}if(C==="g")try{this._solver.removeGeometryById?.(parseInt(o))}catch{}if(C==="c")try{this._solver.removeConstraintById?.(parseInt(o))}catch{}if(!x(this,lA,xn).call(this)){try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}try{XU(this)}catch{}return}const i=t.getAttribute("data-act");if(!i)return;const[I,s]=i.split(":");I==="p"&&x(this,lA,Vi).call(this,{type:"point",id:parseInt(s)}),I==="g"&&x(this,lA,Vi).call(this,{type:"geometry",id:parseInt(s)}),I==="c"&&x(this,lA,Vi).call(this,{type:"constraint",id:parseInt(s)}),x(this,lA,sg).call(this)},this._acc.uiElement.onmousemove=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const B=t.getAttribute("data-act");if(!B)return x(this,lA,As).call(this,null);const[i,I]=B.split(":");i==="p"?x(this,lA,As).call(this,{type:"point",id:parseInt(I)}):i==="g"?x(this,lA,As).call(this,{type:"geometry",id:parseInt(I)}):i==="c"&&x(this,lA,As).call(this,{type:"constraint",id:parseInt(I)})},this._acc.uiElement.onmouseleave=()=>x(this,lA,As).call(this,null);try{XU(this)}catch{}},"#refreshLists"),r7=E(function(){try{$R(this)}catch{}},"#applyHoverAndSelectionColors"),sg=E(function(){if(!this._ctxBar||!this._solver)return;const g=Array.from(this._selection),A=this._solver.sketchObject,e=new Set(g.filter(r=>r.type==="point").map(r=>r.id)),t=g.filter(r=>r.type==="point").map(r=>parseInt(r.id)).filter(r=>Number.isFinite(r)),B=g.filter(r=>r.type==="geometry").map(r=>A.geometries.find(a=>a.id===parseInt(r.id))).filter(Boolean);for(const r of B)(r.type==="arc"?r.points.slice(0,2):r.points).forEach(a=>e.add(a));const i=e.size;this._ctxBar.innerHTML="";const I=E(({label:r,tooltip:a,variant:w="default",onClick:c})=>{const h=document.createElement("button");return h.textContent=r,a&&(h.title=a,h.setAttribute("aria-label",a)),h.style.background="transparent",h.style.borderRadius="6px",h.style.padding="4px 8px",h.style.width="100%",h.style.minHeight="34px",h.style.boxSizing="border-box",w==="danger"?(h.style.color="#ff8b8b",h.style.border="1px solid #5b2b2b"):(h.style.color="#ddd",h.style.border="1px solid #364053"),h.onclick=c,this._ctxBar.appendChild(h),h},"appendButton"),s=E(({label:r,type:a,tooltip:w})=>I({label:r,tooltip:w,onClick:E(()=>{this._solver.createConstraint(a,g),x(this,lA,Gi).call(this),x(this,lA,sg).call(this)},"onClick")}),"addConstraintButton"),C=E(()=>I({label:"🧹",tooltip:"Remove unused points",onClick:E(()=>x(this,lA,EL).call(this),"onClick")}),"addCleanupButton"),o=E(()=>I({label:"🗑",tooltip:"Delete selection",variant:"danger",onClick:E(()=>x(this,lA,oz).call(this),"onClick")}),"addDeleteButton");if(C(),t.length){const r=t.every(c=>x(this,lA,nL).call(this,c));I({label:r?"Unfix":"Fix",tooltip:r?"Remove ground constraint":"Add ground constraint",onClick:E(()=>x(this,lA,w7).call(this,t,r),"onClick")});const a=t.map(c=>A.points?.find(h=>Number(h?.id)===Number(c))).filter(Boolean),w=a.length>0&&a.every(c=>c.construction===!0);I({label:"◐",tooltip:w?"Include selected points in 3D result":"Exclude selected points from 3D result (construction points)",onClick:E(()=>x(this,lA,l7).call(this,t,w),"onClick")})}const Q=g.filter(r=>r.type==="constraint");let n=null;if(Q.length===1&&Array.isArray(A?.constraints)){const r=Number(Q[0].id);n=A.constraints.find(a=>Number(a.id)===r)||null}if(n&&n.type==="∠"&&(I({label:"Reverse Angle",tooltip:"Swap the angle measurement to the opposite side",onClick:E(()=>{x(this,lA,h7).call(this,Number(n.id))},"onClick")}),I({label:"Alternative Angle",tooltip:"Flip the first line direction and measure the other arc",onClick:E(()=>{x(this,lA,D7).call(this,Number(n.id))},"onClick")})),B.length>0){const r=B.every(a=>!!a.construction);I({label:"◐",tooltip:r?"Convert to regular geometry":"Convert to construction geometry",onClick:E(()=>{try{this._solver.toggleConstruction()}catch{}try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,Gi).call(this),x(this,lA,sg).call(this)},"onClick")})}if(B.length===1&&(B[0]?.type==="arc"||B[0]?.type==="circle")){const r=E((a,w,c)=>I({label:a,tooltip:c,onClick:E(()=>{x(this,lA,M7).call(this,w,g)},"onClick")}),"mkAct");r("R","radius","Create radius dimension"),r("⌀","diameter","Create diameter dimension"),o();return}if(B.length===2&&B.every(r=>r?.type==="line")){s({label:"∥",type:"∥",tooltip:"Parallel"}),s({label:"⟂",type:"⟂",tooltip:"Perpendicular"}),s({label:"∠",type:"∠",tooltip:"Angle"}),s({label:"⇌",type:"⇌",tooltip:"Equal distance"}),s({label:"⏛",type:"⏛",tooltip:"Point on line"}),g.length&&o();return}if(B.length===2&&B.every(r=>r&&(r.type==="arc"||r.type==="circle"))){s({label:"⇌",type:"⇌",tooltip:"Equal radius"}),g.length&&o();return}if(B.length===2&&(B[0]?.type==="line"&&(B[1]?.type==="arc"||B[1]?.type==="circle")||B[1]?.type==="line"&&(B[0]?.type==="arc"||B[0]?.type==="circle"))){s({label:"⟠",type:"⟂",tooltip:"Tangent"}),g.length&&o();return}B.length===1&&B[0]?.type==="line"&&t.length===2&&s({label:"⟂",type:"⟂",tooltip:"Perpendicular"}),i===1&&s({label:"⏚",type:"⏚",tooltip:"Ground (fix point)"}),i===2&&(s({label:"━",type:"━",tooltip:"Horizontal"}),s({label:"│",type:"│",tooltip:"Vertical"}),s({label:"≡",type:"≡",tooltip:"Coincident"}),s({label:"⟺",type:"⟺",tooltip:"Distance"})),i===3&&(s({label:"⋯",type:"⋯",tooltip:"Midpoint"}),s({label:"⏛",type:"⏛",tooltip:"Point on line"}),s({label:"↥",type:ny,tooltip:"Line to point distance"}),s({label:"∠",type:"∠",tooltip:"Angle"})),g.length&&o()},"#refreshContextBar"),oz=E(function(){try{const g=this._solver;if(!g)return;const A=Array.from(this._selection||[]);for(const e of A)if(e?.type==="constraint")try{g.removeConstraintById?.(parseInt(e.id))}catch{}for(const e of A)if(e?.type==="geometry")try{g.removeGeometryById?.(parseInt(e.id))}catch{}for(const e of A)if(e?.type==="point")try{g.removePointById?.(parseInt(e.id))}catch{}if(this._selection.clear(),!x(this,lA,xn).call(this)){try{g.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}}catch{}},"#deleteSelection"),a7=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t))return console.warn("[SketchTrim] delete point blocked",{pointId:g??null,reason:"invalid solver/sketch/point id"}),!1;if(!(Array.isArray(e.points)&&e.points.some(B=>parseInt(B?.id)===t)))return console.warn("[SketchTrim] delete point blocked",{pointId:t,reason:"point not found"}),!1;try{A.removePointById?.(t)}catch{return console.error("[SketchTrim] delete point failed",{pointId:t,reason:"solver.removePointById threw"}),!1}if((A.sketchObject?.points||[]).some(B=>parseInt(B?.id)===t))return console.warn("[SketchTrim] delete point failed",{pointId:t,reason:"point still present after remove"}),!1;if(console.log("[SketchTrim] delete point succeeded",{pointId:t}),this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deletePointById"),QL=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t)||!(Array.isArray(e.geometries)&&e.geometries.some(B=>parseInt(B?.id)===t)))return!1;try{A.removeGeometryById?.(t)}catch{return!1}if((A.sketchObject?.geometries||[]).some(B=>parseInt(B?.id)===t))return!1;if(this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deleteGeometryById"),Qz=E(function(g){const A=this._solver,e=A?.sketchObject,t=parseInt(g);if(!A||!e||!Number.isFinite(t))return console.warn("[SketchTrim] delete constraint blocked",{constraintId:g??null,reason:"invalid solver/sketch/constraint id"}),!1;if(!(Array.isArray(e.constraints)&&e.constraints.some(B=>parseInt(B?.id)===t)))return console.warn("[SketchTrim] delete constraint blocked",{constraintId:t,reason:"constraint not found"}),!1;try{A.removeConstraintById?.(t)}catch{return console.error("[SketchTrim] delete constraint failed",{constraintId:t,reason:"solver.removeConstraintById threw"}),!1}if((A.sketchObject?.constraints||[]).some(B=>parseInt(B?.id)===t))return console.warn("[SketchTrim] delete constraint failed",{constraintId:t,reason:"constraint still present after remove"}),!1;if(console.log("[SketchTrim] delete constraint succeeded",{constraintId:t}),this._selection.clear(),!x(this,lA,xn).call(this)){try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0},"#deleteConstraintById"),EL=E(function(){const g=this._solver,A=g?.sketchObject;if(!g||!A)return 0;const e=new Set;for(const i of A.geometries||[])if(!(!i||!Array.isArray(i.points)))for(const I of i.points)e.add(parseInt(I));const t=new Map;for(const i of A.constraints||[])if(!(!i||i.temporary||!Array.isArray(i.points)))for(const I of i.points){const s=parseInt(I);if(!Number.isFinite(s))continue;const C=t.get(s);C?C.push(i):t.set(s,[i])}const B=[];for(const i of A.points||[]){const I=parseInt(i.id);if(!Number.isFinite(I)||I===0||e.has(I))continue;const s=t.get(I)||[];if(s.length===0){B.push(I);continue}if(s.length===1){const C=s[0]?.type;(C==="≡"||C==="⏛")&&B.push(I)}}if(!B.length)return 0;for(const i of B)try{g.removePointById?.(i)}catch{}try{g.solveSketch("full")}catch{}return this._selection.clear(),x(this,lA,Cg).call(this),x(this,lA,Gi).call(this),x(this,lA,sg).call(this),B.length},"#cleanupUnusedPoints"),c7=E(function(){const g=this._solver?.sketchObject;if(!g||!Array.isArray(g.constraints))return 0;const A=g.constraints,e=new Map,t=E(Q=>{let n=e.get(Q);return n==null?(e.set(Q,Q),Q):(n!==Q&&(n=t(n),e.set(Q,n)),n)},"find"),B=E((Q,n)=>{const r=t(Q),a=t(n);r!==a&&(r<a?e.set(a,r):e.set(r,a))},"union"),i=E(Q=>{const n=parseInt(Q);return Number.isFinite(n)?e.has(n)?t(n):n:null},"canonical"),I=E((Q,n)=>Q<=n?`${Q},${n}`:`${n},${Q}`,"pairKey");for(const Q of A){if(!Q||Q.temporary||Q.type!=="≡"||!Array.isArray(Q.points)||Q.points.length<2)continue;const n=parseInt(Q.points[0]),r=parseInt(Q.points[1]);!Number.isFinite(n)||!Number.isFinite(r)||B(n,r)}const s=new Set,C=[];let o=0;for(const Q of A){if(!Q||Q.temporary||Q.type!=="⏛"||!Array.isArray(Q.points)||Q.points.length<3){C.push(Q);continue}const n=i(Q.points[0]),r=i(Q.points[1]),a=i(Q.points[2]);if(![n,r,a].every(Number.isFinite)){C.push(Q);continue}if(a===n||a===r){o+=1;continue}const w=`${I(n,r)}|${a}`;if(s.has(w)){o+=1;continue}s.add(w),C.push(Q)}return o?(g.constraints=C,o):0},"#cleanupRedundantPointOnLineConstraints"),xn=E(function(){return this._solverSettings?.autoCleanupOrphans?x(this,lA,EL).call(this):0},"#maybeAutoCleanupPoints"),nL=E(function(g){const A=this._solver?.sketchObject;return!A||!Array.isArray(A.constraints)?!1:A.constraints.some(e=>e?.type==="⏚"&&Array.isArray(e.points)&&parseInt(e.points[0])===g)},"#pointHasGround"),w7=E(function(g,A){const e=this._solver,t=e?.sketchObject;if(!e||!t||!Array.isArray(g)||!g.length)return;const B=g.map(i=>parseInt(i)).filter(i=>Number.isFinite(i)&&i!==0);if(B.length){if(A){t.constraints=(t.constraints||[]).filter(i=>i?.type!=="⏚"||!Array.isArray(i.points)?!0:!B.includes(parseInt(i.points[0])));for(const i of B){const I=t.points?.find(s=>parseInt(s.id)===i);I&&(I.fixed=!1)}}else{const i=E(()=>Math.max(0,...(t.constraints||[]).map(I=>+I.id||0))+1,"nextId");for(const I of B){if(x(this,lA,nL).call(this,I))continue;const s=i();t.constraints=t.constraints||[],t.constraints.push({id:s,type:"⏚",points:[I]});const C=t.points?.find(o=>parseInt(o.id)===I);C&&(C.fixed=!0)}}try{e.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}},"#toggleGroundConstraints"),l7=E(function(g,A){const e=this._solver,t=e?.sketchObject;if(!e||!t||!Array.isArray(g)||!g.length)return;const B=g.map(s=>parseInt(s)).filter(s=>Number.isFinite(s));if(!B.length)return;const i=!A;let I=!1;for(const s of B){const C=t.points?.find(o=>parseInt(o?.id)===s);C&&C.construction!==i&&(C.construction=i,I=!0)}if(I){try{e.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}},"#togglePointConstruction"),h7=E(function(g){const A=this._solver,e=A?.sketchObject;if(!A||!e||!Array.isArray(e.constraints))return;const t=Number(g),B=e.constraints.find(C=>Number(C.id)===t);if(!B||B.type!=="∠"||!Array.isArray(B.points)||B.points.length<4)return;const i=B.points.slice(),I=[i[3],i[2],i[0],i[1],...i.slice(4)];B.points=I;const s=this._dimOffsets.get(B.id);s&&(typeof s.du=="number"||typeof s.dv=="number")&&this._dimOffsets.set(B.id,{...s,du:typeof s.du=="number"?-s.du:s.du,dv:typeof s.dv=="number"?-s.dv:s.dv}),B.value=null,"valueExpr"in B&&delete B.valueExpr;try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)},"#reverseAngleConstraint"),D7=E(function(g){const A=this._solver,e=A?.sketchObject;if(!A||!e||!Array.isArray(e.constraints))return;const t=Number(g),B=e.constraints.find(s=>Number(s.id)===t);if(!B||B.type!=="∠"||!Array.isArray(B.points)||B.points.length<2)return;const i=B.points.slice(),I=[i[0],i[1],i[3],i[2]];B.points=I,B.value=null,"valueExpr"in B&&delete B.valueExpr;try{A.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)},"#alternativeAngleConstraint"),M7=E(function(g,A){try{this._solver.createConstraint("⟺",A);const e=this._solver.sketchObject,t=(e.constraints||[]).reduce((C,o)=>+(C?.id||0)>+o.id?C:o,null);if(!t)return;t.displayStyle=g==="diameter"?"diameter":"radius";const B=Array.isArray(A)?parseInt(A.find(C=>C?.type==="geometry")?.id):NaN,i=Number.isFinite(B)?(e.geometries||[]).find(C=>parseInt(C?.id)===B):null;i&&(i.type==="arc"||i.type==="circle")&&(t.radialGeometryType=i.type);const I=e.points.find(C=>C.id===t.points?.[0])||null,s=e.points.find(C=>C.id===t.points?.[1])||null;if(I&&s){const C=s.x-I.x,o=s.y-I.y,Q=Math.hypot(C,o),n=Q>1e-9?C/Q:1,r=Q>1e-9?o/Q:0,a=-r,w=n,c=Math.max(.2,Q*.35);this._dimOffsets.set(t.id,{du:C+n*c+a*c*.35,dv:o+r*c+w*c*.35})}this._solver.solveSketch("full"),x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}catch{}},"#addRadialDimension"),Vi=E(function(g){const A=g.type+":"+g.id,e=Array.from(this._selection).find(t=>t.type+":"+t.id===A);e?this._selection.delete(e):this._selection.add(g);try{XU(this)}catch{}try{$R(this)}catch{}try{x(this,lA,MC).call(this)}catch{}try{this.revealListForItem?.(g.type,g.id)}catch{}},"#toggleSelection"),As=E(function(g){const A=this._hover?this._hover.type+":"+this._hover.id:null,e=g?g.type+":"+g.id:null;if(A!==e){this._hover=g;try{XU(this)}catch{}try{$R(this)}catch{}if(g&&g.type&&g.id!=null)try{this.revealListForItem?.(g.type,g.id)}catch{}}},"#setHover"),Fo=E(function(g){if(!this._sketchGroup||!this._solver)return null;const A=this.viewer,e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject,{width:B,height:i}=x(this,lA,zi).call(this,A.renderer.domElement),I=x(this,lA,XK).call(this,g),s=x(this,lA,Ln).call(this,B,i)*I*1.2;let C=null,o=1/0;for(const Q of t.points||[]){const n=Math.hypot(e.u-Q.x,e.v-Q.y);n<o&&(o=n,C=Q.id)}return C!=null&&o<=s?C:null},"#hitTestPoint"),F7=E(function(g,A=null){if(!this._solver||g==null)return!1;const e=this._solver.sketchObject;if(!e||!Array.isArray(e.points))return!1;const t=this._solver.getPointById?.(g)||e.points.find(c=>c.id===g);if(!t)return!1;const B=this.viewer;if(!B?.renderer||!B?.camera)return!1;const{width:i,height:I}=x(this,lA,zi).call(this,B.renderer.domElement),s=x(this,lA,wI).call(this,B.camera,i,I),C=x(this,lA,Ln).call(this,i,I),o=Number(this._solverSettings?.pointConstraintPx),Q=Math.max(C*1.2,s*(Number.isFinite(o)?o:12)),n=A?x(this,lA,MB).call(this,A):null,r=Number.isFinite(n?.u)?n.u:t.x,a=Number.isFinite(n?.v)?n.v:t.y,w=[];for(const c of e.points){if(!c||c.id===g)continue;const h=Math.hypot(r-c.x,a-c.y);h<=Q&&w.push({id:c.id,d:h})}if(!w.length)return!1;w.sort((c,h)=>c.d-h.d);for(const c of w)if(!x(this,lA,d7).call(this,g,c.id))return this._solver.createConstraint("≡",[{type:"point",id:g},{type:"point",id:c.id}]),x(this,lA,Gi).call(this),x(this,lA,sg).call(this),!0;return!0},"#maybeAddCoincidentOnDrop"),d7=E(function(g,A){const e=parseInt(g),t=parseInt(A);if(!Number.isFinite(e)||!Number.isFinite(t))return!1;if(e===t)return!0;const B=this._solver?.sketchObject?.constraints||[],i=new Map;for(const C of B){if(C?.type!=="≡"||!Array.isArray(C.points)||C.points.length<2)continue;const o=parseInt(C.points[0]),Q=parseInt(C.points[1]);!Number.isFinite(o)||!Number.isFinite(Q)||(i.has(o)||i.set(o,new Set),i.has(Q)||i.set(Q,new Set),i.get(o).add(Q),i.get(Q).add(o))}const I=new Set([e]),s=[e];for(;s.length;){const C=s.shift(),o=i.get(C);if(o)for(const Q of o){if(Q===t)return!0;I.has(Q)||(I.add(Q),s.push(Q))}}return!1},"#arePointsCoincident"),u7=E(function(g,A=null){if(!this._solver||g==null)return!1;const e=this._solver.sketchObject;if(!e||!Array.isArray(e.points)||!Array.isArray(e.geometries))return!1;const t=this._solver.getPointById?.(g)||e.points.find(h=>h.id===g);if(!t)return!1;const B=this.viewer;if(!B?.renderer||!B?.camera)return!1;const{width:i,height:I}=x(this,lA,zi).call(this,B.renderer.domElement),s=x(this,lA,wI).call(this,B.camera,i,I),C=x(this,lA,Ln).call(this,i,I),o=Number(this._solverSettings?.pointConstraintPx),Q=Math.max(C*1.2,s*(Number.isFinite(o)?o:12)),n=A?x(this,lA,MB).call(this,A):null,r=Number.isFinite(n?.u)?n.u:t.x,a=Number.isFinite(n?.v)?n.v:t.y;let w=null,c=1/0;for(const h of e.geometries){if(!h||h.type!=="line"||!Array.isArray(h.points)||h.points.length<2)continue;const l=e.points.find(d=>d.id===h.points[0]),M=e.points.find(d=>d.id===h.points[1]);if(!l||!M||l.id===g||M.id===g)continue;const F=x(this,lA,p7).call(this,l.x,l.y,M.x,M.y,r,a);F<c&&(c=F,w=h)}if(!w||c>Q||!x(this,lA,wL).call(this,w,g,null))return!1;try{this._solver.solveSketch("full")}catch{}return x(this,lA,Cg).call(this),x(this,lA,sg).call(this),!0},"#maybeAddPointOnLineOnDrop"),hy=E(function(g){const A=this.viewer;if(!A||!this._solver||!this._lock)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject;if(!t)return null;const{width:B,height:i}=x(this,lA,zi).call(this,A.renderer.domElement),I=x(this,lA,wI).call(this,A.camera,B,i),s=Math.max(.05,I*6)*x(this,lA,XK).call(this,g);let C=null,o=1/0;const Q=E((r,a,w,c,h,l)=>{const M=w-r,F=c-a,d=h-r,Y=l-a,u=M*M+F*F||1e-12;let G=(d*M+Y*F)/u;G<0?G=0:G>1&&(G=1);const y=r+M*G,U=a+F*G,N=h-y,f=l-U;return Math.hypot(N,f)},"distToSeg"),n=E(r=>{const a=Math.PI*2;return r=r%a,r<0&&(r+=a),r},"normAng");for(const r of t.geometries||[])if(r.type==="line"&&Array.isArray(r.points)&&r.points.length>=2){const a=t.points.find(h=>h.id===r.points[0]),w=t.points.find(h=>h.id===r.points[1]);if(!a||!w)continue;const c=Q(a.x,a.y,w.x,w.y,e.u,e.v);c<o&&(o=c,C={id:r.id,type:"line"})}else if(r.type==="circle"&&Array.isArray(r.points)&&r.points.length>=2){const a=t.points.find(l=>l.id===r.points[0]),w=t.points.find(l=>l.id===r.points[1]);if(!a||!w)continue;const c=Math.hypot(w.x-a.x,w.y-a.y),h=Math.abs(Math.hypot(e.u-a.x,e.v-a.y)-c);h<o&&(o=h,C={id:r.id,type:"circle"})}else if(r.type==="arc"&&Array.isArray(r.points)&&r.points.length>=3){const a=t.points.find(u=>u.id===r.points[0]),w=t.points.find(u=>u.id===r.points[1]),c=t.points.find(u=>u.id===r.points[2]);if(!a||!w||!c)continue;const h=a.x,l=a.y,M=Math.hypot(w.x-h,w.y-l);let F=Math.atan2(w.y-l,w.x-h),d=Math.atan2(c.y-l,c.x-h);F=n(F),d=n(d);let Y=d-F;if(Y<0&&(Y+=Math.PI*2),Math.abs(Y)<1e-6){const u=Math.abs(Math.hypot(e.u-h,e.v-l)-M);u<o&&(o=u,C={id:r.id,type:"arc"})}else{let u=n(Math.atan2(e.v-l,e.u-h))-F;u<0&&(u+=Math.PI*2),u=u/Y,u<0?u=0:u>1&&(u=1);const G=h+M*Math.cos(F+u*Y),y=l+M*Math.sin(F+u*Y),U=Math.hypot(e.u-G,e.v-y);U<o&&(o=U,C={id:r.id,type:"arc"})}}else if(r.type==="bezier"&&Array.isArray(r.points)&&r.points.length>=4){const a=r.points||[],w=Math.floor((a.length-1)/3);for(let c=0;c<w;c++){const h=c*3,l=t.points.find(u=>u.id===a[h]),M=t.points.find(u=>u.id===a[h+1]),F=t.points.find(u=>u.id===a[h+2]),d=t.points.find(u=>u.id===a[h+3]);if(!l||!M||!F||!d)continue;const Y=x(this,lA,AL).call(this,l,M,F,d,e,64);Y&&Y.dist<o&&(o=Y.dist,C={id:r.id,type:"bezier",segmentIndex:c,t:Y.t})}}return C&&o<=s?C:null},"#hitTestGeometry"),Y7=E(function(g,A){if(!this._solver)return!1;const e=this._solver.sketchObject;if(!e)return!1;const t=(e.geometries||[]).find(r=>r&&r.id===parseInt(g.id));if(!t)return!1;const B=x(this,lA,MB).call(this,A);if(!B)return!1;const i=new Map((e.points||[]).map(r=>[r.id,r])),I=x(this,lA,aL).call(this,t,i);if(!I||!Array.isArray(I.samples)||I.samples.length<2)return!1;const s=x(this,lA,m7).call(this,B,I.samples);if(!s||!Number.isFinite(s.param))return!1;const C=[],o=new Map;for(const r of e.geometries||[]){if(!r||r.id===t.id)continue;let a=o.get(r.id);a||(a=x(this,lA,aL).call(this,r,i),o.set(r.id,a)),a&&x(this,lA,R7).call(this,I,a,C,r,i)}const Q=x(this,lA,k7).call(this,C,s.param,I);if(!Q)return x(this,lA,QL).call(this,t.id);let n=!1;if(t.type==="line"?n=x(this,lA,y7).call(this,t,Q):t.type==="circle"?n=x(this,lA,rL).call(this,t,Q):t.type==="arc"?I.closed?n=x(this,lA,rL).call(this,t,Q):n=x(this,lA,U7).call(this,t,Q):t.type==="bezier"&&(n=x(this,lA,G7).call(this,t,Q,I)),n){if(this._selection.clear(),x(this,lA,c7).call(this),!x(this,lA,xn).call(this)){try{this._solver.solveSketch("full")}catch{}x(this,lA,Cg).call(this),x(this,lA,sg).call(this)}return!0}return x(this,lA,QL).call(this,t.id)},"#trimGeometry"),y7=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<2)return!1;const B=e.points.find(w=>w.id===t[0]),i=e.points.find(w=>w.id===t[1]);if(!B||!i)return!1;const I=1e-5,s=A.prev&&A.prev.param>I,C=A.next&&A.next.param<1-I;if(!s&&!C||s&&C&&A.next.param-A.prev.param<=I)return!1;const o=E(w=>{const c=B.x+(i.x-B.x)*w,h=B.y+(i.y-B.y)*w;return{x:c,y:h}},"pointAt"),Q=s?x(this,lA,bn).call(this,o(A.prev.param)):t[0],n=C?x(this,lA,bn).call(this,o(A.next.param)):t[1],r=E((w,c)=>{if(w==null||c==null||w===c)return!1;const h=e.points.find(M=>M.id===w),l=e.points.find(M=>M.id===c);return!h||!l||Math.hypot(h.x-l.x,h.y-l.y)<1e-7?!1:(x(this,lA,Ni).call(this,"line",[w,c],g),!0)},"addLine");let a=!1;return s&&(a=r(t[0],Q)||a),C&&(a=r(n,t[1])||a),s&&x(this,lA,Kn).call(this,Q,A.prev),C&&x(this,lA,Kn).call(this,n,A.next),a&&this._solver.removeGeometryById?.(g.id),a},"#trimLineGeometry"),U7=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<3)return!1;const B=e.points.find(h=>h.id===t[0]),i=e.points.find(h=>h.id===t[1]),I=e.points.find(h=>h.id===t[2]);if(!B||!i||!I)return!1;const s=Math.hypot(i.x-B.x,i.y-B.y);if(!Number.isFinite(s)||s<1e-9)return!1;const C=1e-5,o=A.prev&&A.prev.param>C,Q=A.next&&A.next.param<1-C;if(!o&&!Q||o&&Q&&A.next.param-A.prev.param<=C)return!1;const n=E(h=>{const l=Math.atan2(h.y-B.y,h.x-B.x);return{x:B.x+s*Math.cos(l),y:B.y+s*Math.sin(l)}},"pointOnCircle"),r=o?x(this,lA,bn).call(this,n(A.prev)):t[1],a=Q?x(this,lA,bn).call(this,n(A.next)):t[2],w=E((h,l)=>{if(h==null||l==null||h===l)return!1;const M=e.points.find(d=>d.id===h),F=e.points.find(d=>d.id===l);return!M||!F||Math.hypot(M.x-F.x,M.y-F.y)<1e-7?!1:(x(this,lA,Ni).call(this,"arc",[t[0],h,l],g),!0)},"addArc");let c=!1;return o&&(c=w(t[1],r)||c),Q&&(c=w(a,t[2])||c),o&&(x(this,lA,Kn).call(this,r,A.prev),x(this,lA,Wc).call(this,g,r)),Q&&(x(this,lA,Kn).call(this,a,A.next),x(this,lA,Wc).call(this,g,a)),c&&this._solver.removeGeometryById?.(g.id),c},"#trimArcGeometry"),rL=E(function(g,A){const e=this._solver?.sketchObject;if(!e)return!1;const t=Array.isArray(g?.points)?g.points:[];if(t.length<2)return!1;const B=e.points.find(r=>r.id===t[0]),i=e.points.find(r=>r.id===t[1]);if(!B||!i)return!1;const I=Math.hypot(i.x-B.x,i.y-B.y);if(!Number.isFinite(I)||I<1e-9||!A.prev||!A.next)return!1;const s=A.maxParam||1,C=(A.next.param-A.prev.param+s)%s;if(C<1e-5||C>s-1e-5)return!1;const o=E(r=>{const a=Math.atan2(r.y-B.y,r.x-B.x);return{x:B.x+I*Math.cos(a),y:B.y+I*Math.sin(a)}},"pointOnCircle"),Q=x(this,lA,bn).call(this,o(A.prev)),n=x(this,lA,bn).call(this,o(A.next));return Q==null||n==null||Q===n||!x(this,lA,Ni).call(this,"arc",[t[0],n,Q],g)?!1:(x(this,lA,Kn).call(this,Q,A.prev),x(this,lA,Kn).call(this,n,A.next),x(this,lA,Wc).call(this,g,Q),x(this,lA,Wc).call(this,g,n),this._solver.removeGeometryById?.(g.id),!0)},"#trimCircleGeometry"),G7=E(function(g,A,e){if(!this._solver?.sketchObject||!g||!Array.isArray(g.points))return!1;const t=e?.segCount||Math.floor((g.points.length-1)/3);if(t<1)return!1;const B=A.prev||null,i=A.next||null;if(!B&&!i||B&&i&&i.param-B.param<=1e-5)return!1;const I=[];if(B){const c=Math.min(t-1,Math.max(0,Math.floor(B.param))),h=B.param-c;I.push({kind:"prev",segIndex:c,t:h,pos:B.param})}if(i){const c=Math.min(t-1,Math.max(0,Math.floor(i.param))),h=i.param-c;I.push({kind:"next",segIndex:c,t:h,pos:i.param})}I.sort((c,h)=>c.pos-h.pos);let s=0;if(I.length===2&&I[0].segIndex===I[1].segIndex){const c=I[0],h=I[1];if(h.t-c.t<1e-5)return!1;const l=x(this,lA,Mm).call(this,g,c.segIndex+s,c.t);if(!l)return!1;c.anchorIndex=l.anchorIndex,s+=1;const M=(h.t-c.t)/(1-c.t),F=x(this,lA,Mm).call(this,g,c.segIndex+s,M);if(!F)return!1;h.anchorIndex=F.anchorIndex}else for(const c of I){const h=x(this,lA,Mm).call(this,g,c.segIndex+s,c.t);if(!h)return!1;c.anchorIndex=h.anchorIndex,s+=1}const C=Math.floor((g.points.length-1)/3),o=I.find(c=>c.kind==="prev"),Q=I.find(c=>c.kind==="next"),n=o?Math.floor(o.anchorIndex/3):0,r=Q?Math.floor(Q.anchorIndex/3):C;if(r<=n)return!1;const a=[];n>0&&a.push([0,n]),r<C&&a.push([r,C]);let w=!1;for(const[c,h]of a){if(h-c<1)continue;const l=c*3,M=h*3,F=g.points.slice(l,M+1);F.length>=4&&(x(this,lA,Ni).call(this,"bezier",F,g),w=!0)}return w&&this._solver.removeGeometryById?.(g.id),w},"#trimBezierGeometry"),N7=E(function(g,A){if(!g||!A||!Array.isArray(g.points))return[];if(g.type==="line"&&g.points.length>=2){const e=A.get(g.points[0]),t=A.get(g.points[1]);return[e?{point:e,param:0}:null,t?{point:t,param:1}:null].filter(Boolean)}if(g.type==="arc"&&g.points.length>=3){const e=A.get(g.points[1]),t=A.get(g.points[2]);return[e?{point:e,param:0}:null,t?{point:t,param:1}:null].filter(Boolean)}if(g.type==="bezier"&&g.points.length>=4){const e=Math.floor((g.points.length-1)/3);if(e<1)return[];const t=A.get(g.points[0]),B=A.get(g.points[g.points.length-1]);return[t?{point:t,param:0}:null,B?{point:B,param:e}:null].filter(Boolean)}return[]},"#getGeometryEndpointInfos"),f7=E(function(g){if(!Array.isArray(g)||g.length===0)return .001;let A=1/0,e=1/0,t=-1/0,B=-1/0;for(const C of g)C&&(C.x<A&&(A=C.x),C.y<e&&(e=C.y),C.x>t&&(t=C.x),C.y>B&&(B=C.y));const i=t-A,I=B-e,s=Math.hypot(i,I);return!Number.isFinite(s)||s<1e-9?.001:Math.max(1e-5,Math.min(.01,s*.001))},"#sampleTol"),p7=E(function(g,A,e,t,B,i){const I=e-g,s=t-A,C=B-g,o=i-A,Q=I*I+s*s||1e-12;let n=(C*I+o*s)/Q;n<0?n=0:n>1&&(n=1);const r=g+I*n,a=A+s*n;return Math.hypot(B-r,i-a)},"#distancePointToSeg"),Mm=E(function(g,A,e){const t=this._solver?.sketchObject;if(!t||!g||!Array.isArray(g.points))return null;const B=g.points,i=Math.floor((B.length-1)/3);if(A<0||A>=i)return null;const I=A*3,s=t.points.find(N=>N.id===B[I]),C=t.points.find(N=>N.id===B[I+1]),o=t.points.find(N=>N.id===B[I+2]),Q=t.points.find(N=>N.id===B[I+3]);if(!s||!C||!o||!Q)return null;const n=Math.min(.9999,Math.max(1e-4,e)),r=E((N,f,m)=>({x:N.x+(f.x-N.x)*m,y:N.y+(f.y-N.y)*m}),"lerp"),a={x:s.x,y:s.y},w={x:C.x,y:C.y},c={x:o.x,y:o.y},h={x:Q.x,y:Q.y},l=r(a,w,n),M=r(w,c,n),F=r(c,h,n),d=r(l,M,n),Y=r(M,F,n),u=r(d,Y,n);C.x=l.x,C.y=l.y,o.x=F.x,o.y=F.y;const G=x(this,lA,Yt).call(this,d.x,d.y,!1),y=x(this,lA,Yt).call(this,u.x,u.y,!1),U=x(this,lA,Yt).call(this,Y.x,Y.y,!1);return G==null||y==null||U==null?null:(g.points.splice(I+2,0,G,y,U),x(this,lA,Ni).call(this,"line",[y,G],null,{construction:!0}),x(this,lA,Ni).call(this,"line",[y,U],null,{construction:!0}),{anchorIndex:I+3,anchorId:y})},"#splitBezierAt"),aL=E(function(g,A){if(!g||!A)return null;const e=E(t=>A.get(t),"get");if(g.type==="line"&&Array.isArray(g.points)&&g.points.length>=2){const t=e(g.points[0]),B=e(g.points[1]);return!t||!B?null:{type:"line",closed:!1,maxParam:1,segCount:1,samples:[{x:t.x,y:t.y,param:0},{x:B.x,y:B.y,param:1}]}}if(g.type==="circle"&&Array.isArray(g.points)&&g.points.length>=2){const t=e(g.points[0]),B=e(g.points[1]);if(!t||!B)return null;const i=Math.hypot(B.x-t.x,B.y-t.y);if(!Number.isFinite(i)||i<1e-9)return null;const I=96,s=[];for(let C=0;C<=I;C++){const o=C/I,Q=o*Math.PI*2;s.push({x:t.x+i*Math.cos(Q),y:t.y+i*Math.sin(Q),param:o})}return{type:"circle",closed:!0,maxParam:1,segCount:1,samples:s}}if(g.type==="arc"&&Array.isArray(g.points)&&g.points.length>=3){const t=e(g.points[0]),B=e(g.points[1]),i=e(g.points[2]);if(!t||!B||!i)return null;const I=Math.hypot(B.x-t.x,B.y-t.y);if(!Number.isFinite(I)||I<1e-9)return null;let s=Math.atan2(B.y-t.y,B.x-t.x),C=Math.atan2(i.y-t.y,i.x-t.x)-s;C=(C%(2*Math.PI)+2*Math.PI)%(2*Math.PI);const o=C<1e-6;o&&(C=2*Math.PI);const Q=Math.max(8,Math.ceil(96*(C/(2*Math.PI)))),n=[];for(let r=0;r<=Q;r++){const a=r/Q,w=s+C*a;n.push({x:t.x+I*Math.cos(w),y:t.y+I*Math.sin(w),param:a})}return{type:"arc",closed:o,maxParam:1,segCount:1,samples:n}}if(g.type==="bezier"&&Array.isArray(g.points)&&g.points.length>=4){const t=g.points,B=Math.floor((t.length-1)/3);if(B<1)return null;const i=24,I=[];for(let s=0;s<B;s++){const C=s*3,o=e(t[C]),Q=e(t[C+1]),n=e(t[C+2]),r=e(t[C+3]);if(!(!o||!Q||!n||!r))for(let a=0;a<=i;a++){if(s>0&&a===0)continue;const w=a/i,c=1-w,h=c*c*c*o.x+3*c*c*w*Q.x+3*c*w*w*n.x+w*w*w*r.x,l=c*c*c*o.y+3*c*c*w*Q.y+3*c*w*w*n.y+w*w*w*r.y;I.push({x:h,y:l,param:s+w})}}return{type:"bezier",closed:!1,maxParam:B,segCount:B,samples:I}}return null},"#sampleGeometry"),m7=E(function(g,A){if(!g||!Array.isArray(A)||A.length<2)return null;const e=x(this,lA,cL).call(this,g.u,g.v,A);return e?{param:e.param,dist:e.dist}:null},"#closestParamOnSamples"),cL=E(function(g,A,e){if(!Array.isArray(e)||e.length<2)return null;let t={param:e[0].param,x:e[0].x,y:e[0].y,dist:1/0};for(let B=0;B<e.length-1;B++){const i=e[B],I=e[B+1],s=I.x-i.x,C=I.y-i.y,o=g-i.x,Q=A-i.y,n=s*s+C*C||1e-12;let r=(o*s+Q*C)/n;r<0?r=0:r>1&&(r=1);const a=i.x+s*r,w=i.y+C*r,c=Math.hypot(g-a,A-w),h=i.param+(I.param-i.param)*r;c<t.dist&&(t={param:h,x:a,y:w,dist:c})}return t},"#closestPointOnSamples"),R7=E(function(g,A,e,t,B){const i=g?.samples,I=A?.samples;if(!Array.isArray(i)||!Array.isArray(I)||i.length<2||I.length<2)return;for(let C=0;C<i.length-1;C++){const o=i[C],Q=i[C+1];for(let n=0;n<I.length-1;n++){const r=I[n],a=I[n+1],w=x(this,lA,H7).call(this,o,Q,r,a);if(!w)continue;const c=o.param+(Q.param-o.param)*w.ta,h=r.param+(a.param-r.param)*w.tb;e.push({param:c,x:w.x,y:w.y,otherParam:h,otherGeoId:t?.id??null,otherType:t?.type??null})}}const s=x(this,lA,N7).call(this,t,B);s.length&&x(this,lA,S7).call(this,g,s,e,t)},"#collectIntersections"),S7=E(function(g,A,e,t){const B=g?.samples;if(!Array.isArray(B)||B.length<2||!Array.isArray(A)||A.length<1)return;const i=x(this,lA,f7).call(this,B);for(const I of A){const s=I?.point;if(!s)continue;const C=x(this,lA,cL).call(this,s.x,s.y,B);!C||!Number.isFinite(C.param)||!Number.isFinite(C.dist)||C.dist>i||e.push({param:C.param,x:s.x,y:s.y,otherParam:Number.isFinite(I.param)?I.param:null,otherGeoId:t?.id??null,otherType:t?.type??null,endpointSnap:!0})}},"#collectEndpointIntersectionsOnTarget"),H7=E(function(g,A,e,t,B=1e-9){const i=A.x-g.x,I=A.y-g.y,s=t.x-e.x,C=t.y-e.y,o=i*C-I*s;if(Math.abs(o)<B)return null;const Q=((e.x-g.x)*C-(e.y-g.y)*s)/o,n=((e.x-g.x)*I-(e.y-g.y)*i)/o;if(Q<-B||Q>1+B||n<-B||n>1+B)return null;const r=Math.min(1,Math.max(0,Q));return{x:g.x+i*r,y:g.y+I*r,ta:r,tb:Math.min(1,Math.max(0,n))}},"#segmentIntersection"),k7=E(function(g,A,e){const t=e?.maxParam||1,B=Math.max(1e-5,t*1e-4),i=[];for(const o of g||[]){if(!o||!Number.isFinite(o.param))continue;let Q=o.param;if(e?.closed)Q=(Q%t+t)%t,(Q<B||Q>t-B)&&(Q=0);else if(Q<=B||Q>=t-B)continue;i.push({...o,param:Q,x:o.x,y:o.y})}i.sort((o,Q)=>o.param-Q.param);const I=[];for(const o of i){const Q=I[I.length-1];!Q||Math.abs(o.param-Q.param)>B?I.push(o):!Q.endpointSnap&&o.endpointSnap&&(I[I.length-1]=o)}if(e?.closed){if(I.length<2)return null;let o=null,Q=null,n=1/0,r=-1/0;for(const a of I){let w=a.param-A;w=(w%t+t)%t,!(w<B)&&(w<n&&(n=w,Q=a),w>r&&(r=w,o=a))}return!o||!Q?null:{prev:o,next:Q,closed:!0,maxParam:t}}if(!I.length)return null;let s=null,C=null;for(const o of I)if(o.param<A-B)s=o;else if(o.param>A+B){C=o;break}return!s&&!C?null:{prev:s,next:C,closed:!1,maxParam:t}},"#selectTrimBounds"),J7=E(function(g,A,e=1e-6){const t=this._solver?.sketchObject;if(!t||!Array.isArray(t.points))return null;for(const B of t.points)if(Math.hypot(B.x-g,B.y-A)<=e)return B.id;return null},"#findExistingPointId"),bn=E(function(g){return x(this,lA,J7).call(this,g.x,g.y)??x(this,lA,Yt).call(this,g.x,g.y,!1)},"#getOrCreatePointId"),Kn=E(function(g,A){if(!A||g==null)return!1;const e=this._solver?.sketchObject;if(!e)return!1;const t=A.otherGeoId;if(t==null)return!1;const B=(e.geometries||[]).find(i=>i&&i.id===parseInt(t));return!B||!B.type?!1:B.type==="line"?x(this,lA,wL).call(this,B,g,A):B.type==="arc"||B.type==="circle"?x(this,lA,Wc).call(this,B,g):!1},"#applyTrimIntersectionConstraint"),wL=E(function(g,A,e){const t=this._solver?.sketchObject;if(!t||!g)return!1;const B=Array.isArray(g.points)?g.points:[];if(B.length<2)return!1;const i=B[0],I=B[1],s=t.points.find(h=>h.id===i),C=t.points.find(h=>h.id===I),o=t.points.find(h=>h.id===A);if(!s||!C||!o)return!1;const Q=Math.hypot(C.x-s.x,C.y-s.y)||1,n=.001,r=Math.max(1e-5,Math.min(.01,Q*.001)),a=Number.isFinite(e?.otherParam)?e.otherParam:null,w=a!=null&&a<=n||Math.hypot(o.x-s.x,o.y-s.y)<=r,c=a!=null&&a>=1-n||Math.hypot(o.x-C.x,o.y-C.y)<=r;return w&&A!==i?x(this,lA,VQ).call(this,"≡",[i,A]):c&&A!==I?x(this,lA,VQ).call(this,"≡",[I,A]):A===i||A===I?!1:x(this,lA,VQ).call(this,"⏛",[i,I,A])},"#ensurePointOnLineConstraint"),Wc=E(function(g,A){if(!this._solver?.sketchObject||!g)return!1;const e=Array.isArray(g.points)?g.points:[];if(e.length<2)return!1;const t=e[0],B=e[1];return t==null||B==null||A===t||A===B?!1:x(this,lA,VQ).call(this,"⇌",[t,B,t,A])},"#ensurePointOnArcConstraint"),VQ=E(function(g,A){const e=this._solver?.sketchObject;if(!e||!Array.isArray(A)||(Array.isArray(e.constraints)||(e.constraints=[]),e.constraints.some(B=>x(this,lA,T7).call(this,B,g,A))))return!1;const t=Math.max(0,...e.constraints.map(B=>+B.id||0))+1;return e.constraints.push({id:t,type:g,points:A.slice(),labelX:0,labelY:0,displayStyle:"",value:null,valueNeedsSetup:!0}),!0},"#addConstraintIfMissing"),T7=E(function(g,A,e){if(!g||g.type!==A||!Array.isArray(g.points))return!1;if(A==="≡"){if(e.length<2||g.points.length<2)return!1;const[t,B]=e,[i,I]=g.points;return i===t&&I===B||i===B&&I===t}if(A==="⏛"){if(e.length<3||g.points.length<3)return!1;const[t,B,i]=e,[I,s,C]=g.points;return(I===t&&s===B||I===B&&s===t)&&C===i}if(A==="⇌"){if(e.length<4||g.points.length<4)return!1;const[t,B,i,I]=e,[s,C,o,Q]=g.points,n=E((w,c,h,l)=>w===h&&c===l||w===l&&c===h,"samePair"),r=n(s,C,t,B)&&n(o,Q,i,I),a=n(s,C,i,I)&&n(o,Q,t,B);return r||a}return!1},"#constraintMatches"),Ni=E(function(g,A,e=null,t={}){const B=this._solver?.sketchObject;if(!B)return null;const i=Math.max(0,...B.geometries.map(s=>+s.id||0))+1,I=typeof t.construction=="boolean"?t.construction:!!e?.construction;return B.geometries.push({id:i,type:g,points:A,construction:I}),i},"#addGeometry"),lL=E(function(g){const A=this.viewer;if(!A)return null;const e=A.renderer.domElement.getBoundingClientRect(),t=new LA((g.clientX-e.left)/e.width*2-1,-((g.clientY-e.top)/e.height*2-1));x(this,lA,hm).call(this,t);try{const{width:I,height:s}=x(this,lA,zi).call(this,A.renderer.domElement),C=x(this,lA,wI).call(this,A.camera,I,s);this._raycaster.params.Line=this._raycaster.params.Line||{},this._raycaster.params.Line.threshold=Math.max(.05,C*6);const o=window.devicePixelRatio||1;this._raycaster.params.Line2=this._raycaster.params.Line2||{},this._raycaster.params.Line2.threshold=Math.max(1,2*o)}catch{}const B=[];try{A.scene.traverse(I=>{I&&I.type==="EDGE"&&I.visible!==!1&&B.push(I)})}catch{}const i=B.length?this._raycaster.intersectObjects(B,!0):[];return i&&i.length?i[0]:null},"#hitTestSceneEdge"),hL=E(function(g){const A=this.viewer;if(!A||!this._solver||!this._lock)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const t=this._solver.sketchObject;if(!t)return null;const B=E(h=>t.points.find(l=>l.id===h),"P"),{width:i,height:I}=x(this,lA,zi).call(this,A.renderer.domElement),s=x(this,lA,wI).call(this,A.camera,i,I),C=Math.max(.05,s*10),o=E((h,l,M,F,d,Y)=>{const u=M-h,G=F-l,y=d-h,U=Y-l,N=u*u+G*G||1e-12;let f=(y*u+U*G)/N;f<0?f=0:f>1&&(f=1);const m=h+u*f,R=l+G*f;return Math.hypot(d-m,Y-R)},"distToSeg"),Q=E((h,l,M)=>{const F=Number(h?.du),d=Number(h?.dv);if(Number.isFinite(F)||Number.isFinite(d))return{du:Number.isFinite(F)?F:0,dv:Number.isFinite(d)?d:0};const Y=(M?.x??0)-(l?.x??0),u=(M?.y??0)-(l?.y??0),G=Math.hypot(Y,u),y=G>1e-9?Y/G:1,U=G>1e-9?u/G:0,N=-U,f=y;if(h&&(h.dr!==void 0||h.dp!==void 0)){const R=Number(h.dr)||0,p=Number(h.dp)||0;return{du:Y+y*R+N*p,dv:u+U*R+f*p}}const m=Math.max(.2,G*.35);return{du:Y+y*m+N*m*.35,dv:u+U*m+f*m*.35}},"radialOffsetToPlane"),n=E(h=>{const l=h?.radialGeometryType;if(l==="arc"||l==="circle")return l;if(!Array.isArray(t?.geometries)||!Array.isArray(h?.points)||h.points.length<2)return null;const M=parseInt(h.points[0]),F=parseInt(h.points[1]);if(!Number.isFinite(M)||!Number.isFinite(F))return null;let d=!1;for(const Y of t.geometries||[])if(!(!Y||!Array.isArray(Y.points)||Y.points.length<2)){if(Y.type==="arc"&&Y.points.length>=3){const u=parseInt(Y.points[0]),G=parseInt(Y.points[1]),y=parseInt(Y.points[2]);if(u===M&&(G===F||y===F))return"arc"}else if(Y.type==="circle"){const u=parseInt(Y.points[0]),G=parseInt(Y.points[1]);u===M&&G===F&&(d=!0)}}return d?"circle":null},"resolveRadialGeometryType"),r=E((h,l,M,F)=>{const d=(h.x-l.x)*(M.y-F.y)-(h.y-l.y)*(M.x-F.x);if(Math.abs(d)<1e-9)return{x:l.x,y:l.y};const Y=((h.x*h.y-l.x*l.y)*(M.x-F.x)-(h.x-l.x)*(M.x*M.y-F.x*F.y))/d,u=((h.x*h.y-l.x*l.y)*(M.y-F.y)-(h.y-l.y)*(M.x*M.y-F.x*F.y))/d;return{x:Y,y:u}},"intersect"),a=E(h=>{if(!h||!Array.isArray(h.points))return null;if(h.type==="⟺"&&h.points.length>=2&&h.displayStyle!=="radius"&&h.displayStyle!=="diameter"){const l=B(h.points[0]),M=B(h.points[1]);return!l||!M?null:{a:l,b:M}}if(h.type===ny&&h.points.length>=3){const l=B(h.points[0]),M=B(h.points[1]),F=B(h.points[2]);if(!l||!M||!F)return null;const d=M.x-l.x,Y=M.y-l.y,u=d*d+Y*Y;if(!(u>1e-12))return{a:l,b:F};let G=((F.x-l.x)*d+(F.y-l.y)*Y)/u;return Number.isFinite(G)||(G=0),{a:{x:l.x+G*d,y:l.y+G*Y},b:{x:F.x,y:F.y}}}return null},"linearDistanceEndpoints");let w=null,c=1/0;for(const h of t.constraints||[])if((h.type==="⟺"||h.type===ny)&&Array.isArray(h.points))if(h.type==="⟺"&&(h.displayStyle==="radius"||h.displayStyle==="diameter")){const l=B(h.points[0]),M=B(h.points[1]);if(!l||!M)continue;const F=Q(this._dimOffsets.get(h.id)||{},l,M),d=l.x+F.du,Y=l.y+F.dv,u=M.x-l.x,G=M.y-l.y,y=Math.hypot(u,G);if(!(y>1e-9))continue;let U=d-l.x,N=Y-l.y,f=Math.hypot(U,N);f>1e-9||(U=u,N=G,f=Math.hypot(U,N)||1),U/=f,N/=f;const m=l.x+U*y,R=l.y+N*y,p=l.x-U*y,k=l.y-N*y;let H=o(m,R,d,Y,e.u,e.v);h.displayStyle==="diameter"?(H=Math.min(H,o(p,k,m,R,e.u,e.v)),n(h)==="arc"&&(H=Math.min(H,Math.abs(Math.hypot(e.u-l.x,e.v-l.y)-y)))):H=Math.min(H,o(l.x,l.y,m,R,e.u,e.v)),H<c&&(c=H,w=h.id)}else{const l=a(h);if(!l)continue;const M=o(l.a.x,l.a.y,l.b.x,l.b.y,e.u,e.v);M<c&&(c=M,w=h.id)}else if(h.type==="∠"&&Array.isArray(h.points)&&h.points.length>=4){const l=B(h.points[0]),M=B(h.points[1]),F=B(h.points[2]),d=B(h.points[3]);if(!l||!M||!F||!d)continue;const Y=r(l,M,F,d),u=Math.max(.2,s*12),G=Math.abs(Math.hypot(e.u-Y.x,e.v-Y.y)-u);G<c&&(c=G,w=h.id)}return w!=null&&c<=C?{cid:w}:null},"#hitTestDim"),Fm=E(function(g){const A=this.viewer;if(!A||!this._lock||!this._glyphCenters)return null;const e=x(this,lA,MB).call(this,g);if(!e)return null;const{width:t,height:B}=x(this,lA,zi).call(this,A.renderer.domElement),i=x(this,lA,wI).call(this,A.camera,t,B),I=Math.max(.05,i*8);let s=null,C=1/0;try{for(const[o,Q]of this._glyphCenters.entries()){const n=Math.hypot(e.u-Q.u,e.v-Q.v);n<C&&(C=n,s=o)}}catch{}return s!=null&&C<=I?{cid:s}:null},"#hitTestGlyph"),dm=E(function(g,A){const e=this._theme?.[g];if(e==null)return A;try{return new se(e).getHex()}catch{return A}},"#themeColor"),DL=E(function(g,A,e=-1/0,t=1/0){const B=this._theme?.[g],i=Number(B),I=Number.isFinite(i)?i:A;return Number.isFinite(I)?Math.max(e,Math.min(t,I)):A},"#themeNumber"),Ln=E(function(g,A){const e=x(this,lA,wI).call(this,this.viewer.camera,g,A),t=x(this,lA,DL).call(this,"pointSizePx",8,1,128);return Math.max(.02,e*t*.5)},"#pointRadiusWorld"),Cg=E(function(){const g=this._sketchGroup;if(!g||!this._solver)return;for(let u=g.children.length-1;u>=0;u--){const G=g.children[u];g.remove(G);try{G.geometry?.dispose(),G.material?.dispose?.()}catch{}}const A=this._solver.sketchObject,e=this._lock?.basis;if(!e)return;x(this,lA,bo).call(this);const t=new Set;try{for(const u of A.constraints||[])if(!(!u||u.temporary||!Array.isArray(u.points)))for(const G of u.points)t.add(parseInt(G))}catch{}const B=e.origin,i=e.x,I=e.y,s=x(this,lA,dm).call(this,"geometryColor",16777096),C=x(this,lA,dm).call(this,"pointColor",10406399),o=x(this,lA,dm).call(this,"constructionPointColor",16754794),Q=x(this,lA,DL).call(this,"curveThicknessPx",1,.5,48),n=this._useFatCurveLines===!0||Q>1,r=E((u,G)=>new K().copy(B).addScaledVector(i,u).addScaledVector(I,G),"to3"),a=new hg({color:s,linewidth:Q,depthTest:!1,depthWrite:!1,transparent:!0}),w=new r0({color:s,linewidth:Q,depthTest:!1,depthWrite:!1,transparent:!0,dashSize:.1,gapSize:.08});let c=.05,h=1,l=1;try{const{width:u,height:G}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);h=Math.max(1,u||1),l=Math.max(1,G||1),c=x(this,lA,wI).call(this,this.viewer.camera,u,G)}catch{}const M=E((u,G,y)=>{if(!Array.isArray(u)||u.length<2||!G)return;const U=Array.from(this._selection).some(m=>m.type==="geometry"&&m.id===G.id)?7332463:s,N=G.construction===!0;let f=null;if(!N&&n){const m=[];for(const k of u)m.push(k.x,k.y,k.z);const R=new YB;R.setPositions(m);const p=new ri({color:U,linewidth:Q,worldUnits:!1,dashed:!1,transparent:!0,depthTest:!1,depthWrite:!1,toneMapped:!1});try{p.resolution?.set?.(h,l)}catch{}f=new Lw(R,p)}else{const m=new ce().setFromPoints(u),R=N?w.clone():a.clone();if(N)try{R.dashSize=Math.max(.02,8*c),R.gapSize=Math.max(.01,6*c)}catch{}try{R.color.set(U)}catch{}if(f=new lt(m,R),N)try{f.computeLineDistances()}catch{}}f&&(f.renderOrder=1e4,f.userData={kind:"geometry",id:G.id,type:y},g.add(f))},"addCurveObject");for(const u of A.geometries||[])if(u.type==="line"&&u.points?.length===2){const G=A.points.find(U=>U.id===u.points[0]),y=A.points.find(U=>U.id===u.points[1]);if(!G||!y)continue;M([r(G.x,G.y),r(y.x,y.y)],u,"line")}else if(u.type==="circle"){const G=u.points||[],y=A.points.find(R=>R.id===G[0]),U=A.points.find(R=>R.id===G[1]);if(!y||!U)continue;const N=Math.hypot(U.x-y.x,U.y-y.y),f=64,m=[];for(let R=0;R<=f;R++){const p=R/f*Math.PI*2;m.push(r(y.x+N*Math.cos(p),y.y+N*Math.sin(p)))}M(m,u,u.type)}else if(u.type==="arc"){const G=u.points||[],y=A.points.find(z=>z.id===G[0]),U=A.points.find(z=>z.id===G[1]),N=A.points.find(z=>z.id===G[2]);if(!y||!U||!N)continue;const f=y.x,m=y.y,R=Math.hypot(U.x-f,U.y-m);let p=Math.atan2(U.y-m,U.x-f),k=Math.atan2(N.y-m,N.x-f)-p;k=(k%(2*Math.PI)+2*Math.PI)%(2*Math.PI),Math.abs(k)<1e-6&&(k=2*Math.PI);const H=Math.max(8,Math.ceil(64*k/(2*Math.PI))),S=[];for(let z=0;z<=H;z++){const v=p+k*(z/H);S.push(r(f+R*Math.cos(v),m+R*Math.sin(v)))}M(S,u,u.type)}else if(u.type==="bezier"){const G=u.points||[],y=Math.floor((G.length-1)/3);if(y<1)continue;const U=64,N=[];for(let f=0;f<y;f++){const m=f*3,R=A.points.find(S=>S.id===G[m]),p=A.points.find(S=>S.id===G[m+1]),k=A.points.find(S=>S.id===G[m+2]),H=A.points.find(S=>S.id===G[m+3]);if(!(!R||!p||!k||!H))for(let S=0;S<=U;S++){if(f>0&&S===0)continue;const z=S/U,v=1-z,X=v*v*v*R.x+3*v*v*z*p.x+3*v*z*z*k.x+z*z*z*H.x,b=v*v*v*R.y+3*v*v*z*p.y+3*v*z*z*k.y+z*z*z*H.y;N.push(r(X,b))}}M(N,u,u.type)}const{width:F,height:d}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);c=x(this,lA,wI).call(this,this.viewer.camera,F,d);const Y=x(this,lA,Ln).call(this,F,d);for(const u of A.points||[]){const G=Array.from(this._selection).some(p=>p.type==="point"&&p.id===u.id),y=u?.construction===!0,U=!G&&!u.fixed&&!t.has(u.id),N=y?o:C,f=this._uniformPointColor||y?N:U?16757575:N,m=new Pg({color:G?7332463:f,depthTest:!1,depthWrite:!1,transparent:!0}),R=new Bg(this._handleGeom,m);R.renderOrder=10001,R.position.copy(r(u.x,u.y)),R.userData={kind:"point",id:u.id,underConstrained:U,isConstructionPoint:y,isExternalReference:x(this,lA,wy).call(this,u.id)},R.scale.setScalar(G?Y*2:Y),g.add(R)}x(this,lA,Gi).call(this),x(this,lA,MC).call(this),x(this,lA,r7).call(this),x(this,lA,iL).call(this)},"#rebuildSketchGraphics"),iGA=E(function(){if(!this._sketchGroup)return;const{width:g,height:A}=x(this,lA,zi).call(this,this.viewer.renderer.domElement);x(this,lA,x7).call(this,g,A);const e=x(this,lA,Ln).call(this,g,A);if(!(Math.abs(e-this._lastHandleScale)<1e-4)){this._lastHandleScale=e;for(const t of this._sketchGroup.children)if(t?.userData?.kind==="point"){const B=Array.from(this._selection).some(i=>i.type==="point"&&i.id===t.userData.id);t.scale.setScalar(B?e*2:e)}}},"#updateHandleSizes"),x7=E(function(g,A){const e=Math.max(1,Number(g)||1),t=Math.max(1,Number(A)||1);for(const B of this._sketchGroup?.children||[]){const i=B?.material;if(!(!i||typeof i!="object"))try{i.resolution&&typeof i.resolution.set=="function"&&i.resolution.set(e,t)}catch{}}},"#updateFatLineResolutions"),IGA=E(function(){const g=this.viewer?.container;if(!g)return;const A=document.createElement("div");A.className="sketch-dims",A.style.position="absolute",A.style.left="0",A.style.top="0",A.style.right="0",A.style.bottom="0",A.style.pointerEvents="none";const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",A.appendChild(e),this._dimSVG=e,g.appendChild(A),this._dimRoot=A},"#mountDimRoot"),MC=E(function(){try{h3(this)}catch{}},"#renderDimensions"),b7=E(function(g){const A=this._solver?.sketchObject;if(!A)return null;const e=parseInt(g);return(A.constraints||[]).find(t=>parseInt(t.id)===e)||null},"#getConstraintById"),K7=E(function(g){if(!this._dragDim.active)return;const A=x(this,lA,MB).call(this,g);if(!A)return;const e=x(this,lA,b7).call(this,this._dragDim.cid);if(!e)return;const t=this._solver.sketchObject;if(e.type==="⟺"&&e.displayStyle==="radius"&&(e.points||[]).length>=2){const B=t.points.find(l=>l.id===e.points[0]),i=t.points.find(l=>l.id===e.points[1]);if(!B||!i)return;const I=i.x-B.x,s=i.y-B.y,C=Math.hypot(I,s)||1,o=I/C,Q=s/C,n=-Q,r=o,a=A.u-i.x,w=A.v-i.y,c=this._dragDim.start.dr+(a*o+w*Q),h=this._dragDim.start.dp+(a*n+w*r);this._dimOffsets.set(this._dragDim.cid,{dr:c,dp:h})}else if((e.type==="⟺"||e.type===ny)&&(e.points||[]).length>=2){let B=null,i=null;if(e.type===ny&&(e.points||[]).length>=3){const a=t.points.find(F=>F.id===e.points[0]),w=t.points.find(F=>F.id===e.points[1]),c=t.points.find(F=>F.id===e.points[2]);if(!a||!w||!c)return;const h=w.x-a.x,l=w.y-a.y,M=h*h+l*l;if(!(M>1e-12))B=a,i=c;else{let F=((c.x-a.x)*h+(c.y-a.y)*l)/M;Number.isFinite(F)||(F=0),B={x:a.x+F*h,y:a.y+F*l},i={x:c.x,y:c.y}}}else B=t.points.find(a=>a.id===e.points[0]),i=t.points.find(a=>a.id===e.points[1]);if(!B||!i)return;const I=i.x-B.x,s=i.y-B.y,C=Math.hypot(I,s)||1,o=-(s/C),Q=I/C,n=(A.u-this._dragDim.sx)*o+(A.v-this._dragDim.sy)*Q,r=this._dragDim.start.d+n;this._dimOffsets.set(this._dragDim.cid,{d:r})}x(this,lA,MC).call(this),g.preventDefault(),g.stopPropagation()},"#moveDimDrag"),L7=E(function(g){this._dragDim.active=!1,this._dragDim.last=null;try{g.target.releasePointerCapture?.(g.pointerId)}catch{}g.preventDefault(),g.stopPropagation();try{this.viewer?.controls&&(this.viewer.controls.enabled=!0)}catch{}x(this,lA,iL).call(this),setTimeout(()=>{x(this,lA,um).call(this,g)},30)},"#endDimDrag"),um=E(function(g){try{this.viewer?.controls?.dispatchEvent?.({type:"end"})}catch{}},"#notifyControlsEnd"),E(sGA,"SketchMode3D");let CGA=sGA;const Y3="__embed_sketch_feature__",BJ=!1,iJ=1,G8A=100,N8A=1e-4,f8A=300,oGA={geometryColor:null,pointColor:null,constraintColor:null,backgroundColor:null,pointSizePx:null,curveThicknessPx:null};function RN(g={}){const A=Number(g?.pointSizePx??g?.pointSize),e=Number(g?.curveThicknessPx??g?.curveThickness);return{geometryColor:g?.geometryColor??null,pointColor:g?.pointColor??null,constraintColor:g?.constraintColor??null,backgroundColor:g?.backgroundColor??null,pointSizePx:Number.isFinite(A)&&A>0?A:null,curveThicknessPx:Number.isFinite(e)&&e>0?e:null}}D(RN,"_y");E(RN,"normalizeTheme$1");function QGA(g,A=!1){return g==null?A:g!==!1}D(QGA,"CkA");E(QGA,"normalizeSidebarExpanded$2");function IJ(g,A=BJ){if(g==null)return A;if(typeof g=="string"){const e=g.trim().toLowerCase();if(e==="false"||e==="0"||e==="off"||e==="no")return!1;if(e==="true"||e==="1"||e==="on"||e==="yes")return!0}return g!==!1&&g!==0}D(IJ,"jT");E(IJ,"normalizeGridVisible$1");function sJ(g,A=iJ){const e=Number(g);return!Number.isFinite(e)||e<=0?A:Math.max(1e-4,Math.min(1e6,e))}D(sJ,"VT");E(sJ,"normalizeGridSpacing$1");function CJ(g,A){return typeof g=="number"&&Number.isFinite(g)?`#${Math.max(0,Math.min(16777215,g|0)).toString(16).padStart(6,"0")}`:typeof g=="string"&&g.trim()?g.trim():A}D(CJ,"WT");E(CJ,"toCssColor");var ar,j7,EGA,nGA,rGA,aGA,qu;const cGA=(qu=class extends AC{constructor(A,e){super(),Og(this,ar),this.camera=A,this.domElement=e,this.enabled=!0,this.target=new K(0,0,0),this._panning=!1,this._lastX=0,this._lastY=0,this._boundPointerDown=t=>x(this,ar,EGA).call(this,t),this._boundPointerMove=t=>x(this,ar,nGA).call(this,t),this._boundPointerUp=()=>x(this,ar,rGA).call(this),this._boundWheel=t=>x(this,ar,aGA).call(this,t),this._boundContextMenu=t=>t.preventDefault(),e.addEventListener("pointerdown",this._boundPointerDown,{passive:!1}),window.addEventListener("pointermove",this._boundPointerMove,{passive:!1}),window.addEventListener("pointerup",this._boundPointerUp,{passive:!1}),e.addEventListener("wheel",this._boundWheel,{passive:!1}),e.addEventListener("contextmenu",this._boundContextMenu,{passive:!1})}update(){}updateMatrixState(){}dispose(){const A=this.domElement;A&&(A.removeEventListener("pointerdown",this._boundPointerDown),window.removeEventListener("pointermove",this._boundPointerMove),window.removeEventListener("pointerup",this._boundPointerUp),A.removeEventListener("wheel",this._boundWheel),A.removeEventListener("contextmenu",this._boundContextMenu))}},D(qu,"mV"),qu);ar=new WeakSet,j7=E(function(){const g=this.domElement,A=Math.max(1,g.clientWidth||g.width||1),e=Math.max(1,g.clientHeight||g.height||1);if(!this.camera?.isOrthographicCamera)return{x:.05,y:.05};const t=this.camera.zoom>0?this.camera.zoom:1;return{x:(this.camera.right-this.camera.left)/(A*t),y:(this.camera.top-this.camera.bottom)/(e*t)}},"#worldPerPixel"),EGA=E(function(g){this.enabled&&(g.button!==1&&g.button!==2||(g.preventDefault(),this._panning=!0,this._lastX=g.clientX,this._lastY=g.clientY))},"#onPointerDown"),nGA=E(function(g){if(!this.enabled||!this._panning)return;g.preventDefault();const A=g.clientX-this._lastX,e=g.clientY-this._lastY;this._lastX=g.clientX,this._lastY=g.clientY;const t=x(this,ar,j7).call(this),B=A*t.x,i=e*t.y;this.camera.position.x-=B,this.camera.position.y+=i,this.target.x-=B,this.target.y+=i,this.camera.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})},"#onPointerMove"),rGA=E(function(){this._panning&&(this._panning=!1,this.dispatchEvent({type:"end"}))},"#onPointerUp"),aGA=E(function(g){if(!this.enabled||!this.camera?.isOrthographicCamera)return;g.preventDefault();const A=Math.exp(g.deltaY*.0015),e=this.camera.zoom/A;this.camera.zoom=Math.max(N8A,Math.min(f8A,e)),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.dispatchEvent({type:"change"})},"#onWheel"),E(cGA,"Simple2DControls");let p8A=cGA;var aB,jG,Ez,nz,P7,oJ,wGA,rz,az,lGA,_u;const hGA=(_u=class{constructor({container:A,sidebar:e,theme:t=oGA,gridVisible:B=BJ,gridSpacing:i=iJ,featureID:I=Y3,onSketchChange:s=null,onSketchFinished:C=null,onSketchCancelled:o=null}){if(Og(this,aB),this.container=A,this.sidebar=e,this.theme=RN(t),this._dragThreshold=5,this._featureID=I,this._onSketchChange=s,this._onSketchFinished=C,this._onSketchCancelled=o,this._gridVisible=IJ(B,BJ),this._gridSpacing=sJ(i,iJ),this._gridHelper=null,this.scene=new Za,this.camera=new vC(-20,20,20,-20,.01,5e3),this.camera.position.set(0,0,80),this.camera.up.set(0,1,0),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0),this.renderer=new sT({antialias:!0,alpha:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.setClearColor(CJ(this.theme.backgroundColor,"#ffffff"),1),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.display="block",this.renderer.domElement.style.touchAction="none",this.container.appendChild(this.renderer.domElement),this.controls=new p8A(this.camera,this.renderer.domElement),this._boundControlsChange=()=>{try{this._sketchMode?.onCameraChanged?.()}catch{}},this.controls.addEventListener("change",this._boundControlsChange),this.controls.addEventListener("end",this._boundControlsChange),x(this,aB,az).call(this),this.mainToolbar=new UUA(this),this._feature={inputParams:{featureID:this._featureID,sketchPlane:null},persistentData:{sketch:null,externalRefs:[]}},this.partHistory={scene:this.scene,features:[this._feature],runHistory:E(async()=>null,"runHistory"),queueHistorySnapshot:E(()=>null,"queueHistorySnapshot"),getObjectByName:E(Q=>this.scene.getObjectByName(Q)||null,"getObjectByName")},this._raf=0,this._running=!1,this._sketchMode=null,this._disposed=!1,this._resizeRaf=0,this._boundResize=()=>x(this,aB,oJ).call(this),this._boundResizeQueued=()=>x(this,aB,wGA).call(this),window.addEventListener("resize",this._boundResize),typeof ResizeObserver<"u"){this._resizeObserver=new ResizeObserver(this._boundResizeQueued);try{this._resizeObserver.observe(this.container)}catch{}}else this._resizeObserver=null;x(this,aB,oJ).call(this)}_getSidebarShouldShow(){return!0}render(){this.renderer.render(this.scene,this.camera)}start(A=null){A&&x(this,aB,jG).call(this,A),x(this,aB,Ez).call(this),x(this,aB,lGA).call(this)}stop(){this._running=!1,this._raf&&cancelAnimationFrame(this._raf),this._raf=0;try{this._sketchMode?.close?.()}catch{}this._sketchMode=null}dispose(){this._disposed=!0,this.stop(),this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeRaf=0,window.removeEventListener("resize",this._boundResize);try{this._resizeObserver?.disconnect?.()}catch{}this._resizeObserver=null;try{this.controls?.dispose?.()}catch{}try{this.controls?.removeEventListener?.("change",this._boundControlsChange)}catch{}try{this.controls?.removeEventListener?.("end",this._boundControlsChange)}catch{}try{this.mainToolbar?._ro?.disconnect?.()}catch{}try{this.mainToolbar?.root?.parentNode?.removeChild(this.mainToolbar.root)}catch{}x(this,aB,rz).call(this);try{this.renderer?.dispose?.()}catch{}try{this.renderer?.domElement?.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}catch{}}getSketch(){const A=this._sketchMode?.getSketchData?.()||this._feature?.persistentData?.sketch||null;return de(A)}setSketch(A){const e=de(A||null);return x(this,aB,jG).call(this,e),this._sketchMode?.setSketchData&&this._sketchMode.setSketchData(e),this.getSketch()}setTheme(A){this.theme=RN({...this.theme,...A||{}});try{this.renderer.setClearColor(CJ(this.theme.backgroundColor,"#ffffff"),1)}catch{}if(this._sketchMode){this._sketchMode._theme=this.theme;const e=this._sketchMode.getSketchData?.()||null;this._sketchMode.setSketchData?.(e)}}setGridOptions(A={}){const e=A?.gridVisible??A?.visible,t=A?.gridSpacing??A?.spacing;this._gridVisible=IJ(e,this._gridVisible),this._gridSpacing=sJ(t,this._gridSpacing),x(this,aB,az).call(this)}onSketchFinished(A,e){x(this,aB,jG).call(this,e);try{this._onSketchFinished&&this._onSketchFinished(de(e||null))}catch{}x(this,aB,nz).call(this)}onSketchCancelled(A){try{this._onSketchCancelled&&this._onSketchCancelled()}catch{}x(this,aB,nz).call(this)}},D(_u,"RV"),_u);aB=new WeakSet,jG=E(function(g){this._feature.persistentData=this._feature.persistentData||{},this._feature.persistentData.sketch=de(g||null)},"#setFeatureSketch"),Ez=E(function(){if(!this._disposed){try{this._sketchMode?.dispose?.()}catch{}this._sketchMode=new CGA(this,this._featureID,{theme:this.theme,uniformPointColor:!0,useFatCurveLines:!0,onSketchChange:E(g=>{x(this,aB,jG).call(this,g);try{this._onSketchChange&&this._onSketchChange(de(g))}catch{}},"onSketchChange")}),this._sketchMode.open()}},"#openSketchMode"),nz=E(function(){this._disposed||setTimeout(()=>{this._disposed||x(this,aB,Ez).call(this)},0)},"#reopenSketchModeSoon"),P7=E(function(g,A){const e=Math.max(1,g||1),t=Math.max(1,A||1),B=e/t,i=40*.5,I=i*B;this.camera.left=-I,this.camera.right=I,this.camera.top=i,this.camera.bottom=-i,this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(!0)},"#updateCameraFrustum"),oJ=E(function(){if(this._disposed)return;const g=this.container.getBoundingClientRect(),A=Math.max(1,Math.floor(g.width)),e=Math.max(1,Math.floor(g.height));this.renderer.setSize(A,e,!1),x(this,aB,P7).call(this,A,e),this.render()},"#onResize"),wGA=E(function(){this._disposed||this._resizeRaf||(this._resizeRaf=requestAnimationFrame(()=>{this._resizeRaf=0,x(this,aB,oJ).call(this)}))},"#queueResize"),rz=E(function(){if(this._gridHelper){try{this.scene.remove(this._gridHelper)}catch{}try{const g=Array.isArray(this._gridHelper.material)?this._gridHelper.material:[this._gridHelper.material];for(const A of g)try{A?.dispose?.()}catch{}try{this._gridHelper.geometry?.dispose?.()}catch{}}catch{}this._gridHelper=null}},"#clearGrid"),az=E(function(){if(x(this,aB,rz).call(this),!this._gridVisible)return;const g=200*G8A,A=this._gridSpacing*g,e=new IT(A,g,6055026,4015444);e.rotation.x=Math.PI/2,e.position.z=-.001,e.renderOrder=9e3,e.frustumCulled=!1;const t=Array.isArray(e.material)?e.material:[e.material];for(let B=0;B<t.length;B+=1){const i=t[B];i&&(i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=B===0?.38:.2,i.toneMapped=!1)}this.scene.add(e),this._gridHelper=e},"#rebuildGrid"),lGA=E(function(){if(this._running)return;this._running=!0;const g=E(()=>{this._running&&(this.controls.update(),this.render(),this._raf=requestAnimationFrame(g))},"tick");g()},"#startRenderLoop"),E(hGA,"EmbeddedSketchViewer");let m8A=hGA;var St,DGA,MGA,qU,ML,FGA,z7,v7,FL,dL,uL,Dy,$u;const dGA=($u=class{constructor({channel:A,instanceId:e}){Og(this,St),this._channel=A,this._instanceId=e,this._viewer=null,this._customCssEl=null,this._root=null,this._canvasHost=null,this._sidebarHost=null,this._disposed=!1,this._theme=RN(oGA),this._sidebarExpanded=!1,this._gridVisible=BJ,this._gridSpacing=iJ,this._boundMessage=t=>x(this,St,FGA).call(this,t)}boot(){this._disposed||(x(this,St,DGA).call(this),x(this,St,MGA).call(this),window.addEventListener("message",this._boundMessage),x(this,St,qU).call(this,"ready",{version:1}))}dispose(){if(!this._disposed){this._disposed=!0,window.removeEventListener("message",this._boundMessage);try{this._viewer?.dispose?.()}catch{}this._viewer=null;try{this._root?.parentNode&&this._root.parentNode.removeChild(this._root)}catch{}this._root=null,this._canvasHost=null,this._sidebarHost=null}}},D($u,"SV"),$u);St=new WeakSet,DGA=E(function(){if(document.getElementById("sk2d-base-styles"))return;const g=document.createElement("style");g.id="sk2d-base-styles",g.textContent=`
10260
10260
  html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
10261
10261
  body { background: #f5f6f8; color: #111; font-family: "Segoe UI", Tahoma, sans-serif; }
10262
10262
  .sk2d-root { position: relative; width: 100%; height: 100%; overflow: hidden; margin: 0; padding: 0; }