diff --git a/asset-manifest.json b/asset-manifest.json index 37c6408c3..e930d1891 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,8 +1,8 @@ { "files": { "main.css": "/aladdin/static/css/main.c1ee157d.chunk.css", - "main.js": "/aladdin/static/js/main.d3157261.chunk.js", - "main.js.map": "/aladdin/static/js/main.d3157261.chunk.js.map", + "main.js": "/aladdin/static/js/main.c62f7be7.chunk.js", + "main.js.map": "/aladdin/static/js/main.c62f7be7.chunk.js.map", "runtime-main.js": "/aladdin/static/js/runtime-main.b3c25317.js", "runtime-main.js.map": "/aladdin/static/js/runtime-main.b3c25317.js.map", "static/css/2.447301e6.chunk.css": "/aladdin/static/css/2.447301e6.chunk.css", @@ -203,6 +203,6 @@ "static/css/2.447301e6.chunk.css", "static/js/2.663ef815.chunk.js", "static/css/main.c1ee157d.chunk.css", - "static/js/main.d3157261.chunk.js" + "static/js/main.c62f7be7.chunk.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index 9e4e81a5b..a906f5760 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -
0&&De&&Object(gf.jsx)(Qf,{cz:O[0].lz,points:De}),k&&!A&&Object(gf.jsxs)("group",{position:[0,0,b+.15],children:[Object(gf.jsx)(jp,{position:[Ae.x,Ae.y,Ae.z],onPointerDown:function(){if(fe.current=!0,U(!0),Hh.set(Ae.x,Ae.y,ie),l&&O[0]){var e=Ew.getState().cameraDirection,t=Math.atan2(e.z,e.y),a=O[0].relativeAngle;zh.set(-vt-t,0,a,"ZXY")}B(ge.Left),Et.getState().setEnableOrbitController(!1)}}),Object(gf.jsx)(jp,{position:[Pe.x,Pe.y,Pe.z],onPointerDown:function(e){if(Ce(t.id,e,X.Select),fe.current=!0,pe.current=R,U(!0),Hh.set(Pe.x,Pe.y,ie),l){var a=-Math.atan2(se.position.x-n,se.position.y-c)-l.rotation[2];zh.set(-vt,0,a,"ZXY")}B(ge.Mid),Et.getState().setEnableOrbitController(!1),I((function(e){e.resizeHandleType=K.Top,e.selectedElementHeight=ie+t.thickness}))},onPointerOver:function(){I((function(e){e.hoveredHandle=ge.Mid,e.selectedElementHeight=ie+t.thickness,e.selectedElementX=be.x,e.selectedElementY=be.y}))}}),Object(gf.jsx)(jp,{position:[Te.x,Te.y,Te.z],onPointerDown:function(){if(fe.current=!0,U(!0),Hh.set(Te.x,Te.y,ie),l&&O[0]){var e=Ew.getState().cameraDirection,t=Math.atan2(e.z,e.y),a=O[0].relativeAngle;zh.set(-vt-t,0,a,"ZXY")}B(ge.Right),Et.getState().setEnableOrbitController(!1)}})]}),E&&Object(gf.jsx)(Lt.f,{name:"Roof Intersection Plane",ref:re,args:[1e3,100],visible:!1,position:Hh,rotation:zh,onPointerMove:function(e){if(re.current&&fe.current){!function(e){ue.x=e.offsetX/ce.domElement.clientWidth*2-1,ue.y=-e.offsetY/ce.domElement.clientHeight*2+1,de.setFromCamera(ue,se)}(e);var o=de.intersectObjects([re.current]);if(o[0]&&l){var i=o[0].point;if(i.z<.001)return;var r=O[0],n=(new Me.Vector3).subVectors(r.rightPoint,r.leftPoint).length();switch(G){case ge.Left:var c=Pe.clone().sub(Hh).applyEuler(new Me.Euler(0,0,-zh.z)),s=i.clone().sub(new Me.Vector3(l.cx,l.cy,l.cz)).applyEuler(new Me.Euler(0,0,-l.rotation[2])).sub(Hh).applyEuler(new Me.Euler(0,0,-zh.z)),d=(new Me.Vector3).subVectors(s,c).x;_(Tw.clamp(-d,.1-te,n/2-.01));break;case ge.Right:var u=Pe.clone().sub(Hh).applyEuler(new Me.Euler(0,0,-zh.z)),f=i.clone().sub(new Me.Vector3(l.cx,l.cy,l.cz)).applyEuler(new Me.Euler(0,0,-l.rotation[2])).sub(Hh).applyEuler(new Me.Euler(0,0,-zh.z)),h=(new Me.Vector3).subVectors(f,u).x;le(Tw.clamp(h,.1-Z,n/2-.01));break;case ge.Mid:var p=Math.max(0,i.z-l.lz-.3-oe);Ew.getState().updateRoofRiseById(a,p,ie+t.thickness)}}}},onPointerUp:function(){switch(G){case ge.Mid:wp(a,pe.current,R);break;case ge.Left:case ge.Right:xe(a,Z,te),function(e,t,l,a,o){var i={name:"Resize Hip Roof Ridge",timestamp:Date.now(),resizedElementId:e,resizedElementType:V.Roof,oldLeftRidgeLength:t,oldRightRidgeLength:l,newLeftRidgeLength:a,newRightRidgeLength:o,undo:function(){xe(i.resizedElementId,i.oldLeftRidgeLength,i.oldRightRidgeLength,!0)},redo:function(){xe(i.resizedElementId,i.newLeftRidgeLength,i.newRightRidgeLength,!0)}};Ew.getState().addUndoable(i)}(a,h,p,Z,te)}fe.current=!1,U(!1),B(ge.Null),Et.getState().setEnableOrbitController(!0)},children:Object(gf.jsx)("meshBasicMaterial",{side:Me.DoubleSide,transparent:!0,opacity:.5})})]})},Mh=n.a.memo(Dh,zp),Wh=new Me.Vector3,Ih=new Me.Euler,Ch=new Me.Vector3(0,0,1),Oh=n.a.memo((function(e){var t=e.roofSegments,l=e.thickness,a=e.lineWidth,o=e.lineColor,i=Object(r.useMemo)((function(){return t.reduce((function(e,t){return e.concat(t.points[1])}),[t[0].points[0]])}),[t]),c=Object(r.useMemo)((function(){return t.reduce((function(e,t){return e.concat(t.points[6].clone())}),[t[0].points[7].clone()])}),[t]),s=Object(r.useMemo)((function(){return Object(gf.jsx)(Jl.a,{points:i,lineWidth:a,color:o})}),[i,a,o]);if(t.length<2)return null;var d=Math.abs(t[0].points[0].z-t[0].points[3].z)<.1;return Object(gf.jsxs)(gf.Fragment,{children:[!d&&Object(gf.jsx)(Jl.a,{points:c,lineWidth:a,color:o}),s,Object(gf.jsx)("group",{position:[0,0,l],children:s}),t.map((function(e,t){return Object(gf.jsxs)(n.a.Fragment,{children:[!d&&Object(gf.jsx)(Jl.a,{points:[e.points[7],e.points[4]],lineWidth:a,color:o}),Object(gf.jsx)(Jl.a,{points:[e.points[4],e.points[0]],lineWidth:a,color:o})]},t)}))]})})),Fh=function(e){var t=e.roofModel,l=e.foundationModel,a=t.id,i=t.wallsId,c=t.cx,s=t.cy,d=t.lz,p=t.textureType,y=t.color,g=void 0===y?"white":y,m=t.sideColor,w=void 0===m?"white":m,x=t.thickness,v=void 0===x?.2:x,b=t.locked,A=t.lineColor,T=void 0===A?"black":A,P=t.lineWidth,S=void 0===P?.2:P,j=t.roofType,H=t.foundationId,z=t.ridgeWidth,R=void 0===z?1:z,D=t.rise,M=void 0===D?d:D,W=t.ceiling,I=void 0!==W&&W,C=t.frontRidge,O=t.backRidge,F=Mp(p),k=_f(a),Y=Vm.getWireframetStyle(T,S,k,b),L=Object(u.a)(Y,2);T=L[0],S=L[1];var E=Ew(si),U=Ew(qc),N=Ew(o.shadowEnabled),J=Ew((function(e){return e.ray})),G=Ew((function(e){return e.mouse})),B=Object(r.useState)(R),q=Object(u.a)(B,2),Q=q[0],Z=q[1],_=Object(r.useState)(null),$=Object(u.a)(_,2),ee=$[0],te=$[1],le=Object(r.useState)(!1),ae=Object(u.a)(le,2),oe=ae[0],ie=ae[1],re=Object(r.useState)(ge.Null),ne=Object(u.a)(re,2),ce=ne[0],se=ne[1],de=Object(r.useState)(null),ue=Object(u.a)(de,2),fe=ue[0],pe=ue[1],ye=Object(r.useRef)(Q),me=Object(r.useRef)(M),we=Object(r.useRef)(null),xe=Object(r.useRef)(!1),ve=Object(Se.f)(),be=ve.gl,Ae=ve.camera,Te=M<.01,Pe=function(e,t){E((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&i.type===V.Roof&&i.roofType===It.Mansard){i.ridgeWidth=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},je=Ip(H,a,i),He=je.currentWallArray,ze=je.isLoopRef,Re=Fp(He,M),De=Re.highestWallHeight,We=Re.topZ;Lp(t,De);var Ie=Object(r.useMemo)((function(){if(He.length<2)return new Me.Vector3;var e=function(e){var t,l=[],a=e.length,o=Object(f.a)(e);try{for(o.s();!(t=o.n()).done;){var i=t.value;void 0!==i.leftPoint[0]&&void 0!==i.leftPoint[1]&&l.push({x:i.leftPoint[0],y:i.leftPoint[1]})}}catch(r){o.e(r)}finally{o.f()}return ze.current||!e[a-1].rightPoint[0]&&0!==e[a-1].rightPoint[0]||!e[a-1].rightPoint[1]&&0!==e[a-1].rightPoint[1]||l.push({x:e[a-1].rightPoint[0],y:e[a-1].rightPoint[1]}),l}(He),t=Tw.calculatePolygonCentroid(e);return Number.isNaN(t.x)||Number.isNaN(t.y)?new Me.Vector3:new Me.Vector3(t.x,t.y,We)}),[He,We]),Ce=Object(r.useMemo)((function(){var e=He.map((function(e){var t;return Vm.getWallNormal(e).multiplyScalar(null!==(t=e.eavesLength)&&void 0!==t?t:0)}));if(!ze.current&&0!==e.length){var t=(new Me.Vector3).subVectors(new Me.Vector3(He[He.length-1].rightPoint[0],He[He.length-1].rightPoint[1]),new Me.Vector3(He[0].leftPoint[0],He[0].leftPoint[1])).applyEuler(Mt).normalize().multiplyScalar(.3);e.push(t)}return e}),[He]),Oe=Object(r.useMemo)((function(){var e=He.map((function(e,t){return{leftPoint:new Me.Vector3(e.leftPoint[0],e.leftPoint[1]).add(Ce[t]),rightPoint:new Me.Vector3(e.rightPoint[0],e.rightPoint[1]).add(Ce[t])}}));return ze.current||0===e.length||e.push({leftPoint:new Me.Vector3(He[He.length-1].rightPoint[0],He[He.length-1].rightPoint[1]).add(Ce[Ce.length-1]),rightPoint:new Me.Vector3(He[0].leftPoint[0],He[0].leftPoint[1]).add(Ce[Ce.length-1])}),e}),[He,Ce]),Fe=Object(r.useMemo)((function(){var e=He.map((function(e,t){var l=new Me.Vector3(e.leftPoint[0],e.leftPoint[1]),a=new Me.Vector3(e.rightPoint[0],e.rightPoint[1]),o=(new Me.Vector3).subVectors(Ie,l).setZ(0).normalize().multiplyScalar(Q),i=(new Me.Vector3).subVectors(Ie,a).setZ(0).normalize().multiplyScalar(Q);return l.add(o).setZ(We),a.add(i).setZ(We),{leftPoint:l,rightPoint:a}}));return ze.current||0===e.length||e.push({leftPoint:e[e.length-1].rightPoint,rightPoint:e[0].leftPoint}),e}),[He,Ie,Q]),ke=Object(r.useMemo)((function(){return Ch.clone().multiplyScalar(v)}),[v]),Ye=Object(r.useMemo)((function(){var e=[];if(He.length<2)return e;for(var t=function(){for(var e=1/0,t=0;t 0&&Object(gf.jsx)(Oh,{roofSegments:Ye,thickness:v,lineColor:T,lineWidth:S})]})}),I&&M>0&&Object(gf.jsx)(Qf,{points:Ee,cz:He[0].lz}),k&&!b&&Object(gf.jsxs)("group",{position:[Ie.x,Ie.y,Ie.z+v],children:[Object(gf.jsx)(jp,{position:[0,0,.3],onPointerDown:function(e){if(Ve(t.id,e,X.Select),xe.current=!0,me.current=M,ie(!0),Wh.set(Ie.x,Ie.y,We),l){var a=-Math.atan2(Ae.position.x-c,Ae.position.y-s)-l.rotation[2];Ih.set(-vt,0,a,"ZXY")}se(ge.Top),Et.getState().setEnableOrbitController(!1),E((function(e){e.resizeHandleType=K.Top,e.selectedElementHeight=We+t.thickness}))},onPointerOver:function(){E((function(e){e.hoveredHandle=ge.Top,e.selectedElementHeight=We+t.thickness,e.selectedElementX=Ie.x,e.selectedElementY=Ie.y}))}}),Fe.map((function(e,t){var l=e.leftPoint.clone().sub(Ie);return Object(gf.jsx)(jp,{position:[l.x,l.y,0],onPointerDown:function(){xe.current=!0,ie(!0),Wh.set(l.x,l.y,We+.15),Ih.set(0,0,0),se(ge.Ridge),pe(t),te(He.reduce((function(e,t){return Math.min(e,new Me.Vector3(t.leftPoint[0],t.leftPoint[1],We).distanceTo(Ie)-1)}),1/0)),Et.getState().setEnableOrbitController(!1),ye.current=Q}},t)}))]}),oe&&Object(gf.jsx)(Lt.f,{name:"Roof Intersection Plane",ref:we,args:[1e3,100],visible:!1,position:Wh,rotation:Ih,onPointerMove:function(e){if(we.current&&xe.current){!function(e){G.x=e.offsetX/be.domElement.clientWidth*2-1,G.y=-e.offsetY/be.domElement.clientHeight*2+1,J.setFromCamera(G,Ae)}(e);var o=J.intersectObjects([we.current]);if(o[0]&&l){var i=o[0].point;if(i.z<.001)return;switch(ce){case ge.Top:var r=Math.max(0,i.z-l.lz-.6-De);Ew.getState().updateRoofRiseById(a,r,We+t.thickness);break;case ge.Ridge:if(l&&null!==fe){var n=i.clone().applyEuler(new Me.Euler(0,0,l.rotation[2])).sub(new Me.Vector3(l.cx,l.cy)).setZ(0),c=function(e){if(e 0&&c(o.id,T,a)<0&&(H[z][R]+=j*P))}else for(var W=0;W 0){var C=W-p/2+.5,O=I-y/2+.5;T.set(x.x+C*b,x.y+C*A,x.z+O*m),c(o.id,T,a)<0&&(H[W][I]+=j*P)}return{intensity:H,unitArea:g*m}}},{key:"pointWithinArch",value:function(e,t,l,a,o){if(a>0){var i=.5*t,r=Math.min(a,l,i),n=.5*(r+i*i/r),c=e.x-o.x,s=e.y-o.y,d=c*c+s*s,u=e.z-o.z;return d-l/2||d+(u=e.z-(l-n))*u 0){var C=W-p/2+.5,O=I-y/2+.5;T.set(x.x+C*b,x.y+C*A,x.z+O*m),c(o.id,T,a)<0&&(H[W][I]+=j*P)}return{intensity:H,unitArea:g*m}}},{key:"computeRoofWindowSolarRadiationEnergy",value:function(t,l,a,o,i,r,n,c){var s,d=Tw.dayOfYear(t),u=null!==(s=l.solarRadiationHeatmapGridCellSize)&&void 0!==s?s:.5,f=o.lx,h=o.lz,p=Math.max(2,Math.round(f/u)),y=Math.max(2,Math.round(h/u)),g=f/p,m=h/y,w=new Me.Vector3(o.cx,o.cy,o.cz).applyEuler(new Me.Euler(0,0,r.rotation[2]));w.x+=r.cx,w.y+=r.cy,w.z+=r.lz;var x=new Me.Euler(o.rotation[0],o.rotation[1],o.rotation[2]+r.rotation[2],"ZXY"),v=new Me.Vector3(0,0,1).applyEuler(x),b=new Me.Vector3,A=zy(a,d,n,ny.SPHERE_MODEL),T=Ry(l.ground,t.getMonth(),v,A),P=v.dot(a),S=Array(p).fill(0).map((function(){return Array(y).fill(0)}));if(o.windowType===Yt.Arched)for(var j=0;j 0&&c(o.id,b,a)<0&&(S[j][H]+=P*A))}else for(var M=0;M 0){var I=M-p/2+.5,C=W-y/2+.5,O=new Me.Vector3(I,C,0);O.applyEuler(x),b.set(w.x+O.x,w.y+O.y,w.z+O.z),c(o.id,b,a)<0&&(S[M][W]+=P*A)}return{intensity:S,unitArea:g*m}}},{key:"computePyramidRoofSolarRadiationEnergy",value:function(t,l,a,o,i,r,n,c,s,d,h,p){var y;if(i)return e.computeFlatRoofSolarRadiationEnergy(t,l,a,o,r,n,c,s,d,h,p);var g,m=null!==(y=l.solarRadiationHeatmapGridCellSize)&&void 0!==y?y:.5,w=Tw.dayOfYear(t),x=new Me.Euler(0,0,c.rotation[2],"ZYX"),v=zy(a,w,h,ny.SPHERE_MODEL),b=[],A=[],T=Object(f.a)(n.entries());try{var P=function(){var i=Object(u.a)(g.value,2),n=i[0],f=i[1],h=o.id+"-"+n,y=f[0].clone().applyEuler(x),w=f[1].clone().applyEuler(x),T=f[2].clone().applyEuler(x),P=(new Me.Vector3).subVectors(w,y),S=(new Me.Vector3).subVectors(T,y),j=(new Me.Vector3).subVectors(T,w),H=P.length(),z=(new Me.Vector3).crossVectors(S,j).length()/H,R=Math.max(2,Math.round(H/m)),D=Math.max(2,Math.round(z/m)),M=Array(R).fill(0).map((function(){return Array(D).fill(0)}));b.push(M),P.normalize();var W=R*S.dot(P)/H;S.normalize(),j.normalize();var I=(new Me.Vector3).crossVectors(S,j).normalize(),C=P.multiplyScalar(.5*H/R),O=(new Me.Vector3).crossVectors(I,P).normalize().multiplyScalar(.5*z/D),F=new Me.Vector3(c.cx+y.x,c.cy+y.y,c.lz+y.z+xy+(r?o.thickness:0));F.add(C).add(O),C.multiplyScalar(2),O.multiplyScalar(2),A.push(C.length()*O.length());var k=new Me.Vector3,Y=[],L=.01;Y.push({x:-.01,y:-.01}),Y.push({x:R+L,y:-.01}),Y.push({x:W,y:D+L});for(var E=Ry(l.ground,t.getMonth(),I,v),U=I.dot(a),N=0;N .01){i=!1;break}}}catch(re){d.e(re)}finally{d.f()}}}catch(re){n.e(re)}finally{n.f()}var p,g=i?1:a,m=[],w=y(V.Window,e.id),v=Object(f.a)(t);try{for(v.s();!(p=v.n()).done;){var b=p.value,A=0;if(3===b.length?A=Tw.getTriangleArea(b[0],b[1],b[2]):4===b.length&&(A=Tw.getTriangleArea(b[0],b[1],b[2])+Tw.getTriangleArea(b[2],b[3],b[0])),w.length>0){var T,P=Object(f.a)(w);try{for(P.s();!(T=P.n()).done;){var j=T.value;Vm.onSegment(b,j.cx,j.cy)&&(A-=j.lx*j.lz)}}catch(re){P.e(re)}finally{P.f()}A<0&&(A=0)}m.push(A)}}catch(re){v.e(re)}finally{v.f()}var H=i?[m.reduce((function(e,t){return e+t}),0)]:m,z=PT(e),D=Array(g).fill(0);if(Q.current&&Q.current.z>0){for(var M=y(V.SolarPanel,e.id),W=wk.computeHipRoofSolarRadiationEnergy(le,R,Q.current,e,i,!0,t,l,w,M,ae,ue),I=0;I 0){var d,u=Object(f.a)(i);try{for(u.s();!(d=u.n()).done;){var p=d.value;Vm.onSegment(c,p.cx,p.cy)&&(s-=p.lx*p.lz)}}catch(J){u.e(J)}finally{u.f()}s<0&&(s=0)}r.push(s)}}catch(J){n.e(J)}finally{n.f()}var g=PT(e),m=Array(a).fill(0);if(Q.current&&Q.current.z>0){for(var w=y(V.SolarPanel,e.id),v=wk.computeGableRoofSolarRadiationEnergy(le,R,Q.current,e,!0,t,l,i,w,ae,ue),b=0;b0&&(h(),H(),Tf.setState((function(e){e.runStaticSimulation=!1,e.simulationInProgress=!1,e.showSolarRadiationHeatmap=!0})),Kh(me.t("message.SimulationCompleted",m)))}),[p]);var j=function(e,t,l){if(P.current.length>1){S.current.length=0,A.set(t,l);var a=P.current.filter((function(t){return t.uuid!==e}));return A.intersectObjects(a,!1,S.current),S.current.length>0}return!1},H=function(){!function(){var e=g.children.filter((function(e){return"Content"===e.name}));if(e.length>0){var t=e[0].children;P.current.length=0;var l,a=Object(f.a)(t);try{for(a.s();!(l=a.n()).done;){var o=l.value;Tw.fetchSimulationElements(o,P.current)}}catch(i){a.e(i)}finally{a.f()}}}();var e,t=Object(f.a)(i);try{for(t.s();!(e=t.n()).done;){var l=e.value;switch(l.type){case V.Foundation:var a=l;R(a),a.solarStructure===G.UpdraftTower&&D(a);break;case V.Cuboid:z(l);break;case V.SolarPanel:M(l);break;case V.Wall:W(l);break;case V.Door:I(l);break;case V.Roof:var o=l;switch(o.roofType){case It.Pyramid:C(o);break;case It.Gable:L(o);break;case It.Gambrel:F(o);break;case It.Mansard:O(o);break;case It.Hip:k(o)}}}}catch(r){t.e(r)}finally{t.f()}},z=function(e){var t=x.getFullYear(),l=x.getMonth(),a=x.getDate(),i=Tw.dayOfYear(x),r=e.lx,n=e.ly,s=e.lz,u=Math.max(2,Math.round(r/T)),f=Math.max(2,Math.round(n/T)),h=Math.max(2,Math.round(s/T)),p=r/u,y=n/f,g=s/h,m=c(e),A=e.cx,P=e.cy,S=e.cz;if(m&&m.type===V.Cuboid){var H=Tw.getWorldDataById(e.id);A=H.pos.x,P=H.pos.y,S=H.pos.z}for(var z=Array(u).fill(0).map((function(){return Array(f).fill(0)})),R=Array(u).fill(0).map((function(){return Array(h).fill(0)})),D=Array(u).fill(0).map((function(){return Array(h).fill(0)})),M=Array(f).fill(0).map((function(){return Array(h).fill(0)})),W=Array(f).fill(0).map((function(){return Array(h).fill(0)})),I=Rt,C=zt.clone().applyAxisAngle(Rt,e.rotation[2]),O=Ht.clone().applyAxisAngle(Rt,e.rotation[2]),F=jt.clone().applyAxisAngle(Rt,e.rotation[2]),k=St.clone().applyAxisAngle(Rt,e.rotation[2]),Y=new Me.Vector3,L=0,U=new Me.Vector2(A,P),N=new Me.Vector2,J=P-n/2,G=P+n/2,X=A-r/2,B=A+r/2,K=0;K<24;K++)for(var q=0;q 0&&(j(e.id,H,O)||(z[L][U]+=Y*F)))}else for(var J=0;J 0&&(H.set(P.x+X*D,P.y+X*M,P.z+B*m),j(e.id,H,O)||(z[J][G]+=Y*F))}}}var K=R*b/60,q=K>At?w.sunshineHours[r]/(30*K*o.timesPerHour):0;E(z,q),d(e.id,z)},C=function(e){if(e.roofType!==It.Pyramid)throw new Error("roof is not pyramid");var t=s(e);if(!t)throw new Error("foundation of wall not found");var l=y(e.id);if(l&&0!==l.length){var a,i=!0,r=l[0][0].z,n=Object(f.a)(l);try{for(n.s();!(a=n.n()).done;){var c,h=a.value,p=Object(f.a)(h);try{for(p.s();!(c=p.n()).done;){var g=c.value;if(Math.abs(g.z-r)>.01){i=!1;break}}}catch(M){p.e(M)}finally{p.f()}}}catch(M){n.e(M)}finally{n.f()}if(i)Y(e,t,l);else{var m,A=x.getFullYear(),P=x.getMonth(),S=x.getDate(),H=Tw.dayOfYear(x),z=new Me.Euler(0,0,t.rotation[2],"ZYX"),R=Object(f.a)(l.entries());try{var D=function(){var l=Object(u.a)(m.value,2),a=l[0],i=l[1],r=e.id+"-"+a,n=i[0].clone().applyEuler(z),c=i[1].clone().applyEuler(z),s=i[2].clone().applyEuler(z),f=(new Me.Vector3).subVectors(c,n),h=(new Me.Vector3).subVectors(s,n),p=(new Me.Vector3).subVectors(s,c),y=f.length(),g=(new Me.Vector3).crossVectors(h,p).length()/y,x=Math.max(2,Math.round(y/T)),R=Math.max(2,Math.round(g/T)),D=Array(x).fill(0).map((function(){return Array(R).fill(0)}));f.normalize(),h.normalize(),p.normalize();var M=(new Me.Vector3).crossVectors(h,p).normalize(),W=f.multiplyScalar(.5*y/x),I=(new Me.Vector3).crossVectors(M,f).normalize().multiplyScalar(.5*g/R),C=new Me.Vector3(t.cx+n.x,t.cy+n.y,t.lz+n.z+xy);C.add(W).add(I),W.multiplyScalar(2),I.multiplyScalar(2);for(var O=0,F=new Me.Vector3,k=0;k<24;k++)for(var Y=0;Y 0){C++;for(var U=zy(L,c,v,ny.SPHERE_MODEL),N=Ry(o.ground,r,Rt,U),V=Rt.dot(L),J=0;J.1,de=S>0&&T;Object(r.useEffect)((function(){var e=function(){Et.getState().setEnableOrbitController(!0),Z.current=!1,Q(!1),D((function(e){e.rotateHandleType=null,e.moveHandleType=null,e.resizeHandleType=null}))};return window.addEventListener("pointerup",e),function(){window.removeEventListener("pointerup",e)}}),[]);var ue=function(e,t){e.intersections.length>0&&(e.intersections[0].object===e.eventObject&&(J(t),t===B.Top?F.style.cursor="move":t===q.Lower||t===q.Upper||t===q.Tilt?F.style.cursor="grab":F.style.cursor="pointer"))},fe=function(){J(null),F.style.cursor="default"},he=function(e){return N===e||Ew.getState().rotateHandleType===e?pt:ht};return Object(gf.jsxs)("group",{name:"Solar Panel Group",position:[a,o,S+n],rotation:re,children:[Object(gf.jsx)(cw,{solarPanelModel:e,groupRotation:re,panelRotation:ne}),ce&&Object(gf.jsxs)("group",{position:[0,0,-S],rotation:[0,0,ne.z],children:[Object(gf.jsx)(oy,{id:t,position:[0,-P-H/2,S],color:he(q.Upper),ratio:H,handleType:q.Upper,hoverHandle:ue,noHoverHandle:fe}),Object(gf.jsx)(oy,{id:t,position:[0,P+H/2,S],color:he(q.Lower),ratio:H,handleType:q.Lower,hoverHandle:ue,noHoverHandle:fe})]}),se&&Object(gf.jsxs)(gf.Fragment,{children:[Object(gf.jsx)(Lt.g,{name:q.Tilt,args:[z,1.1*z,18,2,-vt,Math.PI],rotation:[0,-vt,ne.z,"ZXY"],onPointerOver:function(e){ue(e,q.Tilt)},onPointerOut:function(e){fe()},onPointerDown:function(e){if(Q(!0),N){Et.getState().setEnableOrbitController(!1),Z.current=!0,_.current=y;var t=Tw.getWorldDataById(l).rot;ee.current=t}D((function(e){e.rotateHandleType=q.Tilt}))},children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",side:Me.DoubleSide,color:N===q.Tilt||K?pt:ht})}),K&&Object(gf.jsxs)(gf.Fragment,{children:[Object(gf.jsx)(Lt.g,{ref:le,name:"Solar panel tilt handle",args:[z,2*z,18,2,-vt,Math.PI],rotation:[0,-vt,ne.z,"ZXY"],onPointerUp:function(e){if(Math.abs($.current-_.current)>At){var l={name:"Set Solar Panel Tilt Angle",timestamp:Date.now(),oldValue:_.current,newValue:$.current,changedElementId:t,changedElementType:V.SolarPanel,undo:function(){M(l.changedElementId,l.oldValue)},redo:function(){M(l.changedElementId,l.newValue)}};W(l)}},onPointerMove:function(e){if(Z.current&&(Y.setFromCamera(L,k),le.current)){var l=Y.intersectObjects([le.current]);if(l.length>0){var a=l[0].point,o=le.current.parent;if(o){var i=o.localToWorld(new Me.Vector3),r=(new Me.Vector3).subVectors(a,i),n=r.angleTo(Rt);if(!(.5*s*Math.abs(Math.sin(n))>S)){var c,d=g+(null!==(c=ee.current)&&void 0!==c?c:0),u=d%Math.PI===0?Math.sign(-r.y)*Math.sign(Math.cos(d)):Math.sign(r.x)*Math.sign(Math.sin(d));M(t,n*=u),$.current=n}}}}},children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",depthTest:!1,transparent:!0,opacity:.5,side:Me.DoubleSide})}),Object(gf.jsx)(Jl.a,{points:[[0,0,z],[0,0,1.75*z]],rotation:new Me.Euler(y,0,ne.z,"ZXY"),lineWidth:1}),ae.map((function(e,t){return Object(gf.jsxs)("group",{rotation:new Me.Euler(Math.PI/12*t-vt,0,ne.z,"ZXY"),children:[Object(gf.jsx)(Jl.a,{points:[[0,0,1.8*z],[0,0,2*z]],color:"white",transparent:!0,opacity:.5}),Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},text:"".concat(15*t-90,"\xb0"),fontSize:20*z,fontFace:"Times Roman",textHeight:.15*z,position:[0,0,1.6*z]})]},t)})),Object(gf.jsx)("group",{rotation:new Me.Euler(y,0,ne.z,"ZXY"),children:Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},text:"".concat(Math.floor(y/Math.PI*180),"\xb0"),fontSize:20*z,fontFace:"Times Roman",textHeight:.2*z,position:[0,0,.75*z]})})]})]}),de&&ie.map((function(e,t){return Object(gf.jsx)(Lt.d,{userData:{unintersectable:!0},name:"Pole "+t,castShadow:!1,receiveShadow:!1,args:[w,w,m+2*(e.z-R)+d,4,1],position:e,rotation:[vt,0,0],children:Object(gf.jsx)("meshStandardMaterial",{attach:"material",color:b})},t)}))]})},cw=function(e){var t,l,a,n,c,s=e.solarPanelModel,d=e.groupRotation,f=e.panelRotation,h=s.id,p=s.parentId,y=s.lx,g=s.ly,m=s.lz,w=s.cx,x=s.cy,v=s.cz,b=s.normal,A=s.tiltAngle,T=s.relativeAzimuth,P=s.trackerType,S=s.drawSunBeam,j=s.locked,H=s.showLabel,z=s.label,R=s.pvModelName,D=s.orientation,M=s.frameColor,W=s.backsheetColor,I=s.color,C=s.poleHeight,O=_f(h),F=Ew(si),k=Ew(is),Y=Ew(i.date),L=Ew(i.latitude),E=Ew(Ru),U=Ew(Vi),N=Tf(Ns),J=Ew(Yi),G=Ew(o.solarPanelShininess),Q=null!==(t=Ew(o.orthographic))&&void 0!==t&&t,Z=Object(r.useMemo)((function(){return{lng:U}}),[U]),_=uw(b),ee=_?A:0,le=_?T:0,ae=Math.max(1,(y+g)/16),oe=dt*ae*1.5,ie=st*ae*2,re=[y,g,m].map((function(e){return e/2})),ne=Object(u.a)(re,3),ce=ne[0],se=ne[1],de=ne[2],ue=[oe,oe,1.2*m],fe=J[R];fe&&(m=Math.max(fe.thickness,.02));var he=Object(r.useMemo)((function(){return new Date(Y)}),[Y]),pe=Object(r.useMemo)((function(){return(z||me.t("shared.SolarPanelElement",Z))+(j?" ("+me.t("shared.ElementLocked",Z)+")":"")+(z?"":"\n"+me.t("word.Coordinates",Z)+": ("+w.toFixed(1)+", "+x.toFixed(1)+", "+v.toFixed(1)+") "+me.t("word.MeterAbbreviation",Z))}),[z,j,U,w,x,v]),ye=Object(r.useMemo)((function(){var e=[];if(fe){var t,l;D===$.portrait?(t=Math.max(1,Math.round(y/fe.width)),l=Math.max(1,Math.round(g/fe.length))):(t=Math.max(1,Math.round(y/fe.length)),l=Math.max(1,Math.round(g/fe.width)));for(var a=y/t,o=g/l,i=0;i<=t;i++)e.push({points:[new Me.Vector3(i*a-ce,-se,m),new Me.Vector3(i*a-ce,se,m)]});for(var r=0;r<=l;r++)e.push({points:[new Me.Vector3(-ce,r*o-se,m),new Me.Vector3(ce,r*o-se,m)]})}return e}),[fe,D,R,y,g,m]),ge=Object(r.useState)(Oe()),we=Object(u.a)(ge,2),xe=we[0],ve=we[1],be=Object(r.useState)(!1),Ae=Object(u.a)(be,2),Te=Ae[0],Pe=Ae[1],je=Object(r.useState)(null),He=Object(u.a)(je,2),ze=He[0],Re=He[1],De=Object(r.useRef)(null),We=Object(Se.f)().gl,Ie=Uy(y,g,fe,D,M,W),Ce=Ey(h);function Oe(){var e=new Me.Euler,t=fw(p,d.z);return P===te.NO_TRACKER?e.set(-d.x-ee,0,-t-le):e.set(-d.x-f.x,-f.y,-t-f.z),jy(he,L).applyEuler(e)}function Fe(e){return ze===e||E===e?pt:ht}function ke(e,t){Et.getState().setEnableOrbitController(!1),F((function(l){l.resizeHandleType=e,l.resizeAnchor.copy(t)}))}return Object(Se.d)((function(){var e=Oe();e.equals(xe)||ve(e)})),Object(gf.jsxs)(gf.Fragment,{children:[Object(gf.jsxs)("group",{name:"Solar Panel Box Group",rotation:f,children:[Object(gf.jsxs)(Lt.a,{uuid:h,ref:De,args:[y,g,m],position:[0,0,de],onPointerDown:function(e){2!==e.button&&k(h,e,X.Select)},onContextMenu:function(e){k(h,e,X.ContextMenu),F((function(t){e.intersections.length>0&&(e.intersections[0].object===De.current&&(t.contextMenuObjectType=V.SolarPanel))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===De.current&&(Pe(!0),We.domElement.style.cursor="move"))},onPointerOut:function(e){Pe(!1),We.domElement.style.cursor="default"},children:[Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:"white"}),N&&Ce?Object(gf.jsx)("meshBasicMaterial",{attachArray:"material",map:Ce}):Ie?Q||0===G?Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",map:Ie,color:I}):Object(gf.jsx)("meshPhongMaterial",{attachArray:"material",specular:new Me.Color("Blue"===(null===fe||void 0===fe?void 0:fe.color)?at:ot),shininess:null!==G&&void 0!==G?G:tt,side:Me.FrontSide,map:Ie,color:I}):Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:I}),0===(null===fe||void 0===fe?void 0:fe.bifacialityFactor)||Q||0===C&&0===A?Object(gf.jsx)("meshStandardMaterial",{attachArray:"material",color:I}):Ie?Object(gf.jsx)("meshPhongMaterial",{attachArray:"material",specular:new Me.Color("Blue"===(null===fe||void 0===fe?void 0:fe.color)?at:ot),shininess:null!==G&&void 0!==G?G:tt,side:Me.FrontSide,map:Ie,color:I}):null]}),O&&!j&&Object(gf.jsxs)("group",{name:rw,onPointerDown:function(e){if(e.intersections.length>0&&e.intersections[0].eventObject.name===rw){var t=e.object.name;switch(t){case B.Default:Et.getState().setEnableOrbitController(!1),F((function(e){e.moveHandleType=t,e.selectedElement=e.elements.find((function(t){var l;return t.id===(null===(l=e.selectedElement)||void 0===l?void 0:l.id)}))}));break;case K.Left:var l=e.object.localToWorld(new Me.Vector3(y,0,0));ke(t,l);break;case K.Right:var a=e.object.localToWorld(new Me.Vector3(-y,0,0));ke(t,a);break;case K.Lower:var o=e.object.localToWorld(new Me.Vector3(0,g,0));ke(t,o);break;case K.Upper:var i=e.object.localToWorld(new Me.Vector3(0,-g,0));ke(t,i)}}},onPointerOver:function(e){if(e.intersections.length>0&&e.eventObject.name.includes(rw)){var t=e.object.name;Re(t),t===B.Top?We.domElement.style.cursor="move":t===q.Lower||t===q.Upper||t===q.Tilt?We.domElement.style.cursor="grab":We.domElement.style.cursor="pointer"}},onPointerOut:function(){Re(null),We.domElement.style.cursor="default"},children:[Object(gf.jsx)(Lt.h,{args:[ie,6,6],name:B.Default,children:Object(gf.jsx)("meshBasicMaterial",{color:"orange"})}),Object(gf.jsx)(Lt.a,{position:[0,-se,de],args:ue,name:K.Lower,children:Object(gf.jsx)("meshBasicMaterial",{color:Fe(K.Lower)})}),Object(gf.jsx)(Lt.a,{position:[0,se,de],args:ue,name:K.Upper,children:Object(gf.jsx)("meshBasicMaterial",{color:Fe(K.Upper)})}),Object(gf.jsx)(Lt.a,{position:[-ce,0,de],args:ue,name:K.Left,children:Object(gf.jsx)("meshBasicMaterial",{color:Fe(K.Left)})}),Object(gf.jsx)(Lt.a,{position:[ce,0,de],args:ue,name:K.Right,children:Object(gf.jsx)("meshBasicMaterial",{color:Fe(K.Right)})})]}),S&&xe.z>0&&Object(gf.jsx)(sw,{sunDirection:xe}),N&&Ce&&ye.map((function(e,t){return Object(gf.jsx)(Jl.a,{name:"Solar Panel Lines",userData:{unintersectable:!0},points:e.points,castShadow:!1,receiveShadow:!1,lineWidth:.2,color:"black"},t)})),Object(gf.jsx)(Lt.f,{name:"Solar Panel Simulation Plane",uuid:h,args:[y,g],userData:{simulation:!0},receiveShadow:!1,castShadow:!1,visible:!1,children:Object(gf.jsx)("meshBasicMaterial",{side:Me.DoubleSide})}),O&&j&&Object(gf.jsx)(Jl.a,{name:"Selection highlight lines",userData:{unintersectable:!0},points:[[-ce,-se,0],[-ce,se,0],[ce,se,0],[ce,-se,0],[-ce,-se,0]],castShadow:!1,receiveShadow:!1,lineWidth:2,color:yt})]}),(Te||H)&&!O&&Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:pe,color:null!==(l=s.labelColor)&&void 0!==l?l:"white",fontSize:null!==(a=s.labelFontSize)&&void 0!==a?a:20,textHeight:null!==(n=s.labelSize)&&void 0!==n?n:.2,position:[0,0,null!==(c=s.labelHeight)&&void 0!==c?c:Math.max(se*Math.abs(Math.sin(A))+.1,.2)]})]})},sw=n.a.memo((function(e){var t=e.sunDirection,l=Ew(Kr),a=Object(r.useMemo)((function(){return Math.max(100,10*l)}),[l]);return Object(gf.jsxs)("group",{name:"Sun Beam Group",children:[Object(gf.jsx)(Jl.a,{userData:{unintersectable:!0},points:[Rt.clone().multiplyScalar(.75),[0,0,0],t.clone().multiplyScalar(a)],name:"Sun Beam",lineWidth:.5,color:"white"}),Object(gf.jsx)(Jl.a,{userData:{unintersectable:!0},points:[t.clone().multiplyScalar(.5),Rt.clone().multiplyScalar(.5)],name:"Angle",lineWidth:.5,color:"white"}),Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Angle Value",text:Tw.toDegrees(t.angleTo(Rt)).toFixed(1)+"\xb0",fontSize:20,fontFace:"Times Roman",textHeight:.1,position:t.clone().multiplyScalar(.75).add(Rt.clone().multiplyScalar(.75)).multiplyScalar(.5)}),Object(gf.jsx)("group",{position:Rt.clone().multiplyScalar(.75),rotation:[vt,0,0],children:Object(gf.jsx)(Lt.c,{userData:{unintersectable:!0},args:[.04,.2,4,2],name:"Normal Vector Arrow Head",children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",color:"white"})})})]})}));function dw(e){var t=Object(u.a)(e,3),l=t[0],a=t[1];return 1===t[2]?new Me.Euler(0,0,0):0!==l?new Me.Euler(vt,0,l*vt,"ZXY"):0!==a?new Me.Euler(-a*vt,0,0):new Me.Euler}function uw(e){return Math.abs(e[2]-1)<.01}function fw(e,t){return Tw.getWorldDataById(e).rot+t}var hw=n.a.memo(nw),pw=function(e){var t,l,a,i,n,c,s=e.id,p=e.cx,y=e.cy,g=e.lx,m=void 0===g?1:g,w=e.ly,x=void 0===w?1:w,v=e.lz,b=void 0===v?1:v,A=e.color,T=void 0===A?"silver":A,P=e.lineColor,S=void 0===P?"black":P,j=e.lineWidth,H=void 0===j?.1:j,z=e.locked,R=void 0!==z&&z,D=e.showLabel,M=void 0!==D&&D,W=e.textureTypes,I=void 0===W?[de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture,de.NoTexture]:W,C=e.stackable,O=_f(s),F=Ew(si),k=Ew(Vi),Y=Ew(o.orthographic),L=Ew(Zr),E=Ew(on),U=Ew(ns),N=Ew(qc),J=Ew(An),G=Ew(Sn),Q=Ew(cn),Z=Ew(sn),_=Ew(dn),ee=Ew(is),te=Ew(rc),le=Ew(Ei),ae=Ew(o.shadowEnabled),oe=Ew(Sr),ie=Ew(Iu),re=Ew(qn),ne=Ew(Kn),ce=Ew(rn),se=Tf(Ns),ue=Ew(o.solarRadiationHeatmapMaxValue),fe=Pf(wi),he=Ew(o.groundImage),pe=Object(Se.f)(),ye=pe.camera,ge=pe.gl.domElement,we=pe.raycaster,xe=pe.mouse,ve=Object(r.useState)(null),be=Object(u.a)(ve,2),Ae=be[0],Te=be[1],Pe=Object(r.useState)(null),je=Object(u.a)(Pe,2),He=je[0],ze=je[1],Re=Object(r.useState)(null),De=Object(u.a)(Re,2),We=De[0],Ie=De[1],Ce=Object(r.useState)(null),Oe=Object(u.a)(Ce,2),Fe=Oe[0],ke=Oe[1],Ye=Object(r.useState)(null),Le=Object(u.a)(Ye,2),Ee=Le[0],Ue=Le[1],Ne=Object(r.useState)(!1),Ve=Object(u.a)(Ne,2),Je=Ve[0],Ge=Ve[1],Xe=Object(r.useState)(!1),Be=Object(u.a)(Xe,2),Ke=Be[0],qe=Be[1],Qe=Object(r.useState)(),Ze=Object(u.a)(Qe,2),_e=Ze[0],$e=Ze[1],et=Object(r.useRef)(null),tt=Object(r.useRef)(),lt=Object(r.useRef)(null),at=Object(r.useRef)(Rt),ot=Object(r.useRef)(new Me.Vector3(0,0,0)),it=Object(r.useRef)(new Me.Euler(0,0,0)),rt=Object(r.useRef)(new Me.Vector3(1,1,1)),nt=Object(r.useRef)(new Me.Vector3),ct=Object(r.useRef)(new Me.Vector3),dt=Object(r.useRef)(new Me.Vector3),ut=Object(r.useRef)(new Me.Vector3),ft=Object(r.useRef)(new Me.Vector3(1,1,1)),ht=Object(r.useRef)(new Me.Vector3(1,1,1)),pt=Object(r.useRef)(0),gt=Object(r.useRef)(0),mt=Object(r.useRef)([]),wt=Object(r.useRef)([]),xt=Object(r.useRef)(),Pt=Object(r.useRef)(new Me.Vector3),Mt=Object(r.useRef)(0),Wt=Object(r.useMemo)((function(){return{lng:k}}),[k]),It=m/2,Ct=x/2,Ot=b/2,Ft=Object(r.useMemo)((function(){return new Me.Vector3}),[]);if(lt.current&<.current.type===V.SolarPanel){var kt=uw(lt.current.normal)?lt.current.poleHeight:0;Ft.set(0,0,e.lz/2+kt)}var Yt=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.CuboidElement",Wt))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",Wt)+")":"")+((null===e||void 0===e?void 0:e.label)?"":"\n"+me.t("word.Coordinates",Wt)+": ("+p.toFixed(1)+", "+y.toFixed(1)+", "+(b/2).toFixed(1)+") "+me.t("word.MeterAbbreviation",Wt))}),[null===e||void 0===e?void 0:e.label,R,k,p,y,b]);Object(r.useEffect)((function(){var e=function(){lt.current=null,qe(!1),Et.getState().setEnableOrbitController(!0)};return window.addEventListener("pointerup",e),function(){window.removeEventListener("pointerup",e)}}),[]),Object(r.useEffect)((function(){Ew.getState().tempHumanPlant.length>0&&F((function(e){var t;(t=e.elements).push.apply(t,Object(h.a)(e.tempHumanPlant)),e.tempHumanPlant=[]}))}),[]),Object(r.useEffect)((function(){if(e&&se){var t=null!==ue&&void 0!==ue?ue:5,l=fe(e.id+"-top");l&&Te(Tw.fetchHeatmapTexture(l,t));var a=fe(e.id+"-south");a&&ze(Tw.fetchHeatmapTexture(a,t));var o=fe(e.id+"-north");o&&Ie(Tw.fetchHeatmapTexture(o,t));var i=fe(e.id+"-west");i&&ke(Tw.fetchHeatmapTexture(i,t));var r=fe(e.id+"-east");r&&Ue(Tw.fetchHeatmapTexture(r,t,!0))}}),[se,ue]);var Ut=function(e){switch(e){case de.Facade01:return Xm;case de.Facade02:return Bm;case de.Facade03:return Km;case de.Facade04:return qm;case de.Facade05:return Qm;case de.Facade06:return Zm;case de.Facade07:return _m;case de.Facade08:return $m;case de.Facade09:return ew;case de.Facade10:return tw;default:return Sf}},Nt=function(e){switch(e){case de.Facade01:case de.Facade02:return{x:14,y:6.5};case de.Facade03:return{x:10,y:12};case de.Facade04:return{x:20,y:11};case de.Facade05:return{x:15,y:10};case de.Facade06:return{x:11,y:3.5};case de.Facade07:return{x:11,y:10};case de.Facade08:return{x:16,y:9};case de.Facade09:return{x:10,y:9};case de.Facade10:return{x:12,y:9};default:return{x:1,y:1}}},Vt=Object(r.useMemo)((function(){return(new Me.TextureLoader).load(I?Ut(I[0]):Sf,(function(e){var t=Nt(I[0]);e.repeat.set(x/t.x,b/t.y),e.rotation=vt,e.center.x=1,e.center.y=0,e.wrapS=e.wrapT=Me.RepeatWrapping,Bt(e)}))}),[I[0],x,b]),Jt=Object(r.useState)(Vt),Gt=Object(u.a)(Jt,2),Xt=Gt[0],Bt=Gt[1],Kt=Object(r.useMemo)((function(){return(new Me.TextureLoader).load(I?Ut(I[1]):Sf,(function(e){var t=Nt(I[1]);e.repeat.set(x/t.x,b/t.y),e.rotation=-vt,e.wrapS=e.wrapT=Me.RepeatWrapping,_t(e)}))}),[I[1],x,b]),qt=Object(r.useState)(Kt),Qt=Object(u.a)(qt,2),Zt=Qt[0],_t=Qt[1],$t=Object(r.useMemo)((function(){return(new Me.TextureLoader).load(I?Ut(I[2]):Sf,(function(e){var t=Nt(I[2]);e.repeat.set(m/t.x,b/t.y),e.rotation=Math.PI,e.center.x=0,e.center.y=1,e.wrapS=e.wrapT=Me.RepeatWrapping,al(e)}))}),[I[2],m,b]),el=Object(r.useState)($t),tl=Object(u.a)(el,2),ll=tl[0],al=tl[1],ol=Object(r.useMemo)((function(){return(new Me.TextureLoader).load(I?Ut(I[3]):Sf,(function(e){var t=Nt(I[3]);e.repeat.set(m/t.x,b/t.y),e.wrapS=e.wrapT=Me.RepeatWrapping,cl(e)}))}),[I[3],m,b]),il=Object(r.useState)(ol),rl=Object(u.a)(il,2),nl=rl[0],cl=rl[1],sl=Object(r.useMemo)((function(){return(new Me.TextureLoader).load(I?Ut(I[4]):Sf,(function(e){var t=Nt(I[4]);e.repeat.set(m/t.x,x/t.y),e.wrapS=e.wrapT=Me.RepeatWrapping,hl(e)}))}),[I[4],m,x]),dl=Object(r.useState)(sl),ul=Object(u.a)(dl,2),fl=ul[0],hl=ul[1];Object(r.useEffect)((function(){Object(Se.c)()}),Object(h.a)(I));var pl=function(e){at.current=e;var t=.01;Tw.isSame(at.current,Rt)?(ot.current=new Me.Vector3(0,0,Ot+t),it.current=new Me.Euler(0,0,0),rt.current.set(It,Ct,Ot)):Tw.isSame(at.current,St)?(ot.current=new Me.Vector3(It+t,0,0),it.current=new Me.Euler(0,vt,0),rt.current.set(Ot,Ct,It)):Tw.isSame(at.current,jt)?(ot.current=new Me.Vector3(-It-t,0,0),it.current=new Me.Euler(0,-vt,0),rt.current.set(Ot,Ct,It)):Tw.isSame(at.current,zt)?(ot.current=new Me.Vector3(0,-Ct-t,0),it.current=new Me.Euler(vt,0,0),rt.current.set(It,Ot,Ct)):Tw.isSame(at.current,Ht)&&(ot.current=new Me.Vector3(0,Ct+t,0),it.current=new Me.Euler(-vt,0,0),rt.current.set(It,Ot,Ct))},yl=Math.max(1,Math.max(m,x)/8),gl=st*yl,ml=Tw.isIdentical(null===(t=lt.current)||void 0===t?void 0:t.normal,Tt),wl=function(t,l,a){var o=JSON.parse(JSON.stringify(t));return o.cx=l,o.cy=a,ce(o)?(Qh(me.t("message.MoveCancelledBecauseOfOverlap",Wt)),!1):!(Tw.isIdentical(t.normal,Tt)&&!Tw.isSolarCollectorWithinHorizontalSurface(o,e))||(Qh(me.t("message.MoveOutsideBoundaryCancelled",Wt)),!1)},xl=function(t,l,a,o,i){if(0!==t.tiltAngle&&.5*i*Math.abs(Math.sin(t.tiltAngle))>t.poleHeight)return!1;var r=JSON.parse(JSON.stringify(t));return r.cx=l,r.cy=a,r.lx=o,r.ly=i,!!Tw.isSolarCollectorWithinHorizontalSurface(r,e)},vl=he?Y?.25:.75:1,bl=[se&&Ee?Ee:Xt,se&&Fe?Fe:Zt,se&&We?We:ll,se&&He?He:nl,se&&Ae?Ae:fl,null],Al=e&&e.faceColors?[0,1,2,3,4,5].map((function(t){return I&&I[t]!==de.NoTexture?se?Object(gf.jsx)("meshBasicMaterial",{side:Me.FrontSide,attachArray:"material",color:"white",map:bl[t],transparent:Y&&he,opacity:vl},t):Object(gf.jsx)("meshStandardMaterial",{side:Me.FrontSide,attachArray:"material",color:"white",map:bl[t],transparent:Y&&he,opacity:vl},t):se?Object(gf.jsx)("meshBasicMaterial",{side:Me.FrontSide,attachArray:"material",color:"white",map:bl[t],transparent:Y&&he,opacity:vl},t):Object(gf.jsx)("meshStandardMaterial",{side:Me.FrontSide,attachArray:"material",color:e.faceColors?e.faceColors[t]:T,map:bl[t],transparent:Y&&he,opacity:vl},t)})):Object(gf.jsx)("meshStandardMaterial",{side:Me.FrontSide,attach:"material",color:T,transparent:Y&&he,opacity:vl}),Tl=Object(r.useMemo)((function(){return[It,Ct,Ot]}),[It,Ct,Ot]),Pl=O&&!R;return Object(gf.jsxs)("group",{ref:et,name:"Cuboid Group "+s,userData:{aabb:!0},children:[Object(gf.jsx)(Lt.a,{castShadow:ae,receiveShadow:ae,userData:{simulation:!0,stand:!0,stackable:C},uuid:s,ref:tt,args:[m,x,b],name:"Cuboid "+s,onContextMenu:function(e){ee(s,e,X.ContextMenu),F((function(t){t.pastePoint.copy(e.intersections[0].point);var l=e.intersections[0].face;(l&&(t.pasteNormal=l.normal.clone(),Tw.isSame(l.normal,St)?t.selectedSideIndex=0:Tw.isSame(l.normal,jt)?t.selectedSideIndex=1:Tw.isSame(l.normal,Ht)?t.selectedSideIndex=2:Tw.isSame(l.normal,zt)?t.selectedSideIndex=3:Tw.isSame(l.normal,Rt)&&(t.selectedSideIndex=4)),t.clickObjectType=V.Cuboid,e.intersections.length>0)&&(e.intersections[0].object===tt.current&&(t.contextMenuObjectType=V.Cuboid))}))},onPointerDown:function(t){if(2!==t.button){ie()||ee(s,t,X.Select);var l=E(),a=!1;if(t.intersections[0].object.name===V.Polygon&&Ew.getState().objectTypeToAdd!==V.None&&(a=!0),(null===l||void 0===l?void 0:l.id)===s||a)if(function(e){switch(e){case V.Polygon:case V.Sensor:case V.Light:case V.SolarPanel:case V.Human:case V.Tree:case V.Flower:return!0}return!1}(Ew.getState().objectTypeToAdd)&&e){qe(!0);var o=function(t){var l,a=t.intersections[0];if(Ew.getState().objectTypeToAdd===V.SolarPanel){var o,i,r,n,c,d,u,f,h=a.point,p=Tw.getWorldDataById(s),y=p.pos,g=p.rot,w=(new Me.Vector3).subVectors(h,y).applyEuler(new Me.Euler(0,0,-g)),v=Vl.makeSolarPanel(e,Ew.getState().getPvModule(null!==(o=Ew.getState().actionState.solarPanelModelName)&&void 0!==o?o:"SPR-X21-335-BLK"),w.x/m,w.y/x,w.z/b,null!==(i=Ew.getState().actionState.solarPanelOrientation)&&void 0!==i?i:$.landscape,null!==(r=Ew.getState().actionState.solarPanelPoleHeight)&&void 0!==r?r:1,null!==(n=Ew.getState().actionState.solarPanelPoleSpacing)&&void 0!==n?n:3,null!==(c=Ew.getState().actionState.solarPanelTiltAngle)&&void 0!==c?c:0,null!==(d=Ew.getState().actionState.solarPanelRelativeAzimuth)&&void 0!==d?d:0,null===(u=a.face)||void 0===u?void 0:u.normal,[0,0,0],null!==(f=Ew.getState().actionState.solarPanelFrameColor)&&void 0!==f?f:"white");return F((function(e){e.elements.push(v)})),v}return U(e,a.point,null===(l=a.face)||void 0===l?void 0:l.normal)}(t);if(o){var i={name:"Add",timestamp:Date.now(),addedElement:o,undo:function(){N(i.addedElement.id,!1)},redo:function(){F((function(e){e.elements.push(i.addedElement),e.selectedElement=i.addedElement}))}};oe(i),F((function(e){e.objectTypeToAdd=V.None}))}}else Et.getState().selectNone(),Et.setState((function(e){e.cuboidRef=et}));else if(l&&l.parentId===s&&function(e){switch(e){case V.Polygon:case V.Sensor:case V.Light:case V.SolarPanel:return!0}return!1}(l.type)){qe(!0);var r,n=Tw.getWorldDataById(s),c=n.rot,u=n.pos;Pt.current.copy(u),Mt.current=c,lt.current=l;var h,p=Object(f.a)(t.intersections);try{for(p.s();!(h=p.n()).done;){var y=h.value;if(y.object===tt.current){r=y.face;break}}}catch(g){p.e(g)}finally{p.f()}switch(r&&(pl(r.normal),_e&&_e.equals(r.normal)||$e(r.normal)),Et.getState().setEnableOrbitController(!1),nt.current.x=l.cx,nt.current.y=l.cy,nt.current.z=l.cz,dt.current.fromArray(l.normal),ft.current.x=l.lx,ft.current.y=l.ly,ft.current.z=l.lz,l.type){case V.SolarPanel:pt.current=l.relativeAzimuth;break;case V.Polygon:mt.current=l.vertices.map((function(e){return Object(d.a)({},e)}))}}}},onPointerMove:function(t){if(lt.current&&e){if(lt.current.type===V.SolarPanel&&ml)return;if(lt.current.parentId===s&<.current.type&&!lt.current.locked){var l=new Me.Vector2(t.offsetX/ge.clientWidth*2-1,1-t.offsetY/ge.clientHeight*2);if(we.setFromCamera(l,ye),tt.current){var a=we.intersectObjects([tt.current]);if(a.length>0){var o=a[0].point,i=a[0].face;if(Ew.getState().moveHandleType){if(i){var r=i.normal;_e&&!_e.equals(r)&&$e(r),pl(r),_(lt.current.id,r.x,r.y,r.z)}if(o=Tw.relativeCoordinates(o.x,o.y,o.z,e),lt.current.type===V.Polygon){var n=lt.current;if(Ew.getState().moveHandleType===B.Default){var c,f,h=Tw.calculatePolygonCentroid(mt.current),p=(new Me.Vector3).fromArray(n.normal);Tw.isSame(p,St)?(c=-(h.x+o.z),f=o.y-h.y):Tw.isSame(p,jt)?(c=o.z-h.x,f=o.y-h.y):Tw.isSame(p,Ht)?(c=o.x-h.x,f=-(h.y+o.z)):Tw.isSame(p,zt)?(c=o.x-h.x,f=o.z-h.y):(c=o.x-h.x,f=o.y-h.y);var y=mt.current.map((function(e){return Object(d.a)({},e)}));y.forEach((function(e){e.x+=c,e.y+=f})),re(n.id,y)}}else Q(lt.current.id,o.x,o.y,o.z)}else if(Ew.getState().resizeHandleType)switch(lt.current.type){case V.SolarPanel:var g=lt.current,w=Em(g),v=Object(u.a)(w,2),A=v[0],T=v[1],P=Ew.getState().resizeAnchor,S=Ew.getState().resizeHandleType;if(S===K.Lower||S===K.Upper){var j=Math.max(1,Math.round(Math.abs(o.z-P.z)/T))*T,H=new Me.Vector3(0,0,o.z-P.z).normalize().multiplyScalar(j),z=(new Me.Vector3).addVectors(P,H.clone().divideScalar(2));F((function(e){var t=e.elements.find((function(e){return e.id===g.id}));t&&(t.cz=(z.z-Pt.current.z)/b,t.ly=Math.abs(H.z))}))}else if(S===K.Left||S===K.Right){var R=(new Me.Vector3).subVectors(o,P).setZ(0),D=Math.max(1,Math.round(R.length()/A))*A,M=R.clone().normalize().multiplyScalar(D),W=(new Me.Vector3).addVectors(P,M.clone().divideScalar(2)),I=(new Me.Vector3).subVectors(W,Pt.current).applyEuler(new Me.Euler(0,0,-Mt.current));F((function(e){var t=e.elements.find((function(e){return e.id===g.id}));t&&(Math.abs(Math.abs(t.normal[1])-1)<.01?t.cx=I.x/m:t.cy=I.y/x,t.lx=M.length())}))}break;case V.Polygon:if(Ew.getState().resizeHandleType===K.Default){var C,O,k=new Me.Vector3(o.x-Pt.current.x,o.y-Pt.current.y,0).applyEuler(new Me.Euler(0,0,-Mt.current,"ZXY")),Y=lt.current,L=(new Me.Vector3).fromArray(Y.normal);Tw.isSame(L,St)?(C=e.lz,O=e.ly,k.x=-o.z+Pt.current.z):Tw.isSame(L,jt)?(C=e.lz,O=e.ly,k.x=o.z-Pt.current.z):Tw.isSame(L,Ht)?(C=e.lx,O=e.lz,k.y=-o.z+Pt.current.z):Tw.isSame(L,zt)?(C=e.lx,O=e.lz,k.y=o.z-Pt.current.z):(C=e.lx,O=e.ly),(k=Ew.getState().enableFineGrid?Tw.snapToFineGrid(k):Tw.snapToNormalGrid(k)).x/=C,k.y/=O,ne(Y.id,Y.selectedIndex,k.x,k.y)}}}}}}},onPointerUp:function(){if(lt.current){var t=L(lt.current.id);if(t&&t.parentId===s){if(t.type===V.Polygon){if(Ew.getState().moveHandleType||Ew.getState().resizeHandleType){wt.current=t.vertices.map((function(e){return Object(d.a)({},e)}));var l={name:Ew.getState().moveHandleType?"Move Polygon":"Resize Polygon",timestamp:Date.now(),oldValue:mt.current,newValue:wt.current,changedElementId:t.id,changedElementType:t.type,undo:function(){re(l.changedElementId,l.oldValue)},redo:function(){re(l.changedElementId,l.newValue)}};oe(l)}}else if(Ew.getState().resizeHandleType){if(ct.current.x=t.cx,ct.current.y=t.cy,ct.current.z=t.cz,ht.current.x=t.lx,ht.current.y=t.ly,ht.current.z=t.lz,ct.current.distanceToSquared(nt.current)>At&&ht.current.distanceToSquared(ft.current)>At){var a={name:"Resize",timestamp:Date.now(),resizedElementId:lt.current.id,resizedElementType:lt.current.type,oldCx:nt.current.x,oldCy:nt.current.y,oldCz:nt.current.z,newCx:ct.current.x,newCy:ct.current.y,newCz:ct.current.z,oldLx:ft.current.x,oldLy:ft.current.y,oldLz:ft.current.z,newLx:ht.current.x,newLy:ht.current.y,newLz:ht.current.z,undo:function(){Q(a.resizedElementId,a.oldCx,a.oldCy,a.oldCz),Z(a.resizedElementId,a.oldLx,a.oldLy,a.oldLz)},redo:function(){Q(a.resizedElementId,a.newCx,a.newCy,a.newCz),Z(a.resizedElementId,a.newLx,a.newLy,a.newLz)}};oe(a)}}else if(Ew.getState().rotateHandleType){if(lt.current.type===V.SolarPanel){var o=lt.current;if(Math.abs(gt.current-pt.current)>At)if(function(t,l){var a=JSON.parse(JSON.stringify(t));return a.relativeAzimuth=l,ce(a)?(Qh(me.t("message.RotationCancelledBecauseOfOverlap",Wt)),!1):!!Tw.isSolarCollectorWithinHorizontalSurface(a,e)||(Qh(me.t("message.RotationOutsideBoundaryCancelled",Wt)),!1)}(o,gt.current)){F((function(e){e.selectedElementAngle=gt.current}));var i={name:"Rotate",timestamp:Date.now(),oldValue:pt.current,newValue:gt.current,changedElementId:o.id,changedElementType:o.type,undo:function(){te(i.changedElementId,i.oldValue)},redo:function(){te(i.changedElementId,i.newValue)}};oe(i)}else te(o.id,pt.current)}}else if(ct.current.x=t.cx,ct.current.y=t.cy,ct.current.z=t.cz,ut.current.fromArray(t.normal),ct.current.distanceToSquared(nt.current)>At){var r=!0;if(t.type===V.SolarPanel&&(r=wl(t,t.cx,t.cy)),r){var n,c={name:"Move",timestamp:Date.now(),movedElementId:lt.current.id,movedElementType:null===(n=lt.current)||void 0===n?void 0:n.type,oldCx:nt.current.x,oldCy:nt.current.y,oldCz:nt.current.z,oldNormal:dt.current.clone(),newCx:ct.current.x,newCy:ct.current.y,newCz:ct.current.z,newNormal:ut.current.clone(),undo:function(){Q(c.movedElementId,c.oldCx,c.oldCy,c.oldCz),c.oldNormal&&_(c.movedElementId,c.oldNormal.x,c.oldNormal.y,c.oldNormal.z)},redo:function(){Q(c.movedElementId,c.newCx,c.newCy,c.newCz),c.newNormal&&_(c.movedElementId,c.newNormal.x,c.newNormal.y,c.newNormal.z)}};oe(c)}else Q(t.id,nt.current.x,nt.current.y,nt.current.z)}lt.current=null}}},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===tt.current&&Ge(!0))},onPointerOut:function(){if(Ge(!1),lt.current)switch(lt.current.type){case V.Human:case V.Tree:case V.Flower:qe(!1);break;case V.SolarPanel:var e=Ew.getState().getElementById(lt.current.id);Ew.getState().moveHandleType&&!wl(e,e.cx,e.cy)&&Q(e.id,nt.current.x,nt.current.y,nt.current.z)}},onPointerEnter:function(e){lt.current&&Tw.isPlantOrHuman(lt.current)&&(e.intersections[0].object===tt.current&&qe(!0))},children:Al}),(null===(l=lt.current)||void 0===l?void 0:l.type)===V.SolarPanel&&ml&&!lt.current.locked&&Object(gf.jsx)(Lt.f,{ref:xt,name:"Cuboid Intersection Plane",position:Ft,args:[m,x],visible:!1,onPointerMove:function(t){if(xt.current&<.current&&e){if(lt.current.type!==V.SolarPanel||!ml)return;var l=lt.current;if(l.parentId!==s||l.locked)return;we.setFromCamera(xe,ye);var a=we.intersectObjects([xt.current]);if(a.length>0){var o=a[0].point.clone();if(Ew.getState().moveHandleType)o=Tw.relativeCoordinates(o.x,o.y,o.z-l.poleHeight,e),Q(l.id,o.x,o.y,o.z);else if(Ew.getState().rotateHandleType&&Ew.getState().rotateHandleType!==q.Tilt){var i=Mt.current,r=new Me.Vector2(Pt.current.x,Pt.current.y),n=new Me.Vector2(e.lx*l.cx,e.ly*l.cy).rotateAround(Dt,i),c=(new Me.Vector2).addVectors(n,r),d=-i+Math.atan2(-o.x+c.x,o.y-c.y)+(Ew.getState().rotateHandleType===q.Lower?0:Math.PI),u=d+(Math.abs(d)>Math.PI?-Math.sign(d)*bt:0);te(l.id,u),gt.current=u}else if(Ew.getState().resizeHandleType){var f=Ew.getState().resizeAnchor,h=le(l.pvModelName),p=new Me.Vector2(o.x,o.y),y=new Me.Vector2(f.x,f.y),g=p.distanceTo(y),w=l.relativeAzimuth+Mt.current,v=(new Me.Vector2).subVectors(p,y);switch(Ew.getState().resizeHandleType){case K.Lower:case K.Upper:var b=Ew.getState().resizeHandleType===K.Lower?1:-1,A=v.angle()-w+b*vt,T=g*Math.cos(A);if(l.orientation===$.portrait)T=Math.max(1,Math.ceil((T-h.length/2)/h.length))*h.length;else T=Math.max(1,Math.ceil((T-h.width/2)/h.width))*h.width;var P=f.x+b*(T*Math.sin(w))/2,S=f.y-b*(T*Math.cos(w))/2,j=new Me.Vector2(P,S),H=new Me.Vector2(Pt.current.x,Pt.current.y),z=(new Me.Vector2).subVectors(j,H).rotateAround(Dt,-Mt.current),R=z.x/m,D=z.y/x;xl(l,R,D,l.lx,T)&&(G(l.id,T),Q(l.id,R,D));break;case K.Left:case K.Right:var M=Ew.getState().resizeHandleType===K.Left?-1:1,W=v.angle()-w+(Ew.getState().resizeHandleType===K.Left?Math.PI:0),I=g*Math.cos(W);if(l.orientation===$.portrait)I=Math.max(1,Math.ceil((I-h.width/2)/h.width))*h.width;else I=Math.max(1,Math.ceil((I-h.length/2)/h.length))*h.length;var C=f.x+M*(I*Math.cos(w))/2,O=f.y+M*(I*Math.sin(w))/2,F=new Me.Vector2(C,O),k=new Me.Vector2(Pt.current.x,Pt.current.y),Y=(new Me.Vector2).subVectors(F,k).rotateAround(Dt,-Mt.current),L=Y.x/m,E=Y.y/x;xl(l,L,E,I,l.ly)&&(J(l.id,I),Q(l.id,L,E))}}}}}}),Ke&&Object(gf.jsxs)(gf.Fragment,{children:[(Ew.getState().moveHandleType||Ew.getState().resizeHandleType)&&Object(gf.jsx)(mf,{hx:rt.current.x,hy:rt.current.y,hz:rt.current.z,position:ot.current,rotation:it.current}),Ew.getState().rotateHandleType&<.current&<.current.type===V.SolarPanel&&Object(gf.jsx)(ly,{element:lt.current,height:lt.current.poleHeight+Ot})]}),O&&Object(gf.jsx)(cy,{element:e,verticalLift:gl}),(!O||he)&&Object(gf.jsx)(ry,{hx:It,hy:Ct,hz:Ot,lineColor:he&&Y?"white":S,lineWidth:he&&Y?5*H:H}),O&&R&&Object(gf.jsx)(ry,{hx:It,hy:Ct,hz:Ot,lineColor:yt,lineWidth:5*H}),Pl&&Object(gf.jsx)(iw,{id:s,args:Tl}),(Je||M)&&!O&&Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",text:Yt,color:null!==(a=null===e||void 0===e?void 0:e.labelColor)&&void 0!==a?a:"white",fontSize:null!==(i=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==i?i:20,fontFace:"Roboto",textHeight:null!==(n=null===e||void 0===e?void 0:e.labelSize)&&void 0!==n?n:.2,position:[0,0,Ot+(null!==(c=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==c?c:.2)]})]})},yw=n.a.memo(pw),gw=function(e){var t,l,a,i,n=e.id,c=e.cx,s=e.cy,d=e.cz,h=e.lx,p=void 0===h?1:h,y=e.ly,g=void 0===y?1:y,m=e.lz,w=void 0===m?.1:m,x=e.rotation,v=void 0===x?[0,0,0]:x,b=e.normal,A=void 0===b?[0,0,1]:b,T=e.color,P=void 0===T?"white":T,S=e.lineColor,j=void 0===S?"black":S,H=e.lineWidth,z=void 0===H?.1:H,R=e.locked,D=void 0!==R&&R,M=e.showLabel,W=void 0!==M&&M,I=e.parentId,C=e.foundationId,O=(e.light,e.heatFlux,Ew(si)),F=Ew(Vi),k=Ew(o.shadowEnabled),Y=Ew(is),L=_f(n),E=Object(Se.f)().gl.domElement,U=Object(r.useState)(!1),N=Object(u.a)(U,2),J=N[0],G=N[1],K=Object(r.useRef)(),q=Object(r.useRef)(),Q=Object(r.useMemo)((function(){return{lng:F}}),[F]),Z=Ew((function(e){var t,l=Object(f.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===I)return a}}catch(o){l.e(o)}finally{l.f()}})),_=Ew((function(e){var t,l=Object(f.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===C)return a}}catch(o){l.e(o)}finally{l.f()}}));if(I&&Z)switch(Z.type){case V.Foundation:if(d=Z.cz+Z.lz/2,Tw.isZero(v[2]))c=Z.cx+c*Z.lx,s=Z.cy+s*Z.ly;else{var $=new Me.Vector3(c*Z.lx,s*Z.ly,0);$.applyAxisAngle(Rt,v[2]),c=Z.cx+$.x,s=Z.cy+$.y}break;case V.Wall:if((null===_||void 0===_?void 0:_.type)===V.Foundation){var ee=Tw.absoluteCoordinates(c,s,d,Z,_);c=ee.x,s=ee.y,d=ee.z}break;case V.Roof:if((null===_||void 0===_?void 0:_.type)===V.Foundation){var te=Tw.absoluteCoordinates(c,s,d,Z,_);c=te.x,s=te.y,d=te.z}}var le=w/2,ae=Object(r.useMemo)((function(){if((null===Z||void 0===Z?void 0:Z.type)===V.Wall){var e=Z,t=_?_.rotation[2]+e.relativeAngle:e.relativeAngle;return new Me.Euler(vt,0,t,"ZXY")}if((null===Z||void 0===Z?void 0:Z.type)===V.Roof)return new Me.Euler(v[0],v[1],_?_.rotation[2]+v[2]:v[2],"ZXY");if((null===Z||void 0===Z?void 0:Z.type)===V.Cuboid)return dw(A);var l=(new Me.Vector3).fromArray(A);return Tw.isSame(l,St)?new Me.Euler(0,vt,v[2],"ZXY"):Tw.isSame(l,jt)?new Me.Euler(0,-vt,v[2],"ZXY"):Tw.isSame(l,Ht)?new Me.Euler(-vt,0,v[2],"ZXY"):Tw.isSame(l,zt)?new Me.Euler(vt,0,v[2],"ZXY"):new Me.Euler(0,0,v[2])}),[A,v,null===_||void 0===_?void 0:_.rotation]),oe=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.SensorElement",Q))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",Q)+")":"")+"\n"+me.t("word.Coordinates",Q)+": ("+c.toFixed(1)+", "+s.toFixed(1)+", "+d.toFixed(1)+") "+me.t("word.MeterAbbreviation",Q)}),[null===e||void 0===e?void 0:e.label,D,F,c,s,d]);return Object(gf.jsxs)("group",{name:"Sensor Group "+n,rotation:ae,position:[c,s,d+le],children:[Object(gf.jsx)(Lt.a,{receiveShadow:k,uuid:n,ref:K,args:[p,g,w],name:"Sensor",onPointerDown:function(e){2!==e.button&&(Y(n,e,X.Move),Et.getState().setEnableOrbitController(!1),Tf.setState((function(e){e.showWallIntersectionPlaneId=I,e.oldParentId=I,e.oldFoundationId=C})),O((function(e){e.moveHandleType=B.Default})))},onContextMenu:function(e){Y(n,e,X.ContextMenu),O((function(t){e.intersections.length>0&&(e.intersections[0].object===K.current&&(t.contextMenuObjectType=V.Sensor))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===K.current&&(G(!0),E.style.cursor="move"))},onPointerOut:function(){G(!1),E.style.cursor="default"},children:Object(gf.jsx)("meshStandardMaterial",{attach:"material",color:(null===e||void 0===e?void 0:e.lit)?pt:P})}),Object(gf.jsx)(Lt.d,{userData:{unintersectable:!0},name:"Meter",castShadow:!1,receiveShadow:!1,args:[.3*p,.3*g,le,8,1],position:new Me.Vector3(0,0,le),rotation:[vt,0,0],children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",color:"black"})}),!L&&Object(gf.jsx)(ry,{hx:p/2,hy:g/2,hz:w/2,lineColor:j,lineWidth:z}),L&&D&&Object(gf.jsx)(ry,{hx:p/2,hy:g/2,hz:w/2,lineColor:yt,lineWidth:10*z}),L&&!D&&Object(gf.jsx)(Lt.h,{ref:q,position:new Me.Vector3(0,0,0),args:[st,6,6,0,Math.PI],name:B.Default,onPointerDown:function(e){2===e.button?(Y(n,e,X.ContextMenu),O((function(t){e.intersections.length>0&&(e.intersections[0].object===q.current&&(t.contextMenuObjectType=V.Sensor))}))):Y(n,e,X.Move),Et.getState().setEnableOrbitController(!1),Tf.setState((function(e){e.showWallIntersectionPlaneId=I,e.oldParentId=I,e.oldFoundationId=C})),O((function(e){e.moveHandleType=B.Default}))},children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",color:"orange"})}),(J||W)&&!L&&Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:oe,color:null!==(t=null===e||void 0===e?void 0:e.labelColor)&&void 0!==t?t:"white",fontSize:null!==(l=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==l?l:20,textHeight:null!==(a=null===e||void 0===e?void 0:e.labelSize)&&void 0!==a?a:.2,position:[0,0,w+(null!==(i=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==i?i:.2)]})]})},mw=n.a.memo(gw),ww=function(e){var t,l,a,i,n=e.id,c=e.cx,s=e.cy,d=e.cz,h=e.lx,p=void 0===h?1:h,y=e.ly,g=void 0===y?1:y,m=e.lz,w=void 0===m?.1:m,x=e.rotation,v=void 0===x?[0,0,0]:x,b=e.normal,A=void 0===b?[0,0,1]:b,T=e.color,P=void 0===T?"#ffff99":T,S=(e.lineColor,e.lineWidth),j=void 0===S?.1:S,H=e.locked,z=void 0!==H&&H,R=e.showLabel,D=void 0!==R&&R,M=e.parentId,W=e.foundationId,I=e.decay,C=void 0===I?2:I,O=e.distance,F=void 0===O?5:O,k=e.intensity,Y=void 0===k?3:k,L=e.inside,E=void 0!==L&&L,U=Ew(si),N=Ew(Vi),J=Ew(o.shadowEnabled),G=Ew(is),K=Ew(Es).z<=0,q=_f(n),Q=Object(Se.f)().gl.domElement,Z=Object(r.useState)(!1),_=Object(u.a)(Z,2),$=_[0],ee=_[1],te=Object(r.useRef)(),le=Object(r.useRef)(),ae=Object(r.useMemo)((function(){return{lng:N}}),[N]),oe=Ew((function(e){var t,l=Object(f.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===M)return a}}catch(o){l.e(o)}finally{l.f()}})),ie=Ew((function(e){var t,l=Object(f.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(a.id===W)return a}}catch(o){l.e(o)}finally{l.f()}})),re=.1;if(M&&oe)switch(oe.type){case V.Foundation:if(d=oe.cz+oe.lz/2,Tw.isZero(v[2]))c=oe.cx+c*oe.lx,s=oe.cy+s*oe.ly;else{var ne=new Me.Vector3(c*oe.lx,s*oe.ly,0);ne.applyAxisAngle(Rt,v[2]),c=oe.cx+ne.x,s=oe.cy+ne.y}break;case V.Wall:if((null===ie||void 0===ie?void 0:ie.type)===V.Foundation){var ce=Tw.absoluteCoordinates(c,s,d,oe,ie);c=ce.x,s=ce.y,d=ce.z}re=oe.ly;break;case V.Roof:if((null===ie||void 0===ie?void 0:ie.type)===V.Foundation){var se=Tw.absoluteCoordinates(c,s,d,oe,ie);c=se.x,s=se.y,d=se.z}re=oe.thickness}var de=w/2,ue=Object(r.useMemo)((function(){if((null===oe||void 0===oe?void 0:oe.type)===V.Wall){var e=oe,t=ie?ie.rotation[2]+e.relativeAngle:e.relativeAngle;return new Me.Euler(vt,0,t,"ZXY")}if((null===oe||void 0===oe?void 0:oe.type)===V.Roof)return new Me.Euler(v[0],v[1],ie?ie.rotation[2]+v[2]:v[2],"ZXY");if((null===oe||void 0===oe?void 0:oe.type)===V.Cuboid)return dw(A);var l=(new Me.Vector3).fromArray(A);return Tw.isSame(l,St)?new Me.Euler(0,vt,v[2],"ZXY"):Tw.isSame(l,jt)?new Me.Euler(0,-vt,v[2],"ZXY"):Tw.isSame(l,Ht)?new Me.Euler(-vt,0,v[2],"ZXY"):Tw.isSame(l,zt)?new Me.Euler(vt,0,v[2],"ZXY"):new Me.Euler(0,0,v[2])}),[A,v,null===ie||void 0===ie?void 0:ie.rotation]),fe=Object(r.useMemo)((function(){return((null===e||void 0===e?void 0:e.label)?e.label:me.t("shared.LightElement",ae))+((null===e||void 0===e?void 0:e.locked)?" ("+me.t("shared.ElementLocked",ae)+")":"")+"\n"+me.t("word.Coordinates",ae)+": ("+c.toFixed(1)+", "+s.toFixed(1)+", "+d.toFixed(1)+") "+me.t("word.MeterAbbreviation",ae)}),[null===e||void 0===e?void 0:e.label,z,N,c,s,d]);return Object(gf.jsxs)("group",{name:"Light Group "+n,rotation:ue,position:[c,s,d],children:[K&&Object(gf.jsx)("pointLight",{color:P,name:"Point Light "+n,position:[0,0,E?-re-de:de],decay:C,distance:F,intensity:Y,castShadow:!0}),Object(gf.jsx)(Lt.d,{receiveShadow:J,userData:{unintersectable:!0},uuid:n,ref:te,position:[0,0,E?-re:0],rotation:[vt,0,0],args:[.5*p,.5*g,de,16,1],name:"Light Base",onPointerDown:function(e){2!==e.button&&(G(n,e,X.Move),Et.getState().setEnableOrbitController(!1),Tf.setState((function(e){e.showWallIntersectionPlaneId=M,e.oldParentId=M,e.oldFoundationId=W})))},onContextMenu:function(e){G(n,e,X.ContextMenu),U((function(t){e.intersections.length>0&&(e.intersections[0].object===te.current&&(t.contextMenuObjectType=V.Light))}))},onPointerOver:function(e){e.intersections.length>0&&(e.intersections[0].object===te.current&&(ee(!0),Q.style.cursor="move"))},onPointerOut:function(){ee(!1),Q.style.cursor="default"},children:Object(gf.jsx)("meshStandardMaterial",{attach:"material",color:"lightgray"})}),Object(gf.jsx)(Lt.h,{userData:{unintersectable:!0},name:"Light Bulb",castShadow:!1,receiveShadow:J,args:[.3*p,8,8,0,bt,0,Math.PI],position:new Me.Vector3(0,0,E?-re-de:de),rotation:[vt,0,0],children:K?Object(gf.jsx)("meshBasicMaterial",{attach:"material",color:"white"}):Object(gf.jsx)("meshStandardMaterial",{attach:"material",color:"white"})}),q&&z&&Object(gf.jsx)(ry,{hx:p/2,hy:g/2,hz:w/2,lineColor:yt,lineWidth:10*j}),q&&!z&&Object(gf.jsx)(Lt.h,{ref:le,position:new Me.Vector3(0,0,E?-re-de:de),args:[st,6,6,E?Math.PI:0,Math.PI],name:B.Default,onPointerDown:function(e){2===e.button?(G(n,e,X.ContextMenu),U((function(t){e.intersections.length>0&&(e.intersections[0].object===le.current&&(t.contextMenuObjectType=V.Light))}))):G(n,e,X.Move),Et.getState().setEnableOrbitController(!1),Tf.setState((function(e){e.showWallIntersectionPlaneId=M,e.oldParentId=M,e.oldFoundationId=W}))},children:Object(gf.jsx)("meshBasicMaterial",{attach:"material",color:"orange"})}),($||D)&&!q&&Object(gf.jsx)("textSprite",{userData:{unintersectable:!0},name:"Label",fontFace:"Roboto",text:fe,color:null!==(t=null===e||void 0===e?void 0:e.labelColor)&&void 0!==t?t:"white",fontSize:null!==(l=null===e||void 0===e?void 0:e.labelFontSize)&&void 0!==l?l:20,textHeight:null!==(a=null===e||void 0===e?void 0:e.labelSize)&&void 0!==a?a:.2,position:[0,0,(E?-re:0)+w+(null!==(i=null===e||void 0===e?void 0:e.labelHeight)&&void 0!==i?i:.2)]})]})},xw=n.a.memo(ww),vw="Cuboid Wrapper",bw="Cuboid Stackable Child",Aw=function e(t){var l=t.elements,a=t.cuboidModel,o=a.cx,i=a.cy,r=a.lz,n=a.rotation,c=r/2;return Object(gf.jsx)(gf.Fragment,{children:Object(gf.jsxs)("group",{name:vw,position:[o,i,c],rotation:[0,0,n[2]],children:[Object(gf.jsx)(yw,Object(d.a)({},a)),l.map((function(t){if(function(e){return Jm(e)&&e.parentId===a.id}(t))return Object(gf.jsx)("group",{name:bw,position:[0,0,c],children:Object(gf.jsx)(e,{elements:l,cuboidModel:t})},t.id);if(t.parentId===a.id){var o=a.lx,i=a.ly,r=a.lz;switch(t.type){case V.SolarPanel:return Object(gf.jsx)(hw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);case V.Sensor:return Object(gf.jsx)(mw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);case V.Light:return Object(gf.jsx)(xw,Object(d.a)(Object(d.a)({},t),{},{cx:t.cx*o,cy:t.cy*i,cz:t.cz*r}),t.id);default:return null}}}))]})})},Tw=function(){function e(){Object(He.a)(this,e)}return Object(Fe.a)(e,null,[{key:"calculateProfit",value:function(e){return.001*(e.yearlyYield*e.sellingPrice-e.panelCount*e.unitCost*365)}},{key:"calculateCost",value:function(e){return e.panelCount*e.unitCost*.365}},{key:"getLatLngKey",value:function(e,t){return e.toFixed(4)+", "+t.toFixed(4)}},{key:"getModelKey",value:function(e){return e.title+", "+e.userid}},{key:"resizeCanvas",value:function(e,t,l){var a=document.createElement("canvas");a.width=t,a.height=l||t*e.height/e.width;var o=a.getContext("2d");return o&&o.drawImage(e,0,0,e.width,e.height,0,0,a.width,a.height),a}},{key:"getEuler",value:function(e,t,l,a,o,i){var r=new Me.Quaternion;r.setFromUnitVectors(e,t);var n=new Me.Euler;return n.setFromQuaternion(r),l&&(n.order=l),a&&(n.x+=a),o&&(n.y+=o),i&&(n.z+=i),n}},{key:"zero2DArray",value:function(e){for(var t=0;t0&&((t.intersections.filter((function(e){return!e.eventObject.name.startsWith("Wall Intersection Plane")}))[0].object===t.eventObject||o)&&l((function(l){var o,r,n,c,s,d=Object(f.a)(l.elements);try{for(d.s();!(s=d.n()).done;){var u=s.value;if(u.id===e)if(u.selected=!0,l.selectedElement=u,l.selectedElementHeight=u.lz,l.groupActionMode){var h,p=null!==(h=u.foundationId)&&void 0!==h?h:null;!p&&Lw(u)&&(p=Tw.getBaseId(u.id)),p&&(l.multiSelectionsMode||l.selectedElementIdSet.clear(),l.selectedElementIdSet.has(p)?l.selectedElementIdSet.delete(p):l.selectedElementIdSet.add(p))}else if(a===X.ContextMenu)if(l.selectedElementIdSet.has(e)){var y,g=Object(f.a)(l.elements);try{for(g.s();!(y=g.n()).done;){var m=y.value;l.selectedElementIdSet.has(m.id)&&m.type!==l.selectedElement.type&&l.selectedElementIdSet.delete(m.id)}}catch(b){g.e(b)}finally{g.f()}}else if(l.multiSelectionsMode){l.selectedElementIdSet.add(e);var w,x=Object(f.a)(l.elements);try{for(x.s();!(w=x.n()).done;){var v=w.value;l.selectedElementIdSet.has(v.id)&&v.type!==l.selectedElement.type&&l.selectedElementIdSet.delete(v.id)}}catch(b){x.e(b)}finally{x.f()}}else l.selectedElementIdSet.clear(),l.selectedElementIdSet.add(e);else l.multiSelectionsMode?l.selectedElementIdSet.has(e)?l.selectedElementIdSet.delete(e):l.selectedElementIdSet.add(e):(l.selectedElementIdSet.clear(),l.selectedElementIdSet.add(e));else u.selected=!1}}catch(b){d.e(b)}finally{d.f()}if(l.moveHandleType=null,l.resizeHandleType=null,l.rotateHandleType=null,a)switch(a){case X.Move:(null===(o=l.selectedElement)||void 0===o?void 0:o.type)===V.Tree||(null===(r=l.selectedElement)||void 0===r?void 0:r.type)===V.Human?l.moveHandleType=B.Default:l.moveHandleType=t.eventObject.name,i(!1);break;case X.Resize:l.resizeHandleType=t.eventObject.name,i(!1);break;case X.Rotate:l.rotateHandleType=t.eventObject.name,i(!1);break;case X.Select:l.selectedElementAngle=null!==(n=null===(c=t.object.parent)||void 0===c?void 0:c.rotation.z)&&void 0!==n?n:0,i(!0);break;default:i(!0)}})))},updateAllElementLocks:function(e){l((function(t){var l,a=Object(f.a)(t.elements);try{for(a.s();!(l=a.n()).done;){l.value.locked=e}}catch(o){a.e(o)}finally{a.f()}}))},updateElementLockByFoundationId:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.foundationId!==e&&i.parentId!==e&&i.id!==e||(i.locked=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLockByParentId:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.parentId===e&&t===r.type&&(r.locked=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLockById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.locked=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementReferenceById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.referenceId=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLabelById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.label=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementShowLabelById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.showLabel=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementColorById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.color=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementColorOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Tw.isIdentical(n.normal,a)&&!n.locked&&(n.color=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementColorAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.color=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementColorForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.color=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineColorById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lineColor=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineColorOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Tw.isIdentical(n.normal,a)&&!n.locked&&(n.lineColor=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLineColorAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lineColor=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLineColorForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lineColor=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineWidthById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e){i.lineWidth=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLineWidthOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;n.type===e&&n.parentId===t&&Tw.isIdentical(n.normal,a)&&!n.locked&&(n.lineWidth=o)}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLineWidthAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lineWidth=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLineWidthForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lineWidth=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCxById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cx=t,i.type===V.SolarPanel&&i.parentType===V.Roof&&(l.updateElementOnRoofFlag=!0);break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCyById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cy=t,i.type===V.SolarPanel&&i.parentType===V.Roof&&(l.updateElementOnRoofFlag=!0);break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCzById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.cz=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementCzForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.cz=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLxById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lx=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLxAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lx=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLxOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.lx=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLxForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lx=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLyById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.ly=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLyAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.ly=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLyOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.ly=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLyForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.ly=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLzById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked){i.lz=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateElementLzAboveFoundation:function(e,t,a){l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||(r.lz=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateElementLzOnSurface:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.lz=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateElementLzForAll:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.lz=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateElementRotationById:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;(n.id!==e||n.locked)&&(n.parentId!==e||Jm(n))||(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o)}}catch(c){r.e(c)}finally{r.f()}l.selectedElementAngle=o}))},updateElementRotationForAll:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e)n.locked||(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o);else{var c=l.getParent(n);c&&!c.locked&&c.type===e&&(n.rotation[0]=t,n.rotation[1]=a,n.rotation[2]=o)}}}catch(s){r.e(s)}finally{r.f()}}))},updateSolarCollectorDrawSunBeamById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Tw.isSolarCollector(i)){i.drawSunBeam=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorDrawSunBeamAboveFoundation:function(e,t,a){Tw.isSolarCollectorType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type===e&&(r.drawSunBeam=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorDrawSunBeamForAll:function(e,t){Tw.isSolarCollectorType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.locked||i.type===e&&(i.drawSunBeam=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorRelativeAzimuthById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Tw.isSolarCollector(i)){i.relativeAzimuth=t,l.selectedElementAngle=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorRelativeAzimuthAboveFoundation:function(e,t,a){Tw.isSolarCollectorType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type!==e||r.foundationId!==t||r.locked||r.parentType===V.Wall||(r.relativeAzimuth=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorRelativeAzimuthOnSurface:function(e,t,a,o){Tw.isSolarCollectorType(e)&&l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===e&&!n.locked){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.relativeAzimuth=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorRelativeAzimuthForAll:function(e,t){Tw.isSolarCollectorType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||i.parentType===V.Wall||(i.relativeAzimuth=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleHeightById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Tw.isSolarCollector(i)){i.poleHeight=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleHeightAboveFoundation:function(e,t,a){Tw.isSolarCollectorType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type!==e||(r.poleHeight=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorPoleHeightOnSurface:function(e,t,a,o){Tw.isSolarCollectorType(e)&&l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(!n.locked&&n.type===e){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.poleHeight=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorPoleHeightForAll:function(e,t){Tw.isSolarCollectorType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.poleHeight=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleRadiusById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&!i.locked&&Tw.isSolarCollector(i)){i.poleRadius=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorPoleRadiusAboveFoundation:function(e,t,a){Tw.isSolarCollectorType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.foundationId!==t||r.locked||r.type!==e||(r.poleRadius=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateSolarCollectorPoleRadiusOnSurface:function(e,t,a,o){Tw.isSolarCollectorType(e)&&l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(!n.locked&&n.type===e){(a?n.parentId===t&&Tw.isIdentical(n.normal,a):n.parentId===t)&&(n.poleRadius=o)}}}catch(c){r.e(c)}finally{r.f()}}))},updateSolarCollectorPoleRadiusForAll:function(e,t){Tw.isSolarCollectorType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type!==e||i.locked||(i.poleRadius=t)}}catch(r){o.e(r)}finally{o.f()}}))},clearAllSolarCollectorYields:function(){l((function(e){var t,l=Object(f.a)(e.elements);try{for(l.s();!(t=l.n()).done;){var a=t.value;if(Tw.isSolarCollector(a)){var o=a;o.dailyYield=0,o.yearlyYield=0}}}catch(i){l.e(i)}finally{l.f()}}))},updateSolarCollectorDailyYieldById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isSolarCollector(i)){i.dailyYield=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateSolarCollectorYearlyYieldById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isSolarCollector(i)){i.yearlyYield=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateCspReflectanceById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isCspCollector(i)){i.reflectance=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateCspReflectanceAboveFoundation:function(e,t,a){Tw.isCspCollectorType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.reflectance=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateCspReflectanceForAll:function(e,t){Tw.isCspCollectorType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.reflectance=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorAbsorptanceById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isParabolicCollector(i)){i.absorptance=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorAbsorptanceAboveFoundation:function(e,t,a){Tw.isParabolaType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.absorptance=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorAbsorptanceForAll:function(e,t){Tw.isParabolaType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.absorptance=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorOpticalEfficiencyById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isParabolicCollector(i)){i.opticalEfficiency=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorOpticalEfficiencyAboveFoundation:function(e,t,a){Tw.isParabolaType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.opticalEfficiency=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorOpticalEfficiencyForAll:function(e,t){Tw.isParabolaType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.opticalEfficiency=t)}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorThermalEfficiencyById:function(e,t){l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id===e&&Tw.isParabolicCollector(i)){i.thermalEfficiency=t;break}}}catch(r){o.e(r)}finally{o.f()}}))},updateParabolicCollectorThermalEfficiencyAboveFoundation:function(e,t,a){Tw.isParabolaType(e)&&l((function(l){var o,i=Object(f.a)(l.elements);try{for(i.s();!(o=i.n()).done;){var r=o.value;r.type===e&&r.foundationId===t&&(r.thermalEfficiency=a)}}catch(n){i.e(n)}finally{i.f()}}))},updateParabolicCollectorThermalEfficiencyForAll:function(e,t){Tw.isParabolaType(e)&&l((function(l){var a,o=Object(f.a)(l.elements);try{for(o.s();!(a=o.n()).done;){var i=a.value;i.type===e&&(i.thermalEfficiency=t)}}catch(r){o.e(r)}finally{o.f()}}))},foundationActionScope:_.OnlyThisObject,setFoundationActionScope:function(e){l((function(t){t.foundationActionScope=e}))},cuboidActionScope:_.OnlyThisSide,setCuboidActionScope:function(e){l((function(t){t.cuboidActionScope=e}))},polygonActionScope:_.OnlyThisObject,setPolygonActionScope:function(e){l((function(t){t.polygonActionScope=e}))},updatePolygonVertexPositionById:function(e,t,a,o){l((function(l){var i,r=Object(f.a)(l.elements);try{for(r.s();!(i=r.n()).done;){var n=i.value;if(n.type===V.Polygon&&n.id===e){var c=n;t>=0&&t11&&(o=0),i=(c-s)/(s+Tw.daysOfMonth(o,r)/2)}return{low:t[a]+(t[o]-t[a])*i,high:l[a]+(l[o]-l[a])*i}},zT=function(e,t,l,a,o,i,r,n,c){return function(e,t,l,a,o,i){for(var r=l.length,n=0,c=-1e3,s=1e3,d=-1e3,u=1e3,f=0;f0&&(I.set(p+(C+.5)*f,y+(O+.5)*h),I.rotateAround(g,e.rotation[2]),m.set(I.x,I.y,c),j(e.id,m,R)||(A[C][O]+=W*D))}}var F=P*b/60,k=F>At?w.sunshineHours[l]/(30*F*o.timesPerHour):0;E(A,k),d(e.id,A)},D=function(e){var t=e.solarUpdraftTower;if(t){for(var l,a,i=x.getFullYear(),r=x.getMonth(),n=x.getDate(),c=Tw.dayOfYear(x),s=t.collectorRadius,u=Math.max(2,Math.round(2*s/T)),f=e.cx-s+T/2,h=e.cy-s+T/2,p=e.lz+t.collectorHeight,y=Array(u).fill(0).map((function(){return Array(u).fill(0)})),g=new Me.Vector3(0,0,p),m=s*s,A=0,P=0;P<24;P++)for(var S=0;S0&&(N(e.id,v,t)||(b[H][z]+=P*A)))}else for(var W=0;W0){var C=W-s/2+.5,F=I-d/2+.5;v.set(g.x+C*w,g.y+C*x,g.z+F*f),N(e.id,v,t)||(b[W][I]+=P*A)}}},Q=function(e,t,l,a){var o,i=a[0][0].z,r=Tw.dayOfYear(S),n=zy(e,r,j,ny.SPHERE_MODEL),s=new Me.Euler(0,0,l.rotation[2],"ZYX"),d=Number.MAX_VALUE,u=Number.MAX_VALUE,h=-Number.MAX_VALUE,p=-Number.MAX_VALUE,y=Object(f.a)(a);try{for(y.s();!(o=y.n()).done;){var g,m=o.value,w=Object(f.a)(m);try{for(w.s();!(g=w.n()).done;){var x=g.value.clone().applyEuler(s);x.x>h&&(h=x.x),x.x