toposync-ext-structural 0.3.0__tar.gz → 0.4.0__tar.gz

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 (31) hide show
  1. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/PKG-INFO +1 -1
  2. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/pyproject.toml +1 -1
  3. toposync_ext_structural-0.4.0/src/toposync_ext_structural/static/12.js +2 -0
  4. toposync_ext_structural-0.3.0/src/toposync_ext_structural/static/12.js +0 -2
  5. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/.gitignore +0 -0
  6. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/LICENSE +0 -0
  7. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/README.md +0 -0
  8. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/__init__.py +0 -0
  9. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/extension.json +0 -0
  10. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/plugin.py +0 -0
  11. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/static/12.js.LICENSE.txt +0 -0
  12. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/static/326.js +0 -0
  13. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/static/326.js.LICENSE.txt +0 -0
  14. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/static/main.js +0 -0
  15. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/src/toposync_ext_structural/static/remoteEntry.js +0 -0
  16. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/package.json +0 -0
  17. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/activate.tsx +0 -0
  18. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/colors.ts +0 -0
  19. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/constants.ts +0 -0
  20. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/elements/AreaElementType.tsx +0 -0
  21. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/elements/PoolElementType.tsx +0 -0
  22. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/elements/WallElementType.tsx +0 -0
  23. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/entry.ts +0 -0
  24. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/geometry.ts +0 -0
  25. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/parsing.ts +0 -0
  26. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/textures.ts +0 -0
  27. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/tools/structuralTools.ts +0 -0
  28. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/translations.ts +0 -0
  29. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/src/wallOpenings.ts +0 -0
  30. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/tsconfig.json +0 -0
  31. {toposync_ext_structural-0.3.0 → toposync_ext_structural-0.4.0}/ui/webpack.config.js +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toposync-ext-structural
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Toposync first-party extension: Structural drawing tools (2D walls/areas).
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "toposync-ext-structural"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Toposync first-party extension: Structural drawing tools (2D walls/areas)."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 12.js.LICENSE.txt */
2
+ "use strict";(self.webpackChunk_toposync_extension_structural_ui=self.webpackChunk_toposync_extension_structural_ui||[]).push([[12],{12(e,t,o){o.r(t),o.d(t,{activate:()=>Xe});var r=o(870),n=o(496);function a(e){const t=e.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(t)?{r:Number.parseInt(t.slice(0,2),16),g:Number.parseInt(t.slice(2,4),16),b:Number.parseInt(t.slice(4,6),16)}:null}function i(e,t){const o=a(e),r=Math.max(0,Math.min(1,t));return o?`rgba(${o.r},${o.g},${o.b},${r})`:`rgba(99,102,241,${r})`}function s(e,t,o){const r=a(e),n=a(t);if(!r||!n)return e;const i=Math.max(0,Math.min(1,o));return function(e){const t=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");return`#${t(e.r)}${t(e.g)}${t(e.b)}`}({r:r.r+(n.r-r.r)*i,g:r.g+(n.g-r.g)*i,b:r.b+(n.b-r.b)*i})}function l(e,t){return t>=0?s(e,"#ffffff",t):s(e,"#000000",Math.abs(t))}const c="com.toposync.structural.wall",u="com.toposync.structural.area",d="com.toposync.structural.pool",p="#dcddda",m=.12,h="#dcddda",x="toposync.structural.area.fill.v1";function f(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function g(e,t){return"string"==typeof e?e:t}function w(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function y(e){try{if(!w(e))return;localStorage.setItem(x,e)}catch{}}function _(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return t;const o=e;return{x:f(o.x,t.x),z:f(o.z,t.z)}}function M(e){return Array.isArray(e)?e.map(e=>_(e,{x:0,z:0})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.z)):[]}function b(e){const t=document.createElement("canvas");return t.width=e,t.height=e,t}function v(e,t){return e+Math.floor(Math.random()*(t-e+1))}function k(e,t,o,r){e.save(),e.globalAlpha=r;for(let r=0;r<o;r++){const o=Math.random()*t,r=Math.random()*t,n=1+2*Math.random(),a=1+2*Math.random(),i=v(0,255);e.fillStyle=`rgb(${i},${i},${i})`,e.fillRect(o,r,n,a)}e.restore()}function z(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#6b7280",o.fillRect(0,0,e,e);const r=e/10,n=2.2*r,a=Math.max(1,Math.round(.01*e));for(let t=0;t<10;t++){const i=t*r;for(let s=-(t%2==0?0:n/2);s<e+n;s+=n){const e=Math.floor(s+a),t=Math.floor(i+a),l=Math.ceil(n-2*a),c=Math.ceil(r-2*a),u=v(86,140);o.fillStyle=`rgb(${u},${u},${u})`,o.fillRect(e,t,l,c)}}o.strokeStyle="#111827",o.lineWidth=a,o.globalAlpha=.85;for(let t=0;t<=10;t++){const n=t*r;o.beginPath(),o.moveTo(0,n+.5),o.lineTo(e,n+.5),o.stroke()}for(let t=0;t<10;t++){const a=t*r;for(let i=-(t%2==0?0:n/2);i<e+n;i+=n){const e=i;o.beginPath(),o.moveTo(e+.5,a),o.lineTo(e+.5,a+r),o.stroke()}}return k(o,e,Math.floor(e*e/10),.06),t}function S(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#7c5d3a",o.fillRect(0,0,e,e),o.save(),o.globalAlpha=.35;for(let t=0;t<e;t+=1){const r=t/e,n=Math.sin(r*Math.PI*8+1.2*Math.sin(r*Math.PI*2)),a=Math.round(88+20*n+12*Math.random());o.fillStyle=`rgb(${a},${Math.round(.72*a)},${Math.round(.45*a)})`,o.fillRect(0,t,e,1)}o.restore(),o.save(),o.globalAlpha=.18,o.strokeStyle="#3f2f1f",o.lineWidth=1;for(let t=0;t<48;t++){const t=Math.random()*e,r=Math.random()*e,n=2+6*Math.random(),a=1+3*Math.random();o.beginPath(),o.ellipse(t,r,n,a,Math.random()*Math.PI,0,2*Math.PI),o.stroke()}return o.restore(),k(o,e,Math.floor(e*e/4),.06),t}function j(e){const t=b(e),o=t.getContext("2d");return o?(o.fillStyle="#9ca3af",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.08),k(o,e,Math.floor(e*e/3),.06),t):t}function N(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#166534",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.1),o.save(),o.globalAlpha=.2,o.strokeStyle="#052e16",o.lineWidth=1;for(let t=0;t<360;t++){const t=Math.random()*e,r=Math.random()*e,n=4+10*Math.random(),a=-Math.PI/2+.8*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}o.globalAlpha=.14,o.strokeStyle="#4ade80";for(let t=0;t<180;t++){const t=Math.random()*e,r=Math.random()*e,n=3+8*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}return o.restore(),t}function T(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#14532d",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.08),k(o,e,Math.floor(e*e/3),.06),o.save(),o.globalAlpha=.18,o.strokeStyle="#052e16",o.lineWidth=1;for(let t=0;t<900;t++){const t=Math.random()*e,r=Math.random()*e,n=4+12*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}o.globalAlpha=.12,o.strokeStyle="#86efac";for(let t=0;t<520;t++){const t=Math.random()*e,r=Math.random()*e,n=3+10*Math.random(),a=-Math.PI/2+1*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}return o.restore(),t}const W=new Map;function P(e,t,o,r){const n=W.get(t);if(n)return n;const a=o(r?.size??256),i=new e.CanvasTexture(a);return i.wrapS=e.RepeatWrapping,i.wrapT=e.RepeatWrapping,i.colorSpace=e.SRGBColorSpace,i.anisotropy=r?.anisotropy??4,W.set(t,i),i}function C(e,t){return"none"===e||"brick"===e||"concrete"===e?e:t}function D(e,t){return"none"===e||"grass"===e||"concrete"===e?e:t}function A(e,t){return"none"===e||"wood"===e||"concrete"===e||"glass"===e?e:t}function F(e,t){return"none"===t||"glass"===t?null:"wood"===t?P(e,"opening:wood",S,{size:256,anisotropy:4}):"concrete"===t?P(e,"opening:concrete",j,{size:256,anisotropy:4}):null}let E=null;function R(e){const t=Math.random(),o=Math.random(),r=Math.sqrt(t),n=1-r,a=o*r,i=1-n-a;return{x:e.ax*n+e.bx*a+e.cx*i,z:e.az*n+e.bz*a+e.cz*i}}function B(e){return{type:u,layerGroup:"areas",name:{key:"ext.structural.area.name",fallback:"Area"},description:{key:"ext.structural.area.desc",fallback:"Area (polygon) in 2D."},defaultProps:{fill:h,opacity:1,texture:"none",vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:e=>function(e){if(0===e.length)return null;let t=e[0].x,o=e[0].x,r=e[0].z,n=e[0].z;for(let a=1;a<e.length;a+=1){const i=e[a];t=Math.min(t,i.x),o=Math.max(o,i.x),r=Math.min(r,i.z),n=Math.max(n,i.z)}return{minX:t,maxX:o,minZ:r,maxZ:n}}(M(e.props.vertices)),renderMain2DVector:({element:e})=>{const t=M(e.props.vertices);if(t.length<3)return null;const o=g(e.props.fill,h),n=f(e.props.opacity,1),a=n<.001?0:n;if(a<=0)return null;const s=D(e.props.texture,"none"),c=function(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}(t),u=i(l(o,"grass"===s?-.24:-.16),Math.min(.34,.34*a)),d=i(l(o,.42),Math.min(.2,.2*a)),p="grass"===s?"mainVector2dGrassPattern":"concrete"===s?"mainVector2dConcretePattern":"";return(0,r.jsxs)("g",{className:"mainVector2dArea",children:[(0,r.jsx)("polygon",{points:c,fill:i(o,Math.min(.92,Math.max(0,a))),stroke:u,strokeWidth:.026,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),p?(0,r.jsx)("polygon",{points:c,fill:`url(#${p})`,opacity:Math.min(.42,.38*a)}):null,(0,r.jsx)("polygon",{points:c,fill:"none",stroke:d,strokeWidth:.01,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.MeshStandardMaterial({color:h,roughness:.95,metalness:0,side:e.DoubleSide,transparent:!1,opacity:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});n.stencilWrite=!0,n.stencilRef=1,n.stencilFunc=e.NotEqualStencilFunc,n.stencilFail=e.KeepStencilOp,n.stencilZFail=e.KeepStencilOp,n.stencilZPass=e.KeepStencilOp,n.stencilWriteMask=0,n.stencilFuncMask=255;let a=null,i="",s=null,l=null,c="";function u(t,o,n){if(s&&(r.remove(s),s.geometry.dispose(),s=null),!(o>0))return;const a=new e.PlaneGeometry(1,1,1,4);a.translate(0,.5,0);const i=a,c=new e.InstancedBufferAttribute(new Float32Array(o),1);i.setAttribute("instanceSeed",c);const u=function(){if(l)return l;const t=function(e){if(E)return E;const t=64,o=document.createElement("canvas");o.width=t,o.height=t;const r=o.getContext("2d");if(r){r.clearRect(0,0,t,t),r.fillStyle="black",r.fillRect(0,0,t,t);const e=r.createLinearGradient(0,t,0,0);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.18,"rgba(255,255,255,1)"),e.addColorStop(1,"rgba(255,255,255,1)"),r.fillStyle=e,r.beginPath(),r.moveTo(32,1.28),r.quadraticCurveTo(37.12,28.8,39.68,62.72),r.quadraticCurveTo(32,57.6,24.32,62.72),r.quadraticCurveTo(26.88,28.8,32,1.28),r.closePath(),r.fill(),r.globalCompositeOperation="destination-in";const o=r.createRadialGradient(32,51.2,0,32,51.2,35.2);o.addColorStop(0,"rgba(255,255,255,1)"),o.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=o,r.fillRect(0,0,t,t)}const n=new e.CanvasTexture(o);return n.wrapS=e.ClampToEdgeWrapping,n.wrapT=e.ClampToEdgeWrapping,n.magFilter=e.LinearFilter,n.minFilter=e.LinearMipmapLinearFilter,n.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,E=n,n}(e),o=new e.MeshStandardMaterial({color:1483594,roughness:.88,metalness:0,side:e.DoubleSide,alphaMap:t,alphaTest:.35});return o.stencilWrite=!0,o.stencilRef=1,o.stencilFunc=e.NotEqualStencilFunc,o.stencilFail=e.KeepStencilOp,o.stencilZFail=e.KeepStencilOp,o.stencilZPass=e.KeepStencilOp,o.stencilWriteMask=0,o.stencilFuncMask=255,o.onBeforeCompile=e=>{e.uniforms.uTime={value:0},e.vertexShader=e.vertexShader.replace("#include <common>","#include <common>\nuniform float uTime;\nattribute float instanceSeed;").replace("#include <begin_vertex>","#include <begin_vertex>\nfloat h01 = clamp(position.y, 0.0, 1.0);\nfloat wind = sin(uTime * 1.2 + instanceSeed + position.x * 2.4) * 0.12;\nfloat wind2 = cos(uTime * 0.9 + instanceSeed * 1.7) * 0.08;\ntransformed.x += (wind + wind2) * h01 * h01;\ntransformed.z += sin(uTime * 1.1 + instanceSeed * 0.7) * 0.06 * h01 * h01;"),o.userData.shader=e},l=o,o}();u.color.set(n);const d=new e.InstancedMesh(i,u,o);d.frustumCulled=!1,d.renderOrder=5;const p=function(e){const t=e.getAttribute("position"),o=e.getIndex(),r=[],n=[];let a=0;function i(e,o,i){const s=t.getX(e),l=t.getZ(e),c=t.getX(o),u=t.getZ(o),d=t.getX(i),p=t.getZ(i),m=.5*Math.abs((c-s)*(p-l)-(d-s)*(u-l));m>1e-9&&(a+=m,r.push({ax:s,az:l,bx:c,bz:u,cx:d,cz:p,area:m}),n.push(a))}if(o)for(let e=0;e<o.count;e+=3)i(o.getX(e),o.getX(e+1),o.getX(e+2));else for(let e=0;e<t.count;e+=3)i(e,e+1,e+2);return{triangles:r,cdf:n,totalArea:a}}(t);if(!(p.totalArea>1e-9)||0===p.triangles.length)return void i.dispose();const m=new e.Matrix4,h=new e.Quaternion,x=new e.Vector3,f=new e.Vector3,g=new e.Vector3(0,1,0);for(let e=0;e<o;e+=1){const t=Math.random()*p.totalArea;let o=0,r=p.cdf.length-1;for(;o<r;){const e=o+r>>1;t<=p.cdf[e]?r=e:o=e+1}const n=R(p.triangles[o]),a=Math.random()*Math.PI*2;h.setFromAxisAngle(g,a);const i=.1+.2*Math.random(),s=i*(.12+.1*Math.random());f.set(s,i,1),x.set(n.x,.012,n.z),m.compose(x,h,f),d.setMatrixAt(e,m),c.setX(e,1e3*Math.random())}d.instanceMatrix.needsUpdate=!0,c.needsUpdate=!0,s=d,r.add(d)}function d(o){const d=M(o.props.vertices),p=JSON.stringify(d.map(e=>({x:Math.round(1e3*(e.x-o.position.x))/1e3,z:Math.round(1e3*(e.z-o.position.z))/1e3})));if(p!==i){i=p;const t=function(t){const o=M(t.props.vertices);if(o.length<3)return null;const r=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),n=new e.Shape;n.moveTo(r[0].x,-r[0].z);for(let e=1;e<r.length;e++)n.lineTo(r[e].x,-r[e].z);n.closePath();const a=new e.ShapeGeometry(n);a.rotateX(-Math.PI/2);const i=a.getAttribute("position"),s=new e.BufferAttribute(new Float32Array(2*i.count),2);for(let e=0;e<i.count;e++){const o=i.getX(e)+t.position.x,r=i.getZ(e)+t.position.z;s.setXY(e,o,r)}return a.setAttribute("uv",s),a}(o);t?a?(a.geometry.dispose(),a.geometry=t):(a=new e.Mesh(t,n),a.receiveShadow=!0,r.add(a)):a&&(r.remove(a),a.geometry.dispose(),a=null)}const m=g(o.props.fill,h),x=Math.max(0,Math.min(1,f(o.props.opacity,1)))<.001,w=x?0:1,y=D(o.props.texture,"none"),_=t.graphicsQuality??"simplified",b=function(e,t,o="simplified"){return"none"===t?null:"grass"===t?"detailed"===o?P(e,"floor:grass:detailed",T,{size:512,anisotropy:8}):P(e,"floor:grass:simplified",N,{size:256,anisotropy:4}):"concrete"===t?P(e,"floor:concrete",j,{size:256,anisotropy:4}):null}(e,y,_);if(n.color.set(m),n.map!==b&&(n.map=b,n.needsUpdate=!0),n.roughness="grass"===y?.98:.95,n.metalness=0,n.opacity=w,n.transparent=x,n.depthWrite=!x,a&&(a.visible=!x,a.position.y=.01),x||"grass"!==y||"detailed"!==_||!Boolean(a&&a.geometry))return void(s&&(s.visible=!1));s&&(s.visible=!0);const v=function(e){if(e.length<3)return 0;let t=0;for(let o=0;o<e.length;o+=1){const r=e[o],n=e[(o+1)%e.length];t+=r.x*n.z-n.x*r.z}return Math.abs(t)/2}(d),k=Math.max(240,Math.min(1800,Math.floor(35*v))),z=`${p}:${k}`;z!==c&&a?(c=z,u(a.geometry,k,m)):l&&l.color.set(m)}return d(o),{object:r,update:d,tick:()=>{if(!l||!s?.visible)return!1;const e=l.userData.shader;return!!e&&(e.uniforms.uTime.value=performance.now()/1e3,!0)},dispose:()=>{a&&a.geometry.dispose(),n.dispose(),s&&s.geometry.dispose(),l?.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=M(t.props.vertices);if(r.length<3)return;const n=g(t.props.fill,h),a=f(t.props.opacity,1)<.001?0:1,s=r.map(e=>o.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(s[0].x,s[0].y);for(let t=1;t<s.length;t++)e.lineTo(s[t].x,s[t].y);e.closePath(),e.fillStyle=i(n,a),e.fill(),e.strokeStyle=i("#e6e8f2",.22),e.lineWidth=2,e.stroke(),e.restore()},renderEditorModal:({element:t,update:o,remove:n,close:a})=>(0,r.jsx)(I,{element:t,update:o,remove:n,close:a,i18n:e})}}function I({element:e,update:t,remove:o,close:n,i18n:a}){const{t:i}=a.useI18n(),s=g(e.props.fill,h),l=f(e.props.opacity,1)<.001,c=D(e.props.texture,"none");return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"field",children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.area_name")}),(0,r.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.area_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:s,onChange:e=>{const o=e.target.value;y(o),t({props:{fill:o}})}})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.floor_texture")}),(0,r.jsxs)("select",{className:"input",value:c,onChange:e=>{const o=D(e.target.value,c),r="grass"===o?"#16a34a":"concrete"===o?h:s;y(r),t({props:{texture:o,fill:r}})},children:[(0,r.jsx)("option",{value:"none",children:i("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"grass",children:i("ext.structural.editor.texture.grass")}),(0,r.jsx)("option",{value:"concrete",children:i("ext.structural.editor.texture.concrete")})]})]}),(0,r.jsxs)("label",{className:"chipButton",style:{display:"inline-flex",alignItems:"center",gap:10},children:[(0,r.jsx)("input",{type:"checkbox",checked:l,onChange:e=>t({props:{opacity:e.target.checked?0:1}})}),(0,r.jsx)("span",{children:i("ext.structural.editor.transparent")})]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:i("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:n,children:i("core.actions.close")})]})]})}let G=null,O=null;function $(e,t,o){return Math.max(t,Math.min(o,e))}function q(e){return{depth_m:$(f(e.depth_m,1.4),.1,20),vertices:M(e.vertices)}}function X(e){return{type:d,layerGroup:"areas",name:{key:"ext.structural.pool.name",fallback:"Pool"},description:{key:"ext.structural.pool.desc",fallback:"Swimming pool (hole) in 2D."},defaultProps:{depth_m:1.4,vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:e=>function(e){if(0===e.length)return null;let t=e[0].x,o=e[0].x,r=e[0].z,n=e[0].z;for(let a=1;a<e.length;a+=1){const i=e[a];t=Math.min(t,i.x),o=Math.max(o,i.x),r=Math.min(r,i.z),n=Math.max(n,i.z)}return{minX:t,maxX:o,minZ:r,maxZ:n}}(q(e.props).vertices),renderMain2DVector:({element:e})=>{const t=q(e.props);if(t.vertices.length<3)return null;const o=function(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}(t.vertices),n=$(t.depth_m/4.5,.16,.42);return(0,r.jsxs)("g",{className:"mainVector2dPool",children:[(0,r.jsx)("polygon",{points:o,fill:`rgba(8,47,73,${n})`,stroke:"rgba(125,211,252,0.60)",strokeWidth:.045,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),(0,r.jsx)("polygon",{points:o,fill:"url(#mainVector2dWaterGradient)",opacity:"0.86"}),(0,r.jsx)("polygon",{points:o,fill:"url(#mainVector2dWaterPattern)",opacity:"0.46"}),(0,r.jsx)("polygon",{points:o,fill:"none",stroke:"rgba(224,242,254,0.58)",strokeWidth:.016,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.BufferGeometry,a=new e.MeshBasicMaterial({color:0});a.colorWrite=!1,a.depthWrite=!1,a.depthTest=!1,a.stencilWrite=!0,a.stencilRef=1,a.stencilFunc=e.AlwaysStencilFunc,a.stencilZPass=e.ReplaceStencilOp;const i=function(e){if(G)return G;const t=function(e){const t=document.createElement("canvas");t.width=e,t.height=e;const o=t.getContext("2d");if(!o)return t;o.fillStyle="rgb(128,128,128)",o.fillRect(0,0,e,e),o.save(),o.globalAlpha=.14,o.fillStyle="rgb(150,150,150)";for(let t=0;t<220;t++){const t=Math.random()*e,r=Math.random()*e,n=6+26*Math.random();o.beginPath(),o.arc(t,r,n,0,2*Math.PI),o.fill()}o.globalAlpha=.1,o.fillStyle="rgb(100,100,100)";for(let t=0;t<160;t++){const t=Math.random()*e,r=Math.random()*e,n=4+20*Math.random();o.beginPath(),o.arc(t,r,n,0,2*Math.PI),o.fill()}return o.restore(),t}(256),o=new e.CanvasTexture(t);return o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.repeat.set(2,2),o.anisotropy=4,o.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,G=o,o}(e),s=function(e){if(O)return O;const t=function(e){const t=document.createElement("canvas");t.width=e,t.height=e;const o=t.getContext("2d");if(!o)return t;const r=o.createImageData(e,e),n=r.data,a=2*Math.PI,i=[{dirX:.92,dirY:.39,freq:3,amp:.7,phase:Math.random()*a},{dirX:-.16,dirY:.99,freq:5,amp:.5,phase:Math.random()*a},{dirX:.68,dirY:-.73,freq:8,amp:.35,phase:Math.random()*a},{dirX:-.91,dirY:-.41,freq:12,amp:.22,phase:Math.random()*a}];for(let t=0;t<e;t+=1){const o=t/e;for(let r=0;r<e;r+=1){const s=r/e;let l=0,c=0;for(const e of i){const t=a*(e.dirX*s+e.dirY*o)*e.freq+e.phase,r=Math.cos(t),n=e.amp*e.freq*a;l+=r*n*e.dirX,c+=r*n*e.dirY}let u=.085*-l,d=1,p=.085*-c;const m=1/Math.sqrt(u*u+d*d+p*p);u*=m,d*=m,p*=m;const h=4*(t*e+r);n[h+0]=Math.round(255*(.5*u+.5)),n[h+1]=Math.round(255*(.5*d+.5)),n[h+2]=Math.round(255*(.5*p+.5)),n[h+3]=255}}return o.putImageData(r,0,0),t}(256),o=new e.CanvasTexture(t);return o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.repeat.set(2,2),o.anisotropy=8,o.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,O=o,o}(e),l=new e.MeshStandardMaterial({color:959977,roughness:.18,metalness:.02,transparent:!0,opacity:.68,side:e.DoubleSide,depthWrite:!1,emissive:new e.Color(402490),emissiveIntensity:.1});l.bumpMap=i,l.bumpScale=0;const c=new e.MeshPhysicalMaterial({color:959977,roughness:.12,metalness:0,transmission:.92,thickness:.18,ior:1.33,transparent:!0,opacity:1,side:e.DoubleSide,depthWrite:!1,clearcoat:.62,clearcoatRoughness:.08});c.normalMap=s,c.normalScale=new e.Vector2(.55,.55),c.attenuationColor=new e.Color(402490),c.attenuationDistance=.8;const u=new e.MeshStandardMaterial({color:988970,roughness:.95,metalness:.02,side:e.DoubleSide}),d=new e.MeshStandardMaterial({color:728888,roughness:.98,metalness:0,side:e.DoubleSide}),p=new e.Mesh(n,a);p.renderOrder=-20;const m=new e.Mesh(n,l);m.renderOrder=10;const h=new e.Mesh(n,u),x=new e.Mesh(n,d);r.add(p),r.add(h),r.add(x),r.add(m);let f=null,g=null,w="";function y(o){const r=q(o.props),a="detailed"===(t.graphicsQuality??"simplified"),i=JSON.stringify({v:r.vertices.map(e=>({x:Math.round(1e3*(e.x-o.position.x))/1e3,z:Math.round(1e3*(e.z-o.position.z))/1e3})),d:Math.round(1e3*r.depth_m)/1e3});if(i!==w){w=i;const t=function(e,t,o){if(o.length<3)return null;const r=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),n=new e.Shape;n.moveTo(r[0].x,-r[0].z);for(let e=1;e<r.length;e++)n.lineTo(r[e].x,-r[e].z);n.closePath();const a=new e.ShapeGeometry(n);return a.rotateX(-Math.PI/2),a}(e,o,r.vertices),a=function(e,t,o,r){if(o.length<2)return null;const n=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),a=-Math.abs(r),i=n.length,s=new Float32Array(4*i*3),l=[];for(let e=0;e<i;e++){const t=n[e],o=n[(e+1)%i],r=4*e;s[3*(r+0)+0]=t.x,s[3*(r+0)+1]=0,s[3*(r+0)+2]=t.z,s[3*(r+1)+0]=o.x,s[3*(r+1)+1]=0,s[3*(r+1)+2]=o.z,s[3*(r+2)+0]=o.x,s[3*(r+2)+1]=a,s[3*(r+2)+2]=o.z,s[3*(r+3)+0]=t.x,s[3*(r+3)+1]=a,s[3*(r+3)+2]=t.z,l.push(r+0,r+1,r+2,r+0,r+2,r+3)}const c=new e.BufferGeometry;return c.setAttribute("position",new e.BufferAttribute(s,3)),c.setIndex(l),c.computeVertexNormals(),c}(e,o,r.vertices,r.depth_m);f&&f.dispose(),g&&g.dispose(),f=t,g=a,p.geometry=f??n,m.geometry=f??n,x.geometry=f??n,h.geometry=g??n}const s=Boolean(f&&g);if(p.visible=s,m.visible=s,x.visible=s,h.visible=s,!s)return;p.position.y=.01,h.position.y=0,x.position.y=0-r.depth_m;const u=Math.min(.06,Math.max(.02,.3*r.depth_m));m.position.y=0-u,m.material=a?c:l,a?(c.roughness=.1,c.transmission=.92,c.clearcoat=.65,c.clearcoatRoughness=.08,c.attenuationDistance=.8+.35*$(r.depth_m,.2,2.5)):(l.roughness=.22,l.opacity=.66,l.emissiveIntensity=.06,l.bumpScale=0)}return y(o),{object:r,update:y,tick:e=>{if("detailed"!==(t.graphicsQuality??"simplified")||!m.visible)return!1;const o=performance.now(),r=s.userData??={};return o-("number"==typeof r.lastOffsetUpdateMs?r.lastOffsetUpdateMs:0)<4||(r.lastOffsetUpdateMs=o,s.offset.x=(s.offset.x+.022*e)%1,s.offset.y=(s.offset.y+.022*e*.7)%1),!0},dispose:()=>{f&&f.dispose(),g&&g.dispose(),n.dispose(),a.dispose(),u.dispose(),d.dispose(),l.dispose(),c.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=q(t.props);if(r.vertices.length<3)return;const n=r.vertices.map(e=>o.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#0ea5e9",.14),e.fill(),e.strokeStyle=i("#38bdf8",.65),e.lineWidth=2,e.stroke(),e.restore()},renderEditorModal:({element:t,update:o,remove:n,close:a})=>(0,r.jsx)(K,{element:t,update:o,remove:n,close:a,i18n:e})}}function K({element:e,update:t,remove:o,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=q(e.props),u=(0,n.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s("ext.structural.pool.name")}),(0,r.jsxs)("div",{className:"cardMeta",children:[u.format(c.depth_m)," m"]})]}),(0,r.jsx)("div",{className:"cardBody",children:s("ext.structural.pool.desc")})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"field",children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_name")}),(0,r.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,r.jsx)("div",{className:"rowWrap",children:(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_depth")}),(0,r.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:.1,max:20,step:.1,value:c.depth_m,onChange:e=>{const o=Number.parseFloat(e.target.value);Number.isFinite(o)&&t({props:{depth_m:$(o,.1,20)}})}})]})}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:s("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}function L(e,t){const o=e.x-t.x,r=e.z-t.z;return Math.hypot(o,r)}function V(e,t){return{x:e.x+t.x,z:e.z+t.z}}function Z(e,t){return{x:e.x-t.x,z:e.z-t.z}}function U(e,t){return{x:e.x*t,z:e.z*t}}function Y(e){const t=Math.hypot(e.x,e.z);return t<=1e-9?{x:1,z:0}:{x:e.x/t,z:e.z/t}}function H(e){return{x:-e.z,z:e.x}}function J(e){if(0===e.length)return{x:0,z:0};const t=e.reduce((e,t)=>({x:e.x+t.x,z:e.z+t.z}),{x:0,z:0});return{x:t.x/e.length,z:t.z/e.length}}const Q=.25,ee=/^#[0-9a-fA-F]{6}$/;function te(e,t,o){return Math.max(t,Math.min(o,e))}function oe(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function re(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function ne(e){if("string"!=typeof e)return;const t=e.trim();return t.length>0?t:void 0}function ae(e){return"door"===e?.9:"window"===e?1.2:1}function ie(e){return"door"===e?"#8f806a":"window"===e?"#b9d8f4":void 0}function se(e){return"door"===e?"wood":"window"===e?"glass":"none"}function le(){const e=crypto;return e.randomUUID?.()??`opening-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ce(e){if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,o=function(e){return"opening"===e||"door"===e||"window"===e}(t.kind)?t.kind:"opening",r=Math.max(Q,oe(t.width_m,ae(o))),n=ne(t.color),a=ne(t.texture);return{id:ne(t.id)??le(),kind:o,center_m:oe(t.center_m,0),width_m:r,y_min_m:re(t.y_min_m),y_max_m:re(t.y_max_m),color:n&&ee.test(n)?n:void 0,texture:a}}function ue(e){if(!Array.isArray(e))return[];const t=[],o=new Set;for(const r of e){const e=ce(r);if(e){for(;o.has(e.id);)e.id=le();o.add(e.id),t.push(e)}}return t}function de(e,t){const o=Math.max(.15,t);if("opening"===e)return{yMin:0,yMax:o};if("door"===e)return{yMin:0,yMax:Math.min(o,2.1)};const r=Math.min(.9,Math.max(0,o-.3));return{yMin:r,yMax:Math.min(o,Math.max(r+.25,2))}}function pe(e){const t=Math.max(Q,e.width_m);return{id:le(),kind:e.kind,center_m:e.center_m,width_m:t,color:ie(e.kind),texture:se(e.kind)}}function me(e,t,o){const r=Math.max(.001,t),n=Math.max(.15,o),a=[];for(const t of e){const e=Math.min(Q,r),o=te(Number.isFinite(t.width_m)?t.width_m:ae(t.kind),e,r),i=te(Number.isFinite(t.center_m)?t.center_m:r/2,o/2,r-o/2),s=i-o/2,l=i+o/2;if(l-s<e-1e-6)continue;const c=de(t.kind,n);let u,d;if("opening"===t.kind?(u=0,d=n):(u=Number.isFinite(t.y_min_m??NaN)?t.y_min_m:c.yMin,d=Number.isFinite(t.y_max_m??NaN)?t.y_max_m:c.yMax),u=te(u,0,n),d=te(d,0,n),d<u){const e=d;d=u,u=e}d-u<.08||a.push({id:t.id,kind:t.kind,center_m:i,width_m:o,start_m:s,end_m:l,y_min_m:u,y_max_m:d,color:t.color,texture:t.texture})}return a.sort((e,t)=>e.start_m-t.start_m||e.id.localeCompare(t.id)),a}function he(e){return e.map(e=>{const t={id:e.id,kind:e.kind,center_m:e.center_m,width_m:e.width_m};return"number"==typeof e.y_min_m&&Number.isFinite(e.y_min_m)&&(t.y_min_m=e.y_min_m),"number"==typeof e.y_max_m&&Number.isFinite(e.y_max_m)&&(t.y_max_m=e.y_max_m),e.color&&(t.color=e.color),e.texture&&(t.texture=e.texture),t})}function xe(e,t,o){return Math.max(t,Math.min(o,e))}function fe(e){return Math.round(1e3*e)/1e3}function ge(e,t){const o=function(e,t,o){const r=e.map(e=>({start:xe(Math.min(e.start,e.end),0,o),end:xe(Math.max(e.start,e.end),0,o)})).filter(e=>e.end-e.start>1e-6).sort((e,t)=>e.start-t.start),n=[];for(const e of r){const t=n[n.length-1];!t||e.start>t.end+1e-6?n.push(e):t.end=Math.max(t.end,e.end)}return n}(t,0,e),r=[];let n=0;for(const e of o)e.start>n+1e-6&&r.push({start:n,end:e.start}),n=Math.max(n,e.end);return n<e-1e-6&&r.push({start:n,end:e}),r}function we(e,t,o){return V(e,U(t,o))}function ye(e){const t=_(e.props.a,{x:e.position.x,z:e.position.z}),o=_(e.props.b,{x:e.position.x+1,z:e.position.z}),r=Math.max(.04,f(e.props.width,m));return{minX:Math.min(t.x,o.x)-r,maxX:Math.max(t.x,o.x)+r,minZ:Math.min(t.z,o.z)-r,maxZ:Math.max(t.z,o.z)+r}}function _e(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}function Me(e,t){if(Array.isArray(e))for(const o of e)t.has(o)||(t.add(o),o.dispose());else t.has(e)||(t.add(e),e.dispose())}function be(e,t){const o=e.getAttribute("position"),r=e.getAttribute("normal"),n=e.getAttribute("uv");if(!o||!r||!n)return;const a=t.thicknessWorld/2;for(let e=0;e<n.count;e+=1){const i=r.getX(e),s=(r.getY(e),r.getZ(e)),l=o.getX(e),c=o.getY(e),u=o.getZ(e);let d=0,p=0;Math.abs(s)>=.5?(d=l+t.originX,p=c+t.originY):Math.abs(i)>=.5?(d=u+t.originZ+a,p=c+t.originY):(d=l+t.originX,p=u+t.originZ+a),n.setXY(e,d,p)}n.needsUpdate=!0}function ve(e,t){const o=new Set;for(const r of[...e.children]){const n=r;n.geometry&&"dispose"in n.geometry&&n.geometry.dispose(),t&&n.material&&Me(n.material,o),e.remove(r)}}function ke(e){return"door"===e?{fill:"rgba(251,146,60,0.20)",stroke:"rgba(251,146,60,0.92)",dash:[7,4]}:"window"===e?{fill:"rgba(56,189,248,0.18)",stroke:"rgba(56,189,248,0.92)",dash:[5,4]}:{fill:"rgba(251,191,36,0.12)",stroke:"rgba(251,191,36,0.92)",dash:[9,5]}}function ze(e,t,o,r){const n=o.y_max_m-o.y_min_m;if(o.width_m<=.12||n<=.12)return;const a=xe(.11*Math.min(o.width_m,n),.03,.09),i=.48*r,s=.34*r,l=F(e,A(o.texture,se("door"))),c=new e.MeshStandardMaterial({color:"#5b5044",roughness:.82,metalness:.05,map:l}),u=new e.MeshStandardMaterial({color:o.color??ie("door")??"#8f806a",roughness:.74,metalness:.08,map:l}),d=new e.BoxGeometry(a,n,i),p=new e.BoxGeometry(a,n,i),m=new e.BoxGeometry(o.width_m,a,i),h=new e.Mesh(d,c),x=new e.Mesh(p,c),f=new e.Mesh(m,c);for(const e of[h,x,f])e.userData.__toposyncAllowPickWhenGhostWalls=!0;const g=0+o.y_min_m+n/2;h.position.set(o.start_m+a/2,g,0),x.position.set(o.end_m-a/2,g,0),f.position.set(o.center_m,0+o.y_max_m-a/2,0);const w=xe(.02*a,.001,.004),y=o.width_m-2*a-2*w,_=n-a-w;if(y>.08&&_>.2){const r=new e.BoxGeometry(y,_,s),n=new e.Mesh(r,u);n.userData.__toposyncAllowPickWhenGhostWalls=!0,n.position.set(o.center_m,0+o.y_min_m+_/2,0),n.castShadow=!0,n.receiveShadow=!0,t.add(n)}else u.dispose();for(const e of[h,x,f])e.castShadow=!0,e.receiveShadow=!0,t.add(e)}function Se(e,t,o,r){const n=o.y_max_m-o.y_min_m;if(o.width_m<=.12||n<=.12)return;const a=xe(.09*Math.min(o.width_m,n),.025,.07),i=.35*r,s=.14*r,l=A(o.texture,se("window")),c=F(e,l),u=new e.MeshStandardMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.55,metalness:.18,map:c}),d=new e.BoxGeometry(o.width_m,a,i),p=new e.BoxGeometry(o.width_m,a,i),m=new e.BoxGeometry(a,n,i),h=new e.BoxGeometry(a,n,i),x=new e.Mesh(d,u),f=new e.Mesh(p,u),g=new e.Mesh(m,u),w=new e.Mesh(h,u);for(const e of[x,f,g,w])e.userData.__toposyncAllowPickWhenGhostWalls=!0;const y=0+o.y_min_m+n/2;x.position.set(o.center_m,0+o.y_max_m-a/2,0),f.position.set(o.center_m,0+o.y_min_m+a/2,0),g.position.set(o.start_m+a/2,y,0),w.position.set(o.end_m-a/2,y,0);for(const e of[x,f,g,w])e.castShadow=!0,e.receiveShadow=!0,t.add(e);const _=o.width_m-2.2*a,M=n-2.2*a;if(_<=.08||M<=.08)return;const b=new e.BoxGeometry(_,M,s);let v;v="glass"===l?new e.MeshPhysicalMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.1,metalness:0,transmission:.88,thickness:.05,transparent:!0,opacity:.55}):new e.MeshStandardMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.42,metalness:.12,map:c});const k=new e.Mesh(b,v);k.userData.__toposyncAllowPickWhenGhostWalls=!0,k.position.set(o.center_m,y,0),k.castShadow=!1,k.receiveShadow=!0,t.add(k)}function je({element:e,update:t,remove:o,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=g(e.props.color,p),u=C(e.props.texture,"none"),d=(0,n.useMemo)(()=>ue(e.props.openings),[e.props.openings]),m=(0,n.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]),h=(0,n.useMemo)(()=>L(_(e.props.a,{x:e.position.x,z:e.position.z}),_(e.props.b,{x:e.position.x+1,z:e.position.z})),[e]),x=(0,n.useMemo)(()=>[...d].sort((e,t)=>e.center_m-t.center_m||e.id.localeCompare(t.id)),[d]),f=(0,n.useMemo)(()=>{const e=me(d,h,3.2),t=new Map;for(const o of e)t.set(o.id,o);return t},[d,h]);function w(e){t({props:{openings:he(e)}})}function y(e,t){w(d.map(o=>o.id===e?{...o,...t}:o))}function M(e){const t="door"===e?.9:"window"===e?1.2:1,o=Math.max(0,h),r=xe(t,Math.min(Q,o),o),n=pe({kind:e,center_m:h/2,width_m:r});w([...d,n])}return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s("ext.structural.wall.name")}),(0,r.jsxs)("div",{className:"cardMeta",children:[m.format(h)," m"]})]}),(0,r.jsxs)("div",{className:"cardBody",children:[s("ext.structural.editor.preview")," • ",x.length," ",s("ext.structural.editor.openings")]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:c,onChange:e=>t({props:{color:e.target.value}})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_texture")}),(0,r.jsxs)("select",{className:"input",value:u,onChange:e=>t({props:{texture:C(e.target.value,u)}}),children:[(0,r.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"brick",children:s("ext.structural.editor.texture.brick")}),(0,r.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")})]})]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",style:{alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.openings")}),(0,r.jsxs)("div",{className:"rowWrap",style:{gap:8},children:[(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("opening"),children:["+ ",s("ext.structural.tools.wall_opening")]}),(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("door"),children:["+ ",s("ext.structural.tools.wall_door")]}),(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("window"),children:["+ ",s("ext.structural.tools.wall_window")]})]})]}),0===x.length?(0,r.jsx)("div",{className:"cardBody",children:s("ext.structural.editor.openings_empty")}):null,x.map(e=>{const t=e.kind,o=A(e.texture,se(t)),n=e.color??ie(t)??"#8f806a",a=f.get(e.id)??null,i="opening"===t?s("ext.structural.editor.opening_height_full"):a?s("ext.structural.editor.opening_height_range",{yMin:m.format(a.y_min_m),yMax:m.format(a.y_max_m)}):null,l=Math.max(0,h),c=Math.min(Q,l),u=xe(e.width_m,c,Math.max(c,l)),p=u/2,x=Math.max(p,l-u/2),g=xe(e.center_m,p,x);return(0,r.jsxs)("div",{className:"card",style:{marginTop:10},children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s(`ext.structural.editor.kind.${t}`)}),(0,r.jsxs)("div",{className:"cardMeta",children:[m.format(u)," m"]})]}),i?(0,r.jsx)("div",{className:"cardMeta",style:{marginTop:6},children:i}):null,(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_kind")}),(0,r.jsxs)("select",{className:"input",value:t,onChange:o=>{const r="opening"===(n=o.target.value)||"door"===n||"window"===n?n:t;var n;const a={kind:r};!e.color&&ie(r)&&(a.color=ie(r)),e.texture&&e.texture!==se(t)||(a.texture=se(r)),y(e.id,a)},children:[(0,r.jsx)("option",{value:"opening",children:s("ext.structural.editor.kind.opening")}),(0,r.jsx)("option",{value:"door",children:s("ext.structural.editor.kind.door")}),(0,r.jsx)("option",{value:"window",children:s("ext.structural.editor.kind.window")})]})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_center")}),(0,r.jsx)("input",{className:"input",type:"number",step:.05,value:g,onChange:t=>{const o=Number(t.target.value);Number.isFinite(o)&&y(e.id,{center_m:xe(o,p,x)})}}),(0,r.jsx)("div",{className:"cardMeta",children:s("ext.structural.editor.opening_center_hint",{start:m.format(0),end:m.format(h)})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_width")}),(0,r.jsx)("input",{className:"input",type:"number",step:.05,min:c,max:Math.max(c,l),value:u,onChange:t=>{const o=Number(t.target.value);if(!Number.isFinite(o))return;const r=xe(o,c,Math.max(c,l)),n=r/2,a=Math.max(n,l-r/2);y(e.id,{width_m:r,center_m:xe(e.center_m,n,a)})}})]})]}),"opening"!==t?(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:n,onChange:t=>y(e.id,{color:t.target.value})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_texture")}),(0,r.jsxs)("select",{className:"input",value:o,onChange:t=>y(e.id,{texture:A(t.target.value,o)}),children:[(0,r.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"wood",children:s("ext.structural.editor.texture.wood")}),(0,r.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")}),(0,r.jsx)("option",{value:"glass",children:s("ext.structural.editor.texture.glass")})]})]})]}):null,(0,r.jsx)("div",{className:"rowWrap",children:(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:()=>{return t=e.id,void w(d.filter(e=>e.id!==t));var t},children:s("core.actions.delete")})})]},e.id)}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:s("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}const Ne={id:"structure",name:{key:"core.ui.tools.group.structure",fallback:"Structure"},order:20},Te={id:"areas",name:{key:"core.ui.tools.group.areas",fallback:"Areas"},order:30};function We(e,t,o){const r={x:(t.x+o.x)/2,z:(t.z+o.z)/2};return e.createElement(c,{name:"",position:{x:r.x,y:0,z:r.z},props:{a:t,b:o,color:p,width:m,openings:[]}})}function Pe(e,t){const o=J(t),r=function(){try{const e=localStorage.getItem(x);if(e&&w(e))return e}catch{}return h}();return e.createElement(u,{name:"",position:{x:o.x,y:0,z:o.z},props:{vertices:t,fill:r,opacity:1}})}function Ce(e,t){const o=J(t);return e.createElement(d,{name:"",position:{x:o.x,y:0,z:o.z},props:{vertices:t,depth_m:1.4}})}function De(e,t){const o=t.length;if(!(o<2))for(let r=0;r<o;r++)We(e,t[r],t[(r+1)%o])}function Ae(e,t,o){return Math.max(t,Math.min(o,e))}function Fe(e,t){return{x:e.x+t.x,z:e.z+t.z}}function Ee(e,t){return{x:e.x*t,z:e.z*t}}function Re(e,t,o,r){const n=function(e,t){return e.x*t.x+e.z*t.z}(function(e,t){return{x:e.x-t.x,z:e.z-t.z}}(e,t),o),a=Math.max(0,Math.min(r,n));return{point:Fe(t,Ee(o,a)),scalar:a}}function Be(e,t,o){const r=L(t,o);return L(e,r<=1e-6?t:Re(e,t,{x:(o.x-t.x)/r,z:(o.z-t.z)/r},r).point)}function Ie(e,t){const o="door"===(r=t.kind)?{stroke:i("#fb923c",.92),fill:i("#fb923c",.22),dash:[8,6],labelKey:"ext.structural.tools.wall_door",fallback:"Door",descriptionKey:"ext.structural.tools.wall_door_desc",descriptionFallback:"Place a door cutout on a wall.",icon:"door-open",order:20}:"window"===r?{stroke:i("#38bdf8",.92),fill:i("#38bdf8",.22),dash:[5,5],labelKey:"ext.structural.tools.wall_window",fallback:"Window",descriptionKey:"ext.structural.tools.wall_window_desc",descriptionFallback:"Place a window cutout on a wall.",icon:"window-maximize",order:30}:{stroke:i("#fbbf24",.92),fill:i("#fbbf24",.22),dash:[9,4],labelKey:"ext.structural.tools.wall_opening",fallback:"Opening",descriptionKey:"ext.structural.tools.wall_opening_desc",descriptionFallback:"Hover a wall, click and drag to size. Click to place default width.",icon:"crop-simple",order:40};var r;return{id:"door"===t.kind?"com.toposync.structural.tool.door":"window"===t.kind?"com.toposync.structural.tool.window":"com.toposync.structural.tool.opening",name:{key:o.labelKey,fallback:o.fallback},description:{key:o.descriptionKey,fallback:o.descriptionFallback},icon:o.icon,group:Ne,order:o.order,createSession:e=>{let r=null,n=null,a=null,i=null,s=null,l=!1;function u(){a=null,i=null,s=null,l=!1}function d(e,o,r,n){const a=Math.min(Math.max(Q,.2),e),i=Math.abs(r-o);let s=i,l=(o+r)/2;return n?(s=2*i,l=o):i<.04&&(s=Math.min(e,Math.max(a,function(e){return"door"===e?.9:"window"===e?1.2:1}(t.kind))),l=o),s=Ae(s,a,e),l=Ae(l,s/2,e-s/2),{start:l-s/2,end:l+s/2,center:l,width:s}}function p(t){if(a)return;const o=function(e){const t=[];for(const o of e.getElements()){if(o.type!==c)continue;const e=_(o.props.a,{x:o.position.x-.5,z:o.position.z}),r=_(o.props.b,{x:o.position.x+.5,z:o.position.z}),n=L(e,r);if(n<=1e-6)continue;const a={x:(r.x-e.x)/n,z:(r.z-e.z)/n},i={x:-a.z,z:a.x};t.push({id:o.id,a:e,b:r,dir:a,normal:i,length:n,width:Math.max(.04,f(o.props.width,m)),props:o.props})}return t}(e),i=function(e,t){let o=null,r=Number.POSITIVE_INFINITY;for(const n of e){const e=Be(t,n.a,n.b);e>Math.max(.45,3.5*n.width)||e<r&&(r=e,o=n)}return o}(o,t);r=i,n=i?Re(t,i.a,i.dir,i.length).scalar:null}function h(e,t,o){const r=t.worldToScreen(o.a),n=t.worldToScreen(o.b);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,n.y),e.strokeStyle="rgba(255,255,255,0.55)",e.lineWidth=2.25,e.setLineDash([6,6]),e.stroke()}function x(e,t,r,n,a,i){const s=d(r.length,n,a,i),l=Fe(r.a,Ee(r.dir,s.start)),c=Fe(r.a,Ee(r.dir,s.end)),u=Math.max(.09,r.width/2),p=[Fe(l,Ee(r.normal,u)),Fe(c,Ee(r.normal,u)),Fe(c,Ee(r.normal,-u)),Fe(l,Ee(r.normal,-u))].map(e=>t.worldToScreen(e));e.beginPath(),e.moveTo(p[0].x,p[0].y);for(let t=1;t<p.length;t++)e.lineTo(p[t].x,p[t].y);e.closePath(),e.fillStyle=o.fill,e.fill(),e.strokeStyle=o.stroke,e.lineWidth=2,e.setLineDash(o.dash),e.stroke(),e.setLineDash([]);const m=t.worldToScreen(Fe(r.a,Ee(r.dir,s.center))),h=`${s.width.toFixed(2)} m`;e.font="12px ui-sans-serif, system-ui";const x=e.measureText(h).width+16,f=m.x-x/2,g=m.y-Math.max(28,24+12/Math.max(1,t.scale));e.fillStyle="rgba(8,12,26,0.86)",e.fillRect(f,g,x,20),e.strokeStyle="rgba(255,255,255,0.18)",e.lineWidth=1,e.strokeRect(f+.5,g+.5,x-1,19),e.fillStyle="rgba(230,232,242,0.95)",e.textAlign="center",e.textBaseline="middle",e.fillText(h,m.x,g+10)}return{onPointerEvent:o=>{if("cancel"!==o.kind){if("move"===o.kind)return a?(l=o.shiftKey,void(s=Re(o.world,a.a,a.dir,a.length).scalar)):void p(o.world);if("down"===o.kind){if(0!==o.button)return;return p(o.world),r&&null!=n?(a=r,i=n,s=n,void(l=o.shiftKey)):void u()}if("up"===o.kind){if(0!==o.button)return;if(!a||null==i)return;l=o.shiftKey,s=Re(o.world,a.a,a.dir,a.length).scalar,function(){if(!a||null==i||null==s)return;const o=d(a.length,i,s,l),r=e.getElements().find(e=>e.id===a?.id),n=ue(r?.props.openings??a.props.openings),c=pe({kind:t.kind,center_m:o.center,width_m:o.width});e.updateElement(a.id,{props:{openings:he([...n,c])}}),e.openEditor(a.id)}(),u(),p(o.world)}}else u()},onKeyDown:e=>{"Escape"===e.key&&u()},renderOverlay2D:({ctx:e,viewport:t})=>{e.save(),a&&null!=i&&null!=s?(h(e,t,a),x(e,t,a,i,s,l)):r&&null!=n&&(h(e,t,r),x(e,t,r,n,n,!1)),e.restore()},getCursor:()=>r?"copy":"crosshair"}}}}function Ge(e,t){return{id:t.withWalls?"com.toposync.structural.tool.area_square_walls":"com.toposync.structural.tool.area_square",name:{key:t.withWalls?"ext.structural.tools.area_square_walls":"ext.structural.tools.area_square",fallback:t.withWalls?"Rectangular room":"Rectangular area"},icon:t.withWalls?"border-all":"vector-square",group:Te,order:t.withWalls?10:30,createSession:e=>{let o=null,r=null;function n(){o=null,r=null}return{onPointerEvent:a=>{if("cancel"!==a.kind)if("move"!==a.kind){if("down"===a.kind&&0===a.button)return o?void function(r){if(!o)return;const a=function(e,t){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.z,t.z),a=Math.max(e.z,t.z);return[{x:o,z:n},{x:r,z:n},{x:r,z:a},{x:o,z:a}]}(o,r);if(L(a[0],a[2])<.12)return void n();const i=Pe(e,a);t.withWalls&&De(e,a),i&&e.openEditor(i),n()}(a.world):(o=a.world,void(r=a.world))}else o&&(r=a.world);else n()},onKeyDown:e=>{"Escape"===e.key&&n()},renderOverlay2D:({ctx:e,viewport:t})=>{if(!o||!r)return;const n=[o,{x:r.x,z:o.z},r,{x:o.x,z:r.z}].map(e=>t.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#fbbf24",.12),e.fill(),e.strokeStyle=i("#fbbf24",.8),e.lineWidth=2,e.setLineDash([6,6]),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}}}function Oe(e){return{id:"com.toposync.structural.tool.pool_square",name:{key:"ext.structural.tools.pool_square",fallback:"Rectangular pool"},icon:"water-ladder",group:Te,order:50,createSession:e=>{let t=null,o=null;function r(){t=null,o=null}return{onPointerEvent:n=>{if("cancel"!==n.kind)if("move"!==n.kind){if("down"===n.kind&&0===n.button)return t?void function(o){if(!t)return;const n=function(e,t){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.z,t.z),a=Math.max(e.z,t.z);return[{x:o,z:n},{x:r,z:n},{x:r,z:a},{x:o,z:a}]}(t,o);if(L(n[0],n[2])<.12)return void r();const a=Ce(e,n);a&&e.openEditor(a),r()}(n.world):(t=n.world,void(o=n.world))}else t&&(o=n.world);else r()},onKeyDown:e=>{"Escape"===e.key&&r()},renderOverlay2D:({ctx:e,viewport:r})=>{if(!t||!o)return;const n=[t,{x:o.x,z:t.z},o,{x:t.x,z:o.z}].map(e=>r.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#0ea5e9",.12),e.fill(),e.strokeStyle=i("#38bdf8",.8),e.lineWidth=2,e.setLineDash([6,6]),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}}}function $e(e,t){return{id:t.withWalls?"com.toposync.structural.tool.area_polygon_walls":"com.toposync.structural.tool.area_polygon",name:{key:t.withWalls?"ext.structural.tools.area_polygon_walls":"ext.structural.tools.area_polygon",fallback:t.withWalls?"Freeform room":"Freeform area"},icon:t.withWalls?"object-group":"draw-polygon",group:Te,order:t.withWalls?20:40,createSession:e=>{const o=[];let r=null;function n(){o.splice(0,o.length),r=null}function a(){if(o.length<3)return void n();const r=Pe(e,[...o]);t.withWalls&&De(e,o),r&&e.openEditor(r),n()}return{onPointerEvent:e=>{"cancel"!==e.kind?"move"!==e.kind?"dblclick"!==e.kind?"down"===e.kind&&0===e.button&&(function(e){if(o.length<3)return!1;const t=o[0];return L(e.world,t)<.22}(e)?a():(o.push(e.world),r=e.world)):a():r=e.world:n()},onKeyDown:e=>{"Escape"===e.key&&n(),"Enter"===e.key&&a(),("Backspace"===e.key||"Delete"===e.key)&&o.length>0&&o.pop()},renderOverlay2D:({ctx:e,viewport:t})=>{if(0===o.length)return;const n=o.map(e=>t.worldToScreen(e)),a=r?t.worldToScreen(r):null;if(e.save(),o.length>=2){e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);a&&e.lineTo(a.x,a.y),e.strokeStyle=i("#fbbf24",.85),e.lineWidth=2,e.setLineDash([6,6]),e.stroke()}for(let t=0;t<n.length;t++){const r=n[t],a=0===t&&o.length>=3;e.beginPath(),e.arc(r.x,r.y,a?6:5,0,2*Math.PI),e.fillStyle=i(a?"#22c55e":"#fbbf24",.85),e.fill(),e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=2,e.stroke()}e.restore()},getCursor:()=>"crosshair"}}}}const qe={en:{"ext.structural.wall.name":"Wall","ext.structural.wall.desc":"Simple wall (line) in 2D.","ext.structural.area.name":"Area","ext.structural.area.desc":"Area (polygon) in 2D.","ext.structural.pool.name":"Pool","ext.structural.pool.desc":"Swimming pool (hole) in 2D.","ext.structural.tools.wall":"Wall","ext.structural.tools.wall_opening":"Opening","ext.structural.tools.wall_opening_desc":"Floor-to-ceiling wall cutout. Hover a wall, click and drag to size. Click to place default width. Hold Shift for symmetric sizing.","ext.structural.tools.wall_door":"Door","ext.structural.tools.wall_door_desc":"Place a door cutout on a wall.","ext.structural.tools.wall_window":"Window","ext.structural.tools.wall_window_desc":"Place a window cutout on a wall.","ext.structural.tools.area_square":"Rectangular area","ext.structural.tools.area_polygon":"Freeform area","ext.structural.tools.area_square_walls":"Rectangular room","ext.structural.tools.area_polygon_walls":"Freeform room","ext.structural.tools.pool_square":"Rectangular pool","ext.structural.tools.pool_polygon":"Freeform pool","ext.structural.editor.wall_color":"Wall color","ext.structural.editor.wall_texture":"Wall texture","ext.structural.editor.openings":"Openings","ext.structural.editor.openings_empty":"No openings yet. Use tools or add one here.","ext.structural.editor.opening_kind":"Type","ext.structural.editor.opening_center":"Position (m)","ext.structural.editor.opening_center_hint":"Along the wall: {{start}} m = start (1st point), {{end}} m = end (2nd point).","ext.structural.editor.opening_width":"Width (m)","ext.structural.editor.opening_height_full":"Height: floor to ceiling.","ext.structural.editor.opening_height_range":"Height: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Color","ext.structural.editor.opening_texture":"Texture","ext.structural.editor.kind.opening":"Opening","ext.structural.editor.kind.door":"Door","ext.structural.editor.kind.window":"Window","ext.structural.editor.area_name":"Area name (optional)","ext.structural.editor.area_color":"Area color","ext.structural.editor.floor_texture":"Floor texture","ext.structural.editor.transparent":"Transparent","ext.structural.editor.texture.none":"None","ext.structural.editor.texture.brick":"Brick","ext.structural.editor.texture.concrete":"Concrete","ext.structural.editor.texture.wood":"Wood","ext.structural.editor.texture.glass":"Glass","ext.structural.editor.texture.grass":"Grass","ext.structural.editor.pool_name":"Pool name (optional)","ext.structural.editor.pool_depth":"Depth (m)","ext.structural.editor.preview":"Preview"},"pt-BR":{"ext.structural.wall.name":"Parede","ext.structural.wall.desc":"Parede simples (linha) em 2D.","ext.structural.area.name":"Área","ext.structural.area.desc":"Área (polígono) em 2D.","ext.structural.pool.name":"Piscina","ext.structural.pool.desc":"Piscina (buraco) em 2D.","ext.structural.tools.wall":"Parede","ext.structural.tools.wall_opening":"Abertura","ext.structural.tools.wall_opening_desc":"Recorte do piso ao teto. Passe sobre a parede, clique e arraste para dimensionar. Clique para largura padrão. Segure Shift para simetria.","ext.structural.tools.wall_door":"Porta","ext.structural.tools.wall_door_desc":"Adiciona um recorte de porta na parede.","ext.structural.tools.wall_window":"Janela","ext.structural.tools.wall_window_desc":"Adiciona um recorte de janela na parede.","ext.structural.tools.area_square":"Área retangular","ext.structural.tools.area_polygon":"Área livre","ext.structural.tools.area_square_walls":"Ambiente retangular","ext.structural.tools.area_polygon_walls":"Ambiente livre","ext.structural.tools.pool_square":"Piscina retangular","ext.structural.tools.pool_polygon":"Piscina livre","ext.structural.editor.wall_color":"Cor da parede","ext.structural.editor.wall_texture":"Textura da parede","ext.structural.editor.openings":"Aberturas","ext.structural.editor.openings_empty":"Sem aberturas ainda. Use as ferramentas ou adicione aqui.","ext.structural.editor.opening_kind":"Tipo","ext.structural.editor.opening_center":"Posição (m)","ext.structural.editor.opening_center_hint":"Ao longo da parede: {{start}} m = início (1º ponto), {{end}} m = fim (2º ponto).","ext.structural.editor.opening_width":"Largura (m)","ext.structural.editor.opening_height_full":"Altura: piso ao teto.","ext.structural.editor.opening_height_range":"Altura: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Cor","ext.structural.editor.opening_texture":"Textura","ext.structural.editor.kind.opening":"Abertura","ext.structural.editor.kind.door":"Porta","ext.structural.editor.kind.window":"Janela","ext.structural.editor.area_name":"Nome da área (opcional)","ext.structural.editor.area_color":"Cor da área","ext.structural.editor.floor_texture":"Textura do chão","ext.structural.editor.transparent":"Transparente","ext.structural.editor.texture.none":"Nenhuma","ext.structural.editor.texture.brick":"Tijolo","ext.structural.editor.texture.concrete":"Concreto","ext.structural.editor.texture.wood":"Madeira","ext.structural.editor.texture.glass":"Vidro","ext.structural.editor.texture.grass":"Grama","ext.structural.editor.pool_name":"Nome da piscina (opcional)","ext.structural.editor.pool_depth":"Profundidade (m)","ext.structural.editor.preview":"Prévia"}};function Xe(e){var t;e.i18n.registerTranslations(qe),e.registerElementType((t=e.i18n,{type:c,layerGroup:"walls",name:{key:"ext.structural.wall.name",fallback:"Wall"},description:{key:"ext.structural.wall.desc",fallback:"Simple wall (line) in 2D."},defaultProps:{color:p,texture:"none",width:m,a:{x:0,z:0},b:{x:1,z:0},openings:[]},getMain2DBounds:ye,renderMain2DVector:({element:e})=>{const t=_(e.props.a,{x:e.position.x,z:e.position.z}),o=_(e.props.b,{x:e.position.x+1,z:e.position.z}),n=g(e.props.color,p),a=C(e.props.texture,"none"),s=Math.max(.04,f(e.props.width,m)),c=Math.max(.001,L(t,o)),u=Y(Z(o,t)),d=H(u),h=me(ue(e.props.openings),c,3.2),x=ge(c,h.map(e=>({start:e.start_m,end:e.end_m}))),w=Math.max(s/2,.09),y=i(l(n,"brick"===a?-.16:"concrete"===a?-.1:-.12),.98);return(0,r.jsxs)("g",{className:"mainVector2dWall",children:[x.map((e,o)=>{const n=we(t,u,e.start),a=we(t,u,e.end),i=Math.max(s/2,.02),l=V(n,U(d,i)),c=V(a,U(d,i)),p=V(a,U(d,-i)),m=V(n,U(d,-i));return(0,r.jsx)("polygon",{points:_e([l,c,p,m]),fill:y},`solid:${o}`)}),h.map(e=>{const o=we(t,u,e.start_m),n=we(t,u,e.end_m),a=V(o,U(d,w)),c=V(n,U(d,w)),p=V(n,U(d,-w)),m=V(o,U(d,-w)),h=function(e){const t=ie(e.kind)??"#cbd5e1",o=e.color??t,r=A(e.texture,se(e.kind));if("window"===e.kind){const e="glass"===r?o:"#b9d8f4";return{fill:i(e,.3),stroke:i(l(e,-.16),.56),accent:i(l(e,.34),.82),highlight:"rgba(255,255,255,0.38)"}}return"door"===e.kind?{fill:i(o,"wood"===r?.5:.38),stroke:i(l(o,-.28),.52),accent:i(l(o,.26),.42),highlight:"rgba(255,255,255,0.16)"}:{fill:"rgba(255,255,255,0.08)",stroke:i(o,.26),accent:i(l(o,.2),.22),highlight:"rgba(255,255,255,0.10)"}}(e),x=we(t,u,e.start_m+.18*e.width_m),f=we(t,u,e.end_m-.18*e.width_m);return(0,r.jsxs)("g",{className:`mainVector2dWallOpening mainVector2dWallOpening-${e.kind}`,children:[(0,r.jsx)("polygon",{points:_e([a,c,p,m]),fill:h.fill,stroke:h.stroke,strokeWidth:.018,vectorEffect:"non-scaling-stroke"}),(0,r.jsx)("line",{x1:x.x,y1:x.z,x2:f.x,y2:f.z,stroke:h.accent,strokeWidth:Math.max(.008,"window"===e.kind?.32*s:.18*s),strokeLinecap:"round"}),"window"===e.kind?(0,r.jsx)("line",{x1:V(x,U(d,.46*-w)).x,y1:V(x,U(d,.46*-w)).z,x2:V(f,U(d,.46*-w)).x,y2:V(f,U(d,.46*-w)).z,stroke:h.highlight,strokeWidth:.01,strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}):null]},e.id)})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.Group,a=new e.Group,i=new e.Group,s=new e.Group;n.add(a),n.add(i),n.add(s),r.add(n);const l=new e.MeshStandardMaterial({color:p,roughness:.82,metalness:.05,flatShading:!0}),c=new e.MeshStandardMaterial({color:p,roughness:.86,metalness:.04,flatShading:!0}),u=new e.MeshBasicMaterial({color:"#000000",transparent:!0,opacity:0,depthWrite:!1});u.colorWrite=!1;let d="";function h(o){const r=_(o.props.a,{x:o.position.x-.5,z:o.position.z}),h=_(o.props.b,{x:o.position.x+.5,z:o.position.z}),x=Y(Z(h,r)),w=Math.max(.04,f(o.props.width,m)),y=Math.max(.15,t.wallHeight),M=Math.max(.001,L(r,h)),b=g(o.props.color,p),v=C(o.props.texture,"none"),k=function(e,t){if("none"===t)return null;if("brick"===t){const t=P(e,"wall:brick",z,{size:256,anisotropy:4});return t.repeat.set(1,1),t}if("concrete"===t){const t=P(e,"wall:concrete",j,{size:256,anisotropy:4});return t.repeat.set(.5,.5),t}return null}(e,v);n.position.set(r.x-o.position.x,0,r.z-o.position.z),n.rotation.set(0,Math.atan2(-x.z,x.x),0);const S=me(ue(o.props.openings),M,y),N=JSON.stringify({length:fe(M),thickness:fe(w),height:fe(y),openings:S.map(e=>({id:e.id,kind:e.kind,start:fe(e.start_m),end:fe(e.end_m),y0:fe(e.y_min_m),y1:fe(e.y_max_m),color:e.color??"",texture:e.texture??""}))});if(N!==d){d=N,ve(a,!1),ve(i,!0),ve(s,!1);const t=function(e,t,o){const r=[0,t];for(const e of o)r.push(xe(e.y_min_m,0,t)),r.push(xe(e.y_max_m,0,t));r.sort((e,t)=>e-t);const n=[];for(const e of r)(0===n.length||Math.abs(e-n[n.length-1])>1e-6)&&n.push(e);const a=[];for(let t=0;t<n.length-1;t++){const r=n[t],i=n[t+1];if(i-r<=1e-6)continue;const s=[];for(const e of o)e.y_min_m>=i-1e-6||e.y_max_m<=r+1e-6||s.push({start:e.start_m,end:e.end_m});const l=ge(e,s);for(const e of l)e.end-e.start<=1e-6||a.push({x0:e.start,x1:e.end,y0:r,y1:i})}return a}(M,y,S);for(const o of t){if(o.x1-o.x0<=1e-6||o.y1-o.y0<=1e-6)continue;const t=new e.BoxGeometry(o.x1-o.x0,o.y1-o.y0,w);be(t,{originX:(o.x0+o.x1)/2,originY:0+(o.y0+o.y1)/2,originZ:0,thicknessWorld:w});const r=[c,c,c,c,l,l],n=new e.Mesh(t,r);n.castShadow=!0,n.receiveShadow=!0,n.position.set((o.x0+o.x1)/2,0+(o.y0+o.y1)/2,0),a.add(n)}for(const t of S)"door"!==t.kind?"window"===t.kind&&Se(e,i,t,w):ze(e,i,t,w);for(const t of S){const o=t.y_max_m-t.y_min_m;if(t.width_m<=.08||o<=.08)continue;const r=new e.BoxGeometry(t.width_m,o,1.06*w),n=new e.Mesh(r,u);n.userData.__toposyncAllowPickWhenGhostWalls=!0,n.position.set(t.center_m,0+t.y_min_m+o/2,0),n.castShadow=!1,n.receiveShadow=!1,s.add(n)}}l.color.set(b),c.color.set(b),l.map!==k&&(l.map=k,l.needsUpdate=!0),l.roughness="brick"===v?.9:.82,l.metalness="brick"===v?.02:.05}return h(o),{object:r,update:h,dispose:()=>{ve(a,!1),ve(i,!0),ve(s,!1),l.dispose(),c.dispose(),u.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=_(t.props.a,{x:t.position.x,z:t.position.z}),n=_(t.props.b,{x:t.position.x+1,z:t.position.z}),a=g(t.props.color,p),i=Math.max(.04,f(t.props.width,m)),s=Math.max(.001,L(r,n)),l=Y(Z(n,r)),c=H(l),u=me(ue(t.props.openings),s,3.2),d=ge(s,u.map(e=>({start:e.start_m,end:e.end_m}))),h=Math.max(2,i*o.scale);e.save(),e.lineCap="round",e.lineJoin="round";for(const t of d){const n=o.worldToScreen(we(r,l,t.start)),i=o.worldToScreen(we(r,l,t.end));e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=h+3,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.stroke(),e.strokeStyle=a,e.lineWidth=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.stroke()}const x=Math.max(i/2,.09);for(const t of u){const n=we(r,l,t.start_m),a=we(r,l,t.end_m),i=o.worldToScreen(V(n,U(c,x))),s=o.worldToScreen(V(a,U(c,x))),u=o.worldToScreen(V(a,U(c,-x))),d=o.worldToScreen(V(n,U(c,-x))),p=ke(t.kind);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(s.x,s.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.fillStyle=p.fill,e.fill(),e.strokeStyle=p.stroke,e.lineWidth=1.8,e.setLineDash(p.dash),e.stroke(),e.setLineDash([])}e.restore()},hitTest2D:({element:e,world:t,viewport:o})=>{const r=_(e.props.a,{x:e.position.x,z:e.position.z}),n=_(e.props.b,{x:e.position.x+1,z:e.position.z}),a=Math.max(.04,f(e.props.width,m)),i=Math.max(a/2,.09,10/Math.max(1,o.scale));return function(e,t,o){const r=Z(o,t),n=Z(e,t),a=r.x*r.x+r.z*r.z;return a<=1e-9?Math.hypot(n.x,n.z):L(e,V(t,U(r,xe((n.x*r.x+n.z*r.z)/a,0,1))))}(t,r,n)<=i},renderEditorModal:({element:e,update:o,remove:n,close:a})=>(0,r.jsx)(je,{element:e,update:o,remove:n,close:a,i18n:t})})),e.registerElementType(B(e.i18n)),e.registerElementType(X(e.i18n));for(const t of(e.i18n,[{id:"com.toposync.structural.tool.wall",name:{key:"ext.structural.tools.wall",fallback:"Wall"},icon:"grip-lines",group:Ne,order:10,createSession:e=>{let t=null,o=null;function r(){t=null,o=null}return{onPointerEvent:n=>{var a;if("cancel"!==n.kind)if("move"!==n.kind){if("down"===n.kind&&0===n.button)return t?(a=n.world,void(t&&(L(t,a)<.05||We(e,t,a),r()))):(t=n.world,void(o=n.world))}else t&&(o=n.world);else r()},onKeyDown:e=>{"Escape"===e.key&&r()},renderOverlay2D:({ctx:e,viewport:r})=>{if(!t||!o)return;const n=r.worldToScreen(t),a=r.worldToScreen(o),s=Math.max(2,m*r.scale);e.save(),e.setLineDash([8,6]),e.lineCap="round",e.strokeStyle=i("#fbbf24",.85),e.lineWidth=s,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}},Ie(0,{kind:"door"}),Ie(0,{kind:"window"}),Ie(0,{kind:"opening"}),Ge(0,{withWalls:!0}),$e(0,{withWalls:!0}),Ge(0,{withWalls:!1}),$e(0,{withWalls:!1}),Oe(),{id:"com.toposync.structural.tool.pool_polygon",name:{key:"ext.structural.tools.pool_polygon",fallback:"Freeform pool"},icon:"water",group:Te,order:60,createSession:e=>{const t=[];let o=null;function r(){t.splice(0,t.length),o=null}function n(){if(t.length<3)return void r();const o=Ce(e,[...t]);o&&e.openEditor(o),r()}return{onPointerEvent:e=>{"cancel"!==e.kind?"move"!==e.kind?"dblclick"!==e.kind?"down"===e.kind&&0===e.button&&(function(e){if(t.length<3)return!1;const o=t[0];return L(e.world,o)<.22}(e)?n():(t.push(e.world),o=e.world)):n():o=e.world:r()},onKeyDown:e=>{"Escape"===e.key&&r(),"Enter"===e.key&&n(),("Backspace"===e.key||"Delete"===e.key)&&t.length>0&&t.pop()},renderOverlay2D:({ctx:e,viewport:r})=>{if(0===t.length)return;const n=t.map(e=>r.worldToScreen(e)),a=o?r.worldToScreen(o):null;if(e.save(),t.length>=2){e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);a&&e.lineTo(a.x,a.y),e.strokeStyle=i("#38bdf8",.85),e.lineWidth=2,e.setLineDash([6,6]),e.stroke()}for(let o=0;o<n.length;o++){const r=n[o],a=0===o&&t.length>=3;e.beginPath(),e.arc(r.x,r.y,a?6:5,0,2*Math.PI),e.fillStyle=i(a?"#22c55e":"#38bdf8",.85),e.fill(),e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=2,e.stroke()}e.restore()},getCursor:()=>"crosshair"}}}]))e.registerEditorTool(t)}},94(e,t,o){var r=o(496),n=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,o){var r,l={},c=null,u=null;for(r in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!s.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===l[r]&&(l[r]=t[r]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:i.current}}t.jsx=l,t.jsxs=l},870(e,t,o){e.exports=o(94)}}]);
@@ -1,2 +0,0 @@
1
- /*! For license information please see 12.js.LICENSE.txt */
2
- "use strict";(self.webpackChunk_toposync_extension_structural_ui=self.webpackChunk_toposync_extension_structural_ui||[]).push([[12],{94(e,t,o){var r=o(496),n=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,o){var r,l={},c=null,u=null;for(r in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!s.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===l[r]&&(l[r]=t[r]);return{$$typeof:n,type:e,key:c,ref:u,props:l,_owner:i.current}}t.jsx=l,t.jsxs=l},870(e,t,o){e.exports=o(94)},12(e,t,o){o.r(t),o.d(t,{activate:()=>Xe});var r=o(870),n=o(496);function a(e){const t=e.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(t)?{r:Number.parseInt(t.slice(0,2),16),g:Number.parseInt(t.slice(2,4),16),b:Number.parseInt(t.slice(4,6),16)}:null}function i(e,t){const o=a(e),r=Math.max(0,Math.min(1,t));return o?`rgba(${o.r},${o.g},${o.b},${r})`:`rgba(99,102,241,${r})`}function s(e,t,o){const r=a(e),n=a(t);if(!r||!n)return e;const i=Math.max(0,Math.min(1,o));return function(e){const t=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");return`#${t(e.r)}${t(e.g)}${t(e.b)}`}({r:r.r+(n.r-r.r)*i,g:r.g+(n.g-r.g)*i,b:r.b+(n.b-r.b)*i})}function l(e,t){return t>=0?s(e,"#ffffff",t):s(e,"#000000",Math.abs(t))}const c="com.toposync.structural.wall",u="com.toposync.structural.area",d="com.toposync.structural.pool",p="#dcddda",m=.12,h="#dcddda",x="toposync.structural.area.fill.v1";function f(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function g(e,t){return"string"==typeof e?e:t}function w(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function y(e){try{if(!w(e))return;localStorage.setItem(x,e)}catch{}}function _(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return t;const o=e;return{x:f(o.x,t.x),z:f(o.z,t.z)}}function M(e){return Array.isArray(e)?e.map(e=>_(e,{x:0,z:0})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.z)):[]}function b(e){const t=document.createElement("canvas");return t.width=e,t.height=e,t}function v(e,t){return e+Math.floor(Math.random()*(t-e+1))}function k(e,t,o,r){e.save(),e.globalAlpha=r;for(let r=0;r<o;r++){const o=Math.random()*t,r=Math.random()*t,n=1+2*Math.random(),a=1+2*Math.random(),i=v(0,255);e.fillStyle=`rgb(${i},${i},${i})`,e.fillRect(o,r,n,a)}e.restore()}function z(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#6b7280",o.fillRect(0,0,e,e);const r=e/10,n=2.2*r,a=Math.max(1,Math.round(.01*e));for(let t=0;t<10;t++){const i=t*r;for(let s=-(t%2==0?0:n/2);s<e+n;s+=n){const e=Math.floor(s+a),t=Math.floor(i+a),l=Math.ceil(n-2*a),c=Math.ceil(r-2*a),u=v(86,140);o.fillStyle=`rgb(${u},${u},${u})`,o.fillRect(e,t,l,c)}}o.strokeStyle="#111827",o.lineWidth=a,o.globalAlpha=.85;for(let t=0;t<=10;t++){const n=t*r;o.beginPath(),o.moveTo(0,n+.5),o.lineTo(e,n+.5),o.stroke()}for(let t=0;t<10;t++){const a=t*r;for(let i=-(t%2==0?0:n/2);i<e+n;i+=n){const e=i;o.beginPath(),o.moveTo(e+.5,a),o.lineTo(e+.5,a+r),o.stroke()}}return k(o,e,Math.floor(e*e/10),.06),t}function S(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#7c5d3a",o.fillRect(0,0,e,e),o.save(),o.globalAlpha=.35;for(let t=0;t<e;t+=1){const r=t/e,n=Math.sin(r*Math.PI*8+1.2*Math.sin(r*Math.PI*2)),a=Math.round(88+20*n+12*Math.random());o.fillStyle=`rgb(${a},${Math.round(.72*a)},${Math.round(.45*a)})`,o.fillRect(0,t,e,1)}o.restore(),o.save(),o.globalAlpha=.18,o.strokeStyle="#3f2f1f",o.lineWidth=1;for(let t=0;t<48;t++){const t=Math.random()*e,r=Math.random()*e,n=2+6*Math.random(),a=1+3*Math.random();o.beginPath(),o.ellipse(t,r,n,a,Math.random()*Math.PI,0,2*Math.PI),o.stroke()}return o.restore(),k(o,e,Math.floor(e*e/4),.06),t}function j(e){const t=b(e),o=t.getContext("2d");return o?(o.fillStyle="#9ca3af",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.08),k(o,e,Math.floor(e*e/3),.06),t):t}function N(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#166534",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.1),o.save(),o.globalAlpha=.2,o.strokeStyle="#052e16",o.lineWidth=1;for(let t=0;t<360;t++){const t=Math.random()*e,r=Math.random()*e,n=4+10*Math.random(),a=-Math.PI/2+.8*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}o.globalAlpha=.14,o.strokeStyle="#4ade80";for(let t=0;t<180;t++){const t=Math.random()*e,r=Math.random()*e,n=3+8*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}return o.restore(),t}function T(e){const t=b(e),o=t.getContext("2d");if(!o)return t;o.fillStyle="#14532d",o.fillRect(0,0,e,e),k(o,e,Math.floor(e*e/2),.08),k(o,e,Math.floor(e*e/3),.06),o.save(),o.globalAlpha=.18,o.strokeStyle="#052e16",o.lineWidth=1;for(let t=0;t<900;t++){const t=Math.random()*e,r=Math.random()*e,n=4+12*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}o.globalAlpha=.12,o.strokeStyle="#86efac";for(let t=0;t<520;t++){const t=Math.random()*e,r=Math.random()*e,n=3+10*Math.random(),a=-Math.PI/2+1*(Math.random()-.5);o.beginPath(),o.moveTo(t,r),o.lineTo(t+Math.cos(a)*n,r+Math.sin(a)*n),o.stroke()}return o.restore(),t}const W=new Map;function P(e,t,o,r){const n=W.get(t);if(n)return n;const a=o(r?.size??256),i=new e.CanvasTexture(a);return i.wrapS=e.RepeatWrapping,i.wrapT=e.RepeatWrapping,i.colorSpace=e.SRGBColorSpace,i.anisotropy=r?.anisotropy??4,W.set(t,i),i}function C(e,t){return"none"===e||"brick"===e||"concrete"===e?e:t}function D(e,t){return"none"===e||"grass"===e||"concrete"===e?e:t}function A(e,t){return"none"===e||"wood"===e||"concrete"===e||"glass"===e?e:t}function F(e,t){return"none"===t||"glass"===t?null:"wood"===t?P(e,"opening:wood",S,{size:256,anisotropy:4}):"concrete"===t?P(e,"opening:concrete",j,{size:256,anisotropy:4}):null}let E=null;function R(e){const t=Math.random(),o=Math.random(),r=Math.sqrt(t),n=1-r,a=o*r,i=1-n-a;return{x:e.ax*n+e.bx*a+e.cx*i,z:e.az*n+e.bz*a+e.cz*i}}function B(e){return{type:u,layerGroup:"areas",name:{key:"ext.structural.area.name",fallback:"Area"},description:{key:"ext.structural.area.desc",fallback:"Area (polygon) in 2D."},defaultProps:{fill:h,opacity:1,texture:"none",vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:e=>function(e){if(0===e.length)return null;let t=e[0].x,o=e[0].x,r=e[0].z,n=e[0].z;for(let a=1;a<e.length;a+=1){const i=e[a];t=Math.min(t,i.x),o=Math.max(o,i.x),r=Math.min(r,i.z),n=Math.max(n,i.z)}return{minX:t,maxX:o,minZ:r,maxZ:n}}(M(e.props.vertices)),renderMain2DVector:({element:e})=>{const t=M(e.props.vertices);if(t.length<3)return null;const o=g(e.props.fill,h),n=f(e.props.opacity,1),a=n<.001?0:n;if(a<=0)return null;const s=D(e.props.texture,"none"),c=function(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}(t),u=i(l(o,"grass"===s?-.24:-.16),Math.min(.34,.34*a)),d=i(l(o,.42),Math.min(.2,.2*a)),p="grass"===s?"mainVector2dGrassPattern":"concrete"===s?"mainVector2dConcretePattern":"";return(0,r.jsxs)("g",{className:"mainVector2dArea",children:[(0,r.jsx)("polygon",{points:c,fill:i(o,Math.min(.92,Math.max(0,a))),stroke:u,strokeWidth:.026,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),p?(0,r.jsx)("polygon",{points:c,fill:`url(#${p})`,opacity:Math.min(.42,.38*a)}):null,(0,r.jsx)("polygon",{points:c,fill:"none",stroke:d,strokeWidth:.01,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.MeshStandardMaterial({color:h,roughness:.95,metalness:0,side:e.DoubleSide,transparent:!1,opacity:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});n.stencilWrite=!0,n.stencilRef=1,n.stencilFunc=e.NotEqualStencilFunc,n.stencilFail=e.KeepStencilOp,n.stencilZFail=e.KeepStencilOp,n.stencilZPass=e.KeepStencilOp,n.stencilWriteMask=0,n.stencilFuncMask=255;let a=null,i="",s=null,l=null,c="";function u(t,o,n){if(s&&(r.remove(s),s.geometry.dispose(),s=null),!(o>0))return;const a=new e.PlaneGeometry(1,1,1,4);a.translate(0,.5,0);const i=a,c=new e.InstancedBufferAttribute(new Float32Array(o),1);i.setAttribute("instanceSeed",c);const u=function(){if(l)return l;const t=function(e){if(E)return E;const t=64,o=document.createElement("canvas");o.width=t,o.height=t;const r=o.getContext("2d");if(r){r.clearRect(0,0,t,t),r.fillStyle="black",r.fillRect(0,0,t,t);const e=r.createLinearGradient(0,t,0,0);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.18,"rgba(255,255,255,1)"),e.addColorStop(1,"rgba(255,255,255,1)"),r.fillStyle=e,r.beginPath(),r.moveTo(32,1.28),r.quadraticCurveTo(37.12,28.8,39.68,62.72),r.quadraticCurveTo(32,57.6,24.32,62.72),r.quadraticCurveTo(26.88,28.8,32,1.28),r.closePath(),r.fill(),r.globalCompositeOperation="destination-in";const o=r.createRadialGradient(32,51.2,0,32,51.2,35.2);o.addColorStop(0,"rgba(255,255,255,1)"),o.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=o,r.fillRect(0,0,t,t)}const n=new e.CanvasTexture(o);return n.wrapS=e.ClampToEdgeWrapping,n.wrapT=e.ClampToEdgeWrapping,n.magFilter=e.LinearFilter,n.minFilter=e.LinearMipmapLinearFilter,n.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,E=n,n}(e),o=new e.MeshStandardMaterial({color:1483594,roughness:.88,metalness:0,side:e.DoubleSide,alphaMap:t,alphaTest:.35});return o.stencilWrite=!0,o.stencilRef=1,o.stencilFunc=e.NotEqualStencilFunc,o.stencilFail=e.KeepStencilOp,o.stencilZFail=e.KeepStencilOp,o.stencilZPass=e.KeepStencilOp,o.stencilWriteMask=0,o.stencilFuncMask=255,o.onBeforeCompile=e=>{e.uniforms.uTime={value:0},e.vertexShader=e.vertexShader.replace("#include <common>","#include <common>\nuniform float uTime;\nattribute float instanceSeed;").replace("#include <begin_vertex>","#include <begin_vertex>\nfloat h01 = clamp(position.y, 0.0, 1.0);\nfloat wind = sin(uTime * 1.2 + instanceSeed + position.x * 2.4) * 0.12;\nfloat wind2 = cos(uTime * 0.9 + instanceSeed * 1.7) * 0.08;\ntransformed.x += (wind + wind2) * h01 * h01;\ntransformed.z += sin(uTime * 1.1 + instanceSeed * 0.7) * 0.06 * h01 * h01;"),o.userData.shader=e},l=o,o}();u.color.set(n);const d=new e.InstancedMesh(i,u,o);d.frustumCulled=!1,d.renderOrder=5;const p=function(e){const t=e.getAttribute("position"),o=e.getIndex(),r=[],n=[];let a=0;function i(e,o,i){const s=t.getX(e),l=t.getZ(e),c=t.getX(o),u=t.getZ(o),d=t.getX(i),p=t.getZ(i),m=.5*Math.abs((c-s)*(p-l)-(d-s)*(u-l));m>1e-9&&(a+=m,r.push({ax:s,az:l,bx:c,bz:u,cx:d,cz:p,area:m}),n.push(a))}if(o)for(let e=0;e<o.count;e+=3)i(o.getX(e),o.getX(e+1),o.getX(e+2));else for(let e=0;e<t.count;e+=3)i(e,e+1,e+2);return{triangles:r,cdf:n,totalArea:a}}(t);if(!(p.totalArea>1e-9)||0===p.triangles.length)return void i.dispose();const m=new e.Matrix4,h=new e.Quaternion,x=new e.Vector3,f=new e.Vector3,g=new e.Vector3(0,1,0);for(let e=0;e<o;e+=1){const t=Math.random()*p.totalArea;let o=0,r=p.cdf.length-1;for(;o<r;){const e=o+r>>1;t<=p.cdf[e]?r=e:o=e+1}const n=R(p.triangles[o]),a=Math.random()*Math.PI*2;h.setFromAxisAngle(g,a);const i=.1+.2*Math.random(),s=i*(.12+.1*Math.random());f.set(s,i,1),x.set(n.x,.012,n.z),m.compose(x,h,f),d.setMatrixAt(e,m),c.setX(e,1e3*Math.random())}d.instanceMatrix.needsUpdate=!0,c.needsUpdate=!0,s=d,r.add(d)}function d(o){const d=M(o.props.vertices),p=JSON.stringify(d.map(e=>({x:Math.round(1e3*(e.x-o.position.x))/1e3,z:Math.round(1e3*(e.z-o.position.z))/1e3})));if(p!==i){i=p;const t=function(t){const o=M(t.props.vertices);if(o.length<3)return null;const r=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),n=new e.Shape;n.moveTo(r[0].x,-r[0].z);for(let e=1;e<r.length;e++)n.lineTo(r[e].x,-r[e].z);n.closePath();const a=new e.ShapeGeometry(n);a.rotateX(-Math.PI/2);const i=a.getAttribute("position"),s=new e.BufferAttribute(new Float32Array(2*i.count),2);for(let e=0;e<i.count;e++){const o=i.getX(e)+t.position.x,r=i.getZ(e)+t.position.z;s.setXY(e,o,r)}return a.setAttribute("uv",s),a}(o);t?a?(a.geometry.dispose(),a.geometry=t):(a=new e.Mesh(t,n),a.receiveShadow=!0,r.add(a)):a&&(r.remove(a),a.geometry.dispose(),a=null)}const m=g(o.props.fill,h),x=Math.max(0,Math.min(1,f(o.props.opacity,1)))<.001,w=x?0:1,y=D(o.props.texture,"none"),_=t.graphicsQuality??"simplified",b=function(e,t,o="simplified"){return"none"===t?null:"grass"===t?"detailed"===o?P(e,"floor:grass:detailed",T,{size:512,anisotropy:8}):P(e,"floor:grass:simplified",N,{size:256,anisotropy:4}):"concrete"===t?P(e,"floor:concrete",j,{size:256,anisotropy:4}):null}(e,y,_);if(n.color.set(m),n.map!==b&&(n.map=b,n.needsUpdate=!0),n.roughness="grass"===y?.98:.95,n.metalness=0,n.opacity=w,n.transparent=x,n.depthWrite=!x,a&&(a.visible=!x,a.position.y=.01),x||"grass"!==y||"detailed"!==_||!Boolean(a&&a.geometry))return void(s&&(s.visible=!1));s&&(s.visible=!0);const v=function(e){if(e.length<3)return 0;let t=0;for(let o=0;o<e.length;o+=1){const r=e[o],n=e[(o+1)%e.length];t+=r.x*n.z-n.x*r.z}return Math.abs(t)/2}(d),k=Math.max(240,Math.min(1800,Math.floor(35*v))),z=`${p}:${k}`;z!==c&&a?(c=z,u(a.geometry,k,m)):l&&l.color.set(m)}return d(o),{object:r,update:d,tick:()=>{if(!l||!s?.visible)return!1;const e=l.userData.shader;return!!e&&(e.uniforms.uTime.value=performance.now()/1e3,!0)},dispose:()=>{a&&a.geometry.dispose(),n.dispose(),s&&s.geometry.dispose(),l?.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=M(t.props.vertices);if(r.length<3)return;const n=g(t.props.fill,h),a=f(t.props.opacity,1)<.001?0:1,s=r.map(e=>o.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(s[0].x,s[0].y);for(let t=1;t<s.length;t++)e.lineTo(s[t].x,s[t].y);e.closePath(),e.fillStyle=i(n,a),e.fill(),e.strokeStyle=i("#e6e8f2",.22),e.lineWidth=2,e.stroke(),e.restore()},renderEditorModal:({element:t,update:o,remove:n,close:a})=>(0,r.jsx)(I,{element:t,update:o,remove:n,close:a,i18n:e})}}function I({element:e,update:t,remove:o,close:n,i18n:a}){const{t:i}=a.useI18n(),s=g(e.props.fill,h),l=f(e.props.opacity,1)<.001,c=D(e.props.texture,"none");return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"field",children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.area_name")}),(0,r.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.area_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:s,onChange:e=>{const o=e.target.value;y(o),t({props:{fill:o}})}})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:i("ext.structural.editor.floor_texture")}),(0,r.jsxs)("select",{className:"input",value:c,onChange:e=>{const o=D(e.target.value,c),r="grass"===o?"#16a34a":"concrete"===o?h:s;y(r),t({props:{texture:o,fill:r}})},children:[(0,r.jsx)("option",{value:"none",children:i("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"grass",children:i("ext.structural.editor.texture.grass")}),(0,r.jsx)("option",{value:"concrete",children:i("ext.structural.editor.texture.concrete")})]})]}),(0,r.jsxs)("label",{className:"chipButton",style:{display:"inline-flex",alignItems:"center",gap:10},children:[(0,r.jsx)("input",{type:"checkbox",checked:l,onChange:e=>t({props:{opacity:e.target.checked?0:1}})}),(0,r.jsx)("span",{children:i("ext.structural.editor.transparent")})]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:i("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:n,children:i("core.actions.close")})]})]})}let G=null,O=null;function $(e,t,o){return Math.max(t,Math.min(o,e))}function q(e){return{depth_m:$(f(e.depth_m,1.4),.1,20),vertices:M(e.vertices)}}function X(e){return{type:d,layerGroup:"areas",name:{key:"ext.structural.pool.name",fallback:"Pool"},description:{key:"ext.structural.pool.desc",fallback:"Swimming pool (hole) in 2D."},defaultProps:{depth_m:1.4,vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:e=>function(e){if(0===e.length)return null;let t=e[0].x,o=e[0].x,r=e[0].z,n=e[0].z;for(let a=1;a<e.length;a+=1){const i=e[a];t=Math.min(t,i.x),o=Math.max(o,i.x),r=Math.min(r,i.z),n=Math.max(n,i.z)}return{minX:t,maxX:o,minZ:r,maxZ:n}}(q(e.props).vertices),renderMain2DVector:({element:e})=>{const t=q(e.props);if(t.vertices.length<3)return null;const o=function(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}(t.vertices),n=$(t.depth_m/4.5,.16,.42);return(0,r.jsxs)("g",{className:"mainVector2dPool",children:[(0,r.jsx)("polygon",{points:o,fill:`rgba(8,47,73,${n})`,stroke:"rgba(125,211,252,0.60)",strokeWidth:.045,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),(0,r.jsx)("polygon",{points:o,fill:"url(#mainVector2dWaterGradient)",opacity:"0.86"}),(0,r.jsx)("polygon",{points:o,fill:"url(#mainVector2dWaterPattern)",opacity:"0.46"}),(0,r.jsx)("polygon",{points:o,fill:"none",stroke:"rgba(224,242,254,0.58)",strokeWidth:.016,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.BufferGeometry,a=new e.MeshBasicMaterial({color:0});a.colorWrite=!1,a.depthWrite=!1,a.depthTest=!1,a.stencilWrite=!0,a.stencilRef=1,a.stencilFunc=e.AlwaysStencilFunc,a.stencilZPass=e.ReplaceStencilOp;const i=function(e){if(G)return G;const t=function(e){const t=document.createElement("canvas");t.width=e,t.height=e;const o=t.getContext("2d");if(!o)return t;o.fillStyle="rgb(128,128,128)",o.fillRect(0,0,e,e),o.save(),o.globalAlpha=.14,o.fillStyle="rgb(150,150,150)";for(let t=0;t<220;t++){const t=Math.random()*e,r=Math.random()*e,n=6+26*Math.random();o.beginPath(),o.arc(t,r,n,0,2*Math.PI),o.fill()}o.globalAlpha=.1,o.fillStyle="rgb(100,100,100)";for(let t=0;t<160;t++){const t=Math.random()*e,r=Math.random()*e,n=4+20*Math.random();o.beginPath(),o.arc(t,r,n,0,2*Math.PI),o.fill()}return o.restore(),t}(256),o=new e.CanvasTexture(t);return o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.repeat.set(2,2),o.anisotropy=4,o.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,G=o,o}(e),s=function(e){if(O)return O;const t=function(e){const t=document.createElement("canvas");t.width=e,t.height=e;const o=t.getContext("2d");if(!o)return t;const r=o.createImageData(e,e),n=r.data,a=2*Math.PI,i=[{dirX:.92,dirY:.39,freq:3,amp:.7,phase:Math.random()*a},{dirX:-.16,dirY:.99,freq:5,amp:.5,phase:Math.random()*a},{dirX:.68,dirY:-.73,freq:8,amp:.35,phase:Math.random()*a},{dirX:-.91,dirY:-.41,freq:12,amp:.22,phase:Math.random()*a}];for(let t=0;t<e;t+=1){const o=t/e;for(let r=0;r<e;r+=1){const s=r/e;let l=0,c=0;for(const e of i){const t=a*(e.dirX*s+e.dirY*o)*e.freq+e.phase,r=Math.cos(t),n=e.amp*e.freq*a;l+=r*n*e.dirX,c+=r*n*e.dirY}let u=.085*-l,d=1,p=.085*-c;const m=1/Math.sqrt(u*u+d*d+p*p);u*=m,d*=m,p*=m;const h=4*(t*e+r);n[h+0]=Math.round(255*(.5*u+.5)),n[h+1]=Math.round(255*(.5*d+.5)),n[h+2]=Math.round(255*(.5*p+.5)),n[h+3]=255}}return o.putImageData(r,0,0),t}(256),o=new e.CanvasTexture(t);return o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.repeat.set(2,2),o.anisotropy=8,o.colorSpace=e.NoColorSpace??e.LinearSRGBColorSpace,O=o,o}(e),l=new e.MeshStandardMaterial({color:959977,roughness:.18,metalness:.02,transparent:!0,opacity:.68,side:e.DoubleSide,depthWrite:!1,emissive:new e.Color(402490),emissiveIntensity:.1});l.bumpMap=i,l.bumpScale=0;const c=new e.MeshPhysicalMaterial({color:959977,roughness:.12,metalness:0,transmission:.92,thickness:.18,ior:1.33,transparent:!0,opacity:1,side:e.DoubleSide,depthWrite:!1,clearcoat:.62,clearcoatRoughness:.08});c.normalMap=s,c.normalScale=new e.Vector2(.55,.55),c.attenuationColor=new e.Color(402490),c.attenuationDistance=.8;const u=new e.MeshStandardMaterial({color:988970,roughness:.95,metalness:.02,side:e.DoubleSide}),d=new e.MeshStandardMaterial({color:728888,roughness:.98,metalness:0,side:e.DoubleSide}),p=new e.Mesh(n,a);p.renderOrder=-20;const m=new e.Mesh(n,l);m.renderOrder=10;const h=new e.Mesh(n,u),x=new e.Mesh(n,d);r.add(p),r.add(h),r.add(x),r.add(m);let f=null,g=null,w="";function y(o){const r=q(o.props),a="detailed"===(t.graphicsQuality??"simplified"),i=JSON.stringify({v:r.vertices.map(e=>({x:Math.round(1e3*(e.x-o.position.x))/1e3,z:Math.round(1e3*(e.z-o.position.z))/1e3})),d:Math.round(1e3*r.depth_m)/1e3});if(i!==w){w=i;const t=function(e,t,o){if(o.length<3)return null;const r=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),n=new e.Shape;n.moveTo(r[0].x,-r[0].z);for(let e=1;e<r.length;e++)n.lineTo(r[e].x,-r[e].z);n.closePath();const a=new e.ShapeGeometry(n);return a.rotateX(-Math.PI/2),a}(e,o,r.vertices),a=function(e,t,o,r){if(o.length<2)return null;const n=o.map(e=>({x:e.x-t.position.x,z:e.z-t.position.z})),a=-Math.abs(r),i=n.length,s=new Float32Array(4*i*3),l=[];for(let e=0;e<i;e++){const t=n[e],o=n[(e+1)%i],r=4*e;s[3*(r+0)+0]=t.x,s[3*(r+0)+1]=0,s[3*(r+0)+2]=t.z,s[3*(r+1)+0]=o.x,s[3*(r+1)+1]=0,s[3*(r+1)+2]=o.z,s[3*(r+2)+0]=o.x,s[3*(r+2)+1]=a,s[3*(r+2)+2]=o.z,s[3*(r+3)+0]=t.x,s[3*(r+3)+1]=a,s[3*(r+3)+2]=t.z,l.push(r+0,r+1,r+2,r+0,r+2,r+3)}const c=new e.BufferGeometry;return c.setAttribute("position",new e.BufferAttribute(s,3)),c.setIndex(l),c.computeVertexNormals(),c}(e,o,r.vertices,r.depth_m);f&&f.dispose(),g&&g.dispose(),f=t,g=a,p.geometry=f??n,m.geometry=f??n,x.geometry=f??n,h.geometry=g??n}const s=Boolean(f&&g);if(p.visible=s,m.visible=s,x.visible=s,h.visible=s,!s)return;p.position.y=.01,h.position.y=0,x.position.y=0-r.depth_m;const u=Math.min(.06,Math.max(.02,.3*r.depth_m));m.position.y=0-u,m.material=a?c:l,a?(c.roughness=.1,c.transmission=.92,c.clearcoat=.65,c.clearcoatRoughness=.08,c.attenuationDistance=.8+.35*$(r.depth_m,.2,2.5)):(l.roughness=.22,l.opacity=.66,l.emissiveIntensity=.06,l.bumpScale=0)}return y(o),{object:r,update:y,tick:e=>{if("detailed"!==(t.graphicsQuality??"simplified")||!m.visible)return!1;const o=performance.now(),r=s.userData??={};return o-("number"==typeof r.lastOffsetUpdateMs?r.lastOffsetUpdateMs:0)<4||(r.lastOffsetUpdateMs=o,s.offset.x=(s.offset.x+.022*e)%1,s.offset.y=(s.offset.y+.022*e*.7)%1),!0},dispose:()=>{f&&f.dispose(),g&&g.dispose(),n.dispose(),a.dispose(),u.dispose(),d.dispose(),l.dispose(),c.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=q(t.props);if(r.vertices.length<3)return;const n=r.vertices.map(e=>o.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#0ea5e9",.14),e.fill(),e.strokeStyle=i("#38bdf8",.65),e.lineWidth=2,e.stroke(),e.restore()},renderEditorModal:({element:t,update:o,remove:n,close:a})=>(0,r.jsx)(K,{element:t,update:o,remove:n,close:a,i18n:e})}}function K({element:e,update:t,remove:o,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=q(e.props),u=(0,n.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s("ext.structural.pool.name")}),(0,r.jsxs)("div",{className:"cardMeta",children:[u.format(c.depth_m)," m"]})]}),(0,r.jsx)("div",{className:"cardBody",children:s("ext.structural.pool.desc")})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"field",children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_name")}),(0,r.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,r.jsx)("div",{className:"rowWrap",children:(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_depth")}),(0,r.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:.1,max:20,step:.1,value:c.depth_m,onChange:e=>{const o=Number.parseFloat(e.target.value);Number.isFinite(o)&&t({props:{depth_m:$(o,.1,20)}})}})]})}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:s("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}function L(e,t){const o=e.x-t.x,r=e.z-t.z;return Math.hypot(o,r)}function V(e,t){return{x:e.x+t.x,z:e.z+t.z}}function Z(e,t){return{x:e.x-t.x,z:e.z-t.z}}function U(e,t){return{x:e.x*t,z:e.z*t}}function Y(e){const t=Math.hypot(e.x,e.z);return t<=1e-9?{x:1,z:0}:{x:e.x/t,z:e.z/t}}function H(e){return{x:-e.z,z:e.x}}function J(e){if(0===e.length)return{x:0,z:0};const t=e.reduce((e,t)=>({x:e.x+t.x,z:e.z+t.z}),{x:0,z:0});return{x:t.x/e.length,z:t.z/e.length}}const Q=.25,ee=/^#[0-9a-fA-F]{6}$/;function te(e,t,o){return Math.max(t,Math.min(o,e))}function oe(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function re(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function ne(e){if("string"!=typeof e)return;const t=e.trim();return t.length>0?t:void 0}function ae(e){return"door"===e?.9:"window"===e?1.2:1}function ie(e){return"door"===e?"#8f806a":"window"===e?"#b9d8f4":void 0}function se(e){return"door"===e?"wood":"window"===e?"glass":"none"}function le(){const e=crypto;return e.randomUUID?.()??`opening-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ce(e){if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e,o=function(e){return"opening"===e||"door"===e||"window"===e}(t.kind)?t.kind:"opening",r=Math.max(Q,oe(t.width_m,ae(o))),n=ne(t.color),a=ne(t.texture);return{id:ne(t.id)??le(),kind:o,center_m:oe(t.center_m,0),width_m:r,y_min_m:re(t.y_min_m),y_max_m:re(t.y_max_m),color:n&&ee.test(n)?n:void 0,texture:a}}function ue(e){if(!Array.isArray(e))return[];const t=[],o=new Set;for(const r of e){const e=ce(r);if(e){for(;o.has(e.id);)e.id=le();o.add(e.id),t.push(e)}}return t}function de(e,t){const o=Math.max(.15,t);if("opening"===e)return{yMin:0,yMax:o};if("door"===e)return{yMin:0,yMax:Math.min(o,2.1)};const r=Math.min(.9,Math.max(0,o-.3));return{yMin:r,yMax:Math.min(o,Math.max(r+.25,2))}}function pe(e){const t=Math.max(Q,e.width_m);return{id:le(),kind:e.kind,center_m:e.center_m,width_m:t,color:ie(e.kind),texture:se(e.kind)}}function me(e,t,o){const r=Math.max(.001,t),n=Math.max(.15,o),a=[];for(const t of e){const e=Math.min(Q,r),o=te(Number.isFinite(t.width_m)?t.width_m:ae(t.kind),e,r),i=te(Number.isFinite(t.center_m)?t.center_m:r/2,o/2,r-o/2),s=i-o/2,l=i+o/2;if(l-s<e-1e-6)continue;const c=de(t.kind,n);let u,d;if("opening"===t.kind?(u=0,d=n):(u=Number.isFinite(t.y_min_m??NaN)?t.y_min_m:c.yMin,d=Number.isFinite(t.y_max_m??NaN)?t.y_max_m:c.yMax),u=te(u,0,n),d=te(d,0,n),d<u){const e=d;d=u,u=e}d-u<.08||a.push({id:t.id,kind:t.kind,center_m:i,width_m:o,start_m:s,end_m:l,y_min_m:u,y_max_m:d,color:t.color,texture:t.texture})}return a.sort((e,t)=>e.start_m-t.start_m||e.id.localeCompare(t.id)),a}function he(e){return e.map(e=>{const t={id:e.id,kind:e.kind,center_m:e.center_m,width_m:e.width_m};return"number"==typeof e.y_min_m&&Number.isFinite(e.y_min_m)&&(t.y_min_m=e.y_min_m),"number"==typeof e.y_max_m&&Number.isFinite(e.y_max_m)&&(t.y_max_m=e.y_max_m),e.color&&(t.color=e.color),e.texture&&(t.texture=e.texture),t})}function xe(e,t,o){return Math.max(t,Math.min(o,e))}function fe(e){return Math.round(1e3*e)/1e3}function ge(e,t){const o=function(e,t,o){const r=e.map(e=>({start:xe(Math.min(e.start,e.end),0,o),end:xe(Math.max(e.start,e.end),0,o)})).filter(e=>e.end-e.start>1e-6).sort((e,t)=>e.start-t.start),n=[];for(const e of r){const t=n[n.length-1];!t||e.start>t.end+1e-6?n.push(e):t.end=Math.max(t.end,e.end)}return n}(t,0,e),r=[];let n=0;for(const e of o)e.start>n+1e-6&&r.push({start:n,end:e.start}),n=Math.max(n,e.end);return n<e-1e-6&&r.push({start:n,end:e}),r}function we(e,t,o){return V(e,U(t,o))}function ye(e){const t=_(e.props.a,{x:e.position.x,z:e.position.z}),o=_(e.props.b,{x:e.position.x+1,z:e.position.z}),r=Math.max(.04,f(e.props.width,m));return{minX:Math.min(t.x,o.x)-r,maxX:Math.max(t.x,o.x)+r,minZ:Math.min(t.z,o.z)-r,maxZ:Math.max(t.z,o.z)+r}}function _e(e){return e.map(e=>`${e.x},${e.z}`).join(" ")}function Me(e,t){if(Array.isArray(e))for(const o of e)t.has(o)||(t.add(o),o.dispose());else t.has(e)||(t.add(e),e.dispose())}function be(e,t){const o=e.getAttribute("position"),r=e.getAttribute("normal"),n=e.getAttribute("uv");if(!o||!r||!n)return;const a=t.thicknessWorld/2;for(let e=0;e<n.count;e+=1){const i=r.getX(e),s=(r.getY(e),r.getZ(e)),l=o.getX(e),c=o.getY(e),u=o.getZ(e);let d=0,p=0;Math.abs(s)>=.5?(d=l+t.originX,p=c+t.originY):Math.abs(i)>=.5?(d=u+t.originZ+a,p=c+t.originY):(d=l+t.originX,p=u+t.originZ+a),n.setXY(e,d,p)}n.needsUpdate=!0}function ve(e,t){const o=new Set;for(const r of[...e.children]){const n=r;n.geometry&&"dispose"in n.geometry&&n.geometry.dispose(),t&&n.material&&Me(n.material,o),e.remove(r)}}function ke(e){return"door"===e?{fill:"rgba(251,146,60,0.20)",stroke:"rgba(251,146,60,0.92)",dash:[7,4]}:"window"===e?{fill:"rgba(56,189,248,0.18)",stroke:"rgba(56,189,248,0.92)",dash:[5,4]}:{fill:"rgba(251,191,36,0.12)",stroke:"rgba(251,191,36,0.92)",dash:[9,5]}}function ze(e,t,o,r){const n=o.y_max_m-o.y_min_m;if(o.width_m<=.12||n<=.12)return;const a=xe(.11*Math.min(o.width_m,n),.03,.09),i=.48*r,s=.34*r,l=F(e,A(o.texture,se("door"))),c=new e.MeshStandardMaterial({color:"#5b5044",roughness:.82,metalness:.05,map:l}),u=new e.MeshStandardMaterial({color:o.color??ie("door")??"#8f806a",roughness:.74,metalness:.08,map:l}),d=new e.BoxGeometry(a,n,i),p=new e.BoxGeometry(a,n,i),m=new e.BoxGeometry(o.width_m,a,i),h=new e.Mesh(d,c),x=new e.Mesh(p,c),f=new e.Mesh(m,c);for(const e of[h,x,f])e.userData.__toposyncAllowPickWhenGhostWalls=!0;const g=0+o.y_min_m+n/2;h.position.set(o.start_m+a/2,g,0),x.position.set(o.end_m-a/2,g,0),f.position.set(o.center_m,0+o.y_max_m-a/2,0);const w=xe(.02*a,.001,.004),y=o.width_m-2*a-2*w,_=n-a-w;if(y>.08&&_>.2){const r=new e.BoxGeometry(y,_,s),n=new e.Mesh(r,u);n.userData.__toposyncAllowPickWhenGhostWalls=!0,n.position.set(o.center_m,0+o.y_min_m+_/2,0),n.castShadow=!0,n.receiveShadow=!0,t.add(n)}else u.dispose();for(const e of[h,x,f])e.castShadow=!0,e.receiveShadow=!0,t.add(e)}function Se(e,t,o,r){const n=o.y_max_m-o.y_min_m;if(o.width_m<=.12||n<=.12)return;const a=xe(.09*Math.min(o.width_m,n),.025,.07),i=.35*r,s=.14*r,l=A(o.texture,se("window")),c=F(e,l),u=new e.MeshStandardMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.55,metalness:.18,map:c}),d=new e.BoxGeometry(o.width_m,a,i),p=new e.BoxGeometry(o.width_m,a,i),m=new e.BoxGeometry(a,n,i),h=new e.BoxGeometry(a,n,i),x=new e.Mesh(d,u),f=new e.Mesh(p,u),g=new e.Mesh(m,u),w=new e.Mesh(h,u);for(const e of[x,f,g,w])e.userData.__toposyncAllowPickWhenGhostWalls=!0;const y=0+o.y_min_m+n/2;x.position.set(o.center_m,0+o.y_max_m-a/2,0),f.position.set(o.center_m,0+o.y_min_m+a/2,0),g.position.set(o.start_m+a/2,y,0),w.position.set(o.end_m-a/2,y,0);for(const e of[x,f,g,w])e.castShadow=!0,e.receiveShadow=!0,t.add(e);const _=o.width_m-2.2*a,M=n-2.2*a;if(_<=.08||M<=.08)return;const b=new e.BoxGeometry(_,M,s);let v;v="glass"===l?new e.MeshPhysicalMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.1,metalness:0,transmission:.88,thickness:.05,transparent:!0,opacity:.55}):new e.MeshStandardMaterial({color:o.color??ie("window")??"#b9d8f4",roughness:.42,metalness:.12,map:c});const k=new e.Mesh(b,v);k.userData.__toposyncAllowPickWhenGhostWalls=!0,k.position.set(o.center_m,y,0),k.castShadow=!1,k.receiveShadow=!0,t.add(k)}function je({element:e,update:t,remove:o,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=g(e.props.color,p),u=C(e.props.texture,"none"),d=(0,n.useMemo)(()=>ue(e.props.openings),[e.props.openings]),m=(0,n.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]),h=(0,n.useMemo)(()=>L(_(e.props.a,{x:e.position.x,z:e.position.z}),_(e.props.b,{x:e.position.x+1,z:e.position.z})),[e]),x=(0,n.useMemo)(()=>[...d].sort((e,t)=>e.center_m-t.center_m||e.id.localeCompare(t.id)),[d]),f=(0,n.useMemo)(()=>{const e=me(d,h,3.2),t=new Map;for(const o of e)t.set(o.id,o);return t},[d,h]);function w(e){t({props:{openings:he(e)}})}function y(e,t){w(d.map(o=>o.id===e?{...o,...t}:o))}function M(e){const t="door"===e?.9:"window"===e?1.2:1,o=Math.max(0,h),r=xe(t,Math.min(Q,o),o),n=pe({kind:e,center_m:h/2,width_m:r});w([...d,n])}return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s("ext.structural.wall.name")}),(0,r.jsxs)("div",{className:"cardMeta",children:[m.format(h)," m"]})]}),(0,r.jsxs)("div",{className:"cardBody",children:[s("ext.structural.editor.preview")," • ",x.length," ",s("ext.structural.editor.openings")]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:c,onChange:e=>t({props:{color:e.target.value}})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_texture")}),(0,r.jsxs)("select",{className:"input",value:u,onChange:e=>t({props:{texture:C(e.target.value,u)}}),children:[(0,r.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"brick",children:s("ext.structural.editor.texture.brick")}),(0,r.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")})]})]})]}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",style:{alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.openings")}),(0,r.jsxs)("div",{className:"rowWrap",style:{gap:8},children:[(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("opening"),children:["+ ",s("ext.structural.tools.wall_opening")]}),(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("door"),children:["+ ",s("ext.structural.tools.wall_door")]}),(0,r.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>M("window"),children:["+ ",s("ext.structural.tools.wall_window")]})]})]}),0===x.length?(0,r.jsx)("div",{className:"cardBody",children:s("ext.structural.editor.openings_empty")}):null,x.map(e=>{const t=e.kind,o=A(e.texture,se(t)),n=e.color??ie(t)??"#8f806a",a=f.get(e.id)??null,i="opening"===t?s("ext.structural.editor.opening_height_full"):a?s("ext.structural.editor.opening_height_range",{yMin:m.format(a.y_min_m),yMax:m.format(a.y_max_m)}):null,l=Math.max(0,h),c=Math.min(Q,l),u=xe(e.width_m,c,Math.max(c,l)),p=u/2,x=Math.max(p,l-u/2),g=xe(e.center_m,p,x);return(0,r.jsxs)("div",{className:"card",style:{marginTop:10},children:[(0,r.jsxs)("div",{className:"cardHeaderRow",children:[(0,r.jsx)("div",{className:"cardTitle",children:s(`ext.structural.editor.kind.${t}`)}),(0,r.jsxs)("div",{className:"cardMeta",children:[m.format(u)," m"]})]}),i?(0,r.jsx)("div",{className:"cardMeta",style:{marginTop:6},children:i}):null,(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_kind")}),(0,r.jsxs)("select",{className:"input",value:t,onChange:o=>{const r="opening"===(n=o.target.value)||"door"===n||"window"===n?n:t;var n;const a={kind:r};!e.color&&ie(r)&&(a.color=ie(r)),e.texture&&e.texture!==se(t)||(a.texture=se(r)),y(e.id,a)},children:[(0,r.jsx)("option",{value:"opening",children:s("ext.structural.editor.kind.opening")}),(0,r.jsx)("option",{value:"door",children:s("ext.structural.editor.kind.door")}),(0,r.jsx)("option",{value:"window",children:s("ext.structural.editor.kind.window")})]})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_center")}),(0,r.jsx)("input",{className:"input",type:"number",step:.05,value:g,onChange:t=>{const o=Number(t.target.value);Number.isFinite(o)&&y(e.id,{center_m:xe(o,p,x)})}}),(0,r.jsx)("div",{className:"cardMeta",children:s("ext.structural.editor.opening_center_hint",{start:m.format(0),end:m.format(h)})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_width")}),(0,r.jsx)("input",{className:"input",type:"number",step:.05,min:c,max:Math.max(c,l),value:u,onChange:t=>{const o=Number(t.target.value);if(!Number.isFinite(o))return;const r=xe(o,c,Math.max(c,l)),n=r/2,a=Math.max(n,l-r/2);y(e.id,{width_m:r,center_m:xe(e.center_m,n,a)})}})]})]}),"opening"!==t?(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_color")}),(0,r.jsx)("input",{className:"input",type:"color",value:n,onChange:t=>y(e.id,{color:t.target.value})})]}),(0,r.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,r.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_texture")}),(0,r.jsxs)("select",{className:"input",value:o,onChange:t=>y(e.id,{texture:A(t.target.value,o)}),children:[(0,r.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,r.jsx)("option",{value:"wood",children:s("ext.structural.editor.texture.wood")}),(0,r.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")}),(0,r.jsx)("option",{value:"glass",children:s("ext.structural.editor.texture.glass")})]})]})]}):null,(0,r.jsx)("div",{className:"rowWrap",children:(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:()=>{return t=e.id,void w(d.filter(e=>e.id!==t));var t},children:s("core.actions.delete")})})]},e.id)}),(0,r.jsx)("div",{className:"sectionDivider"}),(0,r.jsxs)("div",{className:"rowWrap",children:[(0,r.jsx)("button",{className:"dangerButton",type:"button",onClick:o,children:s("core.actions.delete")}),(0,r.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}const Ne={id:"structure",name:{key:"core.ui.tools.group.structure",fallback:"Structure"},order:20},Te={id:"areas",name:{key:"core.ui.tools.group.areas",fallback:"Areas"},order:30};function We(e,t,o){const r={x:(t.x+o.x)/2,z:(t.z+o.z)/2};return e.createElement(c,{name:"",position:{x:r.x,y:0,z:r.z},props:{a:t,b:o,color:p,width:m,openings:[]}})}function Pe(e,t){const o=J(t),r=function(){try{const e=localStorage.getItem(x);if(e&&w(e))return e}catch{}return h}();return e.createElement(u,{name:"",position:{x:o.x,y:0,z:o.z},props:{vertices:t,fill:r,opacity:1}})}function Ce(e,t){const o=J(t);return e.createElement(d,{name:"",position:{x:o.x,y:0,z:o.z},props:{vertices:t,depth_m:1.4}})}function De(e,t){const o=t.length;if(!(o<2))for(let r=0;r<o;r++)We(e,t[r],t[(r+1)%o])}function Ae(e,t,o){return Math.max(t,Math.min(o,e))}function Fe(e,t){return{x:e.x+t.x,z:e.z+t.z}}function Ee(e,t){return{x:e.x*t,z:e.z*t}}function Re(e,t,o,r){const n=function(e,t){return e.x*t.x+e.z*t.z}(function(e,t){return{x:e.x-t.x,z:e.z-t.z}}(e,t),o),a=Math.max(0,Math.min(r,n));return{point:Fe(t,Ee(o,a)),scalar:a}}function Be(e,t,o){const r=L(t,o);return L(e,r<=1e-6?t:Re(e,t,{x:(o.x-t.x)/r,z:(o.z-t.z)/r},r).point)}function Ie(e,t){const o="door"===(r=t.kind)?{stroke:i("#fb923c",.92),fill:i("#fb923c",.22),dash:[8,6],labelKey:"ext.structural.tools.wall_door",fallback:"Door",descriptionKey:"ext.structural.tools.wall_door_desc",descriptionFallback:"Place a door cutout on a wall.",icon:"door-open",order:20}:"window"===r?{stroke:i("#38bdf8",.92),fill:i("#38bdf8",.22),dash:[5,5],labelKey:"ext.structural.tools.wall_window",fallback:"Window",descriptionKey:"ext.structural.tools.wall_window_desc",descriptionFallback:"Place a window cutout on a wall.",icon:"window-maximize",order:30}:{stroke:i("#fbbf24",.92),fill:i("#fbbf24",.22),dash:[9,4],labelKey:"ext.structural.tools.wall_opening",fallback:"Opening",descriptionKey:"ext.structural.tools.wall_opening_desc",descriptionFallback:"Hover a wall, click and drag to size. Click to place default width.",icon:"crop-simple",order:40};var r;return{id:"door"===t.kind?"com.toposync.structural.tool.door":"window"===t.kind?"com.toposync.structural.tool.window":"com.toposync.structural.tool.opening",name:{key:o.labelKey,fallback:o.fallback},description:{key:o.descriptionKey,fallback:o.descriptionFallback},icon:o.icon,group:Ne,order:o.order,createSession:e=>{let r=null,n=null,a=null,i=null,s=null,l=!1;function u(){a=null,i=null,s=null,l=!1}function d(e,o,r,n){const a=Math.min(Math.max(Q,.2),e),i=Math.abs(r-o);let s=i,l=(o+r)/2;return n?(s=2*i,l=o):i<.04&&(s=Math.min(e,Math.max(a,function(e){return"door"===e?.9:"window"===e?1.2:1}(t.kind))),l=o),s=Ae(s,a,e),l=Ae(l,s/2,e-s/2),{start:l-s/2,end:l+s/2,center:l,width:s}}function p(t){if(a)return;const o=function(e){const t=[];for(const o of e.getElements()){if(o.type!==c)continue;const e=_(o.props.a,{x:o.position.x-.5,z:o.position.z}),r=_(o.props.b,{x:o.position.x+.5,z:o.position.z}),n=L(e,r);if(n<=1e-6)continue;const a={x:(r.x-e.x)/n,z:(r.z-e.z)/n},i={x:-a.z,z:a.x};t.push({id:o.id,a:e,b:r,dir:a,normal:i,length:n,width:Math.max(.04,f(o.props.width,m)),props:o.props})}return t}(e),i=function(e,t){let o=null,r=Number.POSITIVE_INFINITY;for(const n of e){const e=Be(t,n.a,n.b);e>Math.max(.45,3.5*n.width)||e<r&&(r=e,o=n)}return o}(o,t);r=i,n=i?Re(t,i.a,i.dir,i.length).scalar:null}function h(e,t,o){const r=t.worldToScreen(o.a),n=t.worldToScreen(o.b);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,n.y),e.strokeStyle="rgba(255,255,255,0.55)",e.lineWidth=2.25,e.setLineDash([6,6]),e.stroke()}function x(e,t,r,n,a,i){const s=d(r.length,n,a,i),l=Fe(r.a,Ee(r.dir,s.start)),c=Fe(r.a,Ee(r.dir,s.end)),u=Math.max(.09,r.width/2),p=[Fe(l,Ee(r.normal,u)),Fe(c,Ee(r.normal,u)),Fe(c,Ee(r.normal,-u)),Fe(l,Ee(r.normal,-u))].map(e=>t.worldToScreen(e));e.beginPath(),e.moveTo(p[0].x,p[0].y);for(let t=1;t<p.length;t++)e.lineTo(p[t].x,p[t].y);e.closePath(),e.fillStyle=o.fill,e.fill(),e.strokeStyle=o.stroke,e.lineWidth=2,e.setLineDash(o.dash),e.stroke(),e.setLineDash([]);const m=t.worldToScreen(Fe(r.a,Ee(r.dir,s.center))),h=`${s.width.toFixed(2)} m`;e.font="12px ui-sans-serif, system-ui";const x=e.measureText(h).width+16,f=m.x-x/2,g=m.y-Math.max(28,24+12/Math.max(1,t.scale));e.fillStyle="rgba(8,12,26,0.86)",e.fillRect(f,g,x,20),e.strokeStyle="rgba(255,255,255,0.18)",e.lineWidth=1,e.strokeRect(f+.5,g+.5,x-1,19),e.fillStyle="rgba(230,232,242,0.95)",e.textAlign="center",e.textBaseline="middle",e.fillText(h,m.x,g+10)}return{onPointerEvent:o=>{if("cancel"!==o.kind){if("move"===o.kind)return a?(l=o.shiftKey,void(s=Re(o.world,a.a,a.dir,a.length).scalar)):void p(o.world);if("down"===o.kind){if(0!==o.button)return;return p(o.world),r&&null!=n?(a=r,i=n,s=n,void(l=o.shiftKey)):void u()}if("up"===o.kind){if(0!==o.button)return;if(!a||null==i)return;l=o.shiftKey,s=Re(o.world,a.a,a.dir,a.length).scalar,function(){if(!a||null==i||null==s)return;const o=d(a.length,i,s,l),r=e.getElements().find(e=>e.id===a?.id),n=ue(r?.props.openings??a.props.openings),c=pe({kind:t.kind,center_m:o.center,width_m:o.width});e.updateElement(a.id,{props:{openings:he([...n,c])}}),e.openEditor(a.id)}(),u(),p(o.world)}}else u()},onKeyDown:e=>{"Escape"===e.key&&u()},renderOverlay2D:({ctx:e,viewport:t})=>{e.save(),a&&null!=i&&null!=s?(h(e,t,a),x(e,t,a,i,s,l)):r&&null!=n&&(h(e,t,r),x(e,t,r,n,n,!1)),e.restore()},getCursor:()=>r?"copy":"crosshair"}}}}function Ge(e,t){return{id:t.withWalls?"com.toposync.structural.tool.area_square_walls":"com.toposync.structural.tool.area_square",name:{key:t.withWalls?"ext.structural.tools.area_square_walls":"ext.structural.tools.area_square",fallback:t.withWalls?"Rectangular room":"Rectangular area"},icon:t.withWalls?"border-all":"vector-square",group:Te,order:t.withWalls?10:30,createSession:e=>{let o=null,r=null;function n(){o=null,r=null}return{onPointerEvent:a=>{if("cancel"!==a.kind)if("move"!==a.kind){if("down"===a.kind&&0===a.button)return o?void function(r){if(!o)return;const a=function(e,t){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.z,t.z),a=Math.max(e.z,t.z);return[{x:o,z:n},{x:r,z:n},{x:r,z:a},{x:o,z:a}]}(o,r);if(L(a[0],a[2])<.12)return void n();const i=Pe(e,a);t.withWalls&&De(e,a),i&&e.openEditor(i),n()}(a.world):(o=a.world,void(r=a.world))}else o&&(r=a.world);else n()},onKeyDown:e=>{"Escape"===e.key&&n()},renderOverlay2D:({ctx:e,viewport:t})=>{if(!o||!r)return;const n=[o,{x:r.x,z:o.z},r,{x:o.x,z:r.z}].map(e=>t.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#fbbf24",.12),e.fill(),e.strokeStyle=i("#fbbf24",.8),e.lineWidth=2,e.setLineDash([6,6]),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}}}function Oe(e){return{id:"com.toposync.structural.tool.pool_square",name:{key:"ext.structural.tools.pool_square",fallback:"Rectangular pool"},icon:"water-ladder",group:Te,order:50,createSession:e=>{let t=null,o=null;function r(){t=null,o=null}return{onPointerEvent:n=>{if("cancel"!==n.kind)if("move"!==n.kind){if("down"===n.kind&&0===n.button)return t?void function(o){if(!t)return;const n=function(e,t){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.z,t.z),a=Math.max(e.z,t.z);return[{x:o,z:n},{x:r,z:n},{x:r,z:a},{x:o,z:a}]}(t,o);if(L(n[0],n[2])<.12)return void r();const a=Ce(e,n);a&&e.openEditor(a),r()}(n.world):(t=n.world,void(o=n.world))}else t&&(o=n.world);else r()},onKeyDown:e=>{"Escape"===e.key&&r()},renderOverlay2D:({ctx:e,viewport:r})=>{if(!t||!o)return;const n=[t,{x:o.x,z:t.z},o,{x:t.x,z:o.z}].map(e=>r.worldToScreen(e));e.save(),e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStyle=i("#0ea5e9",.12),e.fill(),e.strokeStyle=i("#38bdf8",.8),e.lineWidth=2,e.setLineDash([6,6]),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}}}function $e(e,t){return{id:t.withWalls?"com.toposync.structural.tool.area_polygon_walls":"com.toposync.structural.tool.area_polygon",name:{key:t.withWalls?"ext.structural.tools.area_polygon_walls":"ext.structural.tools.area_polygon",fallback:t.withWalls?"Freeform room":"Freeform area"},icon:t.withWalls?"object-group":"draw-polygon",group:Te,order:t.withWalls?20:40,createSession:e=>{const o=[];let r=null;function n(){o.splice(0,o.length),r=null}function a(){if(o.length<3)return void n();const r=Pe(e,[...o]);t.withWalls&&De(e,o),r&&e.openEditor(r),n()}return{onPointerEvent:e=>{"cancel"!==e.kind?"move"!==e.kind?"dblclick"!==e.kind?"down"===e.kind&&0===e.button&&(function(e){if(o.length<3)return!1;const t=o[0];return L(e.world,t)<.22}(e)?a():(o.push(e.world),r=e.world)):a():r=e.world:n()},onKeyDown:e=>{"Escape"===e.key&&n(),"Enter"===e.key&&a(),("Backspace"===e.key||"Delete"===e.key)&&o.length>0&&o.pop()},renderOverlay2D:({ctx:e,viewport:t})=>{if(0===o.length)return;const n=o.map(e=>t.worldToScreen(e)),a=r?t.worldToScreen(r):null;if(e.save(),o.length>=2){e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);a&&e.lineTo(a.x,a.y),e.strokeStyle=i("#fbbf24",.85),e.lineWidth=2,e.setLineDash([6,6]),e.stroke()}for(let t=0;t<n.length;t++){const r=n[t],a=0===t&&o.length>=3;e.beginPath(),e.arc(r.x,r.y,a?6:5,0,2*Math.PI),e.fillStyle=i(a?"#22c55e":"#fbbf24",.85),e.fill(),e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=2,e.stroke()}e.restore()},getCursor:()=>"crosshair"}}}}const qe={en:{"ext.structural.wall.name":"Wall","ext.structural.wall.desc":"Simple wall (line) in 2D.","ext.structural.area.name":"Area","ext.structural.area.desc":"Area (polygon) in 2D.","ext.structural.pool.name":"Pool","ext.structural.pool.desc":"Swimming pool (hole) in 2D.","ext.structural.tools.wall":"Wall","ext.structural.tools.wall_opening":"Opening","ext.structural.tools.wall_opening_desc":"Floor-to-ceiling wall cutout. Hover a wall, click and drag to size. Click to place default width. Hold Shift for symmetric sizing.","ext.structural.tools.wall_door":"Door","ext.structural.tools.wall_door_desc":"Place a door cutout on a wall.","ext.structural.tools.wall_window":"Window","ext.structural.tools.wall_window_desc":"Place a window cutout on a wall.","ext.structural.tools.area_square":"Rectangular area","ext.structural.tools.area_polygon":"Freeform area","ext.structural.tools.area_square_walls":"Rectangular room","ext.structural.tools.area_polygon_walls":"Freeform room","ext.structural.tools.pool_square":"Rectangular pool","ext.structural.tools.pool_polygon":"Freeform pool","ext.structural.editor.wall_color":"Wall color","ext.structural.editor.wall_texture":"Wall texture","ext.structural.editor.openings":"Openings","ext.structural.editor.openings_empty":"No openings yet. Use tools or add one here.","ext.structural.editor.opening_kind":"Type","ext.structural.editor.opening_center":"Position (m)","ext.structural.editor.opening_center_hint":"Along the wall: {{start}} m = start (1st point), {{end}} m = end (2nd point).","ext.structural.editor.opening_width":"Width (m)","ext.structural.editor.opening_height_full":"Height: floor to ceiling.","ext.structural.editor.opening_height_range":"Height: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Color","ext.structural.editor.opening_texture":"Texture","ext.structural.editor.kind.opening":"Opening","ext.structural.editor.kind.door":"Door","ext.structural.editor.kind.window":"Window","ext.structural.editor.area_name":"Area name (optional)","ext.structural.editor.area_color":"Area color","ext.structural.editor.floor_texture":"Floor texture","ext.structural.editor.transparent":"Transparent","ext.structural.editor.texture.none":"None","ext.structural.editor.texture.brick":"Brick","ext.structural.editor.texture.concrete":"Concrete","ext.structural.editor.texture.wood":"Wood","ext.structural.editor.texture.glass":"Glass","ext.structural.editor.texture.grass":"Grass","ext.structural.editor.pool_name":"Pool name (optional)","ext.structural.editor.pool_depth":"Depth (m)","ext.structural.editor.preview":"Preview"},"pt-BR":{"ext.structural.wall.name":"Parede","ext.structural.wall.desc":"Parede simples (linha) em 2D.","ext.structural.area.name":"Área","ext.structural.area.desc":"Área (polígono) em 2D.","ext.structural.pool.name":"Piscina","ext.structural.pool.desc":"Piscina (buraco) em 2D.","ext.structural.tools.wall":"Parede","ext.structural.tools.wall_opening":"Abertura","ext.structural.tools.wall_opening_desc":"Recorte do piso ao teto. Passe sobre a parede, clique e arraste para dimensionar. Clique para largura padrão. Segure Shift para simetria.","ext.structural.tools.wall_door":"Porta","ext.structural.tools.wall_door_desc":"Adiciona um recorte de porta na parede.","ext.structural.tools.wall_window":"Janela","ext.structural.tools.wall_window_desc":"Adiciona um recorte de janela na parede.","ext.structural.tools.area_square":"Área retangular","ext.structural.tools.area_polygon":"Área livre","ext.structural.tools.area_square_walls":"Ambiente retangular","ext.structural.tools.area_polygon_walls":"Ambiente livre","ext.structural.tools.pool_square":"Piscina retangular","ext.structural.tools.pool_polygon":"Piscina livre","ext.structural.editor.wall_color":"Cor da parede","ext.structural.editor.wall_texture":"Textura da parede","ext.structural.editor.openings":"Aberturas","ext.structural.editor.openings_empty":"Sem aberturas ainda. Use as ferramentas ou adicione aqui.","ext.structural.editor.opening_kind":"Tipo","ext.structural.editor.opening_center":"Posição (m)","ext.structural.editor.opening_center_hint":"Ao longo da parede: {{start}} m = início (1º ponto), {{end}} m = fim (2º ponto).","ext.structural.editor.opening_width":"Largura (m)","ext.structural.editor.opening_height_full":"Altura: piso ao teto.","ext.structural.editor.opening_height_range":"Altura: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Cor","ext.structural.editor.opening_texture":"Textura","ext.structural.editor.kind.opening":"Abertura","ext.structural.editor.kind.door":"Porta","ext.structural.editor.kind.window":"Janela","ext.structural.editor.area_name":"Nome da área (opcional)","ext.structural.editor.area_color":"Cor da área","ext.structural.editor.floor_texture":"Textura do chão","ext.structural.editor.transparent":"Transparente","ext.structural.editor.texture.none":"Nenhuma","ext.structural.editor.texture.brick":"Tijolo","ext.structural.editor.texture.concrete":"Concreto","ext.structural.editor.texture.wood":"Madeira","ext.structural.editor.texture.glass":"Vidro","ext.structural.editor.texture.grass":"Grama","ext.structural.editor.pool_name":"Nome da piscina (opcional)","ext.structural.editor.pool_depth":"Profundidade (m)","ext.structural.editor.preview":"Prévia"}};function Xe(e){var t;e.i18n.registerTranslations(qe),e.registerElementType((t=e.i18n,{type:c,layerGroup:"walls",name:{key:"ext.structural.wall.name",fallback:"Wall"},description:{key:"ext.structural.wall.desc",fallback:"Simple wall (line) in 2D."},defaultProps:{color:p,texture:"none",width:m,a:{x:0,z:0},b:{x:1,z:0},openings:[]},getMain2DBounds:ye,renderMain2DVector:({element:e})=>{const t=_(e.props.a,{x:e.position.x,z:e.position.z}),o=_(e.props.b,{x:e.position.x+1,z:e.position.z}),n=g(e.props.color,p),a=C(e.props.texture,"none"),s=Math.max(.04,f(e.props.width,m)),c=Math.max(.001,L(t,o)),u=Y(Z(o,t)),d=H(u),h=me(ue(e.props.openings),c,3.2),x=ge(c,h.map(e=>({start:e.start_m,end:e.end_m}))),w=Math.max(s/2,.09),y=i(l(n,"brick"===a?-.16:"concrete"===a?-.1:-.12),.98);return(0,r.jsxs)("g",{className:"mainVector2dWall",children:[x.map((e,o)=>{const n=we(t,u,e.start),a=we(t,u,e.end),i=Math.max(s/2,.02),l=V(n,U(d,i)),c=V(a,U(d,i)),p=V(a,U(d,-i)),m=V(n,U(d,-i));return(0,r.jsx)("polygon",{points:_e([l,c,p,m]),fill:y},`solid:${o}`)}),h.map(e=>{const o=we(t,u,e.start_m),n=we(t,u,e.end_m),a=V(o,U(d,w)),c=V(n,U(d,w)),p=V(n,U(d,-w)),m=V(o,U(d,-w)),h=function(e){const t=ie(e.kind)??"#cbd5e1",o=e.color??t,r=A(e.texture,se(e.kind));if("window"===e.kind){const e="glass"===r?o:"#b9d8f4";return{fill:i(e,.3),stroke:i(l(e,-.16),.56),accent:i(l(e,.34),.82),highlight:"rgba(255,255,255,0.38)"}}return"door"===e.kind?{fill:i(o,"wood"===r?.5:.38),stroke:i(l(o,-.28),.52),accent:i(l(o,.26),.42),highlight:"rgba(255,255,255,0.16)"}:{fill:"rgba(255,255,255,0.08)",stroke:i(o,.26),accent:i(l(o,.2),.22),highlight:"rgba(255,255,255,0.10)"}}(e),x=we(t,u,e.start_m+.18*e.width_m),f=we(t,u,e.end_m-.18*e.width_m);return(0,r.jsxs)("g",{className:`mainVector2dWallOpening mainVector2dWallOpening-${e.kind}`,children:[(0,r.jsx)("polygon",{points:_e([a,c,p,m]),fill:h.fill,stroke:h.stroke,strokeWidth:.018,vectorEffect:"non-scaling-stroke"}),(0,r.jsx)("line",{x1:x.x,y1:x.z,x2:f.x,y2:f.z,stroke:h.accent,strokeWidth:Math.max(.008,"window"===e.kind?.32*s:.18*s),strokeLinecap:"round"}),"window"===e.kind?(0,r.jsx)("line",{x1:V(x,U(d,.46*-w)).x,y1:V(x,U(d,.46*-w)).z,x2:V(f,U(d,.46*-w)).x,y2:V(f,U(d,.46*-w)).z,stroke:h.highlight,strokeWidth:.01,strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}):null]},e.id)})]})},create3D:({THREE:e,view:t},o)=>{const r=new e.Group,n=new e.Group,a=new e.Group,i=new e.Group,s=new e.Group;n.add(a),n.add(i),n.add(s),r.add(n);const l=new e.MeshStandardMaterial({color:p,roughness:.82,metalness:.05,flatShading:!0}),c=new e.MeshStandardMaterial({color:p,roughness:.86,metalness:.04,flatShading:!0}),u=new e.MeshBasicMaterial({color:"#000000",transparent:!0,opacity:0,depthWrite:!1});u.colorWrite=!1;let d="";function h(o){const r=_(o.props.a,{x:o.position.x-.5,z:o.position.z}),h=_(o.props.b,{x:o.position.x+.5,z:o.position.z}),x=Y(Z(h,r)),w=Math.max(.04,f(o.props.width,m)),y=Math.max(.15,t.wallHeight),M=Math.max(.001,L(r,h)),b=g(o.props.color,p),v=C(o.props.texture,"none"),k=function(e,t){if("none"===t)return null;if("brick"===t){const t=P(e,"wall:brick",z,{size:256,anisotropy:4});return t.repeat.set(1,1),t}if("concrete"===t){const t=P(e,"wall:concrete",j,{size:256,anisotropy:4});return t.repeat.set(.5,.5),t}return null}(e,v);n.position.set(r.x-o.position.x,0,r.z-o.position.z),n.rotation.set(0,Math.atan2(-x.z,x.x),0);const S=me(ue(o.props.openings),M,y),N=JSON.stringify({length:fe(M),thickness:fe(w),height:fe(y),openings:S.map(e=>({id:e.id,kind:e.kind,start:fe(e.start_m),end:fe(e.end_m),y0:fe(e.y_min_m),y1:fe(e.y_max_m),color:e.color??"",texture:e.texture??""}))});if(N!==d){d=N,ve(a,!1),ve(i,!0),ve(s,!1);const t=function(e,t,o){const r=[0,t];for(const e of o)r.push(xe(e.y_min_m,0,t)),r.push(xe(e.y_max_m,0,t));r.sort((e,t)=>e-t);const n=[];for(const e of r)(0===n.length||Math.abs(e-n[n.length-1])>1e-6)&&n.push(e);const a=[];for(let t=0;t<n.length-1;t++){const r=n[t],i=n[t+1];if(i-r<=1e-6)continue;const s=[];for(const e of o)e.y_min_m>=i-1e-6||e.y_max_m<=r+1e-6||s.push({start:e.start_m,end:e.end_m});const l=ge(e,s);for(const e of l)e.end-e.start<=1e-6||a.push({x0:e.start,x1:e.end,y0:r,y1:i})}return a}(M,y,S);for(const o of t){if(o.x1-o.x0<=1e-6||o.y1-o.y0<=1e-6)continue;const t=new e.BoxGeometry(o.x1-o.x0,o.y1-o.y0,w);be(t,{originX:(o.x0+o.x1)/2,originY:0+(o.y0+o.y1)/2,originZ:0,thicknessWorld:w});const r=[c,c,c,c,l,l],n=new e.Mesh(t,r);n.castShadow=!0,n.receiveShadow=!0,n.position.set((o.x0+o.x1)/2,0+(o.y0+o.y1)/2,0),a.add(n)}for(const t of S)"door"!==t.kind?"window"===t.kind&&Se(e,i,t,w):ze(e,i,t,w);for(const t of S){const o=t.y_max_m-t.y_min_m;if(t.width_m<=.08||o<=.08)continue;const r=new e.BoxGeometry(t.width_m,o,1.06*w),n=new e.Mesh(r,u);n.userData.__toposyncAllowPickWhenGhostWalls=!0,n.position.set(t.center_m,0+t.y_min_m+o/2,0),n.castShadow=!1,n.receiveShadow=!1,s.add(n)}}l.color.set(b),c.color.set(b),l.map!==k&&(l.map=k,l.needsUpdate=!0),l.roughness="brick"===v?.9:.82,l.metalness="brick"===v?.02:.05}return h(o),{object:r,update:h,dispose:()=>{ve(a,!1),ve(i,!0),ve(s,!1),l.dispose(),c.dispose(),u.dispose()}}},render2D:({ctx:e,element:t,viewport:o})=>{const r=_(t.props.a,{x:t.position.x,z:t.position.z}),n=_(t.props.b,{x:t.position.x+1,z:t.position.z}),a=g(t.props.color,p),i=Math.max(.04,f(t.props.width,m)),s=Math.max(.001,L(r,n)),l=Y(Z(n,r)),c=H(l),u=me(ue(t.props.openings),s,3.2),d=ge(s,u.map(e=>({start:e.start_m,end:e.end_m}))),h=Math.max(2,i*o.scale);e.save(),e.lineCap="round",e.lineJoin="round";for(const t of d){const n=o.worldToScreen(we(r,l,t.start)),i=o.worldToScreen(we(r,l,t.end));e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=h+3,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.stroke(),e.strokeStyle=a,e.lineWidth=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.stroke()}const x=Math.max(i/2,.09);for(const t of u){const n=we(r,l,t.start_m),a=we(r,l,t.end_m),i=o.worldToScreen(V(n,U(c,x))),s=o.worldToScreen(V(a,U(c,x))),u=o.worldToScreen(V(a,U(c,-x))),d=o.worldToScreen(V(n,U(c,-x))),p=ke(t.kind);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(s.x,s.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.fillStyle=p.fill,e.fill(),e.strokeStyle=p.stroke,e.lineWidth=1.8,e.setLineDash(p.dash),e.stroke(),e.setLineDash([])}e.restore()},hitTest2D:({element:e,world:t,viewport:o})=>{const r=_(e.props.a,{x:e.position.x,z:e.position.z}),n=_(e.props.b,{x:e.position.x+1,z:e.position.z}),a=Math.max(.04,f(e.props.width,m)),i=Math.max(a/2,.09,10/Math.max(1,o.scale));return function(e,t,o){const r=Z(o,t),n=Z(e,t),a=r.x*r.x+r.z*r.z;return a<=1e-9?Math.hypot(n.x,n.z):L(e,V(t,U(r,xe((n.x*r.x+n.z*r.z)/a,0,1))))}(t,r,n)<=i},renderEditorModal:({element:e,update:o,remove:n,close:a})=>(0,r.jsx)(je,{element:e,update:o,remove:n,close:a,i18n:t})})),e.registerElementType(B(e.i18n)),e.registerElementType(X(e.i18n));for(const t of(e.i18n,[{id:"com.toposync.structural.tool.wall",name:{key:"ext.structural.tools.wall",fallback:"Wall"},icon:"grip-lines",group:Ne,order:10,createSession:e=>{let t=null,o=null;function r(){t=null,o=null}return{onPointerEvent:n=>{var a;if("cancel"!==n.kind)if("move"!==n.kind){if("down"===n.kind&&0===n.button)return t?(a=n.world,void(t&&(L(t,a)<.05||We(e,t,a),r()))):(t=n.world,void(o=n.world))}else t&&(o=n.world);else r()},onKeyDown:e=>{"Escape"===e.key&&r()},renderOverlay2D:({ctx:e,viewport:r})=>{if(!t||!o)return;const n=r.worldToScreen(t),a=r.worldToScreen(o),s=Math.max(2,m*r.scale);e.save(),e.setLineDash([8,6]),e.lineCap="round",e.strokeStyle=i("#fbbf24",.85),e.lineWidth=s,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.stroke(),e.restore()},getCursor:()=>"crosshair"}}},Ie(0,{kind:"door"}),Ie(0,{kind:"window"}),Ie(0,{kind:"opening"}),Ge(0,{withWalls:!0}),$e(0,{withWalls:!0}),Ge(0,{withWalls:!1}),$e(0,{withWalls:!1}),Oe(),{id:"com.toposync.structural.tool.pool_polygon",name:{key:"ext.structural.tools.pool_polygon",fallback:"Freeform pool"},icon:"water",group:Te,order:60,createSession:e=>{const t=[];let o=null;function r(){t.splice(0,t.length),o=null}function n(){if(t.length<3)return void r();const o=Ce(e,[...t]);o&&e.openEditor(o),r()}return{onPointerEvent:e=>{"cancel"!==e.kind?"move"!==e.kind?"dblclick"!==e.kind?"down"===e.kind&&0===e.button&&(function(e){if(t.length<3)return!1;const o=t[0];return L(e.world,o)<.22}(e)?n():(t.push(e.world),o=e.world)):n():o=e.world:r()},onKeyDown:e=>{"Escape"===e.key&&r(),"Enter"===e.key&&n(),("Backspace"===e.key||"Delete"===e.key)&&t.length>0&&t.pop()},renderOverlay2D:({ctx:e,viewport:r})=>{if(0===t.length)return;const n=t.map(e=>r.worldToScreen(e)),a=o?r.worldToScreen(o):null;if(e.save(),t.length>=2){e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);a&&e.lineTo(a.x,a.y),e.strokeStyle=i("#38bdf8",.85),e.lineWidth=2,e.setLineDash([6,6]),e.stroke()}for(let o=0;o<n.length;o++){const r=n[o],a=0===o&&t.length>=3;e.beginPath(),e.arc(r.x,r.y,a?6:5,0,2*Math.PI),e.fillStyle=i(a?"#22c55e":"#38bdf8",.85),e.fill(),e.strokeStyle="rgba(0,0,0,0.35)",e.lineWidth=2,e.stroke()}e.restore()},getCursor:()=>"crosshair"}}}]))e.registerEditorTool(t)}}}]);