@roomle/web-sdk 2.76.0 → 2.77.0-alpha.2

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 (189) hide show
  1. package/lib/{banana-for-scale-00c51c97.nomodule.js → banana-for-scale-747faad0.nomodule.js} +2 -2
  2. package/lib/{banana-for-scale-00c51c97.nomodule.js.map → banana-for-scale-747faad0.nomodule.js.map} +1 -1
  3. package/lib/{banana-for-scale-6bb1ee7e.js → banana-for-scale-9b1f01e9.js} +2 -2
  4. package/lib/{banana-for-scale-6bb1ee7e.js.map → banana-for-scale-9b1f01e9.js.map} +1 -1
  5. package/lib/{camera-behaviour-c7eaa412.js → camera-behaviour-d6af6d09.js} +2 -2
  6. package/lib/{camera-behaviour-c7eaa412.js.map → camera-behaviour-d6af6d09.js.map} +1 -1
  7. package/lib/{camera-behaviour-35b9043c.nomodule.js → camera-behaviour-eee26e60.nomodule.js} +2 -2
  8. package/lib/{camera-behaviour-35b9043c.nomodule.js.map → camera-behaviour-eee26e60.nomodule.js.map} +1 -1
  9. package/lib/{component-dimensioning-be6f4978.nomodule.js → component-dimensioning-505e3be3.nomodule.js} +2 -2
  10. package/lib/component-dimensioning-505e3be3.nomodule.js.map +1 -0
  11. package/lib/{component-dimensioning-b340ff88.js → component-dimensioning-a87836c0.js} +2 -2
  12. package/lib/component-dimensioning-a87836c0.js.map +1 -0
  13. package/lib/{component-raycast-helper-fbc6ea71.js → component-raycast-helper-357d58fb.js} +2 -2
  14. package/lib/component-raycast-helper-357d58fb.js.map +1 -0
  15. package/lib/{component-raycast-helper-b5e775b6.nomodule.js → component-raycast-helper-4260f5f3.nomodule.js} +2 -2
  16. package/lib/component-raycast-helper-4260f5f3.nomodule.js.map +1 -0
  17. package/lib/{configurator-0545dd74.nomodule.js → configurator-28c8e5dc.nomodule.js} +2 -2
  18. package/lib/configurator-28c8e5dc.nomodule.js.map +1 -0
  19. package/lib/{configurator-e8e7249b.js → configurator-7be15b5d.js} +2 -2
  20. package/lib/configurator-7be15b5d.js.map +1 -0
  21. package/lib/configurator-main-9627b78d.js +2 -0
  22. package/lib/configurator-main-9627b78d.js.map +1 -0
  23. package/lib/configurator-main.nomodule.js +1 -1
  24. package/lib/{continuous-drawing-helper-3bf27c77.js → continuous-drawing-helper-51677944.js} +2 -2
  25. package/lib/continuous-drawing-helper-51677944.js.map +1 -0
  26. package/lib/{continuous-drawing-helper-c48a8810.nomodule.js → continuous-drawing-helper-ecb99fa7.nomodule.js} +2 -2
  27. package/lib/continuous-drawing-helper-ecb99fa7.nomodule.js.map +1 -0
  28. package/lib/{default-light-setting-50a8aae2.js → default-light-setting-432c00f7.js} +2 -2
  29. package/lib/default-light-setting-432c00f7.js.map +1 -0
  30. package/lib/{default-light-setting-4b8e7ee6.nomodule.js → default-light-setting-8492f1aa.nomodule.js} +2 -2
  31. package/lib/default-light-setting-8492f1aa.nomodule.js.map +1 -0
  32. package/lib/definitions/common-core/src/configurator-kernel-access.d.ts +1 -0
  33. package/lib/definitions/common-core/src/utils/shims.d.ts +2 -2
  34. package/lib/definitions/configurator-core/src/roomle-configurator.d.ts +4 -4
  35. package/lib/definitions/configurator-core/src/services/configurator-ui-callback.d.ts +2 -2
  36. package/lib/definitions/glb-viewer-core/src/roomle-glb-viewer.d.ts +1 -1
  37. package/lib/definitions/material-viewer/src/roomle-material-viewer.d.ts +1 -1
  38. package/lib/definitions/planner-core/src/roomle-planner-ui-callback.d.ts +5 -0
  39. package/lib/definitions/typings/kernel.d.ts +1 -0
  40. package/lib/{dimensioning-helper-ab6b7f69.js → dimensioning-helper-02499f1a.js} +2 -2
  41. package/lib/{dimensioning-helper-ab6b7f69.js.map → dimensioning-helper-02499f1a.js.map} +1 -1
  42. package/lib/{dimensioning-helper-c84c6aa3.nomodule.js → dimensioning-helper-be6a25b7.nomodule.js} +2 -2
  43. package/lib/{dimensioning-helper-c84c6aa3.nomodule.js.map → dimensioning-helper-be6a25b7.nomodule.js.map} +1 -1
  44. package/lib/{glb-viewer-622cb79a.nomodule.js → glb-viewer-7282caf7.nomodule.js} +2 -2
  45. package/lib/{glb-viewer-622cb79a.nomodule.js.map → glb-viewer-7282caf7.nomodule.js.map} +1 -1
  46. package/lib/{glb-viewer-camera-behaviour-6088e966.js → glb-viewer-camera-behaviour-94516099.js} +2 -2
  47. package/lib/glb-viewer-camera-behaviour-94516099.js.map +1 -0
  48. package/lib/{glb-viewer-camera-behaviour-8633618f.nomodule.js → glb-viewer-camera-behaviour-bee9e036.nomodule.js} +2 -2
  49. package/lib/glb-viewer-camera-behaviour-bee9e036.nomodule.js.map +1 -0
  50. package/lib/{glb-viewer-4a506f4e.js → glb-viewer-f88249d7.js} +2 -2
  51. package/lib/{glb-viewer-4a506f4e.js.map → glb-viewer-f88249d7.js.map} +1 -1
  52. package/lib/glb-viewer-main-42ec8932.js +2 -0
  53. package/lib/glb-viewer-main-42ec8932.js.map +1 -0
  54. package/lib/glb-viewer-main.nomodule.js +1 -1
  55. package/lib/legacy/{banana-for-scale-ebedc20c.legacy.js → banana-for-scale-adf89519.legacy.js} +2 -2
  56. package/lib/legacy/{banana-for-scale-ebedc20c.legacy.js.map → banana-for-scale-adf89519.legacy.js.map} +1 -1
  57. package/lib/legacy/{camera-behaviour-022aa24e.legacy.js → camera-behaviour-529c19c2.legacy.js} +2 -2
  58. package/lib/legacy/{camera-behaviour-022aa24e.legacy.js.map → camera-behaviour-529c19c2.legacy.js.map} +1 -1
  59. package/lib/legacy/{component-dimensioning-5e8990a3.legacy.js → component-dimensioning-480dad60.legacy.js} +2 -2
  60. package/lib/legacy/component-dimensioning-480dad60.legacy.js.map +1 -0
  61. package/lib/legacy/{component-raycast-helper-e04ecdef.legacy.js → component-raycast-helper-a732cc57.legacy.js} +2 -2
  62. package/lib/legacy/component-raycast-helper-a732cc57.legacy.js.map +1 -0
  63. package/lib/legacy/{configurator-a4557504.legacy.js → configurator-0ee3fb6e.legacy.js} +2 -2
  64. package/lib/legacy/configurator-0ee3fb6e.legacy.js.map +1 -0
  65. package/lib/legacy/configurator-main.legacy.js +1 -1
  66. package/lib/legacy/{continuous-drawing-helper-605724b0.legacy.js → continuous-drawing-helper-1c6ee6c9.legacy.js} +2 -2
  67. package/lib/legacy/continuous-drawing-helper-1c6ee6c9.legacy.js.map +1 -0
  68. package/lib/legacy/{default-light-setting-4bfdc4a5.legacy.js → default-light-setting-e546d92d.legacy.js} +2 -2
  69. package/lib/legacy/default-light-setting-e546d92d.legacy.js.map +1 -0
  70. package/lib/legacy/{dimensioning-helper-d2bd342f.legacy.js → dimensioning-helper-d367a9ae.legacy.js} +2 -2
  71. package/lib/legacy/{dimensioning-helper-d2bd342f.legacy.js.map → dimensioning-helper-d367a9ae.legacy.js.map} +1 -1
  72. package/lib/legacy/{glb-viewer-c3cdd113.legacy.js → glb-viewer-32520b42.legacy.js} +2 -2
  73. package/lib/legacy/{glb-viewer-c3cdd113.legacy.js.map → glb-viewer-32520b42.legacy.js.map} +1 -1
  74. package/lib/legacy/{glb-viewer-camera-behaviour-db58cf5d.legacy.js → glb-viewer-camera-behaviour-e7544c90.legacy.js} +2 -2
  75. package/lib/legacy/glb-viewer-camera-behaviour-e7544c90.legacy.js.map +1 -0
  76. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  77. package/lib/legacy/{material-viewer-8323195c.legacy.js → material-viewer-9f4642e2.legacy.js} +2 -2
  78. package/lib/legacy/material-viewer-9f4642e2.legacy.js.map +1 -0
  79. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  80. package/lib/legacy/planner-ca9be806.legacy.js +2 -0
  81. package/lib/legacy/{planner-b5bb8ed7.legacy.js.map → planner-ca9be806.legacy.js.map} +1 -1
  82. package/lib/legacy/planner-main.legacy.js +1 -1
  83. package/lib/legacy/roomle-configurator-35ccd5e3.legacy.js +2 -0
  84. package/lib/legacy/roomle-configurator-35ccd5e3.legacy.js.map +1 -0
  85. package/lib/legacy/{roomle-dependency-injection-d61f4763.legacy.js → roomle-dependency-injection-32a7ed2e.legacy.js} +3 -3
  86. package/lib/legacy/{roomle-dependency-injection-d61f4763.legacy.js.map → roomle-dependency-injection-32a7ed2e.legacy.js.map} +1 -1
  87. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  88. package/lib/legacy/{script-loader-0d8dab5c.legacy.js → script-loader-d14aa469.legacy.js} +2 -2
  89. package/lib/legacy/script-loader-d14aa469.legacy.js.map +1 -0
  90. package/lib/legacy/static/ConfiguratorKernel-c4372bbeb5743db2.wasm +0 -0
  91. package/lib/legacy/static/RoomleCore-0a87ce9a99621bd9.wasm +0 -0
  92. package/lib/{static/RoomleToolsCore-3ed4fcaccf294e37.wasm → legacy/static/RoomleToolsCore-61c01f70818028fb.wasm} +0 -0
  93. package/lib/legacy/{stats-helper-3a7e4556.legacy.js → stats-helper-048249dd.legacy.js} +2 -2
  94. package/lib/legacy/stats-helper-048249dd.legacy.js.map +1 -0
  95. package/lib/legacy/{tools-core-6800c7b7.legacy.js → tools-core-bef6b8f0.legacy.js} +2 -2
  96. package/lib/legacy/tools-core-bef6b8f0.legacy.js.map +1 -0
  97. package/lib/{material-viewer-ea6dba3f.js → material-viewer-561c5edf.js} +2 -2
  98. package/lib/material-viewer-561c5edf.js.map +1 -0
  99. package/lib/{material-viewer-ac971800.nomodule.js → material-viewer-da069f1a.nomodule.js} +2 -2
  100. package/lib/material-viewer-da069f1a.nomodule.js.map +1 -0
  101. package/lib/material-viewer-main-36f6466f.js +2 -0
  102. package/lib/material-viewer-main-36f6466f.js.map +1 -0
  103. package/lib/material-viewer-main.nomodule.js +1 -1
  104. package/lib/planner-2128f72c.js +2 -0
  105. package/lib/{planner-e8b990fe.js.map → planner-2128f72c.js.map} +1 -1
  106. package/lib/planner-948239c6.nomodule.js +2 -0
  107. package/lib/{planner-7f1380f3.nomodule.js.map → planner-948239c6.nomodule.js.map} +1 -1
  108. package/lib/planner-main-feee1b27.js +2 -0
  109. package/lib/planner-main-feee1b27.js.map +1 -0
  110. package/lib/planner-main.nomodule.js +1 -1
  111. package/lib/roomle-configurator-760afe57.nomodule.js +2 -0
  112. package/lib/roomle-configurator-760afe57.nomodule.js.map +1 -0
  113. package/lib/roomle-configurator-b8abfbd1.js +2 -0
  114. package/lib/roomle-configurator-b8abfbd1.js.map +1 -0
  115. package/lib/{roomle-dependency-injection-a1a06d1e.nomodule.js → roomle-dependency-injection-b567df3a.nomodule.js} +3 -3
  116. package/lib/{roomle-dependency-injection-a1a06d1e.nomodule.js.map → roomle-dependency-injection-b567df3a.nomodule.js.map} +1 -1
  117. package/lib/{roomle-dependency-injection-ae5fa28d.js → roomle-dependency-injection-d3a8c907.js} +3 -3
  118. package/lib/{roomle-dependency-injection-ae5fa28d.js.map → roomle-dependency-injection-d3a8c907.js.map} +1 -1
  119. package/lib/{roomle-sdk-2ab19e90.js → roomle-sdk-7a4f6fc0.js} +2 -2
  120. package/lib/roomle-sdk-7a4f6fc0.js.map +1 -0
  121. package/lib/roomle-sdk.nomodule.js +1 -1
  122. package/lib/{script-loader-234d078e.js → script-loader-3c5eb130.js} +2 -2
  123. package/lib/script-loader-3c5eb130.js.map +1 -0
  124. package/lib/{script-loader-687f7fbc.nomodule.js → script-loader-ed493cd8.nomodule.js} +2 -2
  125. package/lib/script-loader-ed493cd8.nomodule.js.map +1 -0
  126. package/lib/static/ConfiguratorKernel-c4372bbeb5743db2.wasm +0 -0
  127. package/lib/static/RoomleCore-0a87ce9a99621bd9.wasm +0 -0
  128. package/lib/{legacy/static/RoomleToolsCore-3ed4fcaccf294e37.wasm → static/RoomleToolsCore-61c01f70818028fb.wasm} +0 -0
  129. package/lib/{stats-helper-b09eb905.js → stats-helper-92c35a95.js} +2 -2
  130. package/lib/stats-helper-92c35a95.js.map +1 -0
  131. package/lib/{stats-helper-e97ec5e1.nomodule.js → stats-helper-9bdccb5b.nomodule.js} +2 -2
  132. package/lib/stats-helper-9bdccb5b.nomodule.js.map +1 -0
  133. package/lib/{tools-core-33ca2cb1.js → tools-core-86b0b79b.js} +2 -2
  134. package/lib/tools-core-86b0b79b.js.map +1 -0
  135. package/lib/{tools-core-fd03b0a0.nomodule.js → tools-core-9e4e23dc.nomodule.js} +2 -2
  136. package/lib/tools-core-9e4e23dc.nomodule.js.map +1 -0
  137. package/package.json +2 -2
  138. package/lib/component-dimensioning-b340ff88.js.map +0 -1
  139. package/lib/component-dimensioning-be6f4978.nomodule.js.map +0 -1
  140. package/lib/component-raycast-helper-b5e775b6.nomodule.js.map +0 -1
  141. package/lib/component-raycast-helper-fbc6ea71.js.map +0 -1
  142. package/lib/configurator-0545dd74.nomodule.js.map +0 -1
  143. package/lib/configurator-e8e7249b.js.map +0 -1
  144. package/lib/configurator-main-422f9df6.js +0 -2
  145. package/lib/configurator-main-422f9df6.js.map +0 -1
  146. package/lib/continuous-drawing-helper-3bf27c77.js.map +0 -1
  147. package/lib/continuous-drawing-helper-c48a8810.nomodule.js.map +0 -1
  148. package/lib/default-light-setting-4b8e7ee6.nomodule.js.map +0 -1
  149. package/lib/default-light-setting-50a8aae2.js.map +0 -1
  150. package/lib/glb-viewer-camera-behaviour-6088e966.js.map +0 -1
  151. package/lib/glb-viewer-camera-behaviour-8633618f.nomodule.js.map +0 -1
  152. package/lib/glb-viewer-main-06539243.js +0 -2
  153. package/lib/glb-viewer-main-06539243.js.map +0 -1
  154. package/lib/legacy/component-dimensioning-5e8990a3.legacy.js.map +0 -1
  155. package/lib/legacy/component-raycast-helper-e04ecdef.legacy.js.map +0 -1
  156. package/lib/legacy/configurator-a4557504.legacy.js.map +0 -1
  157. package/lib/legacy/continuous-drawing-helper-605724b0.legacy.js.map +0 -1
  158. package/lib/legacy/default-light-setting-4bfdc4a5.legacy.js.map +0 -1
  159. package/lib/legacy/glb-viewer-camera-behaviour-db58cf5d.legacy.js.map +0 -1
  160. package/lib/legacy/material-viewer-8323195c.legacy.js.map +0 -1
  161. package/lib/legacy/planner-b5bb8ed7.legacy.js +0 -2
  162. package/lib/legacy/roomle-configurator-876d1ced.legacy.js +0 -2
  163. package/lib/legacy/roomle-configurator-876d1ced.legacy.js.map +0 -1
  164. package/lib/legacy/script-loader-0d8dab5c.legacy.js.map +0 -1
  165. package/lib/legacy/static/ConfiguratorKernel-031e65eaee5cacde.wasm +0 -0
  166. package/lib/legacy/static/RoomleCore-55c9812f52948f19.wasm +0 -0
  167. package/lib/legacy/stats-helper-3a7e4556.legacy.js.map +0 -1
  168. package/lib/legacy/tools-core-6800c7b7.legacy.js.map +0 -1
  169. package/lib/material-viewer-ac971800.nomodule.js.map +0 -1
  170. package/lib/material-viewer-ea6dba3f.js.map +0 -1
  171. package/lib/material-viewer-main-2d9d0a22.js +0 -2
  172. package/lib/material-viewer-main-2d9d0a22.js.map +0 -1
  173. package/lib/planner-7f1380f3.nomodule.js +0 -2
  174. package/lib/planner-e8b990fe.js +0 -2
  175. package/lib/planner-main-39d3166e.js +0 -2
  176. package/lib/planner-main-39d3166e.js.map +0 -1
  177. package/lib/roomle-configurator-4136c482.js +0 -2
  178. package/lib/roomle-configurator-4136c482.js.map +0 -1
  179. package/lib/roomle-configurator-e97356ed.nomodule.js +0 -2
  180. package/lib/roomle-configurator-e97356ed.nomodule.js.map +0 -1
  181. package/lib/roomle-sdk-2ab19e90.js.map +0 -1
  182. package/lib/script-loader-234d078e.js.map +0 -1
  183. package/lib/script-loader-687f7fbc.nomodule.js.map +0 -1
  184. package/lib/static/ConfiguratorKernel-031e65eaee5cacde.wasm +0 -0
  185. package/lib/static/RoomleCore-55c9812f52948f19.wasm +0 -0
  186. package/lib/stats-helper-b09eb905.js.map +0 -1
  187. package/lib/stats-helper-e97ec5e1.nomodule.js.map +0 -1
  188. package/lib/tools-core-33ca2cb1.js.map +0 -1
  189. package/lib/tools-core-fd03b0a0.nomodule.js.map +0 -1
@@ -1,9 +1,9 @@
1
- System.register(["./main-thread-to-worker-ff04af1e.nomodule.js"],(function(e,t){var n,s,i,a,r,o,l,h,d,c,u,p,m,g,f,_,v,w,b,y,S,x,P,M,C,T,A,R,E,I,D,O,L,k,U,B,N,F,G,j,z,V,H,W,K,q,X,Y,Q,Z,J,$,ee,te,ne,se,ie,ae,re,oe,le,he,de,ce,ue,pe,me,ge,fe,_e,ve,we,be,ye,Se,xe,Pe,Me,Ce,Te,Ae,Re,Ee,Ie,De,Oe,Le,ke,Ue,Be,Ne,Fe,Ge,je,ze,Ve,He,We,Ke,qe,Xe,Ye,Qe,Ze,Je,$e,et,tt,nt,st,it,at,rt,ot,lt,ht,dt,ct,ut,pt,mt,gt,ft,_t,vt,wt,bt,yt,St,xt,Pt,Mt,Ct,Tt,At,Rt,Et,It,Dt,Ot,Lt,kt,Ut,Bt,Nt,Ft,Gt,jt,zt,Vt,Ht,Wt,Kt,qt;return{setters:[function(e){n=e.g,s=e.A,i=e.D,a=e.V,r=e.a,o=e.R,l=e.S,h=e.C,d=e.M,c=e.B,u=e.b,p=e.T,m=e.c,g=e.d,f=e.L,_=e.e,v=e.F,w=e.f,b=e.P,y=e.h,S=e.i,x=e.j,P=e.k,M=e.Q,C=e.I,T=e.l,A=e.O,R=e.m,E=e.n,I=e.o,D=e.p,O=e.q,L=e.r,k=e.s,U=e.t,B=e.u,N=e.v,F=e.w,G=e.x,j=e.y,z=e.z,V=e.E,H=e.G,W=e.H,K=e.J,q=e.K,X=e.N,Y=e.U,Q=e.W,Z=e.X,J=e.Y,$=e.Z,ee=e._,te=e.$,ne=e.a0,se=e.a1,ie=e.a2,ae=e.a3,re=e.a4,oe=e.a5,le=e.a6,he=e.a7,de=e.a8,ce=e.a9,ue=e.aa,pe=e.ab,me=e.ac,ge=e.ad,fe=e.ae,_e=e.af,ve=e.ag,we=e.ah,be=e.ai,ye=e.aj,Se=e.ak,xe=e.al,Pe=e.am,Me=e.an,Ce=e.ao,Te=e.ap,Ae=e.aq,Re=e.ar,Ee=e.as,Ie=e.at,De=e.au,Oe=e.av,Le=e.aw,ke=e.ax,Ue=e.ay,Be=e.az,Ne=e.aA,Fe=e.aB,Ge=e.aC,je=e.aD,ze=e.aE,Ve=e.aF,He=e.aG,We=e.aH,Ke=e.aI,qe=e.aJ,Xe=e.aK,Ye=e.aL,Qe=e.aM,Ze=e.aN,Je=e.aO,$e=e.aP,et=e.aQ,tt=e.aR,nt=e.aS,st=e.aT,it=e.aU,at=e.aV,rt=e.aW,ot=e.aX,lt=e.aY,ht=e.aZ,dt=e.a_,ct=e.a$,ut=e.b0,pt=e.b1,mt=e.b2,gt=e.b3,ft=e.b4,_t=e.b5,vt=e.b6,wt=e.b7,bt=e.b8,yt=e.b9,St=e.ba,xt=e.bb,Pt=e.bc,Mt=e.bd,Ct=e.be,Tt=e.bf,At=e.bg,Rt=e.bh,Et=e.bi,It=e.bj,Dt=e.bk,Ot=e.bl,Lt=e.bm,kt=e.bn,Ut=e.bo,Bt=e.bp,Nt=e.bq,Ft=e.br,Gt=e.bs,jt=e.bt,zt=e.bu,Vt=e.bv,Ht=e.bw,Wt=e.bx,Kt=e.by,qt=e.bz}],execute:function(){e({G:po,_:on,i:hn});class Xt{constructor(){this._context=new Map,this._lookups=new Map,this._singletons=new Map}getContext(e){if(this._context.has(e)){const t=this._context.get(e);return this._context.set(e,t+1),e+t}return this._context.set(e,1),e+0}addDependencyInjectionAssignments(e){e.forEach(e=>{this._lookups.set(e.className,e)})}lookup(e,t){if(!this._lookups.has(e))return null;const n=this._lookups.get(e);if(1===n.type&&void 0===t){const t="Dependency "+e+" has definition context but no context was defined!";return console.trace(t),console.error(t),null}let s=t&&1===n.type?t:"global";if(s+="_"+e,2===n.type)return new n.classDefinition;if(this._singletons.has(s))return this._singletons.get(s);const i=new n.classDefinition(t);return this._singletons.set(s,i),i}cleanUp(e){if(e){let t=[];this._singletons.forEach((n,s)=>{s.startsWith(e)&&t.push(s)}),t.forEach(e=>{this._singletons.delete(e)})}else this._singletons.clear(),this._singletons=new Map}}class Yt{constructor(e,t,n){this.className=e,this.classDefinition=t,this.type=void 0===n?0:n}}e("D",Yt);const Qt={JPG:".jpg",JPEG:".jpeg",PNG:".png",GIF:".gif"};class Zt{_base64toBlob(e,t){t=t||"";const n=atob(e),s=n.length,i=Math.ceil(s/1024),a=new Array(i);for(let e=0;e<i;++e){let t=1024*e,i=Math.min(t+1024,s);const r=new Array(i-t);for(let e=t,s=0;e<i;++s,++e)r[s]=n[e].charCodeAt(0);a[e]=new Uint8Array(r)}return new Blob(a,{type:t})}_createFormData(e,t,n,s){const i=new FormData;-1!==e.indexOf(",")&&(e=e.substr(e.indexOf(",")+1));const a=-1===Object.keys(Qt).map(e=>Qt[e]).indexOf(n)?"application":"image",r=this._base64toBlob(e,a+"/"+n.substr(1));return i.append(s,r,t+n),i}create(e,t,n,s){return this._createFormData(e,t,n,s)}}const Jt=e("r",{SOFA:"sofa",SHELF:"shelf",SHELF_FRONT:"shelf_front",BAKED:"baked",CAMERA:"camera",EQUAL:"equal"});class $t{static createDynamicLightSettingSource(e,t){let s={};if(e)s.url=e;else if(t)switch(t){case Jt.SHELF:s.url=n()+"static/shelf-2975dd3f2fa9c763.json";break;case Jt.SHELF_FRONT:s.url=n()+"static/shelf_front-8c9566a4512f0de8.json";break;case Jt.SOFA:s.url=n()+"static/sofa-997b116bc5f2e92e.json";break;case Jt.BAKED:s.url=n()+"static/baked-6485a2b1daeb69e8.json";break;case Jt.CAMERA:s.url=n()+"static/camera-05824b47cdb951e4.json";break;case Jt.EQUAL:s.url=n()+"static/equal-319f6b83c827913f.json";break;default:s.url=n()+"static/camera-05824b47cdb951e4.json"}else s=null;return s}parse(e){let t=JSON.parse(e);return t.lights?this.load(t):[]}load(e){let t=[];return e.lights?(e.lights.forEach(e=>{let n;switch(e.type){case"ambient":n=this._parseAmbientLight(e);break;case"rectarea":n=this._parseRectAreaLight(e);break;case"spot":n=this._parseSpotLight(e);break;case"directional":n=this._parseDirectionalLight(e)}n&&t.push(n)}),t):[]}_parseAmbientLight(e){let t=new s;return this._parseCommon(t,e),t}_parseRectAreaLight(e){let{intensity:t,castShadow:n,target:s,width:l,height:h}=e,d=null;if(n&&$t.rectAreaLightReplacement){const n=new i;this._parseCommon(n,e),d=n,n.castShadow=!0,n.shadow.camera.near=.1,n.shadow.camera.far=100,n.shadow.mapSize=new a(1024,1024),n.shadow.bias=-5e-5,n.shadow.normalBias=.01,n.intensity=t?t/100:1,n.lookAt(s?new r(s.x,s.y,s.z):new r(0,0,0))}else{const n=new o;this._parseCommon(n,e),d=n,n.width=l||.8,n.height=h||.8,n.castShadow=!1,n.matrixAutoUpdate=!0,n.intensity=(t||240)/((l||.8)*(h||.8)),n.lookAt(s?new r(s.x,s.y,s.z):new r(0,0,0)),$t.rectAreaLightLoadingListener&&$t.rectAreaLightLoadingListener(n)}return d}_parseSpotLight(e){let t=new l;this._parseCommon(t,e);let{angle:n,penumbra:s,target:i,castShadow:o}=e;return t.angle=(n||100)*Math.PI/180,t.penumbra=s||.5,t.lookAt(i?new r(i.x,i.y,i.z):new r(0,0,0)),t.shadow.camera.near=.1,t.shadow.camera.far=10,t.shadow.mapSize=new a(1024,1024),t.castShadow=o||!1,t}_parseDirectionalLight(e){let t=new i;this._parseCommon(t,e);let{target:n,castShadow:s}=e;return t.castShadow=s||!1,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize=new a(1024,1024),t.shadow.bias=-5e-5,t.lookAt(n?new r(n.x,n.y,n.z):new r(0,0,0)),t}_parseCommon(e,t){let{name:n,intensity:s,color:i,position:a,movesWithCamera:o}=t;e.name=n||"",e.intensity=s||1,e.color=new h(i||"#ffffff"),e.position.copy(a?new r(a.x,a.y,a.z):new r(0,0,0)),e.visible=!0,e.layers.set(1),e.userData.movesWithCamera=o}}e("q",$t),$t.rectAreaLightReplacement=!0;const en=e("z",()=>{var e;const t=(()=>{if(window.__RML__ENV__&&window.__RML__ENV__.skipIframeCheck)return!1;try{return window.self!==window.top}catch(e){return!0}})();let n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href;if(!n)return null;if(t){if(!document.referrer)return null;n=document.referrer}const{hostname:s}=new URL(n);return s}),tn=["127.0.0.1","localhost","0.0.0.0"],nn=(e("O",(function(e){return!(!e||"string"!=typeof e||e.split(":").length>2)})),e("K",e=>{if(!e||"string"!=typeof e)return null;const t=e.split(":");return t.length<2?null:t[0]})),sn=({articleNr:e,componentId:t})=>e&&""!==e?t.split(":")[0]+":"+e:null,an=(e,t)=>null!=e?"string"==typeof e?"true"===e:!0===e:("string"==typeof t&&(t=parseInt(t,10)),t>=200&&t<300);class rn{constructor(){this._queue=[],this._pendingRequests=0}_nextSlot(){if(this._pendingRequests-=1,!this._queue.length)return;const{request:e,resolve:t,reject:n}=this._queue.shift();this._fetch(e).then(t,n)}_fetch(e,t={},n={}){return this._pendingRequests+=1,new Promise((s,i)=>{self.fetch(e,t).then(async function(e){this._nextSlot();const t=!n.checkResponse||!1!==await n.checkResponse(e);if(an(e.ok,e.status)&&t)s(...arguments);else{const t=(null==e?void 0:e.url)||"URL unknown";i(new Error(e.statusText||'Http error "'+(e&&e.status?e.status:"unknown")+'", for "'+t+'"'))}}.bind(this),e=>{this._nextSlot(),i(e)})})}fetch(e,t={},n={}){return this._pendingRequests>=40?new Promise((t,n)=>this._queue.push({request:e,resolve:t,reject:n})):this._fetch(e,t,n)}}function on(e,t,n,s){var i,a=arguments.length,r=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,s);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(r=(a<3?i(r):a>3?i(t,n,r):i(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}"function"==typeof SuppressedError&&SuppressedError;const ln=function(e){return e.startsWith("_")&&(e=e.substr(1)),e.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(function(e,t){return(t>0?"-":"")+e.toLowerCase()}))};function hn(e,t){const n=Symbol("property-cache");Object.defineProperty(e,t,{get(){if(!this[n]){const e=window.__RML__DI__.lookup(ln(t),this._creator_);e?this[n]=e:console.error("Dependency "+ln(t)+" not found! Add dependency to /utils/injectables.ts")}return this[n]}})}class dn{info(...e){console}log(...e){console}warn(...e){console.warn.apply(console,e)}error(...e){console.warn.apply(console,e)}}e("L",dn);class cn extends dn{constructor(e){super(),this._creator_=e}setMeta(e){this._meta=e}get meta(){return this._meta?this._meta:{}}throw(e){const t="[Kernel Exception]: "+e;this._globalCallback.onKernelMsg("exception",e,this.meta),this.error(t)}error(e){this._globalCallback.onKernelMsg("error",e,this.meta),super.error(e)}warn(e){this._globalCallback.onKernelMsg("warning",e,this.meta),super.warn(e)}}on([hn],cn.prototype,"_globalCallback",void 0);const un=new Map,pn=new Map,mn=new Map,gn=new Map;class fn{constructor(e){this._bootCallbacks=[],this._isStarted=!1,this._isStarting=!1,this._alwaysUseCache=!1,this._creator_=e}start(e){return this._configuratorUiCallbacks.onSyncStarted(),this._startWorker().then(()=>this._handleCatalog(e)).then(()=>{const{typeChangeTag:e,floorMaterialsTag:t}=this._initData;Promise.all([this._syncFloorTag(t),this._syncTypeChangeTag(e)]).then(()=>{gn.set(e,!0),this._configuratorUiCallbacks.onSyncDone()})})}syncCatalog(e){return this._startWorker().then(()=>this._handleCatalog(e))}syncFloorTag(e){return this._startWorker().then(()=>this._syncFloorTag(e))}syncTypeChangeTag(e){return this._startWorker().then(()=>this._syncTypeChangeTag(e))}_syncFloorTag(e){const t=[];return e&&!mn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{t.push(this._handleMaterialsAndTextures(e))}),this._singlePromiseFactory.create(1,e,n=>{Promise.all(t).then(()=>{mn.set(e,!0),n()},e=>this._softReject(n,'_syncFloorTag error: "'+e+'"'))})):Promise.resolve()}_syncTypeChangeTag(e){const t=[];return e&&!gn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{this._rapiAccess.getItems(e.items).then(e=>{e.forEach(e=>{this.getIsCatalogSynced(e.catalog)&&t.push(this._handleCatalog(e.catalog))})})}),this._singlePromiseFactory.create(2,e,n=>{Promise.all(t).then(()=>{mn.set(e,!0),n()},e=>this._softReject(n,'_syncTypeChangeTag error: "'+e+'"'))})):Promise.resolve()}getIsCatalogSynced(e){return!!pn.get(e)}_startWorker(){return new Promise((e,t)=>{if(this._isStarted)return e();this._bootCallbacks.push({resolve:e,reject:t}),this._isStarting||(this._worker=new Worker(n()+"static/asset-loader.worker-1735a5fb1e401244.js"),this._mainThreadToWorker=new d(this,this._worker),this._isStarting=!0,this._mainThreadToWorker.sendToWorker(1))})}onCommand(e,t,n){switch(e){case 4:this._isStarted=!0,this._bootCallbacks.forEach(({resolve:e})=>e());break;case 3:this._mainThreadToWorker.resolvePromises(t,n)}}_handleCatalog(e){return this._singlePromiseFactory.create(0,e,t=>this.getIsCatalogSynced(e)?t():this._rapiAccess.getCatalog(e).then(e=>Promise.all([this._handleContentWithAssets(this._rapiAccess.getComponentsOf(e),["perspectiveImage"]),this._handleItemsAndAdditionalContents(e),this._handleMaterialsAndTextures(e),this._handleExternalMeshes(e),this._handleTags(e.tags)])).then(()=>{pn.set(e,!0),t()},e=>this._softReject(t,'Catalog sync error: "'+e+'"')))}_handleTags(e){return this._handleContentWithAssets(this._rapiAccess.getTags(e),["pngIcon","svgIcon"])}_handleExternalMeshes(e){return new Promise(t=>{this._rapiAccess.getMeshesOfCatalog(e.id).then(e=>{const n=[];e.forEach(e=>{n.push(this._handleContentWithAssets(Promise.all([this._rapiAccess.getMesh(e.id)]),["url"]))}),Promise.all(n).then(t,e=>this._softReject(t,'Sync crt files error: "'+e+'"'))},e=>this._softReject(t,'getMeshesOfCatalog error: "'+e+'"'))})}_handleItemsAndAdditionalContents(e){return new Promise(t=>{this._rapiAccess.getItemsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["perspectiveImage"])),this._rapiAccess.getAdditionalContentsOfItems(e).then(e=>{const t=e.filter(e=>-1!==[5,6,4].indexOf(e.type));n.push(this._handleContentWithAssets(Promise.resolve(t),["content"]))},e=>this._softReject(t,'getAdditionalContentsOfItems error: "'+e+'"')),Promise.all(n).then(t,e=>this._softReject(t,'AdditionalContent image sync error:"'+e+'"'))})})}_handleMaterialsAndTextures(e){return new Promise(t=>{this._rapiAccess.getMaterialsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["thumbnail"])),e.forEach(e=>{n.push(this._handleContentWithAssets(this._rapiAccess.getTexturesOf(e),["image"]))}),Promise.all(n).then(t,e=>this._softReject(t,'getTexturesOf error: "'+e+'"'))},e=>this._softReject(t,'getMaterialsOf error: "'+e+'"'))})}_handleContentWithAssets(e,t){return new Promise(n=>e.then(e=>this._fetchAssets(e,t).then(n,e=>this._softReject(n,'_handleContentWithAssets error: "'+e+'"')),e=>this._softReject(n,'_handleContentWithAssets promise error: "'+e+'"')))}_fetchAssets(e,t){const n=[];e||(e=[]);for(let s=0,i=e.length;s<i;s++){const i=e[s];t.forEach(e=>{const t=i[e];t&&n.push(this._preCacheAsset(t))})}return Promise.all(n)}_preCacheAsset(e){return new Promise(t=>{if(un.get(e))return t();this._assetUrlToBase64(e).then(n=>{un.set(e,n),t()},e=>this._softReject(t,'_preCacheAsset error: "'+e+'"'))})}_assetUrlToBase64(e){return new Promise(t=>{this._mainThreadToWorker.sendToWorker(5,e,t,e=>this._softReject(t,'_assetUrlToBase64 error: "'+e+'"'))})}_softReject(e,t){this._errorHandler.softReject(e,t,2)}requestAsset(e,t=!1){return navigator.onLine&&!this._alwaysUseCache?e:un.get(e)||(t?e:null)}setAlwaysUseCache(e){this._alwaysUseCache=e}preFillAssetCache(e,t){un.set(e,t)}}e("a",fn),on([hn],fn.prototype,"_rapiAccess",void 0),on([hn],fn.prototype,"_singlePromiseFactory",void 0),on([hn],fn.prototype,"_errorHandler",void 0),on([hn],fn.prototype,"_configuratorUiCallbacks",void 0),on([hn],fn.prototype,"_initData",void 0);class _n{constructor(e){this.info=e,this._init()}_init(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){e&&this._resolve(e),this._resolve()}reject(e){this._reject(e)}wait(){return this._promise}reset(){this._init()}}function vn(e,t=!1){const n=null!==e[0].index,s=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},r={},o=e[0].morphTargetsRelative,l=new c;let h=0;for(let d=0;d<e.length;++d){const c=e[d];let u=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in c.attributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(c.attributes[e]),u++}if(u!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in c.morphAttributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;void 0===r[e]&&(r[e]=[]),r[e].push(c.morphAttributes[e])}if(t){let e;if(n)e=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;e=c.attributes.position.count}l.addGroup(h,e,d),h+=e}}if(n){let t=0;const n=[];for(let s=0;s<e.length;++s){const i=e[s].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[s].attributes.position.count}l.setIndex(n)}for(const e in a){const t=wn(a[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in r){const t=r[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let s=0;s<r[e].length;++s)t.push(r[e][s][n]);const s=wn(t);if(!s)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(s)}}return l}function wn(e){let t,n,s,i=-1,a=0;for(let r=0;r<e.length;++r){const o=e[r];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===s&&(s=o.normalized),s!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===i&&(i=o.gpuType),i!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=o.count*n}const r=new t(a),o=new u(r,n,s);let l=0;for(let t=0;t<e.length;++t){const s=e[t];if(s.isInterleavedBufferAttribute){const e=l/n;for(let t=0,i=s.count;t<i;t++)for(let i=0;i<n;i++){const n=s.getComponent(t,i);o.setComponent(t+e,i,n)}}else r.set(s.array,l);l+=s.count*n}return void 0!==i&&(o.gpuType=i),o}function bn(e,t){if(t===p)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===m||t===g){let n=e.getIndex();if(null===n){const t=[],s=e.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const s=n.count-2,i=[];if(t===m)for(let e=1;e<=s;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<s;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=e.clone();return a.setIndex(i),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}e("ah",_n);class yn extends f{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Tn(e)})),this.register((function(e){return new Un(e)})),this.register((function(e){return new Bn(e)})),this.register((function(e){return new Nn(e)})),this.register((function(e){return new Rn(e)})),this.register((function(e){return new En(e)})),this.register((function(e){return new In(e)})),this.register((function(e){return new Dn(e)})),this.register((function(e){return new Cn(e)})),this.register((function(e){return new On(e)})),this.register((function(e){return new An(e)})),this.register((function(e){return new kn(e)})),this.register((function(e){return new Ln(e)})),this.register((function(e){return new Pn(e)})),this.register((function(e){return new Fn(e)})),this.register((function(e){return new Gn(e)}))}load(e,t,n,s){const i=this;let a;if(""!==this.resourcePath)a=this.resourcePath;else if(""!==this.path){const t=_.extractUrlBase(e);a=_.resolveURL(t,this.path)}else a=_.extractUrlBase(e);this.manager.itemStart(e);const r=function(t){s?s(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,a,(function(n){t(n),i.manager.itemEnd(e)}),r)}catch(e){r(e)}}),n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const a={},r={},o=new TextDecoder;if("string"==typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===jn){try{a[xn.KHR_BINARY_GLTF]=new zn(e)}catch(e){return void(s&&s(e))}i=JSON.parse(a[xn.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new ds(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){const t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case xn.KHR_MATERIALS_UNLIT:a[t]=new Mn;break;case xn.KHR_DRACO_MESH_COMPRESSION:a[t]=new Vn(i,this.dracoLoader);break;case xn.KHR_TEXTURE_TRANSFORM:a[t]=new Hn;break;case xn.KHR_MESH_QUANTIZATION:a[t]=new Wn;break;default:n.indexOf(t)>=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(r),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise((function(s,i){n.parse(e,t,s,i)}))}}function Sn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const xn={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Pn{constructor(e){this.parser=e,this.name=xn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&void 0!==s.extensions[this.name].light&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const a=t.json,r=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let o;const d=new h(16777215);void 0!==r.color&&d.setRGB(r.color[0],r.color[1],r.color[2],w);const c=void 0!==r.range?r.range:0;switch(r.type){case"directional":o=new i(d),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new b(d),o.distance=c;break;case"spot":o=new l(d),o.distance=c,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,o.angle=r.spot.outerConeAngle,o.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return o.position.set(0,0,0),o.decay=2,is(o,r),void 0!==r.intensity&&(o.intensity=r.intensity),o.name=t.createUniqueName(r.name||"light_"+e),s=Promise.resolve(o),t.cache.add(n,s),s}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],i=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class Mn{constructor(){this.name=xn.KHR_MATERIALS_UNLIT}getMaterialType(){return y}extendParams(e,t,n){const s=[];e.color=new h(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],w),e.opacity=t[3]}void 0!==i.baseColorTexture&&s.push(n.assignTexture(e,"map",i.baseColorTexture,S))}return Promise.all(s)}}class Cn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name].emissiveStrength;return void 0!==s&&(t.emissiveIntensity=s),Promise.resolve()}}class Tn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new a(e,e)}return Promise.all(i)}}class An{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(t.iridescenceIOR=a.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(i)}}class Rn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=s.extensions[this.name];if(void 0!==a.sheenColorFactor){const e=a.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],w)}return void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,S)),void 0!==a.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(i)}}class En{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(i)}}class In{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const r=a.attenuationColor||[1,1,1];return t.attenuationColor=(new h).setRGB(r[0],r[1],r[2],w),Promise.all(i)}}class Dn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.ior=void 0!==s.ior?s.ior:1.5,Promise.resolve()}}class On{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const r=a.specularColorFactor||[1,1,1];return t.specularColor=(new h).setRGB(r[0],r[1],r[2],w),void 0!==a.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,S)),Promise.all(i)}}class Ln{constructor(e){this.parser=e,this.name=xn.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return t.bumpScale=void 0!==a.bumpFactor?a.bumpFactor:1,void 0!==a.bumpTexture&&i.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(i)}}class kn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.anisotropyStrength&&(t.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(t.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(i)}}class Un{constructor(e){this.parser=e,this.name=xn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,a)}}class Bn{constructor(e){this.parser=e,this.name=xn.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const a=i.extensions[t],r=s.images[a.source];let o=n.textureLoader;if(r.uri){const e=n.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,a.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Nn{constructor(e){this.parser=e,this.name=xn.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const a=i.extensions[t],r=s.images[a.source];let o=n.textureLoader;if(r.uri){const e=n.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,a.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Fn{constructor(e){this.name=xn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],s=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then((function(t){const n=e.byteOffset||0,s=e.byteLength||0,a=e.count,r=e.byteStride,o=new Uint8Array(t,n,s);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,r,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(a*r);return i.decodeGltfBuffer(new Uint8Array(t),a,r,o,e.mode,e.filter),t}))}))}return null}}class Gn{constructor(e){this.name=xn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const s=t.meshes[n.mesh];for(const e of s.primitives)if(e.mode!==Yn.TRIANGLES&&e.mode!==Yn.TRIANGLE_STRIP&&e.mode!==Yn.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,a=[],o={};for(const e in i)a.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],s=e[0].count,i=[];for(const e of n){const t=new P,n=new r,a=new M,l=new r(1,1,1),h=new C(e.geometry,e.material,s);for(let e=0;e<s;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&l.fromBufferAttribute(o.SCALE,e),h.setMatrixAt(e,t.compose(n,a,l));for(const t in o)if("_COLOR_0"===t){const e=o[t];h.instanceColor=new T(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);A.prototype.copy.call(h,e),this.parser.assignFinalMaterial(h),i.push(h)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}}const jn="glTF";class zn{constructor(e){this.name=xn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==jn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let a=0;for(;a<s;){const t=i.getUint32(a,!0);a+=4;const s=i.getUint32(a,!0);if(a+=4,1313821514===s){const s=new Uint8Array(e,12+a,t);this.content=n.decode(s)}else if(5130562===s){const n=12+a;this.body=e.slice(n,n+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Vn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=xn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,r={},o={},l={};for(const e in a){const t=es[e]||e.toLowerCase();r[t]=a[e]}for(const t in e.attributes){const s=es[t]||t.toLowerCase();if(void 0!==a[t]){const i=n.accessors[e.attributes[t]],a=Qn[i.componentType];l[s]=a.name,o[s]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t,n){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],s=o[t];void 0!==s&&(n.normalized=s)}t(e)}),r,l,w,n)}))}))}}class Hn{constructor(){this.name=xn.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Wn{constructor(){this.name=xn.KHR_MESH_QUANTIZATION}}class Kn extends _e{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let e=0;e!==s;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,a=this.sampleValues,r=this.valueSize,o=2*r,l=3*r,h=s-t,d=(n-t)/h,c=d*d,u=c*d,p=e*l,m=p-l,g=-2*u+3*c,f=u-c,_=1-g,v=f-c+d;for(let e=0;e!==r;e++){const t=a[m+e+r],n=a[m+e+o]*h,s=a[p+e+r],l=a[p+e]*h;i[e]=_*t+v*n+g*s+f*l}return i}}const qn=new M;class Xn extends Kn{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return qn.fromArray(i).normalize().toArray(i),i}}const Yn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Qn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Zn={9728:ne,9729:D,9984:se,9985:ie,9986:ae,9987:O},Jn={33071:re,33648:oe,10497:L},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},es={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ns={CUBICSPLINE:void 0,LINEAR:ee,STEP:le};function ss(e,t,n){for(const s in n.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=n.extensions[s])}function is(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function as(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,s=t.weights.length;n<s;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,s=n.length;t<s;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function rs(e){let t;const n=e.extensions&&e.extensions[xn.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+os(n.attributes):e.indices+":"+os(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,s=e.targets.length;n<s;n++)t+=":"+os(e.targets[n]);return t}function os(e){let t="";const n=Object.keys(e).sort();for(let s=0,i=n.length;s<i;s++)t+=n[s]+":"+e[n[s]]+";";return t}function ls(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const hs=new P;class ds{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Sn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,i=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=navigator.userAgent.indexOf("Firefox")>-1,i=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||s&&i<98?this.textureLoader=new R(this.options.manager):this.textureLoader=new E(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:n,userData:{}};return ss(i,a,s),is(a,s),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const s=t[n].joints;for(let t=0,n=s.length;t<n;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(n[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,s]of e.children.entries())i(s,t.children[n])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!s)throw new Error("Unknown type: "+e)}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return n.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[xn.KHR_BINARY_GLTF].body);const s=this.options;return new Promise((function(e,i){n.load(_.resolveURL(t.uri,s.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+n)}))}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse){const e=$n[s.type],t=Qn[s.componentType],n=!0===s.normalized,i=new t(s.count*e);return Promise.resolve(new u(i,e,n))}const i=[];return void 0!==s.bufferView?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),void 0!==s.sparse&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],a=$n[s.type],r=Qn[s.componentType],o=r.BYTES_PER_ELEMENT,l=o*a,h=s.byteOffset||0,d=void 0!==s.bufferView?n.bufferViews[s.bufferView].byteStride:void 0,c=!0===s.normalized;let p,m;if(d&&d!==l){const e=Math.floor(h/d),n="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+e+":"+s.count;let l=t.cache.get(n);l||(p=new r(i,e*d,s.count*d/o),l=new I(p,d/o),t.cache.add(n,l)),m=new de(l,a,h%d/o,c)}else p=null===i?new r(s.count*a):new r(i,h,s.count*a),m=new u(p,a,c);if(void 0!==s.sparse){const t=$n.SCALAR,n=Qn[s.sparse.indices.componentType],o=s.sparse.indices.byteOffset||0,l=s.sparse.values.byteOffset||0,h=new n(e[1],o,s.sparse.count*t),d=new r(e[2],l,s.sparse.count*a);null!==i&&(m=new u(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*a]),a>=2&&m.setY(t,d[e*a+1]),a>=3&&m.setZ(t,d[e*a+2]),a>=4&&m.setW(t,d[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,i=t.images[s];let a=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(a=e)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const s=this,i=this.json,a=i.textures[e],r=i.images[t],o=(r.uri||r.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||r.name||"",""===t.name&&"string"==typeof r.uri&&!1===r.uri.startsWith("data:image/")&&(t.name=r.uri);const n=(i.samplers||{})[a.sampler]||{};return t.magFilter=Zn[n.magFilter]||D,t.minFilter=Zn[n.minFilter]||O,t.wrapS=Jn[n.wrapS]||L,t.wrapT=Jn[n.wrapT]||L,s.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=n.images[e],a=self.URL||self.webkitURL;let r=i.uri||"",o=!1;if(void 0!==i.bufferView)r=this.getDependency("bufferView",i.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:i.mimeType});return r=a.createObjectURL(t),r}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(r).then((function(e){return new Promise((function(n,i){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new ce(e);t.needsUpdate=!0,n(t)}),t.load(_.resolveURL(e,s.path),a,void 0,i)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(r),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),i.extensions[xn.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[xn.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(a);a=i.extensions[xn.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return void 0!==s&&(a.colorSpace=s),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new k,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new B,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(s||i||a){let e="ClonedMaterial:"+n.uuid+":";s&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return N}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let r;const o={},l=[];if((i.extensions||{})[xn.KHR_MATERIALS_UNLIT]){const e=s[xn.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new h(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],w),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,S)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=F);const d=i.alphaMode||"OPAQUE";if("BLEND"===d?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===d&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&r!==y&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new a(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&r!==y&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&r!==y){const e=i.emissiveFactor;o.emissive=(new h).setRGB(e[0],e[1],e[2],w)}return void 0!==i.emissiveTexture&&r!==y&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,S)),Promise.all(l).then((function(){const n=new r(o);return i.name&&(n.name=i.name),is(n,i),t.associations.set(n,{materials:e}),i.extensions&&ss(s,n,i),n}))}createUniqueName(e){const t=G.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(e){return n[xn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return cs(n,e,t)}))}const a=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],o=rs(r),l=s[o];if(l)a.push(l.promise);else{let e;e=r.extensions&&r.extensions[xn.KHR_DRACO_MESH_COMPRESSION]?i(r):cs(new c,r,t),s[o]={primitive:r,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],a=i.primitives,r=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new N({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:he})),o.DefaultMaterial):this.getDependency("material",a[e].material);r.push(t)}var o;return r.push(t.loadGeometries(a)),Promise.all(r).then((function(n){const r=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],d=a[n];let c;const u=r[n];if(d.mode===Yn.TRIANGLES||d.mode===Yn.TRIANGLE_STRIP||d.mode===Yn.TRIANGLE_FAN||void 0===d.mode)c=!0===i.isSkinnedMesh?new j(h,u):new z(h,u),!0===c.isSkinnedMesh&&c.normalizeSkinWeights(),d.mode===Yn.TRIANGLE_STRIP?c.geometry=bn(c.geometry,g):d.mode===Yn.TRIANGLE_FAN&&(c.geometry=bn(c.geometry,m));else if(d.mode===Yn.LINES)c=new V(h,u);else if(d.mode===Yn.LINE_STRIP)c=new H(h,u);else if(d.mode===Yn.LINE_LOOP)c=new W(h,u);else{if(d.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);c=new K(h,u)}Object.keys(c.geometry.morphAttributes).length>0&&as(c,i),c.name=t.createUniqueName(i.name||"mesh_"+e),is(c,i),d.extensions&&ss(s,c,d),t.assignFinalMaterial(c),l.push(c)}for(let n=0,s=l.length;n<s;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return i.extensions&&ss(s,l[0],i),l[0];const h=new q;i.extensions&&ss(s,h,i),t.associations.set(h,{meshes:e});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(s)return"perspective"===n.type?t=new X(Y.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===n.type&&(t=new Q(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),is(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,s=t.joints.length;e<s;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),s=e,i=[],a=[];for(let e=0,r=s.length;e<r;e++){const r=s[e];if(r){i.push(r);const t=new P;null!==n&&t.fromArray(n.array,16*e),a.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Z(i,a)}))}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,a=[],r=[],o=[],l=[],h=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],i=t.target,d=i.node,c=void 0!==s.parameters?s.parameters[n.input]:n.input,u=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==i.node&&(a.push(this.getDependency("node",d)),r.push(this.getDependency("accessor",c)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(i))}return Promise.all([Promise.all(a),Promise.all(r),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(e){const t=e[0],s=e[1],a=e[2],r=e[3],o=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],h=s[e],d=a[e],c=r[e],u=o[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=n._createAnimationTracks(i,h,d,c,u);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}return new J(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return void 0===s.mesh?null:n.getDependency("mesh",s.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=s.weights.length;t<n;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],s=t._loadNodeShallow(e),i=[],a=n.children||[];for(let e=0,n=a.length;e<n;e++)i.push(t.getDependency("node",a[e]));const r=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),r]).then((function(e){const t=e[0],n=e[1],s=e[2];null!==s&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(s,hs)}));for(let e=0,s=n.length;e<s;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],a=i.name?s.createUniqueName(i.name):"",r=[],o=s._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&r.push(o),void 0!==i.camera&&r.push(s.getDependency("camera",i.camera).then((function(e){return s._getNodeRef(s.cameraCache,i.camera,e)}))),s._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){r.push(e)})),this.nodeCache[e]=Promise.all(r).then((function(t){let r;if(r=!0===i.isBone?new $:t.length>1?new q:1===t.length?t[0]:new A,r!==t[0])for(let e=0,n=t.length;e<n;e++)r.add(t[e]);if(i.name&&(r.userData.name=i.name,r.name=a),is(r,i),i.extensions&&ss(n,r,i),void 0!==i.matrix){const e=new P;e.fromArray(i.matrix),r.applyMatrix4(e)}else void 0!==i.translation&&r.position.fromArray(i.translation),void 0!==i.rotation&&r.quaternion.fromArray(i.rotation),void 0!==i.scale&&r.scale.fromArray(i.scale);return s.associations.has(r)||s.associations.set(r,{}),s.associations.get(r).nodes=e,r})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new q;n.name&&(i.name=s.createUniqueName(n.name)),is(i,n),n.extensions&&ss(t,i,n);const a=n.nodes||[],r=[];for(let e=0,t=a.length;e<t;e++)r.push(s.getDependency("node",a[e]));return Promise.all(r).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return s.associations=(e=>{const t=new Map;for(const[e,n]of s.associations)(e instanceof U||e instanceof ce)&&t.set(e,n);return e.traverse(e=>{const n=s.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i}))}_createAnimationTracks(e,t,n,s,i){const a=[],r=e.name?e.name:e.uuid,o=[];let l;switch(ts[i.path]===ts.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(r),ts[i.path]){case ts.weights:l=pe;break;case ts.rotation:l=me;break;case ts.position:case ts.scale:l=ue;break;default:switch(n.itemSize){case 1:l=pe;break;case 2:case 3:default:l=ue}}const h=void 0!==s.interpolation?ns[s.interpolation]:ee,d=this._getArrayFromAccessor(n);for(let e=0,n=o.length;e<n;e++){const n=new l(o[e]+"."+ts[i.path],t.array,d,h);"CUBICSPLINE"===s.interpolation&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=ls(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Xn:Kn)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function cs(e,t,n){const s=t.attributes,i=[];function a(t,s){return n.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(const t in s){const n=es[t]||t.toLowerCase();n in e.attributes||i.push(a(s[t],n))}if(void 0!==t.indices&&!e.index){const s=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(s)}return te.workingColorSpace!==w&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${te.workingColorSpace}" not supported.`),is(e,t),function(e,t,n){const s=t.attributes,i=new ge;if(void 0===s.POSITION)return;{const e=n.json.accessors[s.POSITION],t=e.min,a=e.max;if(void 0===t||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new r(t[0],t[1],t[2]),new r(a[0],a[1],a[2])),e.normalized){const t=ls(Qn[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const a=t.targets;if(void 0!==a){const e=new r,t=new r;for(let s=0,i=a.length;s<i;s++){const i=a[s];if(void 0!==i.POSITION){const s=n.json.accessors[i.POSITION],a=s.min,r=s.max;if(void 0!==a&&void 0!==r){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(r[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(r[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(r[2]))),s.normalized){const e=ls(Qn[s.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new fe;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let s=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(s=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(a=!0),s&&i&&a)break}if(!s&&!i&&!a)return Promise.resolve(e);const r=[],o=[],l=[];for(let h=0,d=t.length;h<d;h++){const d=t[h];if(s){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;r.push(t)}if(i){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(a){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],r=t[1],o=t[2];return s&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=r),a&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const us=new WeakMap;class ps extends f{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const i=new v(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,s)},n,s)}parse(e,t,n=(()=>{})){this.decodeDracoFile(e,t,null,null,S).catch(n)}decodeDracoFile(e,t,n,s,i=w,a=(()=>{})){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,r).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(us.has(e)){const t=us.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const i=this.workerNextTaskID++,a=e.byteLength,r=this._getWorker(i,a).then(n=>(s=n,new Promise((n,a)=>{s._callbacks[i]={resolve:n,reject:a},s.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return r.catch(()=>!0).then(()=>{s&&i&&this._releaseTask(s,i)}),us.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new c;e.index&&t.setIndex(new u(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],i=s.name,a=s.array,r=s.itemSize,o=new u(a,r);"color"===i&&(this._assignVertexColorSpace(o,s.vertexColorSpace),o.normalized=a instanceof Float32Array==0),t.setAttribute(i,o)}return t}_assignVertexColorSpace(e,t){if(t!==S)return;const n=new h;for(let t=0,s=e.count;t<s;t++)n.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,s)=>{n.load(e,t,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=ms.toString(),i=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){this.workerPool.map(e=>e._taskLoad)}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function ms(){let e,t;function n(e,t,n,s,i,a){const r=a.num_components(),o=n.num_points()*r,l=o*i.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,a,h,l,d);const c=new i(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:s,array:c,itemSize:r}}onmessage=function(s){const i=s.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const s=i.buffer,a=i.taskConfig;t.then(e=>{const t=e.draco,r=new t.Decoder;try{const e=function(e,t,s,i){const a=i.attributeIDs,r=i.attributeTypes;let o,l;const h=t.GetEncodedGeometryType(s);if(h===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(s,s.byteLength,o);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(s,s.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const s in a){const l=self[r[s]];let h,c;if(i.useUniqueIDs)c=a[s],h=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[a[s]]),-1===c)continue;h=t.GetAttribute(o,c)}const u=n(e,t,o,s,l,h);"color"===s&&(u.vertexColorSpace=i.vertexColorSpace),d.attributes.push(u)}return h===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const s=3*n.num_faces(),i=4*s,a=e._malloc(i);t.GetTrianglesUInt32Array(n,i,a);const r=new Uint32Array(e.HEAPF32.buffer,a,s).slice();return e._free(a),{array:r,itemSize:1}}(e,t,o)),e.destroy(o),d}(t,r,new Int8Array(s),a),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(r)}})}}}const gs={"draco_wasm_wrapper.js":"static/draco_wasm_wrapper-6263f3a4b71cdf3b.js","draco_decoder.wasm":"static/draco_decoder-b048235474cbf09e.wasm","draco_decoder.js":"static/draco_decoder-dc7f397e2a2ebac4.js"};class fs{constructor(e){this._context_=e}getStore(e="rml_default"){return this._localStorage.getItem(e)||{entries:[]}}saveStore(e,t){this._localStorage.setItem(e,t)}addItem(e,t,n="rml_default",s=5){const i=this.getStore(n),a=i.entries.find(t=>t.id===e);if(a?(a.payload=t,a.date=Date.now()):i.entries.push({id:e,date:Date.now(),payload:t}),i.entries.length>s)for(i.entries.sort((e,t)=>t.date-e.date);i.entries.length>s;)i.entries.pop();this.saveStore(n,i)}getItem(e,t="rml_default"){const n=this.getStore(t).entries.find(t=>t.id===e);return n?n.payload:null}}on([hn],fs.prototype,"_localStorage",void 0);const _s=e("t",(function(e){return e*(Math.PI/180)})),vs=e("H",(function(e){return e*(180/Math.PI)})),ws=(e("y",(function(e,t,n,s,i,a){e=Math.sqrt(e*e+n*n);const r=i/a,o=2*Math.atan(Math.tan(s*Math.PI/180/2)*r)*180/Math.PI,l=_s(s),h=t/2/Math.tan(l/2),d=e/(2*Math.atan(Math.PI*o/360));return Math.max(h,d)})),function(e){return Math.round(1e3*e)/1e3}),bs=(e("a3",(function(e,t){return Math.abs(e.y-t.y)+Math.abs(e.x-t.x)})),e("ad",e=>new r(e.x/1e3,e.z/1e3,e.y/-1e3))),ys=e=>new r(e.x/1e3,e.z/1e3,e.y/1e3),Ss=e("j",e=>({x:Math.round(1e3*e.x),y:Math.round(-1e3*e.z),z:Math.round(1e3*e.y)})),xs=e=>decodeURIComponent(encodeURIComponent(e)),Ps=e("V",e=>{if(!e){const t=typeof e;return"number"===t||"boolean"===t?e:null}if(!e.hasOwnProperty("size")&&e.size&&"function"==typeof e.size){let t=Ms(e);for(let e=0;e<t.length;e++)t[e]=Ps(t[e]);return"string"==typeof t?xs(t):t}if("object"==typeof e)for(let t in e)e.hasOwnProperty(t)&&(e[t]=Ps(e[t]));return"string"==typeof e?xs(e):e}),Ms=e=>{let t=[];if(e){let n=e.size();for(let s=0;s<n;s++)t.push(e.get(s))}return t},Cs=e=>{let t=new P,n=Ps(e);return t.fromArray(n),t.transpose(),(e=>{let t=new P;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),t.scale(new r(.001,.001,.001));let n=new P;return n.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),n.scale(new r(1e3,1e3,1e3)),t.multiply(e).multiply(n)})(t)};function Ts(e,t){var n=e.__state.conversionName.toString(),s=Math.round(e.r),i=Math.round(e.g),a=Math.round(e.b),r=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var d=e.hex.toString(16);d.length<6;)d="0"+d;return"#"+d}return"CSS_RGB"===n?"rgb("+s+","+i+","+a+")":"CSS_RGBA"===n?"rgba("+s+","+i+","+a+","+r+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+s+","+i+","+a+"]":"RGBA_ARRAY"===n?"["+s+","+i+","+a+","+r+"]":"RGB_OBJ"===n?"{r:"+s+",g:"+i+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+s+",g:"+i+",b:"+a+",a:"+r+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+r+"}":"unknown format"}var As=Array.prototype.forEach,Rs=Array.prototype.slice,Es={BREAK:{},extend:function(e){return this.each(Rs.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Rs.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Rs.call(arguments);return function(){for(var t=Rs.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(As&&e.forEach&&e.forEach===As)e.forEach(t,n);else if(e.length===e.length+0){var s,i=void 0;for(i=0,s=e.length;i<s;i++)if(i in e&&t.call(n,e[i],i)===this.BREAK)return}else for(var a in e)if(t.call(n,e[a],a)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var s=void 0;return function(){var i=this,a=arguments;function r(){s=null,n||e.apply(i,a)}var o=n||!s;clearTimeout(s),s=setTimeout(r,t),o&&e.apply(i,a)}},toArray:function(e){return e.toArray?e.toArray():Rs.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},Is=[{litmus:Es.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:Ts},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:Ts},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:Ts},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:Ts}}},{litmus:Es.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Es.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:Es.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Es.isNumber(e.r)&&Es.isNumber(e.g)&&Es.isNumber(e.b)&&Es.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(Es.isNumber(e.r)&&Es.isNumber(e.g)&&Es.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(Es.isNumber(e.h)&&Es.isNumber(e.s)&&Es.isNumber(e.v)&&Es.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(Es.isNumber(e.h)&&Es.isNumber(e.s)&&Es.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],Ds=void 0,Os=void 0,Ls=function(){Os=!1;var e=arguments.length>1?Es.toArray(arguments):arguments[0];return Es.each(Is,(function(t){if(t.litmus(e))return Es.each(t.conversions,(function(t,n){if(Ds=t.read(e),!1===Os&&!1!==Ds)return Os=Ds,Ds.conversionName=n,Ds.conversion=t,Es.BREAK})),Es.BREAK})),Os},ks=void 0,Us={hsv_to_rgb:function(e,t,n){var s=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),a=n*(1-t),r=n*(1-i*t),o=n*(1-(1-i)*t),l=[[n,o,a],[r,n,a],[a,n,o],[a,r,n],[o,a,n],[n,a,r]][s];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var s=Math.min(e,t,n),i=Math.max(e,t,n),a=i-s,r=void 0;return 0===i?{h:NaN,s:0,v:0}:(r=e===i?(t-n)/a:t===i?2+(n-e)/a:4+(e-t)/a,(r/=6)<0&&(r+=1),{h:360*r,s:a/i,v:i/255})},rgb_to_hex:function(e,t,n){var s=this.hex_with_component(0,2,e);return s=this.hex_with_component(s,1,t),this.hex_with_component(s,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(ks=8*t)|e&~(255<<ks)}},Bs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ns=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Fs=function(){function e(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(t,n,s){return n&&e(t.prototype,n),s&&e(t,s),t}}(),Gs=function e(t,n,s){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,s)}if("value"in i)return i.value;var r=i.get;return void 0!==r?r.call(s):void 0},js=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},zs=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},Vs=function(){function e(){if(Ns(this,e),this.__state=Ls.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Fs(e,[{key:"toString",value:function(){return Ts(this)}},{key:"toHexString",value:function(){return Ts(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function Hs(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Vs.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Vs.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function Ws(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Vs.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Vs.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Vs.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=Us.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Es.extend(e.__state,Us.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Vs.recalculateHSV=function(e){var t=Us.rgb_to_hsv(e.r,e.g,e.b);Es.extend(e.__state,{s:t.s,v:t.v}),Es.isNaN(t.h)?Es.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},Vs.COMPONENTS=["r","g","b","h","s","v","hex","a"],Hs(Vs.prototype,"r",2),Hs(Vs.prototype,"g",1),Hs(Vs.prototype,"b",0),Ws(Vs.prototype,"h"),Ws(Vs.prototype,"s"),Ws(Vs.prototype,"v"),Object.defineProperty(Vs.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Vs.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=Us.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Ks=function(){function e(t,n){Ns(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return Fs(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),qs={};Es.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){Es.each(e,(function(e){qs[e]=t}))}));var Xs=/(\d+(\.\d+)?)px/;function Ys(e){if("0"===e||Es.isUndefined(e))return 0;var t=e.match(Xs);return Es.isNull(t)?0:parseFloat(t[1])}var Qs={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var s=n,i=t;Es.isUndefined(i)&&(i=!0),Es.isUndefined(s)&&(s=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),s&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,s){var i=n||{},a=qs[t];if(!a)throw new Error("Event type "+t+" not supported.");var r=document.createEvent(a);switch(a){case"MouseEvents":var o=i.x||i.clientX||0,l=i.y||i.clientY||0;r.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var h=r.initKeyboardEvent||r.initKeyEvent;Es.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:r.initEvent(t,i.bubbles||!1,i.cancelable||!0)}Es.defaults(r,s),e.dispatchEvent(r)},bind:function(e,t,n,s){var i=s||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),Qs},unbind:function(e,t,n,s){var i=s||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),Qs},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return Qs},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),s=n.indexOf(t);-1!==s&&(n.splice(s,1),e.className=n.join(" "))}else e.className=void 0;return Qs},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Ys(t["border-left-width"])+Ys(t["border-right-width"])+Ys(t["padding-left"])+Ys(t["padding-right"])+Ys(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Ys(t["border-top-width"])+Ys(t["border-bottom-width"])+Ys(t["padding-top"])+Ys(t["padding-bottom"])+Ys(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Zs=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=s;return s.__prev=s.getValue(),s.__checkbox=document.createElement("input"),s.__checkbox.setAttribute("type","checkbox"),Qs.bind(s.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),s.domElement.appendChild(s.__checkbox),s.updateDisplay(),s}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Ks),Js=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=s,r=i;if(i.__select=document.createElement("select"),Es.isArray(a)){var o={};Es.each(a,(function(e){o[e]=e})),a=o}return Es.each(a,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),r.__select.appendChild(n)})),i.updateDisplay(),Qs.bind(i.__select,"change",(function(){var e=this.options[this.selectedIndex].value;r.setValue(e)})),i.domElement.appendChild(i.__select),i}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return Qs.isActive(this.__select)?this:(this.__select.value=this.getValue(),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(Ks),$s=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=s;function a(){i.setValue(i.__input.value)}return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),Qs.bind(s.__input,"keyup",a),Qs.bind(s.__input,"change",a),Qs.bind(s.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),Qs.bind(s.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),s.updateDisplay(),s.domElement.appendChild(s.__input),s}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){return Qs.isActive(this.__input)||(this.__input.value=this.getValue()),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Ks);function ei(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var ti=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=s||{};return i.__min=a.min,i.__max=a.max,i.__step=a.step,Es.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=ei(i.__impliedStep),i}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=ei(e),this}}]),t}(Ks),ni=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,s));i.__truncationSuspended=!1;var a=i,r=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=r-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),r=e.clientY}function h(){Qs.unbind(window,"mousemove",l),Qs.unbind(window,"mouseup",h),o()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),Qs.bind(i.__input,"change",(function(){var e=parseFloat(a.__input.value);Es.isNaN(e)||a.setValue(e)})),Qs.bind(i.__input,"blur",(function(){o()})),Qs.bind(i.__input,"mousedown",(function(e){Qs.bind(window,"mousemove",l),Qs.bind(window,"mouseup",h),r=e.clientY})),Qs.bind(i.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e,n,s;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,s=Math.pow(10,n),Math.round(e*s)/s),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ti);function si(e,t,n,s,i){return s+(e-t)/(n-t)*(i-s)}var ii=function(e){function t(e,n,s,i,a){Ns(this,t);var r=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:s,max:i,step:a})),o=r;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(si(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){Qs.unbind(window,"mousemove",l),Qs.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function d(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(si(t,n.left,n.right,o.__min,o.__max))}function c(){Qs.unbind(window,"touchmove",d),Qs.unbind(window,"touchend",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return r.__background=document.createElement("div"),r.__foreground=document.createElement("div"),Qs.bind(r.__background,"mousedown",(function(e){document.activeElement.blur(),Qs.bind(window,"mousemove",l),Qs.bind(window,"mouseup",h),l(e)})),Qs.bind(r.__background,"touchstart",(function(e){1===e.touches.length&&(Qs.bind(window,"touchmove",d),Qs.bind(window,"touchend",c),d(e))})),Qs.addClass(r.__background,"slider"),Qs.addClass(r.__foreground,"slider-fg"),r.updateDisplay(),r.__background.appendChild(r.__foreground),r.domElement.appendChild(r.__background),r}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ti),ai=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===s?"Fire":s,Qs.bind(i.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Qs.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return js(t,e),Fs(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Ks),ri=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));s.__color=new Vs(s.getValue()),s.__temp=new Vs(0);var i=s;s.domElement=document.createElement("div"),Qs.makeSelectable(s.domElement,!1),s.__selector=document.createElement("div"),s.__selector.className="selector",s.__saturation_field=document.createElement("div"),s.__saturation_field.className="saturation-field",s.__field_knob=document.createElement("div"),s.__field_knob.className="field-knob",s.__field_knob_border="2px solid ",s.__hue_knob=document.createElement("div"),s.__hue_knob.className="hue-knob",s.__hue_field=document.createElement("div"),s.__hue_field.className="hue-field",s.__input=document.createElement("input"),s.__input.type="text",s.__input_textShadow="0 1px 1px ",Qs.bind(s.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),Qs.bind(s.__input,"blur",c),Qs.bind(s.__selector,"mousedown",(function(){Qs.addClass(this,"drag").bind(window,"mouseup",(function(){Qs.removeClass(i.__selector,"drag")}))})),Qs.bind(s.__selector,"touchstart",(function(){Qs.addClass(this,"drag").bind(window,"touchend",(function(){Qs.removeClass(i.__selector,"drag")}))}));var a,r=document.createElement("div");function o(e){p(e),Qs.bind(window,"mousemove",p),Qs.bind(window,"touchmove",p),Qs.bind(window,"mouseup",h),Qs.bind(window,"touchend",h)}function l(e){m(e),Qs.bind(window,"mousemove",m),Qs.bind(window,"touchmove",m),Qs.bind(window,"mouseup",d),Qs.bind(window,"touchend",d)}function h(){Qs.unbind(window,"mousemove",p),Qs.unbind(window,"touchmove",p),Qs.unbind(window,"mouseup",h),Qs.unbind(window,"touchend",h),u()}function d(){Qs.unbind(window,"mousemove",m),Qs.unbind(window,"touchmove",m),Qs.unbind(window,"mouseup",d),Qs.unbind(window,"touchend",d),u()}function c(){var e=Ls(this.value);!1!==e?(i.__color.__state=e,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function u(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,s=n.clientX,a=n.clientY,r=(s-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),r>1?r=1:r<0&&(r=0),i.__color.v=o,i.__color.s=r,i.setValue(i.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return Es.extend(s.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Es.extend(s.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:s.__field_knob_border+(s.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Es.extend(s.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Es.extend(s.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Es.extend(r.style,{width:"100%",height:"100%",background:"none"}),li(r,"top","rgba(0,0,0,0)","#000"),Es.extend(s.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=s.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Es.extend(s.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:s.__input_textShadow+"rgba(0,0,0,0.7)"}),Qs.bind(s.__saturation_field,"mousedown",o),Qs.bind(s.__saturation_field,"touchstart",o),Qs.bind(s.__field_knob,"mousedown",o),Qs.bind(s.__field_knob,"touchstart",o),Qs.bind(s.__hue_field,"mousedown",l),Qs.bind(s.__hue_field,"touchstart",l),s.__saturation_field.appendChild(r),s.__selector.appendChild(s.__field_knob),s.__selector.appendChild(s.__saturation_field),s.__selector.appendChild(s.__hue_field),s.__hue_field.appendChild(s.__hue_knob),s.domElement.appendChild(s.__input),s.domElement.appendChild(s.__selector),s.updateDisplay(),s}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e=Ls(this.getValue());if(!1!==e){var t=!1;Es.each(Vs.COMPONENTS,(function(n){if(!Es.isUndefined(e[n])&&!Es.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Es.extend(this.__color.__state,e)}Es.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,s=255-n;Es.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,li(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Es.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+s+","+s+","+s+",.7)"})}}]),t}(Ks),oi=["-moz-","-o-","-webkit-","-ms-",""];function li(e,t,n,s){e.style.background="",Es.each(oi,(function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+s+" 100%); "}))}var hi='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',di=function(e,t){var n=e[t];return Es.isArray(arguments[2])||Es.isObject(arguments[2])?new Js(e,t,arguments[2]):Es.isNumber(n)?Es.isNumber(arguments[2])&&Es.isNumber(arguments[3])?Es.isNumber(arguments[4])?new ii(e,t,arguments[2],arguments[3],arguments[4]):new ii(e,t,arguments[2],arguments[3]):Es.isNumber(arguments[4])?new ni(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new ni(e,t,{min:arguments[2],max:arguments[3]}):Es.isString(n)?new $s(e,t):Es.isFunction(n)?new ai(e,t,""):Es.isBoolean(n)?new Zs(e,t):null},ci=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},ui=function(){function e(){Ns(this,e),this.backgroundElement=document.createElement("div"),Es.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Qs.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Es.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Qs.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Fs(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Es.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Qs.unbind(e.domElement,"webkitTransitionEnd",t),Qs.unbind(e.domElement,"transitionend",t),Qs.unbind(e.domElement,"oTransitionEnd",t)};Qs.bind(this.domElement,"webkitTransitionEnd",t),Qs.bind(this.domElement,"transitionend",t),Qs.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Qs.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Qs.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=document,s=document.createElement("style");s.type="text/css",s.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(s)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var pi=function(){try{return!!window.localStorage}catch(e){return!1}}(),mi=void 0,gi=!0,fi=void 0,_i=!1,vi=[],wi=function e(t){var n=this,s=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Qs.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],s=Es.defaults(s,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),s=Es.defaults(s,{resizable:s.autoPlace,hideable:s.autoPlace}),Es.isUndefined(s.load)?s.load={preset:"Default"}:s.preset&&(s.load.preset=s.preset),Es.isUndefined(s.parent)&&s.hideable&&vi.push(this),s.resizable=Es.isUndefined(s.parent)&&s.resizable,s.autoPlace&&Es.isUndefined(s.scrollable)&&(s.scrollable=!0);var i,a=pi&&"true"===localStorage.getItem(Mi(0,"isLocal")),r=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return s.parent}},scrollable:{get:function(){return s.scrollable}},autoPlace:{get:function(){return s.autoPlace}},closeOnTop:{get:function(){return s.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:s.load.preset},set:function(e){n.parent?n.getRoot().preset=e:s.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return s.width},set:function(e){s.width=e,Ei(n,e)}},name:{get:function(){return s.name},set:function(e){s.name=e,o&&(o.innerHTML=s.name)}},closed:{get:function(){return s.closed},set:function(t){s.closed=t,s.closed?Qs.addClass(n.__ul,e.CLASS_CLOSED):Qs.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return s.load}},useLocalStorage:{get:function(){return a},set:function(e){pi&&(a=e,e?Qs.bind(window,"unload",r):Qs.unbind(window,"unload",r),localStorage.setItem(Mi(0,"isLocal"),e))}}}),Es.isUndefined(s.parent)){if(this.closed=s.closed||!1,Qs.addClass(this.domElement,e.CLASS_MAIN),Qs.makeSelectable(this.domElement,!1),pi&&a){n.useLocalStorage=!0;var l=localStorage.getItem(Mi(0,"gui"));l&&(s.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,Qs.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),s.closeOnTop?(Qs.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(Qs.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),Qs.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===s.closed&&(s.closed=!0);var h=document.createTextNode(s.name);Qs.addClass(h,"controller-name"),o=bi(n,h),Qs.addClass(this.__ul,e.CLASS_CLOSED),Qs.addClass(o,"title"),Qs.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),s.closed||(this.closed=!1)}s.autoPlace&&(Es.isUndefined(s.parent)&&(gi&&(fi=document.createElement("div"),Qs.addClass(fi,"dg"),Qs.addClass(fi,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(fi),gi=!1),fi.appendChild(this.domElement),Qs.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||Ei(n,s.width)),this.__resizeHandler=function(){n.onResizeDebounced()},Qs.bind(window,"resize",this.__resizeHandler),Qs.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),Qs.bind(this.__ul,"transitionend",this.__resizeHandler),Qs.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),s.resizable&&Ri(this),r=function(){pi&&"true"===localStorage.getItem(Mi(0,"isLocal"))&&localStorage.setItem(Mi(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=r,s.parent||((i=n.getRoot()).width+=1,Es.defer((function(){i.width-=1})))};function bi(e,t,n){var s=document.createElement("li");return t&&s.appendChild(t),n?e.__ul.insertBefore(s,n):e.__ul.appendChild(s),e.onResize(),s}function yi(e){Qs.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&Qs.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function Si(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function xi(e,t){var n=e.getRoot(),s=n.__rememberedObjects.indexOf(t.object);if(-1!==s){var i=n.__rememberedObjectIndecesToControllers[s];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[s]=i),i[t.property]=t,n.load&&n.load.remembered){var a=n.load.remembered,r=void 0;if(a[e.preset])r=a[e.preset];else{if(!a.Default)return;r=a.Default}if(r[s]&&void 0!==r[s][t.property]){var o=r[s][t.property];t.initialValue=o,t.setValue(o)}}}}function Pi(e,t,n,s){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(s.color)i=new ri(t,n);else{var a=[t,n].concat(s.factoryArgs);i=di.apply(e,a)}s.before instanceof Ks&&(s.before=s.before.__li),xi(e,i),Qs.addClass(i.domElement,"c");var r=document.createElement("span");Qs.addClass(r,"property-name"),r.innerHTML=i.property;var o=document.createElement("div");o.appendChild(r),o.appendChild(i.domElement);var l=bi(e,o,s.before);return Qs.addClass(l,wi.CLASS_CONTROLLER_ROW),i instanceof ri?Qs.addClass(l,"color"):Qs.addClass(l,Bs(i.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,Es.extend(n,{options:function(t){if(arguments.length>1){var s=n.__li.nextElementSibling;return n.remove(),Pi(e,n.object,n.property,{before:s,factoryArgs:[Es.toArray(arguments)]})}if(Es.isArray(t)||Es.isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),Pi(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof ii){var s=new ni(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Es.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],i=s[e];n[e]=s[e]=function(){var e=Array.prototype.slice.call(arguments);return i.apply(s,e),t.apply(n,e)}})),Qs.addClass(t,"has-slider"),n.domElement.insertBefore(s.domElement,n.domElement.firstElementChild)}else if(n instanceof ni){var i=function(t){if(Es.isNumber(n.__min)&&Es.isNumber(n.__max)){var s=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=Pi(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(s),i&&a.listen(),a}return t};n.min=Es.compose(i,n.min),n.max=Es.compose(i,n.max)}else n instanceof Zs?(Qs.bind(t,"click",(function(){Qs.fakeEvent(n.__checkbox,"click")})),Qs.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof ai?(Qs.bind(t,"click",(function(){Qs.fakeEvent(n.__button,"click")})),Qs.bind(t,"mouseover",(function(){Qs.addClass(n.__button,"hover")})),Qs.bind(t,"mouseout",(function(){Qs.removeClass(n.__button,"hover")}))):n instanceof ri&&(Qs.addClass(t,"color"),n.updateDisplay=Es.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Es.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&Si(e.getRoot(),!0),t}),n.setValue)}(e,l,i),e.__controllers.push(i),i}function Mi(e,t){return document.location.href+"."+t}function Ci(e,t,n){var s=document.createElement("option");s.innerHTML=t,s.value=t,e.__preset_select.appendChild(s),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Ti(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Ai(e){var t=e.__save_row=document.createElement("li");Qs.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Qs.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML="&nbsp;",Qs.addClass(n,"button gears");var s=document.createElement("span");s.innerHTML="Save",Qs.addClass(s,"button"),Qs.addClass(s,"save");var i=document.createElement("span");i.innerHTML="New",Qs.addClass(i,"button"),Qs.addClass(i,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Qs.addClass(a,"button"),Qs.addClass(a,"revert");var r=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Es.each(e.load.remembered,(function(t,n){Ci(e,n,n===e.preset)})):Ci(e,"Default",!1),Qs.bind(r,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(r),t.appendChild(n),t.appendChild(s),t.appendChild(i),t.appendChild(a),pi){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(Mi(0,"isLocal"))&&l.setAttribute("checked","checked"),Ti(e,o),Qs.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,Ti(e,o)}))}var h=document.getElementById("dg-new-constructor");Qs.bind(h,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||mi.hide()})),Qs.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),mi.show(),h.focus(),h.select()})),Qs.bind(s,"click",(function(){e.save()})),Qs.bind(i,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),Qs.bind(a,"click",(function(){e.revert()}))}function Ri(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function s(){Qs.removeClass(e.__closeButton,wi.CLASS_DRAG),Qs.unbind(window,"mousemove",n),Qs.unbind(window,"mouseup",s)}function i(i){return i.preventDefault(),t=i.clientX,Qs.addClass(e.__closeButton,wi.CLASS_DRAG),Qs.bind(window,"mousemove",n),Qs.bind(window,"mouseup",s),!1}e.__resize_handle=document.createElement("div"),Es.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Qs.bind(e.__resize_handle,"mousedown",i),Qs.bind(e.__closeButton,"mousedown",i),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Ei(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Ii(e,t){var n={};return Es.each(e.__rememberedObjects,(function(s,i){var a={},r=e.__rememberedObjectIndecesToControllers[i];Es.each(r,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[i]=a})),n}wi.toggleHide=function(){_i=!_i,Es.each(vi,(function(e){e.domElement.style.display=_i?"none":""}))},wi.CLASS_AUTO_PLACE="a",wi.CLASS_AUTO_PLACE_CONTAINER="ac",wi.CLASS_MAIN="main",wi.CLASS_CONTROLLER_ROW="cr",wi.CLASS_TOO_TALL="taller-than-window",wi.CLASS_CLOSED="closed",wi.CLASS_CLOSE_BUTTON="close-button",wi.CLASS_CLOSE_TOP="close-top",wi.CLASS_CLOSE_BOTTOM="close-bottom",wi.CLASS_DRAG="drag",wi.DEFAULT_WIDTH=245,wi.TEXT_CLOSED="Close Controls",wi.TEXT_OPEN="Open Controls",wi._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||wi.toggleHide()},Qs.bind(window,"keydown",wi._keydownHandler,!1),Es.extend(wi.prototype,{add:function(e,t){return Pi(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return Pi(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Es.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&fi.removeChild(this.domElement);var e=this;Es.each(this.__folders,(function(t){e.removeFolder(t)})),Qs.unbind(window,"keydown",wi._keydownHandler,!1),yi(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new wi(t);this.__folders[e]=n;var s=bi(this,n.domElement);return Qs.addClass(s,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],yi(e);var t=this;Es.each(e.__folders,(function(t){e.removeFolder(t)})),Es.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Qs.getOffset(e.__ul).top,n=0;Es.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Qs.getHeight(t))})),window.innerHeight-t-20<n?(Qs.addClass(e.domElement,wi.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(Qs.removeClass(e.domElement,wi.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Es.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Es.debounce((function(){this.onResize()}),50),remember:function(){if(Es.isUndefined(mi)&&((mi=new ui).domElement.innerHTML=hi),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Es.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&Ai(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&Ei(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Ii(this)),e.folders={},Es.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Ii(this),Si(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=Ii(this,!0)),this.load.remembered[e]=Ii(this),this.preset=e,Ci(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Es.each(this.__controllers,(function(t){this.getRoot().load.remembered?xi(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Es.each(this.__folders,(function(e){e.revert(e)})),e||Si(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ci.call(window,(function(){e(t)})),Es.each(t,(function(e){e.updateDisplay()}))}(this.__listening)},updateDisplay:function(){Es.each(this.__controllers,(function(e){e.updateDisplay()})),Es.each(this.__folders,(function(e){e.updateDisplay()}))}});var Di=wi;class Oi{static createMeshPhysicalMaterial(e){return new x(e)}static createMeshStandardMaterial(e){return new N(e)}}e("Z",Oi),e("l",(e,t,n,s)=>{if(!e||!t||0===n||0===s)return new r;let i=e.clone(),a=n/2,o=s/2;return i.project(t),i.x=Math.floor(i.x*a+a),i.y=Math.floor(-i.y*o+o),i.z=e.distanceTo(t.position),i});const Li=e("k",(e,t)=>{t||(t=new r(0,0,0));let n=new r(e.size.x/1e3,e.size.z/1e3,e.size.y/1e3),s=new r(e.origin.x/1e3,e.origin.z/1e3,e.origin.y/-1e3),i=new r(0,0,-n.z).add(s).sub(t),a=new r(n.x,n.y,0).add(s).add(t);return new ge(i,a)});e("X",(e,t)=>{let n=ws(e.x),s=ws(e.y),i=ws(e.z),a=ws(t.x),r=ws(t.y),o=ws(t.z);return n===a&&s===r&&i===o}),e("a2",(e,t)=>{let n=ws(e.w),s=ws(e.x),i=ws(e.y),a=ws(e.z),r=ws(t.w),o=ws(t.x),l=ws(t.y),h=ws(t.z);return n===r&&s===o&&i===l&&a===h}),e("Y",(e,t)=>{let n=ws(e.x),s=ws(e.y),i=ws(t.x),a=ws(t.y);return n===i&&s===a});let ki=null;const Ui=()=>{if(ki)return ki;const e=new Uint8Array(4);for(let t=0;t<1;t++){const n=4*t;e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255}const t=new ye(e,1,1,be);return t.needsUpdate=!0,t},Bi=(e,t,n,s)=>{const i=new Uint8Array(4),a=Math.floor(255*e),r=Math.floor(255*t),o=Math.floor(255*n),l=Math.floor(255*s);for(let e=0;e<4;e++){const t=4*e;i[t]=a,i[t+1]=r,i[t+2]=o,i[t+3]=l}const h=new ye(i,1,1,be);return h.needsUpdate=!0,h},Ni=e("$",e=>Fi(null,e)),Fi=e("ay",(e,t)=>{var n;e||(e=zi()),e.name=t.id?t.id.toString():"";const s="2"===t.shading.version||(null===(n=t.shading.version)||void 0===n?void 0:n.startsWith("2."));return(e=s?ji(e,t):Gi(e,t)).userData.materialVersion=s?2:1,e.map||(ki||(ki=Ui()),e.map=ki),e}),Gi=(e,t)=>{void 0!==t.shading.metallic&&(e.metalness=1===t.shading.metallic?1:.5,e.reflectivity=Se(t.shading.metallic,.5));let n=!1;return t.shading.transmission&&t.shading.transmission>0?(e.opacity=1-t.shading.transmission,e.transparent=!0,e.depthWrite=!1,e.metalness=0,n=!0):void 0!==t.shading.alpha&&t.shading.alpha<1&&(e.transparent=t.shading.alpha<1,e.opacity=t.shading.alpha,e.depthWrite=t.shading.alpha>=1,e.metalness=.5*Math.max(0,t.shading.alpha),n=!0),e.aoMapIntensity=Se(t.shading.occlusion,1),e.roughness=Se(t.shading.roughness,.5),e.alphaTest=Se(t.shading.alphaCutoff,0),Wi(e.color,t.shading.basecolor),n||t.shading.doubleSided?e.side=F:e.side=he,e},ji=(e,t)=>{var n,s,i,a,r,o,l,h,d,c,u,p,m,g;let f=!1;return void 0!==t.shading.alpha&&t.shading.alpha<1?(e.transparent=!0,e.opacity=t.shading.alpha,e.depthWrite=!1,f=!0):(e.transparent=!1,e.opacity=1,e.depthWrite=!0),e.alphaTest=null!==(n=t.shading.alphaCutoff)&&void 0!==n?n:0,Wi(e.color,t.shading.basecolor),e.transmission=null!==(s=t.shading.transmission)&&void 0!==s?s:0,e.ior=null!==(i=Math.max(1,Math.min(2.33,t.shading.transmissionIOR)))&&void 0!==i?i:1.5,e.metalness=null!==(a=t.shading.metallic)&&void 0!==a?a:0,Wi(e.specularColor,t.shading.specularColor),e.specularIntensity=null!==(r=t.shading.specularity)&&void 0!==r?r:0,e.roughness=null!==(o=t.shading.roughness)&&void 0!==o?o:0,e.aoMapIntensity=null!==(l=t.shading.occlusion)&&void 0!==l?l:1,Wi(e.emissive,t.shading.emissiveColor),e.emissiveIntensity=null!==(h=t.shading.emissiveIntensity)&&void 0!==h?h:1,e.clearcoat=null!==(d=t.shading.clearcoatIntensity)&&void 0!==d?d:0,e.clearcoatRoughness=null!==(c=t.shading.clearcoatRoughness)&&void 0!==c?c:0,e.clearcoatNormalScale.setScalar(null!==(u=t.shading.clearcoatNormalScale)&&void 0!==u?u:1),Wi(e.sheenColor,t.shading.sheenColor),e.sheen=null!==(p=t.shading.sheenIntensity)&&void 0!==p?p:1,e.sheenRoughness=null!==(m=t.shading.sheenRoughness)&&void 0!==m?m:1,e.thickness=null!==(g=t.shading.thicknessFactor)&&void 0!==g?g:0,Wi(e.attenuationColor,t.shading.attenuationColor),t.shading.attenuationDistance&&(e.attenuationDistance=t.shading.attenuationDistance),e.side=f||t.shading.doubleSided?F:he,e},zi=()=>Oi.createMeshPhysicalMaterial({}),Vi=(e("az",(e,t=1)=>2===t?Hi(e):Vi(e)),e=>{let t={alpha:e.opacity,metallic:e.reflectivity,basecolor:Ki(e.color),roughness:e.roughness,doubleSided:e.side===F,alphaCutoff:e.alphaTest,transmission:e.transmission};return 1===e.metalness?t.metallic=1:t.metallic=e.reflectivity,t}),Hi=e=>({version:"2.0.0",alpha:e.opacity,alphaCutoff:e.alphaTest,basecolor:Ki(e.color),transmission:e.transmission,transmissionIOR:e.ior,metallic:e.metalness,doubleSided:e.side===F,specularColor:Ki(e.specularColor),specularity:e.specularIntensity,roughness:e.roughness,occlusion:e.aoMapIntensity,emissiveColor:Ki(e.emissive),emissiveIntensity:e.emissiveIntensity,clearcoatIntensity:e.clearcoat,clearcoatRoughness:e.clearcoatRoughness,clearcoatNormalScale:e.clearcoatNormalScale.x,sheenColor:Ki(e.sheenColor),sheenIntensity:e.sheen,sheenRoughness:e.sheenRoughness,thicknessFactor:e.thickness,attenuationColor:Ki(e.attenuationColor),attenuationDistance:e.attenuationDistance}),Wi=(e,t)=>{if(void 0!==t){const n=new h(t.r,t.g,t.b);e.copy(n.convertSRGBToLinear())}},Ki=e=>{const t=e.clone().convertLinearToSRGB();return{r:t.r,g:t.g,b:t.b}};let qi=null;const Xi=e("a0",(e,t,n,s,i,a,r=16)=>(qi||(qi=new R,qi.crossOrigin=""),new Promise((o,l)=>{if(!e)return console.warn("trying to add a texture without image",t),void o();qi.load(e,e=>{Yi(e,t,n,s,i,a,r),o()},l)}))),Yi=e("aA",(e,t,n,s,i,a,r=16)=>{e.anisotropy=s,e.wrapS=L,e.wrapT=L,r<=8&&["ORM","EMRGB","CCRG","CCXYZ","SHRGBA","SPRGBA","TTRG"].includes(t.mapping)?console.warn("ORM maps are not supported on devices with only "+r+" texture units"):(e.repeat.set(i,a),Qi(e,t,n),"RGBA"===t.mapping&&(n.transparent=!0,1===n.userData.materialVersion)&&n.name.includes("glow")&&(n.emissiveIntensity=.5,n.emissive=new h(16777215),n.emissiveMap=n.map),n.needsUpdate=!0)}),Qi=(e,t,n)=>{"XYZ"===t.mapping?(n.normalMap=e,n.map===Ui()&&(n.map=null)):"ORM"===t.mapping?(n.aoMap=e,n.roughnessMap=e,n.metalnessMap=e):"EMRGB"===t.mapping?n.emissiveMap=e:"CCRG"===t.mapping?(n.clearcoatMap=e,n.clearcoatRoughnessMap=e):"CCXYZ"===t.mapping?n.clearcoatNormalMap=e:"SHRGBA"===t.mapping?(n.sheenColorMap=e,n.sheenRoughnessMap=e):"SPRGBA"===t.mapping?(n.specularColorMap=e,n.specularIntensityMap=e):"TTRG"===t.mapping?(n.transmissionMap=e,n.thicknessMap=e):(e.colorSpace=S,n.map=e)},Zi=e("a1",(e=!0)=>(window.__RML_GUI__||(window.__RML_GUI__=new Di({autoPlace:e})),window.__RML_GUI__)),Ji=(e("ak",(e,t)=>{let n=!1;for(const s of t){const t=s.getKernelObject();let i;2===t.wallType.value&&(i=bs(t.rightNormal)),1===t.wallType.value&&(i=bs(t.leftNormal));let a=!0;if(i){let t=bs(s.getPlanElement().getCenter());t=t.applyMatrix4(e.matrixWorldInverse),i=i.transformDirection(e.matrixWorldInverse),a=t.dot(i)>=0}a!==s.getContainer().visible&&(n=!0),a?s.show():s.isSelected||s.hide()}return n}),e("ao",(e,t,n=!0)=>{if(!e.userData.tween)if(t)if(e.transparent=!0,n){let t={opacity:1};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:.2},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.userData.tween=!1}).start()}else e.opacity=.2;else if(n){let t={opacity:.2};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:1},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.transparent=!1,e.userData.tween=!1}).start()}else e.opacity=1,e.transparent=!1}),e=>{let t=new h;return t.setRGB((e>>16)/255,(e>>8&255)/255,(e>>0&255)/255),t}),$i=(e("aa",(e,t)=>{e.traverse(e=>{if(e instanceof z&&TWEEN){const n=e.material;e.userData.tween&&e.userData.tween.stop();const s={opacity:n.opacity};t.transparent&&(n.transparent=t.transparent),e.userData.tween=new TWEEN.Tween(s).to(t,250).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{n.opacity=s.opacity}).onStop(()=>{t.transparent||(n.transparent=t.transparent),n.opacity=t.opacity,n.needsUpdate=!0,e.userData.tween=void 0}).onComplete(()=>{t.transparent||(n.transparent=t.transparent),n.needsUpdate=!0,e.userData.tween=void 0}).start()}})}),e("al",e=>{e.traverse(e=>{if(e instanceof z&&TWEEN){let t=e.material;if(0===t.opacity)return;let n={opacity:0,transparent:!0},s={opacity:t.opacity,transparent:t.transparent};t.transparent=n.transparent,t.opacity=n.opacity,new TWEEN.Tween(n).to(s,500).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{t.opacity=n.opacity}).onComplete(()=>{t.transparent=s.transparent}).start()}})})),ea=e("w",e=>{"Mesh"===e.type?na(e):ta(e)}),ta=e=>{e&&e.children&&0!==e.children.length&&e.children.forEach(e=>{na(e)})},na=e("h",e=>{e&&(e.material&&ia(e.material),e.geometry&&sa(e.geometry),e.children&&e.children.length>0&&ta(e))}),sa=e=>{e&&e.dispose()},ia=e=>{e&&(e.map&&e.map.dispose(),e.normalMap&&e.normalMap.dispose(),e.dispose())};let aa;e("v",e=>0===e.x&&0===e.y&&0===e.z);const ra=(e,t)=>{let n="";return e||""===e?(e.materialId&&""!==e.materialId?n=e.materialId:e.catalogItemId&&""!==e.catalogItemId?n=e.catalogItemId:e.rgbValue>0?n="rgb"+JSON.stringify(e.rgbValue):e.length>0?n=e:t&&1===t.value?n="default_wall_material_"+e.getSourceType().value:t&&7===t.value&&(n="default_ceiling_material_"+e.getSourceType().value),n):null},oa=(e("x",e=>{let t=e.getWorldDirection(new r).clone();t.y=0,t.lengthSq()<.01&&(t=new r(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}),e("g",(e,t)=>{if(!e||!t)return 0;const n=e.clone().expandByScalar(.001).containsBox(t),s=t.clone().expandByScalar(.001).containsBox(e);return s&&n||!s&&!n?0:!0===n?1:-1}),e("ag",(e,t,n,s=1)=>{const i=t>n,a=i?15:0,o=i?0:10,l=e.getSize(new r),h=e.getCenter(new r);let d=l.x>2*a?l.x/2:a,c=l.z>2*o?l.z/2:o;return d*=s,c*=s,new ge(new r(h.x-d,h.y,h.z-c),new r(h.x+d,h.y,h.z+c))}),e("af",e=>{const{x:t,y:n}=e;return{x:t,y:n}})),la=e=>{const{x:t,y:n,z:s}=e;return{x:t,y:n,z:s}};e("an",(e,t,n)=>(new r).setFromSphericalCoords(e,Math.PI*(1-n),2*Math.PI*(1-t))),e("u",e=>{const t=new xe;return t.environment=e.environment.clone(),t.userData.environmentDefinition=e.userData.environmentDefinition.clone(),t.userData.shadowFromEnvironment=e.userData.shadowFromEnvironment,t}),e("am",(e,t)=>{const n=new Pe,s=(new P).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i=new ge;n.setFromProjectionMatrix(s);const a=i.setFromObject(t).getCenter(new r);return n.containsPoint(a)}),e("aG",e=>Math.atan2(Math.sin(e),Math.cos(e)));var ha=e("a9","static/default_256-f1c66a2764f88cc0.exr");const da={uniforms:{tDiffuse:{value:null},colorTransform:{value:new P},colorBase:{value:new Me(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new Ce}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"},ca=new P,ua=(new P).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),pa=(new P).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),ma=(new P).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1);(new P).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new P).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1);const ga=(new P).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),fa=new Me(0,0,0,0),_a=new Me(0,0,0,1),va=new Ce,wa=(new Ce).set(1,0,0,0,-1,1,0,0,1);class ba extends Te{constructor(e,t="additive",n=!1,s=!1){const i="additive"===t?{blendSrc:Ae,blendDst:Re,blendEquation:Ee,blendSrcAlpha:Ie,blendDstAlpha:Re,blendEquationAlpha:Ee}:{};super({uniforms:De.clone(da.uniforms),vertexShader:da.vertexShader,fragmentShader:da.fragmentShader,defines:{LINEAR_TO_SRGB:n?1:0,PREMULTIPLIED_ALPHA:s?1:0},transparent:!0,depthTest:!1,depthWrite:!1,...i}),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const ya={uniforms:{tDiffuse:{value:null},rangeMin:{value:new a(1/512,1/512)},rangeMax:{value:new a(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new a(.1,.9),new a(.1,.9);class Sa extends Te{constructor(e){super({defines:Object.assign({},Sa._linearDepthShader.defines),uniforms:De.clone(Sa._linearDepthShader.uniforms),vertexShader:Sa._linearDepthShader.vertexShader,fragmentShader:Sa._linearDepthShader.fragmentShader,blending:Oe}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}Sa._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new Me(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include <packing>\n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};const xa=new Q(-1,1,1,-1,0,1),Pa=new class extends c{constructor(){super(),this.setAttribute("position",new Le([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Le([0,2,0,0,2,0],2))}};class Ma{constructor(e){this._mesh=new z(Pa,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,xa)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Ca{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,s){return e[0]*t+e[1]*n+e[2]*s}dot4(e,t,n,s,i){return e[0]*t+e[1]*n+e[2]*s+e[3]*i}noise(e,t){let n,s,i;const a=(e+t)*(.5*(Math.sqrt(3)-1)),r=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,h=(r+o)*l,d=e-(r-h),c=t-(o-h);let u,p;d>c?(u=1,p=0):(u=0,p=1);const m=d-u+l,g=c-p+l,f=d-1+2*l,_=c-1+2*l,v=255&r,w=255&o,b=this.perm[v+this.perm[w]]%12,y=this.perm[v+u+this.perm[w+p]]%12,S=this.perm[v+1+this.perm[w+1]]%12;let x=.5-d*d-c*c;x<0?n=0:(x*=x,n=x*x*this.dot(this.grad3[b],d,c));let P=.5-m*m-g*g;P<0?s=0:(P*=P,s=P*P*this.dot(this.grad3[y],m,g));let M=.5-f*f-_*_;return M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,_)),70*(n+s+i)}noise3d(e,t,n){let s,i,a,r;const o=(e+t+n)*(1/3),l=Math.floor(e+o),h=Math.floor(t+o),d=Math.floor(n+o),c=(l+h+d)*(1/6),u=e-(l-c),p=t-(h-c),m=n-(d-c);let g,f,_,v,w,b;u>=p?p>=m?(g=1,f=0,_=0,v=1,w=1,b=0):u>=m?(g=1,f=0,_=0,v=1,w=0,b=1):(g=0,f=0,_=1,v=1,w=0,b=1):p<m?(g=0,f=0,_=1,v=0,w=1,b=1):u<m?(g=0,f=1,_=0,v=0,w=1,b=1):(g=0,f=1,_=0,v=1,w=1,b=0);const y=u-g+1/6,S=p-f+1/6,x=m-_+1/6,P=u-v+1/6*2,M=p-w+1/6*2,C=m-b+1/6*2,T=u-1+.5,A=p-1+.5,R=m-1+.5,E=255&l,I=255&h,D=255&d,O=this.perm[E+this.perm[I+this.perm[D]]]%12,L=this.perm[E+g+this.perm[I+f+this.perm[D+_]]]%12,k=this.perm[E+v+this.perm[I+w+this.perm[D+b]]]%12,U=this.perm[E+1+this.perm[I+1+this.perm[D+1]]]%12;let B=.6-u*u-p*p-m*m;B<0?s=0:(B*=B,s=B*B*this.dot3(this.grad3[O],u,p,m));let N=.6-y*y-S*S-x*x;N<0?i=0:(N*=N,i=N*N*this.dot3(this.grad3[L],y,S,x));let F=.6-P*P-M*M-C*C;F<0?a=0:(F*=F,a=F*F*this.dot3(this.grad3[k],P,M,C));let G=.6-T*T-A*A-R*R;return G<0?r=0:(G*=G,r=G*G*this.dot3(this.grad3[U],T,A,R)),32*(s+i+a+r)}noise4d(e,t,n,s){const i=this.grad4,a=this.simplex,r=this.perm,o=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20;let h,d,c,u,p;const m=(e+t+n+s)*o,g=Math.floor(e+m),f=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(s+m),w=(g+f+_+v)*l,b=e-(g-w),y=t-(f-w),S=n-(_-w),x=s-(v-w),P=(b>y?32:0)+(b>S?16:0)+(y>S?8:0)+(b>x?4:0)+(y>x?2:0)+(S>x?1:0),M=a[P][0]>=3?1:0,C=a[P][1]>=3?1:0,T=a[P][2]>=3?1:0,A=a[P][3]>=3?1:0,R=a[P][0]>=2?1:0,E=a[P][1]>=2?1:0,I=a[P][2]>=2?1:0,D=a[P][3]>=2?1:0,O=a[P][0]>=1?1:0,L=a[P][1]>=1?1:0,k=a[P][2]>=1?1:0,U=a[P][3]>=1?1:0,B=b-M+l,N=y-C+l,F=S-T+l,G=x-A+l,j=b-R+2*l,z=y-E+2*l,V=S-I+2*l,H=x-D+2*l,W=b-O+3*l,K=y-L+3*l,q=S-k+3*l,X=x-U+3*l,Y=b-1+4*l,Q=y-1+4*l,Z=S-1+4*l,J=x-1+4*l,$=255&g,ee=255&f,te=255&_,ne=255&v,se=r[$+r[ee+r[te+r[ne]]]]%32,ie=r[$+M+r[ee+C+r[te+T+r[ne+A]]]]%32,ae=r[$+R+r[ee+E+r[te+I+r[ne+D]]]]%32,re=r[$+O+r[ee+L+r[te+k+r[ne+U]]]]%32,oe=r[$+1+r[ee+1+r[te+1+r[ne+1]]]]%32;let le=.6-b*b-y*y-S*S-x*x;le<0?h=0:(le*=le,h=le*le*this.dot4(i[se],b,y,S,x));let he=.6-B*B-N*N-F*F-G*G;he<0?d=0:(he*=he,d=he*he*this.dot4(i[ie],B,N,F,G));let de=.6-j*j-z*z-V*V-H*H;de<0?c=0:(de*=de,c=de*de*this.dot4(i[ae],j,z,V,H));let ce=.6-W*W-K*K-q*q-X*X;ce<0?u=0:(ce*=ce,u=ce*ce*this.dot4(i[re],W,K,q,X));let ue=.6-Y*Y-Q*Q-Z*Z-J*J;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(i[oe],Y,Q,Z,J)),27*(h+d+c+u+p)}}new R;class Ta{constructor(){this.bounds=new ge(new r(-1,-1,-1),new r(1,1,1)),this.size=new r(2,2,2),this.center=new r(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new r(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Q?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof X&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),s=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const i=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=i/a,e.fov=Y.radToDeg(2*Math.atan2(a,n)),e.near=n,e.far=s,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}class Aa{changed(e){var t,n;const s=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),s}}class Ra{constructor(){this._originalClearColor=new h,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new Ma(void 0),this._emptyScene=new xe,this._defaultCamera=new X}renderWithOverrideMaterial(e,t,n,s,i,a,r){this._backup(e),this._prepareRenderer(e,i,a,r);const o=t.overrideMaterial;t.overrideMaterial=s,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,s){this._backup(e),this._prepareRenderer(e,t,n,s),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,s,i,a){this._backup(e),this._prepareRenderer(e,s,i,a),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,s,i){this._backup(e),this._prepareRenderer(e,n,s,i),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,s){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class Ea{constructor(e,t){var n;this._passRenderer=null!==(n=null==t?void 0:t.passRenderer)&&void 0!==n?n:new Ra,this._blurMaterial=new Te(null!=e?e:ya),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,s){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=s[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=s[1],this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[2])}}const Ia=(e,t)=>{const n=Da(e,t);let s="vec4[SAMPLES](";for(let t=0;t<e;t++){const i=n[t];s+=`vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})${t<e-1?",":")"}`}return s},Da=(e,t)=>{const n=[];for(let s=0;s<e;s++){const i=s*Math.PI*(3-Math.sqrt(5)),a=.01+s/(e-1)*.99,r=t?Math.sqrt(1-a*a):1-a,o=Math.cos(i)*r,l=Math.sin(i)*r,h=4,d=Math.floor(e/h);let c=1-(Math.floor(s/h)+s%h*d)/e;c=.1+.9*c,n.push(new Me(o,l,a,c))}return n},Oa={name:"AOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,SAMPLE_VECTORS:Ia(16,!1),NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",AO_ALGORITHM:4,NV_ALIGNED_SAMPLES:1,SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0,NORMAL_VECTOR_ANTIALIAS:2,DEPTH_BUFFER_ANTIALIAS:1},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new a},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new P},cameraProjectionMatrixInverse:{value:new P},cameraWorldMatrix:{value:new P},radius:{value:1},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},bias:{value:.001},scale:{value:1},sceneBoxMin:{value:new r(-1,-1,-1)},sceneBoxMax:{value:new r(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float bias;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},La={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class ka{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n,s,i){this.needsUpdate=!0,this.parameters={...La},this._width=0,this._height=0,this._samples=0,this._gBufferAntiAliasing=!1,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._passRenderer=new Ra,this._sceneClipBox=new ge(new r(-1,-1,-1),new r(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._samples=n,this._gBufferAntiAliasing=s,this._normalVectorSourceType=(null==i?void 0:i.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==i?void 0:i.depthValueSourceType)||"normalVectorAlpha",this._modulateRedChannel=(null==i?void 0:i.modulateRedChannel)||!1,(null==i?void 0:i.aoParameters)&&(this.parameters=i.aoParameters),i&&this.updateTextures(i)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ca,n=new Uint8Array(e*e*4);for(let s=0;s<e;s++)for(let i=0;i<e;i++){const a=s,r=i;n[4*(s*e+i)]=127.5*(t.noise(a,r)+1),n[4*(s*e+i)+1]=127.5*(t.noise(a+e,r)+1),n[4*(s*e+i)+2]=127.5*(t.noise(a,r+e)+1),n[4*(s*e+i)+3]=127.5*(t.noise(a+e,r+e)+1)}this._noiseTexture=new ye(n,e,e,be,ke),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;return this._aoMaterial||(this._aoMaterial=this._newAoMaterial(),n=!0),n&&(this._updateShader(this._aoMaterial,e),this._aoMaterial.needsUpdate=!0),this._updateUniforms(this._aoMaterial,e,n),this._aoMaterial}_newAoMaterial(){const e=new Te({defines:Object.assign({},Oa.defines),uniforms:De.clone(Oa.uniforms),vertexShader:Oa.vertexShader,fragmentShader:Oa.fragmentShader,depthTest:!1,depthWrite:!1});return this._modulateRedChannel&&(e.blending=Ue,e.blendEquation=Be,e.blendEquationAlpha=null,e.blendSrc=Ne,e.blendSrcAlpha=null,e.blendDst=Ne,e.blendDstAlpha=null),e.defines.FRAGMENT_OUTPUT=this._modulateRedChannel?"vec4(ao, 1., 1., 1.)":void 0,e.uniforms.tNoise.value=(e=>{const t=new Ca,n=Math.floor(5)%2==0?Math.floor(5)+1:Math.floor(5),s=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,s=Array(n).fill(0);let i=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===i&&a===t?(a=t-2,i=0):(a===t&&(a=0),i<0&&(i=t-1)),0===s[i*t+a]?(s[i*t+a]=e++,a++,i--):(a-=2,i++);return s})(n),i=s.length,a=new Uint8Array(4*i);for(let e=0;e<i;++e){const n=s[e],o=2*Math.PI*n/i,l=new r(Math.cos(o),Math.sin(o),0).normalize();a[4*e]=255*(.5*l.x+.5),a[4*e+1]=255*(.5*l.y+.5),a[4*e+2]=127,a[4*e+3]=255*(.5*t.noise(e/5,e%5)+.5)}const o=new ye(a,n,n);return o.wrapS=L,o.wrapT=L,o.needsUpdate=!0,o})(),e}_updateShader(e,t){e.defines.PERSPECTIVE_CAMERA=t.isPerspectiveCamera?1:0,e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=Ia(this.parameters.samples,0===this.parameters.algorithm),e.defines.NORMAL_VECTOR_TYPE="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_SWIZZLING="normalVectorAlpha"===this._depthValueSourceType?"a":"x",e.defines.AO_ALGORITHM=this.parameters.algorithm,e.defines.NV_ALIGNED_SAMPLES=3===this.parameters.algorithm||4===this.parameters.algorithm?0:1,e.defines.SCREEN_SPACE_RADIUS=this.parameters.screenSpaceRadius?1:0,e.defines.SCENE_CLIP_BOX=1,e.defines.NORMAL_VECTOR_ANTIALIAS=this._gBufferAntiAliasing?2:0,e.defines.DEPTH_BUFFER_ANTIALIAS=this._gBufferAntiAliasing?1:0}_updateUniforms(e,t,n){const s=this.parameters.screenSpaceRadius?1:this._sceneScale,i="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;e.uniforms.tNormal.value=this.normalTexture,e.uniforms.tDepth.value=i,e.uniforms.resolution.value.set(this._width,this._height),e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse),e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld);const a=t;e.uniforms.cameraNear.value=a.near,e.uniforms.cameraFar.value=a.far,n&&(e.uniforms.radius.value=this.parameters.radius*s,e.uniforms.distanceExponent.value=this.parameters.distanceExponent,e.uniforms.thickness.value=this.parameters.thickness*s,e.uniforms.distanceFallOff.value=this.parameters.distanceFallOff,e.uniforms.scale.value=this.parameters.scale,this._sceneClipBox&&(e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min),e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)))}_getRenderTargets(){return this._renderTarget||(this._renderTarget=new Fe(this._width,this._height,{samples:this._samples,magFilter:D,minFilter:D})),this._renderTarget}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._aoMaterial)||void 0===t||t.dispose(),null===(n=this._renderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._renderTarget)||void 0===n||n.setSize(e,t),this.needsUpdate=!0}updateBounds(e,t){this._sceneClipBox=(new ge).copy(e),this._sceneScale=null!=t?t:1,this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}clear(e,t){this._passRenderer.clear(e,t||this._getRenderTargets(),16777215,1)}render(e,t,n,s){const i=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,i,s||this._getRenderTargets())}}const Ua={shadowType:"PCFSoftShadowMap",shAndAoPassParameters:{aoIntensity:.3,shadow:{shadowRadius:.1},ao:{algorithm:0,samples:32,radius:.02,distanceExponent:2,thickness:.1,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:.4,normalPhi:4}},groundReflectionParameters:{brightness:.5}},Ba=e=>Math.max(0,Math.min(1,e));class Na{constructor(e){return this.autoQuality=!1,this.colors=(e=>{const t={},n=Object.keys(e);for(const s of n){const n=e[s];t[s]=He(n)?n:Ve(n)}return t})(We),this.unit=null,this.unitStringType=null,this.meshSelection=!0,this.stats=!1,this._measureTraffic=!1,this.disableDebugGUI=!1,this.disableEnvMap=!1,this.envMapUrl=ha,this.envMapIntensity=1.5,this.envMapRotation=0,this.maxLightSources=-1,this.legacyLight=!1,this.sceneLight=null,this.shading="default",this.restrictionLevel=0,this.highlighting=je.SMART,this.dls=null,this.ls=null,this.cameraSpacing=0,this.transparentHighlighting=!0,this.featureFlags={pulsePreview:!1,reDock:!1,configureInRoom:!1,advancedDocking:!1},this.mode=ze.CAMERA_3D,this.edit=!1,this.moc=!1,this.callbacksOnlyIfGeometryIsReady=!0,this._creator_=e,new Proxy(this,{get:(e,t)=>"colors"===t?e.colors?new Proxy(e.colors,{get:(e,t)=>Ve(e[t]),set:(t,n,s)=>(e.colors[n]=Ve(s),!0)}):e.colors:e[t]})}setOverrides(e){Ge(this,e)}}e("aF",Na);const Fa=["language","browserLanguage","userLanguage","systemLanguage"];e("ac",/^((?!chrome|android).)*safari/i.test(navigator.userAgent));class Ga{constructor(e){this.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,n=Fa.length;e<n;e++){const n=t[Fa[e]];if(n)return n.substr(0,2)}return"en"})()||"en",this.overrideCountry=null,this.e2e=!1,this.e2eRoomleRendererForImages=!1,this._creator_=e}setOverrides(e){Ge(this,e)}}e("aE",Ga);class ja{_setMute(e){Ke(this,"_isMute",!0),this._isMute=e,Ke(this,"_isMute",!1)}mute(){this._setMute(!0)}unmute(){this._setMute(!1)}constructor(e){return this._isMute=!1,this.cameraStartsMoving=()=>{},this._creator_=e,qe(this,"_isMute",{enumerable:!1,writable:!1}),qe(ja.prototype,"_setMute",{enumerable:!1,writable:!1}),qe(ja.prototype,"mute",{enumerable:!1,writable:!1}),qe(ja.prototype,"unmute",{enumerable:!1,writable:!1}),new Proxy(this,this)}get(e,t){return this._isMute&&"function"==typeof this[t]&&"on"===t.substr(0,2)?()=>{}:this[t]}}e("aB",ja);class za extends ja{constructor(){super(...arguments),this.onNetworkRequest=(e,t,n)=>{},this.onKernelMsg=(e,t,n={})=>{},this.onCheckExternalCache=async(e,t)=>Promise.resolve(null),this.onValidateNetworkResponse=(e,t)=>Promise.resolve(!0),this.onApiJsonReceived=async(e,t,n)=>Promise.resolve(void 0)}}e("aD",za),e("m",{HSC:"rml-configurator",HSP:"rml-hsp",GLB:"rml-glb",RMV:"rml-mv"});class Va{get element(){return this._container}constructor(e){this._creator_=e,this._lifeCycleManager.addEventListener(this)}setDomElement(e){if(!this._container){this._container=document.createElement("div"),this._container.classList.add("rml-threejs-canvas-container"),this._container.setAttribute("ondragover","return false"),this._container.style.position="relative",this._container.style.width="100%",this._container.style.height="100%";const t=document.createElement("style");t.innerText=".rml-threejs-canvas-container canvas{position:absolute;top:0;left:0;right:0;bottom:0;z-index:100; opacity:1;}",this._container.appendChild(t),e.appendChild(this._container)}this._element=e}getClientDimensions(){return new a(this._element.clientWidth,this._element.clientHeight)}_removeDomElement(e){if(!e)return;const t=e.parentElement;t&&t.removeChild(e)}reset(){this._element=null,this._removeDomElement(this._container),this._container=null}pause(){this.reset()}resume(){}destroy(){}}on([hn],Va.prototype,"_lifeCycleManager",void 0),e("aI",class{constructor(e){this._creator_=e}setScene(e){}setUiScene(e){}updateBounds(e){}clearScene(e,t){}moveCameraEnd(e){}moveCameraStart(e){}needsUiScene(){return!1}});class Ha{constructor(e){this._plugins=[],this._creator_=e}async init(e,n,s){this._scene=e,this._uiScene=n,this._cameraPosition=s;const{bananaForScale:i}=this._initData;i&&await t.import("./banana-for-scale-00c51c97.nomodule.js").then(({default:e})=>this._plugins.push(new e(this._creator_))),this._plugins.forEach(e=>e.setScene(this._scene)),this._plugins.forEach(e=>e.setUiScene(this._uiScene)),this._plugins.forEach(e=>e.updateBounds(this._bounds)),this._plugins.forEach(e=>e.moveCameraEnd(this._cameraPosition))}addPlugin(e){this._plugins.push(e),e.setScene(this._scene),e.setUiScene(this._uiScene),e.updateBounds(this._bounds),e.moveCameraEnd(this._cameraPosition)}updateBounds(e){this._bounds=e,this._plugins.forEach(t=>t.updateBounds(e))}clearScene(e,t){this._plugins.forEach(n=>n.clearScene(e,t))}getActivePlugins(){return this._plugins}getPlugin(e){for(let t of this._plugins)if(t instanceof e)return t;return null}moveCameraEnd(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraEnd(e))}moveCameraStart(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraStart(e))}needsUiScene(){return this._plugins.map(e=>e.needsUiScene()).reduce((e,t)=>e||t,!1)}}on([hn],Ha.prototype,"_initData",void 0);class Wa{constructor(e,t){this._waitingPromises=[],this._finishPromiseExecutor=[],this._errorCallback=()=>{},Promise.allSettled=Promise.allSettled||(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),e&&this.registerCallback(e),t&&(this._errorCallback=t)}push(e){this._waitingPromises.push(e),Promise.all(this._waitingPromises).then(e=>{e.length===this._waitingPromises.length&&(this._callback&&this._callback(e),this._waitingPromises=[])},this._errorCallback)}finished(e=!1){return new Promise((t,n)=>{this._finishPromiseExecutor.push({resolve:t,reject:n});const s=e?"allSettled":"all";Promise[s](this._waitingPromises).then(e=>{if("allSettled"===s){const t=[];e.forEach(({value:e,status:n})=>{"fulfilled"===n&&t.push(e)}),this._resolveAllExecutors(t)}else this._resolveAllExecutors(e)},e=>{this._rejectAllExecutors(e)})})}registerCallback(e){this._callback=e}unregisterCallback(){this._callback=null}_resolveAllExecutors(e){this._finishPromiseExecutor.forEach(({resolve:t})=>t(e)),this._finishPromiseExecutor=[]}_rejectAllExecutors(e){this._finishPromiseExecutor.forEach(({reject:t})=>t(e)),this._finishPromiseExecutor=[]}clear(){const e=this._waitingPromises.length>0;this._waitingPromises=[],e?this._rejectAllExecutors(new Error("Promise queue has been cleared")):this._resolveAllExecutors([])}get length(){return this._waitingPromises.length}}class Ka{constructor(e){this.materialQueue=new Wa,this._geometryComponentMaterialCache=new Map,this._maxAnisotropy=1,this._maxTextures=16,this._textureLoader=new R,this._configuratorPreviewMaterial=Oi.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:1,roughness:1,envMap:null,polygonOffset:!0,polygonOffsetFactor:-1}),this._creator_=e,this._previewMaterial=Oi.createMeshStandardMaterial({color:"#DDDDDD",roughness:1,metalness:0})}getGeometry(e){return e&&this._cacheHolder.geometryCache.has(e)?this._cacheHolder.geometryCache.get(e):null}_generateGeometry(e,t,n,s,i){let a;return e&&this._cacheHolder.geometryCache.has(e)?a=this._cacheHolder.geometryCache.get(e):(a=new c,a.setIndex(new Xe(n,1)),a.setAttribute("position",new Le(t,3)),a.setAttribute("normal",new Le(i,3)),a.setAttribute("uv",new Le(s,2)),a.scale(.001,.001,.001),a.rotateX(-Math.PI/2),e&&this._cacheHolder.geometryCache.set(e,a)),a}changeMaterialOfMesh(e,t,n){e&&t?(e.material=t,e.material.transparent||0===e.material.opacity||e.material.transmission>0?(e.castShadow=!1,e.receiveShadow=!1):(e.castShadow=!0,e.receiveShadow=!0),e.material.needsUpdate=!0,this._materialLoaded&&this._materialLoaded(t),this._updateMaterialProperties(e,n)):console.warn("could not assign material to mesh",{mesh:e},{material:t})}_updateMaterialProperties(e,t){var n;if(t&&Object.keys(t).length>0&&e.material instanceof N){const s=e.material.clone();s.userData.materialAttributes=t,this._updateStandardMaterialProperties(s,t),s instanceof x&&this._updatePhysicalMaterialProperties(s,t),s.transparent=s.opacity<1;const i=e.material;e.material=s,(null===(n=i.userData)||void 0===n?void 0:n.materialAttributes)&&i.dispose()}}_updateStandardMaterialProperties(e,t){t.color&&(e.color=new h(t.color)),t.alpha&&(e.opacity=parseFloat(t.alpha)),t.roughness&&(e.roughness=parseFloat(t.roughness)),t.metallic&&(e.metalness=parseFloat(t.metallic)),t.alphaCutoff&&(e.alphaTest=parseFloat(t.alphaCutoff)),t.doubleSided&&(e.side=t.doubleSided?F:he),t.occlusion&&(e.aoMapIntensity=parseFloat(t.occlusion)),t.emissiveColor&&(e.emissive=new h(t.emissiveColor)),t.emissiveIntensity&&(e.emissiveIntensity=parseFloat(t.emissiveIntensity))}_updatePhysicalMaterialProperties(e,t){t.transmission&&(e.transmission=parseFloat(t.transmission)),t.specularColor&&(e.specularColor=new h(t.specularColor)),t.specularity&&(e.specularIntensity=parseFloat(t.specularity)),t.clearcoatIntensity&&(e.clearcoat=parseFloat(t.clearcoatIntensity)),t.clearcoatRoughness&&(e.clearcoatRoughness=parseFloat(t.clearcoatRoughness)),t.clearcoatNormalScale&&e.clearcoatNormalScale.setScalar(parseFloat(t.clearcoatNormalScale)),t.sheenColor&&(e.sheenColor=new h(t.sheenColor)),t.sheenIntensity&&(e.sheen=parseFloat(t.sheenIntensity)),t.sheenRoughness&&(e.sheenRoughness=parseFloat(t.sheenRoughness)),t.thicknessFactor&&(e.thickness=parseFloat(t.thicknessFactor)),t.attenuationColor&&(e.attenuationColor=new h(t.attenuationColor)),t.attenuationDistance&&(e.attenuationDistance=parseFloat(t.attenuationDistance))}_createMaterial(e,t,n,s,i){if(this._cacheHolder.materialCache.has(e))t();else if(e.startsWith("benchmarkMaterial")){let a=Ye(e),r=Ni(a);this._loadBenchmarkTextures(a,r,s,i).then(t,n)}else this._rapiAccess.getMaterial(e).then(e=>{let a=Ni(e);this._loadTextures(e,a,s,i).then(t,n)},n)}_loadBenchmarkTextures(e,t,n=1,s=1){return new Promise((i,a)=>{const r=Qe(e.id);Xi(this._dataSyncer.requestAsset(r.image,!0),r,t,this._maxAnisotropy,n/(0===r.mmWidth?1:r.mmWidth),s/(0===r.mmHeight?1:r.mmHeight),this._maxTextures).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},a)})}_loadTextures(e,t,n=1,s=1){return new Promise((i,a)=>{if(!e.textures||e.textures&&0===e.textures.length)return this._cacheHolder.materialCache.set(e.id,t),i();this._rapiAccess.getTexturesOf(e).then(r=>{let o=[];r.forEach(e=>{o.push(Xi(this._dataSyncer.requestAsset(e.image,!0),e,t,this._maxAnisotropy,n/(0===e.mmWidth?1:e.mmWidth),s/(0===e.mmHeight?1:e.mmHeight),this._maxTextures))}),Promise.all(o).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},a)})})}_loadMaterial(e,t,n){return new Promise((s,i)=>{this._singlePromiseFactory.create(6,e,(s,i)=>this._createMaterial(e,s,i,t,n)).then(()=>{setTimeout(()=>s(this._cacheHolder.materialCache.get(e)),0)},i)})}_assignMaterial(e,t,n){return this._cacheHolder.materialCache.has(t)?(this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t),n),Promise.resolve()):new Promise((s,i)=>{this._loadMaterial(t).then(i=>{e.userData.materialId===t&&this.changeMaterialOfMesh(e,i,n),s()},i)})}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy=e}get maxTextures(){return this._maxTextures}set maxTextures(e){this._maxTextures=e}clear(){this._cacheHolder.clear()}_assignRGB(e,t){return new Promise(n=>{let s,i="rgb"+JSON.stringify(t);this._cacheHolder.materialCache.has(i)?s=this._cacheHolder.materialCache.get(i):(s=Oi.createMeshPhysicalMaterial({color:t}),this._cacheHolder.materialCache.set(i,s)),this.changeMaterialOfMesh(e,s),setTimeout(()=>n(),0)})}_assignItem(e,t){return new Promise((n,s)=>{if(this._cacheHolder.materialCache.has(t))return this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t)),void n();this._rapiAccess.getItem(t).then(i=>{if(i.topImage)this._textureLoader.load(i.topImage,s=>{s.anisotropy=this._maxAnisotropy,s.wrapS=L,s.wrapT=L;let r=new a(1,1);i.width>0&&(r.x=1/i.width),i.depth>0&&(r.y=1/i.depth),s.repeat.set(r.x,r.y);const o=Oi.createMeshPhysicalMaterial({map:s,roughness:.5,metalness:.1});this._cacheHolder.materialCache.set(t,o),this.changeMaterialOfMesh(e,o),setTimeout(()=>n(),0)});else{const e="can not set material, catalog item top image is not set";console.warn(e),s(e)}},s)})}setMaterialLoadedListener(e){this._materialLoaded=e}removeMaterialLoadedListener(){this._materialLoaded=void 0}_createMesh(e,t,n){if(e&&t){const s=this._getComponentMeshId(e,t);if(this._geometryComponentMaterialCache.has(s)){const e=this._geometryComponentMaterialCache.get(s);if(this._cacheHolder.materialCache.has(e)){const t=this._cacheHolder.materialCache.get(e);return new z(n,t)}}}return new z(n,this._configuratorPreviewMaterial.clone())}_getComponentMeshId(e,t){return e+"_"+t}}on([hn],Ka.prototype,"_initData",void 0),on([hn],Ka.prototype,"_rapiAccess",void 0),on([hn],Ka.prototype,"_dataSyncer",void 0),on([hn],Ka.prototype,"_singlePromiseFactory",void 0),on([hn],Ka.prototype,"_cacheHolder",void 0),on([hn],Ka.prototype,"_plannerMeshGenerator",void 0);class qa extends Ka{constructor(e){super(e)}generateMesh(e=0,t=null,n,s,i,a,r,o=!1,l){let h;h=o?this._generateGeometry(t,s,i,a,r).clone():this._generateGeometry(t,s,i,a,r);const d=this._createMesh(e,t,h);return d.userData.materialId=n,d.layers.set(4),n&&this.materialQueue.push(this._assignMaterial(d,n,l).then(()=>{e&&t&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n)})),d}setMaterial(e,t,n,s){return this._assignMaterial(e,t,s)}loadMaterial(e,t,n){return super._loadMaterial(e,t,n)}loadTextures(e,t,n,s){return super._loadTextures(e,t,n,s)}}e("aC",qa);class Xa{constructor(){this._listeners={},this._disabled=!1}_addEventListener(e,t,n){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push({callback:t,scope:n})}addEventListener(e,t,n){this._addEventListener(e,t,n)}dispatchEvent(e,t){if(!this._listeners[e]||this._disabled)return;const n=this._listeners[e];for(let s=0;s<this._listeners[e].length;s++){const e=n[s];t?e.callback.apply(e.scope,[t]):e.callback.call(e.scope)}}removeEventListener(e,t){const n=this._listeners[e];if(n)for(let e=0,s=n.length;e<s;e++)if(n[e].callback===t)return void n.splice(e,1)}enableEvents(){this._disabled=!1}disableEvents(){this._disabled=!0}}e("E",Xa);const Ya={SCROLL:"scroll",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_LEAVE:"mouseleave",MOUSE_ENTER:"mouseenter",MOUSE_WHEEL:"wheel",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend",CONTEXT_MENU:"contextmenu",DOUBLE_CLICK:"dblclick"};e("ae",{DRAG:50});class Qa{constructor(e,t,n,s,i){this.position=e,this.positionRelative=t,this.type=n,this.rotation=s,this.event=i}}const Za=e("a4",5*window.devicePixelRatio),Ja=4*window.devicePixelRatio;class $a extends Xa{constructor(e){super(),this._elementHit=!1,this._delta=-1,this._state=0,this._pinchDistance=-1,this._rotationAngle=-1,this._lastMouseWheelEvent=null,this._lastTouchEvent=null,this._events=Object.keys(Ya).map(e=>Ya[e]),this._boundingClientRectInvalid=!0,this._creator_=e,this._downPosition={x:0,y:0},this._downPositionRelative={x:0,y:0},this._boundingClientRect=this._getBoundingClientRect()}enableDragIn(e){this._setState(1),this._dragEnabled=!0,e&&(this._dragMV=this._dragM.bind(this),this._dragEV=this._dragE.bind(this),this._dragTarget=e.currentTarget||e.target,this._delta=-1,this._dragMVName="drag",this._dragEVName="dragend",window.TouchEvent&&e instanceof TouchEvent?(this._dragMVName="touchmove",this._dragEVName="touchend"):e.dataTransfer&&e.dataTransfer.setData&&e.dataTransfer.setData("text/plain"," "),this._firefoxDragPosition={x:0,y:0},document.ondragover=e=>{e=e||window.event,this._firefoxDragPosition.x=e.pageX,this._firefoxDragPosition.y=e.pageY},this._dragTarget.addEventListener(this._dragMVName,this._dragMV,!1),this._dragTarget.addEventListener(this._dragEVName,this._dragEV,!1))}isMouseUp(){return 0===this._state}_dragM(e){let t=e,n=null,s=null;window.TouchEvent&&e instanceof TouchEvent?(n=this._getTouchPosition(t),s=this._getTouchPositionRelative(t)):(n=this._getMousePosition(t),s=this._getMousePositionRelative(t)),n.x>0&&n.y>0&&this._move(n,s)}_dragE(e){let t=e;document.ondragover=null,this._firefoxDragPosition=null,this._dragTarget.removeEventListener(this._dragMVName,this._dragMV),this._dragTarget.removeEventListener(this._dragEVName,this._dragEV),window.TouchEvent&&e instanceof TouchEvent?this._onUp(this._getTouchPosition(t),this._getTouchPositionRelative(t),2):this._onUp(this._getMousePosition(t),this._getMousePositionRelative(t),1)}addEvents(e){this._events.forEach(t=>e.addEventListener(t,this,!1)),null===window||void 0===window||window.addEventListener("scroll",this,!1)}removeEvents(e){this._events.forEach(t=>e.removeEventListener(t,this)),null===window||void 0===window||window.removeEventListener("scroll",this)}_move2(e){if(this._lastTouchEvent&&e.timeStamp-this._lastTouchEvent.timeStamp<16)return;const t=e.touches[0],n=e.touches[1],s=t.pageX-n.pageX,i=t.pageY-n.pageY,a=Math.abs(s)+Math.abs(i);this._pinchDistance>-1&&(a>this._pinchDistance+Ja?(this._setState(3),this.dispatchEvent(7,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):a<this._pinchDistance-Ja?(this._setState(3),this.dispatchEvent(8,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):a<=this._pinchDistance+Ja&&a>=this._pinchDistance-Ja&&3!==this._state&&(this._setState(5),this.dispatchEvent(11,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e))))),this._pinchDistance=a,this._lastTouchEvent=e}_setState(e){this._state=e}_move(e,t,n,s){void 0===n&&(n=0),void 0===this._dragEnabled&&(this._dragEnabled=!1),1===this._state&&this._canDrag(n)&&(this._delta=this._getDelta(e),(this._delta>Za||this._elementHit)&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new Qa(this._downPosition,this._downPositionRelative)))),2===this._state&&this.dispatchEvent(1,new Qa(e,t)),this.dispatchEvent(6,new Qa(e,t,n,null,s))}_longClick(e){2!==e&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new Qa(this._downPosition,this._downPositionRelative)),this.dispatchEvent(1,new Qa(this._downPosition,this._downPositionRelative))),this.dispatchEvent(14,new Qa(this._downPosition,this._downPositionRelative,2))}_onUp(e,t,n){this.dispatchEvent(4,new Qa(e,t,n)),this._getDelta(e)<=Za&&this.dispatchEvent(5,new Qa(e,t)),2===this._state&&this.dispatchEvent(2,new Qa(e,t)),4===this._state&&(this.dispatchEvent(10,new Qa(e,t)),this._rotationAngle=-1),3!==this._state&&5!==this._state||(this._pinchDistance=-1),this._lastTouchEvent=null,this._setState(0),this._dragTarget=null,this._elementHit=!1,this._longClickTimer&&clearTimeout(this._longClickTimer)}_getTouchPosition(e){if(e.touches.length){let{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>1){const s=e.touches[1],i=s.clientX,a=s.clientY;t=(t+i)/2,n=(n+a)/2}return{x:t,y:n}}const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}_getTouchPositionRelative(e){const t=this._getBoundingClientRect(),{clientWidth:n,clientHeight:s}=this._domHelper.element;if(e.touches.length){const{clientX:i,clientY:a}=e.touches[0];return{x:(i-t.left)/n*2-1,y:-(a-t.top)/s*2+1}}const i=e.changedTouches[0];return{x:(i.clientX-t.left)/n*2-1,y:-(i.clientY-t.top)/s*2+1}}_getMousePosition(e){if(0!==e.clientX&&0!==e.clientY)return{x:e.clientX,y:e.clientY};{let{x:t,y:n}=this._getFireFoxMousePosition(e);return{x:t,y:n}}}_getFireFoxMousePosition(e){let{x:t,y:n}=this._domHelper.getClientDimensions();return{x:t-(t+e.offsetX),y:n-(n+e.offsetY)}}_getMousePositionRelative(e){const t=this._getBoundingClientRect();return 0!==e.clientX&&0!==e.clientY?{x:(e.clientX-t.left)/this._domHelper.element.clientWidth*2-1,y:-(e.clientY-t.top)/this._domHelper.element.clientHeight*2+1}:this._firefoxDragPosition&&0!==this._firefoxDragPosition.x&&0!==this._firefoxDragPosition.y?{x:(this._firefoxDragPosition.x-t.left)/this._domHelper.element.clientWidth*2-1,y:-(this._firefoxDragPosition.y-t.top)/this._domHelper.element.clientHeight*2+1}:{x:0,y:0}}_getDelta(e){return Math.abs(this._downPosition.y-e.y)+Math.abs(this._downPosition.x-e.x)}setDragEnabled(e){this._dragEnabled=e}handleEvent(e){switch(e.type){case Ya.SCROLL:this._boundingClientRectInvalid=!0;break;case Ya.MOUSE_MOVE:this._onMouseMove(e);break;case Ya.DOUBLE_CLICK:this._onDoubleClick(e);break;case Ya.MOUSE_DOWN:this._onMouseDown(e);break;case Ya.MOUSE_UP:this._onMouseUp(e);break;case Ya.MOUSE_LEAVE:this._onMouseLeave(e);break;case Ya.MOUSE_ENTER:this._onMouseEnter(e);break;case Ya.MOUSE_WHEEL:this._onMouseWheel(e);break;case Ya.TOUCH_MOVE:this._onTouchMove(e);break;case Ya.TOUCH_START:this._onTouchStart(e);break;case Ya.TOUCH_END:this._onTouchEnd(e);break;case Ya.CONTEXT_MENU:this._onContextMenu(e)}}_onMouseDown(e){if(e.preventDefault(),2===e.detail)return;let{x:t,y:n}=this._getMousePosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getMousePositionRelative(e),this.dispatchEvent(3,new Qa({x:t,y:n},this._downPositionRelative,1)),this._setState(1)}_onMouseUp(e){e.preventDefault(),2!==e.detail&&this._onUp(this._getMousePosition(e),this._getMousePositionRelative(e),1)}_onMouseMove(e){e.preventDefault(),this._move(this._getMousePosition(e),this._getMousePositionRelative(e),1,e)}_onDoubleClick(e){e.preventDefault(),this.dispatchEvent(12,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1))}_onMouseLeave(e){var t;this._delta=-1,(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest('[data-rml-sdk="ignore-mouse-leave"]'))||this._onMouseUp(e)}_onMouseEnter(e){e.preventDefault()}_onMouseWheel(e){if(this._lastMouseWheelEvent&&e.timeStamp-this._lastMouseWheelEvent.timeStamp<40)return e.preventDefault(),void e.stopPropagation();e.deltaY<0?this.dispatchEvent(7,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)):this.dispatchEvent(8,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)),this._lastMouseWheelEvent=e}_onTouchMove(e){if(e.preventDefault(),!this._dragTarget)if(1===e.touches.length)this._move(this._getTouchPosition(e),this._getTouchPositionRelative(e),2);else if(2===e.touches.length)if(this._elementHit||4===this._state){const s=e.touches[0],i=e.touches[1],a=function(e){let t=vs(e);return t<0&&(t=180+(180+t)),t}((t={x:s.pageX,y:s.pageY},n={x:i.pageX,y:i.pageY},Math.atan2(n.y-t.y,n.x-t.x)));this._rotationAngle<0&&(this._rotationAngle=a);const r=a-this._rotationAngle;this._rotationAngle=a,this.dispatchEvent(9,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e),2,_s(r))),this._setState(4)}else this._move2(e);var t,n}_onTouchStart(e){if(e.preventDefault(),1===e.touches.length){let{x:t,y:n}=this._getTouchPosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getTouchPositionRelative(e),this.dispatchEvent(3,new Qa({x:t,y:n},this._downPositionRelative,2)),this._setState(1),this._longClickTimer=window.setTimeout(this._longClick.bind(this,2),350)}else 2===e.touches.length&&(1!==this._state&&2!==this._state||this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2))}_onTouchEnd(e){e.preventDefault(),this.dispatchEvent(13,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)),this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)}_onContextMenu(e){e.preventDefault()}_canDrag(e){return this._dragEnabled}onElementHit(){this._elementHit=!0}_getBoundingClientRect(){return this._boundingClientRectInvalid&&(this._boundingClientRect=this._domHelper.element.getBoundingClientRect(),this._boundingClientRectInvalid=!1),this._boundingClientRect}updateSize(){this._boundingClientRectInvalid=!0}}e("aw",$a),on([hn],$a.prototype,"_domHelper",void 0);class er{constructor(e){const{component:t,resetCamera:n,consecutive:s}=e;this.component=t,this.resetCamera=void 0===n||n,this.consecutive=void 0===s||s}}class tr extends f{constructor(e){super(e)}load(e,t,n,s){const i=this,a=new v(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){const n=i.parse(JSON.parse(e));t&&t(n)}),n,s)}parse(e){return new nr(e)}}class nr{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],s=function(e,t,n){const s=Array.from(e),i=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,r=[];let o=0,l=0;for(let e=0;e<s.length;e++){const t=s[e];if("\n"===t)o=0,l-=a;else{const e=sr(t,i,o,l,n);o+=e.offsetX,r.push(e.path)}}return r}(e,t,this.data);for(let e=0,t=s.length;e<t;e++)n.push(...s[e].toShapes());return n}}function sr(e,t,n,s,i){const a=i.glyphs[e]||i.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+i.familyName+".");const r=new Ze;let o,l,h,d,c,u,p,m;if(a.o){const e=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let i=0,a=e.length;i<a;)switch(e[i++]){case"m":o=e[i++]*t+n,l=e[i++]*t+s,r.moveTo(o,l);break;case"l":o=e[i++]*t+n,l=e[i++]*t+s,r.lineTo(o,l);break;case"q":h=e[i++]*t+n,d=e[i++]*t+s,c=e[i++]*t+n,u=e[i++]*t+s,r.quadraticCurveTo(c,u,h,d);break;case"b":h=e[i++]*t+n,d=e[i++]*t+s,c=e[i++]*t+n,u=e[i++]*t+s,p=e[i++]*t+n,m=e[i++]*t+s,r.bezierCurveTo(c,u,p,m,h,d)}}return{offsetX:a.ha*t,path:r}}const ir=new Map,ar=new Map;class rr{static loadFont(e){if(ar.has(e))return new Promise(t=>{t(ar.get(e))});if(ir.has(e))return new Promise((t,n)=>{ir.get(e).push({resolve:t,reject:n})});let t=new tr;return new Promise((s,i)=>{ir.set(e,[{resolve:s,reject:i}]),t.load(n()+e,t=>{ar.set(e,t),rr._resolveAll(e,t)})})}static _resolveAll(e,t){ir.has(e)&&ir.get(e).forEach(e=>e.resolve(t)),ir.delete(e)}}e("aH",rr);class or{constructor(e){this._activeComponents=[],this._componentDimensioningsExist=new Map,this._creator_=e}setCamera(e){this._camera=e}add(e){if(this._componentDimensioningsExist.has(e.runtimeId)&&!this._componentDimensioningsExist.get(e.runtimeId))return!1;const n=this._plannerKernelAccess.kernelInstance.getComponent(e.runtimeId),s=n.dimensionings;if(this._componentDimensioningsExist.set(e.runtimeId,s.length>0),!s||0===s.length||this._camera.position.z<0)return!1;const i=Li(n.boxForMeasurement),a={x:this._camera.position.x,y:this._camera.position.z};return t.import("./component-dimensioning-be6f4978.nomodule.js").then(t=>{rr.loadFont("static/rubik_regular-bc008a7de2daee79.json").then(n=>{s.forEach(s=>{var r;e.add(new t.default(((r=s).from=r.from/1e3,r.to=r.to/1e3,1===r.type.value?(r.type={value:2},r.from*=-1,r.to*=-1):2===r.type.value&&(r.type={value:1}),r),i,n,a))})})}),this._activeComponents.push(e),!0}remove(e,n=!0){return new Promise(s=>{t.import("./component-dimensioning-be6f4978.nomodule.js").then(t=>{let i=[];e.children.forEach(e=>{e instanceof t.default&&i.push(e)}),i.forEach(t=>{e.remove(t),ea(t)}),n&&Je(this._activeComponents,e),s()})})}hasComponentDimensions(){return this._activeComponents.length>0}async reset(){for(const e of this._activeComponents)await this.remove(e);this._activeComponents=[]}invalidateDimensioningsCache(e){e?this._componentDimensioningsExist.delete(e):this._componentDimensioningsExist.clear()}}on([hn],or.prototype,"_plannerKernelAccess",void 0);const lr=(e("as",e=>lr(e)),e=>({...e,fromPosition3d:la(e.fromPosition3d),toPosition3d:la(e.toPosition3d),textPosition3d:la(e.textPosition3d),fromPosition2d:oa(e.fromPosition2d),toPosition2d:oa(e.toPosition2d),textPosition2d:oa(e.textPosition2d),textDirection:la(e.textDirection),textRotation:e.textRotation,length:e.length})),hr=(e,t)=>{let n,s;0===t.value?(n=bs(e.getCornerFromLeft()),s=bs(e.getCornerToLeft())):1===t.value&&(n=bs(e.getCornerFromRight()),s=bs(e.getCornerToRight()));const i=n.clone().add(s).divideScalar(2);return{from:n,to:s,middle:i}},dr=e=>{const t=bs(e.getCornerFromLeft()),n=bs(e.getCornerToLeft()),s=bs(e.getCornerFromRight()),i=bs(e.getCornerToRight());return{centerFrom:t.clone().add(s).divideScalar(2),centerTo:n.clone().add(i).divideScalar(2)}},cr=e=>{const t=e.clone();e.dot(new r(1,0,0))<0&&t.multiplyScalar(-1);const n=Math.atan2(t.z,t.x);let s=n;return n>=Math.PI/2&&n<3*Math.PI/2&&(s+=Math.PI),{textDirection:t,textRotation:s}},ur=(e,t,n,s=23)=>{const i=t/n,a=i>1.77;let r=1080,o=s;return i<1?o="0.7"===i.toFixed(1)?30:20:a&&(r=1188,o=2===Math.round(i)?25:30),o/n*(n/(e*r))},pr=e("au",e=>{const t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));return t}),mr=(e,t,n,s)=>{let i;if(!e.getPlanElement()||!("getAttachedWall"in e.getPlanElement())||!(i=e.getPlanElement().getAttachedWall()))return null;const a=i.getPreferredSide(),o=e.getPlanElement().getPreferredSide(),l=bs(i.getCenter()),{from:h,to:d,middle:c}=hr(i,a);let{from:u,to:p}=hr(e.getPlanElement(),o);h.y=0,d.y=0,u.y=0,p.y=0;const{wallFromCenterPoint:m,wallToCenterPoint:g}=gr(e,h,u,d,p),{centerFrom:f,centerTo:_}=dr(e.getPlanElement()),v=p.clone().sub(u),w=v.clone().cross(new r(0,1,0)).normalize();w.clone().dot(c.clone().sub(l))<0&&w.multiplyScalar(-1);const{textDirection:b,textRotation:y}=cr(v),S=ur(t,n,s),x=w.clone().multiplyScalar(S),P=new r(0,0,0),M={fromPosition2d:P,toPosition2d:P,textPosition2d:P};return{leftMeasurement:{fromPosition3d:u,toPosition3d:h,textDirection:w,textRotation:y,textPosition3d:f.clone().add(m).divideScalar(2),length:1e3*u.distanceTo(h),...M},rightMeasurement:{fromPosition3d:p,toPosition3d:d,textDirection:w,textRotation:y,textPosition3d:_.clone().add(g).divideScalar(2),length:1e3*p.distanceTo(d),...M},elementRange:{fromPosition3d:u,toPosition3d:p,textDirection:b,textRotation:y,textPosition3d:u.clone().add(p).divideScalar(2).add(x),length:1e3*v.length(),...M}}},gr=(e,t,n,s,i)=>{const a=t.clone().sub(n),r=s.clone().sub(i),o=a.length(),l=r.length(),h=a.clone().normalize().multiplyScalar(o),d=r.clone().normalize().multiplyScalar(l),{centerFrom:c,centerTo:u}=dr(e.getPlanElement());return{wallFromCenterPoint:c.clone().add(h),wallToCenterPoint:u.clone().add(d)}};class fr{constructor(){this._promiseExecutors=[]}create(){return new Promise((e,t)=>{this._promiseExecutors.push({resolve:e,reject:t})})}resolve(e){return new Promise(t=>{this._promiseExecutors.forEach(t=>t.resolve(e)),this._promiseExecutors=[],t(e)})}reject(e){return new Promise((t,n)=>{this._promiseExecutors.forEach(t=>t.reject(e)),this._promiseExecutors=[],n(e)})}}class _r extends class{constructor(e){this._coreReference=e.clone()}clearReference(){this._coreReference.delete(),this._coreReference=null}getKernelObject(){return this._coreReference}}{constructor(e){super(e),this._objectWaiter=new fr,this._topView=!1;const t=bs(e.getCenter());this._container=new A,this._container.position.copy(t),this._boundingBox=this._generateBoundingBox(),$i(this._boundingBox),this._container.add(this._boundingBox),2!==this.getPlanElement().getType().value&&(this._object=new A,this._container.add(this._object))}getSize(){return this._object?(new ge).setFromObject(this._object).getSize(new r):new r}update(){this._container.position.copy(bs(this.getPlanElement().getMeshCenter())),this._boundingBox&&this._updateBoundingBox()}_updateBoundingBox(){const e=this.getSize();this._boundingBox.geometry=new $e(e.x,e.y,e.z),this._boundingBox.position.y=e.y/2}getPosition(){return this._container.position}getRotation(){return this._container.rotation.y}getBounds(){let e;return this.getPlanElement().boxForMeasurement?(e=Li(this.getPlanElement().boxForMeasurement),e.applyMatrix4(this.getContainer().matrix)):(e=new ge,e.setFromObject(this._container)),e}getBoundingBox(){return this._boundingBox}getPlanElement(){return this._coreReference}setObject(e){this._object=e,this._objectWaiter.resolve(e)}getObject(){return this._object}async getObjectAsync(){return this._object?Promise.resolve(this._object):this._objectWaiter.create()}addMesh(e){this._object.add(e),this.hidePreviewBox()}getMesh(e){if(!this._object||0===this._object.children.length)return null;const t=ra(e,this.getPlanElement().getType());return this._object.children.find(e=>e.userData.material===t)}getContainer(){return this._container}getId(){var e,t;return null!==(t=null===(e=this.getPlanElement())||void 0===e?void 0:e.getId())&&void 0!==t?t:0}clear(){ea(this._container),this._selectionMesh&&ea(this._selectionMesh)}remove(){var e;null===(e=this._container.parent)||void 0===e||e.remove(this._container),this.clear()}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material=(aa||(aa=new y,aa.visible=!1),aa))}_generateBoundingBox(){const e=this.getSize(),t=new $e(e.x,e.y,e.z);let n=new h("#DDDDDD");const s=this.getPlanElement().customColor;s>0&&(n=Ji(s));let i=Oi.createMeshStandardMaterial({color:n,opacity:1,transparent:!0}),a=new z(t,i);return a.name="bounding box",a.position.y=e.y/2,a.castShadow=!1,a.receiveShadow=!1,a.layers.set(6),a}select(){this._isSelected=!0,this._selectionMesh&&this._container.add(this._selectionMesh)}deselect(){this._isSelected=!1,this._selectionMesh&&this._container.remove(this._selectionMesh)}hoverOn(){}hoverOff(){}setTopView(e){this._topView=e}toJSON(){return{rootElementId:this.getPlanElement().getId()}}}e("ar",e=>({...lr(e)}));class vr extends _r{constructor(e){super(e),this._initDone=!1,this._initFailed=null,this._initWaiter=new fr,this._container.rotation.y=e.rotation}finishInit(){return this._initDone=!0,this._initFailed=null,this._initWaiter.resolve()}failInit(e){return this._initFailed=e,this._initDone=!1,this._initWaiter.reject(this._initFailed)}isInitDone(){return this._initDone?Promise.resolve():this._initFailed?Promise.reject(this._initFailed):this._initWaiter.create()}getPlanObject(){return this.getPlanElement()}getSize(){return ys(this.getPlanObject().size)}getObjectMeasurements(e,t,n){const s=this.getPlanObject(),i=s.getRectangle(),{referencePoints:a,size:o,center:l}=i;if(!a)return null;const h=(s,i,a=!1,o=0)=>{const h=bs(s),d=bs(i);let c=h.clone().add(d).divideScalar(2);const u=h.clone().sub(d),{textDirection:p,textRotation:m}=cr(u);if(a){const s=u.clone().cross(new r(0,1,0)).normalize(),i=c.clone().sub(bs(l));s.dot(i)<0&&s.multiplyScalar(-1);const a=ur(e,t,n),o=s.multiplyScalar(a);c.add(o)}return{fromPosition3d:h,toPosition3d:d,textPosition3d:c,textDirection:p,textRotation:m,length:o}},d=[{from:a.topLeft,to:a.topRight},{from:a.topRight,to:a.bottomRight},{from:a.bottomRight,to:a.bottomLeft},{from:a.bottomLeft,to:a.topLeft}].map(e=>h(e.from,e.to)),c=[{from:a.topLeft,to:a.topRight,length:o.x},{from:a.topRight,to:a.bottomRight,length:o.y}].map(e=>{const t=h(e.from,e.to,!0);return t.length=e.length,t}),u=pr(s.getWallDistances());return{rectMeasurements:d,objectMeasurements:c,objectToWallsMeasurements:u?u.map(e=>({...h(e.startPoint,e.endPoint,!1,e.length),id:et(e.angle+"_"+e.length)})):null}}update(){super.update(),this._container.rotation.y=this.getPlanObject().rotation}}class wr extends vr{constructor(e){super(e),this._container.name="Configurable "+this._container.name}addRootComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId,this._container.add(this.getObject())}addChildEntityComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId}getConfigurationRuntimeId(){return this.getPlanObject().getConfigurationRuntimeId()}getRootComponentId(){return this._rootComponentId}getRootComponentRuntimeId(){return this._rootComponentRuntimeId}finishConstruction(){return this.finishInit()}failConstruction(){return this.failInit(new Error("Construction of configuration failed"))}toJSON(){return{...super.toJSON(),rootComponentRuntimeId:this._rootComponentRuntimeId}}}e("d",wr);let br=JSON.parse(JSON.stringify({isProduction:!0,isUnitTesting:!1,environment:"production",detailEnvironment:"development",features:{},APP:{RAPI:{server:"/api/v2",localReverseProxy:"https://www.roomle.com/api/v2",liveServer:"https://www.roomle.com/api/v2",testServer:"https://www.test.roomle.com/api/v2",headers:{apiKey:"roomle_portal_v2",currentTenant:9,locale:"en",language:"en",device:1,token:"anonymous",platform:"web"},itemHeaders:{assetRevision:"glb",assetFileFormat:"glb"}},SHORTENER_URL:"http://rml.co/"},environments:{PRODUCTION:"production",DEVELOPMENT:"development",TEST:"test",TEST_SERVER:"test_server",ALPHA:"alpha"}}));br.isUnitTesting=!1,void 0!==t&&t.exports||(window.IS_DEBUG=!0);const yr={ENV_DEBUG:function(e=!1){if(e){let e=JSON.parse(JSON.stringify(br));const t={...e.APP,SHORTENER_URL:"http://localhost:4747/?isItem=false&id="},n={...e.features};return{...e,isProduction:!1,APP:t,features:n}}}(),ENV_PRODUCTION:JSON.parse(JSON.stringify(br))};var Sr=e("n",yr.ENV_PRODUCTION);class xr extends vr{constructor(e){super(e),this._originalSize=new r,this._container.name="Static "+this._container.name}setRapiItem(e){return this._rapiItem?this.isInitDone():this._addStaticItem(e)}async _addStaticItem(e){this._rapiItem=e;let t=this.getPlanObject();if(this._glbUrl=tt(e),!this._glbUrl)return Promise.reject("No glb url found");let n=e.scaleable?ys(t.size):void 0,s=new r(1,1,1);t.flipX&&(s.x*=-1),t.flipY&&(s.z*=-1);try{const i=await this._staticItemLoader.loadGLB(this._glbUrl,void 0,void 0,n,s,t.customColor,e.colorable);this._originalSize.copy(i.boundingBox.getSize(new r)),i.scene.name=e.label,this.setObject(i.scene),((e,t)=>{let n=(new ge).setFromObject(e),s=n.getSize(new r),i=Math.min(s.x,s.y,s.z),a=!0;i>5&&(console.warn("GLB seems to be too big ("+i+")",t),a=!1),n.min.y<-.01&&(console.warn("GLB seems to be under the floor ("+n.min.y+"): ",t),a=!1)})(i.scene,this._glbUrl),$i(i.scene),this._container.add(this.getObject()),this.hidePreviewBox(),await this.finishInit()}catch(e){await this.failInit(e)}}getRapiItem(){return this._rapiItem}needsRapiItem(){return!this._glbUrl}getGLBUrl(){return this._glbUrl}update(){super.update();const e=ys(this.getPlanElement().size),t=this.getObject();if(!t)return;if(e){const{x:n,y:s,z:i}=this._originalSize;let a=new r(e.x/n,e.y/s,e.z/i);t.scale.copy(a)}this.getPlanElement().flipX&&(t.scale.x*=-1),this.getPlanElement().flipY&&(t.scale.z*=-1);const n=this.getPlanElement().customColor;t.traverse(e=>{if(e instanceof z&&e.material instanceof N){const t=e.material;if(this._rapiItem.colorable&&n&&n>0){let e=new h(n);t.color=e.copySRGBToLinear(e)}t.needsUpdate=!0}})}}let Pr;e("S",xr),on([hn],xr.prototype,"_staticItemLoader",void 0),e("at",e=>({...lr(e),id:e.id,fromWithoutPadding:la(e.fromWithoutPadding),toWithoutPadding:la(e.toWithoutPadding),lengthFormatted:e.lengthFormatted}));const Mr=()=>(Pr||(Pr=Oi.createMeshPhysicalMaterial({color:0})),Pr);class Cr extends _r{constructor(e){super(e),this._container.name="Wall Plan Element"}get isSelected(){return this._isSelected}getWallDimension(e,t,n){const s=this.getPlanElement(),i=bs(s.getCenter()),a=s.getPreferredSide(),{from:o,to:l,middle:h}=hr(s,a),d=o.clone().sub(l),c=d.clone().cross(new r(0,1,0)).normalize();c.clone().dot(h.clone().sub(i))<0&&c.multiplyScalar(-1);const u=parseFloat(ur(e,t,n).toFixed(3)),{textDirection:p,textRotation:m}=cr(d),g=c.clone().multiplyScalar(u),f=o.clone().add(g),_=l.clone().add(g),v=c.clone().multiplyScalar(u/2),w=o.clone().add(v),b=l.clone().add(v),y=f.clone().add(_).divideScalar(2);return{id:s.getId(),fromPosition3d:f,toPosition3d:_,textPosition3d:y,textDirection:p,textRotation:m,length:s.getLength(a),fromWithoutPadding:w,toWithoutPadding:b}}addMesh(e){e.traverse(e=>{this._setMaterial(e)}),e.layers.set(9),super.addMesh(e);const t=(new ge).setFromObject(this.getObject()).getSize(new r);this._boundingBox.geometry=new $e(t.x,t.y,t.z),this._boundingBox.position.y=t.y/2}show(){var e,t;this.getContainer().visible=!0,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.set(9)}),null===(t=this.getBoundingBox())||void 0===t||t.layers.set(6)}hide(){var e,t;this.getContainer().visible=!1,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.disableAll()}),null===(t=this.getBoundingBox())||void 0===t||t.layers.disableAll()}_enableTopView(){this._container.traverse(e=>{this._setTopMaterial(e)})}_setTopMaterial(e){e instanceof z&&!e.userData.originalMaterial&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial=e.material,e.material=Mr())}_disableTopView(){this._container.traverse(e=>{e instanceof z&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial)})}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView()}getKernelObject(){return super.getKernelObject()}_setMaterial(e){e instanceof z&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),this._topView&&this._isSelected?e.material=new y({color:10526880,side:F}):this._topView&&!this._isSelected?e.material=Mr():(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial))}select(){super.select(),this._container.traverse(e=>{this._setMaterial(e)})}deselect(){super.deselect(),this._container.traverse(e=>{this._setMaterial(e)})}}e("W",Cr),e("ap",e=>({area:e.area,formattedArea:e.formattedArea||null,textPosition3d:la(e.textPosition3d),textPosition2d:e.textPosition2d?la(e.textPosition2d):{x:0,y:0,z:0},isTextVisible:e.isTextVisible}));class Tr extends _r{constructor(e){super(e),this._container.name="Floor Plan Element"}addMesh(e){this.getObject().clear(),super.addMesh(e),e.layers.set(9),e.castShadow=!1,e.position.y=-.001}getFloorData(e){const t=this.getKernelObject(),n=(new ge).setFromObject(this._container),s=bs(t.getLabelPosition()),i=this.calculateTextVisibility(n,e);return{area:t.area,formattedArea:"",textPosition3d:s,textPosition2d:new r,isTextVisible:i}}calculateTextVisibility(e,t){const n=new r;return e.getSize(n),n.length()*t>.2}}e("F",Tr);class Ar extends _r{constructor(e){super(e),this._container.name="Ceiling Plan Element"}addMesh(e){super.addMesh(e),e.castShadow=!1;const t=(new ge).setFromObject(this.getObject()).getSize(new r);this._boundingBox.geometry=new $e(t.x,.01,t.z)}}e("f",Ar);const Rr=new Map;class Er{static start(e){if(!window.performance||!window.performance.getEntriesByName)return"";let t=window.performance.getEntriesByName(e).length++,n="";t<100&&(n="0"),t<10&&(n="0"+n);const s=t>0?e+"_"+n+t:e,i=s+"_start";return window.performance.mark(i),s}static addMeta(e,t){const n=Er.getMeta(e);Rr.set(e,Object.assign(n,t))}static getMeta(e){return Rr.get(e)||{}}static end(e){}static getMeasure(e){return[]}static showBenchmarks(e){const t=window.performance.getEntriesByType("measure");t.sort((function(e,t){return e.startTime-t.startTime}));const n=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];e&&-1===i.name.indexOf(e)||n.push({Start:parseFloat(i.startTime.toFixed(2)),Name:i.name,Duration:parseFloat(i.duration.toFixed(2))})}console.table(n)}}e("B",Er);class Ir{static init(e={}){const{kernelInstance:t,kernelContainer:n,planObjectId:s}=e;Ir.kernelInstance=t,Ir.kernelContainer=n,Ir.planObjectId=s}static cleanUp(){Ir.useHDGeometry=!1,Ir.kernelInstance=null,Ir.kernelContainer=null,Ir.planObjectId=null}}e("A",Ir),Ir.useHDGeometry=!1,Ir.kernelInstance=null,Ir.kernelContainer=null,Ir.planObjectId=null;const Dr=new Map,Or=function(e,t,n){let s=Dr.get(e);if(s){const i=n?[n]:void 0;s.forEach(({resolve:e,reject:n})=>t?e.apply(e,i):n.apply(n,i)),Dr.delete(e)}};class Lr{static finishOperation(e,t){Or(e,!0,t)}static failOperation(e,t){Or(e,!1,t)}static waitFor(e,t){return new Promise((n,s)=>{let i=Dr.get(e);i||(Dr.set(e,[]),i=Dr.get(e)),i.push({resolve:n,reject:s}),"function"==typeof t&&t.apply(t)})}}e("Q",Lr);const kr=e("T",(function(e){return e.validRange&&"string"==typeof e.validRange.type})),Ur=function(e){return e.validValues&&e.validValues.length>0},Br=e("U",(function(e){return"Material"===e.type}));let Nr,Fr,Gr;const jr={WASM_MODERN:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-031e65eaee5cacde.wasm",LOADER:"static/ConfiguratorKernel-82e5093feef1b077.js"},PLANNER:{URL:"static/RoomleCore-55c9812f52948f19.wasm",LOADER:"static/RoomleCore-e517dbd10f96e64e.js"}}},zr=!!window.WebAssembly;class Vr{_utilityToLongArray(e){const t=new this._kernelContainer.LongArray;return e.forEach(e=>t.push_back(e)),t}constructor(e){this._requestedItemIds=[],this._requestedMaterialIds=[],this._configuratorKernelCallbackListener=new Set,this._cachedGroupIds=[],this._waitingForGroups=!1,this._subComponentsWaiters=new Map,this._shouldWait=!0,this._creator_=e,window.KernelCallback={isReady:this.isReady.bind(this)},this._lifeCycleManager.addEventListener(this)}init(e){this._kernelType=e,this._setupKernelPaths(e),this._setupEmsModule(e),this._useWASM=zr,this._kernelPath=zr?Fr:void 0}_initKernel(){const{restrictionLevel:e}=this._initData,t=!1!==this._initData.callbacksOnlyIfGeometryIsReady;this._kernelInstance.setUpdateCallbacksOnlyIfGeometryIsReady(t),this._kernelInstance.setLevel(e),this._unitFormatter.init(this._kernelContainer),this._kernelInstance.setEnvironmentVariable("unit",this._unitFormatter._actualUnitString||"cm"),this._kernelInstance.setEnvironmentVariable("unitString","short"),this._kernelInstance.useEnvironmentGeometry(1===this._kernelType);const{overrideCountry:n,locale:s}=this._globalInitData;n&&(this._kernelInstance.resetPriceListIds(),this._kernelInstance.addPriceList(n)),this._kernelInstance.setEnvironmentVariable("language",s)}get kernelContainer(){return this._kernelContainer}get kernelInstance(){return this._kernelInstance}get configurationExporter(){return this._configurationExporter||(this._configurationExporter=this._kernelContainer.newConfigurationExporter()),this._configurationExporter}_setupKernelPaths(e){const t=0===e?"PLANNER":"CONFIGURATOR";Nr=jr.WASM_MODERN[t].URL,Fr=jr.WASM_MODERN[t].LOADER,Gr=!0}_setupEmsModule(e){const t=this;this._kernelContainer={locateFile(t){const s=0===e?/RoomleCoreJs[\-a-z0-9]*\.js\.mem/:/ConfiguratorKernelJs[\-a-z0-9]*\.js\.mem/;return t.match(s)?n()+void 0:t},wasmBinaryFile:n()+Nr,preRun:[],postRun:[],setStatus:null,print(e){t._kernelIo.log(e)},printErr(e){t._kernelIo.error(e)},quit(e){0!==e&&t._kernelIo.throw(e&&e.toString?e.toString():"Unknown error while C/C++ main executes")}},Gr&&zr&&(this._kernelContainer.instantiateWasm=function(e,t){return((e,t,s)=>{const i="function"==typeof WebAssembly.instantiateStreaming;Er.addMeta("kernel_is_ready",{cachedInIndexedDB:!1});let a=null;i?(Er.start("kernel_stream_compile"),a=WebAssembly.instantiateStreaming(fetch(n()+e),t)):(Er.start("kernel_legacy_compile"),a=fetch(n()+e).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,t))),Er.addMeta("kernel_is_ready",{instantiateStreaming:i}),a.then(e=>{s(e.instance)},e=>console.error(e))})(Nr,e,t),{}})}_passSubComponentsToKernel(e,t){const n=e.id,s=t.get(n);if(s)for(let t=0,i=s.length;t<i;t++){const{parentId:i,partId:a}=s[t];this._kernelIo.setMeta({componentId:n}),this._kernelInstance.loadedSubComponent(i,a,n,e.configuration)}}_fetchSubComponents(e){let t=[...e.keys()];t.length&&this._rapiAccess.getComponents(t).then(t=>{for(let n=0,s=t.length;n<s;n++)this._passSubComponentsToKernel(t[n],e);this._flushSubComponentsWaiters()})}_flushSubComponentsWaiters(){this._fetchSubComponents(this._subComponentsWaiters),this._subComponentsWaiters=new Map,this._shouldWait=!1}isReady(){this._kernelContainer.setExternalHelpers(this._kernelIo,{convertCObject:Ps}),Sr.isProduction||Sr.isUnitTesting||this.addDebugInfo(),window.KernelCallback&&(window.KernelCallback=null,delete window.KernelCallback)}addDebugInfo(){const e=function(t,n=[]){const s=Object.getPrototypeOf(t),i=s?Object.getOwnPropertyNames(s):[],a=t?Object.getOwnPropertyNames(t):[];return s?e(s,[...n,...a,...i]):[...a,...i,...n]},t=e(this),n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf"];[...new Set(t)].forEach(e=>{if(!e.startsWith("_")&&"function"==typeof this[e]&&-1===n.indexOf(e))try{const t=this[e].bind(this);this[e]=function(...n){return this._kernelIo.log("[ KernelCommunication ]: "+e),t(...n)}}catch(e){}})}getConfigurationData(e){return new Promise(t=>{var n;const s=this.kernelInstance.getPlanObject(e),i=(new Date).toISOString(),a=this.kernelInstance.getComponentId(e),r=nn(a),o=(null===(n=s.boxForMeasurement)||void 0===n?void 0:n.size)||s.bounds;t({created:i,lastAccess:i,configuration:this.kernelInstance.getSerializedConfiguration(e),configurationHash:this.kernelInstance.getHashOfConfiguration(e),parts:JSON.stringify(this.kernelInstance.getPartList(e)),rootComponentId:a,width:o.x,height:o.z,depth:o.y,catalog:r,orderable:!1,requestable:!1})})}loadComponent(e,t,n){this._rapiAccess.getComponent(t.componentId).then(s=>{var i;let a=s.configuration;a||(a="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[t.componentId],message:t.componentId+" has no configuration"})),this._kernelIo.setMeta({componentId:t.componentId}),this._kernelInstance.loadComponent(e,a,t,n),this._flushSubComponentsWaiters()},s=>{var i;this._kernelInstance.loadComponent(e,"error",t,n),this.onLoadComponentError(s,t.componentId),null===(i=this._configuratorUiCallbacks)||void 0===i||i.onError(new Error(`Component with id "${t.componentId}" can not be loaded. "${s}"`)),this._flushSubComponentsWaiters()})}loadSubComponent(e,t,n){if(this._shouldWait){let s=this._subComponentsWaiters.get(n);s||this._subComponentsWaiters.set(n,[]),s=this._subComponentsWaiters.get(n),s.push({parentId:e,partId:t}),this._subComponentsWaiters.set(n,s)}else this._rapiAccess.getComponent(n).then(s=>{var i;let a=s.configuration;a||(a="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[n],message:"SubComponent "+n+" has no configuration"})),this._kernelIo.setMeta({componentId:n,parentId:e}),this._kernelInstance.loadedSubComponent(e,t,n,a)})}async loadItemConfigurations(e,t){let n=Array.isArray(t)?t:[t];if(this._requestedItemIds.push(...n),await nt(0),!this._requestedItemIds.length)return;const s=[...this._requestedItemIds];this._requestedItemIds=[],(await this._rapiAccess.getItems(s)).forEach(t=>{this._kernelInstance.loadedItemConfiguration(e,t.id,t.configuration)})}requestDeleteComponent(e){var t,n;e&&((null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)?this._kernelInstance.deletePlanComponent(e):this._kernelInstance.deleteComponent(e))}dockComponentWithPosition(e,t,n,s,i){var a;this._kernelInstance.dockComponentWithPosition(n,s,e,t,i);const r=this._kernelInstance.getComponentId(n),o=this._kernelInstance.getComponentId(e);null===(a=this._configuratorUiCallbacks)||void 0===a||a.onUserInitiatedDockDone(r,s,o,t,i)}Editor3dAddBakedMesh(e,t,n,s,i,a,r,o){this._configuratorKernelCallbackListener.forEach(l=>l.Editor3dAddBakedMesh(e,t,n,s,i,a,r,o))}Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c){this._configuratorKernelCallbackListener.forEach(u=>u.Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c))}Editor3ChangedNamedMesh(e,t,n,s,i,a,r){this._configuratorKernelCallbackListener.forEach(o=>o.Editor3ChangedNamedMesh(e,t,n,s,i,a,r))}Editor3dRemoveNamedMesh(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dRemoveNamedMesh(e,t))}Editor3dBeginConstruction(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dBeginConstruction(e,t))}Editor3dEndConstruction(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dEndConstruction(e))}Editor3dComponentCreated(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentCreated(e,t,n,s,i))}Editor3dComponentDocked(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentDocked(e,t,n,s,i))}Editor3dGeometryReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryReady(e)),this.requestPlanComponentConstruction(e),this._configuratorUiCallbacks.onGeometryReady(e)}Editor3dGeometryNotReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryNotReady(e)),this._configuratorUiCallbacks.onGeometryNotReady(e)}componentDeleted(e){this._configuratorKernelCallbackListener.forEach(t=>t.componentDeleted(e))}componentMetaUpdated(e){let t=this._kernelInstance.getComponent(e);this._configuratorKernelCallbackListener.forEach(e=>e.componentMetaUpdated(t))}sceneCleared(){this._configuratorKernelCallbackListener.forEach(e=>e.sceneCleared())}requestMaterialsInGroup(e){(Array.isArray(e)?e:[e]).forEach(e=>{-1===this._cachedGroupIds.indexOf(e)&&this._cachedGroupIds.push(e)}),this._waitingForGroups||(this._waitingForGroups=!0,Lr.waitFor(4).then(()=>{this._rapiAccess.getMaterialsByGroup(this._cachedGroupIds).then(e=>{let t=[];e.forEach(e=>{const n=[];e.materials.forEach(e=>n.push(e.id));const s=e.legacyId||e.id;e.legacyId||console.warn("Material group has no legacy id, please check content why this is the case"),t.push({group:s,materials:n})}),t.length&&this._kernelInstance.setMaterialsInGroup(t),this._cachedGroupIds=[]},e=>{var t;console.error(e),null===(t=this._configuratorUiCallbacks)||void 0===t||t.onError(new Error(`Material group with ids "${this._cachedGroupIds.join(",")}" can not be loaded. "${e}"`)),this._cachedGroupIds=[]})}))}requestPlanComponentConstruction(e,t=!0){t?this._kernelInstance.requestDeltaPlanComponentConstruction(e):this._kernelInstance.requestPlanComponentConstruction(e)}addConfiguratorListener(e){this._configuratorKernelCallbackListener.add(e)}removeConfiguratorListener(e){this._configuratorKernelCallbackListener.delete(e)}cleanUpCallbacks(){"function"==typeof this._kernelContainer.unregisterConfiguratorCallback&&this._kernelContainer.unregisterConfiguratorCallback(this)}async requestMaterialProperties(e){let t=Array.isArray(e)?e:[e];if(this._requestedMaterialIds.push(...t),await nt(0),!this._requestedMaterialIds.length)return;const n=[...this._requestedMaterialIds];this._requestedMaterialIds=[];const s=await this._rapiAccess.getMaterials(n);let i=[];s.forEach(e=>{const t=new this._kernelContainer.StringStringMap,n=e.properties||{};for(let e in n)n.hasOwnProperty(e)&&t.set(e,n[e]);t.size()&&i.push({id:e.id,properties:t})}),i.length&&this._kernelInstance.setMaterialProperties(i)}registerCallbacks(){this._kernelContainer.registerConfiguratorCallback(this)}pause(){this.cleanUpCallbacks()}resume(){this.cleanUpCallbacks(),this.registerCallbacks()}destroy(){}_handleCortoMesh(e,t,n){var s;try{this._kernelInstance.addMeshCorto(t,n,new Uint8Array(e))}catch(e){console.error(e),null===(s=this._configuratorUiCallbacks)||void 0===s||s.onMemoryCorruption()}}_handleInvalidMesh(e,t){try{this._kernelInstance.setExternalMeshInvalid(e,t)}catch(e){console.error(e)}}calcPartsPriceSum(e){return this._calcPrice(e)}_calcPrice(e){const t=new Map;e||(e=this._kernelInstance.getFullPartList());const n=!!e&&!!e.fullList&&!!e.fullList.length;if(this._initData.useRoomlePrice&&n){const n=e.fullList[0].currencySymbol,s=e.fullList.reduce((e,t)=>e+(t.count?t.count:0)*(t.price?t.price:0),0),i=it(s,2);return this._configuratorUiCallbacks.onUpdatePrice(n,i),Promise.resolve({totalSum:i,partMap:t})}if(this._initData.usePriceService&&n){const n=e.fullList.reduce((e,n)=>{const s=sn(n);return s&&(t.set(s,n),e.push(s)),e},[]);return new Promise((s,i)=>{this._rapiAccess.getPrices(n).then(n=>{if(!n.length)return i(new Error("prices are empty"));let a=0;const r=st(n,"priceId");for(const t of e.fullList){const e=sn(t);if(!r.has(e)){console.warn("PriceId: "+e+" has no corresponding kernel-part");continue}const{price:n,currencySymbol:s}=r.get(e);t.price=n,t.currencySymbol=s,a+=n*t.count}return a=it(a,2),this._configuratorUiCallbacks.onUpdatePrice(n[0].currencySymbol,a),s({totalSum:a,partMap:t})},e=>{console.error(e),i(e)})})}return Promise.resolve({totalSum:0,partMap:t})}async addUiDataAndPriceToPartList(e,t){const{fullList:n,originPart:s}=e,i=e.perMainComponent;let a;this.addUiDataToPartList(n,t);try{const t=await this._calcPrice(e);a=t.partMap}catch(e){console.error(e),a=new Map}const r=this._initData.usePriceService||this._initData.useRoomlePrice,o=e=>{r||(e.price=null,e.currencySymbol=null);const t=sn(e);if(!t)return;if(!a.has(t))return;const{price:n,currencySymbol:s}=a.get(t);"number"==typeof n&&(e.price=n,e.currencySymbol=s)};return n.forEach(o),i.forEach(({fullList:e,perMainComponent:n})=>{n.length>0&&console.error("Not implemented! perMainComponent is deeper than one level"),this.addUiDataToPartList(e,t),e.forEach(o)}),{fullList:n,perMainComponent:i,originPart:s}}addUiDataToPartList(e,t){const n=[];return e.forEach(e=>{const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label),e.parameters.forEach(e=>{if(this._unitFormatter.formatPartListParameter(e),Br(e)){const t=this._rapiAccess.peekMaterial(e.value);t?e.valueLabel=t.label||t.name||e.value:-1===n.indexOf(e.value)&&n.push(e.value)}})}),n.length&&this._rapiAccess.getMaterials(n).then(e=>{const n=this._lastPartListHash!==t;Array.isArray(e)&&e.length&&n&&(this._lastPartListHash=t,this.requestPartListAndUpdatePricesOfParts())}),e}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const s=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(s,btoa(e))}}on([hn],Vr.prototype,"_rapiAccess",void 0),on([hn],Vr.prototype,"_scriptLoader",void 0),on([hn],Vr.prototype,"_kernelIo",void 0),on([hn],Vr.prototype,"_dataSyncer",void 0),on([hn],Vr.prototype,"_lifeCycleManager",void 0),on([hn],Vr.prototype,"_configuratorUiCallbacks",void 0),on([hn],Vr.prototype,"_globalCallback",void 0),on([hn],Vr.prototype,"_initData",void 0),on([hn],Vr.prototype,"_unitFormatter",void 0),on([hn],Vr.prototype,"_configuratorContext",void 0),on([hn],Vr.prototype,"_globalInitData",void 0);const{APP:Hr}=Sr,{RAPI:Wr}=Hr,Kr=Wr.headers,qr=Wr.itemHeaders,Xr=Kr.token,Yr=e("av",e=>e.startsWith("ps_")),Qr=at();let Zr=new Map,Jr=new Map,$r=new Map,eo=new Map,to=new Map,no=new Map,so=new Map,io=new Map,ao=new Map;const ro=e=>Zr.get(e)||Zr.get(Qr+e),oo=e=>e&&e.tags&&e.tags.length,lo=e=>!oo(e)&&e.group;class ho{constructor(e){this._itemLoaded=!1,this._currentToken=null,this._creator_=e,window.addEventListener("online",this._flushOfflineQueue.bind(this))}getPreloadForItem(e){return this._getPreload(e,!0)}getPreloadForConfiguration(e){return this._getPreload(e,!1)}_getPreload(e,t){return new Promise((n,s)=>{if(!navigator.onLine)return n();if(this._dataSyncer.getIsCatalogSynced(nn(e)))return n();if(so.get(e))return n();const i=t?"?itemId=":"?configurationId=";this._get("/preloads/components/"+i+e,"preloads/components").then(t=>{if(so.get(e))return n();t.forEach(e=>{this._prepareData(e,"components")}),so.set(e,!0),n()},s)})}changeUseOfHDGeometry(){const e=eo.get("components");so.clear(),no.clear(),e&&eo.delete("components")}getHSCPackage(e){return new Promise((t,n)=>{if(no.get(e))return t();this._get("/catalogs/"+e+"/package","package").then(n=>{if(no.get(e))return t(n);n.components.forEach(e=>{this._prepareData(e,"components")}),n.materials.forEach(e=>{this._prepareData(e,"materials"),this._prepareGroups(e)}),n.textures.forEach(e=>{this._prepareData(e,"textures")}),no.set(e,!0),t(n)},n)})}getComponent(e){return this._getById(e,"components")}getConfiguration(e){return this._getById(e,"configurations")}getConfigurations(e){return this._getByIds(e,"configurations")}getItem(e){return this._getById(e,"items",{additionalHeaders:qr})}getComponents(e){return this._getByIds(e,"components")}getItems(e){return this._getByIds(e,"items",{additionalHeaders:qr})}getTag(e){return this._getById(e,"tags")}getTags(e){return this._getByIds(e,"tags")}getTexture(e){return this._getById(e,"textures")}getCatalog(e){return this._getById(e,"catalogs")}getMesh(e,t="crt",n=50){return this._getById(e,"meshes",{pathSuffix:"/data?format="+t+"&targetQuality="+n.toString()})}getMeshesOfCatalog(e){return new Promise((t,n)=>{const s=to.get(e);s?t(s):this._get("/meshes?catalog="+e,"catalogMeshes").then(n=>{to.set(e,n),t(n)},n)})}getTexturesOf(e){return this._getRelationData(e,{rapiPath:"textures"})}getItemsOf(e){return this._getRelationData(e,{rapiPath:"items"})}async getMaterialsOf(e){return(await this._getRelationData(e,{rapiPath:"materials"},{embed:["textures"]})).filter(e=>e.active)}getComponentsOf(e){return this._getRelationData(e,{rapiPath:"components"})}getAdditionalContentsOfItems(e){const t=[],n=[],s=[];return e.forEach(e=>{const i=e.id.toString(),a=Jr.get(i);a?n.push(...a):t.push(i),s.push(i)}),new Promise((e,i)=>{0!==t.length?this._getByIdsPackets(t,"itemAdditionalContents",{filterKey:"itemIds"}).then(t=>{t.forEach(e=>{let t=Jr.get(e.itemId);t||(t=[]);for(let n=0,s=t.length;n<s;n++)if(t[n].id===e.id)return;t.push(e),Jr.set(e.itemId,t)}),e(rt(s,[...t,...n],"itemId"))},i):e(n)})}getMaterial(e){return this._getById(e,"materials",{embed:["textures"]})}peekMaterial(e){return this._peekData(e,"materials")}peekComponent(e){return this._peekData(e,"components")}peekItem(e){return this._peekData(e,"items")}peekConfiguration(e){return this._peekData(e,"configurations")}async getMaterials(e){return(await this._getByIds(e,"materials",{embed:["textures"]})).filter(e=>e.active)}getPlan(e){return this._getById(e,"plans")}getPlanSnapshot(e){return this._getById(e,"planSnapshots")}static clearCaches(){Zr=new Map,$r=new Map,eo=new Map,no=new Map,so=new Map,io=new Map,Jr=new Map}cleanUp(){ho.clearCaches()}getMaterialsByGroup(e){const t=e.slice(),n=[];let s=t.length;for(let e=0;e<s;e++){const i=ro(t[e]);if(i){const a=i.length;for(let e=0;e<a;e++){const t=this._getCache("materials").get(i[e]);n.push(t)}t.splice(e,1),s--,e--}}return new Promise((e,s)=>{0!==t.length&&navigator.onLine?this._getByIdsPackets(t,"materials",{filterKey:"groups",embed:["textures"]}).then(t=>{e(this.combineMaterialsToGroups([...t,...n]))},s):e(this.combineMaterialsToGroups(n))})}_flushOfflineQueue(){return new Promise((e,t)=>{const n=this._localStorage.getItem("hsc_configurations_offline_queue_v1"),s=[];for(let e in n)if(n.hasOwnProperty(e)){const t=n[e];s.push(new Promise((e,n)=>{this.saveConfiguration(t.data).then(s=>{const i=[];t.perspectiveImage&&!s.perspectiveImage&&i.push(this.savePerspectiveImage(s,t.perspectiveImage)),t.topImage&&!s.topImage&&i.push(this.savePerspectiveImage(s,t.topImage)),Promise.all(i).then(e,n)},n)}))}Promise.all(s).then(()=>{this._localStorage.setItem("hsc_configurations_offline_queue_v1",{}),e()},t)})}_setQueuedConfiguration(e,t={}){const n=e.configurationHash,{perspectiveImage:s,topImage:i}=t;let a=this._localStorage.getItem("hsc_configurations_offline_queue_v1")||{},r=a[n]||{};r.data=e,r.perspectiveImage=s,r.topImage=i,a[n]=r,this._localStorage.setItem("hsc_configurations_offline_queue_v1",a)}async saveConfiguration(e){return navigator.onLine?await this._save("/configurations",{configuration:e},"configurations",{accept:"application/json",contentType:"application/json; charset=UTF-8"}):(e.perspectiveImage=null,e.topImage=null,this._setQueuedConfiguration(e),this._markConfigurationAsLocally(e),Promise.resolve(e))}saveTopImage(e,t){return this._saveConfigurationImage(e,t,"topImage")}savePerspectiveImage(e,t){return this._saveConfigurationImage(e,t,"perspectiveImage")}savePlanSnapshotTopImage(e,t){return this._savePlanSnapshotImage(e,t,"topImage")}savePlanSnapshotPerspectiveImage(e,t){return this._savePlanSnapshotImage(e,t,"perspectiveImage")}getShortUrl(e,t){return new Promise((n,s)=>this._fetchJson("/shortIds","shortIds",{method:"POST",resolve:n,reject:s,data:JSON.stringify({shortId:{type:t,referencedId:e}}),accept:"application/json",contentType:"application/json; charset=UTF-8"}))}_peekData(e,t){const n=eo.get(t);return n&&n.get(e)||null}_saveConfigurationImage(e,t,n){if(!navigator.onLine){const s={};return s[n]=t,this._setQueuedConfiguration(e,s),this._markConfigurationAsLocally(e),e[n]=t.image,Promise.resolve(e)}const s=this._formDataUtil.create(t.image,e.configurationHash,Qt.PNG,n);return this._save("/configurations/"+e.id+"/"+n,s,"configurations",{accept:"application/json"})}_savePlanSnapshotImage(e,t,n){const s=this._formDataUtil.create(t.image,e.id,Qt.PNG,"file");return s.append("type",n),this._save("/planSnapshots/"+e.id,s,"planSnapshots",{accept:"application/json",method:"PUT"})}_markConfigurationAsLocally(e){e.isLocally=!0,e.id=e.configurationHash}_save(e,t,n,s={}){const i=t instanceof FormData?t:JSON.stringify(t);return new Promise((t,a)=>{const r={method:s.method||"POST",data:i,resolve:t,reject:a};s.contentType&&(r.contentType=s.contentType),s.accept&&(r.accept=s.accept),this._fetchJson(e,n,r)})}combineMaterialsToGroups(e){return new Promise((t,n)=>{const s=new Map,i={id:null,label:null,materials:[]},a=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.tags&&n.tags.length?n.tags.map(e=>({isTag:!0,id:e})):[];n.group&&r.push({isTag:!1,id:Qr+n.group,legacyId:n.group}),r.length||r.push({isTag:!1,id:null}),n.tags&&n.tags.length&&n.tags.forEach(e=>-1===a.indexOf(e)?a.push(e):null),r.forEach(({isTag:e,id:t,legacyId:a})=>{const r=n.id;let o=t?ro(t):[];o||(Zr.set(t,[]),o=ro(t)),-1===o.indexOf(r.toString())&&o.push(r.toString());const l=oo(n),h=l&&e,d=lo(n);if(h||d&&!e||!l&&!d&&!t){let e=t?s.get(t):i;e||(s.set(t,{id:t,label:n.groupLabel,legacyId:a,materials:[]}),e=s.get(t)),e.materials.push(n)}})}const r=i.materials.length?[i]:[];this.getTags(a).then(e=>{const n=e.reduce((e,t)=>(e[t.id]=t,e),{});return s.forEach((e,t)=>{r.push({id:t,label:n[t]?n[t].label:e.label,materials:e.materials,legacyId:e.legacyId,sort:n[t]?n[t].sort:void 0})}),t(r)},n)})}_getByIds(e,t,n={}){const s=this._getCache(t),i=this._getErrorCache(t),a=[],r=[...new Set(e)];let o=r.length;if(s&&s.size){const e=(new Date).getTime();for(let t=0;t<o;t++){const n=r[t],l=s.get(n),h=i.get(n);let d=!1;null!=l?(a.push(l),d=!0):d=void 0!==h&&(e-h.timestamp<6e4||!1===navigator.onLine),d&&(r.splice(t,1),o--,t--)}}return new Promise((s,i)=>{0!==r.length&&navigator.onLine?this._getByIdsPackets(r,t,n).then(t=>{s(rt(e,[...t,...a]))},i):s(a)})}_getByIdsPackets(e,t,n={}){e.sort();const s=n.filterKey||"ids";let i,a="/"+t+"/",r="?",o=[];const l=e.length;if(!l)return new Promise(e=>e([]));let h=!0,d=[];for(i=0;i<l;i++){h=!1;const n=e[i],l=r+s+"[]="+n,c=l.length+a.length;d.push(n),r="&",c<=1500?a+=l:(c>1500&&(d.pop(),i--),o.push({url:a,ids:d}),h=!0,a="/"+t+"/",r="?",d=[])}h||o.push({url:a,ids:d});const c=[];return o.forEach(e=>c.push(this._getByIdsSingle(e.ids,e.url,t,n))),new Promise((e,t)=>{Promise.all(c).then(t=>{const n=[];t.length&&t.forEach(e=>n.push(...e)),e(n)},t)})}_getByIdsSingle(e,t,n,s={}){return e.sort(),new Promise((i,a)=>{this._get(t,n,s).then(t=>{for(let n=0,i=t.length;n<i;n++){const i=s&&s.cacheKey?t[n][s.cacheKey]:t[n].id,a=e.indexOf(i.toString());-1!==a&&e.splice(a,1)}const a=e.length;if(a){const t=this._getCache(n),s=this._getErrorCache(n),i=(new Date).getTime();for(let n=0;n<a;n++)s.set(e[n],{code:0,timestamp:i}),t.delete(e[n]);this._errorHandler.dispatch(2,[n,e.map(e=>'"'+e+'"').join(",")])}i(t)},a)})}_getById(e,t,n={}){if(!e||""===e||"string"!=typeof e)return console.error("no id passed to _getById"),Promise.reject(new Error("no id passed to _getById"));const s=this._getCache(t).get(e);if(s)return new Promise(e=>e(s));if(!navigator.onLine)return Promise.reject("Nothing cached but tried to fetch in offline mode");const i={...n,id:e},a=n.pathSuffix||"";return this._get("/"+t+"/"+e+a,t,i)}_get(e,t,n={}){const s=Ir.useHDGeometry?"includeGeometryHD=true":"";let i=-1===e.indexOf("?")?"?":"&";return""!==s&&(e+=i+s),n.embed&&Array.isArray(n.embed)&&n.embed.forEach(t=>{e+=i+"embed"+(t[0].toUpperCase()+t.substr(1))+"=true",i="&"}),new Promise((s,i)=>{const a=io.get(e);Array.isArray(a)&&a.length>0?a.push({resolve:s,reject:i}):(io.set(e,[{resolve:s,reject:i}]),this._fetchJson(e,t,n))})}async _fetchJson(e,t,n={}){try{const s=await this._fetch(e,n),i=await ot(s);return await this._handleJson(e,t,n)(i)}catch(t){this._handleError(e,n)(t)}}async _fetch(e,t){const n={method:t.method?t.method:"GET",headers:this._createHeaders(t),mode:"cors",cache:"default"};t.data&&(n.body=t.data);let s=Wr.server;const i=this._globalInitData.overrideRapi;i&&(s="live"===i?Wr.liveServer:Wr.testServer),(this._globalInitData.customApiUrl||""===this._globalInitData.customApiUrl)&&(s=this._globalInitData.customApiUrl);const a=new Request(s+e,n);this._globalCallback.onNetworkRequest(e,n,t);const r=await this._globalCallback.onCheckExternalCache(e,n);return r?{headers:{get:()=>"application/json"},json:()=>Promise.resolve(r)}:this._networkLayer.fetch(a,{},{checkResponse:e=>this._globalCallback.onValidateNetworkResponse("rapi-access",e)})}_createHeaders(e={}){const t={...Kr};this._globalInitData.overrideTenant&&(t.currentTenant=this._globalInitData.overrideTenant),this._globalInitData.overrideCountry&&(t.country=this._globalInitData.overrideCountry);const n=this._globalInitData.locale||"en";t.language=n,t.locale=n;const{contentType:s,accept:i,additionalHeaders:a,data:r}=e;if(s&&(t["content-type"]=e.contentType),i&&(t.accept=e.accept),a)for(let e in a)a.hasOwnProperty(e)&&(t[e]=a[e]);this._globalInitData.configuratorId&&(t.configurator=this._globalInitData.configuratorId);const o=this._currentToken||Xr;t.token="03-"+window.btoa((new Date).toISOString()+";"+o+";"+Kr.apiKey);const l=new Headers(t);return r instanceof FormData&&l.delete("content-type"),l}_handleJson(e,t,n={}){return async s=>{const i=await this._globalCallback.onApiJsonReceived(e,t,s);null!=i&&(s=i);let a=null,r=null;"number"==typeof s&&(a=s);for(let e in s)"meta"!==e&&s.hasOwnProperty(e)&&(a=s[e],r=e);if("error"===r)return this._handleError(e,n)(new Error(JSON.stringify(a)));if(!a)throw new TypeError("RAPI returned empty JSON");if(Array.isArray(a))for(let e=0,s=a.length;e<s;e++)this._prepareData(a[e],t,n),this._prepareEmbeddedData(a[e],t,n);else this._prepareData(a,t,n),this._prepareEmbeddedData(a,t,n);n.resolve?n.resolve(a):this._notifyWaiters(e,null,a)}}_prepareEmbeddedData(e,t,n={}){n.embed&&Array.isArray(n.embed)&&n.embed.forEach(s=>{const i=e[s.slice(0,-1)+"Objects"];if(Array.isArray(i)){for(let e=0,t=i.length;e<t;e++)this._prepareData(i[e],s,n);this._prepareRelationalData(t,s,e.id,i)}else i&&(this._prepareData(i,s,n),this._prepareRelationalData(t,s,e.id,[i]))})}_getCache(e){return this._getCacheFrom(e,eo)}_getErrorCache(e){return this._getCacheFrom(e,ao)}_getCacheFrom(e,t){let n=t.get(e);return n||(t.set(e,new Map),n=t.get(e)),n}_setCache(e,t,n){n.set(e.toString(),t)}_prepareData(e,t,n=null){let s=this._getCache(t);const i=n&&n.cacheKey?e[n.cacheKey]:e.id;if(i||n&&n.id||"tenants/me"===t)if("tenants/me"!==t){{const t=i||n.id;this._setCache(t,e,s)}e.__rapi_path__=t}else this._setCache("0",e,s);else"shortIds"!==t&&console.error("Can not cache because there is no ID!")}_getRelationsCacheFor(e,t,n){let s=$r.get(t);if(!s){const i=new Map,a=new Map;a.set(n,void 0),i.set(e,a),$r.set(t,i),s=$r.get(t)}let i=s.get(e);if(!i){const t=new Map;t.set(n,void 0),s.set(e,t),i=s.get(e)}return i.get(n)}_prepareGroups(e){const t=e.group,n=e.id;let s=ro(t);s||(Zr.set(t,[]),s=ro(t)),-1===s.indexOf(n.toString())&&s.push(n.toString())}_handleError(e,t={}){return n=>{navigator.onLine?(n.rmlErrorCode=1,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(1,[n])):(n.rmlErrorCode=0,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(0,[n])),t.reject?t.reject(n):this._notifyWaiters(e,n,null)}}_getRelationData(e,t,n={}){const s=e.id;if(!s)return Promise.resolve([]);const i=e.__rapi_path__,a=t.rapiPath;let r=this._getCache(a),o=this._getRelationsCacheFor(s.toString(),i,a),l=[];return o?(o.forEach(e=>l.push(r.get(e))),new Promise(e=>e(l))):navigator.onLine?new Promise((e,t)=>{this._get("/"+i+"/"+s+"/"+a,a,n).then(t=>{this._prepareRelationalData(i,a,s,t),e(t)},t)}):Promise.resolve([])}_prepareRelationalData(e,t,n,s){$r.has(e)||$r.set(e,new Map);let i=$r.get(e);const a=n.toString();i.has(a)||i.set(a,new Map);let r=i.get(a),o=this._getCache(t),l=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],n=t.id.toString();l.push(n),o.set(n,t)}r.set(t,l)}_notifyWaiters(e,t,n){const s=io.get(e);if(s&&s.length){for(let e=0,i=s.length;e<i;e++)t?s[e].reject(t):s[e].resolve(n);io.delete(e)}}_tenantMe(){return new Promise((e,t)=>{const n=this._getCache("tenants/me"),s=this._globalInitData.overrideTenant?this._globalInitData.overrideTenant:n.get("0");if(s)return e(s);this._fetchJson("/tenants/me","tenants/me",{resolve:t=>e(t),reject:t})})}async getTenant(e){return e||(e=await this._tenantMe()),this._getById(e.toString(),"tenants")}getCurrentSkin(){return this._tenantMe().then(e=>this._getById(e.toString(),"tenants").then(e=>this._getById(e.skin.toString(),"skins")))}getPrices(e){return this._getByIds(e,"prices",{filterKey:"priceIds",cacheKey:"priceId"})}async getConfiguratorSettings(e){const t=await this._getById(e,"configurators");return t.allowedHosts||(t.allowedHosts=[]),t.allowedHosts&&!Array.isArray(t.allowedHosts)&&(t.allowedHosts=t.allowedHosts.split(" ")),t}sendUserAction(e){return this._save("/userActions",{userAction:e},"userActions",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}_share(e,t,n,s){const i="/"+s+"/"+e+"/shares",a=new FormData;return a.append("email",t),a.append("type",n.toString()),new Promise((e,t)=>{const n={method:"POST",data:a,resolve:e,reject:t,accept:"application/json",contentType:"application/json; charset=UTF-8"};this._fetch(i,n).then(n.resolve,n.reject)})}shareConfiguration(e,t,n){return this._share(e,t,n,"configurations")}sharePlanSnapshot(e,t,n){return this._share(e,t,n,"planSnapshots")}export3D(e,t,n,s={}){const i="/"+(Yr(e)?"planSnapshots":"configurations")+"/"+e+"/3d-exports",a={formats:[{file_format:n,pack_external_data:!0,...s}]},r=JSON.stringify(a),o=new FormData;return o.append("email",t),o.append("settings",r),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t};this._fetch(i,n).then(n.resolve,n.reject)})}async trackView(e){if(this._itemLoaded||(t=en())&&(tn.includes(t)||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")||t.endsWith("codesandbox.io")||t.endsWith("stackblitz.com")||/^(admin.*.roomle.com)$/.test(t)))return;var t;const{configuratorId:n}=this._globalInitData,s={module:3,action:1,actionId:e,actionLabel:n};await this.sendUserAction(s),this._itemLoaded=!0}signinUser(e,t){return new Promise((n,s)=>{const i={method:"POST",accept:"application/json",contentType:"application/json; charset=UTF-8",data:JSON.stringify({identification:e,passwordMD5:t}),cacheKey:"token",resolve:n,reject:s};this._fetchJson("/auth/signin","auth",i)})}async signoutUser(e){const t=this._currentToken;t!==e&&this.setCurrentToken(e),await this._fetch("/auth/signout",{}),t&&t!==e?this.setCurrentToken(t):this.removeCurrentToken()}async savePlan(e){const t=e.id?"/plans/"+e.id:"/plans";return this._save(t,{plan:e},"plans",{method:e.id?"PUT":"POST",accept:"application/json",contentType:"application/json; charset=UTF-8"})}async savePlanSnapshot(e){return this._save("/planSnapshots",{planSnapshot:e},"planSnapshots",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}setCurrentToken(e){this._currentToken=e}removeCurrentToken(){this._currentToken=null}createNewPlan(){return{name:"",description:"",changeDate:(new Date).toISOString(),created:(new Date).toISOString(),draftId:null,thumbnail:"data:image/png;base64,missing",planObjects:null,active:!0,open:0,planDirectory:0,changed:0,version:2,floorLevel:0,visibility:9,user:null,tenant:null,assets:[],parent:null,setting:null}}updateCache(e,t){const n=this._getCache(e);this._setCache(t.id,t,n)}}e("R",ho),on([hn],ho.prototype,"_formDataUtil",void 0),on([hn],ho.prototype,"_errorHandler",void 0),on([hn],ho.prototype,"_dataSyncer",void 0),on([hn],ho.prototype,"_networkLayer",void 0),on([hn],ho.prototype,"_localStorage",void 0),on([hn],ho.prototype,"_globalInitData",void 0),on([hn],ho.prototype,"_globalCallback",void 0);const co=e("p",1500),uo=e("o",5);function po(){class e extends A{static _generateOutline(e,t){let n=new V(new ht(e),new dt({color:"#000000",dashSize:.03,gapSize:.01,linewidth:1}));return n.translateOnAxis(t,1),n.userData.ignoreComponentRaycast=!0,n}static cloneDockLine(e,t){let n=new V(e.geometry,e.material);return n.translateOnAxis(t.getCenter(new r),1),n.name="dockline",n.layers.set(5),n.userData.ignoreComponentRaycast=!0,n}_setValues(e,t,n,s,i){e&&(this.runtimeId=e,this.name=e.toString()),t&&(this.roomlePosition=Object.assign({},t)),n&&(this.roomleRotation=Object.assign({},n)),s&&(this.parentObjectId=s),i&&(this.isRootComponent=i)}constructor(e,t,n,s,i){super(),this._selected=!1,this.isChildPlanObject=!1,this.geometryChanged=!0,this.meshes=[],this.castShadow=!1,this.receiveShadow=!0,this._setValues(e,t,n,s,i)}get loadingMesh(){return this._loadingMesh}get boundingBoxMesh(){return this._boundingBoxMesh}get boundingBox(){return this._boundingBox}set roomlePosition(e){this._roomlePosition=e,e&&this.position.set(e.x/1e3,e.z/1e3,e.y/-1e3)}get roomlePosition(){return this._roomlePosition}set roomleRotation(e){this._roomleRotation=e,e&&this.rotation.set(e.x,e.z,-e.y)}get roomleRotation(){return this._roomleRotation}replaceMeshes(e){this.removeAllMeshes(),e.forEach(e=>{this.addMesh(new z(e.geometry,e.material))})}addMesh(e,t){e.renderOrder=2,e.userData.meshType=0,t&&e.applyMatrix4(Cs(t)),this.add(e),this.meshes.push(e)}getMeshById(e){return this.meshes.find(t=>t.userData.meshId===e)}removeMeshById(e){const t=this.getMeshById(e);t?this.removeMesh(t):console.warn("Could not remove mesh with id "+e,this.runtimeId,this.meshes)}removeMesh(e){const t=this.meshes.indexOf(e);this.remove(e),na(e),t<0||this.meshes.splice(t,1)}removeAllMeshes(e=!0){this.meshes.forEach(t=>{this.remove(t),e&&na(t)}),this.meshes=[],this._removeLoadingMesh(),this.remove(this._boundingBoxMesh),na(this._boundingBoxMesh),this._boundingBoxMesh=null}_hideAllMeshes(){this.meshes.forEach(e=>e.visible=!1)}_showAllMeshes(){this.meshes.forEach(e=>e.visible=!0)}select(){this._selected=!0}loading(){if(!this._kernelBoundingBox)return void console.warn("Bounding box (box for measurements) for component "+this.runtimeId+" not set, can not show external mesh loading box!");this._removeLoadingMesh(),this._hideAllMeshes();const{x:e,y:t,z:n}=this._kernelBoundingBox.getSize(new r);let s=new $e(e,t,n);this._loadingMesh=new z(s,Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#DDDDDD")})),this._loadingMesh.name="loading mesh",this._loadingMesh.receiveShadow=!1,this._loadingMesh.castShadow=!1,this._loadingMesh.layers.set(5),this._loadingMesh.translateOnAxis(this._kernelBoundingBox.getCenter(new r),1),this._loadingMesh.renderOrder=3,this.add(this._loadingMesh)}_removeLoadingMesh(){this._loadingMesh&&(this.remove(this._loadingMesh),na(this._loadingMesh),this._loadingMesh=null)}loadingFinished(){this._removeLoadingMesh(),this._showAllMeshes()}deselect(){this._selected=!1}hoverOn(){lt("pointer")}hoverOff(){lt("default")}removeFromParent(){return this.parent&&(this.parent.remove(this),this.removeAllMeshes()),this}computeBoundingBox(t,n=!1){if(this._boundingBoxMesh&&this.remove(this._boundingBoxMesh),!n&&t&&0===t.size.x&&0===t.size.y&&0===t.size.z)return;let s;if(!t||n){this._boundingBox=new ge;let e=new r;this.meshes.forEach(t=>{if(t.geometry instanceof c){let n=t.geometry.attributes.position;if(void 0!==n)for(let s=0,i=n.count;s<i;s++)e.fromBufferAttribute(n,s).applyMatrix4(t.matrix),this._boundingBox.expandByPoint(e)}}),this._kernelBoundingBox=this._boundingBox.clone();let t=this._boundingBox.max.x-this._boundingBox.min.x,n=this._boundingBox.max.y-this._boundingBox.min.y,i=this._boundingBox.max.z-this._boundingBox.min.z;s=new $e(t,n,i)}else{this._kernelBoundingBox=Li(t),this._boundingBox=this._kernelBoundingBox.clone();let{x:e,y:n,z:i}=this._boundingBox.getSize(new r);s=new $e(e,n,i)}this._boundingBoxMesh=new z(s,Oi.createMeshStandardMaterial({color:"#FFFFFF",transparent:!0,opacity:0,polygonOffset:!0,polygonOffsetFactor:-1,visible:!1})),this._boundingBoxMesh.name="bounding box mesh";let i=this._boundingBox.getCenter(new r);this._boundingBoxMesh.position.add(i),this._boundingBoxMesh.layers.set(5),this._boundingBoxMesh.renderOrder=3,this._boundingBoxMesh.castShadow=!1,this._boundingBoxMesh.receiveShadow=!1,this.add(this._boundingBoxMesh),this._dockline=e._generateOutline(s,i),this._dockline.name="bounding box outline",this._dockline.layers.set(5),this._selected&&this.add(this._dockline)}recursiveMeshes(){let t=this.meshes.slice();return this.children.forEach(n=>{n instanceof e&&t.push(...n.recursiveMeshes())}),t}isChild(t){let n=!1;return this.children.forEach(s=>{s instanceof e&&!n&&(n=s.runtimeId===t||s.isChild(t))}),n}getKernelPosition(e){let t=this.parent.localToWorld(this.position);return Ss(e.worldToLocal(t))}}class t extends e{constructor(e,t){super(e,null,null,null,!1),this.glbUrl=t}}class n extends e{constructor(e,t,n,s,i,a){super(t,n,s,i,a),this._stringId=null,this.receivedPointAssociation=!1,this.castShadow=!1,this.receiveShadow=!1,this._creator_=e}get stringId(){return this._stringId?this._stringId:this.runtimeId.toString()}addMesh(e,t){super.addMesh(e,t),e.material instanceof N&&(e.material.opacity=.8,e.material.roughness=1,e.material.metalness=0,e.material.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)),e.renderOrder=1,e.castShadow=!1,e.receiveShadow=!1}startPulsating(){var e,t;if(null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.pulsePreview)for(const e of this.meshes){const t={opacity:.8},n={opacity:.3};new TWEEN.Tween(t).to(n,co).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.material.opacity=t.opacity}).yoyo(!0).repeat(uo).start()}}hoverOn(){this.remove(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.9,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),lt("pointer")}hoverOff(){this.add(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.8,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),lt("default")}clonePreview(t){const s=new n(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.isRootComponent);return s._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof z&&0===e.userData.meshType&&s.meshes.push(e.clone(!0))}),s.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),s.add(e)}),this._dockline&&(s._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(s._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(s._boundingBox=this._boundingBox.clone()),s}preparePreview(){this.add(this._dockline),this.add(this._boundingBoxMesh)}}on([hn],n.prototype,"_initData",void 0);class s extends n{constructor(e,t,n,s,i,a){super(e,t,n,s,i,null),this.lineSegments=[],a&&(this._stringId=this.runtimeId+"_has_additional_dock_point_copy")}set roomleLineFrom(e){this._roomleLineFrom=e,this.lineFrom=bs(e)}get roomleLineFrom(){return this._roomleLineFrom}set roomleLineTo(e){this._roomleLineTo=e;let t=bs(e);t.equals(this.lineFrom)&&(console.warn("lineFrom and lineTo are equal!"),t.add(new r(0,.01,0))),this.lineTo=t}get roomleLineTo(){return this._roomleLineTo}set roomlePositionFrom(e){this._roomlePositionFrom=e,this.positionFrom=bs(e)}get roomlePositionFrom(){return this._roomlePositionFrom}set roomlePositionTo(e){this._roomlePositionTo=e;let t=bs(e);t.equals(this.positionFrom)&&(console.warn("positionFrom and positionTo are equal!"),t.add(new r(0,.01,0))),this.positionTo=t}get roomlePositionTo(){return this._roomlePositionTo}addMesh(e,t){super.addMesh(e,t),e.visible=!1,e.renderOrder=3}hoverOn(){this._dockline.visible=!0,lt("pointer")}hoverOff(){this._dockline.visible=!1,lt("default")}preparePreview(){super.preparePreview(),this._dockline.visible=!1;let e=this.lineTo.clone(),t=this.lineFrom.clone();const n=(new r).subVectors(e,t);let s=n.length(),i=n.normalize();this._createLineMesh(.01,s,this.lineSegments);const a=(new M).setFromUnitVectors(new r(0,1,0),i);this.lineMesh.quaternion.multiply(a),this.lineMesh.renderOrder=1;let o=(new r).addVectors(e,t).multiplyScalar(.5);this.lineMesh.position.copy((new r).subVectors(o,this.position.clone())),this.add(this.lineMesh);let l=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation),h=null,d=0,c=Math.abs(i.x),u=Math.abs(i.y),p=Math.abs(i.z);c>=u&&c>=p?(h=new r(l.x,0,0),d=Math.sqrt(l.y*l.y+l.z*l.z)):u>=c&&u>=p?(h=new r(0,l.y,0),d=Math.sqrt(l.x*l.x+l.z*l.z)):p>=u&&p>=c&&(h=new r(0,0,l.z),d=Math.sqrt(l.y*l.y+l.x*l.x)),d=d>0?d:.01;let m=(new r).subVectors(this.positionTo.clone(),this.positionFrom.clone()).length()+h.length();this._createBoundingLineMesh(1.1*d,m,this.lineSegments);let g=this.positionTo.clone(),f=this.positionFrom.clone(),_=(new r).subVectors(g,f).normalize();const v=(new M).setFromUnitVectors(new r(0,1,0),_);this.boundingLineMesh.quaternion.multiply(v),this.boundingLineMesh.renderOrder=3;let w=(new r).addVectors(this.positionTo.clone(),this.positionFrom.clone()).multiplyScalar(.5).add(l);this.boundingLineMesh.position.copy((new r).subVectors(w,this.position.clone())),this.add(this.boundingLineMesh)}_createLineMesh(e,t,n){this.lineMesh=this._createPreviewMesh(e,t,n,16,Oi.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:.4})),this.lineMesh.name="line mesh"}_createBoundingLineMesh(e,t,n){this.boundingLineMesh=this._createPreviewMesh(e,t,n,32,Oi.createMeshStandardMaterial({color:"#ffffff",transparent:!0,opacity:0})),this.boundingLineMesh.name="bounding line mesh",this.boundingLineMesh.userData.ignoreComponentRaycast=!0,this.boundingLineMesh.layers.set(5)}_createPreviewMesh(e,t,n,s,i){let a;if(0===n.length)a=new ct(e,e,t,s,1);else{const i=[];for(const a of n){const n=a.to-a.from,r=(a.from+a.to)/2,o=new ct(e,e,n,s,1);o.translate(0,r-t/2,0),i.push(o)}a=vn(i,!1)}return new z(a,i)}clonePreviewLine(t){let n=new s(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.receivedPointAssociation);return n._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof z&&0===e.userData.meshType&&n.meshes.push(e.clone(!0))}),n.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),n.add(e)}),this._dockline&&(n._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(n._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(n._boundingBox=this._boundingBox.clone()),n}getPositionForIntersectionPoint(e){let t=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation),n=this.positionTo.clone().add(t),s=this.positionFrom.clone().add(t),i=new ut(s,n).closestPointToPoint(e,!0,new r);return(isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&i.copy(e),i.sub(t)}updatePreviewPosition(e){let t=this.getPositionForIntersectionPoint(e),n=this.parent.localToWorld(t);this._newPosition=this.worldToLocal(n);let s=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation);this._dockline.position.copy((new r).addVectors(this._newPosition,s)),this._dockline.rotation.copy(this.docklineRotation)}hideSelectionLine(){this._dockline.visible=!1}getKernelPosition(e){if(this._newPosition){let t=this.localToWorld(this._newPosition);return Ss(e.worldToLocal(t))}return super.getKernelPosition(e)}}class i extends Q{constructor(e,t,n,s,i,a,r){super(e,t,n,s,i,a),r||(r={left:0,top:1,right:1,bottom:0}),this.offset=r}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}_calculateProjectionMatrix(){const e=this._calculate2DPlanes();if(this._offset.left>=this._offset.right||this._offset.bottom>this._offset.top)return(new P).makeOrthographic(e.left,e.right,e.top,e.bottom,this.near,this.far);const t=this._scaleRange(e.left,e.right,this._offset.left,this._offset.right);let n=t.from,s=t.to;const i=this._scaleRange(e.bottom,e.top,this._offset.bottom,this._offset.top);let a=i.from,r=i.to;const o=(e.right-e.left)/(e.top-e.bottom),l=(s-n)/(r-a);if(l>o){const e=(a+r)/2,t=(r-a)*l/o;a=e-t/2,r=e+t/2}else{const e=(n+s)/2,t=(s-n)*o/l;n=e-t/2,s=e+t/2}return(new P).makeOrthographic(n,s,r,a,this.near,this.far)}_scaleRange(e,t,n,s){const i=(t-e)/(s-n);return{from:e-i*n,to:t+i*(1-s)}}_calculate2DPlanes(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let i=n-e,a=n+e,r=s+t,o=s-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,r-=t*this.view.offsetY,o=r-t*this.view.height}return{left:i,right:a,top:r,bottom:o}}}class o extends X{constructor(e,t,n,s,i){super(e,t,n,s),i||(i={left:0,top:1,right:1,bottom:0}),this.offset=i}copy(e,t){return super.copy(e,t),this._offset=e._offset,this}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}_calculateProjectionMatrix(){let e,t,n,s,i=this.fov*(2*Math.PI/360)/2;n=Math.tan(i),s=-n;let r=Math.atan(this.aspect*Math.tan(i));t=Math.tan(r),e=-t;let o=this._offset.left,l=this._offset.right,h=this._offset.top,d=this._offset.bottom,c=new a(l-o,h-d),u=new a(o+c.x/2,d+c.y/2);if(c.x<c.y){let i=(1-u.x)/(c.x/2),a=u.x/(c.x/2);t*=i,e*=a;let r=(i+a)/2;n*=r,s*=r}else{let i=(1-u.y)/(c.y/2),a=u.y/(c.y/2);n*=i,s*=a;let r=(a+i)/2;e*=r,t*=r}e*=this.near,t*=this.near,n*=this.near,s*=this.near;let p=this.near*Math.tan(Math.PI/180*.5*this.fov)/this.zoom*2,m=this.aspect*p;return this.view&&this.view.enabled&&(e+=this.view.offsetX*m/this.view.fullWidth,n-=this.view.offsetY*p/this.view.fullHeight,t+=this.view.offsetX*m/this.view.fullWidth,s-=this.view.offsetY*p/this.view.fullHeight),(new P).makePerspective(e,t,n,s,this.near,this.far)}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}}return{create:function(t,n,s,i,a){return new e(t,n,s,i,a)},createPreview:function(e,t,s){return new n(s,e,{x:0,y:0,z:0},{x:0,y:0,z:0},t,null)},createStatic:function(e,n){return new t(e,n)},createPreviewLine:function(e,t){let n=new s(t,e.id,e.roomlePosition,e.roomleRotation,e.parentObjectId,e.receivedPointAssociation);return e.meshes.forEach(e=>{let t=e.clone();t.material=e.material.clone(),t.geometry=e.geometry.clone(),n.addMesh(t)}),n.computeBoundingBox(),n},isPreview:function(e){return e instanceof n},isPreviewLine:function(e){return e instanceof s},createPerspectiveCamera:function(e,t,n,s,i){return new o(e,t,n,s,i)},createOrthographicCamera:function(e,t,n,s,a,r,o){return new i(e,t,n,s,a,r,o)}}}const mo=e("J",9);class go{constructor(e){this._mergeThreshold=3,this._componentsToMerge=new fo,this._mergeInProgress=!1,this._components=new Map,this._previews=new Map,this._componentNumberOfPossibleChildren=new Map,this._creator_=e,this._getKernelAccess().addConfiguratorListener(this),this._componentFactory=po()}get materialQueue(){return this.getMeshGenerator().materialQueue}_getKernelAccess(){return Fh.lookup("planner-kernel-access",this._creator_)}_applyMeshTransform(e,t,n,s,i){if(n){const s=e.userData.transform=Cs(n);t&&(e.userData.transform=s),e.applyMatrix4(s)}this._applyMeshUVTransform(e,t,s,i)}_applyMeshUVTransform(e,t,n,s){if(6!==(null==n?void 0:n.length)||(e=>1===e[0]&&0===e[1]&&0===e[2]&&1===e[3]&&0===e[4]&&0===e[5])(n))t&&(t.uvTransform=void 0),s&&(e.geometry=s);else{const i=(e=>{const t=new P;return t.set(e[0],e[2],0,e[4],e[1],e[3],0,e[5],0,0,1,0,0,0,0,1),t})(n);t&&(t.uvTransform=i);const a=null!=s?s:e.geometry;if(a&&a.attributes.uv){const t=a.clone();t.attributes.uv.applyMatrix4(i),e.geometry=t}}}_addMeshToSubPart(e,t,n,s,i,a,r,o,l,h){const d=this._generateMesh(e,t,n,a,r,o,l,void 0,void 0,h);this._applyMeshTransform(d,null,s,i),this._subPartObject.add(d)}_addMeshToComponent(e,t,n,s,i,a,r,o,l,h,d,c){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._addMeshToSubPart(e,null,s,null,null,r,o,l,h,c);const u=this.getComponent(e);if(!u)return;const p=this._componentFactory.isPreview(u),m=this._generateMesh(e,n,p?null:s,r,o,l,h,void 0,void 0,c);m.userData.meshId=t,m.userData.geometryId=n,m.userData.materialId=s,this._applyMeshTransform(m,m.userData,i,a),p&&m.layers.set(5),u&&u.addMesh(m),u.meshes.length>this._mergeThreshold&&this._componentsToMerge.set(e,u.meshes.length)}_changeMeshOfComponent(e,t,n,s,i,a,r){const o=this.getComponent(e);if(!o)return;const l=o.getMeshById(t);if(l){l.userData.geometryId!==n&&console.warn("Geometry of mesh has changed!"),l.userData.materialId=s,l.userData.materialAttributes=r;const e=l.material.clone();this._configuratorMeshGenerator.setMaterial(l,s,void 0,r).then(()=>{this._requestRenderSceneUpdateCallback&&this._requestRenderSceneUpdateCallback()}),e.opacity!==l.material.opacity&&this._requestRenderCallback&&this._requestRenderCallback(),i&&(l.position.set(0,0,0),l.scale.set(1,1,1),l.rotation.set(0,0,0));const t=this._configuratorMeshGenerator.getGeometry(n);this._applyMeshTransform(l,l.userData,i,a,t)}}_removeMeshFromComponent(e,t){const n=this.getComponent(e);n&&n.removeMeshById(t)}getComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:(console.warn("component not found!",e),null)}getNumberOfPossibleChildrenForComponent(e){if(this._componentNumberOfPossibleChildren.has(e))return this._componentNumberOfPossibleChildren.get(e);const t=this._getKernelAccess().kernelInstance.getPlanComponentPossibleChildren(e).length;return this._componentNumberOfPossibleChildren.set(e,t),t}tryToMergeComponents(){this._initData.moc||this._mergeInProgress||(this._mergeInProgress=!0,this._componentsToMerge.size,this._requestMergeComponents())}_requestMergeComponents(){window.requestIdleCallback(this._mergeNextComponent.bind(this))}_mergeNextComponent(){if(this._componentsToMerge.size>0){const e=this._componentsToMerge.largestValue();this._componentsToMerge.delete(e),this._mergeComponent(e),this._requestMergeComponents()}else this._mergeInProgress=!1,this._geometriesMerged&&this._geometriesMerged(),this._components.forEach(e=>{e.loadingMesh&&console.warn("component still has loading mesh: ",e.hash)})}_mergeComponent(e){const t=this._components.get(e);if(t&&!(t.meshes.length<=this._mergeThreshold))if(this._cacheHolder.componentCache.has(t.hash)){const e=this._cacheHolder.componentCache.get(t.hash).meshes;t.replaceMeshes(e)}else{const e=new Map,n=[],s=[];t.meshes.forEach(t=>{const i=t.userData.materialId;if(!i)return void console.warn("mesh has no material id set");if(!e.has(i)){const s=new z(new c,t.material);s.userData.materialId=i,s.receiveShadow=!0,s.castShadow=!0,s.layers.set(3),this._setMaterial(s,i),n.push(s),e.set(i,s)}const a=e.get(i),r=a.geometry;t.userData.transform&&t.geometry.applyMatrix4(t.userData.transform),a.geometry=vn([r,t.geometry]),s.push(t)}),n.forEach(e=>t.addMesh(e)),s.forEach(e=>t.removeMesh(e)),this._cacheHolder.componentCache.set(t.hash,t)}}_addComponent(e){this._listener&&e.isRootComponent&&this._listener.display(e)}removeDockingComponent(){this._getKernelAccess().requestDeleteComponent(this._configuratorContext.dockingRootComponentId),this._configuratorContext.dockingRootComponentId=null}dockComponent(e,t,n,s,i){let a=this._components.get(n),r=this._components.get(e);r&&(r.roomlePosition=s,r.roomleRotation=i,a&&a.add(r),r.parentObjectId=n,r.isRootComponent=t,this._addComponent(r))}dockComponentWithPosition(e,t){let n,s=this._components.get(e.parentId);n=t?t.getKernelPosition(s):e.getKernelPosition(s),Er.start("dock_component_with_position_"+e.childId),this._getKernelAccess().dockComponentWithPosition(e.parentId,e.parentDockId,e.childId,e.childDockId,n),this._configuratorContext.dockingRootComponentId=null}removePreviews(){this._previews.size>0&&(this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear())}_updatePlanObject(e,t){const n=this._components.get(e.rootPlanComponentId);let s=!0;n&&(s=n.geometryChanged),this._listener&&this._listener.planObjectUpdated(e,s,t)}Editor3dAddBakedMesh(e,t,n,s,i,a,r,o){this._addMeshToComponent(e,null,null,t,null,null,n,s,i,a,r,o)}Editor3dAddDockPreview(e,t){const n=this._componentFactory.createPreview(t,e,this._creator_);this._previews.set(t.toString(),n)}Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c){this._addMeshToComponent(e,t,n,s,i,d,a,r,o,l,h,c)}Editor3ChangedNamedMesh(e,t,n,s,i,a,r){this._changeMeshOfComponent(e,t,n,s,i,a,r)}Editor3dRemoveNamedMesh(e,t){this._removeMeshFromComponent(e,t)}Editor3dBeginConstruction(e,t){if(!t){const t=this._components.get(e);t&&t.removeAllMeshes()}this._subPartGuard&&e===this._subPartGuard.info&&(this._subPartObject=new A)}Editor3dComponentCreated(e,t,n,s,i){s&&(this._configuratorContext.rootComponentId=e);let a=null;this._components.has(e)?(a=this._components.get(e),a.removeAllMeshes()):(a=this._componentFactory.create(e,t,n,i,s),a.layers.set(3)),this._components.set(e,a),this._addComponent(a)}Editor3dComponentDocked(e,t,n,s,i){this.dockComponent(e,t,n,s,i)}Editor3dEndConstruction(e){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._subPartGuard.resolve(this._subPartObject);const t=this._getKernelAccess().kernelInstance.getComponent(e),n=this._components.get(e);n&&(n.computeBoundingBox(t.boxForMeasurement),n.boundingBoxMesh&&this._listener&&this._listener.addComponentHandlers(n));let s=this._previews.get(e.toString());s&&s.computeBoundingBox(t.boxForMeasurement,!0)}Editor3dGeometryReady(e){const t=this._components.get(e);t&&t.loadingFinished()}Editor3dGeometryNotReady(e){const t=this._components.get(e);t&&t.loading()}Editor3dPlanObjectConstructionDone(e){const t=this._getKernelAccess().kernelInstance.getPlanObject(e),n=[t,this._getKernelAccess().kernelInstance.getFullPartList(),this._getKernelAccess().kernelInstance.getHashOfConfiguration(e),this._getKernelAccess().kernelInstance.getComponentId(t.rootPlanComponentId)];Lr.finishOperation(2,n),this._updatePlanObject(t,!1),this._listener&&this._listener.planObjectConstructionDone(t)}Editor3dPreviewConstructionDone(e,t){let n=!1;this._previews.forEach(e=>{null!==e.parent&&(this._listener&&(this._componentFactory.isPreviewLine(e)?this._listener.addPreviewLineHandlers(e):this._listener.addPreviewHandlers(e)),n=!0)}),this._listener&&this._listener.previewConstructionDone(this._components.get(e),n)}Editor3dSetPreviewLineAssociations(e,t){let n=this._previews.get(t.toString());if(n.clear(),!n)return;let s=this._componentFactory.createPreviewLine(n,this._creator_),i=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let n;n=0===t?s:s.clonePreviewLine(t),n.name="Preview Line",n.parentDockId=e[t].parentDockId,n.parentId=e[t].parentId,n.childDockId=e[t].childDockId,n.childId=e[t].childId,n.docklineRotation=(a=e[t].rotation,new ve(a.x,a.z,-a.y)),n.roomlePosition=e[t].position,n.roomleLineFrom=e[t].lineFrom,n.roomleLineTo=e[t].lineTo,n.lineSegments=[];for(const s of e[t].lineSegments)n.lineSegments.push({from:s.from/1e3,to:s.to/1e3});n.roomlePositionFrom=e[t].positionFrom,n.roomlePositionTo=e[t].positionTo,i.add(n),n.preparePreview(),this._previews.set(n.stringId,n)}var a}Editor3dSetPreviewPointAssociations(e,t){var n,s;let i=this._previews.get(t.toString());if(!i)return;let a=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let r;0===t?r=i:(r=i.clonePreview(t),this._previews.set(r.stringId,r)),r.name="Preview Point",r.parentDockId=e[t].parentDockId,r.parentId=e[t].parentId,r.childDockId=e[t].childDockId,r.childId=e[t].childId,r.preparePreview(),r.receivedPointAssociation=!0,r.userData.ignoreComponentRaycast=!0,a.add(r);let o=e[t].position;e[t].insertInBetween&&(null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&(o={x:o.x-.5*e[t].displacementVector.x,y:o.y-.5*e[t].displacementVector.y,z:o.z-.5*e[t].displacementVector.z}),r.roomlePosition=o,r.roomleRotation=e[t].rotation,r.startPulsating()}}componentDeleted(e){const t=this._components.get(e);t&&(this._listener&&this._listener.componentDeleted(t),t.removeFromParent(),t.removeAllMeshes(),this._components.delete(e))}componentMetaUpdated(e){const t=this._getRuntimeComponent(e.id);t&&(t.hash=e.hash,t.roomlePosition=e.position,t.roomleRotation=e.rotation,e.boxForMeasurement&&t.computeBoundingBox(e.boxForMeasurement),this._listener&&this._listener.componentUpdated(t,e))}componentConfigurationUpdated(e,t){const n=this._getRuntimeComponent(e);n&&(n.geometryChanged=t)}_getRuntimeComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:null}configurationLoaded(e,t,n,s,i){10===e&&(this._configuratorContext.dockingRootComponentId=n);let a=0===t;a?this._getKernelAccess().kernelInstance.requestPlanComponentConstructionRecursive(n):this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(t);let r=this._getKernelAccess().kernelInstance.getComponent(n),o=this._components.get(n);o&&(o.computeBoundingBox(r.boxForMeasurement),o.hash=r.hash),this._listener&&this._listener.configurationLoaded(o,a&&void 0!==o.boundingBoxMesh)}finishParameterChange(e,t){this.materialQueue.registerCallback(e)}planObjectConfigurationUpdated(e,t,n,s){let i=this._getKernelAccess().kernelInstance.getPlanObject(e);this._updatePlanObject(i,s)}planObjectCreated(e,t){this._configuratorContext.planObjectId=t,this._listener&&this._listener.clearScene()}planObjectUpdated(e,t){this._updatePlanObject(e,t)}sceneCleared(){this._components.forEach((function(e){e.removeFromParent(),e.removeAllMeshes()})),this._components.clear(),this._componentNumberOfPossibleChildren.clear(),this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear()}setListener(e){this._listener=e}getBoundingBox(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxForMeasurement)return Li(e.boxForMeasurement)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxOfGeometry(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxOfGeometry)return Li(e.boxOfGeometry)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxWithPreviews(){const e=this._components.get(this._configuratorContext.rootComponentId);return e?(new ge).setFromObject(e):null}hasPreviews(){return this._previews.size>0}clearRootComponent(){var e;null===(e=this._components.get(this._configuratorContext.rootComponentId))||void 0===e||e.hoverOff()}debugSceneGraph(e){e?this._components.has(e)?this._components.get(e):this._previews.has(e.toString())&&this._previews.get(e.toString()):this._configuratorContext}getComponentsForIds(e){let t=[];return e.forEach(e=>{const n=this._components.get(e);n&&t.push(n)}),t}getComponents(){return Array.from(this._components.values())}getPreviews(){return Array.from(this._previews.values())}hasPreviewLines(){for(const e of this._previews.values())if(this._componentFactory.isPreviewLine(e))return!0;return!1}isPreviewLine(e){return this._componentFactory.isPreviewLine(e)}isPreview(e){return this._componentFactory.isPreview(e)}setGeometriesMergedListener(e){this._geometriesMerged=e}removeGeometriesMergedListener(){this._geometriesMerged=void 0}setMergeThreshold(e){this._mergeThreshold=e}_generateMesh(e=0,t=null,n,s,i,a,r,o,l,h){return this._configuratorMeshGenerator.generateMesh(e,t,n,s,i,a,r,!1,h)}_setMaterial(e,t,n){this._configuratorMeshGenerator.setMaterial(e,t)}constructComponents(e){this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(e)}requestSubPartConstruction(e){return this._subPartGuard=new _n(e),this._getKernelAccess().requestPlanComponentConstruction(e,!1),this._subPartGuard.wait()}getMeshGenerator(){return this._configuratorMeshGenerator}setRequestRenderCallback(e){this._requestRenderCallback=e}setRequestRenderSceneUpdateCallback(e){this._requestRenderSceneUpdateCallback=e}}e("C",go),on([hn],go.prototype,"_configuratorMeshGenerator",void 0),on([hn],go.prototype,"_configuratorContext",void 0),on([hn],go.prototype,"_cacheHolder",void 0),on([hn],go.prototype,"_initData",void 0);class fo extends Map{largestValue(){let e=this.entries().next().value[0],t=0;return this.forEach((n,s)=>{n>t&&(e=s,t=n)}),e}}const _o=["material"];class vo extends Vr{constructor(e){super(e),this.externalMeshQueue=new Wa,this.muteKernelCallbacks=!1,this.listOfVariants=(e,t)=>{}}init(e){super.init(e),Er.addMeta("kernel_is_ready",{isWasm:this._useWASM}),Ir.kernelInstance?(this._kernelContainer=Ir.kernelContainer,setTimeout(()=>this._loadSuccess(),0)):this._scriptLoader.fetch(this._kernelPath,{id:"kernel"}).then(this._loadSuccess.bind(this),this._loadError.bind(this))}_loadSuccess(){Er.start("kernel_is_ready"),window.ConfiguratorKernel&&(Ir.kernelInstance?setTimeout(()=>this.isReady(),0):(window.ConfiguratorKernel(this._kernelContainer),window.ConfiguratorKernel=null))}_loadError(){this._configuratorKernelAccessCallback.loadError()}selectedComponent(e){this._updateComponentDependencies(e)}uiRequestConfiguration(e){const t=this._kernelInstance.getSerializedConfiguration(e);Lr.finishOperation(1,t)}_updateComponentParameters(e){let t=this._kernelInstance.getComponentParameters(e);const n=this._kernelInstance.getComponent(e);this._configuratorKernelAccessCallback.updateParameters(t,n.parameterGroups,e,1)}selectionChange(e,t){let n=!1,s=[];if(e){let t=this._kernelInstance.getComponent(e);t.componentId=this._kernelInstance.getComponentId(e),t&&t.childIds&&t.childIds.length>0&&(n=!0),s.push(t);const i=this._kernelInstance.getPlanObjectFromPlanComponent(e);i&&this._componentSelectionChanged(i,t)}this._configuratorUiCallbacks.onSelectionChange("standard",t,n,s)}_componentSelectionChanged(e,t){}_parameterChanged(e,t,n){}multiSelectionChange(e,t){this._updateCommonComponentDependencies(e);let n=!1,s=!1,i=[];e&&e.forEach(e=>{let a=this._kernelInstance.getComponent(e);a.componentId=this._kernelInstance.getComponentId(e),a&&a.childIds&&a.childIds.length>0&&(n=!0),a.id===t&&(s=!0),i.push(a)}),this._configuratorUiCallbacks.onSelectionChange("multiselect",s,n,i)}_updateCommonComponentDependencies(e){const{parameters:t,parameterGroups:n}=this._kernelInstance.getCommonPlanComponentParameters(this._utilityToLongArray(e));this._configuratorKernelAccessCallback.updateParameters(t,n,e,2)}_updateComponentChildren(e){const t=this._kernelInstance.getPlanComponentPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,1)}_updateComponentDependencies(e){this._updateComponentParameters(e),this._updateComponentChildren(e)}_updatePlanObjectParameters(e){let t,n=this._kernelInstance.getPlanObjectParameters(e);if(0===n.length){let s=this._kernelInstance.getRootPlanComponentIdFromObjectId(e);n=this._kernelInstance.getComponentParameters(s),this._enableRootComponentParametersAsGlobal(),t=this._kernelInstance.getComponent(s)}else this._configuratorContext.rootComponentParametersAsGlobal=!1,t=this._kernelInstance.getPlanObject(e);this._configuratorKernelAccessCallback.updateParameters(n,t.parameterGroups,e,0)}_enableRootComponentParametersAsGlobal(){this._configuratorContext.selectedRuntimeComponentId||(this._configuratorContext.rootComponentParametersAsGlobal=!0)}_updatePlanObjectChildren(e){const t=this._kernelInstance.getPlanObjectPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,0)}updatePlanObjectDependencies(e){this._updatePlanObjectParameters(e),this._updatePlanObjectChildren(e)}_updateConfigurationHasChildren(e,t=null){t||(t=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)));const n=t.childIds.size?t.childIds.size():t.childIds.length;this._configuratorUiCallbacks.onConfigurationHasChildren(n>0)}dockComponent(e,t,n,s){const i=this._kernelInstance.getComponentId(n),a=this._kernelInstance.getComponentId(e);this._kernelInstance.dockComponent(n,s,e,t),this._configuratorUiCallbacks.onUserInitiatedDockDone(i,s,a,t,null)}changeUseOfHDGeometry(e,t){this._rapiAccess.changeUseOfHDGeometry();const n=e.planObjectId,s=e.lastLoadedRapiId?e.lastLoadedRapiId:this._kernelInstance.getComponentId(n),i=this._kernelInstance.getSerializedConfiguration(n);this._kernelInstance.clearAll(),this._kernelInstance.useHDGeometry(t),Lr.finishOperation(3,[i,s])}webGlPreviewDockings(e,t){Lr.waitFor(4).then(({componentId:n})=>{t&&this.requestPlanComponentConstruction(n),this._kernelInstance.requestPreviewGeometry(n,e.planObjectId,!1)}),e.lastPossibleChild&&e.lastPossibleChild.isComponent&&(this._kernelIo.setMeta({componentId:e.lastPossibleChild.id}),this._kernelInstance.loadPlainComponent(10,e.lastPossibleChild.id,e.lastPossibleChild.configuration)),e.lastPossibleChild&&e.lastPossibleChild.isItem&&this._kernelInstance.loadFreeFlyingConfiguration(10,e.lastPossibleChild.configuration)}previewDockingsWithDrag(e,t){var n,s,i;this._kernelInstance.requestPreviewGeometry(e,t,null!==(i=null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&void 0!==i&&i)}loadConfiguration(e){this._initData.id?this._memoryManager.loadingConfiguration(this._initData.id):this._memoryManager.loadingConfigurationString(),this._memoryManager.shouldHardReset()?this._kernelInstance.clearAll():this._kernelInstance.clearScene(),this._kernelInstance.loadConfiguration(mo,e,{x:0,y:0,z:0})}changeCommonComponentParameter(e,t,n,s,i,a){if("string"==typeof s){const n=[];for(const i of e)this._kernelInstance.isExternalPlanObject(i)?n.push(i):this._kernelInstance.setComponentParameter(i,t,s);this._kernelInstance.setPlanComponentParameters(this._utilityToLongArray(n),t,s)}else console.warn("tried to set a parameter to a none string value!",s,t,n);this._finishParameterChange(n,i,a),this._updateCommonComponentDependencies(e)}changeComponentParameter(e,t,n,s,i,a){"string"==typeof s?this._kernelInstance.isExternalPlanObject(e)?this._parameterChanged(e,t,s):this._kernelInstance.setComponentParameter(e,t,s):console.warn("tried to set a parameter to a none string value!",s,t,n),this._finishParameterChange(n,i,a),this._updateComponentDependencies(e)}changePlanObjectParameter(e,t,n,s,i,a){"string"==typeof s?this._kernelInstance.isExternalPlanObject(e)?this._parameterChanged(e,t,s):this._kernelInstance.setPlanObjectParameter(e,t,s):console.warn("tried to set a parameter to a none string value!",s,t,n),this._finishParameterChange(n,i,a)}_finishParameterChange(e,t,n){-1===_o.indexOf(e)?setTimeout(()=>t(),0):this._configuratorKernelCallbackListener.forEach(e=>e.finishParameterChange(t,n))}requestDeleteComponents(e){e&&this._kernelInstance.deletePlanComponents(this._utilityToLongArray(e))}requestDeletePlanComponent(e){var t,n;e&&(null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)&&this._kernelInstance.deletePlanComponent(e)}loadComponentIntoKernel(e,t){this._kernelIo.setMeta({componentId:t}),this._kernelInstance.loadComponentDefinition(10,e)}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const s=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(s,btoa(e))}requestSync(e,t){this.planObjectCreated(e,t),this._kernelInstance.syncPlanObjectToView(e,t)}getGlobalParameters(e,t){return new Promise(n=>{let s=this._kernelInstance.getPlanObjectParameters,i=e;t&&(s=this._kernelInstance.getComponentParameters,i=this._kernelInstance.getRootPlanComponentIdFromObjectId(e)),n(s.apply(this._kernelInstance,[i]))})}getPartList(){return new Promise(e=>{e(this._kernelInstance.getFullPartList())})}getConfigurationHash(e){return new Promise(t=>t(this._kernelInstance.getHashOfConfiguration(e.planObjectId)))}requestPlanObjectConstruction(e){this._kernelInstance.requestPlanObjectConstruction(e)}isReady(){super.isReady(),this._setupKernel(),Sr.isProduction||(window.__RML__DEBUG__.Kernel=this._kernelInstance,window.__RML__DEBUG__.KernelContainer=this._kernelContainer,window.__RML__DEBUG__.Helper={convertCObject:Ps}),this._configuratorKernelAccessCallback.isReady(),this._configuratorUiCallbacks.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Ir.planObjectId&&this.planObjectCreated(-1,Ir.planObjectId)}_setupKernel(){1===this._kernelType&&(Er.start("kernel_create_instance"),Ir.kernelInstance?this._kernelInstance=Ir.kernelInstance:this._kernelInstance=new this._kernelContainer.Kernel),this._initKernel()}onLoadComponentError(e,t){this._configuratorUiCallbacks.onComponentLoadError(e,t)}configurationLoaded(e,t,n,s,i,a){Lr.finishOperation(4,{conversationId:e,objectId:t,componentId:n,hash:s,errors:Ps(i)}),this._configuratorKernelCallbackListener.forEach(a=>a.configurationLoaded(e,t,n,s,i))}componentDefinitionLoaded(e,t){Lr.finishOperation(0,t)}componentDefinitionLoadingError(e,t){this._kernelIo.error(t),Lr.failOperation(0,new Error(t))}configurationLoadingError(e,t){let n="Configuration loading error";if(t){const e=Ps(t);Array.isArray(e)&&(n=e.join("\n"),e.forEach(e=>this._kernelIo.error(e)))}Lr.failOperation(4,new Error(n)),Lr.failOperation(2,new Error(n))}componentConfigurationUpdated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.componentConfigurationUpdated(e,t)),this._kernelInstance.requestDeltaPlanComponentConstruction(e)}setActiveGroupInView(e){this._kernelInstance.setActiveGroupInView(e)}setActiveGroupInViewForPlanObject(e,t){this._kernelInstance.setActiveGroupInViewForPlanObject(e,t||this._configuratorContext.planObjectId)}componentParameters(){}requestComponentDimensions(){}planObjectCreated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.planObjectCreated(e,t))}planObjectUpdated(e,t){const n=this._kernelInstance.getPlanObject(e);this._onBoundsUpdate(n),this._configuratorKernelCallbackListener.forEach(e=>e.planObjectUpdated(n,t))}planObjectConfigurationUpdated(e,t,n,s,i,a){this.updatePlanObjectDependencies(e);let r=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e));this._configuratorKernelCallbackListener.forEach(s=>s.planObjectConfigurationUpdated(e,t,n,a));const o=this._kernelInstance.getPlanObject(e);return this._onBoundsUpdate(o),a||this._configuratorHistory.push(t),this._updateConfigurationHasChildren(e,r),this.requestPartListAndUpdatePricesOfParts(n)}_onBoundsUpdate(e){if(!e.boxForMeasurement)return;const t={width:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.x),height:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.z),depth:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.y),kernelBounds:e.boxForMeasurement};this._configuratorUiCallbacks.onBoundsUpdate(t)}planObjectDeleted(){}requestPlanObjectDimensions(){}async requestExternalMesh(e,t){let n=()=>{};const s=new Promise((e,t)=>{n=e});let i;this.externalMeshQueue.push(s),this._configuratorUiCallbacks.onRequestExternalMesh(e,t);try{i=await this._rapiAccess.getMesh(e,"crt",t)}catch(n){return this._handleInvalidMesh(e,t),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" can not be loaded. "${n}"`)),void console.error(n)}try{const s=await fetch(new Request(this._dataSyncer.requestAsset(i.url,!0))),a=await s.arrayBuffer();this._handleCortoMesh(a,e,t),n()}catch(n){return this._handleInvalidMesh(e,t),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" breaks. "${n}"`)),void console.error(n)}}Editor3dComponentCreated(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentCreated(e,t,n,s,i)),!s&&parent&&i>0&&this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentDocked(e,s,i,t,n))}Editor3dPlanObjectConstructionDone(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dPlanObjectConstructionDone(e)),this.updatePlanObjectDependencies(e),this._updateConfigurationHasChildren(e),this._initData.moc||this._calcPrice()}Editor3dBeginGroup(){}Editor3dEndGroup(){}Editor3dSetMaterial(){}Editor3dLoadMaterial(){}Editor3dAddDockPreview(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dAddDockPreview(e,t))}Editor3dSetPreviewPointAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewPointAssociations(e,t))}Editor3dSetPreviewLineAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewLineAssociations(e,t))}Editor3dPreviewConstructionDone(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dPreviewConstructionDone(e,t))}Editor3dTranslateBy(){}Editor3dRotateBy(){}Editor3dRotateAround(){}Editor3dAddCube(){}Editor3dAddCubeUVMod(){}Editor3dAddSphere(){}Editor3dAddSphereUVMod(){}Editor3dAddRectangle(){}Editor3dAddRectangleUVMod(){}Editor3dAddMesh(){}Editor3dAddMeshUVMod(){}Editor3dAddMeshUVCoord(){}Editor3dAddCylinder(){}Editor3dAddCylinderUVMod(){}Editor3dAddPrism(){}Editor3dAddPrismUVMod(){}Editor3dAddFittingPoint(){}Editor3dAddFittingLine(){}Editor3dSelectObject(){}Editor3dCopy(){}Editor3dUpdatePlanObjectPosition(){}Editor3dUpdatePlanObjectRotation(){}Editor3dUpdatePlanObjectTransform(){}Editor3dUpdatePlanComponentPosition(){}Editor3dUpdatePlanComponentRotation(){}Editor3dUpdatePlanComponentTransform(){}getRuntimeComponentIdOfRootComponent(e){return this._kernelInstance?this._kernelInstance.getRootPlanComponentIdFromObjectId(e):(console.warn("this._kernelInstance not ready now"),0)}getRuntimeComponentId(e){return this._kernelInstance.getComponentId(e)}getParameterGroups(){if(!this._configuratorContext.planObjectId)return[];const e=this._kernelInstance.getRootPlanComponentIdFromObjectId(this._configuratorContext.planObjectId);return this._kernelInstance.getComponent(e).parameterGroups}resume(){this.muteKernelCallbacks||super.resume()}getSerializedConfiguration(e){return this._kernelInstance.getSerializedConfiguration(e)}createNewSerializedConfiguration(e){return this._kernelInstance.createNewSerializedConfiguration(e)}getCurrentConfigurationHash(e){return this._kernelInstance.getHashOfConfiguration(e)}listOfVariantsError(e,t){this._kernelIo.setMeta({rapiId:e}),this._kernelIo.error(t)}}on([hn],vo.prototype,"_memoryManager",void 0),on([hn],vo.prototype,"_configuratorKernelAccessCallback",void 0),on([hn],vo.prototype,"_initData",void 0),on([hn],vo.prototype,"_configuratorHistory",void 0);class wo extends A{constructor(e,t=.05){super(),this.name=e,this._sphereSize=t,this._innerRingRadius=this._sphereSize,this._outerRingRadius=this._innerRingRadius+.02,this._initNodeMesh()}_initNodeMesh(){const e=new pt(this._sphereSize,32),t=new y({color:16777215});this._sphere=new z(e,t);const n=new mt(this._innerRingRadius,this._outerRingRadius,32),s=new y({color:0,side:F});this._innerRingMesh=new z(n,s),this._innerRingMesh.rotation.set(Math.PI/2,0,0);const i=new mt(this._outerRingRadius,this._outerRingRadius+.01,32),a=new y({color:16777215,side:F});this._outerRingMesh=new z(i,a),this._outerRingMesh.rotation.set(Math.PI/2,0,0),this.add(this._sphere),this.add(this._innerRingMesh),this.add(this._outerRingMesh)}getSize(){return(new ge).setFromObject(this).getSize(new r)}hoverOn(){this._sphere.geometry=new pt(this._sphereSize+.02,32),this._innerRingMesh.geometry=new mt(this._innerRingRadius+.02,this._outerRingRadius+.02,32),this._outerRingMesh.geometry=new mt(this._outerRingRadius+.02,this._outerRingRadius+.01+.02,32)}hoverOff(){this._sphere.geometry=new pt(this._sphereSize,32),this._innerRingMesh.geometry=new mt(this._innerRingRadius,this._outerRingRadius,32),this._outerRingMesh.geometry=new mt(this._outerRingRadius,this._outerRingRadius+.01,32)}select(e){this._innerRingMesh.material=new y({color:e,side:F})}deselect(e){this._innerRingMesh.material=new y({color:e,side:F})}}class bo extends _r{constructor(e){super(e);const t=this.getPlanElement().getMaxWallHeight();this._container.position.y=(t<0?2800:t)/1e3+.01,this._container.name="Node Plan Element",this._nodeUiMesh=new wo("Wall draggable node"),this.addMesh(this._nodeUiMesh)}update(){super.update(),this._container.position.y=this.getPlanElement().getMaxWallHeight()/1e3+.01}setTopView(e){super.setTopView(e),e||(this._nodeUiMesh.visible=!1)}getSize(){return this._topView?this._nodeUiMesh.getSize():new r}show(){this._nodeUiMesh.visible=this._topView}hide(){this._nodeUiMesh.visible=!1}select(){this._nodeUiMesh.select(10526880),super.select()}deselect(){this._nodeUiMesh.select(0),super.deselect()}hoverOn(){this._nodeUiMesh.hoverOn(),super.hoverOn()}hoverOff(){this._nodeUiMesh.hoverOff(),super.hoverOff()}_generateBoundingBox(){const e=super._generateBoundingBox();return e.layers.set(9),e}addMesh(e){super.addMesh(e)}}e("N",bo);const yo=Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:0}),So=Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#B1B1B1"),side:F}),xo=Oi.createMeshStandardMaterial({transparent:!0,opacity:.4,color:new h("#B1B1B1"),side:F}),Po=new B({color:new h("#7B7B7B")});class Mo extends A{constructor(e,t){super(),this._planElement=e,this._rapiItem=t,this._init()}_init(){var e,t;const n=this._planElement,{x:s,z:i}=ys(n.size),a=new $e(s,.01,i);this._topGreyMesh=new z(a,So),this.add(this._topGreyMesh);const r=new ht(a);this._topGreyMeshOutline=new V(r,Po),this._topGreyMesh.add(this._topGreyMeshOutline);const o="door"===n.getObjectType()&&(!this._rapiItem||"door"===(null===(e=this._rapiItem)||void 0===e?void 0:e.detailType)),l="door"===n.getObjectType()&&(!this._rapiItem||"door_double"===(null===(t=this._rapiItem)||void 0===t?void 0:t.detailType));if("window"===n.getObjectType()){const e=new $e(s,.02,.03);this._topBlackMesh=new z(e,yo),this.add(this._topBlackMesh)}else if(o){const e=new gt(s,16,0,Math.PI/2);this._topDoorMesh1=new z(e,xo),this._topGreyMesh.add(this._topDoorMesh1);const t=new ht(this._topDoorMesh1.geometry);this._topDoorOutline1=new V(t,Po),this._topDoorMesh1.add(this._topDoorOutline1),this._updateDoor()}else if(l){const e=new gt(s/2,16,0,Math.PI/2);this._topDoorMesh1=new z(e,xo),this._topGreyMesh.add(this._topDoorMesh1);const t=new ht(this._topDoorMesh1.geometry);this._topDoorOutline1=new V(t,Po),this._topDoorMesh1.add(this._topDoorOutline1);const n=new gt(s/2,16,0,Math.PI/2);this._topDoorMesh2=new z(n,xo),this._topGreyMesh.add(this._topDoorMesh2);const i=new ht(this._topDoorMesh2.geometry);this._topDoorOutline2=new V(i,Po),this._topDoorMesh2.add(this._topDoorOutline2),this._updateDoubleDoor()}this.position.y=Co}setTopView(e){e?this._enableTopView():this._disableTopView()}_enableTopView(){this.visible=!0}_disableTopView(){this.visible=!1}_updateDoor(){this._resetTopDoorMesh(this._topDoorMesh1);const e=this._planElement,{flipY:t,flipX:n}=e,{x:s}=ys(e.size);this._topDoorMesh1.geometry=new gt(s,16,0,Math.PI/2),this._topDoorMesh1.rotateX(Math.PI/2*(t?1:-1)),this._topDoorMesh1.position.x=s/2*(n?1:-1),this._topDoorMesh1.scale.x=n?-1:1,this._topDoorOutline1.geometry=new ht(this._topDoorMesh1.geometry)}_updateDoubleDoor(){this._resetTopDoorMesh(this._topDoorMesh1),this._resetTopDoorMesh(this._topDoorMesh2);const e=this._planElement,{flipY:t}=e,{x:n}=ys(e.size),s=Math.PI/2*(t?1:-1);this._topDoorMesh1.geometry=new gt(n/2,16,0,Math.PI/2),this._topDoorMesh1.rotateX(s),this._topDoorMesh1.position.x=-n/2,this._topDoorOutline1.geometry=new ht(this._topDoorMesh1.geometry),this._topDoorMesh2.geometry=new gt(n/2,16,0,Math.PI/2),this._topDoorMesh2.rotateX(s),this._topDoorMesh2.position.x=n/2,this._topDoorMesh2.scale.x=-1,this._topDoorOutline2.geometry=new ht(this._topDoorMesh2.geometry)}_resetTopDoorMesh(e){e.position.y=-.01,e.position.x=0,e.rotation.x=0}update(){if(!this._topGreyMesh||!this._topGreyMeshOutline)return;const{x:e,z:t}=ys(this._planElement.size);this._topGreyMesh.geometry=new $e(e,.01,t),this._topGreyMeshOutline.geometry=new ht(this._topGreyMesh.geometry),this._topBlackMesh&&(this._topBlackMesh.geometry=new $e(e,.02,.03)),this._topDoorMesh1&&!this._topDoorMesh2&&this._updateDoor(),this._topDoorMesh1&&this._topDoorMesh2&&this._updateDoubleDoor()}}const Co=5;class To extends xr{constructor(e){super(e),this._container.name="Construction "+this._container.name}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new Mo(this.getPlanElement(),this.getRapiItem()),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getPlanElement(){return super.getPlanElement()}_generateBoundingBox(){const e=super._generateBoundingBox(),t=this.getSize();return e.geometry=new $e(t.x,this._topView?Co:t.y,t.z),e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new $e(e.x,this._topView?Co:e.y,e.z)}getTopViewContainer(){return this._constructionTopView}getConstructionElementMeasurements(e,t,n){return mr(this,e,t,n)}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update()}}e("e",To),e("aq",e=>({...lr(e),id:e.id,lengthFormatted:e.lengthFormatted}));const Ao=e("ab",{POINT1:"point1",POINT2:"point2"});class Ro extends _r{constructor(e){super(e),this._initializeContainer(),this._initializeLines(),this._initializeDraggables()}_initializeContainer(){this._container.name="Measurement Line Plan Element",this._container.position.copy(new r(0,Co,0))}_initializeLines(){this._lineMesh=this._createLine(0),this._subLine1=this._createLine(0),this._subLine2=this._createLine(0)}_createDraggableNodeBoundBox(e){const t=(new ge).setFromObject(e).getSize(new r),n=new $e(t.x+.2,t.y,t.z+.2);let s=new h("#DDDDDD");const i=this.getPlanElement().customColor;i>0&&(s=Ji(i));let a=Oi.createMeshStandardMaterial({color:s,opacity:1,transparent:!0});a.visible=!1;let o=new z(n,a);return o.name="bounding box for draggable node",o.position.copy(e.position),o.castShadow=!1,o.receiveShadow=!1,o.layers.set(6),o}_initializeDraggables(){this._point1Draggable=new wo("point1 draggable"),this._point1Draggable.layers.set(6),this._point2Draggable=new wo("point2 draggable");const[e,t]=this._getMainLinePoints();this._point1Draggable.position.copy(e),this._point2Draggable.position.copy(t),this._point1BoundingBox=this._createDraggableNodeBoundBox(this._point1Draggable),this._point2BoundingBox=this._createDraggableNodeBoundBox(this._point2Draggable),this._point2Draggable.layers.set(6),this.addMesh(this._point1Draggable),this.addMesh(this._point2Draggable),this.addMesh(this._point1BoundingBox),this.addMesh(this._point2BoundingBox)}_createLine(e){const t=new B({color:e,linewidth:1}),n=new c,s=new H(n,t);return s.layers.set(6),s.frustumCulled=!1,this.addMesh(s),s}getMeasurementLineDimension(){const[e,t]=this._getMainLinePoints(),n=e.clone().sub(t),{textDirection:s,textRotation:i}=cr(n),a=e.clone().add(t).divideScalar(2);return{id:this.getPlanElement().getId(),length:e.clone().multiplyScalar(1e3).distanceTo(t.clone().multiplyScalar(1e3)),textPosition3d:a,textRotation:i,fromPosition3d:e,toPosition3d:t,textDirection:s}}show(){this._container.visible=!0}hide(){this._container.visible=!1}hideAllSubLines(){this._subLine1.material.visible=!1,this._subLine2.material.visible=!1}showAllSubLines(){this._subLine1.material.visible=!0,this._subLine2.material.visible=!0}hideDraggableNodes(){this._point1Draggable.visible=!1,this._point2Draggable.visible=!1,this.showAllSubLines()}showDraggableNodes(){this._point1Draggable.visible=!0,this._point2Draggable.visible=!0,this.hideAllSubLines()}showPoint1DraggableNode(){this._point1Draggable.visible=!0,this._subLine2.material.visible=!0}showPoint2DraggableNode(){this._point2Draggable.visible=!0,this._subLine1.material.visible=!0}hidePoint1DraggableNode(){this._point1Draggable.visible=!1,this._subLine2.material.visible=!1}hidePoint2DraggableNode(){this._point2Draggable.visible=!1,this._subLine1.material.visible=!1}setTopView(e){super.setTopView(e),e?(this.show(),this.update()):this.hide()}update(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t);this._updateSubLineGeometry(this._subLine1,e,n),this._updateSubLineGeometry(this._subLine2,t,n),this.updatePointDraggableGeometry(this._point1Draggable,e),this.updatePointDraggableGeometry(this._point2Draggable,t),this._lineMesh.geometry.setFromPoints([e,t]),this._lineMesh.name="main measurement line",this._boundingBox.geometry=this._getGeometry(),this._point1BoundingBox.position.copy(e),this._point2BoundingBox.position.copy(t),this._point1BoundingBox.material.visible=!1,this._point2BoundingBox.material.visible=!1,this._point1BoundingBox.position.y=3.1,this._point2BoundingBox.position.y=3.1}_generateBoundingBox(){let e=new h("#DDDDDD");const t=this.getPlanElement().customColor;t>0&&(e=Ji(t));let n=Oi.createMeshStandardMaterial({color:e,opacity:1,transparent:!0,side:F}),s=new z(this._getGeometry(),n);return s.name="bounding box",s.position.y=3,s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),s}_getGeometry(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t),s=e.clone().add(n.clone().multiplyScalar(.1)),i=e.clone().add(n.clone().multiplyScalar(-.1)),a=t.clone().add(n.clone().multiplyScalar(.1)),r=t.clone().add(n.clone().multiplyScalar(-.1)),o=new c,l=[s,a,r,i].reduce((e,t)=>[...e,t.x,t.y,t.z],[]);return o.setAttribute("position",new Le(l,3)),o.setIndex([0,1,2,2,3,0]),o.computeVertexNormals(),o}_getMainLinePoints(){const e=this.getPlanElement();return[bs(e.getPoint1()),bs(e.getPoint2())]}_calculateNormalVector(e,t){return e.clone().sub(t).cross(new r(0,1,0)).normalize()}_updateSubLineGeometry(e,t,n){const s=t.clone().add(n.clone().multiplyScalar(.1)),i=t.clone().add(n.clone().multiplyScalar(-.1));e.geometry.setFromPoints([i,s])}updatePointDraggableGeometry(e,t){e.position.copy(t)}getPoint1Draggable(){return this._point1Draggable}getPoint2Draggable(){return this._point2Draggable}getPoint1DraggableBoundingBox(){return this._point1BoundingBox}getPoint2DraggableBoundingBox(){return this._point2BoundingBox}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material.visible=!1)}selectPoint1Draggable(){this._point1Draggable.select(10526880),super.select()}selectPoint2Draggable(){this._point2Draggable.select(10526880),super.select()}deselectPoint1Draggable(){this._point1Draggable.select(0),super.deselect()}deselectPoint2Draggable(){this._point2Draggable.select(0),super.deselect()}selectAllDraggablePoints(){this._point1Draggable.select(10526880),this._point2Draggable.select(10526880),super.select()}deselectAllDraggablePoints(){this._point1Draggable.select(0),this._point2Draggable.select(0),super.deselect()}hoverOnDragPoint1(){this._point1Draggable.hoverOn(),super.hoverOn()}hoverOnDragPoint2(){this._point2Draggable.hoverOn(),super.hoverOn()}hoverOffDragPoint1(){this._point1Draggable.hoverOff(),super.hoverOff()}hoverOffDragPoint2(){this._point2Draggable.hoverOff(),super.hoverOff()}selectPointOnDragStart(e){this.showAllSubLines(),e.deselectAllDraggablePoints(),e.currentPoint===Ao.POINT1?e.selectPoint1Draggable():e.currentPoint===Ao.POINT2&&e.selectPoint2Draggable()}hideDraggablePointsOnDragStart(e,t){e.deselectAllDraggablePoints(),t===Ao.POINT1?(e.hidePoint1DraggableNode(),e.selectPoint1Draggable()):t===Ao.POINT2&&(e.hidePoint2DraggableNode(),e.selectPoint2Draggable())}showDraggablePointsOnDragEnd(e,t){t===Ao.POINT1?e.showPoint1DraggableNode():t===Ao.POINT2&&e.showPoint2DraggableNode(),this.hideAllSubLines()}handleDraggablePointsSelection(e){e.deselectAllDraggablePoints(),e.currentPoint&&e.currentPoint===Ao.POINT1?e.selectPoint1Draggable():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.selectPoint2Draggable()}showDraggablePointsOnHoverOn(e){e.currentPoint&&e.currentPoint===Ao.POINT1?e.hoverOnDragPoint1():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.hoverOnDragPoint2()}showDraggablePointsOnHoverOff(e){e.currentPoint&&e.currentPoint===Ao.POINT1?e.hoverOffDragPoint1():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.hoverOffDragPoint2()}}e("M",Ro);class Eo extends wr{constructor(e){super(e),this._container.name="Configurable "+this._container.name}getConstructionElementMeasurements(e,t,n){return mr(this,e,t,n)}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new $e(e.x,this._topView?Co:e.y,e.z)}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new Mo(this.getPlanElement()),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getTopViewContainer(){return this._constructionTopView}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update(),this._container.position.copy(bs(this._topView?this.getPlanElement().getCenter():this.getPlanElement().getMeshCenter()))}getPlanElement(){return super.getPlanElement()}}e("c",Eo);class Io extends vo{get kernelContainer(){return this._kernelContainer}constructor(e){super(e),this._plannerKernelCallbackListener=new Set}_loadSuccess(){super._loadSuccess(),window.RoomleCore&&window.RoomleCore(this._kernelContainer)}_loadError(){super._loadError(),console.error("kernel load error")}_createPlanInteractionHandler(){var e,t,n,s,i,a,r;this._planInteractionHandler=new this._kernelContainer.PlanInteractionHandler;const o=null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.advancedDocking,l=null!==(i=null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&void 0!==i&&i;this._planInteractionHandler.init(this._planInteractionHandler,1,50,o?this._kernelContainer.SnapMode.ON_COLLISION:this._kernelContainer.SnapMode.WITHIN_SNAP_DISTANCE,o?this._kernelContainer.SnapMode.ON_COLLISION:this._kernelContainer.SnapMode.WITHIN_SNAP_DISTANCE,this._initData.snappingEnabled,this._kernelContainer.DrawingType.CLICK_PER_CLICK),this._planInteractionHandler.dockWhenSnap=l,this._planInteractionHandler.unDockOnMove=l,this._planInteractionHandler.enableRaster=!0,this._planInteractionHandler.unit=this._initData.unit||"cm",this._planInteractionHandler.createChildrenEntities={value:(null===(r=null===(a=this._initData)||void 0===a?void 0:a.featureFlags)||void 0===r?void 0:r.advancedDocking)?1:0},this._roomlePlannerUiCallback.onPlanInteractionHandlerCreated(this._planInteractionHandler)}addPlannerListener(e){this._plannerKernelCallbackListener.add(e)}removePlannerListener(e){this._plannerKernelCallbackListener.delete(e)}isReady(){super.isReady(),this.registerCallbacks(),this._roomlePlannerUiCallback.onPlannerKernelIsReady(this._kernelContainer),this._roomlePlannerUiCallback.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Sr.isProduction||(window.__RML__DEBUG__.ConfiguratorKernel=this._kernelInstance,window.__RML__DEBUG__.PlannerKernelContainer=this._kernelContainer),this._kernelAccessCallback.isReady()}_setupKernel(){0===this._kernelType&&(this._createPlanInteractionHandler(),Ir.kernelInstance?this._kernelInstance=Ir.kernelInstance:this._kernelInstance=this._planInteractionHandler.getConfiguratorKernel()),super._setupKernel()}get callbacks(){return this._roomlePlannerUiCallback}get planInteractionHandler(){return this._planInteractionHandler}get planModelViewHelper(){return this._kernelContainer.PlanModelViewHelper}catalogItemLoaded(e){const t=this._rapiItemToKernelItem(e);this._kernelContainer.catalogItemLoaded(t)}async insertItems(e){this.planInteractionHandler.startInteraction();let t=new this._kernelContainer.CatalogItemPtrList;e.forEach(e=>{let n=e.count||1;for(let s=0;s<n;s++)e.count||(e.count=0),t.push_back(this._rapiItemToKernelItem(e))});const n=this.planInteractionHandler.getPlan().extRef.jsObject,s=n.getPlanObjectViewModelsFromRapiId().reduce((e,t)=>(e[t.getId()]=!0,e),{});this.planInteractionHandler.addPlanObjects(t,!0),await Promise.allSettled([Promise.allSettled(n.getStaticPlanObjectViewModels().map(async e=>{if(e.needsRapiItem()){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}})),Promise.allSettled([...n.getConfigurablePlanObjectViewModels().map(e=>e.isInitDone()),...n.getConfigurableConstructionPlanObjectViewModels().map(e=>e.isInitDone())])]);const i=n.getPlanObjectViewModelsFromRapiId().map(e=>e.getId()).filter(e=>!s[e]);return this.planInteractionHandler.endInteraction(),i}duplicateItems(e){const t=new this.kernelContainer.PlanObjectPtrList;return e.forEach(e=>{t.push_back(e)}),this.planInteractionHandler.duplicatePlanObjects(t,1,!0)}_rapiItemToKernelItem(e){let t=new this._kernelContainer.CatalogItem(e.id),n=t.size;return n.x=e.width||0,n.y=e.depth||0,n.z=e.height||0,t.size=n,t.flipable=e.flipable,e.layer&&(t.layer=e.layer),t.orderable=e.orderable,t.scaleable=e.scaleable,t.type=e.type||"other",t.detailType=e.detailType||t.type||"other",t.configuration=e.configuration||"",t}planObjectDeleted(){}requestPlanObjectDimensions(){}cleanUpCallbacks(){var e;super.cleanUpCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.unregisterPlannerCallback)&&this._kernelContainer.unregisterPlannerCallback(this)}registerCallbacks(){var e;super.registerCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.registerPlannerCallback)&&this._kernelContainer.registerPlannerCallback(this)}planElementRemoved(e){this._plannerKernelCallbackListener.forEach(t=>t.planElementRemoved(e)),this._plannerKernelCallbackListener.forEach(t=>t.removePlanObjectFromScene(e.extRef.jsObject)),this._decoupleReferences(e)}handlerSwitchedPlans(e,t){this._decoupleReferences(e),t&&this._plannerKernelCallbackListener.forEach(n=>n.handlerSwitchedPlans(e,t))}planBoundsChanged(){this._plannerKernelCallbackListener.forEach(e=>e.planBoundsChanged())}planCleared(){this._plannerKernelCallbackListener.forEach(e=>e.planCleared())}planCompletelyLoaded(e){this._plannerKernelCallbackListener.forEach(t=>t.planCompletelyLoaded(e))}planElement3dMeshChanged(e,t){if(t.extRef){const e=t.extRef.jsObject;for(let t=e.getObject().children.length-1;t>=0;t--)e.getObject().remove(e.getObject().children[t])}this.planModelViewHelper.requestMesh3d(t)}async _onStaticItemAdded(e,t){let n;n=this.isConstructionPlanElement(t)?new To(t):new xr(t),this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n);const s=t.getCatalogItemId();if(s){const e=await this._rapiAccess.getItem(s);n.setRapiItem(e),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}}_onConfigurableItemAdded(e,t){const n=new wr(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}_onConfigurableConstructionItemAdded(e,t){const n=new Eo(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}async planElementAdded(e,t){if(e&&e.extRef)if(t.getType()===this._kernelContainer.PlanElementType.OBJECT){const n=t.getConfigurationRuntimeId();t.hasConfiguration()||n>0?"door"===t.getObjectType()||"window"===t.getObjectType()?this._onConfigurableConstructionItemAdded(e,t):this._onConfigurableItemAdded(e,t):await this._onStaticItemAdded(e,t)}else{const n=t;let s;if(t.getType()===this._kernelContainer.PlanElementType.WALL?s=new Cr(n):t.getType()===this._kernelContainer.PlanElementType.FLOOR?s=new Tr(n):t.getType()===this._kernelContainer.PlanElementType.CEILING?s=new Ar(n):t.getType()===this._kernelContainer.PlanElementType.NODE?s=new bo(n):t.getType()===this._kernelContainer.PlanElementType.MEASURE&&(s=new Ro(n)),!s)return;this.coupleReferences(s,n),e.extRef.jsObject.addPlanElementViewModel(s),this.planModelViewHelper.requestMesh3d(t),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(null))}}planElementChanged(e,t){if(t.extRef){let n=t.extRef.jsObject;n.update(),this._plannerKernelCallbackListener.forEach(t=>t.planElementChanged(e,n))}}planHistoryStateChanged(){this.planInteractionHandler&&(this._plannerKernelCallbackListener.forEach(e=>e.planHistoryStateChanged()),this._roomlePlannerUiCallback.onHistoryChange(this.planInteractionHandler.isUndoPossible(),this.planInteractionHandler.isRedoPossible()))}planObjectConfigurationCreated(e,t){}planObjectConfigurationLoaded(e,t,n){e&&e.extRef&&t&&t.extRef&&t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId()>0&&this._plannerKernelCallbackListener.forEach(s=>s.planObjectConfigurationLoaded(e,t,n))}requestCatalogItem(e){}startedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.startedDrawing())}stoppedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.stoppedDrawing())}updateMesh2d(){}beginConstruction(){}addMesh(e,t,n,s,i,a){this._plannerKernelCallbackListener.forEach(r=>r.addMesh(e,t,n,s,i,a))}endConstruction(){}beginPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.beginPlanConstruction(e))}addPlanMesh(e,t,n,s,i,a,r){this._plannerKernelCallbackListener.forEach(o=>o.addPlanMesh(e,t,n,s,i,a,r))}endPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.endPlanConstruction(e))}async addPlanObjectFromItem(e,t,n){if(!t&&!n){const t=await this.insertItems([e]);if(1!==t.length)throw new Error("It was expected that 1 element is added but"+t.length+"were added");return t[0]}n=n||0===n?n:0,t=t||{x:0,y:0,z:0};const s=this._planInteractionHandler.addPlanObjectFromItem(this._rapiItemToKernelItem(e),t,n,!1),i=this._planInteractionHandler.getPlan().extRef.jsObject;let a;return s.hasConfiguration()?(a=i.getConfigurablePlanObjectForId(s.getId()),a||console.warn("Could not find configuration")):(a=i.getStaticPlanObjectViewModelForId(s.getId()),a?await a.setRapiItem(e):console.warn("Could not find static item")),await a.isInitDone(),a.getId()}coupleReferences(e,t){let n=new this._kernelContainer.EMSReference;n.jsObject=e,t.extRef=n}_decoupleReferences(e){e&&e.extRef&&(e.extRef.jsObject.clearReference(),e.extRef.jsObject=null,e.extRef.delete(),e.extRef=null)}isConstructionPlanElement(e){return e instanceof this.kernelContainer.ConstructionObject}}e("P",Io),on([hn],Io.prototype,"_kernelAccessCallback",void 0),on([hn],Io.prototype,"_roomlePlannerUiCallback",void 0);class Do extends Ka{constructor(e){super(e),this._wallMeshes=[],this._defaultMaterial=Oi.createMeshPhysicalMaterial({color:"#ffffff",side:F})}generateGeometry(e=null,t,n,s,i,a=!1){let r;return r=a?this._generateGeometry(e,t,n,s,i).clone():this._generateGeometry(e,t,n,s,i),r}generateMesh(e=0,t=null,n,s,i,a,r,o,l=!1,h){let d;d=l?this._generateGeometry(t,s,i,a,r).clone():this._generateGeometry(t,s,i,a,r);const c=this._createMesh(e,t,d);return c.userData.materialId=n,c.layers.set(4),c.userData.isPlanFloor=o&&3===o.value,c.userData.isPlanWall=o&&1===o.value,n&&this.setMaterial(c,n,o,h).then(()=>{e&&t&&n&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n),c.castShadow=!c.userData.isPlanFloor&&!c.userData.isPlanWall}),this._checkWallMaterial(c,o),c}async setMaterial(e,t,n,s){if(e.userData.materialId=ra(t,n),ft(t))t?await this._assignMaterial(e,t,s):(console.warn("Used default material because material is empty"),this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)));else{if(!t)return void this.changeMaterialOfMesh(e,this._configuratorPreviewMaterial);2===(t=t).getSourceType().value?await this._assignMaterial(e,t.materialId,s):1===t.getSourceType().value?await this._assignItem(e,t.catalogItemId):3===t.getSourceType().value?await this._assignRGB(e,t.rgbValue):0===t.getSourceType().value?this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)):(this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)),1!==n.value&&7!==n.value&&3!==n.value&&console.warn("Used default material because material is not supported",t))}}_getDefaultMaterial(e){return 3===(null==e?void 0:e.value)?this._defaultMaterialFloor:this._defaultMaterial}set maxAnisotropy(e){this._maxAnisotropy=e}_checkWallMaterial(e,t){t&&1===t.value&&(e.renderOrder=5,this._wallMeshes.push(e))}clear(){super.clear(),this.clearWallMeshes()}clearWallMeshes(){this._wallMeshes.forEach(e=>{na(e)}),this._wallMeshes=[]}get wallMeshes(){return this._wallMeshes}}e("ax",Do);let Oo={InchFeet:null,Feet:null,MM:null,CM:null,Inch:null},Lo={NoUnitString:null,LongUnitString:null,ShortUnitString:null};const ko=["mm","cm","feet"],Uo=["inch","inchfeet"];class Bo{constructor(e){this._formatter=null,this._precision=0,this._creator_=e}init(e){const t=new e.UnitMeasureFormatter;Oo=e.Unit,Lo=e.UnitStringType,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType();const{precisionCm:n,precisionInch:s}=this._initData;this._actualUnit===Oo.InchFeet?this._precision=void 0!==s?parseInt(s,10):2:this._actualUnit===Oo.CM&&(this._precision=void 0!==n?parseInt(n,10):1),t.init("mm","cm","'","ft",'"',"inch","m²","sqft",!0,this._precision,!0),this._formatter=t}_initMeasurementSystemType(){let{measurementSystem:e,unit:t}=this._initData;if(this._actualMeasurementString=e,e||!t){if("metric"===e){t||(t="cm");const e=ko.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not a metric unit, using CM"),this._actualUnit=Oo.CM,this._actualUnitString="cm")}if("imperial"===e){t||(t="inch");const e=Uo.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not an imperial unit, using Inches"),this._actualUnit=Oo.Inch,this._actualUnitString="inch")}}else{this._actualUnitString=t;const e=ko.find(e=>e===t);this._actualMeasurementString=e?"metric":"imperial"}}_initActualUnit(){const{unit:e}=this._initData;this._actualUnit=this._getKernelUnitEnum(e)}_getKernelUnitEnum(e){switch(e){case"cm":return Oo.CM;case"mm":return Oo.MM;case"inchfeet":return Oo.InchFeet;case"feet":return Oo.Feet;case"inch":return Oo.Inch;default:return Oo.CM}}_initActualUnitStringType(){const{unitStringType:e}=this._initData;e&&"short"!==e&&console.warn("Only short unit strings is supported at the moment"),this._actualUnitStringType=Lo.ShortUnitString}_isFormatterReady(){return!!this._formatter||(console.warn("Formatter is not ready..."),!1)}formatAngleValueToUnitString(e,t){const n="Integer"===t.type?0:2;return e.toFixed(n)+"°"}parseAngleValueFromUnitString(e){return e.replace("°","").replace(/\s/g,"")}parseValue(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?e:"length"===t.unitType?this.parseMMValueFromUnitString(e,t.unitType):"angle"===t.unitType||"area"===t.unitType?this.parseAngleValueFromUnitString(e):e}formatValueToUnitString(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?"Integer"===t.type?e.toString():parseFloat(e.toString()).toFixed(2):"length"===t.unitType?this.formatMMValueToUnitString(e,t.unitType):"angle"===t.unitType?this.formatAngleValueToUnitString(e,t):"area"===t.unitType?this.formatSquareMMValueToUnitString(e):e}isParseableNumber(e){return this._isFormatterReady()?this._formatter.isParseableNumber(e):null}isParseableUnitString(e,t){return this._isFormatterReady()?"angle"===t.unitType?this._formatter.isParseableUnitString(this.parseAngleValueFromUnitString(e),this._actualUnit):this._formatter.isParseableUnitString(e,this._actualUnit):null}parseMMValueFromUnitString(e,t){return this._isFormatterReady()?"count"===t?parseFloat(e):this._formatter.parseMMValueFromUnitString(e,this._actualUnit):null}parseNumber(e){return this._isFormatterReady()?this._formatter.parseNumber(e):null}formatNumber(e,t=0){return this._isFormatterReady()?this._formatter.formatNumber(e,t):null}formatSquareMMValueToUnitString(e){return this._isFormatterReady()?this._formatter.formatSquareMMValueToUnitString(e,this._actualUnit):null}formatMMValueToUnitString(e,t){return this._isFormatterReady()?"count"===t?e.toString():this._formatter.formatMMValueToUnitString(e,this._actualUnit,this._actualUnitStringType):null}formatMMValueWithReqMaxLength(e,t){return this._isFormatterReady()?this._formatter.formatMMValueWithReqMaxLength(e,this._actualUnit,t):null}_formatParameterValue(e,t){return"length"===t?this.formatMMValueToUnitString(parseFloat(e)):"area"===t?this.formatSquareMMValueToUnitString(parseFloat(e)):e}formatPartListParameter(e){(function(e){return"length"===e.unitType||"area"===e.unitType})(e)&&(e.valueLabel=this._formatParameterValue(e.value,e.unitType))}formatParameter(e){if(e.valueLabel=this._formatParameterValue(e.value,e.unitType),Br(e))e.uiType="Material";else if(function(e){return"Boolean"===e.type}(e))e.uiType="Boolean";else if(kr(e)){e.uiType="Range";const t=null!==e.validRange.valueFrom?e.validRange.valueFrom:Number.MIN_SAFE_INTEGER,n=null!==e.validRange.valueTo?e.validRange.valueTo:Number.MAX_SAFE_INTEGER;e.validRangeLabels={valueFrom:this._formatParameterValue(t.toString(),e.unitType),valueTo:this._formatParameterValue(n.toString(),e.unitType),type:e.validRange.type}}else Ur(e)?(e.uiType="Options",function(e){return!!Ur(e)&&Array.isArray(e.validValues)&&e.validValues.length>0&&"string"==typeof e.validValues[0].thumbnail}(e)&&(e.uiType="Thumbnails")):(console.error("Could not detect uiType of param"),e.uiType=null)}isInch(){return this._actualUnit===Oo.InchFeet}getActualUnitString(){return this._actualUnitString}getActualMeasurementString(){return this._actualMeasurementString}getUnitStringType(){return this._initData.unitStringType}getPrecision(){return this._precision}getAllowedDelta(){const e=1/Math.pow(10,this._precision);return this.isInch()?25.4*e:e}setUnitInitData(e,t=""){this._initData.unit=e,this._initData.measurementSystem=t,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType(),this._plannerKernelAccess.kernelInstance.setEnvironmentVariable("unit",this._actualUnitString)}}on([hn],Bo.prototype,"_initData",void 0),on([hn],Bo.prototype,"_plannerKernelAccess",void 0);class No{constructor(e){this._history=[],this._index=0,this._creator_=e}undo(){if(!this.canUndo())return null;this._index++;const[e]=this._history.slice(this._index);return this._index===this._history.length-1?this._configuratorUiCallbacks.onHistoryChange(!1,!0):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}redo(){if(!this.canRedo())return null;this._index--;const[e]=this._history.slice(this._index);return 0===this._index?this._configuratorUiCallbacks.onHistoryChange(!0,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}push(e){const[t]=this._history.slice(this._index);t!==e&&(this._history=this._history.slice(this._index),this._history.unshift(e),this._index=0,1===this._history.length?this._configuratorUiCallbacks.onHistoryChange(!1,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!1))}canUndo(){return this._index!==this._history.length-1}canRedo(){return 0!==this._index}getHistory(){return this._history}clearHistory(){this._history=[],this._index=0,this._configuratorUiCallbacks.onHistoryChange(!1,!1)}}on([hn],No.prototype,"_configuratorUiCallbacks",void 0),e("aj",{ADDED:"added",CHANGED:"changed",REMOVED:"removed"});class Fo{constructor(e){this._kernelCallbacks={isReady:()=>{},throw:e=>console.error("Kernel exception",e),log:e=>{},error:(e,t,n,s)=>{},message:e=>{this._analyzeComponentCallback&&this._analyzeComponentCallback(e)}},this._creator_=e}async init(){if(this._toolsCoreInstance)return Promise.resolve();const e=this,t={locateFile:e=>"RoomleToolsCore.wasm"===e?n()+"static/RoomleToolsCore-3ed4fcaccf294e37.wasm":e,wasmBinaryFile:n()+"static/RoomleToolsCore-3ed4fcaccf294e37.wasm",preRun:[],postRun:[],setStatus:null,print(t){e._kernelIo.log(t)},printErr(t){e._kernelIo.error(t)},quit(t){0!==t&&e._kernelIo.throw(t&&t.toString?t.toString():"Unknown error while C/C++ main executes")}};await this._scriptLoader.fetch("static/RoomleToolsCore-354feeb929ea1598.js",{id:"core-tool"});const s=await window.RoomleToolsCore(t);s.setContext(this._kernelCallbacks),this._toolsCoreInstance=new s.ToolsCore}analyzeComponent(e,t){const n=[];return this._analyzeComponentCallback=e=>{n.push(e)},this._toolsCoreInstance.analyzeComponent(e,t),this._analyzeComponentCallback=null,Promise.resolve(n)}}on([hn],Fo.prototype,"_scriptLoader",void 0),on([hn],Fo.prototype,"_kernelIo",void 0);
1
+ System.register(["./main-thread-to-worker-ff04af1e.nomodule.js"],(function(e,t){var n,s,i,a,r,o,l,h,d,c,u,p,m,g,f,_,v,w,b,y,S,x,P,M,C,T,A,R,E,I,D,O,k,L,U,B,N,F,G,j,z,V,H,W,K,q,X,Y,Q,Z,J,$,ee,te,ne,se,ie,ae,re,oe,le,he,de,ce,ue,pe,me,ge,fe,_e,ve,we,be,ye,Se,xe,Pe,Me,Ce,Te,Ae,Re,Ee,Ie,De,Oe,ke,Le,Ue,Be,Ne,Fe,Ge,je,ze,Ve,He,We,Ke,qe,Xe,Ye,Qe,Ze,Je,$e,et,tt,nt,st,it,at,rt,ot,lt,ht,dt,ct,ut,pt,mt,gt,ft,_t,vt,wt,bt,yt,St,xt,Pt,Mt,Ct,Tt,At,Rt,Et,It,Dt,Ot,kt,Lt,Ut,Bt,Nt,Ft,Gt,jt,zt,Vt,Ht,Wt,Kt,qt;return{setters:[function(e){n=e.g,s=e.A,i=e.D,a=e.V,r=e.a,o=e.R,l=e.S,h=e.C,d=e.M,c=e.B,u=e.b,p=e.T,m=e.c,g=e.d,f=e.L,_=e.e,v=e.F,w=e.f,b=e.P,y=e.h,S=e.i,x=e.j,P=e.k,M=e.Q,C=e.I,T=e.l,A=e.O,R=e.m,E=e.n,I=e.o,D=e.p,O=e.q,k=e.r,L=e.s,U=e.t,B=e.u,N=e.v,F=e.w,G=e.x,j=e.y,z=e.z,V=e.E,H=e.G,W=e.H,K=e.J,q=e.K,X=e.N,Y=e.U,Q=e.W,Z=e.X,J=e.Y,$=e.Z,ee=e._,te=e.$,ne=e.a0,se=e.a1,ie=e.a2,ae=e.a3,re=e.a4,oe=e.a5,le=e.a6,he=e.a7,de=e.a8,ce=e.a9,ue=e.aa,pe=e.ab,me=e.ac,ge=e.ad,fe=e.ae,_e=e.af,ve=e.ag,we=e.ah,be=e.ai,ye=e.aj,Se=e.ak,xe=e.al,Pe=e.am,Me=e.an,Ce=e.ao,Te=e.ap,Ae=e.aq,Re=e.ar,Ee=e.as,Ie=e.at,De=e.au,Oe=e.av,ke=e.aw,Le=e.ax,Ue=e.ay,Be=e.az,Ne=e.aA,Fe=e.aB,Ge=e.aC,je=e.aD,ze=e.aE,Ve=e.aF,He=e.aG,We=e.aH,Ke=e.aI,qe=e.aJ,Xe=e.aK,Ye=e.aL,Qe=e.aM,Ze=e.aN,Je=e.aO,$e=e.aP,et=e.aQ,tt=e.aR,nt=e.aS,st=e.aT,it=e.aU,at=e.aV,rt=e.aW,ot=e.aX,lt=e.aY,ht=e.aZ,dt=e.a_,ct=e.a$,ut=e.b0,pt=e.b1,mt=e.b2,gt=e.b3,ft=e.b4,_t=e.b5,vt=e.b6,wt=e.b7,bt=e.b8,yt=e.b9,St=e.ba,xt=e.bb,Pt=e.bc,Mt=e.bd,Ct=e.be,Tt=e.bf,At=e.bg,Rt=e.bh,Et=e.bi,It=e.bj,Dt=e.bk,Ot=e.bl,kt=e.bm,Lt=e.bn,Ut=e.bo,Bt=e.bp,Nt=e.bq,Ft=e.br,Gt=e.bs,jt=e.bt,zt=e.bu,Vt=e.bv,Ht=e.bw,Wt=e.bx,Kt=e.by,qt=e.bz}],execute:function(){e({G:po,_:on,i:hn});class Xt{constructor(){this._context=new Map,this._lookups=new Map,this._singletons=new Map}getContext(e){if(this._context.has(e)){const t=this._context.get(e);return this._context.set(e,t+1),e+t}return this._context.set(e,1),e+0}addDependencyInjectionAssignments(e){e.forEach(e=>{this._lookups.set(e.className,e)})}lookup(e,t){if(!this._lookups.has(e))return null;const n=this._lookups.get(e);if(1===n.type&&void 0===t){const t="Dependency "+e+" has definition context but no context was defined!";return console.trace(t),console.error(t),null}let s=t&&1===n.type?t:"global";if(s+="_"+e,2===n.type)return new n.classDefinition;if(this._singletons.has(s))return this._singletons.get(s);const i=new n.classDefinition(t);return this._singletons.set(s,i),i}cleanUp(e){if(e){let t=[];this._singletons.forEach((n,s)=>{s.startsWith(e)&&t.push(s)}),t.forEach(e=>{this._singletons.delete(e)})}else this._singletons.clear(),this._singletons=new Map}}class Yt{constructor(e,t,n){this.className=e,this.classDefinition=t,this.type=void 0===n?0:n}}e("D",Yt);const Qt={JPG:".jpg",JPEG:".jpeg",PNG:".png",GIF:".gif"};class Zt{_base64toBlob(e,t){t=t||"";const n=atob(e),s=n.length,i=Math.ceil(s/1024),a=new Array(i);for(let e=0;e<i;++e){let t=1024*e,i=Math.min(t+1024,s);const r=new Array(i-t);for(let e=t,s=0;e<i;++s,++e)r[s]=n[e].charCodeAt(0);a[e]=new Uint8Array(r)}return new Blob(a,{type:t})}_createFormData(e,t,n,s){const i=new FormData;-1!==e.indexOf(",")&&(e=e.substr(e.indexOf(",")+1));const a=-1===Object.keys(Qt).map(e=>Qt[e]).indexOf(n)?"application":"image",r=this._base64toBlob(e,a+"/"+n.substr(1));return i.append(s,r,t+n),i}create(e,t,n,s){return this._createFormData(e,t,n,s)}}const Jt=e("r",{SOFA:"sofa",SHELF:"shelf",SHELF_FRONT:"shelf_front",BAKED:"baked",CAMERA:"camera",EQUAL:"equal"});class $t{static createDynamicLightSettingSource(e,t){let s={};if(e)s.url=e;else if(t)switch(t){case Jt.SHELF:s.url=n()+"static/shelf-2975dd3f2fa9c763.json";break;case Jt.SHELF_FRONT:s.url=n()+"static/shelf_front-8c9566a4512f0de8.json";break;case Jt.SOFA:s.url=n()+"static/sofa-997b116bc5f2e92e.json";break;case Jt.BAKED:s.url=n()+"static/baked-6485a2b1daeb69e8.json";break;case Jt.CAMERA:s.url=n()+"static/camera-05824b47cdb951e4.json";break;case Jt.EQUAL:s.url=n()+"static/equal-319f6b83c827913f.json";break;default:s.url=n()+"static/camera-05824b47cdb951e4.json"}else s=null;return s}parse(e){let t=JSON.parse(e);return t.lights?this.load(t):[]}load(e){let t=[];return e.lights?(e.lights.forEach(e=>{let n;switch(e.type){case"ambient":n=this._parseAmbientLight(e);break;case"rectarea":n=this._parseRectAreaLight(e);break;case"spot":n=this._parseSpotLight(e);break;case"directional":n=this._parseDirectionalLight(e)}n&&t.push(n)}),t):[]}_parseAmbientLight(e){let t=new s;return this._parseCommon(t,e),t}_parseRectAreaLight(e){let{intensity:t,castShadow:n,target:s,width:l,height:h}=e,d=null;if(n&&$t.rectAreaLightReplacement){const n=new i;this._parseCommon(n,e),d=n,n.castShadow=!0,n.shadow.camera.near=.1,n.shadow.camera.far=100,n.shadow.mapSize=new a(1024,1024),n.shadow.bias=-5e-5,n.shadow.normalBias=.01,n.intensity=t?t/100:1,n.lookAt(s?new r(s.x,s.y,s.z):new r(0,0,0))}else{const n=new o;this._parseCommon(n,e),d=n,n.width=l||.8,n.height=h||.8,n.castShadow=!1,n.matrixAutoUpdate=!0,n.intensity=(t||240)/((l||.8)*(h||.8)),n.lookAt(s?new r(s.x,s.y,s.z):new r(0,0,0)),$t.rectAreaLightLoadingListener&&$t.rectAreaLightLoadingListener(n)}return d}_parseSpotLight(e){let t=new l;this._parseCommon(t,e);let{angle:n,penumbra:s,target:i,castShadow:o}=e;return t.angle=(n||100)*Math.PI/180,t.penumbra=s||.5,t.lookAt(i?new r(i.x,i.y,i.z):new r(0,0,0)),t.shadow.camera.near=.1,t.shadow.camera.far=10,t.shadow.mapSize=new a(1024,1024),t.castShadow=o||!1,t}_parseDirectionalLight(e){let t=new i;this._parseCommon(t,e);let{target:n,castShadow:s}=e;return t.castShadow=s||!1,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize=new a(1024,1024),t.shadow.bias=-5e-5,t.lookAt(n?new r(n.x,n.y,n.z):new r(0,0,0)),t}_parseCommon(e,t){let{name:n,intensity:s,color:i,position:a,movesWithCamera:o}=t;e.name=n||"",e.intensity=s||1,e.color=new h(i||"#ffffff"),e.position.copy(a?new r(a.x,a.y,a.z):new r(0,0,0)),e.visible=!0,e.layers.set(1),e.userData.movesWithCamera=o}}e("q",$t),$t.rectAreaLightReplacement=!0;const en=e("z",()=>{var e;const t=(()=>{if(window.__RML__ENV__&&window.__RML__ENV__.skipIframeCheck)return!1;try{return window.self!==window.top}catch(e){return!0}})();let n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href;if(!n)return null;if(t){if(!document.referrer)return null;n=document.referrer}const{hostname:s}=new URL(n);return s}),tn=["127.0.0.1","localhost","0.0.0.0"],nn=(e("O",(function(e){return!(!e||"string"!=typeof e||e.split(":").length>2)})),e("K",e=>{if(!e||"string"!=typeof e)return null;const t=e.split(":");return t.length<2?null:t[0]})),sn=({articleNr:e,componentId:t})=>e&&""!==e?t.split(":")[0]+":"+e:null,an=(e,t)=>null!=e?"string"==typeof e?"true"===e:!0===e:("string"==typeof t&&(t=parseInt(t,10)),t>=200&&t<300);class rn{constructor(){this._queue=[],this._pendingRequests=0}_nextSlot(){if(this._pendingRequests-=1,!this._queue.length)return;const{request:e,resolve:t,reject:n}=this._queue.shift();this._fetch(e).then(t,n)}_fetch(e,t={},n={}){return this._pendingRequests+=1,new Promise((s,i)=>{self.fetch(e,t).then(async function(e){this._nextSlot();const t=!n.checkResponse||!1!==await n.checkResponse(e);if(an(e.ok,e.status)&&t)s(...arguments);else{const t=(null==e?void 0:e.url)||"URL unknown";i(new Error(e.statusText||'Http error "'+(e&&e.status?e.status:"unknown")+'", for "'+t+'"'))}}.bind(this),e=>{this._nextSlot(),i(e)})})}fetch(e,t={},n={}){return this._pendingRequests>=40?new Promise((t,n)=>this._queue.push({request:e,resolve:t,reject:n})):this._fetch(e,t,n)}}function on(e,t,n,s){var i,a=arguments.length,r=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,s);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(r=(a<3?i(r):a>3?i(t,n,r):i(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}"function"==typeof SuppressedError&&SuppressedError;const ln=function(e){return e.startsWith("_")&&(e=e.substr(1)),e.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(function(e,t){return(t>0?"-":"")+e.toLowerCase()}))};function hn(e,t){const n=Symbol("property-cache");Object.defineProperty(e,t,{get(){if(!this[n]){const e=window.__RML__DI__.lookup(ln(t),this._creator_);e?this[n]=e:console.error("Dependency "+ln(t)+" not found! Add dependency to /utils/injectables.ts")}return this[n]}})}class dn{info(...e){console}log(...e){console}warn(...e){console.warn.apply(console,e)}error(...e){console.warn.apply(console,e)}}e("L",dn);class cn extends dn{constructor(e){super(),this._creator_=e}setMeta(e){this._meta=e}get meta(){return this._meta?this._meta:{}}throw(e){const t="[Kernel Exception]: "+e;this._globalCallback.onKernelMsg("exception",e,this.meta),this.error(t)}error(e){this._globalCallback.onKernelMsg("error",e,this.meta),super.error(e)}warn(e){this._globalCallback.onKernelMsg("warning",e,this.meta),super.warn(e)}}on([hn],cn.prototype,"_globalCallback",void 0);const un=new Map,pn=new Map,mn=new Map,gn=new Map;class fn{constructor(e){this._bootCallbacks=[],this._isStarted=!1,this._isStarting=!1,this._alwaysUseCache=!1,this._creator_=e}start(e){return this._configuratorUiCallbacks.onSyncStarted(),this._startWorker().then(()=>this._handleCatalog(e)).then(()=>{const{typeChangeTag:e,floorMaterialsTag:t}=this._initData;Promise.all([this._syncFloorTag(t),this._syncTypeChangeTag(e)]).then(()=>{gn.set(e,!0),this._configuratorUiCallbacks.onSyncDone()})})}syncCatalog(e){return this._startWorker().then(()=>this._handleCatalog(e))}syncFloorTag(e){return this._startWorker().then(()=>this._syncFloorTag(e))}syncTypeChangeTag(e){return this._startWorker().then(()=>this._syncTypeChangeTag(e))}_syncFloorTag(e){const t=[];return e&&!mn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{t.push(this._handleMaterialsAndTextures(e))}),this._singlePromiseFactory.create(1,e,n=>{Promise.all(t).then(()=>{mn.set(e,!0),n()},e=>this._softReject(n,'_syncFloorTag error: "'+e+'"'))})):Promise.resolve()}_syncTypeChangeTag(e){const t=[];return e&&!gn.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{this._rapiAccess.getItems(e.items).then(e=>{e.forEach(e=>{this.getIsCatalogSynced(e.catalog)&&t.push(this._handleCatalog(e.catalog))})})}),this._singlePromiseFactory.create(2,e,n=>{Promise.all(t).then(()=>{mn.set(e,!0),n()},e=>this._softReject(n,'_syncTypeChangeTag error: "'+e+'"'))})):Promise.resolve()}getIsCatalogSynced(e){return!!pn.get(e)}_startWorker(){return new Promise((e,t)=>{if(this._isStarted)return e();this._bootCallbacks.push({resolve:e,reject:t}),this._isStarting||(this._worker=new Worker(n()+"static/asset-loader.worker-1735a5fb1e401244.js"),this._mainThreadToWorker=new d(this,this._worker),this._isStarting=!0,this._mainThreadToWorker.sendToWorker(1))})}onCommand(e,t,n){switch(e){case 4:this._isStarted=!0,this._bootCallbacks.forEach(({resolve:e})=>e());break;case 3:this._mainThreadToWorker.resolvePromises(t,n)}}_handleCatalog(e){return this._singlePromiseFactory.create(0,e,t=>this.getIsCatalogSynced(e)?t():this._rapiAccess.getCatalog(e).then(e=>Promise.all([this._handleContentWithAssets(this._rapiAccess.getComponentsOf(e),["perspectiveImage"]),this._handleItemsAndAdditionalContents(e),this._handleMaterialsAndTextures(e),this._handleExternalMeshes(e),this._handleTags(e.tags)])).then(()=>{pn.set(e,!0),t()},e=>this._softReject(t,'Catalog sync error: "'+e+'"')))}_handleTags(e){return this._handleContentWithAssets(this._rapiAccess.getTags(e),["pngIcon","svgIcon"])}_handleExternalMeshes(e){return new Promise(t=>{this._rapiAccess.getMeshesOfCatalog(e.id).then(e=>{const n=[];e.forEach(e=>{n.push(this._handleContentWithAssets(Promise.all([this._rapiAccess.getMesh(e.id)]),["url"]))}),Promise.all(n).then(t,e=>this._softReject(t,'Sync crt files error: "'+e+'"'))},e=>this._softReject(t,'getMeshesOfCatalog error: "'+e+'"'))})}_handleItemsAndAdditionalContents(e){return new Promise(t=>{this._rapiAccess.getItemsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["perspectiveImage"])),this._rapiAccess.getAdditionalContentsOfItems(e).then(e=>{const t=e.filter(e=>-1!==[5,6,4].indexOf(e.type));n.push(this._handleContentWithAssets(Promise.resolve(t),["content"]))},e=>this._softReject(t,'getAdditionalContentsOfItems error: "'+e+'"')),Promise.all(n).then(t,e=>this._softReject(t,'AdditionalContent image sync error:"'+e+'"'))})})}_handleMaterialsAndTextures(e){return new Promise(t=>{this._rapiAccess.getMaterialsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["thumbnail"])),e.forEach(e=>{n.push(this._handleContentWithAssets(this._rapiAccess.getTexturesOf(e),["image"]))}),Promise.all(n).then(t,e=>this._softReject(t,'getTexturesOf error: "'+e+'"'))},e=>this._softReject(t,'getMaterialsOf error: "'+e+'"'))})}_handleContentWithAssets(e,t){return new Promise(n=>e.then(e=>this._fetchAssets(e,t).then(n,e=>this._softReject(n,'_handleContentWithAssets error: "'+e+'"')),e=>this._softReject(n,'_handleContentWithAssets promise error: "'+e+'"')))}_fetchAssets(e,t){const n=[];e||(e=[]);for(let s=0,i=e.length;s<i;s++){const i=e[s];t.forEach(e=>{const t=i[e];t&&n.push(this._preCacheAsset(t))})}return Promise.all(n)}_preCacheAsset(e){return new Promise(t=>{if(un.get(e))return t();this._assetUrlToBase64(e).then(n=>{un.set(e,n),t()},e=>this._softReject(t,'_preCacheAsset error: "'+e+'"'))})}_assetUrlToBase64(e){return new Promise(t=>{this._mainThreadToWorker.sendToWorker(5,e,t,e=>this._softReject(t,'_assetUrlToBase64 error: "'+e+'"'))})}_softReject(e,t){this._errorHandler.softReject(e,t,2)}requestAsset(e,t=!1){return navigator.onLine&&!this._alwaysUseCache?e:un.get(e)||(t?e:null)}setAlwaysUseCache(e){this._alwaysUseCache=e}preFillAssetCache(e,t){un.set(e,t)}}e("a",fn),on([hn],fn.prototype,"_rapiAccess",void 0),on([hn],fn.prototype,"_singlePromiseFactory",void 0),on([hn],fn.prototype,"_errorHandler",void 0),on([hn],fn.prototype,"_configuratorUiCallbacks",void 0),on([hn],fn.prototype,"_initData",void 0);class _n{constructor(e){this.info=e,this._init()}_init(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){e&&this._resolve(e),this._resolve()}reject(e){this._reject(e)}wait(){return this._promise}reset(){this._init()}}function vn(e,t=!1){const n=null!==e[0].index,s=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},r={},o=e[0].morphTargetsRelative,l=new c;let h=0;for(let d=0;d<e.length;++d){const c=e[d];let u=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in c.attributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(c.attributes[e]),u++}if(u!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in c.morphAttributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;void 0===r[e]&&(r[e]=[]),r[e].push(c.morphAttributes[e])}if(t){let e;if(n)e=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;e=c.attributes.position.count}l.addGroup(h,e,d),h+=e}}if(n){let t=0;const n=[];for(let s=0;s<e.length;++s){const i=e[s].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[s].attributes.position.count}l.setIndex(n)}for(const e in a){const t=wn(a[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in r){const t=r[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let s=0;s<r[e].length;++s)t.push(r[e][s][n]);const s=wn(t);if(!s)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(s)}}return l}function wn(e){let t,n,s,i=-1,a=0;for(let r=0;r<e.length;++r){const o=e[r];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===s&&(s=o.normalized),s!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===i&&(i=o.gpuType),i!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=o.count*n}const r=new t(a),o=new u(r,n,s);let l=0;for(let t=0;t<e.length;++t){const s=e[t];if(s.isInterleavedBufferAttribute){const e=l/n;for(let t=0,i=s.count;t<i;t++)for(let i=0;i<n;i++){const n=s.getComponent(t,i);o.setComponent(t+e,i,n)}}else r.set(s.array,l);l+=s.count*n}return void 0!==i&&(o.gpuType=i),o}function bn(e,t){if(t===p)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===m||t===g){let n=e.getIndex();if(null===n){const t=[],s=e.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const s=n.count-2,i=[];if(t===m)for(let e=1;e<=s;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<s;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=e.clone();return a.setIndex(i),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}e("ah",_n);class yn extends f{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Tn(e)})),this.register((function(e){return new Un(e)})),this.register((function(e){return new Bn(e)})),this.register((function(e){return new Nn(e)})),this.register((function(e){return new Rn(e)})),this.register((function(e){return new En(e)})),this.register((function(e){return new In(e)})),this.register((function(e){return new Dn(e)})),this.register((function(e){return new Cn(e)})),this.register((function(e){return new On(e)})),this.register((function(e){return new An(e)})),this.register((function(e){return new Ln(e)})),this.register((function(e){return new kn(e)})),this.register((function(e){return new Pn(e)})),this.register((function(e){return new Fn(e)})),this.register((function(e){return new Gn(e)}))}load(e,t,n,s){const i=this;let a;if(""!==this.resourcePath)a=this.resourcePath;else if(""!==this.path){const t=_.extractUrlBase(e);a=_.resolveURL(t,this.path)}else a=_.extractUrlBase(e);this.manager.itemStart(e);const r=function(t){s?s(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},o=new v(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{i.parse(n,a,(function(n){t(n),i.manager.itemEnd(e)}),r)}catch(e){r(e)}}),n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const a={},r={},o=new TextDecoder;if("string"==typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===jn){try{a[xn.KHR_BINARY_GLTF]=new zn(e)}catch(e){return void(s&&s(e))}i=JSON.parse(a[xn.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new ds(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){const t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case xn.KHR_MATERIALS_UNLIT:a[t]=new Mn;break;case xn.KHR_DRACO_MESH_COMPRESSION:a[t]=new Vn(i,this.dracoLoader);break;case xn.KHR_TEXTURE_TRANSFORM:a[t]=new Hn;break;case xn.KHR_MESH_QUANTIZATION:a[t]=new Wn;break;default:n.indexOf(t)>=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(r),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise((function(s,i){n.parse(e,t,s,i)}))}}function Sn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const xn={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Pn{constructor(e){this.parser=e,this.name=xn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&void 0!==s.extensions[this.name].light&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const a=t.json,r=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let o;const d=new h(16777215);void 0!==r.color&&d.setRGB(r.color[0],r.color[1],r.color[2],w);const c=void 0!==r.range?r.range:0;switch(r.type){case"directional":o=new i(d),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new b(d),o.distance=c;break;case"spot":o=new l(d),o.distance=c,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,o.angle=r.spot.outerConeAngle,o.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return o.position.set(0,0,0),o.decay=2,is(o,r),void 0!==r.intensity&&(o.intensity=r.intensity),o.name=t.createUniqueName(r.name||"light_"+e),s=Promise.resolve(o),t.cache.add(n,s),s}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],i=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class Mn{constructor(){this.name=xn.KHR_MATERIALS_UNLIT}getMaterialType(){return y}extendParams(e,t,n){const s=[];e.color=new h(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],w),e.opacity=t[3]}void 0!==i.baseColorTexture&&s.push(n.assignTexture(e,"map",i.baseColorTexture,S))}return Promise.all(s)}}class Cn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name].emissiveStrength;return void 0!==s&&(t.emissiveIntensity=s),Promise.resolve()}}class Tn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],r=s.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new a(e,e)}return Promise.all(i)}}class An{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(t.iridescenceIOR=a.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(i)}}class Rn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=s.extensions[this.name];if(void 0!==a.sheenColorFactor){const e=a.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],w)}return void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,S)),void 0!==a.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(i)}}class En{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(i)}}class In{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const r=a.attenuationColor||[1,1,1];return t.attenuationColor=(new h).setRGB(r[0],r[1],r[2],w),Promise.all(i)}}class Dn{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=n.extensions[this.name];return t.ior=void 0!==s.ior?s.ior:1.5,Promise.resolve()}}class On{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const r=a.specularColorFactor||[1,1,1];return t.specularColor=(new h).setRGB(r[0],r[1],r[2],w),void 0!==a.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,S)),Promise.all(i)}}class kn{constructor(e){this.parser=e,this.name=xn.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return t.bumpScale=void 0!==a.bumpFactor?a.bumpFactor:1,void 0!==a.bumpTexture&&i.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(i)}}class Ln{constructor(e){this.parser=e,this.name=xn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?x:null}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],a=s.extensions[this.name];return void 0!==a.anisotropyStrength&&(t.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(t.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(i)}}class Un{constructor(e){this.parser=e,this.name=xn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,a)}}class Bn{constructor(e){this.parser=e,this.name=xn.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const a=i.extensions[t],r=s.images[a.source];let o=n.textureLoader;if(r.uri){const e=n.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,a.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Nn{constructor(e){this.parser=e,this.name=xn.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const a=i.extensions[t],r=s.images[a.source];let o=n.textureLoader;if(r.uri){const e=n.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,a.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class Fn{constructor(e){this.name=xn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],s=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then((function(t){const n=e.byteOffset||0,s=e.byteLength||0,a=e.count,r=e.byteStride,o=new Uint8Array(t,n,s);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,r,o,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(a*r);return i.decodeGltfBuffer(new Uint8Array(t),a,r,o,e.mode,e.filter),t}))}))}return null}}class Gn{constructor(e){this.name=xn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const s=t.meshes[n.mesh];for(const e of s.primitives)if(e.mode!==Yn.TRIANGLES&&e.mode!==Yn.TRIANGLE_STRIP&&e.mode!==Yn.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,a=[],o={};for(const e in i)a.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],s=e[0].count,i=[];for(const e of n){const t=new P,n=new r,a=new M,l=new r(1,1,1),h=new C(e.geometry,e.material,s);for(let e=0;e<s;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&l.fromBufferAttribute(o.SCALE,e),h.setMatrixAt(e,t.compose(n,a,l));for(const t in o)if("_COLOR_0"===t){const e=o[t];h.instanceColor=new T(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);A.prototype.copy.call(h,e),this.parser.assignFinalMaterial(h),i.push(h)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}}const jn="glTF";class zn{constructor(e){this.name=xn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==jn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let a=0;for(;a<s;){const t=i.getUint32(a,!0);a+=4;const s=i.getUint32(a,!0);if(a+=4,1313821514===s){const s=new Uint8Array(e,12+a,t);this.content=n.decode(s)}else if(5130562===s){const n=12+a;this.body=e.slice(n,n+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Vn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=xn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,r={},o={},l={};for(const e in a){const t=es[e]||e.toLowerCase();r[t]=a[e]}for(const t in e.attributes){const s=es[t]||t.toLowerCase();if(void 0!==a[t]){const i=n.accessors[e.attributes[t]],a=Qn[i.componentType];l[s]=a.name,o[s]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t,n){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],s=o[t];void 0!==s&&(n.normalized=s)}t(e)}),r,l,w,n)}))}))}}class Hn{constructor(){this.name=xn.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Wn{constructor(){this.name=xn.KHR_MESH_QUANTIZATION}}class Kn extends _e{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let e=0;e!==s;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,a=this.sampleValues,r=this.valueSize,o=2*r,l=3*r,h=s-t,d=(n-t)/h,c=d*d,u=c*d,p=e*l,m=p-l,g=-2*u+3*c,f=u-c,_=1-g,v=f-c+d;for(let e=0;e!==r;e++){const t=a[m+e+r],n=a[m+e+o]*h,s=a[p+e+r],l=a[p+e]*h;i[e]=_*t+v*n+g*s+f*l}return i}}const qn=new M;class Xn extends Kn{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return qn.fromArray(i).normalize().toArray(i),i}}const Yn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Qn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Zn={9728:ne,9729:D,9984:se,9985:ie,9986:ae,9987:O},Jn={33071:re,33648:oe,10497:k},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},es={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ns={CUBICSPLINE:void 0,LINEAR:ee,STEP:le};function ss(e,t,n){for(const s in n.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=n.extensions[s])}function is(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function as(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,s=t.weights.length;n<s;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,s=n.length;t<s;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function rs(e){let t;const n=e.extensions&&e.extensions[xn.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+os(n.attributes):e.indices+":"+os(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,s=e.targets.length;n<s;n++)t+=":"+os(e.targets[n]);return t}function os(e){let t="";const n=Object.keys(e).sort();for(let s=0,i=n.length;s<i;s++)t+=n[s]+":"+e[n[s]]+";";return t}function ls(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const hs=new P;class ds{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Sn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,i=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=navigator.userAgent.indexOf("Firefox")>-1,i=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||s&&i<98?this.textureLoader=new R(this.options.manager):this.textureLoader=new E(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:n,userData:{}};return ss(i,a,s),is(a,s),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const s=t[n].joints;for(let t=0,n=s.length;t<n;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(n[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,s]of e.children.entries())i(s,t.children[n])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!s)throw new Error("Unknown type: "+e)}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return n.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[xn.KHR_BINARY_GLTF].body);const s=this.options;return new Promise((function(e,i){n.load(_.resolveURL(t.uri,s.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+n)}))}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse){const e=$n[s.type],t=Qn[s.componentType],n=!0===s.normalized,i=new t(s.count*e);return Promise.resolve(new u(i,e,n))}const i=[];return void 0!==s.bufferView?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),void 0!==s.sparse&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],a=$n[s.type],r=Qn[s.componentType],o=r.BYTES_PER_ELEMENT,l=o*a,h=s.byteOffset||0,d=void 0!==s.bufferView?n.bufferViews[s.bufferView].byteStride:void 0,c=!0===s.normalized;let p,m;if(d&&d!==l){const e=Math.floor(h/d),n="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+e+":"+s.count;let l=t.cache.get(n);l||(p=new r(i,e*d,s.count*d/o),l=new I(p,d/o),t.cache.add(n,l)),m=new de(l,a,h%d/o,c)}else p=null===i?new r(s.count*a):new r(i,h,s.count*a),m=new u(p,a,c);if(void 0!==s.sparse){const t=$n.SCALAR,n=Qn[s.sparse.indices.componentType],o=s.sparse.indices.byteOffset||0,l=s.sparse.values.byteOffset||0,h=new n(e[1],o,s.sparse.count*t),d=new r(e[2],l,s.sparse.count*a);null!==i&&(m=new u(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*a]),a>=2&&m.setY(t,d[e*a+1]),a>=3&&m.setZ(t,d[e*a+2]),a>=4&&m.setW(t,d[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,i=t.images[s];let a=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(a=e)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const s=this,i=this.json,a=i.textures[e],r=i.images[t],o=(r.uri||r.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||r.name||"",""===t.name&&"string"==typeof r.uri&&!1===r.uri.startsWith("data:image/")&&(t.name=r.uri);const n=(i.samplers||{})[a.sampler]||{};return t.magFilter=Zn[n.magFilter]||D,t.minFilter=Zn[n.minFilter]||O,t.wrapS=Jn[n.wrapS]||k,t.wrapT=Jn[n.wrapT]||k,s.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=n.images[e],a=self.URL||self.webkitURL;let r=i.uri||"",o=!1;if(void 0!==i.bufferView)r=this.getDependency("bufferView",i.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:i.mimeType});return r=a.createObjectURL(t),r}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(r).then((function(e){return new Promise((function(n,i){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new ce(e);t.needsUpdate=!0,n(t)}),t.load(_.resolveURL(e,s.path),a,void 0,i)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(r),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),i.extensions[xn.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[xn.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(a);a=i.extensions[xn.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return void 0!==s&&(a.colorSpace=s),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new L,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new B,U.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(s||i||a){let e="ClonedMaterial:"+n.uuid+":";s&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return N}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let r;const o={},l=[];if((i.extensions||{})[xn.KHR_MATERIALS_UNLIT]){const e=s[xn.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new h(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],w),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,S)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=F);const d=i.alphaMode||"OPAQUE";if("BLEND"===d?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===d&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&r!==y&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new a(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&r!==y&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&r!==y){const e=i.emissiveFactor;o.emissive=(new h).setRGB(e[0],e[1],e[2],w)}return void 0!==i.emissiveTexture&&r!==y&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,S)),Promise.all(l).then((function(){const n=new r(o);return i.name&&(n.name=i.name),is(n,i),t.associations.set(n,{materials:e}),i.extensions&&ss(s,n,i),n}))}createUniqueName(e){const t=G.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(e){return n[xn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return cs(n,e,t)}))}const a=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],o=rs(r),l=s[o];if(l)a.push(l.promise);else{let e;e=r.extensions&&r.extensions[xn.KHR_DRACO_MESH_COMPRESSION]?i(r):cs(new c,r,t),s[o]={primitive:r,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],a=i.primitives,r=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new N({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:he})),o.DefaultMaterial):this.getDependency("material",a[e].material);r.push(t)}var o;return r.push(t.loadGeometries(a)),Promise.all(r).then((function(n){const r=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],d=a[n];let c;const u=r[n];if(d.mode===Yn.TRIANGLES||d.mode===Yn.TRIANGLE_STRIP||d.mode===Yn.TRIANGLE_FAN||void 0===d.mode)c=!0===i.isSkinnedMesh?new j(h,u):new z(h,u),!0===c.isSkinnedMesh&&c.normalizeSkinWeights(),d.mode===Yn.TRIANGLE_STRIP?c.geometry=bn(c.geometry,g):d.mode===Yn.TRIANGLE_FAN&&(c.geometry=bn(c.geometry,m));else if(d.mode===Yn.LINES)c=new V(h,u);else if(d.mode===Yn.LINE_STRIP)c=new H(h,u);else if(d.mode===Yn.LINE_LOOP)c=new W(h,u);else{if(d.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);c=new K(h,u)}Object.keys(c.geometry.morphAttributes).length>0&&as(c,i),c.name=t.createUniqueName(i.name||"mesh_"+e),is(c,i),d.extensions&&ss(s,c,d),t.assignFinalMaterial(c),l.push(c)}for(let n=0,s=l.length;n<s;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return i.extensions&&ss(s,l[0],i),l[0];const h=new q;i.extensions&&ss(s,h,i),t.associations.set(h,{meshes:e});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(s)return"perspective"===n.type?t=new X(Y.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===n.type&&(t=new Q(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),is(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,s=t.joints.length;e<s;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),s=e,i=[],a=[];for(let e=0,r=s.length;e<r;e++){const r=s[e];if(r){i.push(r);const t=new P;null!==n&&t.fromArray(n.array,16*e),a.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Z(i,a)}))}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,a=[],r=[],o=[],l=[],h=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],i=t.target,d=i.node,c=void 0!==s.parameters?s.parameters[n.input]:n.input,u=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==i.node&&(a.push(this.getDependency("node",d)),r.push(this.getDependency("accessor",c)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(i))}return Promise.all([Promise.all(a),Promise.all(r),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(e){const t=e[0],s=e[1],a=e[2],r=e[3],o=e[4],l=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],h=s[e],d=a[e],c=r[e],u=o[e];if(void 0===i)continue;i.updateMatrix&&i.updateMatrix();const p=n._createAnimationTracks(i,h,d,c,u);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}return new J(i,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return void 0===s.mesh?null:n.getDependency("mesh",s.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=s.weights.length;t<n;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],s=t._loadNodeShallow(e),i=[],a=n.children||[];for(let e=0,n=a.length;e<n;e++)i.push(t.getDependency("node",a[e]));const r=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),r]).then((function(e){const t=e[0],n=e[1],s=e[2];null!==s&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(s,hs)}));for(let e=0,s=n.length;e<s;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=t.nodes[e],a=i.name?s.createUniqueName(i.name):"",r=[],o=s._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&r.push(o),void 0!==i.camera&&r.push(s.getDependency("camera",i.camera).then((function(e){return s._getNodeRef(s.cameraCache,i.camera,e)}))),s._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){r.push(e)})),this.nodeCache[e]=Promise.all(r).then((function(t){let r;if(r=!0===i.isBone?new $:t.length>1?new q:1===t.length?t[0]:new A,r!==t[0])for(let e=0,n=t.length;e<n;e++)r.add(t[e]);if(i.name&&(r.userData.name=i.name,r.name=a),is(r,i),i.extensions&&ss(n,r,i),void 0!==i.matrix){const e=new P;e.fromArray(i.matrix),r.applyMatrix4(e)}else void 0!==i.translation&&r.position.fromArray(i.translation),void 0!==i.rotation&&r.quaternion.fromArray(i.rotation),void 0!==i.scale&&r.scale.fromArray(i.scale);return s.associations.has(r)||s.associations.set(r,{}),s.associations.get(r).nodes=e,r})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new q;n.name&&(i.name=s.createUniqueName(n.name)),is(i,n),n.extensions&&ss(t,i,n);const a=n.nodes||[],r=[];for(let e=0,t=a.length;e<t;e++)r.push(s.getDependency("node",a[e]));return Promise.all(r).then((function(e){for(let t=0,n=e.length;t<n;t++)i.add(e[t]);return s.associations=(e=>{const t=new Map;for(const[e,n]of s.associations)(e instanceof U||e instanceof ce)&&t.set(e,n);return e.traverse(e=>{const n=s.associations.get(e);null!=n&&t.set(e,n)}),t})(i),i}))}_createAnimationTracks(e,t,n,s,i){const a=[],r=e.name?e.name:e.uuid,o=[];let l;switch(ts[i.path]===ts.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(r),ts[i.path]){case ts.weights:l=pe;break;case ts.rotation:l=me;break;case ts.position:case ts.scale:l=ue;break;default:switch(n.itemSize){case 1:l=pe;break;case 2:case 3:default:l=ue}}const h=void 0!==s.interpolation?ns[s.interpolation]:ee,d=this._getArrayFromAccessor(n);for(let e=0,n=o.length;e<n;e++){const n=new l(o[e]+"."+ts[i.path],t.array,d,h);"CUBICSPLINE"===s.interpolation&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=ls(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Xn:Kn)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function cs(e,t,n){const s=t.attributes,i=[];function a(t,s){return n.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(const t in s){const n=es[t]||t.toLowerCase();n in e.attributes||i.push(a(s[t],n))}if(void 0!==t.indices&&!e.index){const s=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(s)}return te.workingColorSpace!==w&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${te.workingColorSpace}" not supported.`),is(e,t),function(e,t,n){const s=t.attributes,i=new ge;if(void 0===s.POSITION)return;{const e=n.json.accessors[s.POSITION],t=e.min,a=e.max;if(void 0===t||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new r(t[0],t[1],t[2]),new r(a[0],a[1],a[2])),e.normalized){const t=ls(Qn[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const a=t.targets;if(void 0!==a){const e=new r,t=new r;for(let s=0,i=a.length;s<i;s++){const i=a[s];if(void 0!==i.POSITION){const s=n.json.accessors[i.POSITION],a=s.min,r=s.max;if(void 0!==a&&void 0!==r){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(r[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(r[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(r[2]))),s.normalized){const e=ls(Qn[s.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new fe;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let s=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(s=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(a=!0),s&&i&&a)break}if(!s&&!i&&!a)return Promise.resolve(e);const r=[],o=[],l=[];for(let h=0,d=t.length;h<d;h++){const d=t[h];if(s){const t=void 0!==d.POSITION?n.getDependency("accessor",d.POSITION):e.attributes.position;r.push(t)}if(i){const t=void 0!==d.NORMAL?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(t)}if(a){const t=void 0!==d.COLOR_0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],r=t[1],o=t[2];return s&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=r),a&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const us=new WeakMap;class ps extends f{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const i=new v(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{this.parse(e,t,s)},n,s)}parse(e,t,n=(()=>{})){this.decodeDracoFile(e,t,null,null,S).catch(n)}decodeDracoFile(e,t,n,s,i=w,a=(()=>{})){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:i};return this.decodeGeometry(e,r).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(us.has(e)){const t=us.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const i=this.workerNextTaskID++,a=e.byteLength,r=this._getWorker(i,a).then(n=>(s=n,new Promise((n,a)=>{s._callbacks[i]={resolve:n,reject:a},s.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return r.catch(()=>!0).then(()=>{s&&i&&this._releaseTask(s,i)}),us.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new c;e.index&&t.setIndex(new u(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],i=s.name,a=s.array,r=s.itemSize,o=new u(a,r);"color"===i&&(this._assignVertexColorSpace(o,s.vertexColorSpace),o.normalized=a instanceof Float32Array==0),t.setAttribute(i,o)}return t}_assignVertexColorSpace(e,t){if(t!==S)return;const n=new h;for(let t=0,s=e.count;t<s;t++)n.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new v(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,s)=>{n.load(e,t,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=ms.toString(),i=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){this.workerPool.map(e=>e._taskLoad)}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function ms(){let e,t;function n(e,t,n,s,i,a){const r=a.num_components(),o=n.num_points()*r,l=o*i.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),d=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,a,h,l,d);const c=new i(e.HEAPF32.buffer,d,o).slice();return e._free(d),{name:s,array:c,itemSize:r}}onmessage=function(s){const i=s.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const s=i.buffer,a=i.taskConfig;t.then(e=>{const t=e.draco,r=new t.Decoder;try{const e=function(e,t,s,i){const a=i.attributeIDs,r=i.attributeTypes;let o,l;const h=t.GetEncodedGeometryType(s);if(h===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(s,s.byteLength,o);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(s,s.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const s in a){const l=self[r[s]];let h,c;if(i.useUniqueIDs)c=a[s],h=t.GetAttributeByUniqueId(o,c);else{if(c=t.GetAttributeId(o,e[a[s]]),-1===c)continue;h=t.GetAttribute(o,c)}const u=n(e,t,o,s,l,h);"color"===s&&(u.vertexColorSpace=i.vertexColorSpace),d.attributes.push(u)}return h===e.TRIANGULAR_MESH&&(d.index=function(e,t,n){const s=3*n.num_faces(),i=4*s,a=e._malloc(i);t.GetTrianglesUInt32Array(n,i,a);const r=new Uint32Array(e.HEAPF32.buffer,a,s).slice();return e._free(a),{array:r,itemSize:1}}(e,t,o)),e.destroy(o),d}(t,r,new Int8Array(s),a),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(r)}})}}}const gs={"draco_wasm_wrapper.js":"static/draco_wasm_wrapper-6263f3a4b71cdf3b.js","draco_decoder.wasm":"static/draco_decoder-b048235474cbf09e.wasm","draco_decoder.js":"static/draco_decoder-dc7f397e2a2ebac4.js"};class fs{constructor(e){this._context_=e}getStore(e="rml_default"){return this._localStorage.getItem(e)||{entries:[]}}saveStore(e,t){this._localStorage.setItem(e,t)}addItem(e,t,n="rml_default",s=5){const i=this.getStore(n),a=i.entries.find(t=>t.id===e);if(a?(a.payload=t,a.date=Date.now()):i.entries.push({id:e,date:Date.now(),payload:t}),i.entries.length>s)for(i.entries.sort((e,t)=>t.date-e.date);i.entries.length>s;)i.entries.pop();this.saveStore(n,i)}getItem(e,t="rml_default"){const n=this.getStore(t).entries.find(t=>t.id===e);return n?n.payload:null}}on([hn],fs.prototype,"_localStorage",void 0);const _s=e("t",(function(e){return e*(Math.PI/180)})),vs=e("H",(function(e){return e*(180/Math.PI)})),ws=(e("y",(function(e,t,n,s,i,a){e=Math.sqrt(e*e+n*n);const r=i/a,o=2*Math.atan(Math.tan(s*Math.PI/180/2)*r)*180/Math.PI,l=_s(s),h=t/2/Math.tan(l/2),d=e/(2*Math.atan(Math.PI*o/360));return Math.max(h,d)})),function(e){return Math.round(1e3*e)/1e3}),bs=(e("a3",(function(e,t){return Math.abs(e.y-t.y)+Math.abs(e.x-t.x)})),e("ad",e=>new r(e.x/1e3,e.z/1e3,e.y/-1e3))),ys=e=>new r(e.x/1e3,e.z/1e3,e.y/1e3),Ss=e("j",e=>({x:Math.round(1e3*e.x),y:Math.round(-1e3*e.z),z:Math.round(1e3*e.y)})),xs=e=>decodeURIComponent(encodeURIComponent(e)),Ps=e("V",e=>{if(!e){const t=typeof e;return"number"===t||"boolean"===t?e:null}if(!e.hasOwnProperty("size")&&e.size&&"function"==typeof e.size){let t=Ms(e);for(let e=0;e<t.length;e++)t[e]=Ps(t[e]);return"string"==typeof t?xs(t):t}if("object"==typeof e)for(let t in e)e.hasOwnProperty(t)&&(e[t]=Ps(e[t]));return"string"==typeof e?xs(e):e}),Ms=e=>{let t=[];if(e){let n=e.size();for(let s=0;s<n;s++)t.push(e.get(s))}return t},Cs=e=>{let t=new P,n=Ps(e);return t.fromArray(n),t.transpose(),(e=>{let t=new P;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),t.scale(new r(.001,.001,.001));let n=new P;return n.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),n.scale(new r(1e3,1e3,1e3)),t.multiply(e).multiply(n)})(t)};function Ts(e,t){var n=e.__state.conversionName.toString(),s=Math.round(e.r),i=Math.round(e.g),a=Math.round(e.b),r=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var d=e.hex.toString(16);d.length<6;)d="0"+d;return"#"+d}return"CSS_RGB"===n?"rgb("+s+","+i+","+a+")":"CSS_RGBA"===n?"rgba("+s+","+i+","+a+","+r+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+s+","+i+","+a+"]":"RGBA_ARRAY"===n?"["+s+","+i+","+a+","+r+"]":"RGB_OBJ"===n?"{r:"+s+",g:"+i+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+s+",g:"+i+",b:"+a+",a:"+r+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+r+"}":"unknown format"}var As=Array.prototype.forEach,Rs=Array.prototype.slice,Es={BREAK:{},extend:function(e){return this.each(Rs.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Rs.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Rs.call(arguments);return function(){for(var t=Rs.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(As&&e.forEach&&e.forEach===As)e.forEach(t,n);else if(e.length===e.length+0){var s,i=void 0;for(i=0,s=e.length;i<s;i++)if(i in e&&t.call(n,e[i],i)===this.BREAK)return}else for(var a in e)if(t.call(n,e[a],a)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var s=void 0;return function(){var i=this,a=arguments;function r(){s=null,n||e.apply(i,a)}var o=n||!s;clearTimeout(s),s=setTimeout(r,t),o&&e.apply(i,a)}},toArray:function(e){return e.toArray?e.toArray():Rs.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},Is=[{litmus:Es.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:Ts},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:Ts},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:Ts},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:Ts}}},{litmus:Es.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Es.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:Es.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Es.isNumber(e.r)&&Es.isNumber(e.g)&&Es.isNumber(e.b)&&Es.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(Es.isNumber(e.r)&&Es.isNumber(e.g)&&Es.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(Es.isNumber(e.h)&&Es.isNumber(e.s)&&Es.isNumber(e.v)&&Es.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(Es.isNumber(e.h)&&Es.isNumber(e.s)&&Es.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],Ds=void 0,Os=void 0,ks=function(){Os=!1;var e=arguments.length>1?Es.toArray(arguments):arguments[0];return Es.each(Is,(function(t){if(t.litmus(e))return Es.each(t.conversions,(function(t,n){if(Ds=t.read(e),!1===Os&&!1!==Ds)return Os=Ds,Ds.conversionName=n,Ds.conversion=t,Es.BREAK})),Es.BREAK})),Os},Ls=void 0,Us={hsv_to_rgb:function(e,t,n){var s=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),a=n*(1-t),r=n*(1-i*t),o=n*(1-(1-i)*t),l=[[n,o,a],[r,n,a],[a,n,o],[a,r,n],[o,a,n],[n,a,r]][s];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var s=Math.min(e,t,n),i=Math.max(e,t,n),a=i-s,r=void 0;return 0===i?{h:NaN,s:0,v:0}:(r=e===i?(t-n)/a:t===i?2+(n-e)/a:4+(e-t)/a,(r/=6)<0&&(r+=1),{h:360*r,s:a/i,v:i/255})},rgb_to_hex:function(e,t,n){var s=this.hex_with_component(0,2,e);return s=this.hex_with_component(s,1,t),this.hex_with_component(s,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Ls=8*t)|e&~(255<<Ls)}},Bs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ns=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Fs=function(){function e(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(t,n,s){return n&&e(t.prototype,n),s&&e(t,s),t}}(),Gs=function e(t,n,s){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,s)}if("value"in i)return i.value;var r=i.get;return void 0!==r?r.call(s):void 0},js=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},zs=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},Vs=function(){function e(){if(Ns(this,e),this.__state=ks.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Fs(e,[{key:"toString",value:function(){return Ts(this)}},{key:"toHexString",value:function(){return Ts(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function Hs(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Vs.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Vs.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function Ws(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Vs.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Vs.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Vs.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=Us.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Es.extend(e.__state,Us.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Vs.recalculateHSV=function(e){var t=Us.rgb_to_hsv(e.r,e.g,e.b);Es.extend(e.__state,{s:t.s,v:t.v}),Es.isNaN(t.h)?Es.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},Vs.COMPONENTS=["r","g","b","h","s","v","hex","a"],Hs(Vs.prototype,"r",2),Hs(Vs.prototype,"g",1),Hs(Vs.prototype,"b",0),Ws(Vs.prototype,"h"),Ws(Vs.prototype,"s"),Ws(Vs.prototype,"v"),Object.defineProperty(Vs.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Vs.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=Us.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Ks=function(){function e(t,n){Ns(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return Fs(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),qs={};Es.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){Es.each(e,(function(e){qs[e]=t}))}));var Xs=/(\d+(\.\d+)?)px/;function Ys(e){if("0"===e||Es.isUndefined(e))return 0;var t=e.match(Xs);return Es.isNull(t)?0:parseFloat(t[1])}var Qs={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var s=n,i=t;Es.isUndefined(i)&&(i=!0),Es.isUndefined(s)&&(s=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),s&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,s){var i=n||{},a=qs[t];if(!a)throw new Error("Event type "+t+" not supported.");var r=document.createEvent(a);switch(a){case"MouseEvents":var o=i.x||i.clientX||0,l=i.y||i.clientY||0;r.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var h=r.initKeyboardEvent||r.initKeyEvent;Es.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:r.initEvent(t,i.bubbles||!1,i.cancelable||!0)}Es.defaults(r,s),e.dispatchEvent(r)},bind:function(e,t,n,s){var i=s||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),Qs},unbind:function(e,t,n,s){var i=s||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),Qs},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return Qs},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),s=n.indexOf(t);-1!==s&&(n.splice(s,1),e.className=n.join(" "))}else e.className=void 0;return Qs},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Ys(t["border-left-width"])+Ys(t["border-right-width"])+Ys(t["padding-left"])+Ys(t["padding-right"])+Ys(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Ys(t["border-top-width"])+Ys(t["border-bottom-width"])+Ys(t["padding-top"])+Ys(t["padding-bottom"])+Ys(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Zs=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=s;return s.__prev=s.getValue(),s.__checkbox=document.createElement("input"),s.__checkbox.setAttribute("type","checkbox"),Qs.bind(s.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),s.domElement.appendChild(s.__checkbox),s.updateDisplay(),s}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Ks),Js=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=s,r=i;if(i.__select=document.createElement("select"),Es.isArray(a)){var o={};Es.each(a,(function(e){o[e]=e})),a=o}return Es.each(a,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),r.__select.appendChild(n)})),i.updateDisplay(),Qs.bind(i.__select,"change",(function(){var e=this.options[this.selectedIndex].value;r.setValue(e)})),i.domElement.appendChild(i.__select),i}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return Qs.isActive(this.__select)?this:(this.__select.value=this.getValue(),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(Ks),$s=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=s;function a(){i.setValue(i.__input.value)}return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),Qs.bind(s.__input,"keyup",a),Qs.bind(s.__input,"change",a),Qs.bind(s.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),Qs.bind(s.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),s.updateDisplay(),s.domElement.appendChild(s.__input),s}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){return Qs.isActive(this.__input)||(this.__input.value=this.getValue()),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Ks);function ei(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var ti=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=s||{};return i.__min=a.min,i.__max=a.max,i.__step=a.step,Es.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=ei(i.__impliedStep),i}return js(t,e),Fs(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=ei(e),this}}]),t}(Ks),ni=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,s));i.__truncationSuspended=!1;var a=i,r=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=r-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),r=e.clientY}function h(){Qs.unbind(window,"mousemove",l),Qs.unbind(window,"mouseup",h),o()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),Qs.bind(i.__input,"change",(function(){var e=parseFloat(a.__input.value);Es.isNaN(e)||a.setValue(e)})),Qs.bind(i.__input,"blur",(function(){o()})),Qs.bind(i.__input,"mousedown",(function(e){Qs.bind(window,"mousemove",l),Qs.bind(window,"mouseup",h),r=e.clientY})),Qs.bind(i.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e,n,s;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,s=Math.pow(10,n),Math.round(e*s)/s),Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ti);function si(e,t,n,s,i){return s+(e-t)/(n-t)*(i-s)}var ii=function(e){function t(e,n,s,i,a){Ns(this,t);var r=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:s,max:i,step:a})),o=r;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(si(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){Qs.unbind(window,"mousemove",l),Qs.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function d(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(si(t,n.left,n.right,o.__min,o.__max))}function c(){Qs.unbind(window,"touchmove",d),Qs.unbind(window,"touchend",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return r.__background=document.createElement("div"),r.__foreground=document.createElement("div"),Qs.bind(r.__background,"mousedown",(function(e){document.activeElement.blur(),Qs.bind(window,"mousemove",l),Qs.bind(window,"mouseup",h),l(e)})),Qs.bind(r.__background,"touchstart",(function(e){1===e.touches.length&&(Qs.bind(window,"touchmove",d),Qs.bind(window,"touchend",c),d(e))})),Qs.addClass(r.__background,"slider"),Qs.addClass(r.__foreground,"slider-fg"),r.updateDisplay(),r.__background.appendChild(r.__foreground),r.domElement.appendChild(r.__background),r}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Gs(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ti),ai=function(e){function t(e,n,s){Ns(this,t);var i=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===s?"Fire":s,Qs.bind(i.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Qs.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return js(t,e),Fs(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Ks),ri=function(e){function t(e,n){Ns(this,t);var s=zs(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));s.__color=new Vs(s.getValue()),s.__temp=new Vs(0);var i=s;s.domElement=document.createElement("div"),Qs.makeSelectable(s.domElement,!1),s.__selector=document.createElement("div"),s.__selector.className="selector",s.__saturation_field=document.createElement("div"),s.__saturation_field.className="saturation-field",s.__field_knob=document.createElement("div"),s.__field_knob.className="field-knob",s.__field_knob_border="2px solid ",s.__hue_knob=document.createElement("div"),s.__hue_knob.className="hue-knob",s.__hue_field=document.createElement("div"),s.__hue_field.className="hue-field",s.__input=document.createElement("input"),s.__input.type="text",s.__input_textShadow="0 1px 1px ",Qs.bind(s.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),Qs.bind(s.__input,"blur",c),Qs.bind(s.__selector,"mousedown",(function(){Qs.addClass(this,"drag").bind(window,"mouseup",(function(){Qs.removeClass(i.__selector,"drag")}))})),Qs.bind(s.__selector,"touchstart",(function(){Qs.addClass(this,"drag").bind(window,"touchend",(function(){Qs.removeClass(i.__selector,"drag")}))}));var a,r=document.createElement("div");function o(e){p(e),Qs.bind(window,"mousemove",p),Qs.bind(window,"touchmove",p),Qs.bind(window,"mouseup",h),Qs.bind(window,"touchend",h)}function l(e){m(e),Qs.bind(window,"mousemove",m),Qs.bind(window,"touchmove",m),Qs.bind(window,"mouseup",d),Qs.bind(window,"touchend",d)}function h(){Qs.unbind(window,"mousemove",p),Qs.unbind(window,"touchmove",p),Qs.unbind(window,"mouseup",h),Qs.unbind(window,"touchend",h),u()}function d(){Qs.unbind(window,"mousemove",m),Qs.unbind(window,"touchmove",m),Qs.unbind(window,"mouseup",d),Qs.unbind(window,"touchend",d),u()}function c(){var e=ks(this.value);!1!==e?(i.__color.__state=e,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function u(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,s=n.clientX,a=n.clientY,r=(s-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),r>1?r=1:r<0&&(r=0),i.__color.v=o,i.__color.s=r,i.setValue(i.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=i.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return Es.extend(s.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Es.extend(s.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:s.__field_knob_border+(s.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Es.extend(s.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Es.extend(s.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Es.extend(r.style,{width:"100%",height:"100%",background:"none"}),li(r,"top","rgba(0,0,0,0)","#000"),Es.extend(s.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=s.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Es.extend(s.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:s.__input_textShadow+"rgba(0,0,0,0.7)"}),Qs.bind(s.__saturation_field,"mousedown",o),Qs.bind(s.__saturation_field,"touchstart",o),Qs.bind(s.__field_knob,"mousedown",o),Qs.bind(s.__field_knob,"touchstart",o),Qs.bind(s.__hue_field,"mousedown",l),Qs.bind(s.__hue_field,"touchstart",l),s.__saturation_field.appendChild(r),s.__selector.appendChild(s.__field_knob),s.__selector.appendChild(s.__saturation_field),s.__selector.appendChild(s.__hue_field),s.__hue_field.appendChild(s.__hue_knob),s.domElement.appendChild(s.__input),s.domElement.appendChild(s.__selector),s.updateDisplay(),s}return js(t,e),Fs(t,[{key:"updateDisplay",value:function(){var e=ks(this.getValue());if(!1!==e){var t=!1;Es.each(Vs.COMPONENTS,(function(n){if(!Es.isUndefined(e[n])&&!Es.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Es.extend(this.__color.__state,e)}Es.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,s=255-n;Es.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,li(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Es.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+s+","+s+","+s+",.7)"})}}]),t}(Ks),oi=["-moz-","-o-","-webkit-","-ms-",""];function li(e,t,n,s){e.style.background="",Es.each(oi,(function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+s+" 100%); "}))}var hi='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',di=function(e,t){var n=e[t];return Es.isArray(arguments[2])||Es.isObject(arguments[2])?new Js(e,t,arguments[2]):Es.isNumber(n)?Es.isNumber(arguments[2])&&Es.isNumber(arguments[3])?Es.isNumber(arguments[4])?new ii(e,t,arguments[2],arguments[3],arguments[4]):new ii(e,t,arguments[2],arguments[3]):Es.isNumber(arguments[4])?new ni(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new ni(e,t,{min:arguments[2],max:arguments[3]}):Es.isString(n)?new $s(e,t):Es.isFunction(n)?new ai(e,t,""):Es.isBoolean(n)?new Zs(e,t):null},ci=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},ui=function(){function e(){Ns(this,e),this.backgroundElement=document.createElement("div"),Es.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Qs.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Es.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Qs.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Fs(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Es.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Qs.unbind(e.domElement,"webkitTransitionEnd",t),Qs.unbind(e.domElement,"transitionend",t),Qs.unbind(e.domElement,"oTransitionEnd",t)};Qs.bind(this.domElement,"webkitTransitionEnd",t),Qs.bind(this.domElement,"transitionend",t),Qs.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Qs.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Qs.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=document,s=document.createElement("style");s.type="text/css",s.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(s)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var pi=function(){try{return!!window.localStorage}catch(e){return!1}}(),mi=void 0,gi=!0,fi=void 0,_i=!1,vi=[],wi=function e(t){var n=this,s=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Qs.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],s=Es.defaults(s,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),s=Es.defaults(s,{resizable:s.autoPlace,hideable:s.autoPlace}),Es.isUndefined(s.load)?s.load={preset:"Default"}:s.preset&&(s.load.preset=s.preset),Es.isUndefined(s.parent)&&s.hideable&&vi.push(this),s.resizable=Es.isUndefined(s.parent)&&s.resizable,s.autoPlace&&Es.isUndefined(s.scrollable)&&(s.scrollable=!0);var i,a=pi&&"true"===localStorage.getItem(Mi(0,"isLocal")),r=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return s.parent}},scrollable:{get:function(){return s.scrollable}},autoPlace:{get:function(){return s.autoPlace}},closeOnTop:{get:function(){return s.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:s.load.preset},set:function(e){n.parent?n.getRoot().preset=e:s.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return s.width},set:function(e){s.width=e,Ei(n,e)}},name:{get:function(){return s.name},set:function(e){s.name=e,o&&(o.innerHTML=s.name)}},closed:{get:function(){return s.closed},set:function(t){s.closed=t,s.closed?Qs.addClass(n.__ul,e.CLASS_CLOSED):Qs.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return s.load}},useLocalStorage:{get:function(){return a},set:function(e){pi&&(a=e,e?Qs.bind(window,"unload",r):Qs.unbind(window,"unload",r),localStorage.setItem(Mi(0,"isLocal"),e))}}}),Es.isUndefined(s.parent)){if(this.closed=s.closed||!1,Qs.addClass(this.domElement,e.CLASS_MAIN),Qs.makeSelectable(this.domElement,!1),pi&&a){n.useLocalStorage=!0;var l=localStorage.getItem(Mi(0,"gui"));l&&(s.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,Qs.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),s.closeOnTop?(Qs.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(Qs.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),Qs.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===s.closed&&(s.closed=!0);var h=document.createTextNode(s.name);Qs.addClass(h,"controller-name"),o=bi(n,h),Qs.addClass(this.__ul,e.CLASS_CLOSED),Qs.addClass(o,"title"),Qs.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),s.closed||(this.closed=!1)}s.autoPlace&&(Es.isUndefined(s.parent)&&(gi&&(fi=document.createElement("div"),Qs.addClass(fi,"dg"),Qs.addClass(fi,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(fi),gi=!1),fi.appendChild(this.domElement),Qs.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||Ei(n,s.width)),this.__resizeHandler=function(){n.onResizeDebounced()},Qs.bind(window,"resize",this.__resizeHandler),Qs.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),Qs.bind(this.__ul,"transitionend",this.__resizeHandler),Qs.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),s.resizable&&Ri(this),r=function(){pi&&"true"===localStorage.getItem(Mi(0,"isLocal"))&&localStorage.setItem(Mi(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=r,s.parent||((i=n.getRoot()).width+=1,Es.defer((function(){i.width-=1})))};function bi(e,t,n){var s=document.createElement("li");return t&&s.appendChild(t),n?e.__ul.insertBefore(s,n):e.__ul.appendChild(s),e.onResize(),s}function yi(e){Qs.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&Qs.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function Si(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function xi(e,t){var n=e.getRoot(),s=n.__rememberedObjects.indexOf(t.object);if(-1!==s){var i=n.__rememberedObjectIndecesToControllers[s];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[s]=i),i[t.property]=t,n.load&&n.load.remembered){var a=n.load.remembered,r=void 0;if(a[e.preset])r=a[e.preset];else{if(!a.Default)return;r=a.Default}if(r[s]&&void 0!==r[s][t.property]){var o=r[s][t.property];t.initialValue=o,t.setValue(o)}}}}function Pi(e,t,n,s){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(s.color)i=new ri(t,n);else{var a=[t,n].concat(s.factoryArgs);i=di.apply(e,a)}s.before instanceof Ks&&(s.before=s.before.__li),xi(e,i),Qs.addClass(i.domElement,"c");var r=document.createElement("span");Qs.addClass(r,"property-name"),r.innerHTML=i.property;var o=document.createElement("div");o.appendChild(r),o.appendChild(i.domElement);var l=bi(e,o,s.before);return Qs.addClass(l,wi.CLASS_CONTROLLER_ROW),i instanceof ri?Qs.addClass(l,"color"):Qs.addClass(l,Bs(i.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,Es.extend(n,{options:function(t){if(arguments.length>1){var s=n.__li.nextElementSibling;return n.remove(),Pi(e,n.object,n.property,{before:s,factoryArgs:[Es.toArray(arguments)]})}if(Es.isArray(t)||Es.isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),Pi(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof ii){var s=new ni(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Es.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],i=s[e];n[e]=s[e]=function(){var e=Array.prototype.slice.call(arguments);return i.apply(s,e),t.apply(n,e)}})),Qs.addClass(t,"has-slider"),n.domElement.insertBefore(s.domElement,n.domElement.firstElementChild)}else if(n instanceof ni){var i=function(t){if(Es.isNumber(n.__min)&&Es.isNumber(n.__max)){var s=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=Pi(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(s),i&&a.listen(),a}return t};n.min=Es.compose(i,n.min),n.max=Es.compose(i,n.max)}else n instanceof Zs?(Qs.bind(t,"click",(function(){Qs.fakeEvent(n.__checkbox,"click")})),Qs.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof ai?(Qs.bind(t,"click",(function(){Qs.fakeEvent(n.__button,"click")})),Qs.bind(t,"mouseover",(function(){Qs.addClass(n.__button,"hover")})),Qs.bind(t,"mouseout",(function(){Qs.removeClass(n.__button,"hover")}))):n instanceof ri&&(Qs.addClass(t,"color"),n.updateDisplay=Es.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Es.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&Si(e.getRoot(),!0),t}),n.setValue)}(e,l,i),e.__controllers.push(i),i}function Mi(e,t){return document.location.href+"."+t}function Ci(e,t,n){var s=document.createElement("option");s.innerHTML=t,s.value=t,e.__preset_select.appendChild(s),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Ti(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Ai(e){var t=e.__save_row=document.createElement("li");Qs.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Qs.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML="&nbsp;",Qs.addClass(n,"button gears");var s=document.createElement("span");s.innerHTML="Save",Qs.addClass(s,"button"),Qs.addClass(s,"save");var i=document.createElement("span");i.innerHTML="New",Qs.addClass(i,"button"),Qs.addClass(i,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Qs.addClass(a,"button"),Qs.addClass(a,"revert");var r=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Es.each(e.load.remembered,(function(t,n){Ci(e,n,n===e.preset)})):Ci(e,"Default",!1),Qs.bind(r,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(r),t.appendChild(n),t.appendChild(s),t.appendChild(i),t.appendChild(a),pi){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(Mi(0,"isLocal"))&&l.setAttribute("checked","checked"),Ti(e,o),Qs.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,Ti(e,o)}))}var h=document.getElementById("dg-new-constructor");Qs.bind(h,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||mi.hide()})),Qs.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),mi.show(),h.focus(),h.select()})),Qs.bind(s,"click",(function(){e.save()})),Qs.bind(i,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),Qs.bind(a,"click",(function(){e.revert()}))}function Ri(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function s(){Qs.removeClass(e.__closeButton,wi.CLASS_DRAG),Qs.unbind(window,"mousemove",n),Qs.unbind(window,"mouseup",s)}function i(i){return i.preventDefault(),t=i.clientX,Qs.addClass(e.__closeButton,wi.CLASS_DRAG),Qs.bind(window,"mousemove",n),Qs.bind(window,"mouseup",s),!1}e.__resize_handle=document.createElement("div"),Es.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Qs.bind(e.__resize_handle,"mousedown",i),Qs.bind(e.__closeButton,"mousedown",i),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Ei(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Ii(e,t){var n={};return Es.each(e.__rememberedObjects,(function(s,i){var a={},r=e.__rememberedObjectIndecesToControllers[i];Es.each(r,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[i]=a})),n}wi.toggleHide=function(){_i=!_i,Es.each(vi,(function(e){e.domElement.style.display=_i?"none":""}))},wi.CLASS_AUTO_PLACE="a",wi.CLASS_AUTO_PLACE_CONTAINER="ac",wi.CLASS_MAIN="main",wi.CLASS_CONTROLLER_ROW="cr",wi.CLASS_TOO_TALL="taller-than-window",wi.CLASS_CLOSED="closed",wi.CLASS_CLOSE_BUTTON="close-button",wi.CLASS_CLOSE_TOP="close-top",wi.CLASS_CLOSE_BOTTOM="close-bottom",wi.CLASS_DRAG="drag",wi.DEFAULT_WIDTH=245,wi.TEXT_CLOSED="Close Controls",wi.TEXT_OPEN="Open Controls",wi._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||wi.toggleHide()},Qs.bind(window,"keydown",wi._keydownHandler,!1),Es.extend(wi.prototype,{add:function(e,t){return Pi(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return Pi(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Es.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&fi.removeChild(this.domElement);var e=this;Es.each(this.__folders,(function(t){e.removeFolder(t)})),Qs.unbind(window,"keydown",wi._keydownHandler,!1),yi(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new wi(t);this.__folders[e]=n;var s=bi(this,n.domElement);return Qs.addClass(s,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],yi(e);var t=this;Es.each(e.__folders,(function(t){e.removeFolder(t)})),Es.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Qs.getOffset(e.__ul).top,n=0;Es.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Qs.getHeight(t))})),window.innerHeight-t-20<n?(Qs.addClass(e.domElement,wi.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(Qs.removeClass(e.domElement,wi.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Es.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Es.debounce((function(){this.onResize()}),50),remember:function(){if(Es.isUndefined(mi)&&((mi=new ui).domElement.innerHTML=hi),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Es.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&Ai(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&Ei(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Ii(this)),e.folders={},Es.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Ii(this),Si(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=Ii(this,!0)),this.load.remembered[e]=Ii(this),this.preset=e,Ci(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Es.each(this.__controllers,(function(t){this.getRoot().load.remembered?xi(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Es.each(this.__folders,(function(e){e.revert(e)})),e||Si(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ci.call(window,(function(){e(t)})),Es.each(t,(function(e){e.updateDisplay()}))}(this.__listening)},updateDisplay:function(){Es.each(this.__controllers,(function(e){e.updateDisplay()})),Es.each(this.__folders,(function(e){e.updateDisplay()}))}});var Di=wi;class Oi{static createMeshPhysicalMaterial(e){return new x(e)}static createMeshStandardMaterial(e){return new N(e)}}e("Z",Oi),e("l",(e,t,n,s)=>{if(!e||!t||0===n||0===s)return new r;let i=e.clone(),a=n/2,o=s/2;return i.project(t),i.x=Math.floor(i.x*a+a),i.y=Math.floor(-i.y*o+o),i.z=e.distanceTo(t.position),i});const ki=e("k",(e,t)=>{t||(t=new r(0,0,0));let n=new r(e.size.x/1e3,e.size.z/1e3,e.size.y/1e3),s=new r(e.origin.x/1e3,e.origin.z/1e3,e.origin.y/-1e3),i=new r(0,0,-n.z).add(s).sub(t),a=new r(n.x,n.y,0).add(s).add(t);return new ge(i,a)});e("X",(e,t)=>{let n=ws(e.x),s=ws(e.y),i=ws(e.z),a=ws(t.x),r=ws(t.y),o=ws(t.z);return n===a&&s===r&&i===o}),e("a2",(e,t)=>{let n=ws(e.w),s=ws(e.x),i=ws(e.y),a=ws(e.z),r=ws(t.w),o=ws(t.x),l=ws(t.y),h=ws(t.z);return n===r&&s===o&&i===l&&a===h}),e("Y",(e,t)=>{let n=ws(e.x),s=ws(e.y),i=ws(t.x),a=ws(t.y);return n===i&&s===a});let Li=null;const Ui=()=>{if(Li)return Li;const e=new Uint8Array(4);for(let t=0;t<1;t++){const n=4*t;e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255}const t=new ye(e,1,1,be);return t.needsUpdate=!0,t},Bi=(e,t,n,s)=>{const i=new Uint8Array(4),a=Math.floor(255*e),r=Math.floor(255*t),o=Math.floor(255*n),l=Math.floor(255*s);for(let e=0;e<4;e++){const t=4*e;i[t]=a,i[t+1]=r,i[t+2]=o,i[t+3]=l}const h=new ye(i,1,1,be);return h.needsUpdate=!0,h},Ni=e("$",e=>Fi(null,e)),Fi=e("ay",(e,t)=>{var n;e||(e=zi()),e.name=t.id?t.id.toString():"";const s="2"===t.shading.version||(null===(n=t.shading.version)||void 0===n?void 0:n.startsWith("2."));return(e=s?ji(e,t):Gi(e,t)).userData.materialVersion=s?2:1,e.map||(Li||(Li=Ui()),e.map=Li),e}),Gi=(e,t)=>{void 0!==t.shading.metallic&&(e.metalness=1===t.shading.metallic?1:.5,e.reflectivity=Se(t.shading.metallic,.5));let n=!1;return t.shading.transmission&&t.shading.transmission>0?(e.opacity=1-t.shading.transmission,e.transparent=!0,e.depthWrite=!1,e.metalness=0,n=!0):void 0!==t.shading.alpha&&t.shading.alpha<1&&(e.transparent=t.shading.alpha<1,e.opacity=t.shading.alpha,e.depthWrite=t.shading.alpha>=1,e.metalness=.5*Math.max(0,t.shading.alpha),n=!0),e.aoMapIntensity=Se(t.shading.occlusion,1),e.roughness=Se(t.shading.roughness,.5),e.alphaTest=Se(t.shading.alphaCutoff,0),Wi(e.color,t.shading.basecolor),n||t.shading.doubleSided?e.side=F:e.side=he,e},ji=(e,t)=>{var n,s,i,a,r,o,l,h,d,c,u,p,m,g;let f=!1;return void 0!==t.shading.alpha&&t.shading.alpha<1?(e.transparent=!0,e.opacity=t.shading.alpha,e.depthWrite=!1,f=!0):(e.transparent=!1,e.opacity=1,e.depthWrite=!0),e.alphaTest=null!==(n=t.shading.alphaCutoff)&&void 0!==n?n:0,Wi(e.color,t.shading.basecolor),e.transmission=null!==(s=t.shading.transmission)&&void 0!==s?s:0,e.ior=null!==(i=Math.max(1,Math.min(2.33,t.shading.transmissionIOR)))&&void 0!==i?i:1.5,e.metalness=null!==(a=t.shading.metallic)&&void 0!==a?a:0,Wi(e.specularColor,t.shading.specularColor),e.specularIntensity=null!==(r=t.shading.specularity)&&void 0!==r?r:0,e.roughness=null!==(o=t.shading.roughness)&&void 0!==o?o:0,e.aoMapIntensity=null!==(l=t.shading.occlusion)&&void 0!==l?l:1,Wi(e.emissive,t.shading.emissiveColor),e.emissiveIntensity=null!==(h=t.shading.emissiveIntensity)&&void 0!==h?h:1,e.clearcoat=null!==(d=t.shading.clearcoatIntensity)&&void 0!==d?d:0,e.clearcoatRoughness=null!==(c=t.shading.clearcoatRoughness)&&void 0!==c?c:0,e.clearcoatNormalScale.setScalar(null!==(u=t.shading.clearcoatNormalScale)&&void 0!==u?u:1),Wi(e.sheenColor,t.shading.sheenColor),e.sheen=null!==(p=t.shading.sheenIntensity)&&void 0!==p?p:1,e.sheenRoughness=null!==(m=t.shading.sheenRoughness)&&void 0!==m?m:1,e.thickness=null!==(g=t.shading.thicknessFactor)&&void 0!==g?g:0,Wi(e.attenuationColor,t.shading.attenuationColor),t.shading.attenuationDistance&&(e.attenuationDistance=t.shading.attenuationDistance),e.side=f||t.shading.doubleSided?F:he,e},zi=()=>Oi.createMeshPhysicalMaterial({}),Vi=(e("az",(e,t=1)=>2===t?Hi(e):Vi(e)),e=>{let t={alpha:e.opacity,metallic:e.reflectivity,basecolor:Ki(e.color),roughness:e.roughness,doubleSided:e.side===F,alphaCutoff:e.alphaTest,transmission:e.transmission};return 1===e.metalness?t.metallic=1:t.metallic=e.reflectivity,t}),Hi=e=>({version:"2.0.0",alpha:e.opacity,alphaCutoff:e.alphaTest,basecolor:Ki(e.color),transmission:e.transmission,transmissionIOR:e.ior,metallic:e.metalness,doubleSided:e.side===F,specularColor:Ki(e.specularColor),specularity:e.specularIntensity,roughness:e.roughness,occlusion:e.aoMapIntensity,emissiveColor:Ki(e.emissive),emissiveIntensity:e.emissiveIntensity,clearcoatIntensity:e.clearcoat,clearcoatRoughness:e.clearcoatRoughness,clearcoatNormalScale:e.clearcoatNormalScale.x,sheenColor:Ki(e.sheenColor),sheenIntensity:e.sheen,sheenRoughness:e.sheenRoughness,thicknessFactor:e.thickness,attenuationColor:Ki(e.attenuationColor),attenuationDistance:e.attenuationDistance}),Wi=(e,t)=>{if(void 0!==t){const n=new h(t.r,t.g,t.b);e.copy(n.convertSRGBToLinear())}},Ki=e=>{const t=e.clone().convertLinearToSRGB();return{r:t.r,g:t.g,b:t.b}};let qi=null;const Xi=e("a0",(e,t,n,s,i,a,r=16)=>(qi||(qi=new R,qi.crossOrigin=""),new Promise((o,l)=>{if(!e)return console.warn("trying to add a texture without image",t),void o();qi.load(e,e=>{Yi(e,t,n,s,i,a,r),o()},l)}))),Yi=e("aA",(e,t,n,s,i,a,r=16)=>{e.anisotropy=s,e.wrapS=k,e.wrapT=k,r<=8&&["ORM","EMRGB","CCRG","CCXYZ","SHRGBA","SPRGBA","TTRG"].includes(t.mapping)?console.warn("ORM maps are not supported on devices with only "+r+" texture units"):(e.repeat.set(i,a),Qi(e,t,n),"RGBA"===t.mapping&&(n.transparent=!0,1===n.userData.materialVersion)&&n.name.includes("glow")&&(n.emissiveIntensity=.5,n.emissive=new h(16777215),n.emissiveMap=n.map),n.needsUpdate=!0)}),Qi=(e,t,n)=>{"XYZ"===t.mapping?(n.normalMap=e,n.map===Ui()&&(n.map=null)):"ORM"===t.mapping?(n.aoMap=e,n.roughnessMap=e,n.metalnessMap=e):"EMRGB"===t.mapping?n.emissiveMap=e:"CCRG"===t.mapping?(n.clearcoatMap=e,n.clearcoatRoughnessMap=e):"CCXYZ"===t.mapping?n.clearcoatNormalMap=e:"SHRGBA"===t.mapping?(n.sheenColorMap=e,n.sheenRoughnessMap=e):"SPRGBA"===t.mapping?(n.specularColorMap=e,n.specularIntensityMap=e):"TTRG"===t.mapping?(n.transmissionMap=e,n.thicknessMap=e):(e.colorSpace=S,n.map=e)},Zi=e("a1",(e=!0)=>(window.__RML_GUI__||(window.__RML_GUI__=new Di({autoPlace:e})),window.__RML_GUI__)),Ji=(e("ak",(e,t)=>{let n=!1;for(const s of t){const t=s.getKernelObject();let i;2===t.wallType.value&&(i=bs(t.rightNormal)),1===t.wallType.value&&(i=bs(t.leftNormal));let a=!0;if(i){let t=bs(s.getPlanElement().getCenter());t=t.applyMatrix4(e.matrixWorldInverse),i=i.transformDirection(e.matrixWorldInverse),a=t.dot(i)>=0}a!==s.getContainer().visible&&(n=!0),a?s.show():s.isSelected||s.hide()}return n}),e("ao",(e,t,n=!0)=>{if(!e.userData.tween)if(t)if(e.transparent=!0,n){let t={opacity:1};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:.2},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.userData.tween=!1}).start()}else e.opacity=.2;else if(n){let t={opacity:.2};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:1},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.transparent=!1,e.userData.tween=!1}).start()}else e.opacity=1,e.transparent=!1}),e=>{let t=new h;return t.setRGB((e>>16)/255,(e>>8&255)/255,(e>>0&255)/255),t}),$i=(e("aa",(e,t)=>{e.traverse(e=>{if(e instanceof z&&TWEEN){const n=e.material;e.userData.tween&&e.userData.tween.stop();const s={opacity:n.opacity};t.transparent&&(n.transparent=t.transparent),e.userData.tween=new TWEEN.Tween(s).to(t,250).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{n.opacity=s.opacity}).onStop(()=>{t.transparent||(n.transparent=t.transparent),n.opacity=t.opacity,n.needsUpdate=!0,e.userData.tween=void 0}).onComplete(()=>{t.transparent||(n.transparent=t.transparent),n.needsUpdate=!0,e.userData.tween=void 0}).start()}})}),e("al",e=>{e.traverse(e=>{if(e instanceof z&&TWEEN){let t=e.material;if(0===t.opacity)return;let n={opacity:0,transparent:!0},s={opacity:t.opacity,transparent:t.transparent};t.transparent=n.transparent,t.opacity=n.opacity,new TWEEN.Tween(n).to(s,500).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{t.opacity=n.opacity}).onComplete(()=>{t.transparent=s.transparent}).start()}})})),ea=e("w",e=>{"Mesh"===e.type?na(e):ta(e)}),ta=e=>{e&&e.children&&0!==e.children.length&&e.children.forEach(e=>{na(e)})},na=e("h",e=>{e&&(e.material&&ia(e.material),e.geometry&&sa(e.geometry),e.children&&e.children.length>0&&ta(e))}),sa=e=>{e&&e.dispose()},ia=e=>{e&&(e.map&&e.map.dispose(),e.normalMap&&e.normalMap.dispose(),e.dispose())};let aa;e("v",e=>0===e.x&&0===e.y&&0===e.z);const ra=(e,t)=>{let n="";return e||""===e?(e.materialId&&""!==e.materialId?n=e.materialId:e.catalogItemId&&""!==e.catalogItemId?n=e.catalogItemId:e.rgbValue>0?n="rgb"+JSON.stringify(e.rgbValue):e.length>0?n=e:t&&1===t.value?n="default_wall_material_"+e.getSourceType().value:t&&7===t.value&&(n="default_ceiling_material_"+e.getSourceType().value),n):null},oa=(e("x",e=>{let t=e.getWorldDirection(new r).clone();t.y=0,t.lengthSq()<.01&&(t=new r(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}),e("g",(e,t)=>{if(!e||!t)return 0;const n=e.clone().expandByScalar(.001).containsBox(t),s=t.clone().expandByScalar(.001).containsBox(e);return s&&n||!s&&!n?0:!0===n?1:-1}),e("ag",(e,t,n,s=1)=>{const i=t>n,a=i?15:0,o=i?0:10,l=e.getSize(new r),h=e.getCenter(new r);let d=l.x>2*a?l.x/2:a,c=l.z>2*o?l.z/2:o;return d*=s,c*=s,new ge(new r(h.x-d,h.y,h.z-c),new r(h.x+d,h.y,h.z+c))}),e("af",e=>{const{x:t,y:n}=e;return{x:t,y:n}})),la=e=>{const{x:t,y:n,z:s}=e;return{x:t,y:n,z:s}};e("an",(e,t,n)=>(new r).setFromSphericalCoords(e,Math.PI*(1-n),2*Math.PI*(1-t))),e("u",e=>{const t=new xe;return t.environment=e.environment.clone(),t.userData.environmentDefinition=e.userData.environmentDefinition.clone(),t.userData.shadowFromEnvironment=e.userData.shadowFromEnvironment,t}),e("am",(e,t)=>{const n=new Pe,s=(new P).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i=new ge;n.setFromProjectionMatrix(s);const a=i.setFromObject(t).getCenter(new r);return n.containsPoint(a)}),e("aG",e=>Math.atan2(Math.sin(e),Math.cos(e)));var ha=e("a9","static/default_256-f1c66a2764f88cc0.exr");const da={uniforms:{tDiffuse:{value:null},colorTransform:{value:new P},colorBase:{value:new Me(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new Ce}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"},ca=new P,ua=(new P).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),pa=(new P).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),ma=(new P).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1);(new P).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new P).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1);const ga=(new P).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),fa=new Me(0,0,0,0),_a=new Me(0,0,0,1),va=new Ce,wa=(new Ce).set(1,0,0,0,-1,1,0,0,1);class ba extends Te{constructor(e,t="additive",n=!1,s=!1){const i="additive"===t?{blendSrc:Ae,blendDst:Re,blendEquation:Ee,blendSrcAlpha:Ie,blendDstAlpha:Re,blendEquationAlpha:Ee}:{};super({uniforms:De.clone(da.uniforms),vertexShader:da.vertexShader,fragmentShader:da.fragmentShader,defines:{LINEAR_TO_SRGB:n?1:0,PREMULTIPLIED_ALPHA:s?1:0},transparent:!0,depthTest:!1,depthWrite:!1,...i}),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const ya={uniforms:{tDiffuse:{value:null},rangeMin:{value:new a(1/512,1/512)},rangeMax:{value:new a(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new a(.1,.9),new a(.1,.9);class Sa extends Te{constructor(e){super({defines:Object.assign({},Sa._linearDepthShader.defines),uniforms:De.clone(Sa._linearDepthShader.uniforms),vertexShader:Sa._linearDepthShader.vertexShader,fragmentShader:Sa._linearDepthShader.fragmentShader,blending:Oe}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}Sa._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new Me(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include <packing>\n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};const xa=new Q(-1,1,1,-1,0,1),Pa=new class extends c{constructor(){super(),this.setAttribute("position",new ke([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ke([0,2,0,0,2,0],2))}};class Ma{constructor(e){this._mesh=new z(Pa,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,xa)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Ca{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,s){return e[0]*t+e[1]*n+e[2]*s}dot4(e,t,n,s,i){return e[0]*t+e[1]*n+e[2]*s+e[3]*i}noise(e,t){let n,s,i;const a=(e+t)*(.5*(Math.sqrt(3)-1)),r=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,h=(r+o)*l,d=e-(r-h),c=t-(o-h);let u,p;d>c?(u=1,p=0):(u=0,p=1);const m=d-u+l,g=c-p+l,f=d-1+2*l,_=c-1+2*l,v=255&r,w=255&o,b=this.perm[v+this.perm[w]]%12,y=this.perm[v+u+this.perm[w+p]]%12,S=this.perm[v+1+this.perm[w+1]]%12;let x=.5-d*d-c*c;x<0?n=0:(x*=x,n=x*x*this.dot(this.grad3[b],d,c));let P=.5-m*m-g*g;P<0?s=0:(P*=P,s=P*P*this.dot(this.grad3[y],m,g));let M=.5-f*f-_*_;return M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,_)),70*(n+s+i)}noise3d(e,t,n){let s,i,a,r;const o=(e+t+n)*(1/3),l=Math.floor(e+o),h=Math.floor(t+o),d=Math.floor(n+o),c=(l+h+d)*(1/6),u=e-(l-c),p=t-(h-c),m=n-(d-c);let g,f,_,v,w,b;u>=p?p>=m?(g=1,f=0,_=0,v=1,w=1,b=0):u>=m?(g=1,f=0,_=0,v=1,w=0,b=1):(g=0,f=0,_=1,v=1,w=0,b=1):p<m?(g=0,f=0,_=1,v=0,w=1,b=1):u<m?(g=0,f=1,_=0,v=0,w=1,b=1):(g=0,f=1,_=0,v=1,w=1,b=0);const y=u-g+1/6,S=p-f+1/6,x=m-_+1/6,P=u-v+1/6*2,M=p-w+1/6*2,C=m-b+1/6*2,T=u-1+.5,A=p-1+.5,R=m-1+.5,E=255&l,I=255&h,D=255&d,O=this.perm[E+this.perm[I+this.perm[D]]]%12,k=this.perm[E+g+this.perm[I+f+this.perm[D+_]]]%12,L=this.perm[E+v+this.perm[I+w+this.perm[D+b]]]%12,U=this.perm[E+1+this.perm[I+1+this.perm[D+1]]]%12;let B=.6-u*u-p*p-m*m;B<0?s=0:(B*=B,s=B*B*this.dot3(this.grad3[O],u,p,m));let N=.6-y*y-S*S-x*x;N<0?i=0:(N*=N,i=N*N*this.dot3(this.grad3[k],y,S,x));let F=.6-P*P-M*M-C*C;F<0?a=0:(F*=F,a=F*F*this.dot3(this.grad3[L],P,M,C));let G=.6-T*T-A*A-R*R;return G<0?r=0:(G*=G,r=G*G*this.dot3(this.grad3[U],T,A,R)),32*(s+i+a+r)}noise4d(e,t,n,s){const i=this.grad4,a=this.simplex,r=this.perm,o=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20;let h,d,c,u,p;const m=(e+t+n+s)*o,g=Math.floor(e+m),f=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(s+m),w=(g+f+_+v)*l,b=e-(g-w),y=t-(f-w),S=n-(_-w),x=s-(v-w),P=(b>y?32:0)+(b>S?16:0)+(y>S?8:0)+(b>x?4:0)+(y>x?2:0)+(S>x?1:0),M=a[P][0]>=3?1:0,C=a[P][1]>=3?1:0,T=a[P][2]>=3?1:0,A=a[P][3]>=3?1:0,R=a[P][0]>=2?1:0,E=a[P][1]>=2?1:0,I=a[P][2]>=2?1:0,D=a[P][3]>=2?1:0,O=a[P][0]>=1?1:0,k=a[P][1]>=1?1:0,L=a[P][2]>=1?1:0,U=a[P][3]>=1?1:0,B=b-M+l,N=y-C+l,F=S-T+l,G=x-A+l,j=b-R+2*l,z=y-E+2*l,V=S-I+2*l,H=x-D+2*l,W=b-O+3*l,K=y-k+3*l,q=S-L+3*l,X=x-U+3*l,Y=b-1+4*l,Q=y-1+4*l,Z=S-1+4*l,J=x-1+4*l,$=255&g,ee=255&f,te=255&_,ne=255&v,se=r[$+r[ee+r[te+r[ne]]]]%32,ie=r[$+M+r[ee+C+r[te+T+r[ne+A]]]]%32,ae=r[$+R+r[ee+E+r[te+I+r[ne+D]]]]%32,re=r[$+O+r[ee+k+r[te+L+r[ne+U]]]]%32,oe=r[$+1+r[ee+1+r[te+1+r[ne+1]]]]%32;let le=.6-b*b-y*y-S*S-x*x;le<0?h=0:(le*=le,h=le*le*this.dot4(i[se],b,y,S,x));let he=.6-B*B-N*N-F*F-G*G;he<0?d=0:(he*=he,d=he*he*this.dot4(i[ie],B,N,F,G));let de=.6-j*j-z*z-V*V-H*H;de<0?c=0:(de*=de,c=de*de*this.dot4(i[ae],j,z,V,H));let ce=.6-W*W-K*K-q*q-X*X;ce<0?u=0:(ce*=ce,u=ce*ce*this.dot4(i[re],W,K,q,X));let ue=.6-Y*Y-Q*Q-Z*Z-J*J;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(i[oe],Y,Q,Z,J)),27*(h+d+c+u+p)}}new R;class Ta{constructor(){this.bounds=new ge(new r(-1,-1,-1),new r(1,1,1)),this.size=new r(2,2,2),this.center=new r(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new r(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Q?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof X&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),s=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const i=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=i/a,e.fov=Y.radToDeg(2*Math.atan2(a,n)),e.near=n,e.far=s,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}class Aa{changed(e){var t,n;const s=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),s}}class Ra{constructor(){this._originalClearColor=new h,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new Ma(void 0),this._emptyScene=new xe,this._defaultCamera=new X}renderWithOverrideMaterial(e,t,n,s,i,a,r){this._backup(e),this._prepareRenderer(e,i,a,r);const o=t.overrideMaterial;t.overrideMaterial=s,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,s){this._backup(e),this._prepareRenderer(e,t,n,s),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,s,i,a){this._backup(e),this._prepareRenderer(e,s,i,a),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,s,i){this._backup(e),this._prepareRenderer(e,n,s,i),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,s){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(s||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class Ea{constructor(e,t){var n;this._passRenderer=null!==(n=null==t?void 0:t.passRenderer)&&void 0!==n?n:new Ra,this._blurMaterial=new Te(null!=e?e:ya),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,s){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=s[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=s[1],this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[2])}}const Ia=(e,t)=>{const n=Da(e,t);let s="vec4[SAMPLES](";for(let t=0;t<e;t++){const i=n[t];s+=`vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})${t<e-1?",":")"}`}return s},Da=(e,t)=>{const n=[];for(let s=0;s<e;s++){const i=s*Math.PI*(3-Math.sqrt(5)),a=.01+s/(e-1)*.99,r=t?Math.sqrt(1-a*a):1-a,o=Math.cos(i)*r,l=Math.sin(i)*r,h=4,d=Math.floor(e/h);let c=1-(Math.floor(s/h)+s%h*d)/e;c=.1+.9*c,n.push(new Me(o,l,a,c))}return n},Oa={name:"AOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,SAMPLE_VECTORS:Ia(16,!1),NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",AO_ALGORITHM:4,NV_ALIGNED_SAMPLES:1,SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0,NORMAL_VECTOR_ANTIALIAS:2,DEPTH_BUFFER_ANTIALIAS:1},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new a},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new P},cameraProjectionMatrixInverse:{value:new P},cameraWorldMatrix:{value:new P},radius:{value:1},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},bias:{value:.001},scale:{value:1},sceneBoxMin:{value:new r(-1,-1,-1)},sceneBoxMax:{value:new r(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float bias;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},ka={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class La{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n,s,i){this.needsUpdate=!0,this.parameters={...ka},this._width=0,this._height=0,this._samples=0,this._gBufferAntiAliasing=!1,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._passRenderer=new Ra,this._sceneClipBox=new ge(new r(-1,-1,-1),new r(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._samples=n,this._gBufferAntiAliasing=s,this._normalVectorSourceType=(null==i?void 0:i.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==i?void 0:i.depthValueSourceType)||"normalVectorAlpha",this._modulateRedChannel=(null==i?void 0:i.modulateRedChannel)||!1,(null==i?void 0:i.aoParameters)&&(this.parameters=i.aoParameters),i&&this.updateTextures(i)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ca,n=new Uint8Array(e*e*4);for(let s=0;s<e;s++)for(let i=0;i<e;i++){const a=s,r=i;n[4*(s*e+i)]=127.5*(t.noise(a,r)+1),n[4*(s*e+i)+1]=127.5*(t.noise(a+e,r)+1),n[4*(s*e+i)+2]=127.5*(t.noise(a,r+e)+1),n[4*(s*e+i)+3]=127.5*(t.noise(a+e,r+e)+1)}this._noiseTexture=new ye(n,e,e,be,Le),this._noiseTexture.wrapS=k,this._noiseTexture.wrapT=k,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;return this._aoMaterial||(this._aoMaterial=this._newAoMaterial(),n=!0),n&&(this._updateShader(this._aoMaterial,e),this._aoMaterial.needsUpdate=!0),this._updateUniforms(this._aoMaterial,e,n),this._aoMaterial}_newAoMaterial(){const e=new Te({defines:Object.assign({},Oa.defines),uniforms:De.clone(Oa.uniforms),vertexShader:Oa.vertexShader,fragmentShader:Oa.fragmentShader,depthTest:!1,depthWrite:!1});return this._modulateRedChannel&&(e.blending=Ue,e.blendEquation=Be,e.blendEquationAlpha=null,e.blendSrc=Ne,e.blendSrcAlpha=null,e.blendDst=Ne,e.blendDstAlpha=null),e.defines.FRAGMENT_OUTPUT=this._modulateRedChannel?"vec4(ao, 1., 1., 1.)":void 0,e.uniforms.tNoise.value=(e=>{const t=new Ca,n=Math.floor(5)%2==0?Math.floor(5)+1:Math.floor(5),s=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,s=Array(n).fill(0);let i=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===i&&a===t?(a=t-2,i=0):(a===t&&(a=0),i<0&&(i=t-1)),0===s[i*t+a]?(s[i*t+a]=e++,a++,i--):(a-=2,i++);return s})(n),i=s.length,a=new Uint8Array(4*i);for(let e=0;e<i;++e){const n=s[e],o=2*Math.PI*n/i,l=new r(Math.cos(o),Math.sin(o),0).normalize();a[4*e]=255*(.5*l.x+.5),a[4*e+1]=255*(.5*l.y+.5),a[4*e+2]=127,a[4*e+3]=255*(.5*t.noise(e/5,e%5)+.5)}const o=new ye(a,n,n);return o.wrapS=k,o.wrapT=k,o.needsUpdate=!0,o})(),e}_updateShader(e,t){e.defines.PERSPECTIVE_CAMERA=t.isPerspectiveCamera?1:0,e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=Ia(this.parameters.samples,0===this.parameters.algorithm),e.defines.NORMAL_VECTOR_TYPE="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_SWIZZLING="normalVectorAlpha"===this._depthValueSourceType?"a":"x",e.defines.AO_ALGORITHM=this.parameters.algorithm,e.defines.NV_ALIGNED_SAMPLES=3===this.parameters.algorithm||4===this.parameters.algorithm?0:1,e.defines.SCREEN_SPACE_RADIUS=this.parameters.screenSpaceRadius?1:0,e.defines.SCENE_CLIP_BOX=1,e.defines.NORMAL_VECTOR_ANTIALIAS=this._gBufferAntiAliasing?2:0,e.defines.DEPTH_BUFFER_ANTIALIAS=this._gBufferAntiAliasing?1:0}_updateUniforms(e,t,n){const s=this.parameters.screenSpaceRadius?1:this._sceneScale,i="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;e.uniforms.tNormal.value=this.normalTexture,e.uniforms.tDepth.value=i,e.uniforms.resolution.value.set(this._width,this._height),e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse),e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld);const a=t;e.uniforms.cameraNear.value=a.near,e.uniforms.cameraFar.value=a.far,n&&(e.uniforms.radius.value=this.parameters.radius*s,e.uniforms.distanceExponent.value=this.parameters.distanceExponent,e.uniforms.thickness.value=this.parameters.thickness*s,e.uniforms.distanceFallOff.value=this.parameters.distanceFallOff,e.uniforms.scale.value=this.parameters.scale,this._sceneClipBox&&(e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min),e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)))}_getRenderTargets(){return this._renderTarget||(this._renderTarget=new Fe(this._width,this._height,{samples:this._samples,magFilter:D,minFilter:D})),this._renderTarget}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._aoMaterial)||void 0===t||t.dispose(),null===(n=this._renderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._renderTarget)||void 0===n||n.setSize(e,t),this.needsUpdate=!0}updateBounds(e,t){this._sceneClipBox=(new ge).copy(e),this._sceneScale=null!=t?t:1,this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}clear(e,t){this._passRenderer.clear(e,t||this._getRenderTargets(),16777215,1)}render(e,t,n,s){const i=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,i,s||this._getRenderTargets())}}const Ua={shadowType:"PCFSoftShadowMap",shAndAoPassParameters:{aoIntensity:.3,shadow:{shadowRadius:.1},ao:{algorithm:0,samples:32,radius:.02,distanceExponent:2,thickness:.1,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:.4,normalPhi:4}},groundReflectionParameters:{brightness:.5}},Ba=e=>Math.max(0,Math.min(1,e));class Na{constructor(e){return this.autoQuality=!1,this.colors=(e=>{const t={},n=Object.keys(e);for(const s of n){const n=e[s];t[s]=He(n)?n:Ve(n)}return t})(We),this.unit=null,this.unitStringType=null,this.meshSelection=!0,this.stats=!1,this._measureTraffic=!1,this.disableDebugGUI=!1,this.disableEnvMap=!1,this.envMapUrl=ha,this.envMapIntensity=1.5,this.envMapRotation=0,this.maxLightSources=-1,this.legacyLight=!1,this.sceneLight=null,this.shading="default",this.restrictionLevel=0,this.highlighting=je.SMART,this.dls=null,this.ls=null,this.cameraSpacing=0,this.transparentHighlighting=!0,this.featureFlags={pulsePreview:!1,reDock:!1,configureInRoom:!1,advancedDocking:!1},this.mode=ze.CAMERA_3D,this.edit=!1,this.moc=!1,this.callbacksOnlyIfGeometryIsReady=!0,this._creator_=e,new Proxy(this,{get:(e,t)=>"colors"===t?e.colors?new Proxy(e.colors,{get:(e,t)=>Ve(e[t]),set:(t,n,s)=>(e.colors[n]=Ve(s),!0)}):e.colors:e[t]})}setOverrides(e){Ge(this,e)}}e("aF",Na);const Fa=["language","browserLanguage","userLanguage","systemLanguage"];e("ac",/^((?!chrome|android).)*safari/i.test(navigator.userAgent));class Ga{constructor(e){this.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,n=Fa.length;e<n;e++){const n=t[Fa[e]];if(n)return n.substr(0,2)}return"en"})()||"en",this.overrideCountry=null,this.e2e=!1,this.e2eRoomleRendererForImages=!1,this._creator_=e}setOverrides(e){Ge(this,e)}}e("aE",Ga);class ja{_setMute(e){Ke(this,"_isMute",!0),this._isMute=e,Ke(this,"_isMute",!1)}mute(){this._setMute(!0)}unmute(){this._setMute(!1)}constructor(e){return this._isMute=!1,this.cameraStartsMoving=()=>{},this._creator_=e,qe(this,"_isMute",{enumerable:!1,writable:!1}),qe(ja.prototype,"_setMute",{enumerable:!1,writable:!1}),qe(ja.prototype,"mute",{enumerable:!1,writable:!1}),qe(ja.prototype,"unmute",{enumerable:!1,writable:!1}),new Proxy(this,this)}get(e,t){return this._isMute&&"function"==typeof this[t]&&"on"===t.substr(0,2)?()=>{}:this[t]}}e("aB",ja);class za extends ja{constructor(){super(...arguments),this.onNetworkRequest=(e,t,n)=>{},this.onKernelMsg=(e,t,n={})=>{},this.onCheckExternalCache=async(e,t)=>Promise.resolve(null),this.onValidateNetworkResponse=(e,t)=>Promise.resolve(!0),this.onApiJsonReceived=async(e,t,n)=>Promise.resolve(void 0)}}e("aD",za),e("m",{HSC:"rml-configurator",HSP:"rml-hsp",GLB:"rml-glb",RMV:"rml-mv"});class Va{get element(){return this._container}constructor(e){this._creator_=e,this._lifeCycleManager.addEventListener(this)}setDomElement(e){if(!this._container){this._container=document.createElement("div"),this._container.classList.add("rml-threejs-canvas-container"),this._container.setAttribute("ondragover","return false"),this._container.style.position="relative",this._container.style.width="100%",this._container.style.height="100%";const t=document.createElement("style");t.innerText=".rml-threejs-canvas-container canvas{position:absolute;top:0;left:0;right:0;bottom:0;z-index:100; opacity:1;}",this._container.appendChild(t),e.appendChild(this._container)}this._element=e}getClientDimensions(){return new a(this._element.clientWidth,this._element.clientHeight)}_removeDomElement(e){if(!e)return;const t=e.parentElement;t&&t.removeChild(e)}reset(){this._element=null,this._removeDomElement(this._container),this._container=null}pause(){this.reset()}resume(){}destroy(){}}on([hn],Va.prototype,"_lifeCycleManager",void 0),e("aI",class{constructor(e){this._creator_=e}setScene(e){}setUiScene(e){}updateBounds(e){}clearScene(e,t){}moveCameraEnd(e){}moveCameraStart(e){}needsUiScene(){return!1}});class Ha{constructor(e){this._plugins=[],this._creator_=e}async init(e,n,s){this._scene=e,this._uiScene=n,this._cameraPosition=s;const{bananaForScale:i}=this._initData;i&&await t.import("./banana-for-scale-747faad0.nomodule.js").then(({default:e})=>this._plugins.push(new e(this._creator_))),this._plugins.forEach(e=>e.setScene(this._scene)),this._plugins.forEach(e=>e.setUiScene(this._uiScene)),this._plugins.forEach(e=>e.updateBounds(this._bounds)),this._plugins.forEach(e=>e.moveCameraEnd(this._cameraPosition))}addPlugin(e){this._plugins.push(e),e.setScene(this._scene),e.setUiScene(this._uiScene),e.updateBounds(this._bounds),e.moveCameraEnd(this._cameraPosition)}updateBounds(e){this._bounds=e,this._plugins.forEach(t=>t.updateBounds(e))}clearScene(e,t){this._plugins.forEach(n=>n.clearScene(e,t))}getActivePlugins(){return this._plugins}getPlugin(e){for(let t of this._plugins)if(t instanceof e)return t;return null}moveCameraEnd(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraEnd(e))}moveCameraStart(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraStart(e))}needsUiScene(){return this._plugins.map(e=>e.needsUiScene()).reduce((e,t)=>e||t,!1)}}on([hn],Ha.prototype,"_initData",void 0);class Wa{constructor(e,t){this._waitingPromises=[],this._finishPromiseExecutor=[],this._errorCallback=()=>{},Promise.allSettled=Promise.allSettled||(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),e&&this.registerCallback(e),t&&(this._errorCallback=t)}push(e){this._waitingPromises.push(e),Promise.all(this._waitingPromises).then(e=>{e.length===this._waitingPromises.length&&(this._callback&&this._callback(e),this._waitingPromises=[])},this._errorCallback)}finished(e=!1){return new Promise((t,n)=>{this._finishPromiseExecutor.push({resolve:t,reject:n});const s=e?"allSettled":"all";Promise[s](this._waitingPromises).then(e=>{if("allSettled"===s){const t=[];e.forEach(({value:e,status:n})=>{"fulfilled"===n&&t.push(e)}),this._resolveAllExecutors(t)}else this._resolveAllExecutors(e)},e=>{this._rejectAllExecutors(e)})})}registerCallback(e){this._callback=e}unregisterCallback(){this._callback=null}_resolveAllExecutors(e){this._finishPromiseExecutor.forEach(({resolve:t})=>t(e)),this._finishPromiseExecutor=[]}_rejectAllExecutors(e){this._finishPromiseExecutor.forEach(({reject:t})=>t(e)),this._finishPromiseExecutor=[]}clear(){const e=this._waitingPromises.length>0;this._waitingPromises=[],e?this._rejectAllExecutors(new Error("Promise queue has been cleared")):this._resolveAllExecutors([])}get length(){return this._waitingPromises.length}}class Ka{constructor(e){this.materialQueue=new Wa,this._geometryComponentMaterialCache=new Map,this._maxAnisotropy=1,this._maxTextures=16,this._textureLoader=new R,this._configuratorPreviewMaterial=Oi.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:1,roughness:1,envMap:null,polygonOffset:!0,polygonOffsetFactor:-1}),this._creator_=e,this._previewMaterial=Oi.createMeshStandardMaterial({color:"#DDDDDD",roughness:1,metalness:0})}getGeometry(e){return e&&this._cacheHolder.geometryCache.has(e)?this._cacheHolder.geometryCache.get(e):null}_generateGeometry(e,t,n,s,i){let a;return e&&this._cacheHolder.geometryCache.has(e)?a=this._cacheHolder.geometryCache.get(e):(a=new c,a.setIndex(new Xe(n,1)),a.setAttribute("position",new ke(t,3)),a.setAttribute("normal",new ke(i,3)),a.setAttribute("uv",new ke(s,2)),a.scale(.001,.001,.001),a.rotateX(-Math.PI/2),e&&this._cacheHolder.geometryCache.set(e,a)),a}changeMaterialOfMesh(e,t,n){e&&t?(e.material=t,e.material.transparent||0===e.material.opacity||e.material.transmission>0?(e.castShadow=!1,e.receiveShadow=!1):(e.castShadow=!0,e.receiveShadow=!0),e.material.needsUpdate=!0,this._materialLoaded&&this._materialLoaded(t),this._updateMaterialProperties(e,n)):console.warn("could not assign material to mesh",{mesh:e},{material:t})}_updateMaterialProperties(e,t){var n;if(t&&Object.keys(t).length>0&&e.material instanceof N){const s=e.material.clone();s.userData.materialAttributes=t,this._updateStandardMaterialProperties(s,t),s instanceof x&&this._updatePhysicalMaterialProperties(s,t),s.transparent=s.opacity<1;const i=e.material;e.material=s,(null===(n=i.userData)||void 0===n?void 0:n.materialAttributes)&&i.dispose()}}_updateStandardMaterialProperties(e,t){t.color&&(e.color=new h(t.color)),t.alpha&&(e.opacity=parseFloat(t.alpha)),t.roughness&&(e.roughness=parseFloat(t.roughness)),t.metallic&&(e.metalness=parseFloat(t.metallic)),t.alphaCutoff&&(e.alphaTest=parseFloat(t.alphaCutoff)),t.doubleSided&&(e.side=t.doubleSided?F:he),t.occlusion&&(e.aoMapIntensity=parseFloat(t.occlusion)),t.emissiveColor&&(e.emissive=new h(t.emissiveColor)),t.emissiveIntensity&&(e.emissiveIntensity=parseFloat(t.emissiveIntensity))}_updatePhysicalMaterialProperties(e,t){t.transmission&&(e.transmission=parseFloat(t.transmission)),t.specularColor&&(e.specularColor=new h(t.specularColor)),t.specularity&&(e.specularIntensity=parseFloat(t.specularity)),t.clearcoatIntensity&&(e.clearcoat=parseFloat(t.clearcoatIntensity)),t.clearcoatRoughness&&(e.clearcoatRoughness=parseFloat(t.clearcoatRoughness)),t.clearcoatNormalScale&&e.clearcoatNormalScale.setScalar(parseFloat(t.clearcoatNormalScale)),t.sheenColor&&(e.sheenColor=new h(t.sheenColor)),t.sheenIntensity&&(e.sheen=parseFloat(t.sheenIntensity)),t.sheenRoughness&&(e.sheenRoughness=parseFloat(t.sheenRoughness)),t.thicknessFactor&&(e.thickness=parseFloat(t.thicknessFactor)),t.attenuationColor&&(e.attenuationColor=new h(t.attenuationColor)),t.attenuationDistance&&(e.attenuationDistance=parseFloat(t.attenuationDistance))}_createMaterial(e,t,n,s,i){if(this._cacheHolder.materialCache.has(e))t();else if(e.startsWith("benchmarkMaterial")){let a=Ye(e),r=Ni(a);this._loadBenchmarkTextures(a,r,s,i).then(t,n)}else this._rapiAccess.getMaterial(e).then(e=>{let a=Ni(e);this._loadTextures(e,a,s,i).then(t,n)},n)}_loadBenchmarkTextures(e,t,n=1,s=1){return new Promise((i,a)=>{const r=Qe(e.id);Xi(this._dataSyncer.requestAsset(r.image,!0),r,t,this._maxAnisotropy,n/(0===r.mmWidth?1:r.mmWidth),s/(0===r.mmHeight?1:r.mmHeight),this._maxTextures).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},a)})}_loadTextures(e,t,n=1,s=1){return new Promise((i,a)=>{if(!e.textures||e.textures&&0===e.textures.length)return this._cacheHolder.materialCache.set(e.id,t),i();this._rapiAccess.getTexturesOf(e).then(r=>{let o=[];r.forEach(e=>{o.push(Xi(this._dataSyncer.requestAsset(e.image,!0),e,t,this._maxAnisotropy,n/(0===e.mmWidth?1:e.mmWidth),s/(0===e.mmHeight?1:e.mmHeight),this._maxTextures))}),Promise.all(o).then(()=>{this._cacheHolder.materialCache.set(e.id,t),i()},a)})})}_loadMaterial(e,t,n){return new Promise((s,i)=>{this._singlePromiseFactory.create(6,e,(s,i)=>this._createMaterial(e,s,i,t,n)).then(()=>{setTimeout(()=>s(this._cacheHolder.materialCache.get(e)),0)},i)})}_assignMaterial(e,t,n){return this._cacheHolder.materialCache.has(t)?(this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t),n),Promise.resolve()):new Promise((s,i)=>{this._loadMaterial(t).then(i=>{e.userData.materialId===t&&this.changeMaterialOfMesh(e,i,n),s()},i)})}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy=e}get maxTextures(){return this._maxTextures}set maxTextures(e){this._maxTextures=e}clear(){this._cacheHolder.clear()}_assignRGB(e,t){return new Promise(n=>{let s,i="rgb"+JSON.stringify(t);this._cacheHolder.materialCache.has(i)?s=this._cacheHolder.materialCache.get(i):(s=Oi.createMeshPhysicalMaterial({color:t}),this._cacheHolder.materialCache.set(i,s)),this.changeMaterialOfMesh(e,s),setTimeout(()=>n(),0)})}_assignItem(e,t){return new Promise((n,s)=>{if(this._cacheHolder.materialCache.has(t))return this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t)),void n();this._rapiAccess.getItem(t).then(i=>{if(i.topImage)this._textureLoader.load(i.topImage,s=>{s.anisotropy=this._maxAnisotropy,s.wrapS=k,s.wrapT=k;let r=new a(1,1);i.width>0&&(r.x=1/i.width),i.depth>0&&(r.y=1/i.depth),s.repeat.set(r.x,r.y);const o=Oi.createMeshPhysicalMaterial({map:s,roughness:.5,metalness:.1});this._cacheHolder.materialCache.set(t,o),this.changeMaterialOfMesh(e,o),setTimeout(()=>n(),0)});else{const e="can not set material, catalog item top image is not set";console.warn(e),s(e)}},s)})}setMaterialLoadedListener(e){this._materialLoaded=e}removeMaterialLoadedListener(){this._materialLoaded=void 0}_createMesh(e,t,n){if(e&&t){const s=this._getComponentMeshId(e,t);if(this._geometryComponentMaterialCache.has(s)){const e=this._geometryComponentMaterialCache.get(s);if(this._cacheHolder.materialCache.has(e)){const t=this._cacheHolder.materialCache.get(e);return new z(n,t)}}}return new z(n,this._configuratorPreviewMaterial.clone())}_getComponentMeshId(e,t){return e+"_"+t}}on([hn],Ka.prototype,"_initData",void 0),on([hn],Ka.prototype,"_rapiAccess",void 0),on([hn],Ka.prototype,"_dataSyncer",void 0),on([hn],Ka.prototype,"_singlePromiseFactory",void 0),on([hn],Ka.prototype,"_cacheHolder",void 0),on([hn],Ka.prototype,"_plannerMeshGenerator",void 0);class qa extends Ka{constructor(e){super(e)}generateMesh(e=0,t=null,n,s,i,a,r,o=!1,l){let h;h=o?this._generateGeometry(t,s,i,a,r).clone():this._generateGeometry(t,s,i,a,r);const d=this._createMesh(e,t,h);return d.userData.materialId=n,d.layers.set(4),n&&this.materialQueue.push(this._assignMaterial(d,n,l).then(()=>{e&&t&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n)})),d}setMaterial(e,t,n,s){return this._assignMaterial(e,t,s)}loadMaterial(e,t,n){return super._loadMaterial(e,t,n)}loadTextures(e,t,n,s){return super._loadTextures(e,t,n,s)}}e("aC",qa);class Xa{constructor(){this._listeners={},this._disabled=!1}_addEventListener(e,t,n){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push({callback:t,scope:n})}addEventListener(e,t,n){this._addEventListener(e,t,n)}dispatchEvent(e,t){if(!this._listeners[e]||this._disabled)return;const n=this._listeners[e];for(let s=0;s<this._listeners[e].length;s++){const e=n[s];t?e.callback.apply(e.scope,[t]):e.callback.call(e.scope)}}removeEventListener(e,t){const n=this._listeners[e];if(n)for(let e=0,s=n.length;e<s;e++)if(n[e].callback===t)return void n.splice(e,1)}enableEvents(){this._disabled=!1}disableEvents(){this._disabled=!0}}e("E",Xa);const Ya={SCROLL:"scroll",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_LEAVE:"mouseleave",MOUSE_ENTER:"mouseenter",MOUSE_WHEEL:"wheel",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend",CONTEXT_MENU:"contextmenu",DOUBLE_CLICK:"dblclick"};e("ae",{DRAG:50});class Qa{constructor(e,t,n,s,i){this.position=e,this.positionRelative=t,this.type=n,this.rotation=s,this.event=i}}const Za=e("a4",5*window.devicePixelRatio),Ja=4*window.devicePixelRatio;class $a extends Xa{constructor(e){super(),this._elementHit=!1,this._delta=-1,this._state=0,this._pinchDistance=-1,this._rotationAngle=-1,this._lastMouseWheelEvent=null,this._lastTouchEvent=null,this._events=Object.keys(Ya).map(e=>Ya[e]),this._boundingClientRectInvalid=!0,this._creator_=e,this._downPosition={x:0,y:0},this._downPositionRelative={x:0,y:0},this._boundingClientRect=this._getBoundingClientRect()}enableDragIn(e){this._setState(1),this._dragEnabled=!0,e&&(this._dragMV=this._dragM.bind(this),this._dragEV=this._dragE.bind(this),this._dragTarget=e.currentTarget||e.target,this._delta=-1,this._dragMVName="drag",this._dragEVName="dragend",window.TouchEvent&&e instanceof TouchEvent?(this._dragMVName="touchmove",this._dragEVName="touchend"):e.dataTransfer&&e.dataTransfer.setData&&e.dataTransfer.setData("text/plain"," "),this._firefoxDragPosition={x:0,y:0},document.ondragover=e=>{e=e||window.event,this._firefoxDragPosition.x=e.pageX,this._firefoxDragPosition.y=e.pageY},this._dragTarget.addEventListener(this._dragMVName,this._dragMV,!1),this._dragTarget.addEventListener(this._dragEVName,this._dragEV,!1))}isMouseUp(){return 0===this._state}_dragM(e){let t=e,n=null,s=null;window.TouchEvent&&e instanceof TouchEvent?(n=this._getTouchPosition(t),s=this._getTouchPositionRelative(t)):(n=this._getMousePosition(t),s=this._getMousePositionRelative(t)),n.x>0&&n.y>0&&this._move(n,s)}_dragE(e){let t=e;document.ondragover=null,this._firefoxDragPosition=null,this._dragTarget.removeEventListener(this._dragMVName,this._dragMV),this._dragTarget.removeEventListener(this._dragEVName,this._dragEV),window.TouchEvent&&e instanceof TouchEvent?this._onUp(this._getTouchPosition(t),this._getTouchPositionRelative(t),2):this._onUp(this._getMousePosition(t),this._getMousePositionRelative(t),1)}addEvents(e){this._events.forEach(t=>e.addEventListener(t,this,!1)),null===window||void 0===window||window.addEventListener("scroll",this,!1)}removeEvents(e){this._events.forEach(t=>e.removeEventListener(t,this)),null===window||void 0===window||window.removeEventListener("scroll",this)}_move2(e){if(this._lastTouchEvent&&e.timeStamp-this._lastTouchEvent.timeStamp<16)return;const t=e.touches[0],n=e.touches[1],s=t.pageX-n.pageX,i=t.pageY-n.pageY,a=Math.abs(s)+Math.abs(i);this._pinchDistance>-1&&(a>this._pinchDistance+Ja?(this._setState(3),this.dispatchEvent(7,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):a<this._pinchDistance-Ja?(this._setState(3),this.dispatchEvent(8,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):a<=this._pinchDistance+Ja&&a>=this._pinchDistance-Ja&&3!==this._state&&(this._setState(5),this.dispatchEvent(11,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e))))),this._pinchDistance=a,this._lastTouchEvent=e}_setState(e){this._state=e}_move(e,t,n,s){void 0===n&&(n=0),void 0===this._dragEnabled&&(this._dragEnabled=!1),1===this._state&&this._canDrag(n)&&(this._delta=this._getDelta(e),(this._delta>Za||this._elementHit)&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new Qa(this._downPosition,this._downPositionRelative)))),2===this._state&&this.dispatchEvent(1,new Qa(e,t)),this.dispatchEvent(6,new Qa(e,t,n,null,s))}_longClick(e){2!==e&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new Qa(this._downPosition,this._downPositionRelative)),this.dispatchEvent(1,new Qa(this._downPosition,this._downPositionRelative))),this.dispatchEvent(14,new Qa(this._downPosition,this._downPositionRelative,2))}_onUp(e,t,n){this.dispatchEvent(4,new Qa(e,t,n)),this._getDelta(e)<=Za&&this.dispatchEvent(5,new Qa(e,t)),2===this._state&&this.dispatchEvent(2,new Qa(e,t)),4===this._state&&(this.dispatchEvent(10,new Qa(e,t)),this._rotationAngle=-1),3!==this._state&&5!==this._state||(this._pinchDistance=-1),this._lastTouchEvent=null,this._setState(0),this._dragTarget=null,this._elementHit=!1,this._longClickTimer&&clearTimeout(this._longClickTimer)}_getTouchPosition(e){if(e.touches.length){let{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>1){const s=e.touches[1],i=s.clientX,a=s.clientY;t=(t+i)/2,n=(n+a)/2}return{x:t,y:n}}const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}_getTouchPositionRelative(e){const t=this._getBoundingClientRect(),{clientWidth:n,clientHeight:s}=this._domHelper.element;if(e.touches.length){const{clientX:i,clientY:a}=e.touches[0];return{x:(i-t.left)/n*2-1,y:-(a-t.top)/s*2+1}}const i=e.changedTouches[0];return{x:(i.clientX-t.left)/n*2-1,y:-(i.clientY-t.top)/s*2+1}}_getMousePosition(e){if(0!==e.clientX&&0!==e.clientY)return{x:e.clientX,y:e.clientY};{let{x:t,y:n}=this._getFireFoxMousePosition(e);return{x:t,y:n}}}_getFireFoxMousePosition(e){let{x:t,y:n}=this._domHelper.getClientDimensions();return{x:t-(t+e.offsetX),y:n-(n+e.offsetY)}}_getMousePositionRelative(e){const t=this._getBoundingClientRect();return 0!==e.clientX&&0!==e.clientY?{x:(e.clientX-t.left)/this._domHelper.element.clientWidth*2-1,y:-(e.clientY-t.top)/this._domHelper.element.clientHeight*2+1}:this._firefoxDragPosition&&0!==this._firefoxDragPosition.x&&0!==this._firefoxDragPosition.y?{x:(this._firefoxDragPosition.x-t.left)/this._domHelper.element.clientWidth*2-1,y:-(this._firefoxDragPosition.y-t.top)/this._domHelper.element.clientHeight*2+1}:{x:0,y:0}}_getDelta(e){return Math.abs(this._downPosition.y-e.y)+Math.abs(this._downPosition.x-e.x)}setDragEnabled(e){this._dragEnabled=e}handleEvent(e){switch(e.type){case Ya.SCROLL:this._boundingClientRectInvalid=!0;break;case Ya.MOUSE_MOVE:this._onMouseMove(e);break;case Ya.DOUBLE_CLICK:this._onDoubleClick(e);break;case Ya.MOUSE_DOWN:this._onMouseDown(e);break;case Ya.MOUSE_UP:this._onMouseUp(e);break;case Ya.MOUSE_LEAVE:this._onMouseLeave(e);break;case Ya.MOUSE_ENTER:this._onMouseEnter(e);break;case Ya.MOUSE_WHEEL:this._onMouseWheel(e);break;case Ya.TOUCH_MOVE:this._onTouchMove(e);break;case Ya.TOUCH_START:this._onTouchStart(e);break;case Ya.TOUCH_END:this._onTouchEnd(e);break;case Ya.CONTEXT_MENU:this._onContextMenu(e)}}_onMouseDown(e){if(e.preventDefault(),2===e.detail)return;let{x:t,y:n}=this._getMousePosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getMousePositionRelative(e),this.dispatchEvent(3,new Qa({x:t,y:n},this._downPositionRelative,1)),this._setState(1)}_onMouseUp(e){e.preventDefault(),2!==e.detail&&this._onUp(this._getMousePosition(e),this._getMousePositionRelative(e),1)}_onMouseMove(e){e.preventDefault(),this._move(this._getMousePosition(e),this._getMousePositionRelative(e),1,e)}_onDoubleClick(e){e.preventDefault(),this.dispatchEvent(12,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1))}_onMouseLeave(e){var t;this._delta=-1,(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest('[data-rml-sdk="ignore-mouse-leave"]'))||this._onMouseUp(e)}_onMouseEnter(e){e.preventDefault()}_onMouseWheel(e){if(this._lastMouseWheelEvent&&e.timeStamp-this._lastMouseWheelEvent.timeStamp<40)return e.preventDefault(),void e.stopPropagation();e.deltaY<0?this.dispatchEvent(7,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)):this.dispatchEvent(8,new Qa(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)),this._lastMouseWheelEvent=e}_onTouchMove(e){if(e.preventDefault(),!this._dragTarget)if(1===e.touches.length)this._move(this._getTouchPosition(e),this._getTouchPositionRelative(e),2);else if(2===e.touches.length)if(this._elementHit||4===this._state){const s=e.touches[0],i=e.touches[1],a=function(e){let t=vs(e);return t<0&&(t=180+(180+t)),t}((t={x:s.pageX,y:s.pageY},n={x:i.pageX,y:i.pageY},Math.atan2(n.y-t.y,n.x-t.x)));this._rotationAngle<0&&(this._rotationAngle=a);const r=a-this._rotationAngle;this._rotationAngle=a,this.dispatchEvent(9,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e),2,_s(r))),this._setState(4)}else this._move2(e);var t,n}_onTouchStart(e){if(e.preventDefault(),1===e.touches.length){let{x:t,y:n}=this._getTouchPosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getTouchPositionRelative(e),this.dispatchEvent(3,new Qa({x:t,y:n},this._downPositionRelative,2)),this._setState(1),this._longClickTimer=window.setTimeout(this._longClick.bind(this,2),350)}else 2===e.touches.length&&(1!==this._state&&2!==this._state||this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2))}_onTouchEnd(e){e.preventDefault(),this.dispatchEvent(13,new Qa(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)),this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)}_onContextMenu(e){e.preventDefault()}_canDrag(e){return this._dragEnabled}onElementHit(){this._elementHit=!0}_getBoundingClientRect(){return this._boundingClientRectInvalid&&(this._boundingClientRect=this._domHelper.element.getBoundingClientRect(),this._boundingClientRectInvalid=!1),this._boundingClientRect}updateSize(){this._boundingClientRectInvalid=!0}}e("aw",$a),on([hn],$a.prototype,"_domHelper",void 0);class er{constructor(e){const{component:t,resetCamera:n,consecutive:s}=e;this.component=t,this.resetCamera=void 0===n||n,this.consecutive=void 0===s||s}}class tr extends f{constructor(e){super(e)}load(e,t,n,s){const i=this,a=new v(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){const n=i.parse(JSON.parse(e));t&&t(n)}),n,s)}parse(e){return new nr(e)}}class nr{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],s=function(e,t,n){const s=Array.from(e),i=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,r=[];let o=0,l=0;for(let e=0;e<s.length;e++){const t=s[e];if("\n"===t)o=0,l-=a;else{const e=sr(t,i,o,l,n);o+=e.offsetX,r.push(e.path)}}return r}(e,t,this.data);for(let e=0,t=s.length;e<t;e++)n.push(...s[e].toShapes());return n}}function sr(e,t,n,s,i){const a=i.glyphs[e]||i.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+i.familyName+".");const r=new Ze;let o,l,h,d,c,u,p,m;if(a.o){const e=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let i=0,a=e.length;i<a;)switch(e[i++]){case"m":o=e[i++]*t+n,l=e[i++]*t+s,r.moveTo(o,l);break;case"l":o=e[i++]*t+n,l=e[i++]*t+s,r.lineTo(o,l);break;case"q":h=e[i++]*t+n,d=e[i++]*t+s,c=e[i++]*t+n,u=e[i++]*t+s,r.quadraticCurveTo(c,u,h,d);break;case"b":h=e[i++]*t+n,d=e[i++]*t+s,c=e[i++]*t+n,u=e[i++]*t+s,p=e[i++]*t+n,m=e[i++]*t+s,r.bezierCurveTo(c,u,p,m,h,d)}}return{offsetX:a.ha*t,path:r}}const ir=new Map,ar=new Map;class rr{static loadFont(e){if(ar.has(e))return new Promise(t=>{t(ar.get(e))});if(ir.has(e))return new Promise((t,n)=>{ir.get(e).push({resolve:t,reject:n})});let t=new tr;return new Promise((s,i)=>{ir.set(e,[{resolve:s,reject:i}]),t.load(n()+e,t=>{ar.set(e,t),rr._resolveAll(e,t)})})}static _resolveAll(e,t){ir.has(e)&&ir.get(e).forEach(e=>e.resolve(t)),ir.delete(e)}}e("aH",rr);class or{constructor(e){this._activeComponents=[],this._componentDimensioningsExist=new Map,this._creator_=e}setCamera(e){this._camera=e}add(e){if(this._componentDimensioningsExist.has(e.runtimeId)&&!this._componentDimensioningsExist.get(e.runtimeId))return!1;const n=this._plannerKernelAccess.kernelInstance.getComponent(e.runtimeId),s=n.dimensionings;if(this._componentDimensioningsExist.set(e.runtimeId,s.length>0),!s||0===s.length||this._camera.position.z<0)return!1;const i=ki(n.boxForMeasurement),a={x:this._camera.position.x,y:this._camera.position.z};return t.import("./component-dimensioning-505e3be3.nomodule.js").then(t=>{rr.loadFont("static/rubik_regular-bc008a7de2daee79.json").then(n=>{s.forEach(s=>{var r;e.add(new t.default(((r=s).from=r.from/1e3,r.to=r.to/1e3,1===r.type.value?(r.type={value:2},r.from*=-1,r.to*=-1):2===r.type.value&&(r.type={value:1}),r),i,n,a))})})}),this._activeComponents.push(e),!0}remove(e,n=!0){return new Promise(s=>{t.import("./component-dimensioning-505e3be3.nomodule.js").then(t=>{let i=[];e.children.forEach(e=>{e instanceof t.default&&i.push(e)}),i.forEach(t=>{e.remove(t),ea(t)}),n&&Je(this._activeComponents,e),s()})})}hasComponentDimensions(){return this._activeComponents.length>0}async reset(){for(const e of this._activeComponents)await this.remove(e);this._activeComponents=[]}invalidateDimensioningsCache(e){e?this._componentDimensioningsExist.delete(e):this._componentDimensioningsExist.clear()}}on([hn],or.prototype,"_plannerKernelAccess",void 0);const lr=(e("as",e=>lr(e)),e=>({...e,fromPosition3d:la(e.fromPosition3d),toPosition3d:la(e.toPosition3d),textPosition3d:la(e.textPosition3d),fromPosition2d:oa(e.fromPosition2d),toPosition2d:oa(e.toPosition2d),textPosition2d:oa(e.textPosition2d),textDirection:la(e.textDirection),textRotation:e.textRotation,length:e.length})),hr=(e,t)=>{let n,s;0===t.value?(n=bs(e.getCornerFromLeft()),s=bs(e.getCornerToLeft())):1===t.value&&(n=bs(e.getCornerFromRight()),s=bs(e.getCornerToRight()));const i=n.clone().add(s).divideScalar(2);return{from:n,to:s,middle:i}},dr=e=>{const t=bs(e.getCornerFromLeft()),n=bs(e.getCornerToLeft()),s=bs(e.getCornerFromRight()),i=bs(e.getCornerToRight());return{centerFrom:t.clone().add(s).divideScalar(2),centerTo:n.clone().add(i).divideScalar(2)}},cr=e=>{const t=e.clone();e.dot(new r(1,0,0))<0&&t.multiplyScalar(-1);const n=Math.atan2(t.z,t.x);let s=n;return n>=Math.PI/2&&n<3*Math.PI/2&&(s+=Math.PI),{textDirection:t,textRotation:s}},ur=(e,t,n,s=23)=>{const i=t/n,a=i>1.77;let r=1080,o=s;return i<1?o="0.7"===i.toFixed(1)?30:20:a&&(r=1188,o=2===Math.round(i)?25:30),o/n*(n/(e*r))},pr=e("au",e=>{const t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));return t}),mr=(e,t,n,s)=>{let i;if(!e.getPlanElement()||!("getAttachedWall"in e.getPlanElement())||!(i=e.getPlanElement().getAttachedWall()))return null;const a=i.getPreferredSide(),o=e.getPlanElement().getPreferredSide(),l=bs(i.getCenter()),{from:h,to:d,middle:c}=hr(i,a);let{from:u,to:p}=hr(e.getPlanElement(),o);h.y=0,d.y=0,u.y=0,p.y=0;const{wallFromCenterPoint:m,wallToCenterPoint:g}=gr(e,h,u,d,p),{centerFrom:f,centerTo:_}=dr(e.getPlanElement()),v=p.clone().sub(u),w=v.clone().cross(new r(0,1,0)).normalize();w.clone().dot(c.clone().sub(l))<0&&w.multiplyScalar(-1);const{textDirection:b,textRotation:y}=cr(v),S=ur(t,n,s),x=w.clone().multiplyScalar(S),P=new r(0,0,0),M={fromPosition2d:P,toPosition2d:P,textPosition2d:P};return{leftMeasurement:{fromPosition3d:u,toPosition3d:h,textDirection:w,textRotation:y,textPosition3d:f.clone().add(m).divideScalar(2),length:1e3*u.distanceTo(h),...M},rightMeasurement:{fromPosition3d:p,toPosition3d:d,textDirection:w,textRotation:y,textPosition3d:_.clone().add(g).divideScalar(2),length:1e3*p.distanceTo(d),...M},elementRange:{fromPosition3d:u,toPosition3d:p,textDirection:b,textRotation:y,textPosition3d:u.clone().add(p).divideScalar(2).add(x),length:1e3*v.length(),...M}}},gr=(e,t,n,s,i)=>{const a=t.clone().sub(n),r=s.clone().sub(i),o=a.length(),l=r.length(),h=a.clone().normalize().multiplyScalar(o),d=r.clone().normalize().multiplyScalar(l),{centerFrom:c,centerTo:u}=dr(e.getPlanElement());return{wallFromCenterPoint:c.clone().add(h),wallToCenterPoint:u.clone().add(d)}};class fr{constructor(){this._promiseExecutors=[]}create(){return new Promise((e,t)=>{this._promiseExecutors.push({resolve:e,reject:t})})}resolve(e){return new Promise(t=>{this._promiseExecutors.forEach(t=>t.resolve(e)),this._promiseExecutors=[],t(e)})}reject(e){return new Promise((t,n)=>{this._promiseExecutors.forEach(t=>t.reject(e)),this._promiseExecutors=[],n(e)})}}class _r extends class{constructor(e){this._coreReference=e.clone()}clearReference(){this._coreReference.delete(),this._coreReference=null}getKernelObject(){return this._coreReference}}{constructor(e){super(e),this._objectWaiter=new fr,this._topView=!1;const t=bs(e.getCenter());this._container=new A,this._container.position.copy(t),this._boundingBox=this._generateBoundingBox(),$i(this._boundingBox),this._container.add(this._boundingBox),2!==this.getPlanElement().getType().value&&(this._object=new A,this._container.add(this._object))}getSize(){return this._object?(new ge).setFromObject(this._object).getSize(new r):new r}update(){this._container.position.copy(bs(this.getPlanElement().getMeshCenter())),this._boundingBox&&this._updateBoundingBox()}_updateBoundingBox(){const e=this.getSize();this._boundingBox.geometry=new $e(e.x,e.y,e.z),this._boundingBox.position.y=e.y/2}getPosition(){return this._container.position}getRotation(){return this._container.rotation.y}getBounds(){let e;return this.getPlanElement().boxForMeasurement?(e=ki(this.getPlanElement().boxForMeasurement),e.applyMatrix4(this.getContainer().matrix)):(e=new ge,e.setFromObject(this._container)),e}getBoundingBox(){return this._boundingBox}getPlanElement(){return this._coreReference}setObject(e){this._object=e,this._objectWaiter.resolve(e)}getObject(){return this._object}async getObjectAsync(){return this._object?Promise.resolve(this._object):this._objectWaiter.create()}addMesh(e){this._object.add(e),this.hidePreviewBox()}getMesh(e){if(!this._object||0===this._object.children.length)return null;const t=ra(e,this.getPlanElement().getType());return this._object.children.find(e=>e.userData.material===t)}getContainer(){return this._container}getId(){var e,t;return null!==(t=null===(e=this.getPlanElement())||void 0===e?void 0:e.getId())&&void 0!==t?t:0}clear(){ea(this._container),this._selectionMesh&&ea(this._selectionMesh)}remove(){var e;null===(e=this._container.parent)||void 0===e||e.remove(this._container),this.clear()}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material=(aa||(aa=new y,aa.visible=!1),aa))}_generateBoundingBox(){const e=this.getSize(),t=new $e(e.x,e.y,e.z);let n=new h("#DDDDDD");const s=this.getPlanElement().customColor;s>0&&(n=Ji(s));let i=Oi.createMeshStandardMaterial({color:n,opacity:1,transparent:!0}),a=new z(t,i);return a.name="bounding box",a.position.y=e.y/2,a.castShadow=!1,a.receiveShadow=!1,a.layers.set(6),a}select(){this._isSelected=!0,this._selectionMesh&&this._container.add(this._selectionMesh)}deselect(){this._isSelected=!1,this._selectionMesh&&this._container.remove(this._selectionMesh)}hoverOn(){}hoverOff(){}setTopView(e){this._topView=e}toJSON(){return{rootElementId:this.getPlanElement().getId()}}}e("ar",e=>({...lr(e)}));class vr extends _r{constructor(e){super(e),this._initDone=!1,this._initFailed=null,this._initWaiter=new fr,this._container.rotation.y=e.rotation}finishInit(){return this._initDone=!0,this._initFailed=null,this._initWaiter.resolve()}failInit(e){return this._initFailed=e,this._initDone=!1,this._initWaiter.reject(this._initFailed)}isInitDone(){return this._initDone?Promise.resolve():this._initFailed?Promise.reject(this._initFailed):this._initWaiter.create()}getPlanObject(){return this.getPlanElement()}getSize(){return ys(this.getPlanObject().size)}getObjectMeasurements(e,t,n){const s=this.getPlanObject(),i=s.getRectangle(),{referencePoints:a,size:o,center:l}=i;if(!a)return null;const h=(s,i,a=!1,o=0)=>{const h=bs(s),d=bs(i);let c=h.clone().add(d).divideScalar(2);const u=h.clone().sub(d),{textDirection:p,textRotation:m}=cr(u);if(a){const s=u.clone().cross(new r(0,1,0)).normalize(),i=c.clone().sub(bs(l));s.dot(i)<0&&s.multiplyScalar(-1);const a=ur(e,t,n),o=s.multiplyScalar(a);c.add(o)}return{fromPosition3d:h,toPosition3d:d,textPosition3d:c,textDirection:p,textRotation:m,length:o}},d=[{from:a.topLeft,to:a.topRight},{from:a.topRight,to:a.bottomRight},{from:a.bottomRight,to:a.bottomLeft},{from:a.bottomLeft,to:a.topLeft}].map(e=>h(e.from,e.to)),c=[{from:a.topLeft,to:a.topRight,length:o.x},{from:a.topRight,to:a.bottomRight,length:o.y}].map(e=>{const t=h(e.from,e.to,!0);return t.length=e.length,t}),u=pr(s.getWallDistances());return{rectMeasurements:d,objectMeasurements:c,objectToWallsMeasurements:u?u.map(e=>({...h(e.startPoint,e.endPoint,!1,e.length),id:et(e.angle+"_"+e.length)})):null}}update(){super.update(),this._container.rotation.y=this.getPlanObject().rotation}}class wr extends vr{constructor(e){super(e),this._container.name="Configurable "+this._container.name}addRootComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId,this._container.add(this.getObject())}addChildEntityComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId}getConfigurationRuntimeId(){return this.getPlanObject().getConfigurationRuntimeId()}getRootComponentId(){return this._rootComponentId}getRootComponentRuntimeId(){return this._rootComponentRuntimeId}finishConstruction(){return this.finishInit()}failConstruction(){return this.failInit(new Error("Construction of configuration failed"))}toJSON(){return{...super.toJSON(),rootComponentRuntimeId:this._rootComponentRuntimeId}}}e("d",wr);let br=JSON.parse(JSON.stringify({isProduction:!0,isUnitTesting:!1,environment:"production",detailEnvironment:"development",features:{},APP:{RAPI:{server:"/api/v2",localReverseProxy:"https://www.roomle.com/api/v2",liveServer:"https://www.roomle.com/api/v2",testServer:"https://www.test.roomle.com/api/v2",headers:{apiKey:"roomle_portal_v2",currentTenant:9,locale:"en",language:"en",device:1,token:"anonymous",platform:"web"},itemHeaders:{assetRevision:"glb",assetFileFormat:"glb"}},SHORTENER_URL:"http://rml.co/"},environments:{PRODUCTION:"production",DEVELOPMENT:"development",TEST:"test",TEST_SERVER:"test_server",ALPHA:"alpha"}}));br.isUnitTesting=!1,void 0!==t&&t.exports||(window.IS_DEBUG=!0);const yr={ENV_DEBUG:function(e=!1){if(e){let e=JSON.parse(JSON.stringify(br));const t={...e.APP,SHORTENER_URL:"http://localhost:4747/?isItem=false&id="},n={...e.features};return{...e,isProduction:!1,APP:t,features:n}}}(),ENV_PRODUCTION:JSON.parse(JSON.stringify(br))};var Sr=e("n",yr.ENV_PRODUCTION);class xr extends vr{constructor(e){super(e),this._originalSize=new r,this._container.name="Static "+this._container.name}setRapiItem(e){return this._rapiItem?this.isInitDone():this._addStaticItem(e)}async _addStaticItem(e){this._rapiItem=e;let t=this.getPlanObject();if(this._glbUrl=tt(e),!this._glbUrl)return Promise.reject("No glb url found");let n=e.scaleable?ys(t.size):void 0,s=new r(1,1,1);t.flipX&&(s.x*=-1),t.flipY&&(s.z*=-1);try{const i=await this._staticItemLoader.loadGLB(this._glbUrl,void 0,void 0,n,s,t.customColor,e.colorable);this._originalSize.copy(i.boundingBox.getSize(new r)),i.scene.name=e.label,this.setObject(i.scene),((e,t)=>{let n=(new ge).setFromObject(e),s=n.getSize(new r),i=Math.min(s.x,s.y,s.z),a=!0;i>5&&(console.warn("GLB seems to be too big ("+i+")",t),a=!1),n.min.y<-.01&&(console.warn("GLB seems to be under the floor ("+n.min.y+"): ",t),a=!1)})(i.scene,this._glbUrl),$i(i.scene),this._container.add(this.getObject()),this.hidePreviewBox(),await this.finishInit()}catch(e){await this.failInit(e)}}getRapiItem(){return this._rapiItem}needsRapiItem(){return!this._glbUrl}getGLBUrl(){return this._glbUrl}update(){super.update();const e=ys(this.getPlanElement().size),t=this.getObject();if(!t)return;if(e){const{x:n,y:s,z:i}=this._originalSize;let a=new r(e.x/n,e.y/s,e.z/i);t.scale.copy(a)}this.getPlanElement().flipX&&(t.scale.x*=-1),this.getPlanElement().flipY&&(t.scale.z*=-1);const n=this.getPlanElement().customColor;t.traverse(e=>{if(e instanceof z&&e.material instanceof N){const t=e.material;if(this._rapiItem.colorable&&n&&n>0){let e=new h(n);t.color=e.copySRGBToLinear(e)}t.needsUpdate=!0}})}}let Pr;e("S",xr),on([hn],xr.prototype,"_staticItemLoader",void 0),e("at",e=>({...lr(e),id:e.id,fromWithoutPadding:la(e.fromWithoutPadding),toWithoutPadding:la(e.toWithoutPadding),lengthFormatted:e.lengthFormatted}));const Mr=()=>(Pr||(Pr=Oi.createMeshPhysicalMaterial({color:0})),Pr);class Cr extends _r{constructor(e){super(e),this._container.name="Wall Plan Element"}get isSelected(){return this._isSelected}getWallDimension(e,t,n){const s=this.getPlanElement(),i=bs(s.getCenter()),a=s.getPreferredSide(),{from:o,to:l,middle:h}=hr(s,a),d=o.clone().sub(l),c=d.clone().cross(new r(0,1,0)).normalize();c.clone().dot(h.clone().sub(i))<0&&c.multiplyScalar(-1);const u=parseFloat(ur(e,t,n).toFixed(3)),{textDirection:p,textRotation:m}=cr(d),g=c.clone().multiplyScalar(u),f=o.clone().add(g),_=l.clone().add(g),v=c.clone().multiplyScalar(u/2),w=o.clone().add(v),b=l.clone().add(v),y=f.clone().add(_).divideScalar(2);return{id:s.getId(),fromPosition3d:f,toPosition3d:_,textPosition3d:y,textDirection:p,textRotation:m,length:s.getLength(a),fromWithoutPadding:w,toWithoutPadding:b}}addMesh(e){e.traverse(e=>{this._setMaterial(e)}),e.layers.set(9),super.addMesh(e);const t=(new ge).setFromObject(this.getObject()).getSize(new r);this._boundingBox.geometry=new $e(t.x,t.y,t.z),this._boundingBox.position.y=t.y/2}show(){var e,t;this.getContainer().visible=!0,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.set(9)}),null===(t=this.getBoundingBox())||void 0===t||t.layers.set(6)}hide(){var e,t;this.getContainer().visible=!1,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.disableAll()}),null===(t=this.getBoundingBox())||void 0===t||t.layers.disableAll()}_enableTopView(){this._container.traverse(e=>{this._setTopMaterial(e)})}_setTopMaterial(e){e instanceof z&&!e.userData.originalMaterial&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial=e.material,e.material=Mr())}_disableTopView(){this._container.traverse(e=>{e instanceof z&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial)})}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView()}getKernelObject(){return super.getKernelObject()}_setMaterial(e){e instanceof z&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),this._topView&&this._isSelected?e.material=new y({color:10526880,side:F}):this._topView&&!this._isSelected?e.material=Mr():(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial))}select(){super.select(),this._container.traverse(e=>{this._setMaterial(e)})}deselect(){super.deselect(),this._container.traverse(e=>{this._setMaterial(e)})}}e("W",Cr),e("ap",e=>({area:e.area,formattedArea:e.formattedArea||null,textPosition3d:la(e.textPosition3d),textPosition2d:e.textPosition2d?la(e.textPosition2d):{x:0,y:0,z:0},isTextVisible:e.isTextVisible}));class Tr extends _r{constructor(e){super(e),this._container.name="Floor Plan Element"}addMesh(e){this.getObject().clear(),super.addMesh(e),e.layers.set(9),e.castShadow=!1,e.position.y=-.001}getFloorData(e){const t=this.getKernelObject(),n=(new ge).setFromObject(this._container),s=bs(t.getLabelPosition()),i=this.calculateTextVisibility(n,e);return{area:t.area,formattedArea:"",textPosition3d:s,textPosition2d:new r,isTextVisible:i}}calculateTextVisibility(e,t){const n=new r;return e.getSize(n),n.length()*t>.2}}e("F",Tr);class Ar extends _r{constructor(e){super(e),this._container.name="Ceiling Plan Element"}addMesh(e){super.addMesh(e),e.castShadow=!1;const t=(new ge).setFromObject(this.getObject()).getSize(new r);this._boundingBox.geometry=new $e(t.x,.01,t.z)}}e("f",Ar);const Rr=new Map;class Er{static start(e){if(!window.performance||!window.performance.getEntriesByName)return"";let t=window.performance.getEntriesByName(e).length++,n="";t<100&&(n="0"),t<10&&(n="0"+n);const s=t>0?e+"_"+n+t:e,i=s+"_start";return window.performance.mark(i),s}static addMeta(e,t){const n=Er.getMeta(e);Rr.set(e,Object.assign(n,t))}static getMeta(e){return Rr.get(e)||{}}static end(e){}static getMeasure(e){return[]}static showBenchmarks(e){const t=window.performance.getEntriesByType("measure");t.sort((function(e,t){return e.startTime-t.startTime}));const n=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];e&&-1===i.name.indexOf(e)||n.push({Start:parseFloat(i.startTime.toFixed(2)),Name:i.name,Duration:parseFloat(i.duration.toFixed(2))})}console.table(n)}}e("B",Er);class Ir{static init(e={}){const{kernelInstance:t,kernelContainer:n,planObjectId:s}=e;Ir.kernelInstance=t,Ir.kernelContainer=n,Ir.planObjectId=s}static cleanUp(){Ir.useHDGeometry=!1,Ir.kernelInstance=null,Ir.kernelContainer=null,Ir.planObjectId=null}}e("A",Ir),Ir.useHDGeometry=!1,Ir.kernelInstance=null,Ir.kernelContainer=null,Ir.planObjectId=null;const Dr=new Map,Or=function(e,t,n){let s=Dr.get(e);if(s){const i=n?[n]:void 0;s.forEach(({resolve:e,reject:n})=>t?e.apply(e,i):n.apply(n,i)),Dr.delete(e)}};class kr{static finishOperation(e,t){Or(e,!0,t)}static failOperation(e,t){Or(e,!1,t)}static waitFor(e,t){return new Promise((n,s)=>{let i=Dr.get(e);i||(Dr.set(e,[]),i=Dr.get(e)),i.push({resolve:n,reject:s}),"function"==typeof t&&t.apply(t)})}}e("Q",kr);const Lr=e("T",(function(e){return e.validRange&&"string"==typeof e.validRange.type})),Ur=function(e){return e.validValues&&e.validValues.length>0},Br=e("U",(function(e){return"Material"===e.type}));let Nr,Fr,Gr;const jr={WASM_MODERN:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-c4372bbeb5743db2.wasm",LOADER:"static/ConfiguratorKernel-82e5093feef1b077.js"},PLANNER:{URL:"static/RoomleCore-0a87ce9a99621bd9.wasm",LOADER:"static/RoomleCore-e517dbd10f96e64e.js"}}},zr=!!window.WebAssembly;class Vr{_utilityToLongArray(e){const t=new this._kernelContainer.LongArray;return e.forEach(e=>t.push_back(e)),t}constructor(e){this._requestedItemIds=[],this._requestedMaterialIds=[],this._configuratorKernelCallbackListener=new Set,this._cachedGroupIds=[],this._waitingForGroups=!1,this._subComponentsWaiters=new Map,this._shouldWait=!0,this._creator_=e,window.KernelCallback={isReady:this.isReady.bind(this)},this._lifeCycleManager.addEventListener(this)}init(e){this._kernelType=e,this._setupKernelPaths(e),this._setupEmsModule(e),this._useWASM=zr,this._kernelPath=zr?Fr:void 0}_initKernel(){const{restrictionLevel:e}=this._initData,t=!1!==this._initData.callbacksOnlyIfGeometryIsReady;this._kernelInstance.setUpdateCallbacksOnlyIfGeometryIsReady(t),this._kernelInstance.setLevel(e),this._unitFormatter.init(this._kernelContainer),this._kernelInstance.setEnvironmentVariable("unit",this._unitFormatter._actualUnitString||"cm"),this._kernelInstance.setEnvironmentVariable("unitString","short"),this._kernelInstance.useEnvironmentGeometry(1===this._kernelType);const{overrideCountry:n,locale:s}=this._globalInitData;n&&(this._kernelInstance.resetPriceListIds(),this._kernelInstance.addPriceList(n)),this._kernelInstance.setEnvironmentVariable("language",s)}get kernelContainer(){return this._kernelContainer}get kernelInstance(){return this._kernelInstance}get configurationExporter(){return this._configurationExporter||(this._configurationExporter=this._kernelContainer.newConfigurationExporter()),this._configurationExporter}_setupKernelPaths(e){const t=0===e?"PLANNER":"CONFIGURATOR";Nr=jr.WASM_MODERN[t].URL,Fr=jr.WASM_MODERN[t].LOADER,Gr=!0}_setupEmsModule(e){const t=this;this._kernelContainer={locateFile(t){const s=0===e?/RoomleCoreJs[\-a-z0-9]*\.js\.mem/:/ConfiguratorKernelJs[\-a-z0-9]*\.js\.mem/;return t.match(s)?n()+void 0:t},wasmBinaryFile:n()+Nr,preRun:[],postRun:[],setStatus:null,print(e){t._kernelIo.log(e)},printErr(e){t._kernelIo.error(e)},quit(e){0!==e&&t._kernelIo.throw(e&&e.toString?e.toString():"Unknown error while C/C++ main executes")}},Gr&&zr&&(this._kernelContainer.instantiateWasm=function(e,t){return((e,t,s)=>{const i="function"==typeof WebAssembly.instantiateStreaming;Er.addMeta("kernel_is_ready",{cachedInIndexedDB:!1});let a=null;i?(Er.start("kernel_stream_compile"),a=WebAssembly.instantiateStreaming(fetch(n()+e),t)):(Er.start("kernel_legacy_compile"),a=fetch(n()+e).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,t))),Er.addMeta("kernel_is_ready",{instantiateStreaming:i}),a.then(e=>{s(e.instance)},e=>console.error(e))})(Nr,e,t),{}})}_passSubComponentsToKernel(e,t){const n=e.id,s=t.get(n);if(s)for(let t=0,i=s.length;t<i;t++){const{parentId:i,partId:a}=s[t];this._kernelIo.setMeta({componentId:n}),this._kernelInstance.loadedSubComponent(i,a,n,e.configuration)}}_fetchSubComponents(e){let t=[...e.keys()];t.length&&this._rapiAccess.getComponents(t).then(t=>{for(let n=0,s=t.length;n<s;n++)this._passSubComponentsToKernel(t[n],e);this._flushSubComponentsWaiters()})}_flushSubComponentsWaiters(){this._fetchSubComponents(this._subComponentsWaiters),this._subComponentsWaiters=new Map,this._shouldWait=!1}isReady(){this._kernelContainer.setExternalHelpers(this._kernelIo,{convertCObject:Ps}),Sr.isProduction||Sr.isUnitTesting||this.addDebugInfo(),window.KernelCallback&&(window.KernelCallback=null,delete window.KernelCallback)}addDebugInfo(){const e=function(t,n=[]){const s=Object.getPrototypeOf(t),i=s?Object.getOwnPropertyNames(s):[],a=t?Object.getOwnPropertyNames(t):[];return s?e(s,[...n,...a,...i]):[...a,...i,...n]},t=e(this),n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf"];[...new Set(t)].forEach(e=>{if(!e.startsWith("_")&&"function"==typeof this[e]&&-1===n.indexOf(e))try{const t=this[e].bind(this);this[e]=function(...n){return this._kernelIo.log("[ KernelCommunication ]: "+e),t(...n)}}catch(e){}})}getConfigurationData(e){return new Promise(t=>{var n;const s=this.kernelInstance.getPlanObject(e),i=(new Date).toISOString(),a=this.kernelInstance.getComponentId(e),r=nn(a),o=(null===(n=s.boxForMeasurement)||void 0===n?void 0:n.size)||s.bounds;t({created:i,lastAccess:i,configuration:this.kernelInstance.getSerializedConfiguration(e),configurationHash:this.kernelInstance.getHashOfConfiguration(e),parts:JSON.stringify(this.kernelInstance.getPartList(e)),rootComponentId:a,width:o.x,height:o.z,depth:o.y,catalog:r,orderable:!1,requestable:!1})})}loadComponent(e,t,n){this._rapiAccess.getComponent(t.componentId).then(s=>{var i;let a=s.configuration;a||(a="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[t.componentId],message:t.componentId+" has no configuration"})),this._kernelIo.setMeta({componentId:t.componentId}),this._kernelInstance.loadComponent(e,a,t,n),this._flushSubComponentsWaiters()},s=>{var i;this._kernelInstance.loadComponent(e,"error",t,n),this.onLoadComponentError(s,t.componentId),null===(i=this._configuratorUiCallbacks)||void 0===i||i.onError(new Error(`Component with id "${t.componentId}" can not be loaded. "${s}"`)),this._flushSubComponentsWaiters()})}loadSubComponent(e,t,n){if(this._shouldWait){let s=this._subComponentsWaiters.get(n);s||this._subComponentsWaiters.set(n,[]),s=this._subComponentsWaiters.get(n),s.push({parentId:e,partId:t}),this._subComponentsWaiters.set(n,s)}else this._rapiAccess.getComponent(n).then(s=>{var i;let a=s.configuration;a||(a="error",null===(i=this._configuratorUiCallbacks)||void 0===i||i.onContentProblem({rapiPath:"components",ids:[n],message:"SubComponent "+n+" has no configuration"})),this._kernelIo.setMeta({componentId:n,parentId:e}),this._kernelInstance.loadedSubComponent(e,t,n,a)})}async loadItemConfigurations(e,t){let n=Array.isArray(t)?t:[t];if(this._requestedItemIds.push(...n),await nt(0),!this._requestedItemIds.length)return;const s=[...this._requestedItemIds];this._requestedItemIds=[],(await this._rapiAccess.getItems(s)).forEach(t=>{this._kernelInstance.loadedItemConfiguration(e,t.id,t.configuration)})}requestDeleteComponent(e){var t,n;e&&((null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)?this._kernelInstance.deletePlanComponent(e):this._kernelInstance.deleteComponent(e))}dockComponentWithPosition(e,t,n,s,i){var a;this._kernelInstance.dockComponentWithPosition(n,s,e,t,i);const r=this._kernelInstance.getComponentId(n),o=this._kernelInstance.getComponentId(e);null===(a=this._configuratorUiCallbacks)||void 0===a||a.onUserInitiatedDockDone(r,s,o,t,i)}Editor3dAddBakedMesh(e,t,n,s,i,a,r,o){this._configuratorKernelCallbackListener.forEach(l=>l.Editor3dAddBakedMesh(e,t,n,s,i,a,r,o))}Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c){this._configuratorKernelCallbackListener.forEach(u=>u.Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c))}Editor3ChangedNamedMesh(e,t,n,s,i,a,r){this._configuratorKernelCallbackListener.forEach(o=>o.Editor3ChangedNamedMesh(e,t,n,s,i,a,r))}Editor3dRemoveNamedMesh(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dRemoveNamedMesh(e,t))}Editor3dBeginConstruction(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dBeginConstruction(e,t))}Editor3dEndConstruction(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dEndConstruction(e))}Editor3dComponentCreated(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentCreated(e,t,n,s,i))}Editor3dComponentDocked(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentDocked(e,t,n,s,i))}Editor3dGeometryReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryReady(e)),this.requestPlanComponentConstruction(e),this._configuratorUiCallbacks.onGeometryReady(e)}Editor3dGeometryNotReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryNotReady(e)),this._configuratorUiCallbacks.onGeometryNotReady(e)}componentDeleted(e){this._configuratorKernelCallbackListener.forEach(t=>t.componentDeleted(e))}componentMetaUpdated(e){let t=this._kernelInstance.getComponent(e);this._configuratorKernelCallbackListener.forEach(e=>e.componentMetaUpdated(t))}sceneCleared(){this._configuratorKernelCallbackListener.forEach(e=>e.sceneCleared())}requestMaterialsInGroup(e){(Array.isArray(e)?e:[e]).forEach(e=>{-1===this._cachedGroupIds.indexOf(e)&&this._cachedGroupIds.push(e)}),this._waitingForGroups||(this._waitingForGroups=!0,kr.waitFor(4).then(()=>{this._rapiAccess.getMaterialsByGroup(this._cachedGroupIds).then(e=>{let t=[];e.forEach(e=>{const n=[];e.materials.forEach(e=>n.push(e.id));const s=e.legacyId||e.id;e.legacyId||console.warn("Material group has no legacy id, please check content why this is the case"),t.push({group:s,materials:n})}),t.length&&this._kernelInstance.setMaterialsInGroup(t),this._cachedGroupIds=[]},e=>{var t;console.error(e),null===(t=this._configuratorUiCallbacks)||void 0===t||t.onError(new Error(`Material group with ids "${this._cachedGroupIds.join(",")}" can not be loaded. "${e}"`)),this._cachedGroupIds=[]})}))}requestPlanComponentConstruction(e,t=!0){t?this._kernelInstance.requestDeltaPlanComponentConstruction(e):this._kernelInstance.requestPlanComponentConstruction(e)}addConfiguratorListener(e){this._configuratorKernelCallbackListener.add(e)}removeConfiguratorListener(e){this._configuratorKernelCallbackListener.delete(e)}cleanUpCallbacks(){"function"==typeof this._kernelContainer.unregisterConfiguratorCallback&&this._kernelContainer.unregisterConfiguratorCallback(this)}async requestMaterialProperties(e){let t=Array.isArray(e)?e:[e];if(this._requestedMaterialIds.push(...t),await nt(0),!this._requestedMaterialIds.length)return;const n=[...this._requestedMaterialIds];this._requestedMaterialIds=[];const s=await this._rapiAccess.getMaterials(n);let i=[];s.forEach(e=>{const t=new this._kernelContainer.StringStringMap,n=e.properties||{};for(let e in n)n.hasOwnProperty(e)&&t.set(e,n[e]);t.size()&&i.push({id:e.id,properties:t})}),i.length&&this._kernelInstance.setMaterialProperties(i)}registerCallbacks(){this._kernelContainer.registerConfiguratorCallback(this)}pause(){this.cleanUpCallbacks()}resume(){this.cleanUpCallbacks(),this.registerCallbacks()}destroy(){}_handleCortoMesh(e,t,n){var s;try{this._kernelInstance.addMeshCorto(t,n,new Uint8Array(e))}catch(e){console.error(e),null===(s=this._configuratorUiCallbacks)||void 0===s||s.onMemoryCorruption()}}_handleInvalidMesh(e,t){try{this._kernelInstance.setExternalMeshInvalid(e,t)}catch(e){console.error(e)}}calcPartsPriceSum(e){return this._calcPrice(e)}_calcPrice(e){const t=new Map;e||(e=this._kernelInstance.getFullPartList());const n=!!e&&!!e.fullList&&!!e.fullList.length;if(this._initData.useRoomlePrice&&n){const n=e.fullList[0].currencySymbol,s=e.fullList.reduce((e,t)=>e+(t.count?t.count:0)*(t.price?t.price:0),0),i=it(s,2);return this._configuratorUiCallbacks.onUpdatePrice(n,i),Promise.resolve({totalSum:i,partMap:t})}if(this._initData.usePriceService&&n){const n=e.fullList.reduce((e,n)=>{const s=sn(n);return s&&(t.set(s,n),e.push(s)),e},[]);return new Promise((s,i)=>{this._rapiAccess.getPrices(n).then(n=>{if(!n.length)return i(new Error("prices are empty"));let a=0;const r=st(n,"priceId");for(const t of e.fullList){const e=sn(t);if(!r.has(e)){console.warn("PriceId: "+e+" has no corresponding kernel-part");continue}const{price:n,currencySymbol:s}=r.get(e);t.price=n,t.currencySymbol=s,a+=n*t.count}return a=it(a,2),this._configuratorUiCallbacks.onUpdatePrice(n[0].currencySymbol,a),s({totalSum:a,partMap:t})},e=>{console.error(e),i(e)})})}return Promise.resolve({totalSum:0,partMap:t})}async addUiDataAndPriceToPartList(e,t){const{fullList:n,originPart:s}=e,i=e.perMainComponent;let a;this.addUiDataToPartList(n,t);try{const t=await this._calcPrice(e);a=t.partMap}catch(e){console.error(e),a=new Map}const r=this._initData.usePriceService||this._initData.useRoomlePrice,o=e=>{r||(e.price=null,e.currencySymbol=null);const t=sn(e);if(!t)return;if(!a.has(t))return;const{price:n,currencySymbol:s}=a.get(t);"number"==typeof n&&(e.price=n,e.currencySymbol=s)};return n.forEach(o),i.forEach(({fullList:e,perMainComponent:n})=>{n.length>0&&console.error("Not implemented! perMainComponent is deeper than one level"),this.addUiDataToPartList(e,t),e.forEach(o)}),{fullList:n,perMainComponent:i,originPart:s}}addUiDataToPartList(e,t){const n=[];return e.forEach(e=>{const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label),e.parameters.forEach(e=>{if(this._unitFormatter.formatPartListParameter(e),Br(e)){const t=this._rapiAccess.peekMaterial(e.value);t?e.valueLabel=t.label||t.name||e.value:-1===n.indexOf(e.value)&&n.push(e.value)}})}),n.length&&this._rapiAccess.getMaterials(n).then(e=>{const n=this._lastPartListHash!==t;Array.isArray(e)&&e.length&&n&&(this._lastPartListHash=t,this.requestPartListAndUpdatePricesOfParts())}),e}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const s=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(s,btoa(e))}}on([hn],Vr.prototype,"_rapiAccess",void 0),on([hn],Vr.prototype,"_scriptLoader",void 0),on([hn],Vr.prototype,"_kernelIo",void 0),on([hn],Vr.prototype,"_dataSyncer",void 0),on([hn],Vr.prototype,"_lifeCycleManager",void 0),on([hn],Vr.prototype,"_configuratorUiCallbacks",void 0),on([hn],Vr.prototype,"_globalCallback",void 0),on([hn],Vr.prototype,"_initData",void 0),on([hn],Vr.prototype,"_unitFormatter",void 0),on([hn],Vr.prototype,"_configuratorContext",void 0),on([hn],Vr.prototype,"_globalInitData",void 0);const{APP:Hr}=Sr,{RAPI:Wr}=Hr,Kr=Wr.headers,qr=Wr.itemHeaders,Xr=Kr.token,Yr=e("av",e=>e.startsWith("ps_")),Qr=at();let Zr=new Map,Jr=new Map,$r=new Map,eo=new Map,to=new Map,no=new Map,so=new Map,io=new Map,ao=new Map;const ro=e=>Zr.get(e)||Zr.get(Qr+e),oo=e=>e&&e.tags&&e.tags.length,lo=e=>!oo(e)&&e.group;class ho{constructor(e){this._itemLoaded=!1,this._currentToken=null,this._creator_=e,window.addEventListener("online",this._flushOfflineQueue.bind(this))}getPreloadForItem(e){return this._getPreload(e,!0)}getPreloadForConfiguration(e){return this._getPreload(e,!1)}_getPreload(e,t){return new Promise((n,s)=>{if(!navigator.onLine)return n();if(this._dataSyncer.getIsCatalogSynced(nn(e)))return n();if(so.get(e))return n();const i=t?"?itemId=":"?configurationId=";this._get("/preloads/components/"+i+e,"preloads/components").then(t=>{if(so.get(e))return n();t.forEach(e=>{this._prepareData(e,"components")}),so.set(e,!0),n()},s)})}changeUseOfHDGeometry(){const e=eo.get("components");so.clear(),no.clear(),e&&eo.delete("components")}getHSCPackage(e){return new Promise((t,n)=>{if(no.get(e))return t();this._get("/catalogs/"+e+"/package","package").then(n=>{if(no.get(e))return t(n);n.components.forEach(e=>{this._prepareData(e,"components")}),n.materials.forEach(e=>{this._prepareData(e,"materials"),this._prepareGroups(e)}),n.textures.forEach(e=>{this._prepareData(e,"textures")}),no.set(e,!0),t(n)},n)})}getComponent(e){return this._getById(e,"components")}getConfiguration(e){return this._getById(e,"configurations")}getConfigurations(e){return this._getByIds(e,"configurations")}getItem(e){return this._getById(e,"items",{additionalHeaders:qr})}getComponents(e){return this._getByIds(e,"components")}getItems(e){return this._getByIds(e,"items",{additionalHeaders:qr})}getTag(e){return this._getById(e,"tags")}getTags(e){return this._getByIds(e,"tags")}getTexture(e){return this._getById(e,"textures")}getCatalog(e){return this._getById(e,"catalogs")}getMesh(e,t="crt",n=50){return this._getById(e,"meshes",{pathSuffix:"/data?format="+t+"&targetQuality="+n.toString()})}getMeshesOfCatalog(e){return new Promise((t,n)=>{const s=to.get(e);s?t(s):this._get("/meshes?catalog="+e,"catalogMeshes").then(n=>{to.set(e,n),t(n)},n)})}getTexturesOf(e){return this._getRelationData(e,{rapiPath:"textures"})}getItemsOf(e){return this._getRelationData(e,{rapiPath:"items"})}async getMaterialsOf(e){return(await this._getRelationData(e,{rapiPath:"materials"},{embed:["textures"]})).filter(e=>e.active)}getComponentsOf(e){return this._getRelationData(e,{rapiPath:"components"})}getAdditionalContentsOfItems(e){const t=[],n=[],s=[];return e.forEach(e=>{const i=e.id.toString(),a=Jr.get(i);a?n.push(...a):t.push(i),s.push(i)}),new Promise((e,i)=>{0!==t.length?this._getByIdsPackets(t,"itemAdditionalContents",{filterKey:"itemIds"}).then(t=>{t.forEach(e=>{let t=Jr.get(e.itemId);t||(t=[]);for(let n=0,s=t.length;n<s;n++)if(t[n].id===e.id)return;t.push(e),Jr.set(e.itemId,t)}),e(rt(s,[...t,...n],"itemId"))},i):e(n)})}getMaterial(e){return this._getById(e,"materials",{embed:["textures"]})}peekMaterial(e){return this._peekData(e,"materials")}peekComponent(e){return this._peekData(e,"components")}peekItem(e){return this._peekData(e,"items")}peekConfiguration(e){return this._peekData(e,"configurations")}async getMaterials(e){return(await this._getByIds(e,"materials",{embed:["textures"]})).filter(e=>e.active)}getPlan(e){return this._getById(e,"plans")}getPlanSnapshot(e){return this._getById(e,"planSnapshots")}static clearCaches(){Zr=new Map,$r=new Map,eo=new Map,no=new Map,so=new Map,io=new Map,Jr=new Map}cleanUp(){ho.clearCaches()}getMaterialsByGroup(e){const t=e.slice(),n=[];let s=t.length;for(let e=0;e<s;e++){const i=ro(t[e]);if(i){const a=i.length;for(let e=0;e<a;e++){const t=this._getCache("materials").get(i[e]);n.push(t)}t.splice(e,1),s--,e--}}return new Promise((e,s)=>{0!==t.length&&navigator.onLine?this._getByIdsPackets(t,"materials",{filterKey:"groups",embed:["textures"]}).then(t=>{e(this.combineMaterialsToGroups([...t,...n]))},s):e(this.combineMaterialsToGroups(n))})}_flushOfflineQueue(){return new Promise((e,t)=>{const n=this._localStorage.getItem("hsc_configurations_offline_queue_v1"),s=[];for(let e in n)if(n.hasOwnProperty(e)){const t=n[e];s.push(new Promise((e,n)=>{this.saveConfiguration(t.data).then(s=>{const i=[];t.perspectiveImage&&!s.perspectiveImage&&i.push(this.savePerspectiveImage(s,t.perspectiveImage)),t.topImage&&!s.topImage&&i.push(this.savePerspectiveImage(s,t.topImage)),Promise.all(i).then(e,n)},n)}))}Promise.all(s).then(()=>{this._localStorage.setItem("hsc_configurations_offline_queue_v1",{}),e()},t)})}_setQueuedConfiguration(e,t={}){const n=e.configurationHash,{perspectiveImage:s,topImage:i}=t;let a=this._localStorage.getItem("hsc_configurations_offline_queue_v1")||{},r=a[n]||{};r.data=e,r.perspectiveImage=s,r.topImage=i,a[n]=r,this._localStorage.setItem("hsc_configurations_offline_queue_v1",a)}async saveConfiguration(e){return navigator.onLine?await this._save("/configurations",{configuration:e},"configurations",{accept:"application/json",contentType:"application/json; charset=UTF-8"}):(e.perspectiveImage=null,e.topImage=null,this._setQueuedConfiguration(e),this._markConfigurationAsLocally(e),Promise.resolve(e))}saveTopImage(e,t){return this._saveConfigurationImage(e,t,"topImage")}savePerspectiveImage(e,t){return this._saveConfigurationImage(e,t,"perspectiveImage")}savePlanSnapshotTopImage(e,t){return this._savePlanSnapshotImage(e,t,"topImage")}savePlanSnapshotPerspectiveImage(e,t){return this._savePlanSnapshotImage(e,t,"perspectiveImage")}getShortUrl(e,t){return new Promise((n,s)=>this._fetchJson("/shortIds","shortIds",{method:"POST",resolve:n,reject:s,data:JSON.stringify({shortId:{type:t,referencedId:e}}),accept:"application/json",contentType:"application/json; charset=UTF-8"}))}_peekData(e,t){const n=eo.get(t);return n&&n.get(e)||null}_saveConfigurationImage(e,t,n){if(!navigator.onLine){const s={};return s[n]=t,this._setQueuedConfiguration(e,s),this._markConfigurationAsLocally(e),e[n]=t.image,Promise.resolve(e)}const s=this._formDataUtil.create(t.image,e.configurationHash,Qt.PNG,n);return this._save("/configurations/"+e.id+"/"+n,s,"configurations",{accept:"application/json"})}_savePlanSnapshotImage(e,t,n){const s=this._formDataUtil.create(t.image,e.id,Qt.PNG,"file");return s.append("type",n),this._save("/planSnapshots/"+e.id,s,"planSnapshots",{accept:"application/json",method:"PUT"})}_markConfigurationAsLocally(e){e.isLocally=!0,e.id=e.configurationHash}_save(e,t,n,s={}){const i=t instanceof FormData?t:JSON.stringify(t);return new Promise((t,a)=>{const r={method:s.method||"POST",data:i,resolve:t,reject:a};s.contentType&&(r.contentType=s.contentType),s.accept&&(r.accept=s.accept),this._fetchJson(e,n,r)})}combineMaterialsToGroups(e){return new Promise((t,n)=>{const s=new Map,i={id:null,label:null,materials:[]},a=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.tags&&n.tags.length?n.tags.map(e=>({isTag:!0,id:e})):[];n.group&&r.push({isTag:!1,id:Qr+n.group,legacyId:n.group}),r.length||r.push({isTag:!1,id:null}),n.tags&&n.tags.length&&n.tags.forEach(e=>-1===a.indexOf(e)?a.push(e):null),r.forEach(({isTag:e,id:t,legacyId:a})=>{const r=n.id;let o=t?ro(t):[];o||(Zr.set(t,[]),o=ro(t)),-1===o.indexOf(r.toString())&&o.push(r.toString());const l=oo(n),h=l&&e,d=lo(n);if(h||d&&!e||!l&&!d&&!t){let e=t?s.get(t):i;e||(s.set(t,{id:t,label:n.groupLabel,legacyId:a,materials:[]}),e=s.get(t)),e.materials.push(n)}})}const r=i.materials.length?[i]:[];this.getTags(a).then(e=>{const n=e.reduce((e,t)=>(e[t.id]=t,e),{});return s.forEach((e,t)=>{r.push({id:t,label:n[t]?n[t].label:e.label,materials:e.materials,legacyId:e.legacyId,sort:n[t]?n[t].sort:void 0})}),t(r)},n)})}_getByIds(e,t,n={}){const s=this._getCache(t),i=this._getErrorCache(t),a=[],r=[...new Set(e)];let o=r.length;if(s&&s.size){const e=(new Date).getTime();for(let t=0;t<o;t++){const n=r[t],l=s.get(n),h=i.get(n);let d=!1;null!=l?(a.push(l),d=!0):d=void 0!==h&&(e-h.timestamp<6e4||!1===navigator.onLine),d&&(r.splice(t,1),o--,t--)}}return new Promise((s,i)=>{0!==r.length&&navigator.onLine?this._getByIdsPackets(r,t,n).then(t=>{s(rt(e,[...t,...a]))},i):s(a)})}_getByIdsPackets(e,t,n={}){e.sort();const s=n.filterKey||"ids";let i,a="/"+t+"/",r="?",o=[];const l=e.length;if(!l)return new Promise(e=>e([]));let h=!0,d=[];for(i=0;i<l;i++){h=!1;const n=e[i],l=r+s+"[]="+n,c=l.length+a.length;d.push(n),r="&",c<=1500?a+=l:(c>1500&&(d.pop(),i--),o.push({url:a,ids:d}),h=!0,a="/"+t+"/",r="?",d=[])}h||o.push({url:a,ids:d});const c=[];return o.forEach(e=>c.push(this._getByIdsSingle(e.ids,e.url,t,n))),new Promise((e,t)=>{Promise.all(c).then(t=>{const n=[];t.length&&t.forEach(e=>n.push(...e)),e(n)},t)})}_getByIdsSingle(e,t,n,s={}){return e.sort(),new Promise((i,a)=>{this._get(t,n,s).then(t=>{for(let n=0,i=t.length;n<i;n++){const i=s&&s.cacheKey?t[n][s.cacheKey]:t[n].id,a=e.indexOf(i.toString());-1!==a&&e.splice(a,1)}const a=e.length;if(a){const t=this._getCache(n),s=this._getErrorCache(n),i=(new Date).getTime();for(let n=0;n<a;n++)s.set(e[n],{code:0,timestamp:i}),t.delete(e[n]);this._errorHandler.dispatch(2,[n,e.map(e=>'"'+e+'"').join(",")])}i(t)},a)})}_getById(e,t,n={}){if(!e||""===e||"string"!=typeof e)return console.error("no id passed to _getById"),Promise.reject(new Error("no id passed to _getById"));const s=this._getCache(t).get(e);if(s)return new Promise(e=>e(s));if(!navigator.onLine)return Promise.reject("Nothing cached but tried to fetch in offline mode");const i={...n,id:e},a=n.pathSuffix||"";return this._get("/"+t+"/"+e+a,t,i)}_get(e,t,n={}){const s=Ir.useHDGeometry?"includeGeometryHD=true":"";let i=-1===e.indexOf("?")?"?":"&";return""!==s&&(e+=i+s),n.embed&&Array.isArray(n.embed)&&n.embed.forEach(t=>{e+=i+"embed"+(t[0].toUpperCase()+t.substr(1))+"=true",i="&"}),new Promise((s,i)=>{const a=io.get(e);Array.isArray(a)&&a.length>0?a.push({resolve:s,reject:i}):(io.set(e,[{resolve:s,reject:i}]),this._fetchJson(e,t,n))})}async _fetchJson(e,t,n={}){try{const s=await this._fetch(e,n),i=await ot(s);return await this._handleJson(e,t,n)(i)}catch(t){this._handleError(e,n)(t)}}async _fetch(e,t){const n={method:t.method?t.method:"GET",headers:this._createHeaders(t),mode:"cors",cache:"default"};t.data&&(n.body=t.data);let s=Wr.server;const i=this._globalInitData.overrideRapi;i&&(s="live"===i?Wr.liveServer:Wr.testServer),(this._globalInitData.customApiUrl||""===this._globalInitData.customApiUrl)&&(s=this._globalInitData.customApiUrl);const a=new Request(s+e,n);this._globalCallback.onNetworkRequest(e,n,t);const r=await this._globalCallback.onCheckExternalCache(e,n);return r?{headers:{get:()=>"application/json"},json:()=>Promise.resolve(r)}:this._networkLayer.fetch(a,{},{checkResponse:e=>this._globalCallback.onValidateNetworkResponse("rapi-access",e)})}_createHeaders(e={}){const t={...Kr};this._globalInitData.overrideTenant&&(t.currentTenant=this._globalInitData.overrideTenant),this._globalInitData.overrideCountry&&(t.country=this._globalInitData.overrideCountry);const n=this._globalInitData.locale||"en";t.language=n,t.locale=n;const{contentType:s,accept:i,additionalHeaders:a,data:r}=e;if(s&&(t["content-type"]=e.contentType),i&&(t.accept=e.accept),a)for(let e in a)a.hasOwnProperty(e)&&(t[e]=a[e]);this._globalInitData.configuratorId&&(t.configurator=this._globalInitData.configuratorId);const o=this._currentToken||Xr;t.token="03-"+window.btoa((new Date).toISOString()+";"+o+";"+Kr.apiKey);const l=new Headers(t);return r instanceof FormData&&l.delete("content-type"),l}_handleJson(e,t,n={}){return async s=>{const i=await this._globalCallback.onApiJsonReceived(e,t,s);null!=i&&(s=i);let a=null,r=null;"number"==typeof s&&(a=s);for(let e in s)"meta"!==e&&s.hasOwnProperty(e)&&(a=s[e],r=e);if("error"===r)return this._handleError(e,n)(new Error(JSON.stringify(a)));if(!a)throw new TypeError("RAPI returned empty JSON");if(Array.isArray(a))for(let e=0,s=a.length;e<s;e++)this._prepareData(a[e],t,n),this._prepareEmbeddedData(a[e],t,n);else this._prepareData(a,t,n),this._prepareEmbeddedData(a,t,n);n.resolve?n.resolve(a):this._notifyWaiters(e,null,a)}}_prepareEmbeddedData(e,t,n={}){n.embed&&Array.isArray(n.embed)&&n.embed.forEach(s=>{const i=e[s.slice(0,-1)+"Objects"];if(Array.isArray(i)){for(let e=0,t=i.length;e<t;e++)this._prepareData(i[e],s,n);this._prepareRelationalData(t,s,e.id,i)}else i&&(this._prepareData(i,s,n),this._prepareRelationalData(t,s,e.id,[i]))})}_getCache(e){return this._getCacheFrom(e,eo)}_getErrorCache(e){return this._getCacheFrom(e,ao)}_getCacheFrom(e,t){let n=t.get(e);return n||(t.set(e,new Map),n=t.get(e)),n}_setCache(e,t,n){n.set(e.toString(),t)}_prepareData(e,t,n=null){let s=this._getCache(t);const i=n&&n.cacheKey?e[n.cacheKey]:e.id;if(i||n&&n.id||"tenants/me"===t)if("tenants/me"!==t){{const t=i||n.id;this._setCache(t,e,s)}e.__rapi_path__=t}else this._setCache("0",e,s);else"shortIds"!==t&&console.error("Can not cache because there is no ID!")}_getRelationsCacheFor(e,t,n){let s=$r.get(t);if(!s){const i=new Map,a=new Map;a.set(n,void 0),i.set(e,a),$r.set(t,i),s=$r.get(t)}let i=s.get(e);if(!i){const t=new Map;t.set(n,void 0),s.set(e,t),i=s.get(e)}return i.get(n)}_prepareGroups(e){const t=e.group,n=e.id;let s=ro(t);s||(Zr.set(t,[]),s=ro(t)),-1===s.indexOf(n.toString())&&s.push(n.toString())}_handleError(e,t={}){return n=>{navigator.onLine?(n.rmlErrorCode=1,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(1,[n])):(n.rmlErrorCode=0,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(0,[n])),t.reject?t.reject(n):this._notifyWaiters(e,n,null)}}_getRelationData(e,t,n={}){const s=e.id;if(!s)return Promise.resolve([]);const i=e.__rapi_path__,a=t.rapiPath;let r=this._getCache(a),o=this._getRelationsCacheFor(s.toString(),i,a),l=[];return o?(o.forEach(e=>l.push(r.get(e))),new Promise(e=>e(l))):navigator.onLine?new Promise((e,t)=>{this._get("/"+i+"/"+s+"/"+a,a,n).then(t=>{this._prepareRelationalData(i,a,s,t),e(t)},t)}):Promise.resolve([])}_prepareRelationalData(e,t,n,s){$r.has(e)||$r.set(e,new Map);let i=$r.get(e);const a=n.toString();i.has(a)||i.set(a,new Map);let r=i.get(a),o=this._getCache(t),l=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],n=t.id.toString();l.push(n),o.set(n,t)}r.set(t,l)}_notifyWaiters(e,t,n){const s=io.get(e);if(s&&s.length){for(let e=0,i=s.length;e<i;e++)t?s[e].reject(t):s[e].resolve(n);io.delete(e)}}_tenantMe(){return new Promise((e,t)=>{const n=this._getCache("tenants/me"),s=this._globalInitData.overrideTenant?this._globalInitData.overrideTenant:n.get("0");if(s)return e(s);this._fetchJson("/tenants/me","tenants/me",{resolve:t=>e(t),reject:t})})}async getTenant(e){return e||(e=await this._tenantMe()),this._getById(e.toString(),"tenants")}getCurrentSkin(){return this._tenantMe().then(e=>this._getById(e.toString(),"tenants").then(e=>this._getById(e.skin.toString(),"skins")))}getPrices(e){return this._getByIds(e,"prices",{filterKey:"priceIds",cacheKey:"priceId"})}async getConfiguratorSettings(e){const t=await this._getById(e,"configurators");return t.allowedHosts||(t.allowedHosts=[]),t.allowedHosts&&!Array.isArray(t.allowedHosts)&&(t.allowedHosts=t.allowedHosts.split(" ")),t}sendUserAction(e){return this._save("/userActions",{userAction:e},"userActions",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}_share(e,t,n,s){const i="/"+s+"/"+e+"/shares",a=new FormData;return a.append("email",t),a.append("type",n.toString()),new Promise((e,t)=>{const n={method:"POST",data:a,resolve:e,reject:t,accept:"application/json",contentType:"application/json; charset=UTF-8"};this._fetch(i,n).then(n.resolve,n.reject)})}shareConfiguration(e,t,n){return this._share(e,t,n,"configurations")}sharePlanSnapshot(e,t,n){return this._share(e,t,n,"planSnapshots")}export3D(e,t,n,s={}){const i="/"+(Yr(e)?"planSnapshots":"configurations")+"/"+e+"/3d-exports",a={formats:[{file_format:n,pack_external_data:!0,...s}]},r=JSON.stringify(a),o=new FormData;return o.append("email",t),o.append("settings",r),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t};this._fetch(i,n).then(n.resolve,n.reject)})}async trackView(e){if(this._itemLoaded||(t=en())&&(tn.includes(t)||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")||t.endsWith("codesandbox.io")||t.endsWith("stackblitz.com")||/^(admin.*.roomle.com)$/.test(t)))return;var t;const{configuratorId:n}=this._globalInitData,s={module:3,action:1,actionId:e,actionLabel:n};await this.sendUserAction(s),this._itemLoaded=!0}signinUser(e,t){return new Promise((n,s)=>{const i={method:"POST",accept:"application/json",contentType:"application/json; charset=UTF-8",data:JSON.stringify({identification:e,passwordMD5:t}),cacheKey:"token",resolve:n,reject:s};this._fetchJson("/auth/signin","auth",i)})}async signoutUser(e){const t=this._currentToken;t!==e&&this.setCurrentToken(e),await this._fetch("/auth/signout",{}),t&&t!==e?this.setCurrentToken(t):this.removeCurrentToken()}async savePlan(e){const t=e.id?"/plans/"+e.id:"/plans";return this._save(t,{plan:e},"plans",{method:e.id?"PUT":"POST",accept:"application/json",contentType:"application/json; charset=UTF-8"})}async savePlanSnapshot(e){return this._save("/planSnapshots",{planSnapshot:e},"planSnapshots",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}setCurrentToken(e){this._currentToken=e}removeCurrentToken(){this._currentToken=null}createNewPlan(){return{name:"",description:"",changeDate:(new Date).toISOString(),created:(new Date).toISOString(),draftId:null,thumbnail:"data:image/png;base64,missing",planObjects:null,active:!0,open:0,planDirectory:0,changed:0,version:2,floorLevel:0,visibility:9,user:null,tenant:null,assets:[],parent:null,setting:null}}updateCache(e,t){const n=this._getCache(e);this._setCache(t.id,t,n)}}e("R",ho),on([hn],ho.prototype,"_formDataUtil",void 0),on([hn],ho.prototype,"_errorHandler",void 0),on([hn],ho.prototype,"_dataSyncer",void 0),on([hn],ho.prototype,"_networkLayer",void 0),on([hn],ho.prototype,"_localStorage",void 0),on([hn],ho.prototype,"_globalInitData",void 0),on([hn],ho.prototype,"_globalCallback",void 0);const co=e("p",1500),uo=e("o",5);function po(){class e extends A{static _generateOutline(e,t){let n=new V(new ht(e),new dt({color:"#000000",dashSize:.03,gapSize:.01,linewidth:1}));return n.translateOnAxis(t,1),n.userData.ignoreComponentRaycast=!0,n}static cloneDockLine(e,t){let n=new V(e.geometry,e.material);return n.translateOnAxis(t.getCenter(new r),1),n.name="dockline",n.layers.set(5),n.userData.ignoreComponentRaycast=!0,n}_setValues(e,t,n,s,i){e&&(this.runtimeId=e,this.name=e.toString()),t&&(this.roomlePosition=Object.assign({},t)),n&&(this.roomleRotation=Object.assign({},n)),s&&(this.parentObjectId=s),i&&(this.isRootComponent=i)}constructor(e,t,n,s,i){super(),this._selected=!1,this.isChildPlanObject=!1,this.geometryChanged=!0,this.meshes=[],this.castShadow=!1,this.receiveShadow=!0,this._setValues(e,t,n,s,i)}get loadingMesh(){return this._loadingMesh}get boundingBoxMesh(){return this._boundingBoxMesh}get boundingBox(){return this._boundingBox}set roomlePosition(e){this._roomlePosition=e,e&&this.position.set(e.x/1e3,e.z/1e3,e.y/-1e3)}get roomlePosition(){return this._roomlePosition}set roomleRotation(e){this._roomleRotation=e,e&&this.rotation.set(e.x,e.z,-e.y)}get roomleRotation(){return this._roomleRotation}replaceMeshes(e){this.removeAllMeshes(),e.forEach(e=>{this.addMesh(new z(e.geometry,e.material))})}addMesh(e,t){e.renderOrder=2,e.userData.meshType=0,t&&e.applyMatrix4(Cs(t)),this.add(e),this.meshes.push(e)}getMeshById(e){return this.meshes.find(t=>t.userData.meshId===e)}removeMeshById(e){const t=this.getMeshById(e);t?this.removeMesh(t):console.warn("Could not remove mesh with id "+e,this.runtimeId,this.meshes)}removeMesh(e){const t=this.meshes.indexOf(e);this.remove(e),na(e),t<0||this.meshes.splice(t,1)}removeAllMeshes(e=!0){this.meshes.forEach(t=>{this.remove(t),e&&na(t)}),this.meshes=[],this._removeLoadingMesh(),this.remove(this._boundingBoxMesh),na(this._boundingBoxMesh),this._boundingBoxMesh=null}_hideAllMeshes(){this.meshes.forEach(e=>e.visible=!1)}_showAllMeshes(){this.meshes.forEach(e=>e.visible=!0)}select(){this._selected=!0}loading(){if(!this._kernelBoundingBox)return void console.warn("Bounding box (box for measurements) for component "+this.runtimeId+" not set, can not show external mesh loading box!");this._removeLoadingMesh(),this._hideAllMeshes();const{x:e,y:t,z:n}=this._kernelBoundingBox.getSize(new r);let s=new $e(e,t,n);this._loadingMesh=new z(s,Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#DDDDDD")})),this._loadingMesh.name="loading mesh",this._loadingMesh.receiveShadow=!1,this._loadingMesh.castShadow=!1,this._loadingMesh.layers.set(5),this._loadingMesh.translateOnAxis(this._kernelBoundingBox.getCenter(new r),1),this._loadingMesh.renderOrder=3,this.add(this._loadingMesh)}_removeLoadingMesh(){this._loadingMesh&&(this.remove(this._loadingMesh),na(this._loadingMesh),this._loadingMesh=null)}loadingFinished(){this._removeLoadingMesh(),this._showAllMeshes()}deselect(){this._selected=!1}hoverOn(){lt("pointer")}hoverOff(){lt("default")}removeFromParent(){return this.parent&&(this.parent.remove(this),this.removeAllMeshes()),this}computeBoundingBox(t,n=!1){if(this._boundingBoxMesh&&this.remove(this._boundingBoxMesh),!n&&t&&0===t.size.x&&0===t.size.y&&0===t.size.z)return;let s;if(!t||n){this._boundingBox=new ge;let e=new r;this.meshes.forEach(t=>{if(t.geometry instanceof c){let n=t.geometry.attributes.position;if(void 0!==n)for(let s=0,i=n.count;s<i;s++)e.fromBufferAttribute(n,s).applyMatrix4(t.matrix),this._boundingBox.expandByPoint(e)}}),this._kernelBoundingBox=this._boundingBox.clone();let t=this._boundingBox.max.x-this._boundingBox.min.x,n=this._boundingBox.max.y-this._boundingBox.min.y,i=this._boundingBox.max.z-this._boundingBox.min.z;s=new $e(t,n,i)}else{this._kernelBoundingBox=ki(t),this._boundingBox=this._kernelBoundingBox.clone();let{x:e,y:n,z:i}=this._boundingBox.getSize(new r);s=new $e(e,n,i)}this._boundingBoxMesh=new z(s,Oi.createMeshStandardMaterial({color:"#FFFFFF",transparent:!0,opacity:0,polygonOffset:!0,polygonOffsetFactor:-1,visible:!1})),this._boundingBoxMesh.name="bounding box mesh";let i=this._boundingBox.getCenter(new r);this._boundingBoxMesh.position.add(i),this._boundingBoxMesh.layers.set(5),this._boundingBoxMesh.renderOrder=3,this._boundingBoxMesh.castShadow=!1,this._boundingBoxMesh.receiveShadow=!1,this.add(this._boundingBoxMesh),this._dockline=e._generateOutline(s,i),this._dockline.name="bounding box outline",this._dockline.layers.set(5),this._selected&&this.add(this._dockline)}recursiveMeshes(){let t=this.meshes.slice();return this.children.forEach(n=>{n instanceof e&&t.push(...n.recursiveMeshes())}),t}isChild(t){let n=!1;return this.children.forEach(s=>{s instanceof e&&!n&&(n=s.runtimeId===t||s.isChild(t))}),n}getKernelPosition(e){let t=this.parent.localToWorld(this.position);return Ss(e.worldToLocal(t))}}class t extends e{constructor(e,t){super(e,null,null,null,!1),this.glbUrl=t}}class n extends e{constructor(e,t,n,s,i,a){super(t,n,s,i,a),this._stringId=null,this.receivedPointAssociation=!1,this.castShadow=!1,this.receiveShadow=!1,this._creator_=e}get stringId(){return this._stringId?this._stringId:this.runtimeId.toString()}addMesh(e,t){super.addMesh(e,t),e.material instanceof N&&(e.material.opacity=.8,e.material.roughness=1,e.material.metalness=0,e.material.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)),e.renderOrder=1,e.castShadow=!1,e.receiveShadow=!1}startPulsating(){var e,t;if(null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.pulsePreview)for(const e of this.meshes){const t={opacity:.8},n={opacity:.3};new TWEEN.Tween(t).to(n,co).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.material.opacity=t.opacity}).yoyo(!0).repeat(uo).start()}}hoverOn(){this.remove(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.9,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),lt("pointer")}hoverOff(){this.add(this._dockline),this.meshes.forEach(({material:e})=>{e.opacity=.8,e.roughness=1,e.metalness=0,e.color=new h(this._initData.colors.PREVIEW_DOCKING_COLOR)}),lt("default")}clonePreview(t){const s=new n(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.isRootComponent);return s._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof z&&0===e.userData.meshType&&s.meshes.push(e.clone(!0))}),s.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),s.add(e)}),this._dockline&&(s._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(s._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(s._boundingBox=this._boundingBox.clone()),s}preparePreview(){this.add(this._dockline),this.add(this._boundingBoxMesh)}}on([hn],n.prototype,"_initData",void 0);class s extends n{constructor(e,t,n,s,i,a){super(e,t,n,s,i,null),this.lineSegments=[],a&&(this._stringId=this.runtimeId+"_has_additional_dock_point_copy")}set roomleLineFrom(e){this._roomleLineFrom=e,this.lineFrom=bs(e)}get roomleLineFrom(){return this._roomleLineFrom}set roomleLineTo(e){this._roomleLineTo=e;let t=bs(e);t.equals(this.lineFrom)&&(console.warn("lineFrom and lineTo are equal!"),t.add(new r(0,.01,0))),this.lineTo=t}get roomleLineTo(){return this._roomleLineTo}set roomlePositionFrom(e){this._roomlePositionFrom=e,this.positionFrom=bs(e)}get roomlePositionFrom(){return this._roomlePositionFrom}set roomlePositionTo(e){this._roomlePositionTo=e;let t=bs(e);t.equals(this.positionFrom)&&(console.warn("positionFrom and positionTo are equal!"),t.add(new r(0,.01,0))),this.positionTo=t}get roomlePositionTo(){return this._roomlePositionTo}addMesh(e,t){super.addMesh(e,t),e.visible=!1,e.renderOrder=3}hoverOn(){this._dockline.visible=!0,lt("pointer")}hoverOff(){this._dockline.visible=!1,lt("default")}preparePreview(){super.preparePreview(),this._dockline.visible=!1;let e=this.lineTo.clone(),t=this.lineFrom.clone();const n=(new r).subVectors(e,t);let s=n.length(),i=n.normalize();this._createLineMesh(.01,s,this.lineSegments);const a=(new M).setFromUnitVectors(new r(0,1,0),i);this.lineMesh.quaternion.multiply(a),this.lineMesh.renderOrder=1;let o=(new r).addVectors(e,t).multiplyScalar(.5);this.lineMesh.position.copy((new r).subVectors(o,this.position.clone())),this.add(this.lineMesh);let l=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation),h=null,d=0,c=Math.abs(i.x),u=Math.abs(i.y),p=Math.abs(i.z);c>=u&&c>=p?(h=new r(l.x,0,0),d=Math.sqrt(l.y*l.y+l.z*l.z)):u>=c&&u>=p?(h=new r(0,l.y,0),d=Math.sqrt(l.x*l.x+l.z*l.z)):p>=u&&p>=c&&(h=new r(0,0,l.z),d=Math.sqrt(l.y*l.y+l.x*l.x)),d=d>0?d:.01;let m=(new r).subVectors(this.positionTo.clone(),this.positionFrom.clone()).length()+h.length();this._createBoundingLineMesh(1.1*d,m,this.lineSegments);let g=this.positionTo.clone(),f=this.positionFrom.clone(),_=(new r).subVectors(g,f).normalize();const v=(new M).setFromUnitVectors(new r(0,1,0),_);this.boundingLineMesh.quaternion.multiply(v),this.boundingLineMesh.renderOrder=3;let w=(new r).addVectors(this.positionTo.clone(),this.positionFrom.clone()).multiplyScalar(.5).add(l);this.boundingLineMesh.position.copy((new r).subVectors(w,this.position.clone())),this.add(this.boundingLineMesh)}_createLineMesh(e,t,n){this.lineMesh=this._createPreviewMesh(e,t,n,16,Oi.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:.4})),this.lineMesh.name="line mesh"}_createBoundingLineMesh(e,t,n){this.boundingLineMesh=this._createPreviewMesh(e,t,n,32,Oi.createMeshStandardMaterial({color:"#ffffff",transparent:!0,opacity:0})),this.boundingLineMesh.name="bounding line mesh",this.boundingLineMesh.userData.ignoreComponentRaycast=!0,this.boundingLineMesh.layers.set(5)}_createPreviewMesh(e,t,n,s,i){let a;if(0===n.length)a=new ct(e,e,t,s,1);else{const i=[];for(const a of n){const n=a.to-a.from,r=(a.from+a.to)/2,o=new ct(e,e,n,s,1);o.translate(0,r-t/2,0),i.push(o)}a=vn(i,!1)}return new z(a,i)}clonePreviewLine(t){let n=new s(this._creator_,this.runtimeId,this.roomlePosition,this.roomleRotation,this.parentObjectId,this.receivedPointAssociation);return n._stringId=this.runtimeId+"_"+t,this.children.forEach(e=>{e instanceof z&&0===e.userData.meshType&&n.meshes.push(e.clone(!0))}),n.meshes.forEach(e=>{e.material=e.material.clone(),e.geometry=e.geometry.clone(),n.add(e)}),this._dockline&&(n._dockline=e.cloneDockLine(this._dockline,this._boundingBox)),this._boundingBoxMesh&&(n._boundingBoxMesh=this._boundingBoxMesh.clone(!0)),this._boundingBox&&(n._boundingBox=this._boundingBox.clone()),n}getPositionForIntersectionPoint(e){let t=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation),n=this.positionTo.clone().add(t),s=this.positionFrom.clone().add(t),i=new ut(s,n).closestPointToPoint(e,!0,new r);return(isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&i.copy(e),i.sub(t)}updatePreviewPosition(e){let t=this.getPositionForIntersectionPoint(e),n=this.parent.localToWorld(t);this._newPosition=this.worldToLocal(n);let s=this._boundingBox.getCenter(new r).applyEuler(this.docklineRotation);this._dockline.position.copy((new r).addVectors(this._newPosition,s)),this._dockline.rotation.copy(this.docklineRotation)}hideSelectionLine(){this._dockline.visible=!1}getKernelPosition(e){if(this._newPosition){let t=this.localToWorld(this._newPosition);return Ss(e.worldToLocal(t))}return super.getKernelPosition(e)}}class i extends Q{constructor(e,t,n,s,i,a,r){super(e,t,n,s,i,a),r||(r={left:0,top:1,right:1,bottom:0}),this.offset=r}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}_calculateProjectionMatrix(){const e=this._calculate2DPlanes();if(this._offset.left>=this._offset.right||this._offset.bottom>this._offset.top)return(new P).makeOrthographic(e.left,e.right,e.top,e.bottom,this.near,this.far);const t=this._scaleRange(e.left,e.right,this._offset.left,this._offset.right);let n=t.from,s=t.to;const i=this._scaleRange(e.bottom,e.top,this._offset.bottom,this._offset.top);let a=i.from,r=i.to;const o=(e.right-e.left)/(e.top-e.bottom),l=(s-n)/(r-a);if(l>o){const e=(a+r)/2,t=(r-a)*l/o;a=e-t/2,r=e+t/2}else{const e=(n+s)/2,t=(s-n)*o/l;n=e-t/2,s=e+t/2}return(new P).makeOrthographic(n,s,r,a,this.near,this.far)}_scaleRange(e,t,n,s){const i=(t-e)/(s-n);return{from:e-i*n,to:t+i*(1-s)}}_calculate2DPlanes(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let i=n-e,a=n+e,r=s+t,o=s-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,r-=t*this.view.offsetY,o=r-t*this.view.height}return{left:i,right:a,top:r,bottom:o}}}class o extends X{constructor(e,t,n,s,i){super(e,t,n,s),i||(i={left:0,top:1,right:1,bottom:0}),this.offset=i}copy(e,t){return super.copy(e,t),this._offset=e._offset,this}set offset(e){this._offset=e,this.updateProjectionMatrix()}get offset(){return this._offset}resetOffset(){this._offset={left:0,top:1,right:1,bottom:0}}_calculateProjectionMatrix(){let e,t,n,s,i=this.fov*(2*Math.PI/360)/2;n=Math.tan(i),s=-n;let r=Math.atan(this.aspect*Math.tan(i));t=Math.tan(r),e=-t;let o=this._offset.left,l=this._offset.right,h=this._offset.top,d=this._offset.bottom,c=new a(l-o,h-d),u=new a(o+c.x/2,d+c.y/2);if(c.x<c.y){let i=(1-u.x)/(c.x/2),a=u.x/(c.x/2);t*=i,e*=a;let r=(i+a)/2;n*=r,s*=r}else{let i=(1-u.y)/(c.y/2),a=u.y/(c.y/2);n*=i,s*=a;let r=(a+i)/2;e*=r,t*=r}e*=this.near,t*=this.near,n*=this.near,s*=this.near;let p=this.near*Math.tan(Math.PI/180*.5*this.fov)/this.zoom*2,m=this.aspect*p;return this.view&&this.view.enabled&&(e+=this.view.offsetX*m/this.view.fullWidth,n-=this.view.offsetY*p/this.view.fullHeight,t+=this.view.offsetX*m/this.view.fullWidth,s-=this.view.offsetY*p/this.view.fullHeight),(new P).makePerspective(e,t,n,s,this.near,this.far)}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){this._offset?(this.projectionMatrix=this._calculateProjectionMatrix(),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()):super.updateProjectionMatrix()}}return{create:function(t,n,s,i,a){return new e(t,n,s,i,a)},createPreview:function(e,t,s){return new n(s,e,{x:0,y:0,z:0},{x:0,y:0,z:0},t,null)},createStatic:function(e,n){return new t(e,n)},createPreviewLine:function(e,t){let n=new s(t,e.id,e.roomlePosition,e.roomleRotation,e.parentObjectId,e.receivedPointAssociation);return e.meshes.forEach(e=>{let t=e.clone();t.material=e.material.clone(),t.geometry=e.geometry.clone(),n.addMesh(t)}),n.computeBoundingBox(),n},isPreview:function(e){return e instanceof n},isPreviewLine:function(e){return e instanceof s},createPerspectiveCamera:function(e,t,n,s,i){return new o(e,t,n,s,i)},createOrthographicCamera:function(e,t,n,s,a,r,o){return new i(e,t,n,s,a,r,o)}}}const mo=e("J",9);class go{constructor(e){this._mergeThreshold=3,this._componentsToMerge=new fo,this._mergeInProgress=!1,this._components=new Map,this._previews=new Map,this._componentNumberOfPossibleChildren=new Map,this._creator_=e,this._getKernelAccess().addConfiguratorListener(this),this._componentFactory=po()}get materialQueue(){return this.getMeshGenerator().materialQueue}_getKernelAccess(){return Fh.lookup("planner-kernel-access",this._creator_)}_applyMeshTransform(e,t,n,s,i){if(n){const s=e.userData.transform=Cs(n);t&&(e.userData.transform=s),e.applyMatrix4(s)}this._applyMeshUVTransform(e,t,s,i)}_applyMeshUVTransform(e,t,n,s){if(6!==(null==n?void 0:n.length)||(e=>1===e[0]&&0===e[1]&&0===e[2]&&1===e[3]&&0===e[4]&&0===e[5])(n))t&&(t.uvTransform=void 0),s&&(e.geometry=s);else{const i=(e=>{const t=new P;return t.set(e[0],e[2],0,e[4],e[1],e[3],0,e[5],0,0,1,0,0,0,0,1),t})(n);t&&(t.uvTransform=i);const a=null!=s?s:e.geometry;if(a&&a.attributes.uv){const t=a.clone();t.attributes.uv.applyMatrix4(i),e.geometry=t}}}_addMeshToSubPart(e,t,n,s,i,a,r,o,l,h){const d=this._generateMesh(e,t,n,a,r,o,l,void 0,void 0,h);this._applyMeshTransform(d,null,s,i),this._subPartObject.add(d)}_addMeshToComponent(e,t,n,s,i,a,r,o,l,h,d,c){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._addMeshToSubPart(e,null,s,null,null,r,o,l,h,c);const u=this.getComponent(e);if(!u)return;const p=this._componentFactory.isPreview(u),m=this._generateMesh(e,n,p?null:s,r,o,l,h,void 0,void 0,c);m.userData.meshId=t,m.userData.geometryId=n,m.userData.materialId=s,this._applyMeshTransform(m,m.userData,i,a),p&&m.layers.set(5),u&&u.addMesh(m),u.meshes.length>this._mergeThreshold&&this._componentsToMerge.set(e,u.meshes.length)}_changeMeshOfComponent(e,t,n,s,i,a,r){const o=this.getComponent(e);if(!o)return;const l=o.getMeshById(t);if(l){l.userData.geometryId!==n&&console.warn("Geometry of mesh has changed!"),l.userData.materialId=s,l.userData.materialAttributes=r;const e=l.material.clone();this._configuratorMeshGenerator.setMaterial(l,s,void 0,r).then(()=>{this._requestRenderSceneUpdateCallback&&this._requestRenderSceneUpdateCallback()}),e.opacity!==l.material.opacity&&this._requestRenderCallback&&this._requestRenderCallback(),i&&(l.position.set(0,0,0),l.scale.set(1,1,1),l.rotation.set(0,0,0));const t=this._configuratorMeshGenerator.getGeometry(n);this._applyMeshTransform(l,l.userData,i,a,t)}}_removeMeshFromComponent(e,t){const n=this.getComponent(e);n&&n.removeMeshById(t)}getComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:(console.warn("component not found!",e),null)}getNumberOfPossibleChildrenForComponent(e){if(this._componentNumberOfPossibleChildren.has(e))return this._componentNumberOfPossibleChildren.get(e);const t=this._getKernelAccess().kernelInstance.getPlanComponentPossibleChildren(e).length;return this._componentNumberOfPossibleChildren.set(e,t),t}tryToMergeComponents(){this._initData.moc||this._mergeInProgress||(this._mergeInProgress=!0,this._componentsToMerge.size,this._requestMergeComponents())}_requestMergeComponents(){window.requestIdleCallback(this._mergeNextComponent.bind(this))}_mergeNextComponent(){if(this._componentsToMerge.size>0){const e=this._componentsToMerge.largestValue();this._componentsToMerge.delete(e),this._mergeComponent(e),this._requestMergeComponents()}else this._mergeInProgress=!1,this._geometriesMerged&&this._geometriesMerged(),this._components.forEach(e=>{e.loadingMesh&&console.warn("component still has loading mesh: ",e.hash)})}_mergeComponent(e){const t=this._components.get(e);if(t&&!(t.meshes.length<=this._mergeThreshold))if(this._cacheHolder.componentCache.has(t.hash)){const e=this._cacheHolder.componentCache.get(t.hash).meshes;t.replaceMeshes(e)}else{const e=new Map,n=[],s=[];t.meshes.forEach(t=>{const i=t.userData.materialId;if(!i)return void console.warn("mesh has no material id set");if(!e.has(i)){const s=new z(new c,t.material);s.userData.materialId=i,s.receiveShadow=!0,s.castShadow=!0,s.layers.set(3),this._setMaterial(s,i),n.push(s),e.set(i,s)}const a=e.get(i),r=a.geometry;t.userData.transform&&t.geometry.applyMatrix4(t.userData.transform),a.geometry=vn([r,t.geometry]),s.push(t)}),n.forEach(e=>t.addMesh(e)),s.forEach(e=>t.removeMesh(e)),this._cacheHolder.componentCache.set(t.hash,t)}}_addComponent(e){this._listener&&e.isRootComponent&&this._listener.display(e)}removeDockingComponent(){this._getKernelAccess().requestDeleteComponent(this._configuratorContext.dockingRootComponentId),this._configuratorContext.dockingRootComponentId=null}dockComponent(e,t,n,s,i){let a=this._components.get(n),r=this._components.get(e);r&&(r.roomlePosition=s,r.roomleRotation=i,a&&a.add(r),r.parentObjectId=n,r.isRootComponent=t,this._addComponent(r))}dockComponentWithPosition(e,t){let n,s=this._components.get(e.parentId);n=t?t.getKernelPosition(s):e.getKernelPosition(s),Er.start("dock_component_with_position_"+e.childId),this._getKernelAccess().dockComponentWithPosition(e.parentId,e.parentDockId,e.childId,e.childDockId,n),this._configuratorContext.dockingRootComponentId=null}removePreviews(){this._previews.size>0&&(this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear())}_updatePlanObject(e,t){const n=this._components.get(e.rootPlanComponentId);let s=!0;n&&(s=n.geometryChanged),this._listener&&this._listener.planObjectUpdated(e,s,t)}Editor3dAddBakedMesh(e,t,n,s,i,a,r,o){this._addMeshToComponent(e,null,null,t,null,null,n,s,i,a,r,o)}Editor3dAddDockPreview(e,t){const n=this._componentFactory.createPreview(t,e,this._creator_);this._previews.set(t.toString(),n)}Editor3dAddNamedMesh(e,t,n,s,i,a,r,o,l,h,d,c){this._addMeshToComponent(e,t,n,s,i,d,a,r,o,l,h,c)}Editor3ChangedNamedMesh(e,t,n,s,i,a,r){this._changeMeshOfComponent(e,t,n,s,i,a,r)}Editor3dRemoveNamedMesh(e,t){this._removeMeshFromComponent(e,t)}Editor3dBeginConstruction(e,t){if(!t){const t=this._components.get(e);t&&t.removeAllMeshes()}this._subPartGuard&&e===this._subPartGuard.info&&(this._subPartObject=new A)}Editor3dComponentCreated(e,t,n,s,i){s&&(this._configuratorContext.rootComponentId=e);let a=null;this._components.has(e)?(a=this._components.get(e),a.removeAllMeshes()):(a=this._componentFactory.create(e,t,n,i,s),a.layers.set(3)),this._components.set(e,a),this._addComponent(a)}Editor3dComponentDocked(e,t,n,s,i){this.dockComponent(e,t,n,s,i)}Editor3dEndConstruction(e){if(this._subPartGuard&&this._subPartGuard.info===e)return void this._subPartGuard.resolve(this._subPartObject);const t=this._getKernelAccess().kernelInstance.getComponent(e),n=this._components.get(e);n&&(n.computeBoundingBox(t.boxForMeasurement),n.boundingBoxMesh&&this._listener&&this._listener.addComponentHandlers(n));let s=this._previews.get(e.toString());s&&s.computeBoundingBox(t.boxForMeasurement,!0)}Editor3dGeometryReady(e){const t=this._components.get(e);t&&t.loadingFinished()}Editor3dGeometryNotReady(e){const t=this._components.get(e);t&&t.loading()}Editor3dPlanObjectConstructionDone(e){const t=this._getKernelAccess().kernelInstance.getPlanObject(e),n=[t,this._getKernelAccess().kernelInstance.getFullPartList(),this._getKernelAccess().kernelInstance.getHashOfConfiguration(e),this._getKernelAccess().kernelInstance.getComponentId(t.rootPlanComponentId)];kr.finishOperation(2,n),this._updatePlanObject(t,!1),this._listener&&this._listener.planObjectConstructionDone(t)}Editor3dPreviewConstructionDone(e,t){let n=!1;this._previews.forEach(e=>{null!==e.parent&&(this._listener&&(this._componentFactory.isPreviewLine(e)?this._listener.addPreviewLineHandlers(e):this._listener.addPreviewHandlers(e)),n=!0)}),this._listener&&this._listener.previewConstructionDone(this._components.get(e),n)}Editor3dSetPreviewLineAssociations(e,t){let n=this._previews.get(t.toString());if(n.clear(),!n)return;let s=this._componentFactory.createPreviewLine(n,this._creator_),i=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let n;n=0===t?s:s.clonePreviewLine(t),n.name="Preview Line",n.parentDockId=e[t].parentDockId,n.parentId=e[t].parentId,n.childDockId=e[t].childDockId,n.childId=e[t].childId,n.docklineRotation=(a=e[t].rotation,new ve(a.x,a.z,-a.y)),n.roomlePosition=e[t].position,n.roomleLineFrom=e[t].lineFrom,n.roomleLineTo=e[t].lineTo,n.lineSegments=[];for(const s of e[t].lineSegments)n.lineSegments.push({from:s.from/1e3,to:s.to/1e3});n.roomlePositionFrom=e[t].positionFrom,n.roomlePositionTo=e[t].positionTo,i.add(n),n.preparePreview(),this._previews.set(n.stringId,n)}var a}Editor3dSetPreviewPointAssociations(e,t){var n,s;let i=this._previews.get(t.toString());if(!i)return;let a=this._components.get(this._configuratorContext.rootComponentId);for(let t=0;t<e.length;t++){let r;0===t?r=i:(r=i.clonePreview(t),this._previews.set(r.stringId,r)),r.name="Preview Point",r.parentDockId=e[t].parentDockId,r.parentId=e[t].parentId,r.childDockId=e[t].childDockId,r.childId=e[t].childId,r.preparePreview(),r.receivedPointAssociation=!0,r.userData.ignoreComponentRaycast=!0,a.add(r);let o=e[t].position;e[t].insertInBetween&&(null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&(o={x:o.x-.5*e[t].displacementVector.x,y:o.y-.5*e[t].displacementVector.y,z:o.z-.5*e[t].displacementVector.z}),r.roomlePosition=o,r.roomleRotation=e[t].rotation,r.startPulsating()}}componentDeleted(e){const t=this._components.get(e);t&&(this._listener&&this._listener.componentDeleted(t),t.removeFromParent(),t.removeAllMeshes(),this._components.delete(e))}componentMetaUpdated(e){const t=this._getRuntimeComponent(e.id);t&&(t.hash=e.hash,t.roomlePosition=e.position,t.roomleRotation=e.rotation,e.boxForMeasurement&&t.computeBoundingBox(e.boxForMeasurement),this._listener&&this._listener.componentUpdated(t,e))}componentConfigurationUpdated(e,t){const n=this._getRuntimeComponent(e);n&&(n.geometryChanged=t)}_getRuntimeComponent(e){let t=this._components.get(e);return t||(t=this._previews.get(e.toString()),t)?t:null}configurationLoaded(e,t,n,s,i){10===e&&(this._configuratorContext.dockingRootComponentId=n);let a=0===t;a?this._getKernelAccess().kernelInstance.requestPlanComponentConstructionRecursive(n):this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(t);let r=this._getKernelAccess().kernelInstance.getComponent(n),o=this._components.get(n);o&&(o.computeBoundingBox(r.boxForMeasurement),o.hash=r.hash),this._listener&&this._listener.configurationLoaded(o,a&&void 0!==o.boundingBoxMesh)}finishParameterChange(e,t){this.materialQueue.registerCallback(e)}planObjectConfigurationUpdated(e,t,n,s){let i=this._getKernelAccess().kernelInstance.getPlanObject(e);this._updatePlanObject(i,s)}planObjectCreated(e,t){this._configuratorContext.planObjectId=t,this._listener&&this._listener.clearScene()}planObjectUpdated(e,t){this._updatePlanObject(e,t)}sceneCleared(){this._components.forEach((function(e){e.removeFromParent(),e.removeAllMeshes()})),this._components.clear(),this._componentNumberOfPossibleChildren.clear(),this._previews.forEach(e=>{e.removeFromParent(),e.removeAllMeshes()}),this._previews.clear()}setListener(e){this._listener=e}getBoundingBox(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxForMeasurement)return ki(e.boxForMeasurement)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxOfGeometry(){if(this._configuratorContext.planObjectId){const e=this._getKernelAccess().kernelInstance.getPlanObject(this._configuratorContext.planObjectId);if(e&&e.boxOfGeometry)return ki(e.boxOfGeometry)}else if(this._configuratorContext.rootComponentId){const e=this._components.get(this._configuratorContext.rootComponentId);return(new ge).setFromObject(e)}return null}getBoundingBoxWithPreviews(){const e=this._components.get(this._configuratorContext.rootComponentId);return e?(new ge).setFromObject(e):null}hasPreviews(){return this._previews.size>0}clearRootComponent(){var e;null===(e=this._components.get(this._configuratorContext.rootComponentId))||void 0===e||e.hoverOff()}debugSceneGraph(e){e?this._components.has(e)?this._components.get(e):this._previews.has(e.toString())&&this._previews.get(e.toString()):this._configuratorContext}getComponentsForIds(e){let t=[];return e.forEach(e=>{const n=this._components.get(e);n&&t.push(n)}),t}getComponents(){return Array.from(this._components.values())}getPreviews(){return Array.from(this._previews.values())}hasPreviewLines(){for(const e of this._previews.values())if(this._componentFactory.isPreviewLine(e))return!0;return!1}isPreviewLine(e){return this._componentFactory.isPreviewLine(e)}isPreview(e){return this._componentFactory.isPreview(e)}setGeometriesMergedListener(e){this._geometriesMerged=e}removeGeometriesMergedListener(){this._geometriesMerged=void 0}setMergeThreshold(e){this._mergeThreshold=e}_generateMesh(e=0,t=null,n,s,i,a,r,o,l,h){return this._configuratorMeshGenerator.generateMesh(e,t,n,s,i,a,r,!1,h)}_setMaterial(e,t,n){this._configuratorMeshGenerator.setMaterial(e,t)}constructComponents(e){this._getKernelAccess().kernelInstance.requestPlanObjectConstruction(e)}requestSubPartConstruction(e){return this._subPartGuard=new _n(e),this._getKernelAccess().requestPlanComponentConstruction(e,!1),this._subPartGuard.wait()}getMeshGenerator(){return this._configuratorMeshGenerator}setRequestRenderCallback(e){this._requestRenderCallback=e}setRequestRenderSceneUpdateCallback(e){this._requestRenderSceneUpdateCallback=e}}e("C",go),on([hn],go.prototype,"_configuratorMeshGenerator",void 0),on([hn],go.prototype,"_configuratorContext",void 0),on([hn],go.prototype,"_cacheHolder",void 0),on([hn],go.prototype,"_initData",void 0);class fo extends Map{largestValue(){let e=this.entries().next().value[0],t=0;return this.forEach((n,s)=>{n>t&&(e=s,t=n)}),e}}const _o=["material"];class vo extends Vr{constructor(e){super(e),this.externalMeshQueue=new Wa,this.muteKernelCallbacks=!1,this.listOfVariants=(e,t)=>{}}init(e){super.init(e),Er.addMeta("kernel_is_ready",{isWasm:this._useWASM}),Ir.kernelInstance?(this._kernelContainer=Ir.kernelContainer,setTimeout(()=>this._loadSuccess(),0)):this._scriptLoader.fetch(this._kernelPath,{id:"kernel"}).then(this._loadSuccess.bind(this),this._loadError.bind(this))}_loadSuccess(){Er.start("kernel_is_ready"),window.ConfiguratorKernel&&(Ir.kernelInstance?setTimeout(()=>this.isReady(),0):(window.ConfiguratorKernel(this._kernelContainer),window.ConfiguratorKernel=null))}_loadError(){this._configuratorKernelAccessCallback.loadError()}selectedComponent(e){this._updateComponentDependencies(e)}uiRequestConfiguration(e){const t=this._kernelInstance.getSerializedConfiguration(e);kr.finishOperation(1,t)}_updateComponentParameters(e){let t=this._kernelInstance.getComponentParameters(e);const n=this._kernelInstance.getComponent(e);this._configuratorKernelAccessCallback.updateParameters(t,n.parameterGroups,e,1)}selectionChange(e,t){let n=!1,s=[];if(e){let t=this._kernelInstance.getComponent(e);t.componentId=this._kernelInstance.getComponentId(e),t&&t.childIds&&t.childIds.length>0&&(n=!0),s.push(t);const i=this._kernelInstance.getPlanObjectFromPlanComponent(e);i&&this._componentSelectionChanged(i,t)}this._configuratorUiCallbacks.onSelectionChange("standard",t,n,s)}_componentSelectionChanged(e,t){}_parameterChanged(e,t,n){}multiSelectionChange(e,t){this._updateCommonComponentDependencies(e);let n=!1,s=!1,i=[];e&&e.forEach(e=>{let a=this._kernelInstance.getComponent(e);a.componentId=this._kernelInstance.getComponentId(e),a&&a.childIds&&a.childIds.length>0&&(n=!0),a.id===t&&(s=!0),i.push(a)}),this._configuratorUiCallbacks.onSelectionChange("multiselect",s,n,i)}_updateCommonComponentDependencies(e){const{parameters:t,parameterGroups:n}=this._kernelInstance.getCommonPlanComponentParameters(this._utilityToLongArray(e));this._configuratorKernelAccessCallback.updateParameters(t,n,e,2)}_updateComponentChildren(e){const t=this._kernelInstance.getPlanComponentPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,1)}_updateComponentDependencies(e){this._updateComponentParameters(e),this._updateComponentChildren(e)}_updatePlanObjectParameters(e){let t,n=this._kernelInstance.getPlanObjectParameters(e);if(0===n.length){let s=this._kernelInstance.getRootPlanComponentIdFromObjectId(e);n=this._kernelInstance.getComponentParameters(s),this._enableRootComponentParametersAsGlobal(),t=this._kernelInstance.getComponent(s)}else this._configuratorContext.rootComponentParametersAsGlobal=!1,t=this._kernelInstance.getPlanObject(e);this._configuratorKernelAccessCallback.updateParameters(n,t.parameterGroups,e,0)}_enableRootComponentParametersAsGlobal(){this._configuratorContext.selectedRuntimeComponentId||(this._configuratorContext.rootComponentParametersAsGlobal=!0)}_updatePlanObjectChildren(e){const t=this._kernelInstance.getPlanObjectPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,0)}updatePlanObjectDependencies(e){this._updatePlanObjectParameters(e),this._updatePlanObjectChildren(e)}_updateConfigurationHasChildren(e,t=null){t||(t=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)));const n=t.childIds.size?t.childIds.size():t.childIds.length;this._configuratorUiCallbacks.onConfigurationHasChildren(n>0)}dockComponent(e,t,n,s){const i=this._kernelInstance.getComponentId(n),a=this._kernelInstance.getComponentId(e);this._kernelInstance.dockComponent(n,s,e,t),this._configuratorUiCallbacks.onUserInitiatedDockDone(i,s,a,t,null)}changeUseOfHDGeometry(e,t){this._rapiAccess.changeUseOfHDGeometry();const n=e.planObjectId,s=e.lastLoadedRapiId?e.lastLoadedRapiId:this._kernelInstance.getComponentId(n),i=this._kernelInstance.getSerializedConfiguration(n);this._kernelInstance.clearAll(),this._kernelInstance.useHDGeometry(t),kr.finishOperation(3,[i,s])}webGlPreviewDockings(e,t){kr.waitFor(4).then(({componentId:n})=>{t&&this.requestPlanComponentConstruction(n),this._kernelInstance.requestPreviewGeometry(n,e.planObjectId,!1)}),e.lastPossibleChild&&e.lastPossibleChild.isComponent&&(this._kernelIo.setMeta({componentId:e.lastPossibleChild.id}),this._kernelInstance.loadPlainComponent(10,e.lastPossibleChild.id,e.lastPossibleChild.configuration)),e.lastPossibleChild&&e.lastPossibleChild.isItem&&this._kernelInstance.loadFreeFlyingConfiguration(10,e.lastPossibleChild.configuration)}previewDockingsWithDrag(e,t){var n,s,i;this._kernelInstance.requestPreviewGeometry(e,t,null!==(i=null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&void 0!==i&&i)}cancelDocking(e){var t,n,s;this._kernelInstance.cancelDocking(e,null!==(s=null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.advancedDocking)&&void 0!==s&&s)}loadConfiguration(e){this._initData.id?this._memoryManager.loadingConfiguration(this._initData.id):this._memoryManager.loadingConfigurationString(),this._memoryManager.shouldHardReset()?this._kernelInstance.clearAll():this._kernelInstance.clearScene(),this._kernelInstance.loadConfiguration(mo,e,{x:0,y:0,z:0})}changeCommonComponentParameter(e,t,n,s,i,a){if("string"==typeof s){const n=[];for(const i of e)this._kernelInstance.isExternalPlanObject(i)?n.push(i):this._kernelInstance.setComponentParameter(i,t,s);this._kernelInstance.setPlanComponentParameters(this._utilityToLongArray(n),t,s)}else console.warn("tried to set a parameter to a none string value!",s,t,n);this._finishParameterChange(n,i,a),this._updateCommonComponentDependencies(e)}changeComponentParameter(e,t,n,s,i,a){"string"==typeof s?this._kernelInstance.isExternalPlanObject(e)?this._parameterChanged(e,t,s):this._kernelInstance.setComponentParameter(e,t,s):console.warn("tried to set a parameter to a none string value!",s,t,n),this._finishParameterChange(n,i,a),this._updateComponentDependencies(e)}changePlanObjectParameter(e,t,n,s,i,a){"string"==typeof s?this._kernelInstance.isExternalPlanObject(e)?this._parameterChanged(e,t,s):this._kernelInstance.setPlanObjectParameter(e,t,s):console.warn("tried to set a parameter to a none string value!",s,t,n),this._finishParameterChange(n,i,a)}_finishParameterChange(e,t,n){-1===_o.indexOf(e)?setTimeout(()=>t(),0):this._configuratorKernelCallbackListener.forEach(e=>e.finishParameterChange(t,n))}requestDeleteComponents(e){e&&this._kernelInstance.deletePlanComponents(this._utilityToLongArray(e))}requestDeletePlanComponent(e){var t,n;e&&(null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)&&this._kernelInstance.deletePlanComponent(e)}loadComponentIntoKernel(e,t){this._kernelIo.setMeta({componentId:t}),this._kernelInstance.loadComponentDefinition(10,e)}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const s=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(s,btoa(e))}requestSync(e,t){this.planObjectCreated(e,t),this._kernelInstance.syncPlanObjectToView(e,t)}getGlobalParameters(e,t){return new Promise(n=>{let s=this._kernelInstance.getPlanObjectParameters,i=e;t&&(s=this._kernelInstance.getComponentParameters,i=this._kernelInstance.getRootPlanComponentIdFromObjectId(e)),n(s.apply(this._kernelInstance,[i]))})}getPartList(){return new Promise(e=>{e(this._kernelInstance.getFullPartList())})}getConfigurationHash(e){return new Promise(t=>t(this._kernelInstance.getHashOfConfiguration(e.planObjectId)))}requestPlanObjectConstruction(e){this._kernelInstance.requestPlanObjectConstruction(e)}isReady(){super.isReady(),this._setupKernel(),Sr.isProduction||(window.__RML__DEBUG__.Kernel=this._kernelInstance,window.__RML__DEBUG__.KernelContainer=this._kernelContainer,window.__RML__DEBUG__.Helper={convertCObject:Ps}),this._configuratorKernelAccessCallback.isReady(),this._configuratorUiCallbacks.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Ir.planObjectId&&this.planObjectCreated(-1,Ir.planObjectId)}_setupKernel(){1===this._kernelType&&(Er.start("kernel_create_instance"),Ir.kernelInstance?this._kernelInstance=Ir.kernelInstance:this._kernelInstance=new this._kernelContainer.Kernel),this._initKernel()}onLoadComponentError(e,t){this._configuratorUiCallbacks.onComponentLoadError(e,t)}configurationLoaded(e,t,n,s,i,a){kr.finishOperation(4,{conversationId:e,objectId:t,componentId:n,hash:s,errors:Ps(i)}),this._configuratorKernelCallbackListener.forEach(a=>a.configurationLoaded(e,t,n,s,i))}componentDefinitionLoaded(e,t){kr.finishOperation(0,t)}componentDefinitionLoadingError(e,t){this._kernelIo.error(t),kr.failOperation(0,new Error(t))}configurationLoadingError(e,t){let n="Configuration loading error";if(t){const e=Ps(t);Array.isArray(e)&&(n=e.join("\n"),e.forEach(e=>this._kernelIo.error(e)))}kr.failOperation(4,new Error(n)),kr.failOperation(2,new Error(n))}componentConfigurationUpdated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.componentConfigurationUpdated(e,t)),this._kernelInstance.requestDeltaPlanComponentConstruction(e)}setActiveGroupInView(e){this._kernelInstance.setActiveGroupInView(e)}setActiveGroupInViewForPlanObject(e,t){this._kernelInstance.setActiveGroupInViewForPlanObject(e,t||this._configuratorContext.planObjectId)}componentParameters(){}requestComponentDimensions(){}planObjectCreated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.planObjectCreated(e,t))}planObjectUpdated(e,t){const n=this._kernelInstance.getPlanObject(e);this._onBoundsUpdate(n),this._configuratorKernelCallbackListener.forEach(e=>e.planObjectUpdated(n,t))}planObjectConfigurationUpdated(e,t,n,s,i,a){this.updatePlanObjectDependencies(e);let r=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e));this._configuratorKernelCallbackListener.forEach(s=>s.planObjectConfigurationUpdated(e,t,n,a));const o=this._kernelInstance.getPlanObject(e);return this._onBoundsUpdate(o),a||this._configuratorHistory.push(t),this._updateConfigurationHasChildren(e,r),this.requestPartListAndUpdatePricesOfParts(n)}_onBoundsUpdate(e){if(!e.boxForMeasurement)return;const t={width:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.x),height:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.z),depth:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.y),kernelBounds:e.boxForMeasurement};this._configuratorUiCallbacks.onBoundsUpdate(t)}planObjectDeleted(){}requestPlanObjectDimensions(){}async requestExternalMesh(e,t){let n=()=>{};const s=new Promise((e,t)=>{n=e});let i;this.externalMeshQueue.push(s),this._configuratorUiCallbacks.onRequestExternalMesh(e,t);try{i=await this._rapiAccess.getMesh(e,"crt",t)}catch(n){return this._handleInvalidMesh(e,t),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" can not be loaded. "${n}"`)),void console.error(n)}try{const s=await fetch(new Request(this._dataSyncer.requestAsset(i.url,!0))),a=await s.arrayBuffer();this._handleCortoMesh(a,e,t),n()}catch(n){return this._handleInvalidMesh(e,t),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" breaks. "${n}"`)),void console.error(n)}}Editor3dComponentCreated(e,t,n,s,i){this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentCreated(e,t,n,s,i)),!s&&parent&&i>0&&this._configuratorKernelCallbackListener.forEach(a=>a.Editor3dComponentDocked(e,s,i,t,n))}Editor3dPlanObjectConstructionDone(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dPlanObjectConstructionDone(e)),this.updatePlanObjectDependencies(e),this._updateConfigurationHasChildren(e),this._initData.moc||this._calcPrice()}Editor3dBeginGroup(){}Editor3dEndGroup(){}Editor3dSetMaterial(){}Editor3dLoadMaterial(){}Editor3dAddDockPreview(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dAddDockPreview(e,t))}Editor3dSetPreviewPointAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewPointAssociations(e,t))}Editor3dSetPreviewLineAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewLineAssociations(e,t))}Editor3dPreviewConstructionDone(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dPreviewConstructionDone(e,t))}Editor3dTranslateBy(){}Editor3dRotateBy(){}Editor3dRotateAround(){}Editor3dAddCube(){}Editor3dAddCubeUVMod(){}Editor3dAddSphere(){}Editor3dAddSphereUVMod(){}Editor3dAddRectangle(){}Editor3dAddRectangleUVMod(){}Editor3dAddMesh(){}Editor3dAddMeshUVMod(){}Editor3dAddMeshUVCoord(){}Editor3dAddCylinder(){}Editor3dAddCylinderUVMod(){}Editor3dAddPrism(){}Editor3dAddPrismUVMod(){}Editor3dAddFittingPoint(){}Editor3dAddFittingLine(){}Editor3dSelectObject(){}Editor3dCopy(){}Editor3dUpdatePlanObjectPosition(){}Editor3dUpdatePlanObjectRotation(){}Editor3dUpdatePlanObjectTransform(){}Editor3dUpdatePlanComponentPosition(){}Editor3dUpdatePlanComponentRotation(){}Editor3dUpdatePlanComponentTransform(){}getRuntimeComponentIdOfRootComponent(e){return this._kernelInstance?this._kernelInstance.getRootPlanComponentIdFromObjectId(e):(console.warn("this._kernelInstance not ready now"),0)}getRuntimeComponentId(e){return this._kernelInstance.getComponentId(e)}getParameterGroups(){if(!this._configuratorContext.planObjectId)return[];const e=this._kernelInstance.getRootPlanComponentIdFromObjectId(this._configuratorContext.planObjectId);return this._kernelInstance.getComponent(e).parameterGroups}resume(){this.muteKernelCallbacks||super.resume()}getSerializedConfiguration(e){return this._kernelInstance.getSerializedConfiguration(e)}createNewSerializedConfiguration(e){return this._kernelInstance.createNewSerializedConfiguration(e)}getCurrentConfigurationHash(e){return this._kernelInstance.getHashOfConfiguration(e)}listOfVariantsError(e,t){this._kernelIo.setMeta({rapiId:e}),this._kernelIo.error(t)}}on([hn],vo.prototype,"_memoryManager",void 0),on([hn],vo.prototype,"_configuratorKernelAccessCallback",void 0),on([hn],vo.prototype,"_initData",void 0),on([hn],vo.prototype,"_configuratorHistory",void 0);class wo extends A{constructor(e,t=.05){super(),this.name=e,this._sphereSize=t,this._innerRingRadius=this._sphereSize,this._outerRingRadius=this._innerRingRadius+.02,this._initNodeMesh()}_initNodeMesh(){const e=new pt(this._sphereSize,32),t=new y({color:16777215});this._sphere=new z(e,t);const n=new mt(this._innerRingRadius,this._outerRingRadius,32),s=new y({color:0,side:F});this._innerRingMesh=new z(n,s),this._innerRingMesh.rotation.set(Math.PI/2,0,0);const i=new mt(this._outerRingRadius,this._outerRingRadius+.01,32),a=new y({color:16777215,side:F});this._outerRingMesh=new z(i,a),this._outerRingMesh.rotation.set(Math.PI/2,0,0),this.add(this._sphere),this.add(this._innerRingMesh),this.add(this._outerRingMesh)}getSize(){return(new ge).setFromObject(this).getSize(new r)}hoverOn(){this._sphere.geometry=new pt(this._sphereSize+.02,32),this._innerRingMesh.geometry=new mt(this._innerRingRadius+.02,this._outerRingRadius+.02,32),this._outerRingMesh.geometry=new mt(this._outerRingRadius+.02,this._outerRingRadius+.01+.02,32)}hoverOff(){this._sphere.geometry=new pt(this._sphereSize,32),this._innerRingMesh.geometry=new mt(this._innerRingRadius,this._outerRingRadius,32),this._outerRingMesh.geometry=new mt(this._outerRingRadius,this._outerRingRadius+.01,32)}select(e){this._innerRingMesh.material=new y({color:e,side:F})}deselect(e){this._innerRingMesh.material=new y({color:e,side:F})}}class bo extends _r{constructor(e){super(e);const t=this.getPlanElement().getMaxWallHeight();this._container.position.y=(t<0?2800:t)/1e3+.01,this._container.name="Node Plan Element",this._nodeUiMesh=new wo("Wall draggable node"),this.addMesh(this._nodeUiMesh)}update(){super.update(),this._container.position.y=this.getPlanElement().getMaxWallHeight()/1e3+.01}setTopView(e){super.setTopView(e),e||(this._nodeUiMesh.visible=!1)}getSize(){return this._topView?this._nodeUiMesh.getSize():new r}show(){this._nodeUiMesh.visible=this._topView}hide(){this._nodeUiMesh.visible=!1}select(){this._nodeUiMesh.select(10526880),super.select()}deselect(){this._nodeUiMesh.select(0),super.deselect()}hoverOn(){this._nodeUiMesh.hoverOn(),super.hoverOn()}hoverOff(){this._nodeUiMesh.hoverOff(),super.hoverOff()}_generateBoundingBox(){const e=super._generateBoundingBox();return e.layers.set(9),e}addMesh(e){super.addMesh(e)}}e("N",bo);const yo=Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:0}),So=Oi.createMeshStandardMaterial({transparent:!0,opacity:1,color:new h("#B1B1B1"),side:F}),xo=Oi.createMeshStandardMaterial({transparent:!0,opacity:.4,color:new h("#B1B1B1"),side:F}),Po=new B({color:new h("#7B7B7B")});class Mo extends A{constructor(e,t){super(),this._planElement=e,this._rapiItem=t,this._init()}_init(){var e,t;const n=this._planElement,{x:s,z:i}=ys(n.size),a=new $e(s,.01,i);this._topGreyMesh=new z(a,So),this.add(this._topGreyMesh);const r=new ht(a);this._topGreyMeshOutline=new V(r,Po),this._topGreyMesh.add(this._topGreyMeshOutline);const o="door"===n.getObjectType()&&(!this._rapiItem||"door"===(null===(e=this._rapiItem)||void 0===e?void 0:e.detailType)),l="door"===n.getObjectType()&&(!this._rapiItem||"door_double"===(null===(t=this._rapiItem)||void 0===t?void 0:t.detailType));if("window"===n.getObjectType()){const e=new $e(s,.02,.03);this._topBlackMesh=new z(e,yo),this.add(this._topBlackMesh)}else if(o){const e=new gt(s,16,0,Math.PI/2);this._topDoorMesh1=new z(e,xo),this._topGreyMesh.add(this._topDoorMesh1);const t=new ht(this._topDoorMesh1.geometry);this._topDoorOutline1=new V(t,Po),this._topDoorMesh1.add(this._topDoorOutline1),this._updateDoor()}else if(l){const e=new gt(s/2,16,0,Math.PI/2);this._topDoorMesh1=new z(e,xo),this._topGreyMesh.add(this._topDoorMesh1);const t=new ht(this._topDoorMesh1.geometry);this._topDoorOutline1=new V(t,Po),this._topDoorMesh1.add(this._topDoorOutline1);const n=new gt(s/2,16,0,Math.PI/2);this._topDoorMesh2=new z(n,xo),this._topGreyMesh.add(this._topDoorMesh2);const i=new ht(this._topDoorMesh2.geometry);this._topDoorOutline2=new V(i,Po),this._topDoorMesh2.add(this._topDoorOutline2),this._updateDoubleDoor()}this.position.y=Co}setTopView(e){e?this._enableTopView():this._disableTopView()}_enableTopView(){this.visible=!0}_disableTopView(){this.visible=!1}_updateDoor(){this._resetTopDoorMesh(this._topDoorMesh1);const e=this._planElement,{flipY:t,flipX:n}=e,{x:s}=ys(e.size);this._topDoorMesh1.geometry=new gt(s,16,0,Math.PI/2),this._topDoorMesh1.rotateX(Math.PI/2*(t?1:-1)),this._topDoorMesh1.position.x=s/2*(n?1:-1),this._topDoorMesh1.scale.x=n?-1:1,this._topDoorOutline1.geometry=new ht(this._topDoorMesh1.geometry)}_updateDoubleDoor(){this._resetTopDoorMesh(this._topDoorMesh1),this._resetTopDoorMesh(this._topDoorMesh2);const e=this._planElement,{flipY:t}=e,{x:n}=ys(e.size),s=Math.PI/2*(t?1:-1);this._topDoorMesh1.geometry=new gt(n/2,16,0,Math.PI/2),this._topDoorMesh1.rotateX(s),this._topDoorMesh1.position.x=-n/2,this._topDoorOutline1.geometry=new ht(this._topDoorMesh1.geometry),this._topDoorMesh2.geometry=new gt(n/2,16,0,Math.PI/2),this._topDoorMesh2.rotateX(s),this._topDoorMesh2.position.x=n/2,this._topDoorMesh2.scale.x=-1,this._topDoorOutline2.geometry=new ht(this._topDoorMesh2.geometry)}_resetTopDoorMesh(e){e.position.y=-.01,e.position.x=0,e.rotation.x=0}update(){if(!this._topGreyMesh||!this._topGreyMeshOutline)return;const{x:e,z:t}=ys(this._planElement.size);this._topGreyMesh.geometry=new $e(e,.01,t),this._topGreyMeshOutline.geometry=new ht(this._topGreyMesh.geometry),this._topBlackMesh&&(this._topBlackMesh.geometry=new $e(e,.02,.03)),this._topDoorMesh1&&!this._topDoorMesh2&&this._updateDoor(),this._topDoorMesh1&&this._topDoorMesh2&&this._updateDoubleDoor()}}const Co=5;class To extends xr{constructor(e){super(e),this._container.name="Construction "+this._container.name}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new Mo(this.getPlanElement(),this.getRapiItem()),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getPlanElement(){return super.getPlanElement()}_generateBoundingBox(){const e=super._generateBoundingBox(),t=this.getSize();return e.geometry=new $e(t.x,this._topView?Co:t.y,t.z),e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new $e(e.x,this._topView?Co:e.y,e.z)}getTopViewContainer(){return this._constructionTopView}getConstructionElementMeasurements(e,t,n){return mr(this,e,t,n)}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update()}}e("e",To),e("aq",e=>({...lr(e),id:e.id,lengthFormatted:e.lengthFormatted}));const Ao=e("ab",{POINT1:"point1",POINT2:"point2"});class Ro extends _r{constructor(e){super(e),this._initializeContainer(),this._initializeLines(),this._initializeDraggables()}_initializeContainer(){this._container.name="Measurement Line Plan Element",this._container.position.copy(new r(0,Co,0))}_initializeLines(){this._lineMesh=this._createLine(0),this._subLine1=this._createLine(0),this._subLine2=this._createLine(0)}_createDraggableNodeBoundBox(e){const t=(new ge).setFromObject(e).getSize(new r),n=new $e(t.x+.2,t.y,t.z+.2);let s=new h("#DDDDDD");const i=this.getPlanElement().customColor;i>0&&(s=Ji(i));let a=Oi.createMeshStandardMaterial({color:s,opacity:1,transparent:!0});a.visible=!1;let o=new z(n,a);return o.name="bounding box for draggable node",o.position.copy(e.position),o.castShadow=!1,o.receiveShadow=!1,o.layers.set(6),o}_initializeDraggables(){this._point1Draggable=new wo("point1 draggable"),this._point1Draggable.layers.set(6),this._point2Draggable=new wo("point2 draggable");const[e,t]=this._getMainLinePoints();this._point1Draggable.position.copy(e),this._point2Draggable.position.copy(t),this._point1BoundingBox=this._createDraggableNodeBoundBox(this._point1Draggable),this._point2BoundingBox=this._createDraggableNodeBoundBox(this._point2Draggable),this._point2Draggable.layers.set(6),this.addMesh(this._point1Draggable),this.addMesh(this._point2Draggable),this.addMesh(this._point1BoundingBox),this.addMesh(this._point2BoundingBox)}_createLine(e){const t=new B({color:e,linewidth:1}),n=new c,s=new H(n,t);return s.layers.set(6),s.frustumCulled=!1,this.addMesh(s),s}getMeasurementLineDimension(){const[e,t]=this._getMainLinePoints(),n=e.clone().sub(t),{textDirection:s,textRotation:i}=cr(n),a=e.clone().add(t).divideScalar(2);return{id:this.getPlanElement().getId(),length:e.clone().multiplyScalar(1e3).distanceTo(t.clone().multiplyScalar(1e3)),textPosition3d:a,textRotation:i,fromPosition3d:e,toPosition3d:t,textDirection:s}}show(){this._container.visible=!0}hide(){this._container.visible=!1}hideAllSubLines(){this._subLine1.material.visible=!1,this._subLine2.material.visible=!1}showAllSubLines(){this._subLine1.material.visible=!0,this._subLine2.material.visible=!0}hideDraggableNodes(){this._point1Draggable.visible=!1,this._point2Draggable.visible=!1,this.showAllSubLines()}showDraggableNodes(){this._point1Draggable.visible=!0,this._point2Draggable.visible=!0,this.hideAllSubLines()}showPoint1DraggableNode(){this._point1Draggable.visible=!0,this._subLine2.material.visible=!0}showPoint2DraggableNode(){this._point2Draggable.visible=!0,this._subLine1.material.visible=!0}hidePoint1DraggableNode(){this._point1Draggable.visible=!1,this._subLine2.material.visible=!1}hidePoint2DraggableNode(){this._point2Draggable.visible=!1,this._subLine1.material.visible=!1}setTopView(e){super.setTopView(e),e?(this.show(),this.update()):this.hide()}update(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t);this._updateSubLineGeometry(this._subLine1,e,n),this._updateSubLineGeometry(this._subLine2,t,n),this.updatePointDraggableGeometry(this._point1Draggable,e),this.updatePointDraggableGeometry(this._point2Draggable,t),this._lineMesh.geometry.setFromPoints([e,t]),this._lineMesh.name="main measurement line",this._boundingBox.geometry=this._getGeometry(),this._point1BoundingBox.position.copy(e),this._point2BoundingBox.position.copy(t),this._point1BoundingBox.material.visible=!1,this._point2BoundingBox.material.visible=!1,this._point1BoundingBox.position.y=3.1,this._point2BoundingBox.position.y=3.1}_generateBoundingBox(){let e=new h("#DDDDDD");const t=this.getPlanElement().customColor;t>0&&(e=Ji(t));let n=Oi.createMeshStandardMaterial({color:e,opacity:1,transparent:!0,side:F}),s=new z(this._getGeometry(),n);return s.name="bounding box",s.position.y=3,s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),s}_getGeometry(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t),s=e.clone().add(n.clone().multiplyScalar(.1)),i=e.clone().add(n.clone().multiplyScalar(-.1)),a=t.clone().add(n.clone().multiplyScalar(.1)),r=t.clone().add(n.clone().multiplyScalar(-.1)),o=new c,l=[s,a,r,i].reduce((e,t)=>[...e,t.x,t.y,t.z],[]);return o.setAttribute("position",new ke(l,3)),o.setIndex([0,1,2,2,3,0]),o.computeVertexNormals(),o}_getMainLinePoints(){const e=this.getPlanElement();return[bs(e.getPoint1()),bs(e.getPoint2())]}_calculateNormalVector(e,t){return e.clone().sub(t).cross(new r(0,1,0)).normalize()}_updateSubLineGeometry(e,t,n){const s=t.clone().add(n.clone().multiplyScalar(.1)),i=t.clone().add(n.clone().multiplyScalar(-.1));e.geometry.setFromPoints([i,s])}updatePointDraggableGeometry(e,t){e.position.copy(t)}getPoint1Draggable(){return this._point1Draggable}getPoint2Draggable(){return this._point2Draggable}getPoint1DraggableBoundingBox(){return this._point1BoundingBox}getPoint2DraggableBoundingBox(){return this._point2BoundingBox}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material.visible=!1)}selectPoint1Draggable(){this._point1Draggable.select(10526880),super.select()}selectPoint2Draggable(){this._point2Draggable.select(10526880),super.select()}deselectPoint1Draggable(){this._point1Draggable.select(0),super.deselect()}deselectPoint2Draggable(){this._point2Draggable.select(0),super.deselect()}selectAllDraggablePoints(){this._point1Draggable.select(10526880),this._point2Draggable.select(10526880),super.select()}deselectAllDraggablePoints(){this._point1Draggable.select(0),this._point2Draggable.select(0),super.deselect()}hoverOnDragPoint1(){this._point1Draggable.hoverOn(),super.hoverOn()}hoverOnDragPoint2(){this._point2Draggable.hoverOn(),super.hoverOn()}hoverOffDragPoint1(){this._point1Draggable.hoverOff(),super.hoverOff()}hoverOffDragPoint2(){this._point2Draggable.hoverOff(),super.hoverOff()}selectPointOnDragStart(e){this.showAllSubLines(),e.deselectAllDraggablePoints(),e.currentPoint===Ao.POINT1?e.selectPoint1Draggable():e.currentPoint===Ao.POINT2&&e.selectPoint2Draggable()}hideDraggablePointsOnDragStart(e,t){e.deselectAllDraggablePoints(),t===Ao.POINT1?(e.hidePoint1DraggableNode(),e.selectPoint1Draggable()):t===Ao.POINT2&&(e.hidePoint2DraggableNode(),e.selectPoint2Draggable())}showDraggablePointsOnDragEnd(e,t){t===Ao.POINT1?e.showPoint1DraggableNode():t===Ao.POINT2&&e.showPoint2DraggableNode(),this.hideAllSubLines()}handleDraggablePointsSelection(e){e.deselectAllDraggablePoints(),e.currentPoint&&e.currentPoint===Ao.POINT1?e.selectPoint1Draggable():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.selectPoint2Draggable()}showDraggablePointsOnHoverOn(e){e.currentPoint&&e.currentPoint===Ao.POINT1?e.hoverOnDragPoint1():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.hoverOnDragPoint2()}showDraggablePointsOnHoverOff(e){e.currentPoint&&e.currentPoint===Ao.POINT1?e.hoverOffDragPoint1():e.currentPoint&&e.currentPoint===Ao.POINT2&&e.hoverOffDragPoint2()}}e("M",Ro);class Eo extends wr{constructor(e){super(e),this._container.name="Configurable "+this._container.name}getConstructionElementMeasurements(e,t,n){return mr(this,e,t,n)}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new $e(e.x,this._topView?Co:e.y,e.z)}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new Mo(this.getPlanElement()),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getTopViewContainer(){return this._constructionTopView}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update(),this._container.position.copy(bs(this._topView?this.getPlanElement().getCenter():this.getPlanElement().getMeshCenter()))}getPlanElement(){return super.getPlanElement()}}e("c",Eo);class Io extends vo{get kernelContainer(){return this._kernelContainer}constructor(e){super(e),this._plannerKernelCallbackListener=new Set}_loadSuccess(){super._loadSuccess(),window.RoomleCore&&window.RoomleCore(this._kernelContainer)}_loadError(){super._loadError(),console.error("kernel load error")}_createPlanInteractionHandler(){var e,t,n,s,i,a,r;this._planInteractionHandler=new this._kernelContainer.PlanInteractionHandler;const o=null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.advancedDocking,l=null!==(i=null===(s=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===s?void 0:s.advancedDocking)&&void 0!==i&&i;this._planInteractionHandler.init(this._planInteractionHandler,1,50,o?this._kernelContainer.SnapMode.ON_COLLISION:this._kernelContainer.SnapMode.WITHIN_SNAP_DISTANCE,o?this._kernelContainer.SnapMode.ON_COLLISION:this._kernelContainer.SnapMode.WITHIN_SNAP_DISTANCE,this._initData.snappingEnabled,this._kernelContainer.DrawingType.CLICK_PER_CLICK),this._planInteractionHandler.dockWhenSnap=l,this._planInteractionHandler.unDockOnMove=l,this._planInteractionHandler.enableRaster=!0,this._planInteractionHandler.unit=this._initData.unit||"cm",this._planInteractionHandler.createChildrenEntities={value:(null===(r=null===(a=this._initData)||void 0===a?void 0:a.featureFlags)||void 0===r?void 0:r.advancedDocking)?1:0},this._roomlePlannerUiCallback.onPlanInteractionHandlerCreated(this._planInteractionHandler)}addPlannerListener(e){this._plannerKernelCallbackListener.add(e)}removePlannerListener(e){this._plannerKernelCallbackListener.delete(e)}isReady(){super.isReady(),this.registerCallbacks(),this._roomlePlannerUiCallback.onPlannerKernelIsReady(this._kernelContainer),this._roomlePlannerUiCallback.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Sr.isProduction||(window.__RML__DEBUG__.ConfiguratorKernel=this._kernelInstance,window.__RML__DEBUG__.PlannerKernelContainer=this._kernelContainer),this._kernelAccessCallback.isReady()}_setupKernel(){0===this._kernelType&&(this._createPlanInteractionHandler(),Ir.kernelInstance?this._kernelInstance=Ir.kernelInstance:this._kernelInstance=this._planInteractionHandler.getConfiguratorKernel()),super._setupKernel()}get callbacks(){return this._roomlePlannerUiCallback}get planInteractionHandler(){return this._planInteractionHandler}get planModelViewHelper(){return this._kernelContainer.PlanModelViewHelper}catalogItemLoaded(e){const t=this._rapiItemToKernelItem(e);this._kernelContainer.catalogItemLoaded(t)}async insertItems(e){this.planInteractionHandler.startInteraction();let t=new this._kernelContainer.CatalogItemPtrList;e.forEach(e=>{let n=e.count||1;for(let s=0;s<n;s++)e.count||(e.count=0),t.push_back(this._rapiItemToKernelItem(e))});const n=this.planInteractionHandler.getPlan().extRef.jsObject,s=n.getPlanObjectViewModelsFromRapiId().reduce((e,t)=>(e[t.getId()]=!0,e),{});this.planInteractionHandler.addPlanObjects(t,!0),await Promise.allSettled([Promise.allSettled(n.getStaticPlanObjectViewModels().map(async e=>{if(e.needsRapiItem()){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}})),Promise.allSettled([...n.getConfigurablePlanObjectViewModels().map(e=>e.isInitDone()),...n.getConfigurableConstructionPlanObjectViewModels().map(e=>e.isInitDone())])]);const i=n.getPlanObjectViewModelsFromRapiId().map(e=>e.getId()).filter(e=>!s[e]);return this.planInteractionHandler.endInteraction(),i}duplicateItems(e){const t=new this.kernelContainer.PlanObjectPtrList;return e.forEach(e=>{t.push_back(e)}),this.planInteractionHandler.duplicatePlanObjects(t,1,!0)}_rapiItemToKernelItem(e){let t=new this._kernelContainer.CatalogItem(e.id),n=t.size;return n.x=e.width||0,n.y=e.depth||0,n.z=e.height||0,t.size=n,t.flipable=e.flipable,e.layer&&(t.layer=e.layer),t.orderable=e.orderable,t.scaleable=e.scaleable,t.type=e.type||"other",t.detailType=e.detailType||t.type||"other",t.configuration=e.configuration||"",t}planObjectDeleted(){}requestPlanObjectDimensions(){}cleanUpCallbacks(){var e;super.cleanUpCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.unregisterPlannerCallback)&&this._kernelContainer.unregisterPlannerCallback(this)}registerCallbacks(){var e;super.registerCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.registerPlannerCallback)&&this._kernelContainer.registerPlannerCallback(this)}planElementRemoved(e){this._plannerKernelCallbackListener.forEach(t=>t.planElementRemoved(e)),this._plannerKernelCallbackListener.forEach(t=>t.removePlanObjectFromScene(e.extRef.jsObject)),this._decoupleReferences(e)}handlerSwitchedPlans(e,t){this._decoupleReferences(e),t&&this._plannerKernelCallbackListener.forEach(n=>n.handlerSwitchedPlans(e,t))}planBoundsChanged(){this._plannerKernelCallbackListener.forEach(e=>e.planBoundsChanged())}planCleared(){this._plannerKernelCallbackListener.forEach(e=>e.planCleared())}planCompletelyLoaded(e){this._plannerKernelCallbackListener.forEach(t=>t.planCompletelyLoaded(e))}planElement3dMeshChanged(e,t){if(t.extRef){const e=t.extRef.jsObject;for(let t=e.getObject().children.length-1;t>=0;t--)e.getObject().remove(e.getObject().children[t])}this.planModelViewHelper.requestMesh3d(t)}async _onStaticItemAdded(e,t){let n;n=this.isConstructionPlanElement(t)?new To(t):new xr(t),this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n);const s=t.getCatalogItemId();if(s){const e=await this._rapiAccess.getItem(s);n.setRapiItem(e),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}}_onConfigurableItemAdded(e,t){const n=new wr(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}_onConfigurableConstructionItemAdded(e,t){const n=new Eo(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}async planElementAdded(e,t){if(e&&e.extRef)if(t.getType()===this._kernelContainer.PlanElementType.OBJECT){const n=t.getConfigurationRuntimeId();t.hasConfiguration()||n>0?"door"===t.getObjectType()||"window"===t.getObjectType()?this._onConfigurableConstructionItemAdded(e,t):this._onConfigurableItemAdded(e,t):await this._onStaticItemAdded(e,t)}else{const n=t;let s;if(t.getType()===this._kernelContainer.PlanElementType.WALL?s=new Cr(n):t.getType()===this._kernelContainer.PlanElementType.FLOOR?s=new Tr(n):t.getType()===this._kernelContainer.PlanElementType.CEILING?s=new Ar(n):t.getType()===this._kernelContainer.PlanElementType.NODE?s=new bo(n):t.getType()===this._kernelContainer.PlanElementType.MEASURE&&(s=new Ro(n)),!s)return;this.coupleReferences(s,n),e.extRef.jsObject.addPlanElementViewModel(s),this.planModelViewHelper.requestMesh3d(t),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(null))}}planElementChanged(e,t){if(t.extRef){let n=t.extRef.jsObject;n.update(),this._plannerKernelCallbackListener.forEach(t=>t.planElementChanged(e,n))}}planHistoryStateChanged(){this.planInteractionHandler&&(this._plannerKernelCallbackListener.forEach(e=>e.planHistoryStateChanged()),this._roomlePlannerUiCallback.onHistoryChange(this.planInteractionHandler.isUndoPossible(),this.planInteractionHandler.isRedoPossible()))}planObjectConfigurationCreated(e,t){}planObjectConfigurationLoaded(e,t,n){e&&e.extRef&&t&&t.extRef&&t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId()>0&&this._plannerKernelCallbackListener.forEach(s=>s.planObjectConfigurationLoaded(e,t,n))}requestCatalogItem(e){}startedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.startedDrawing())}stoppedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.stoppedDrawing())}updateMesh2d(){}beginConstruction(){}addMesh(e,t,n,s,i,a){this._plannerKernelCallbackListener.forEach(r=>r.addMesh(e,t,n,s,i,a))}endConstruction(){}beginPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.beginPlanConstruction(e))}addPlanMesh(e,t,n,s,i,a,r){this._plannerKernelCallbackListener.forEach(o=>o.addPlanMesh(e,t,n,s,i,a,r))}endPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.endPlanConstruction(e))}async addPlanObjectFromItem(e,t,n){if(!t&&!n){const t=await this.insertItems([e]);if(1!==t.length)throw new Error("It was expected that 1 element is added but"+t.length+"were added");return t[0]}n=n||0===n?n:0,t=t||{x:0,y:0,z:0};const s=this._planInteractionHandler.addPlanObjectFromItem(this._rapiItemToKernelItem(e),t,n,!1),i=this._planInteractionHandler.getPlan().extRef.jsObject;let a;return s.hasConfiguration()?(a=i.getConfigurablePlanObjectForId(s.getId()),a||console.warn("Could not find configuration")):(a=i.getStaticPlanObjectViewModelForId(s.getId()),a?await a.setRapiItem(e):console.warn("Could not find static item")),await a.isInitDone(),a.getId()}coupleReferences(e,t){let n=new this._kernelContainer.EMSReference;n.jsObject=e,t.extRef=n}_decoupleReferences(e){e&&e.extRef&&(e.extRef.jsObject.clearReference(),e.extRef.jsObject=null,e.extRef.delete(),e.extRef=null)}isConstructionPlanElement(e){return e instanceof this.kernelContainer.ConstructionObject}}e("P",Io),on([hn],Io.prototype,"_kernelAccessCallback",void 0),on([hn],Io.prototype,"_roomlePlannerUiCallback",void 0);class Do extends Ka{constructor(e){super(e),this._wallMeshes=[],this._defaultMaterial=Oi.createMeshPhysicalMaterial({color:"#ffffff",side:F})}generateGeometry(e=null,t,n,s,i,a=!1){let r;return r=a?this._generateGeometry(e,t,n,s,i).clone():this._generateGeometry(e,t,n,s,i),r}generateMesh(e=0,t=null,n,s,i,a,r,o,l=!1,h){let d;d=l?this._generateGeometry(t,s,i,a,r).clone():this._generateGeometry(t,s,i,a,r);const c=this._createMesh(e,t,d);return c.userData.materialId=n,c.layers.set(4),c.userData.isPlanFloor=o&&3===o.value,c.userData.isPlanWall=o&&1===o.value,n&&this.setMaterial(c,n,o,h).then(()=>{e&&t&&n&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n),c.castShadow=!c.userData.isPlanFloor&&!c.userData.isPlanWall}),this._checkWallMaterial(c,o),c}async setMaterial(e,t,n,s){if(e.userData.materialId=ra(t,n),ft(t))t?await this._assignMaterial(e,t,s):(console.warn("Used default material because material is empty"),this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)));else{if(!t)return void this.changeMaterialOfMesh(e,this._configuratorPreviewMaterial);2===(t=t).getSourceType().value?await this._assignMaterial(e,t.materialId,s):1===t.getSourceType().value?await this._assignItem(e,t.catalogItemId):3===t.getSourceType().value?await this._assignRGB(e,t.rgbValue):0===t.getSourceType().value?this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)):(this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)),1!==n.value&&7!==n.value&&3!==n.value&&console.warn("Used default material because material is not supported",t))}}_getDefaultMaterial(e){return 3===(null==e?void 0:e.value)?this._defaultMaterialFloor:this._defaultMaterial}set maxAnisotropy(e){this._maxAnisotropy=e}_checkWallMaterial(e,t){t&&1===t.value&&(e.renderOrder=5,this._wallMeshes.push(e))}clear(){super.clear(),this.clearWallMeshes()}clearWallMeshes(){this._wallMeshes.forEach(e=>{na(e)}),this._wallMeshes=[]}get wallMeshes(){return this._wallMeshes}}e("ax",Do);let Oo={InchFeet:null,Feet:null,MM:null,CM:null,Inch:null},ko={NoUnitString:null,LongUnitString:null,ShortUnitString:null};const Lo=["mm","cm","feet"],Uo=["inch","inchfeet"];class Bo{constructor(e){this._formatter=null,this._precision=0,this._creator_=e}init(e){const t=new e.UnitMeasureFormatter;Oo=e.Unit,ko=e.UnitStringType,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType();const{precisionCm:n,precisionInch:s}=this._initData;this._actualUnit===Oo.InchFeet?this._precision=void 0!==s?parseInt(s,10):2:this._actualUnit===Oo.CM&&(this._precision=void 0!==n?parseInt(n,10):1),t.init("mm","cm","'","ft",'"',"inch","m²","sqft",!0,this._precision,!0),this._formatter=t}_initMeasurementSystemType(){let{measurementSystem:e,unit:t}=this._initData;if(this._actualMeasurementString=e,e||!t){if("metric"===e){t||(t="cm");const e=Lo.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not a metric unit, using CM"),this._actualUnit=Oo.CM,this._actualUnitString="cm")}if("imperial"===e){t||(t="inch");const e=Uo.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not an imperial unit, using Inches"),this._actualUnit=Oo.Inch,this._actualUnitString="inch")}}else{this._actualUnitString=t;const e=Lo.find(e=>e===t);this._actualMeasurementString=e?"metric":"imperial"}}_initActualUnit(){const{unit:e}=this._initData;this._actualUnit=this._getKernelUnitEnum(e)}_getKernelUnitEnum(e){switch(e){case"cm":return Oo.CM;case"mm":return Oo.MM;case"inchfeet":return Oo.InchFeet;case"feet":return Oo.Feet;case"inch":return Oo.Inch;default:return Oo.CM}}_initActualUnitStringType(){const{unitStringType:e}=this._initData;e&&"short"!==e&&console.warn("Only short unit strings is supported at the moment"),this._actualUnitStringType=ko.ShortUnitString}_isFormatterReady(){return!!this._formatter||(console.warn("Formatter is not ready..."),!1)}formatAngleValueToUnitString(e,t){const n="Integer"===t.type?0:2;return e.toFixed(n)+"°"}parseAngleValueFromUnitString(e){return e.replace("°","").replace(/\s/g,"")}parseValue(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?e:"length"===t.unitType?this.parseMMValueFromUnitString(e,t.unitType):"angle"===t.unitType||"area"===t.unitType?this.parseAngleValueFromUnitString(e):e}formatValueToUnitString(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?"Integer"===t.type?e.toString():parseFloat(e.toString()).toFixed(2):"length"===t.unitType?this.formatMMValueToUnitString(e,t.unitType):"angle"===t.unitType?this.formatAngleValueToUnitString(e,t):"area"===t.unitType?this.formatSquareMMValueToUnitString(e):e}isParseableNumber(e){return this._isFormatterReady()?this._formatter.isParseableNumber(e):null}isParseableUnitString(e,t){return this._isFormatterReady()?"angle"===t.unitType?this._formatter.isParseableUnitString(this.parseAngleValueFromUnitString(e),this._actualUnit):this._formatter.isParseableUnitString(e,this._actualUnit):null}parseMMValueFromUnitString(e,t){return this._isFormatterReady()?"count"===t?parseFloat(e):this._formatter.parseMMValueFromUnitString(e,this._actualUnit):null}parseNumber(e){return this._isFormatterReady()?this._formatter.parseNumber(e):null}formatNumber(e,t=0){return this._isFormatterReady()?this._formatter.formatNumber(e,t):null}formatSquareMMValueToUnitString(e){return this._isFormatterReady()?this._formatter.formatSquareMMValueToUnitString(e,this._actualUnit):null}formatMMValueToUnitString(e,t){return this._isFormatterReady()?"count"===t?e.toString():this._formatter.formatMMValueToUnitString(e,this._actualUnit,this._actualUnitStringType):null}formatMMValueWithReqMaxLength(e,t){return this._isFormatterReady()?this._formatter.formatMMValueWithReqMaxLength(e,this._actualUnit,t):null}_formatParameterValue(e,t){return"length"===t?this.formatMMValueToUnitString(parseFloat(e)):"area"===t?this.formatSquareMMValueToUnitString(parseFloat(e)):e}formatPartListParameter(e){(function(e){return"length"===e.unitType||"area"===e.unitType})(e)&&(e.valueLabel=this._formatParameterValue(e.value,e.unitType))}formatParameter(e){if(e.valueLabel=this._formatParameterValue(e.value,e.unitType),Br(e))e.uiType="Material";else if(function(e){return"Boolean"===e.type}(e))e.uiType="Boolean";else if(Lr(e)){e.uiType="Range";const t=null!==e.validRange.valueFrom?e.validRange.valueFrom:Number.MIN_SAFE_INTEGER,n=null!==e.validRange.valueTo?e.validRange.valueTo:Number.MAX_SAFE_INTEGER;e.validRangeLabels={valueFrom:this._formatParameterValue(t.toString(),e.unitType),valueTo:this._formatParameterValue(n.toString(),e.unitType),type:e.validRange.type}}else Ur(e)?(e.uiType="Options",function(e){return!!Ur(e)&&Array.isArray(e.validValues)&&e.validValues.length>0&&"string"==typeof e.validValues[0].thumbnail}(e)&&(e.uiType="Thumbnails")):(console.error("Could not detect uiType of param"),e.uiType=null)}isInch(){return this._actualUnit===Oo.InchFeet}getActualUnitString(){return this._actualUnitString}getActualMeasurementString(){return this._actualMeasurementString}getUnitStringType(){return this._initData.unitStringType}getPrecision(){return this._precision}getAllowedDelta(){const e=1/Math.pow(10,this._precision);return this.isInch()?25.4*e:e}setUnitInitData(e,t=""){this._initData.unit=e,this._initData.measurementSystem=t,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType(),this._plannerKernelAccess.kernelInstance.setEnvironmentVariable("unit",this._actualUnitString)}}on([hn],Bo.prototype,"_initData",void 0),on([hn],Bo.prototype,"_plannerKernelAccess",void 0);class No{constructor(e){this._history=[],this._index=0,this._creator_=e}undo(){if(!this.canUndo())return null;this._index++;const[e]=this._history.slice(this._index);return this._index===this._history.length-1?this._configuratorUiCallbacks.onHistoryChange(!1,!0):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}redo(){if(!this.canRedo())return null;this._index--;const[e]=this._history.slice(this._index);return 0===this._index?this._configuratorUiCallbacks.onHistoryChange(!0,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}push(e){const[t]=this._history.slice(this._index);t!==e&&(this._history=this._history.slice(this._index),this._history.unshift(e),this._index=0,1===this._history.length?this._configuratorUiCallbacks.onHistoryChange(!1,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!1))}canUndo(){return this._index!==this._history.length-1}canRedo(){return 0!==this._index}getHistory(){return this._history}clearHistory(){this._history=[],this._index=0,this._configuratorUiCallbacks.onHistoryChange(!1,!1)}}on([hn],No.prototype,"_configuratorUiCallbacks",void 0),e("aj",{ADDED:"added",CHANGED:"changed",REMOVED:"removed"});class Fo{constructor(e){this._kernelCallbacks={isReady:()=>{},throw:e=>console.error("Kernel exception",e),log:e=>{},error:(e,t,n,s)=>{},message:e=>{this._analyzeComponentCallback&&this._analyzeComponentCallback(e)}},this._creator_=e}async init(){if(this._toolsCoreInstance)return Promise.resolve();const e=this,t={locateFile:e=>"RoomleToolsCore.wasm"===e?n()+"static/RoomleToolsCore-61c01f70818028fb.wasm":e,wasmBinaryFile:n()+"static/RoomleToolsCore-61c01f70818028fb.wasm",preRun:[],postRun:[],setStatus:null,print(t){e._kernelIo.log(t)},printErr(t){e._kernelIo.error(t)},quit(t){0!==t&&e._kernelIo.throw(t&&t.toString?t.toString():"Unknown error while C/C++ main executes")}};await this._scriptLoader.fetch("static/RoomleToolsCore-354feeb929ea1598.js",{id:"core-tool"});const s=await window.RoomleToolsCore(t);s.setContext(this._kernelCallbacks),this._toolsCoreInstance=new s.ToolsCore}analyzeComponent(e,t){const n=[];return this._analyzeComponentCallback=e=>{n.push(e)},this._toolsCoreInstance.analyzeComponent(e,t),this._analyzeComponentCallback=null,Promise.resolve(n)}}on([hn],Fo.prototype,"_scriptLoader",void 0),on([hn],Fo.prototype,"_kernelIo",void 0);
2
2
  /*!
3
3
  fflate - fast JavaScript compression/decompression
4
4
  <https://101arrowz.github.io/fflate>
5
5
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
6
6
  version 0.6.9
7
7
  */
8
- var Go=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(Go(""))}catch(e){Go=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var jo=Uint8Array,zo=Uint16Array,Vo=Uint32Array,Ho=new jo([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wo=new jo([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ko=new jo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qo=function(e,t){for(var n=new zo(31),s=0;s<31;++s)n[s]=t+=1<<e[s-1];var i=new Vo(n[30]);for(s=1;s<30;++s)for(var a=n[s];a<n[s+1];++a)i[a]=a-n[s]<<5|s;return[n,i]},Xo=qo(Ho,2),Yo=Xo[0],Qo=Xo[1];Yo[28]=258,Qo[258]=28;for(var Zo=qo(Wo,0)[0],Jo=new zo(32768),$o=0;$o<32768;++$o){var el=(43690&$o)>>>1|(21845&$o)<<1;el=(61680&(el=(52428&el)>>>2|(13107&el)<<2))>>>4|(3855&el)<<4,Jo[$o]=((65280&el)>>>8|(255&el)<<8)>>>1}var tl=function(e,t,n){for(var s=e.length,i=0,a=new zo(t);i<s;++i)++a[e[i]-1];var r,o=new zo(t);for(i=0;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;if(n){r=new zo(1<<t);var l=15-t;for(i=0;i<s;++i)if(e[i])for(var h=i<<4|e[i],d=t-e[i],c=o[e[i]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)r[Jo[c]>>>l]=h}else for(r=new zo(s),i=0;i<s;++i)e[i]&&(r[i]=Jo[o[e[i]-1]++]>>>15-e[i]);return r},nl=new jo(288);for($o=0;$o<144;++$o)nl[$o]=8;for($o=144;$o<256;++$o)nl[$o]=9;for($o=256;$o<280;++$o)nl[$o]=7;for($o=280;$o<288;++$o)nl[$o]=8;var sl=new jo(32);for($o=0;$o<32;++$o)sl[$o]=5;var il=tl(nl,9,1),al=tl(sl,5,1),rl=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ol=function(e,t,n){var s=t/8|0;return(e[s]|e[s+1]<<8)>>(7&t)&n},ll=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},hl=new jo(0);function dl(e,t){return function(e,t,n){var s=e.length;if(!s||n&&!n.l&&s<5)return t||new jo(0);var i=!t||n,a=!n||n.i;n||(n={}),t||(t=new jo(3*s));var r,o=function(e){var n=t.length;if(e>n){var s=new jo(Math.max(2*n,e));s.set(t),t=s}},l=n.f||0,h=n.p||0,d=n.b||0,c=n.l,u=n.d,p=n.m,m=n.n,g=8*s;do{if(!c){n.f=l=ol(e,h,1);var f=ol(e,h+1,3);if(h+=3,!f){var _=e[(A=((r=h)/8|0)+(7&r&&1)+4)-4]|e[A-3]<<8,v=A+_;if(v>s){if(a)throw"unexpected EOF";break}i&&o(d+_),t.set(e.subarray(A,v),d),n.b=d+=_,n.p=h=8*v;continue}if(1==f)c=il,u=al,p=9,m=5;else{if(2!=f)throw"invalid block type";var w=ol(e,h,31)+257,b=ol(e,h+10,15)+4,y=w+ol(e,h+5,31)+1;h+=14;for(var S=new jo(y),x=new jo(19),P=0;P<b;++P)x[Ko[P]]=ol(e,h+3*P,7);h+=3*b;var M=rl(x),C=(1<<M)-1,T=tl(x,M,1);for(P=0;P<y;){var A,R=T[ol(e,h,C)];if(h+=15&R,(A=R>>>4)<16)S[P++]=A;else{var E=0,I=0;for(16==A?(I=3+ol(e,h,3),h+=2,E=S[P-1]):17==A?(I=3+ol(e,h,7),h+=3):18==A&&(I=11+ol(e,h,127),h+=7);I--;)S[P++]=E}}var D=S.subarray(0,w),O=S.subarray(w);p=rl(D),m=rl(O),c=tl(D,p,1),u=tl(O,m,1)}if(h>g){if(a)throw"unexpected EOF";break}}i&&o(d+131072);for(var L=(1<<p)-1,k=(1<<m)-1,U=h;;U=h){var B=(E=c[ll(e,h)&L])>>>4;if((h+=15&E)>g){if(a)throw"unexpected EOF";break}if(!E)throw"invalid length/literal";if(B<256)t[d++]=B;else{if(256==B){U=h,c=null;break}var N=B-254;if(B>264){var F=Ho[P=B-257];N=ol(e,h,(1<<F)-1)+Yo[P],h+=F}var G=u[ll(e,h)&k],j=G>>>4;if(!G)throw"invalid distance";if(h+=15&G,O=Zo[j],j>3&&(F=Wo[j],O+=ll(e,h)&(1<<F)-1,h+=F),h>g){if(a)throw"unexpected EOF";break}i&&o(d+131072);for(var z=d+N;d<z;d+=4)t[d]=t[d-O],t[d+1]=t[d+1-O],t[d+2]=t[d+2-O],t[d+3]=t[d+3-O];d=z}}n.l=c,n.p=U,n.b=d,c&&(l=1,n.m=p,n.d=u,n.n=m)}while(!l);return d==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var s=new(e instanceof zo?zo:e instanceof Vo?Vo:jo)(n-t);return s.set(e.subarray(t,n)),s}(t,0,d)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var cl="undefined"!=typeof TextDecoder&&new TextDecoder;try{cl.decode(hl,{stream:!0})}catch(e){}class ul extends _t{constructor(e){super(e),this.type=vt}parse(e){const t=Math.pow(2.7182818,2.2),n={l:0,c:0,lc:0};function s(e,t,s,i,a){for(;s<e;)t=t<<8|k(i,a),s+=8;s-=e,n.l=t>>s&(1<<e)-1,n.c=t,n.lc=s}const i=new Array(59);function a(e){return 63&e}function r(e){return e>>6}const o={c:0,lc:0};function l(e,t,n,s){e=e<<8|k(n,s),t+=8,o.c=e,o.lc=t}const h={c:0,lc:0};function d(e,t,n,s,i,a,r,d,c){if(e==t){s<8&&(l(n,s,i,a),n=o.c,s=o.lc);let e=n>>(s-=8);if(e=new Uint8Array([e])[0],d.value+e>c)return!1;const t=r[d.value-1];for(;e-- >0;)r[d.value++]=t}else{if(!(d.value<c))return!1;r[d.value++]=e}h.c=n,h.lc=s}function c(e){return 65535&e}function u(e){const t=c(e);return t>32767?t-65536:t}const p={a:0,b:0};function m(e,t){const n=u(e),s=u(t),i=n+(1&s)+(s>>1),a=i,r=i-s;p.a=a,p.b=r}function g(e,t){const n=c(e),s=c(t),i=n-(s>>1)&65535,a=s+i-32768&65535;p.a=a,p.b=i}function f(e,t,n,s,i,a,r){const o=r<16384,l=n>i?i:n;let h,d,c=1;for(;c<=l;)c<<=1;for(c>>=1,h=c,c>>=1;c>=1;){d=0;const r=d+a*(i-h),l=a*c,u=a*h,f=s*c,_=s*h;let v,w,b,y;for(;d<=r;d+=u){let i=d;const a=d+s*(n-h);for(;i<=a;i+=_){const n=i+f,s=i+l,a=s+f;o?(m(e[i+t],e[s+t]),v=p.a,b=p.b,m(e[n+t],e[a+t]),w=p.a,y=p.b,m(v,w),e[i+t]=p.a,e[n+t]=p.b,m(b,y),e[s+t]=p.a,e[a+t]=p.b):(g(e[i+t],e[s+t]),v=p.a,b=p.b,g(e[n+t],e[a+t]),w=p.a,y=p.b,g(v,w),e[i+t]=p.a,e[n+t]=p.b,g(b,y),e[s+t]=p.a,e[a+t]=p.b)}if(n&c){const n=i+l;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}if(i&c){let i=d;const a=d+s*(n-h);for(;i<=a;i+=_){const n=i+f;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}h=c,c>>=1}return d}function _(e,t,c,u,p,m){const g=c.value,f=L(t,c),_=L(t,c);c.value+=4;const v=L(t,c);if(c.value+=4,f<0||f>=65537||_<0||_>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const w=new Array(65537),b=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(b),function(e,t,a,r,o,l){const h=t;let d=0,c=0;for(;r<=o;r++){if(h.value-t.value>a)return!1;s(6,d,c,e,h);const i=n.l;if(d=n.c,c=n.lc,l[r]=i,63==i){if(h.value-t.value>a)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,c,e,h);let i=n.l+6;if(d=n.c,c=n.lc,r+i>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)l[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)l[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)i[e]=0;for(let t=0;t<65537;++t)i[e[t]]+=1;let t=0;for(let e=58;e>0;--e){const n=t+i[e]>>1;i[e]=t,t=n}for(let t=0;t<65537;++t){const n=e[t];n>0&&(e[t]=n|i[n]++<<6)}}(l)}(e,c,u-(c.value-g),f,_,w),v>8*(u-(c.value-g)))throw new Error("Something wrong with hufUncompress");!function(e,t,n,s){for(;t<=n;t++){const n=r(e[t]),i=a(e[t]);if(n>>i)throw new Error("Invalid table entry");if(i>14){const e=s[n>>i-14];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=new Array(1);e.p[e.lit-1]=t}else if(i){let e=0;for(let a=1<<14-i;a>0;a--){const a=s[(n<<14-i)+e];if(a.len||a.p)throw new Error("Invalid table entry");a.len=i,a.lit=t,e++}}}}(w,f,_,b),function(e,t,n,s,i,c,u,p,m){let g=0,f=0;const _=u,v=Math.trunc(s.value+(i+7)/8);for(;s.value<v;)for(l(g,f,n,s),g=o.c,f=o.lc;f>=14;){const i=t[g>>f-14&16383];if(i.len)f-=i.len,d(i.lit,c,g,f,n,s,p,m,_),g=h.c,f=h.lc;else{if(!i.p)throw new Error("hufDecode issues");let t;for(t=0;t<i.lit;t++){const u=a(e[i.p[t]]);for(;f<u&&s.value<v;)l(g,f,n,s),g=o.c,f=o.lc;if(f>=u&&r(e[i.p[t]])==(g>>f-u&(1<<u)-1)){f-=u,d(i.p[t],c,g,f,n,s,p,m,_),g=h.c,f=h.lc;break}}if(t==i.lit)throw new Error("hufDecode issues")}}const w=8-i&7;for(g>>=w,f-=w;f>0;){const e=t[g<<14-f&16383];if(!e.len)throw new Error("hufDecode issues");f-=e.len,d(e.lit,c,g,f,n,s,p,m,_),g=h.c,f=h.lc}}(w,b,e,c,v,_,m,p,{value:0})}function v(e){for(let t=1;t<e.length;t++){const n=e[t-1]+e[t]-128;e[t]=n}}function b(e,t){let n=0,s=Math.floor((e.length+1)/2),i=0;const a=e.length-1;for(;!(i>a||(t[i++]=e[n++],i>a));)t[i++]=e[s++]}function y(e){let t=e.byteLength;const n=new Array;let s=0;const i=new DataView(e);for(;t>0;){const e=i.getInt8(s++);if(e<0){const a=-e;t-=a+1;for(let e=0;e<a;e++)n.push(i.getUint8(s++))}else{const a=e;t-=2;const r=i.getUint8(s++);for(let e=0;e<a+1;e++)n.push(r)}}return n}function S(e,t,n){let s,i=1;for(;i<64;)s=t[e.value],65280==s?i=64:s>>8==255?i+=255&s:(n[i]=s,i++),e.value++}function x(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),s=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),r=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),h=new Array(4),d=new Array(4),c=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=s*e[p+2],l[1]=r*e[p+2],l[2]=s*e[p+6],l[3]=r*e[p+6],h[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+o*e[p+7],h[1]=i*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],h[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+i*e[p+7],h[3]=o*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],d[0]=t*(e[p+0]+e[p+4]),d[3]=t*(e[p+0]-e[p+4]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[p+0]=c[0]+h[0],e[p+1]=c[1]+h[1],e[p+2]=c[2]+h[2],e[p+3]=c[3]+h[3],e[p+4]=c[3]-h[3],e[p+5]=c[2]-h[2],e[p+6]=c[1]-h[1],e[p+7]=c[0]-h[0]}for(let u=0;u<8;++u)l[0]=s*e[16+u],l[1]=r*e[16+u],l[2]=s*e[48+u],l[3]=r*e[48+u],h[0]=n*e[8+u]+i*e[24+u]+a*e[40+u]+o*e[56+u],h[1]=i*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],h[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+i*e[56+u],h[3]=o*e[8+u]-a*e[24+u]+i*e[40+u]-n*e[56+u],d[0]=t*(e[u]+e[32+u]),d[3]=t*(e[u]-e[32+u]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[0+u]=c[0]+h[0],e[8+u]=c[1]+h[1],e[16+u]=c[2]+h[2],e[24+u]=c[3]+h[3],e[32+u]=c[3]-h[3],e[40+u]=c[2]-h[2],e[48+u]=c[1]-h[1],e[56+u]=c[0]-h[0]}function P(e){for(let t=0;t<64;++t){const n=e[0][t],s=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*s-.4682*i,e[2][t]=n+1.8556*s}}function M(e,n,s){for(let a=0;a<64;++a)n[s+a]=St.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(t,Math.abs(i)-1));var i}function C(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function T(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(y(t)),s=new Uint8Array(n.length);return v(n),b(n,s),new DataView(s.buffer)}function A(e){const t=dl(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return v(t),b(t,n),new DataView(n.buffer)}function R(e){const t=e.viewer,n={value:e.offset.value},s=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),i=new Uint8Array(8192);let a=0;const r=new Array(e.channels);for(let t=0;t<e.channels;t++)r[t]={},r[t].start=a,r[t].end=r[t].start,r[t].nx=e.width,r[t].ny=e.lines,r[t].size=e.type,a+=r[t].nx*r[t].ny*r[t].size;const o=j(t,n),l=j(t,n);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let e=0;e<l-o+1;e++)i[e+o]=U(t,n);const h=new Uint16Array(65536),d=function(e,t){let n=0;for(let s=0;s<65536;++s)(0==s||e[s>>3]&1<<(7&s))&&(t[n++]=s);const s=n-1;for(;n<65536;)t[n++]=0;return s}(i,h),c=L(t,n);_(e.array,t,n,c,s,a);for(let t=0;t<e.channels;++t){const e=r[t];for(let n=0;n<r[t].size;++n)f(s,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,d)}!function(e,t,n){for(let s=0;s<n;++s)t[s]=e[t[s]]}(h,s,a);let u=0;const p=new Uint8Array(s.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.channels;t++){const e=r[t],n=e.nx*e.size,i=new Uint8Array(s.buffer,2*e.end,2*n);p.set(i,u),u+=2*n,e.end+=n}return new DataView(p.buffer)}function E(e){const t=dl(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.lines*e.channels*e.width,s=1==e.type?new Uint16Array(n):new Uint32Array(n);let i=0,a=0;const r=new Array(4);for(let n=0;n<e.lines;n++)for(let n=0;n<e.channels;n++){let n=0;switch(e.type){case 1:r[0]=i,r[1]=r[0]+e.width,i=r[1]+e.width;for(let i=0;i<e.width;++i)n+=t[r[0]++]<<8|t[r[1]++],s[a]=n,a++;break;case 2:r[0]=i,r[1]=r[0]+e.width,r[2]=r[1]+e.width,i=r[2]+e.width;for(let i=0;i<e.width;++i)n+=t[r[0]++]<<24|t[r[1]++]<<16|t[r[2]++]<<8,s[a]=n,a++}}return new DataView(s.buffer)}function I(e){const t=e.viewer,n={value:e.offset.value},s=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),i={version:B(t,n),unknownUncompressedSize:B(t,n),unknownCompressedSize:B(t,n),acCompressedSize:B(t,n),dcCompressedSize:B(t,n),rleCompressedSize:B(t,n),rleUncompressedSize:B(t,n),rleRawSize:B(t,n),totalAcUncompressedCount:B(t,n),totalDcUncompressedCount:B(t,n),acCompression:B(t,n)};if(i.version<2)throw new Error("EXRLoader.parse: "+q.compression+" version "+i.version+" is unsupported");const a=new Array;let r=j(t,n)-2;for(;r>0;){const e=D(t.buffer,n),s=U(t,n),i=s>>2&3,o=new Int8Array([(s>>4)-1])[0],l=U(t,n);a.push({name:e,index:o,type:l,compression:i}),r-=e.length+3}const o=q.channels,l=new Array(e.channels);for(let t=0;t<e.channels;++t){const n=l[t]={},s=o[t];n.name=s.name,n.compression=0,n.decoded=!1,n.type=s.pixelType,n.pLinear=s.pLinear,n.width=e.width,n.height=e.lines}const h={idx:new Array(3)};for(let t=0;t<e.channels;++t){const e=l[t];for(let n=0;n<a.length;++n){const s=a[n];e.name==s.name&&(e.compression=s.compression,s.index>=0&&(h.idx[s.index]=t),e.offset=t)}}let d,c,u;if(i.acCompressedSize>0)switch(i.acCompression){case 0:d=new Uint16Array(i.totalAcUncompressedCount),_(e.array,t,n,i.acCompressedSize,d,i.totalAcUncompressedCount);break;case 1:const s=dl(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));d=new Uint16Array(s.buffer),n.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){const t={array:e.array,offset:n,size:i.dcCompressedSize};c=new Uint16Array(A(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(u=y(dl(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0;const m=new Array(l.length);for(let e=0;e<m.length;++e)m[e]=new Array;for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)m[t].push(p),p+=l[t].width*e.type*2;!function(e,t,n,s,i,a){let r=new DataView(a.buffer);const o=n[e.idx[0]].width,l=n[e.idx[0]].height,h=Math.floor(o/8),d=Math.ceil(o/8),c=Math.ceil(l/8),u=o-8*(d-1),p=l-8*(c-1),m={value:0},g=new Array(3),f=new Array(3),_=new Array(3),v=new Array(3),w=new Array(3);for(let n=0;n<3;++n)w[n]=t[e.idx[n]],g[n]=n<1?0:g[n-1]+d*c,f[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(64*d);for(let t=0;t<c;++t){let a=8;t==c-1&&(a=p);let o=8;for(let e=0;e<d;++e){e==d-1&&(o=u);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[g[e]++],S(m,s,_[e]),b=_[e],(y=f[e])[0]=G(b[0]),y[1]=G(b[1]),y[2]=G(b[5]),y[3]=G(b[6]),y[4]=G(b[14]),y[5]=G(b[15]),y[6]=G(b[27]),y[7]=G(b[28]),y[8]=G(b[2]),y[9]=G(b[4]),y[10]=G(b[7]),y[11]=G(b[13]),y[12]=G(b[16]),y[13]=G(b[26]),y[14]=G(b[29]),y[15]=G(b[42]),y[16]=G(b[3]),y[17]=G(b[8]),y[18]=G(b[12]),y[19]=G(b[17]),y[20]=G(b[25]),y[21]=G(b[30]),y[22]=G(b[41]),y[23]=G(b[43]),y[24]=G(b[9]),y[25]=G(b[11]),y[26]=G(b[18]),y[27]=G(b[24]),y[28]=G(b[31]),y[29]=G(b[40]),y[30]=G(b[44]),y[31]=G(b[53]),y[32]=G(b[10]),y[33]=G(b[19]),y[34]=G(b[23]),y[35]=G(b[32]),y[36]=G(b[39]),y[37]=G(b[45]),y[38]=G(b[52]),y[39]=G(b[54]),y[40]=G(b[20]),y[41]=G(b[22]),y[42]=G(b[33]),y[43]=G(b[38]),y[44]=G(b[46]),y[45]=G(b[51]),y[46]=G(b[55]),y[47]=G(b[60]),y[48]=G(b[21]),y[49]=G(b[34]),y[50]=G(b[37]),y[51]=G(b[47]),y[52]=G(b[50]),y[53]=G(b[56]),y[54]=G(b[59]),y[55]=G(b[61]),y[56]=G(b[35]),y[57]=G(b[36]),y[58]=G(b[48]),y[59]=G(b[49]),y[60]=G(b[57]),y[61]=G(b[58]),y[62]=G(b[62]),y[63]=G(b[63]),x(f[e]);P(f);for(let t=0;t<3;++t)M(f[t],v[t],64*e)}let l=0;for(let s=0;s<3;++s){const i=n[e.idx[s]].type;for(let e=8*t;e<8*t+a;++e){l=w[s][e];for(let t=0;t<h;++t){const n=64*t+8*(7&e);r.setUint16(l+0*i,v[s][n+0],!0),r.setUint16(l+2*i,v[s][n+1],!0),r.setUint16(l+4*i,v[s][n+2],!0),r.setUint16(l+6*i,v[s][n+3],!0),r.setUint16(l+8*i,v[s][n+4],!0),r.setUint16(l+10*i,v[s][n+5],!0),r.setUint16(l+12*i,v[s][n+6],!0),r.setUint16(l+14*i,v[s][n+7],!0),l+=16*i}}if(h!=d)for(let e=8*t;e<8*t+a;++e){const t=w[s][e]+8*h*2*i,n=64*h+8*(7&e);for(let e=0;e<o;++e)r.setUint16(t+2*e*i,v[s][n+e],!0)}}}var b,y;const C=new Uint16Array(o);r=new DataView(a.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;const s=n[e.idx[t]].type;if(2==n[t].type)for(let e=0;e<l;++e){const n=w[t][e];for(let e=0;e<o;++e)C[e]=r.getUint16(n+2*e*s,!0);for(let e=0;e<o;++e)r.setFloat32(n+2*e*s,G(C[e]),!0)}}}(h,m,l,d,c,s);for(let t=0;t<l.length;++t){const n=l[t];if(!n.decoded)switch(n.compression){case 2:let i=0,a=0;for(let r=0;r<e.lines;++r){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)s[e++]=u[a+t*n.width*n.height];a++}i++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(s.buffer)}function D(e,t){const n=new Uint8Array(e);let s=0;for(;0!=n[t.value+s];)s+=1;const i=(new TextDecoder).decode(n.slice(t.value,t.value+s));return t.value=t.value+s+1,i}function O(e,t){const n=e.getInt32(t.value,!0);return t.value=t.value+4,n}function L(e,t){const n=e.getUint32(t.value,!0);return t.value=t.value+4,n}function k(e,t){const n=e[t.value];return t.value=t.value+1,n}function U(e,t){const n=e.getUint8(t.value);return t.value=t.value+1,n}const B=function(e,t){let n;return n="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function N(e,t){const n=e.getFloat32(t.value,!0);return t.value+=4,n}function F(e,t){return St.toHalfFloat(N(e,t))}function G(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function j(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function z(e,t){return G(j(e,t))}function V(e,t,n,s,i){return"string"===s||"stringvector"===s||"iccProfile"===s?function(e,t,n){const s=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,s}(t,n,i):"chlist"===s?function(e,t,n,s){const i=n.value,a=[];for(;n.value<i+s-1;){const s=D(t,n),i=O(e,n),r=U(e,n);n.value+=3;const o=O(e,n),l=O(e,n);a.push({name:s,pixelType:i,pLinear:r,xSampling:o,ySampling:l})}return n.value+=1,a}(e,t,n,i):"chromaticities"===s?function(e,t){return{redX:N(e,t),redY:N(e,t),greenX:N(e,t),greenY:N(e,t),blueX:N(e,t),blueY:N(e,t),whiteX:N(e,t),whiteY:N(e,t)}}(e,n):"compression"===s?function(e,t){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][U(e,t)]}(e,n):"box2i"===s?function(e,t){return{xMin:L(e,t),yMin:L(e,t),xMax:L(e,t),yMax:L(e,t)}}(e,n):"lineOrder"===s?function(e,t){return["INCREASING_Y"][U(e,t)]}(e,n):"float"===s?N(e,n):"v2f"===s?function(e,t){return[N(e,t),N(e,t)]}(e,n):"v3f"===s?function(e,t){return[N(e,t),N(e,t),N(e,t)]}(e,n):"int"===s?O(e,n):"rational"===s?function(e,t){return[O(e,t),L(e,t)]}(e,n):"timecode"===s?function(e,t){return[L(e,t),L(e,t)]}(e,n):"preview"===s?(n.value+=i,"skipped"):void(n.value+=i)}const H=new DataView(e),W=new Uint8Array(e),K={value:0},q=function(e,t,n){const s={};if(20000630!=e.getUint32(0,!0))throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");s.version=e.getUint8(4);const i=e.getUint8(5);s.spec={singleTile:!!(2&i),longName:!!(4&i),deepFormat:!!(8&i),multiPart:!!(16&i)},n.value=8;let a=!0;for(;a;){const i=D(t,n);if(0==i)a=!1;else{const a=D(t,n),r=V(e,t,n,a,L(e,n));void 0===r?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${a}'.`):s[i]=r}}if(0!=(-5&i))throw console.error("THREE.EXRHeader:",s),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return s}(H,e,K),X=function(e,t,n,s,i){const a={size:0,viewer:t,array:n,offset:s,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,channels:e.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:e.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:w};switch(e.compression){case"NO_COMPRESSION":a.lines=1,a.uncompress=C;break;case"RLE_COMPRESSION":a.lines=1,a.uncompress=T;break;case"ZIPS_COMPRESSION":a.lines=1,a.uncompress=A;break;case"ZIP_COMPRESSION":a.lines=16,a.uncompress=A;break;case"PIZ_COMPRESSION":a.lines=32,a.uncompress=R;break;case"PXR24_COMPRESSION":a.lines=16,a.uncompress=E;break;case"DWAA_COMPRESSION":a.lines=32,a.uncompress=I;break;case"DWAB_COMPRESSION":a.lines=256,a.uncompress=I;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}if(a.scanlineBlockSize=a.lines,1==a.type)switch(i){case wt:a.getter=z,a.inputSize=2;break;case vt:a.getter=j,a.inputSize=2}else{if(2!=a.type)throw new Error("EXRLoader.parse: unsupported pixelType "+a.type+" for "+e.compression+".");switch(i){case wt:a.getter=N,a.inputSize=4;break;case vt:a.getter=F,a.inputSize=4}}a.blockCount=(e.dataWindow.yMax+1)/a.scanlineBlockSize;for(let e=0;e<a.blockCount;e++)B(t,s);a.outputChannels=3==a.channels?4:a.channels;const r=a.width*a.height*a.outputChannels;switch(i){case wt:a.byteArray=new Float32Array(r),a.channels<a.outputChannels&&a.byteArray.fill(1,0,r);break;case vt:a.byteArray=new Uint16Array(r),a.channels<a.outputChannels&&a.byteArray.fill(15360,0,r);break;default:console.error("THREE.EXRLoader: unsupported type: ",i)}return a.bytesPerLine=a.width*a.inputSize*a.channels,4==a.outputChannels?(a.format=be,a.colorSpace=w):(a.format=bt,a.colorSpace=yt),a}(q,H,W,K,this.type),Y={value:0},Q={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<X.height/X.scanlineBlockSize;e++){const t=L(H,K);X.size=L(H,K),X.lines=t+X.scanlineBlockSize>X.height?X.height-t:X.scanlineBlockSize;const n=X.size<X.lines*X.bytesPerLine?X.uncompress(X):C(X);K.value+=X.size;for(let t=0;t<X.scanlineBlockSize;t++){const s=t+e*X.scanlineBlockSize;if(s>=X.height)break;for(let e=0;e<X.channels;e++){const i=Q[q.channels[e].name];for(let a=0;a<X.width;a++){Y.value=(t*(X.channels*X.width)+e*X.width+a)*X.inputSize;const r=(X.height-1-s)*(X.width*X.outputChannels)+a*X.outputChannels+i;X.byteArray[r]=X.getter(n,Y)}}}}return{header:q,width:X.width,height:X.height,data:X.byteArray,format:X.format,colorSpace:X.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,s){return super.load(e,(function(e,n){e.colorSpace=n.colorSpace,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}),n,s)}}class pl extends _t{constructor(e){super(e),this.type=vt}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},n=function(e,t,n){t=t||1024;let s=e.pos,i=-1,a=0,r="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));for(;0>(i=o.indexOf("\n"))&&a<t&&s<e.byteLength;)r+=o,a+=o.length,s+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),r+o.slice(0,i))},s=function(e,t,n,s){const i=e[t+3],a=Math.pow(2,i-128)/255;n[s+0]=e[t+0]*a,n[s+1]=e[t+1]*a,n[s+2]=e[t+2]*a,n[s+3]=1},i=function(e,t,n,s){const i=e[t+3],a=Math.pow(2,i-128)/255;n[s+0]=St.toHalfFloat(Math.min(e[t+0]*a,65504)),n[s+1]=St.toHalfFloat(Math.min(e[t+1]*a,65504)),n[s+2]=St.toHalfFloat(Math.min(e[t+2]*a,65504)),n[s+3]=St.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;const r=function(e){const s=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,r=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,h;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(h=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=h[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(s))&&(o.gamma=parseFloat(h[1])),(h=l.match(i))&&(o.exposure=parseFloat(h[1])),(h=l.match(a))&&(o.valid|=2,o.format=h[1]),(h=l.match(r))&&(o.valid|=4,o.height=parseInt(h[1],10),o.width=parseInt(h[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=r.width,l=r.height,h=function(e,n,s){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*s);a.length||t(4,"unable to allocate buffer space");let r=0,o=0;const l=4*i,h=new Uint8Array(4),d=new Uint8Array(l);let c=s;for(;c>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==i||t(3,"bad rgbe scanline format");let n,s=0;for(;s<l&&o<e.byteLength;){n=e[o++];const i=n>128;if(i&&(n-=128),(0===n||s+n>l)&&t(3,"bad scanline data"),i){const t=e[o++];for(let e=0;e<n;e++)d[s++]=t}else d.set(e.subarray(o,o+n),s),s+=n,o+=n}const u=i;for(let e=0;e<u;e++){let t=0;a[r]=d[e+t],t+=i,a[r+1]=d[e+t],t+=i,a[r+2]=d[e+t],t+=i,a[r+3]=d[e+t],r+=4}c--}return a}(a.subarray(a.pos),o,l);let d,c,u;switch(this.type){case wt:u=h.length/4;const e=new Float32Array(4*u);for(let t=0;t<u;t++)s(h,4*t,e,4*t);d=e,c=wt;break;case vt:u=h.length/4;const t=new Uint16Array(4*u);for(let e=0;e<u;e++)i(h,4*e,t,4*e);d=t,c=vt;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:o,height:l,data:d,header:r.string,gamma:r.gamma,exposure:r.exposure,type:c}}setDataType(e){return this.type=e,this}load(e,t,n,s){return super.load(e,(function(e,n){switch(e.type){case wt:case vt:e.colorSpace=w,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,s)}}class ml extends z{constructor(e,t){super(new Pt(1,1,10,10),new x({color:ml.alphaMap?0:16777215,transparent:!0,depthWrite:!1,polygonOffset:!0,name:"ShadowGroundPlaneMaterial"})),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;ml.alphaMap?(t.alphaMap=e,t.map=null,t.color.set(0)):(t.alphaMap=null,t.map=e,t.color.set(16777215)),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}ml.alphaMap=!0;class gl extends class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}{get renderPassManager(){return this._renderPassManager}get renderCacheManager(){return this._renderPassManager.renderCacheManager}get scene(){return this._renderPassManager.scene}get camera(){return this._renderPassManager.camera}get gBufferTextures(){return this._renderPassManager.gBufferRenderPass}get passRenderer(){return this._renderPassManager.passRenderer}constructor(e){super(),this._renderPassManager=e}render(e,t,n,s,i){this.renderPass(e)}}const fl={uniforms:{tDiffuse:{value:null},intensity:{value:new a(1,1)}},vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 intensity;\n varying vec2 vUv;\n \n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n vec2 aoAndShadow = vec2(1.0) - intensity + intensity * textureColor.rg;\n gl_FragColor = vec4(vec3(aoAndShadow.r * aoAndShadow.g), 1.0);\n }"};class _l extends Te{constructor(e){super({uniforms:De.clone(fl.uniforms),vertexShader:fl.vertexShader,fragmentShader:fl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ae,blendDst:Re,blendEquation:Ee,blendSrcAlpha:Ie,blendDstAlpha:Re,blendEquationAlpha:Ee}),this._intensity=new a(1,1),this.uniforms.intensity.value=this._intensity,this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),void 0!==(null==e?void 0:e.aoIntensity)&&(this._intensity.x=e.aoIntensity),void 0!==(null==e?void 0:e.shadowIntensity)&&(this._intensity.y=e.shadowIntensity),this}}const vl=(e,t,n)=>{const s=wl(e,t,n);let i="vec3[SAMPLES](";for(let t=0;t<e;t++){const n=s[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?",":")"}`}return i},wl=(e,t,n)=>{const s=[];for(let i=0;i<e;i++){const a=2*Math.PI*t*i/e,o=Math.pow(i/(e-1),n);s.push(new r(Math.cos(a),Math.sin(a),o))}return s},bl={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:vl(16,2,1),NV_ALIGNED_SAMPLES:0,SAMPLE_DISTRIBUTION:0,DEPTH_VALUE_SOURCE:0,LUMINANCE_TYPE:"float",SAMPLE_LUMINANCE:"dot(vec3(0.2125, 0.7154, 0.0721), a)",SCENE_CLIP_BOX:0,FRAGMENT_OUTPUT:"vec4(vec3(denoised), 1.)"},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new a},cameraProjectionMatrix:{value:new P},cameraProjectionMatrixInverse:{value:new P},cameraWorldMatrix:{value:new P},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:10},radiusExponent:{value:1},index:{value:0},sceneBoxMin:{value:new r(-1,-1,-1)},sceneBoxMax:{value:new r(1,1,1)}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nvarying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform vec2 resolution;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraProjectionMatrixInverse;\nuniform mat4 cameraWorldMatrix;\nuniform float lumaPhi;\nuniform float depthPhi;\nuniform float normalPhi;\nuniform float radius;\nuniform float radiusExponent;\nuniform int index;\n#if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\n\n#include <common>\n#include <packing>\n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(vec3(denoised), 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout LUMINANCE_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = fetchDepth(ivec2(vec2(textureSize(tDepth, 0)) * vUv.xy));\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radius * 2.) {\n discard;\n return;\n }\n\t\t#endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n #if SAMPLE_DISTRIBUTION == 1\n vec3 randomVec = normalize(vec3(noiseVec.xy, 0.));\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n #endif\n\n LUMINANCE_TYPE totalWeight = LUMINANCE_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SAMPLE_DISTRIBUTION == 1\n vec3 offsetViewPos = viewPos + normalize(kernelMatrix * vec3(sampleDir.xy, 0.)) * sampleDir.z * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #else\n vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n vec2 sampleUv = vUv + offset;\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = FRAGMENT_OUTPUT;\n}"},yl={iterations:2,samples:16,rings:2,radiusExponent:1,radius:5,lumaPhi:10,depthPhi:.5,normalPhi:1,nvOrientatedSamples:!1};class Sl{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n,s){this.needsUpdate=!0,this.parameters={...yl},this._width=0,this._height=0,this._samples=0,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._passRenderer=new Ra,this._rgInputTexture=!1,this._width=e,this._height=t,this._samples=n,this._normalVectorSourceType=(null==s?void 0:s.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==s?void 0:s.depthValueSourceType)||"normalVectorAlpha",this._inputTexture=(null==s?void 0:s.inputTexture)||null,this.depthTexture=(null==s?void 0:s.depthTexture)||null,this.normalTexture=(null==s?void 0:s.normalTexture)||null,this._rgInputTexture=(null==s?void 0:s.rgInputTexture)||!1,this._luminanceType=(null==s?void 0:s.luminanceType)||"vec3",this._sampleLuminance=(null==s?void 0:s.sampleLuminance)||"a",this._fragmentOutput=(null==s?void 0:s.fragmentOutput)||"vec4(denoised.xyz, 1.)",(null==s?void 0:s.poissonDenoisePassParameters)&&(this.parameters=s.poissonDenoisePassParameters),s&&this.updateTextures(s)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ca,n=new Uint8Array(e*e*4);for(let s=0;s<e;s++)for(let i=0;i<e;i++){const a=s,r=i;n[4*(s*e+i)]=127.5*(t.noise(a,r)+1),n[4*(s*e+i)+1]=127.5*(t.noise(a+e,r)+1),n[4*(s*e+i)+2]=127.5*(t.noise(a,r+e)+1),n[4*(s*e+i)+3]=127.5*(t.noise(a+e,r+e)+1)}this._noiseTexture=new ye(n,e,e,be,ke),this._noiseTexture.wrapS=L,this._noiseTexture.wrapT=L,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;return this._pdMaterial||(this._pdMaterial=new Te({defines:Object.assign({},bl.defines),uniforms:De.clone(bl.uniforms),vertexShader:bl.vertexShader,fragmentShader:bl.fragmentShader,depthTest:!1,depthWrite:!1}),this._pdMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&this._updateShader(this._pdMaterial),this._updateUniforms(this._pdMaterial,e,n),this._pdMaterial}_updateShader(e){e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=vl(this.parameters.samples,this.parameters.rings,this.parameters.radiusExponent),e.defines.SAMPLE_DISTRIBUTION=this.parameters.nvOrientatedSamples?1:0,e.defines.NORMAL_VECTOR_TYPE="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_VALUE_SOURCE="normalVectorAlpha"===this._depthValueSourceType?1:0,e.needsUpdate=!0,e.defines.LUMINANCE_TYPE=this._luminanceType,e.defines.SAMPLE_LUMINANCE=this._sampleLuminance,e.defines.FRAGMENT_OUTPUT=this._fragmentOutput,e.defines.SCENE_CLIP_BOX=this._sceneClipBox?1:0,e.needsUpdate=!0}_updateUniforms(e,t,n){const s="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;e.uniforms.tDiffuse.value=this._inputTexture,e.uniforms.tNormal.value=this.normalTexture,e.uniforms.tDepth.value=s,e.uniforms.resolution.value.set(this._width,this._height),e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse),e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld),n&&(e.uniforms.lumaPhi.value=this.parameters.lumaPhi,e.uniforms.depthPhi.value=this.parameters.depthPhi,e.uniforms.normalPhi.value=this.parameters.normalPhi,e.uniforms.radius.value=this.parameters.radius,e.uniforms.radiusExponent.value=this.parameters.radiusExponent,this._sceneClipBox&&(e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min),e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)))}_getRenderTargets(){return this._renderTargets.length<2&&(this._renderTargets=[new Fe(this._width,this._height,{samples:this._samples,format:be,type:vt,magFilter:D,minFilter:D}),new Fe(this._width,this._height,{samples:this._samples,format:be,type:vt,magFilter:D,minFilter:D})]),this._renderTargets}dispose(){var e,t;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._pdMaterial)||void 0===t||t.dispose(),this._renderTargets.forEach(e=>e.dispose())}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach(n=>n.setSize(e,t)),this.needsUpdate=!0}updateBounds(e){this._sceneClipBox=(new ge).copy(e),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const s=this._getRenderTargets();for(let t=0;t<this.parameters.iterations;t++){const i=s[(t+1)%2];this._outputRenderTargetIndex=t%2;const a=s[this._outputRenderTargetIndex];n.uniforms.tDiffuse.value=0===t?this._inputTexture:i.texture,n.uniforms.index.value=t,this._passRenderer.renderScreenSpace(e,n,a,16777215,1)}}renderToTarget(e,t,n){const s=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,s,n,16777215,1)}}const xl={shadowRadius:.05};class Pl extends gl{get aoAndSoftShadowRenderTarget(){var e;return this._aoAndSoftShadowRenderTarget=null!==(e=this._aoAndSoftShadowRenderTarget)&&void 0!==e?e:new Fe(this._width,this._height,{samples:this._samples,format:Mt,magFilter:ne,minFilter:ne}),this._aoAndSoftShadowRenderTarget}get aoRenderPass(){return this._aoPass||(this._aoPass=new ka(this._width,this._height,this._samples,!this.parameters.applyToMaterial,{normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",modulateRedChannel:!0,aoParameters:this.parameters.ao})),this._aoPass}get softShadowPass(){if(this._softShadowPass){const e=this._softShadowPass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._softShadowPass=new Sl(this._width,this._height,this._samples,{inputTexture:void 0,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,luminanceType:"float",sampleLuminance:"a.x",fragmentOutput:"vec4(1.0, denoised.x, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",poissonDenoisePassParameters:{iterations:1,samples:16,rings:2,radiusExponent:1,radius:this.parameters.shadow.shadowRadius,lumaPhi:10,depthPhi:.1,normalPhi:4,nvOrientatedSamples:!0}});return this._softShadowPass}get fadeRenderTarget(){var e;return this._fadeRenderTarget=null!==(e=this._fadeRenderTarget)&&void 0!==e?e:new Fe(this._width,this._height,{samples:this._samples,format:Mt,magFilter:ne,minFilter:ne}),this._fadeRenderTarget}get denoisePass(){if(this._poissonDenoisePass){const e=this._poissonDenoisePass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._poissonDenoisePass=new Sl(this._width,this._height,this._samples,{inputTexture:this.aoAndSoftShadowRenderTarget.texture,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,fragmentOutput:"vec4(denoised.xy, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",poissonDenoisePassParameters:this.parameters.poissonDenoise});return this._poissonDenoisePass}get denoiseRenderTargetTexture(){return this.denoisePass?this.denoisePass.texture:null}get finalTexture(){return this._finalTexture}constructor(e,t,n,s,i){var a,r,o,l,h,d,c,u;super(e),this.needsUpdate=!0,this.renderToRenderTarget=!1,this.shadowAndAoPassSettings={shadowMapTexture:null,shadowBlurType:"full",shadowFadeInBlurType:"full",shadowFadeInMix:0,noOStaticFrames:0},this._cameraUpdate=new Aa,this._finalTexture=null,this._onlyHardShadow=!1,this._width=t,this._height=n,this._samples=s,this.parameters={enabled:null===(a=null==i?void 0:i.enabled)||void 0===a||a,applyToMaterial:null===(r=null==i?void 0:i.applyToMaterial)||void 0===r||r,aoIntensity:null!==(o=null==i?void 0:i.aoIntensity)&&void 0!==o?o:.5,shadowIntensity:null!==(l=null==i?void 0:i.shadowIntensity)&&void 0!==l?l:.35,aoOnGround:null===(h=null==i?void 0:i.aoOnGround)||void 0===h||h,shadowOnGround:null!==(d=null==i?void 0:i.shadowOnGround)&&void 0!==d&&d,alwaysUpdate:null!==(c=null==i?void 0:i.alwaysUpdate)&&void 0!==c&&c,progressiveDenoiseIterations:null!==(u=null==i?void 0:i.progressiveDenoiseIterations)&&void 0!==u?u:0,shadow:{...xl},ao:{...La},poissonDenoise:{...yl}},this._copyMaterial=new ba,this._blendMaterial=new ba({},"default"),this._blendAoAndShadowMaterial=new _l}dispose(){var e,t,n,s,i,a,r,o;super.dispose(),null===(e=this._aoAndSoftShadowRenderTarget)||void 0===e||e.dispose(),null===(t=this._softShadowPass)||void 0===t||t.dispose(),null===(n=this._aoPass)||void 0===n||n.dispose(),null===(s=this._fadeRenderTarget)||void 0===s||s.dispose(),null===(i=this._poissonDenoisePass)||void 0===i||i.dispose(),null===(a=this._copyMaterial)||void 0===a||a.dispose(),null===(r=this._blendMaterial)||void 0===r||r.dispose(),null===(o=this._blendAoAndShadowMaterial)||void 0===o||o.dispose()}setSize(e,t){var n,s,i,a,r;this._width=e,this._height=t,null===(n=this._aoAndSoftShadowRenderTarget)||void 0===n||n.setSize(e,t),null===(s=this._softShadowPass)||void 0===s||s.setSize(e,t),null===(i=this._aoPass)||void 0===i||i.setSize(e,t),null===(a=this._fadeRenderTarget)||void 0===a||a.setSize(e,t),null===(r=this._poissonDenoisePass)||void 0===r||r.setSize(this._width,this._height),this.needsUpdate=!0}updateParameters(e){void 0!==e.enabled&&(this.parameters.enabled=e.enabled),void 0!==e.applyToMaterial&&(this.parameters.applyToMaterial=e.applyToMaterial),void 0!==e.aoIntensity&&(this.parameters.aoIntensity=e.aoIntensity),void 0!==e.shadowIntensity&&(this.parameters.shadowIntensity=e.shadowIntensity),void 0!==e.aoOnGround&&(this.parameters.aoOnGround=e.aoOnGround),void 0!==e.shadowOnGround&&(this.parameters.shadowOnGround=e.shadowOnGround),void 0!==e.alwaysUpdate&&(this.parameters.alwaysUpdate=e.alwaysUpdate),this._updatePassParameters(e)}_updatePassParameters(e){var t,n;if(null==e?void 0:e.shadow){for(const t in e.shadow)this.parameters.shadow.hasOwnProperty(t)&&(this.parameters.shadow[t]=e.shadow[t]);this._softShadowPass&&(this._softShadowPass.needsUpdate=!0)}if(null==e?void 0:e.ao){for(const t in e.ao)this.parameters.ao.hasOwnProperty(t)&&(this.parameters.ao[t]=e.ao[t]);this._aoPass&&(null===(t=this._aoPass)||void 0===t||t.updateParameters(null==e?void 0:e.ao))}if(null==e?void 0:e.poissonDenoise)if(this._poissonDenoisePass)null===(n=this._poissonDenoisePass)||void 0===n||n.updateParameters(null==e?void 0:e.poissonDenoise);else for(const t in e.poissonDenoise)this.parameters.poissonDenoise.hasOwnProperty(t)&&(this.parameters.poissonDenoise[t]=e.poissonDenoise[t])}updateBounds(e,t){var n,s;null===(n=this._softShadowPass)||void 0===n||n.updateBounds(e.bounds),null===(s=this._aoPass)||void 0===s||s.updateBounds(e.bounds,t)}_getRenderConditions(e="full",t=0,n=0){const s="poisson"===e&&t>.001,i="hard"===e&&t>.001&&t<.999;return{fadeInPoissonShadow:s,fadeInHardShadow:i,onlyHardShadow:"hard"===e&&!i,progressiveDenoise:!s&&!i&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}renderPass(e){if(!this._setRenderState())return;const t=this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType,this.shadowAndAoPassSettings.shadowFadeInMix,this.shadowAndAoPassSettings.noOStaticFrames);let n=!1;!t.onlyHardShadow&&"full"===this.shadowAndAoPassSettings.shadowBlurType&&this._evaluateIfUpdateIsNeeded(this.camera)&&(this._renderShadowAndAo(e,this.scene,this.camera,this.shadowAndAoPassSettings.shadowMapTexture),n=!0);let s=t.onlyHardShadow?this.shadowAndAoPassSettings.shadowMapTexture:this.denoiseRenderTargetTexture;t.fadeInPoissonShadow&&(s=this._renderDynamicShadow(e,this.aoAndSoftShadowRenderTarget.texture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix),n=!0),n?s=this._renderDenoise(e,this.camera,t.fadeInPoissonShadow,!1):t.progressiveDenoise&&(s=this._renderDenoise(e,this.camera,!1,!0)),t.fadeInHardShadow&&(s=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix)),this._finalTexture=s,this._onlyHardShadow=t.onlyHardShadow,this.renderToRenderTarget&&this.renderToTarget(e)}_setRenderState(){return!(!this.parameters.enabled||!(null!==this.parameters.ao.algorithm||this.parameters.shadowIntensity>=.01)||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,s){var i;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;a||null===(i=this._aoPass)||void 0===i||i.clear(e,this.aoAndSoftShadowRenderTarget),this._renderSoftShadow(e,n,s),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const s=this.gBufferTextures.depthBufferTexture,i=this.gBufferTextures.gBufferTexture,a=this._aoAndSoftShadowRenderTarget,r=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=s,o.normalTexture=i,o.render(e,n,t,a),e.autoClear=r}_renderSoftShadow(e,t,n){const s=this.softShadowPass;s.parameters.radius=this.parameters.shadow.shadowRadius,s.inputTexture=n,this.softShadowPass.renderToTarget(e,t,this.aoAndSoftShadowRenderTarget)}_renderDynamicShadow(e,t,n,s=1){const i=s<.999;return i&&(this._copyMaterial.update({texture:t,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),s>.001&&(this._blendMaterial.update({texture:n,blending:i?Ue:Oe,colorTransform:(new P).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,i?s:1),multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,s){const i=this.denoisePass;return i.inputTexture=n?this.fadeRenderTarget.texture:s?i.texture:this.aoAndSoftShadowRenderTarget.texture,i.render(e,t),i.texture}renderToTarget(e){const t=this._onlyHardShadow?this.parameters.shadowIntensity:this.parameters.aoIntensity,n=this._onlyHardShadow?0:this.parameters.shadowIntensity;this.passRenderer.renderScreenSpace(e,this._blendAoAndShadowMaterial.update({texture:this._finalTexture,blending:Ue,aoIntensity:t,shadowIntensity:n}),e.getRenderTarget())}}Pl.shadowTransform=(new P).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class Ml{get isOutlinePassActivated(){return this.outlinePassActivated}get outlinePass(){return this._renderPassManager.outlinePass}constructor(e,t,n){this._effectComposer=null,this.outlinePassActivated=!1,this._renderPassManager=e,this._effectComposer=t,this.parameters={enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215,...n}}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const s=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!s&&this.outlinePassActivated||(!s&&this.outlinePass||this._renderPassManager.createOutlinePass(),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class Cl{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse(e=>{var t,n,s;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(s=this._cache)||void 0===s||s.addObject(e)}),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class Tl{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach(e=>{e.dispose()})}registerCache(e,t){this._cacheMap.set(e,new Cl(t))}clearCache(){this._cacheMap.forEach(e=>{e.clear()})}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const s=this._cacheMap.get(e);s&&(s.update(t),s.onBeforeRender()),n(),s&&s.onAfterRender()}}class Al{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach((e,t)=>{t.visible=!1})}onAfterRender(){this._visibilityCache.forEach((e,t)=>{t.visible=e})}}class Rl{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof N&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!1})}onAfterRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!0})}}class El{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach((e,t)=>{t instanceof z&&(t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),t.receiveShadow!==e.originalObjectData.receiveShadow&&(e.originalObjectData.receiveShadow=t.receiveShadow),t.castShadow!==e.originalObjectData.castShadow&&(e.originalObjectData.castShadow=t.castShadow),t.visible!==e.originalObjectData.visible&&(e.originalObjectData.visible=t.visible)),this._updateObject(t,e.updateObjectData)})}onAfterRender(){this._objectCache.forEach((e,t)=>{this._updateObject(t,e.originalObjectData)})}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof z?e.receiveShadow:void 0,material:e instanceof z?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof z&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof z&&void 0!==t.material&&(e.material=t.material)}}class Il extends gl{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new ml(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n,s){var i,a;super(e),this.limitPlaneSize=!0,this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=n,this.shadowMapSize=null!==(i=s.shadowMapSize)&&void 0!==i?i:2048,this.parameters=this._getDefaultParameters(s),this._groundShadowFar=this.parameters.cameraFar,this._renderer=t,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,new Al(e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name))),this.renderTarget=new Fe(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new Fe(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==s?void 0:s.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new Dl,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new Tt,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",ml.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=F,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new Ea(ya,{...s,passRenderer:this.renderPassManager.passRenderer}),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return{enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0,...e}}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFar<e.size.z&&(this._groundShadowFar=1.01*e.size.z);const s=Math.max(e.size.x,e.size.z);this.parameters.planeSize=s+2*Math.max(this._blurScale,null!==(n=this._shadowScale)&&void 0!==n?n:1,1),this.limitPlaneSize&&this.parameters.planeSize>this.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}renderPass(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,this.scene),!this.parameters.enabled)return void(this.needsUpdate&&(this.needsUpdate=!1,this.passRenderer.clear(e,this.renderTarget,0,1)));if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(this.scene),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this.renderCacheManager?this.renderCacheManager.render(this,e,()=>{this._renderer.render(e,this._groundContactCamera)}):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}Il.addTestMesh=!1;class Dl extends Q{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,s,i;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Ct(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(s=this.cameraHelper)||void 0===s?void 0:s.parent)&&(null===(i=this.cameraHelper)||void 0===i||i.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}class Ol extends Te{constructor(e){var t;super({defines:Object.assign({...Ol._normalAndDepthShader.defines,FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0}),uniforms:De.clone(Ol._normalAndDepthShader.uniforms),vertexShader:Ol._normalAndDepthShader.vertexShader,fragmentShader:Ol._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:Oe}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}Ol._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class Ll extends gl{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new Ol({blending:Oe,floatBufferType:!0,linearDepth:!1}):new At({blending:Oe}),this._gBufferRenderMaterial instanceof Ol&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:wt,samples:this._samples});else{const e=new Rt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=Et,e.type=It,this._depthNormalRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:wt,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,s,i,a,r,o,l,h,d;super(e),this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.drawGround=!0,this.floatRgbNormalAlphaDepth=null!==(s=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==s&&s,this.renderCacheManager&&(this._gBufferMaterialCache=new kl,this.renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(i=null==t?void 0:t.depthNormalScale)&&void 0!==i?i:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:ne,this._targetMagnificationTextureFilter=null!==(r=null==t?void 0:t.textureMagnificationFilter)&&void 0!==r?r:ne,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(h=null==t?void 0:t.samples)&&void 0!==h?h:0,this._shared=null!==(d=null==t?void 0:t.shared)&&void 0!==d&&d}dispose(){var e,t;super.dispose(),null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}renderPass(e){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this.renderPassManager.setGroundVisibility(this.drawGround),this.renderCacheManager?this.renderCacheManager.render(this,this.scene,()=>{this._renderGBuffer(e,this.scene,this.camera)}):this._renderGBuffer(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this.passRenderer.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new ba),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:Oe,colorTransform:pa,colorBase:_a,multiplyChannels:0,uvTransform:va}),this.separateDeptRenderTarget)}}class kl extends El{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof U&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof x&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class Ul extends gl{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n,s,i){super(e),this.reflectionFadeInScale=1,this._width=t,this._height=n,this._samples=null!=s?s:1,this.parameters={enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4,...i},this._copyMaterial=new ba({},"additive",!0,!0),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new Bl({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new Ea(ya,{...i,passRenderer:this.renderPassManager.passRenderer})}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,s={};if(e){const e=new Rt(t,n);s.depthTexture=e,s.samples=this._samples}else s.samples=1;return new Fe(t,n,{format:be,...s})}dispose(){var e,t,n;super.dispose(),null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,s,i,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(s=this._intensityRenderTarget)||void 0===s||s.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._blurRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const s=this.parameters.intensity*t,i=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new P).set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,s),multiplyChannels:0,uvTransform:wa}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}renderPass(e){if(!(this.parameters.enabled&&this.camera instanceof X))return;const t=this._createGroundReflectionCamera(this.camera);this.renderCacheManager.render("inivisibleGround",this.scene,()=>{this._renderGroundReflection(e,this.scene,t,this.reflectionRenderTarget)}),this._renderGroundReflectionIntensity(e,t,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,this.camera,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,this.reflectionFadeInScale),this.passRenderer.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,s){const i=e.getRenderTarget();s&&(e.setRenderTarget(s),this.passRenderer.clear(e,s,0,0)),e.render(t,n),s&&e.setRenderTarget(i)}_renderGroundReflectionIntensity(e,t,n){const s=e.getRenderTarget();e.setRenderTarget(n),this.passRenderer.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(s)}blurReflection(e,t,n){const s=new r(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),i=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(s.dot(new r(0,0,1)));this._blurPass.render(e,n,[4*i,4*a],[4*i*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class Bl extends Te{constructor(e){super({defines:Object.assign({},Bl.shader.defines),uniforms:De.clone(Bl.shader.uniforms),vertexShader:Bl.shader.vertexShader,fragmentShader:Bl.shader.fragmentShader,blending:Oe}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const s=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(s,i)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}Bl.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new a},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new P},cameraInverseProjectionMatrix:{value:new P},inverseViewMatrix:{value:new P},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:0,PREMULTIPLIED_ALPHA:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec2 diffuseTextureSize = vec2(textureSize(tDiffuse, 0 ));\n vec4 fragColor = texelFetch(tDiffuse, ivec2(uv * diffuseTextureSize), 0).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha * step(depth, 0.9999);\n #if PREMULTIPLIED_ALPHA == 1\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n #else\n gl_FragColor = fragColor;\n #endif\n }"};class Nl extends H{constructor(e,t){const n=new c;n.setAttribute("position",new Le([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new B({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const s=new c;s.setAttribute("position",new Le([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new z(s,new y({side:Dt,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class Fl extends Ot{constructor(e){super(e),this.customProgramCacheKey=this._customProgramCacheKey,this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,s,i,a,r){this._enableGroundBoundary=e,Fl._distributionProperties.set(t,n,s,i),Fl._shadowFadeOut.set(a,r)}static setBoundingBox(e){Fl._sceneBoxMin.copy(e.min),Fl._sceneBoxMax.copy(e.max)}_customProgramCacheKey(){return Fl._enableGroundBoundary?"GROUND_BOUNDARY":"NO_GROUND_BOUNDARY"}_onBeforeCompile(e,t){e.vertexShader=Gl,e.fragmentShader=jl,e.defines=Object.assign({...e.defines,DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:Fl._enableGroundBoundary?1:0});const n=e.uniforms;n&&(n.distributionProperties={value:Fl._distributionProperties},n.shadowFadeOut={value:Fl._shadowFadeOut},n.sceneBoxMin={value:Fl._sceneBoxMin},n.sceneBoxMax={value:Fl._sceneBoxMax})}}Fl._enableGroundBoundary=!1,Fl._shadowFadeOut=new a(.1,20),Fl._sceneBoxMin=new r(-1,-1,-1),Fl._sceneBoxMax=new r(1,1,1),Fl._distributionProperties=new Me(1,1,1,1);const Gl="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n #include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",jl="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include <common>\n#include <packing>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include <logdepthbuf_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include <opaque_fragment>\n\t#include <premultiplied_alpha_fragment>\n}\n",zl={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:"DirectionalLightShadow",maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class Vl extends gl{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var s,i,r;super(e),this.needsUpdate=!1,this.drawGround=!0,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Wl,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._cameraUpdate=new Aa,this._viewportSize=new a(t.x,t.y),this._samples=null!==(s=null==n?void 0:n.samples)&&void 0!==s?s:0,this._shadowMapSize=null!==(i=null==n?void 0:n.shadowMapSize)&&void 0!==i?i:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Hl,null===(r=this.renderCacheManager)||void 0===r||r.registerCache(this,this._shadowMapPassOverrideMaterialCache);const o=this._samples;this._shadowRenderTarget=new Fe(this._viewportSize.x,this._viewportSize.y,{samples:o,format:bt,magFilter:ne,minFilter:ne})}_getScreenSpaceShadowMapParameters(e){return{...zl,...e}}dispose(){super.dispose(),this._shadowLightSources.forEach(e=>e.dispose()),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const s=this._shadowScale;if(this._shadowScale=t,Math.abs(s-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach(t=>t.updateBounds(e)),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Q&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach(e=>e.forceShadowUpdate()),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map(e=>e.getShadowLight())}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find(t=>t.getOriginalLight()===e))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new ql(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){const n=this._shadowLightSources;this._shadowLightSources=this._createShadowLightSourceArray(!1);for(const s of n){if(s instanceof ql){const t=s.getRectAreaLight();e.includes(t)&&(s.updatePositionAndTarget(),this._shadowLightSources.push(s))}s.removeFrom(t),s.dispose()}e.forEach(e=>{this._shadowLightSources.find(t=>t instanceof ql&&t.getRectAreaLight()===e)||this.addRectAreaLight(e,t)}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){for(const t of this._shadowLightSources)t.removeFrom(e),t.dispose();this._shadowLightSources=this._createShadowLightSourceArray(!0);const n=1/(t.length>0?Math.max(...t.map(e=>e.maxIntensity)):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach(t=>{t.addTo(e),t.updatePositionAndTarget()}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach(e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new r(e.position.x,e.position.z,e.position.y).multiplyScalar(7),s=new Xl(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(s)}})}_createShadowLightSourceArray(e){const t=[];if(e){const e=new Yl(new r(0,7,0),{shadowMapSize:this._shadowMapSize});t.push(e)}return this.parameters.enableGroundBoundary=e,t}setSize(e,t){this._viewportSize=new a(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach(e=>e.updatePositionAndTarget())}renderPass(e){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(this.camera)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const t=this.scene.background,n=this.scene.environment,s=this.camera.layers.mask;this.scene.environment=null,this.scene.background=null,this.parameters.layers&&(this.camera.layers.mask=this.parameters.layers.mask),this.renderPassManager.setGroundVisibility(this.drawGround),this._renderSimpleShadowMapFromShadowLightSources(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.camera.layers.mask=s,this.scene.environment=n,this.scene.background=t}_renderSimpleShadowMapFromShadowLightSources(e,t,n){var s;this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const i=this._getSortedShadowLightSources();0===i.length?this.passRenderer.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(i),null===(s=this.renderCacheManager)||void 0===s||s.render(this,t,()=>{this.passRenderer.render(e,t,n,this._shadowRenderTarget,16777215,1)}),this._shadowLightSources.forEach(e=>e.finishRenderShadow()))}_getSortedShadowLightSources(){const e=[];return this._shadowLightSources.forEach(t=>e.push(...t.prepareRenderShadow())),e.sort((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity),e}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let s=0;e.forEach(e=>{(n<0||s<n)&&(t+=e.groundShadow?0:e.intensity,e.groundShadow||s++)}),s=0,e.forEach(e=>{var i;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||s<n)?(e.light.visible=!1,e.light.intensity=0,e.light.castShadow=!1):(e.light.visible=!0,e.light.intensity=e.groundShadow?e.intensity:e.intensity/t,(i=e.light).castShadow&&(i.castShadow=this.castShadow)),e.groundShadow||s++})}_updateShadowType(e){e.shadowMap.type=this.shadowConfiguration.currentConfiguration.type;const t=this.parameters.enableShadowMap&&this.shadowConfiguration.currentConfiguration.castShadow;e.shadowMap.enabled=t,e.shadowMap.needsUpdate=!0,this.castShadow=t&&this.shadowConfiguration.currentConfiguration.castShadow,this._shadowLightSources.forEach(e=>e._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}class Hl extends El{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial("default"),this._unlitMaterial=this._createShadowMaterial("unlit"),this._emissiveMaterial=this._createShadowMaterial("emissive"),this._receiveShadowMaterial=this._createShadowMaterial("shadow")}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,s,i,a,r){Fl.setShadowParameters(e,t,n,s,i,a,r)}setBoundingBox(e){this._boundingBoxSet=!0,Fl.setBoundingBox(e)}_createShadowMaterial(e){let t;return t="emissive"===e||"unlit"===e?new y({color:16777215,side:F}):"shadow"===e?new Nt({side:F}):Hl.useModifiedMaterial?this._createCustomerShadowMaterial():new Ft({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:F}),t}_createCustomerShadowMaterial(){return new Fl({side:F})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof B||t instanceof y?this.addToCache(e,{material:this._unlitMaterial}):t instanceof N?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}Hl.useModifiedMaterial=!0;class Wl{constructor(){var e;this.types=new Map([["off",Wl._noShadow],["BasicShadowMap",Wl._basicShadow],["PCFShadowMap",Wl._pcfShadow],["PCFSoftShadowMap",Wl._pcfSoftShadow],["VSMShadowMap",Wl._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Wl._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Wl._defaultType,!0)}}Wl._noShadow={castShadow:!1,type:Lt,bias:0,normalBias:0,radius:0},Wl._basicShadow={castShadow:!0,type:kt,bias:-5e-5,normalBias:.005,radius:0},Wl._pcfShadow={castShadow:!0,type:Lt,bias:-5e-5,normalBias:.01,radius:4},Wl._pcfSoftShadow={castShadow:!0,type:Ut,bias:-5e-5,normalBias:.01,radius:1},Wl._vcmShadow={castShadow:!0,type:Bt,bias:1e-4,normalBias:0,radius:15},Wl._defaultType=Wl._pcfShadow;class Kl{constructor(e,t){var n,s;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(s=null==t?void 0:t.blurSamples)&&void 0!==s?s:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new a(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new r(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof l){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),s=Math.max(.001,Math.min(-n.min.z,-n.max.z)),i=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),r=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(r,a),s);t.aspect=1,t.near=s,t.far=i,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,s,i;if(this._shadowLightSource instanceof l){const n=t.clone().sub(e),s=n.length();n.normalize();const i=t.clone().sub(n.clone().multiplyScalar(4*s));this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(i),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(s=this._shadowLightSource.shadow)||void 0===s||s.camera.lookAt(t);null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class ql extends Kl{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case"DirectionalLightShadow":n=new i(16777215,1);break;case"SpotLightShadow":n=new l(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new Nl(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class Xl extends Kl{constructor(e,t,n){const s=new i(16777215,t);s.position.copy(e),s.lookAt(0,0,0),s.updateMatrix(),s.castShadow=!0,super(s,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class Yl extends Kl{constructor(e,t){const n=new i(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}const Ql={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},Zl={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new a(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t\t//----------------------------------------------------------------------------------\n\t\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t\t// SDK Version: v3.00\n\t\t// Email: gameworks@nvidia.com\n\t\t// Site: http://developer.nvidia.com/\n\t\t//\n\t\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t\t//\n\t\t// Redistribution and use in source and binary forms, with or without\n\t\t// modification, are permitted provided that the following conditions\n\t\t// are met:\n\t\t// * Redistributions of source code must retain the above copyright\n\t\t// notice, this list of conditions and the following disclaimer.\n\t\t// * Redistributions in binary form must reproduce the above copyright\n\t\t// notice, this list of conditions and the following disclaimer in the\n\t\t// documentation and/or other materials provided with the distribution.\n\t\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t\t// contributors may be used to endorse or promote products derived\n\t\t// from this software without specific prior written permission.\n\t\t//\n\t\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t\t//\n\t\t//----------------------------------------------------------------------------------\n\n\t\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t\t/*--------------------------------------------------------------------------*/\n\n\t\t#define NUM_SAMPLES 5\n\n\t\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\t\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t\t}\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t// locate the edge\n\t\t\t\tvec2 dirToEdge;\n\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t// . 2 . . 1 .\n\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t// . 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 H\n\n\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t// V 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 .\n\n\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t// 1 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t// do a simple blur\n\t\t\t\t\treturn mix(\n\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t.4\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\titerationsUsed = i;\n\n\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\tif(!doneN) {\n\t\t\t\t\tnDist += increment;\n\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t}\n\n\t\t\t\tif(!doneP) {\n\t\t\t\t\tpDist += increment;\n\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t}\n\n\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\trgbaM,\n\t\t\t\trgbaN,\n\t\t\t\tdist * .5\n\t\t\t);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t\t}\n\t"};class Jl extends gl{constructor(e,t,n,s,i,r){var o;super(e),this.patternTexture=null,this.clearBackground=!1,this.renderScene=n,this.renderCamera=s,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new h(1,1,1),this.hiddenEdgeColor=new h(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==r?void 0:r.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==r?void 0:r.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==t?new a(t.x,t.y):new a(256,256);const l=Math.round(this.resolution.x/this.downSampleRatio),d=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Fe(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(o=this.gBufferTextures)||void 0===o?void 0:o.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=F,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new Te(Zl),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new Fe(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new Fe(l,d),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Fe(l,d),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Fe(Math.round(l/2),Math.round(d/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Fe(l,d),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Fe(Math.round(l/2),Math.round(d/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(l,d),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(l/2),Math.round(d/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const c=Ql;this.copyUniforms=De.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Te({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:Oe,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new h,this.oldClearAlpha=1,this.fsQuad=new Ma(void 0),this.tempPulseColor1=new h,this.tempPulseColor2=new h,this.textureMatrix=new P}dispose(){var e,t;super.dispose(),this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.prepareMaskMaterial.dispose(),null===(t=this.fxaaRenderMaterial)||void 0===t||t.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,s;this.renderTargetMaskBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,a),this.renderTargetBlurBuffer1.setSize(i,a),this.renderTargetEdgeBuffer1.setSize(i,a),this.separableBlurMaterial1.uniforms.texSize.value.set(i,a),i=Math.round(i/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(i,a),this.renderTargetEdgeBuffer2.setSize(i,a),this.separableBlurMaterial2.uniforms.texSize.value.set(i,a),null===(n=this.fxaaRenderMaterial)||void 0===n||n.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(s=this.renderTargetFxaaBuffer)||void 0===s||s.setSize(e,t)}_canBeHighlighted(e){return e.isMesh||Jl.highlightLines&&e.isLine}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;this.selectedObjects.forEach(n=>n.traverse(n=>{this._canBeHighlighted(n)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];this.selectedObjects.forEach(e=>e.traverse(e=>{this._canBeHighlighted(e)&&n.push(e)})),this.renderScene.traverse(s=>{if(this._canBeHighlighted(s)||s.isSprite){if(!1===n.some(e=>e.id===s.id)){const n=s.visible;!1!==e&&!0!==t.get(s)||(s.visible=e),t.set(s,n)}}else s.isPoints&&(!0===e?s.visible=t.get(s):(t.set(s,s.visible),s.visible=e))})}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,s,i){if(this.selectedObjects.length>0){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;this.clearBackground&&(e.setClearColor(0,255),e.clear(!0,!1,!1)),e.autoClear=!1,i&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const s=this.renderScene.background;this.renderScene.background=null,this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.gBufferTextures.textureWithDepthValue,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=s;let a=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),a=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=a.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Jl.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Jl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Jl.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Jl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=a.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}renderPass(e){this.render(e,null,null,0,!1)}_getPrepareMaskMaterial(e){return new Te({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new a(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new Te({uniforms:{maskTexture:{value:null},texSize:{value:new a(.5,.5)},visibleEdgeColor:{value:new r(1,1,1)},hiddenEdgeColor:{value:new r(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new Te({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new a(.5,.5)},direction:{value:new a(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new Te({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:Gt,depthTest:!1,depthWrite:!1,transparent:!0})}}Jl.BlurDirectionX=new a(1,0),Jl.BlurDirectionY=new a(0,1),Jl.highlightLines=!0;const $l=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new a(t,n)};class eh{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new Fe,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?wt:ke;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new Fe(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new nh(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new nh(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Q(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,s){var i;this.colorRenderTarget.setSize(n,s),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new z(new Pt(2,2),new y({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const r=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*s*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,s,o),{texture:r,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,s){var i;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),r=this.environmentMapDecodeTarget(e);r.setSize(n,s),a.setSourceTexture(t),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new z(new Pt(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(r),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=r.texture,h=r.texture.type===wt,d=h?new Float32Array(n*s*4):new Uint8Array(n*s*4);return e.readRenderTargetPixels(r,0,0,n,s,d),{texture:l,pixels:d,sRgbaPixels:h}}}const th={tDiffuse:{value:null}};class nh extends Te{constructor(e,t){super({uniforms:De.clone(th),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }",defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}e("a6",nh),e("a5",class{constructor(e){var t,n,s,i;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new ce,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new ce,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new ih(0),this.lightSources=[],this._grayScale=new r(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;n<e;n++){const s=n*Math.PI*(3-Math.sqrt(5)),i=1-n/(e-1)*2,a=Math.sqrt(1-i*i),o=Math.cos(s)*a,l=Math.sin(s)*a;t.push(new r(o,l,i))}return t},this._numberOfSamples=null!==(t=null==e?void 0:e.numberOfSamples)&&void 0!==t?t:1e3,this._width=null!==(n=null==e?void 0:e.width)&&void 0!==n?n:1024,this._height=null!==(s=null==e?void 0:e.height)&&void 0!==s?s:512,this._sampleThreshold=null!==(i=null==e?void 0:e.sampleThreshold)&&void 0!==i?i:.707,this.pointDistance=Math.sqrt(4*Math.PI)/Math.sqrt(this._numberOfSamples),this.pixelDistance=Math.sqrt(2)*Math.PI*2/this._width,this.samplePoints=this._createEquirectangularSamplePoints(this._numberOfSamples),this.sampleUVs=this.samplePoints.map(e=>$l(e))}detectLightSources(e,t,n){var s;this.textureData=n,this._textureConverter=null!==(s=this._textureConverter)&&void 0!==s?s:new eh,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort((e,t)=>t.maxIntensity-e.maxIntensity)}_redFromRgbaToNormalizedFloatArray(e,t,n){const s=new Float32Array(e.length/4);let i=1,a=0;for(let t=0;t<e.length/4;++t){const n=new h(...e.slice(4*t,4*t+3));e instanceof Float32Array&&n.convertSRGBToLinear();const o=new r(n.r,n.g,n.b).dot(this._grayScale);i=Math.min(i,o),a=Math.max(a,o),s[t]=o}if(n)for(let e=0;e<s.length;++e){const r=t?s[e]:(s[e]-i)/(a-i);s[e]=Math.pow(r,n)}else if(!t)for(let e=0;e<s.length;++e)s[e]=(s[e]-i)/(a-i);return s}_grayscaleTextureFromFloatArray(e,t,n){const s=t*n,i=new Uint8Array(4*s);for(let t=0;t<s;t++){const n=255*e[t];i[4*t+0]=n,i[4*t+1]=n,i[4*t+2]=n,i[4*t+3]=255}const a=new ye(i,t,n);return a.needsUpdate=!0,a}_filterLightSamples(e){const t=[];for(let n=0;n<this.sampleUVs.length;n++){const s=this.sampleUVs[n];this._detectorTextureLuminanceValueFromUV(s)>e&&t.push(new sh(this.samplePoints[n],s))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let s=0;for(let e=Math.max(0,t-2);e<Math.max(0,t+2);++e)for(let t=Math.max(0,n-2);t<Math.max(0,n+2);++t){const n=t*this.textureData._width+e,i=(this.textureData.data[4*n]+this.textureData.data[4*n+1]+this.textureData.data[4*n+2])/3;s=Math.max(s,i)}return s}_findClusterSegments(e,t){const n=2*this.pixelDistance,s=1.5*this.pointDistance,i=new ih(e.length);for(let a=0;a<e.length;a++)for(let r=a+1;r<e.length;r++)if(e[a].position.angleTo(e[r].position)<s){const s=e[r].position.clone().sub(e[a].position),o=Math.floor(s.length()/n);let l=!0,h=0;for(let n=1;n<o;n++){const i=s.clone().multiplyScalar(n/o),r=$l(e[a].position.clone().add(i).normalize());if(this._detectorTextureLuminanceValueFromUV(r)<t){if(h++,h>1){l=!1;break}}else h=0}l&&(i.adjacent[a].push(r),i.adjacent[r].push(a),i.edges.push([a,r]))}return i}createLightSourcesFromLightGraph(e,t){const n=t.components.filter(e=>e.length>1).map(t=>new ah(t.map(t=>e[t])));return n.forEach(e=>e.calculateLightSourceProperties(e=>this._originalLuminanceValueFromUV(e))),n}});class sh{constructor(e,t){this.position=e,this.uv=t}}class ih{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;t<e;t++)this.adjacent.push([])}findConnectedComponents(){const e=new Array(this.noOfNodes).fill(!1);this.components=[];for(let t=0;t<this.noOfNodes;t++)if(!e[t]){const n=[];this._dfs(t,e,n),this.components.push(n)}this.components.sort((e,t)=>t.length-e.length)}_dfs(e,t,n){t[e]=!0,n.push(e);for(const s of this.adjacent[e])t[s]||this._dfs(s,t,n)}}class ah{constructor(e){this.position=new r,this.uv=new a,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new r,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=$l(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class rh extends gl{constructor(e){super(e),this.debugOutput="",this._environmentMapDecodeMaterial=new nh(!0,!1),this._environmentMapDecodeMaterial.blending=Oe,this._environmentMapDecodeMaterial.depthTest=!1}dispose(){var e,t,n;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),null===(n=this._srgbToLinearCopyMaterial)||void 0===n||n.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new ba,this._copyMaterial.update(e)}getBlendAoAndShadowMaterial(e){var t;return this._blendAoAndShadowMaterial=null!==(t=this._blendAoAndShadowMaterial)&&void 0!==t?t:new _l({blending:Oe}),this._blendAoAndShadowMaterial.update(e)}getSrgbToLinearCopyMaterial(e){var t;return this._srgbToLinearCopyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new ba({},"additive",!0,!0),this._srgbToLinearCopyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new Sa({depthTexture:this.gBufferTextures.textureWithDepthValue,depthFilter:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?new Me(0,0,0,1):new Me(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}renderPass(e){var t,n,s,i,a,r;switch(this.debugOutput){default:break;case"lineardepth":this.passRenderer.renderScreenSpace(e,this._getDepthRenderMaterial(this.camera),null);break;case"g-normal":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(t=this.gBufferTextures)||void 0===t?void 0:t.gBufferTexture,blending:Oe,colorTransform:(new P).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new Me(.5,.5,.5,1),multiplyChannels:0,uvTransform:va}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(n=this.gBufferTextures)||void 0===n?void 0:n.gBufferTexture,blending:Oe,colorTransform:ua,colorBase:_a,multiplyChannels:0,uvTransform:va}),null);break;case"g-depth":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this.gBufferTextures)||void 0===s?void 0:s.gBufferTexture,blending:Oe,colorTransform:pa,colorBase:_a,multiplyChannels:0,uvTransform:va}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this.gBufferTextures)||void 0===i?void 0:i.depthBufferTexture,blending:Oe,colorTransform:ma,colorBase:_a,multiplyChannels:0,uvTransform:va}),null);break;case"ssao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"ssaodenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowmap":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowsoft":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowdenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowfadein":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowandao":this.passRenderer.renderScreenSpace(e,this.getBlendAoAndShadowMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,aoIntensity:this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,shadowIntensity:this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity}),null);break;case"materialao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.aoPassMapTexture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"groundreflection":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:wa}),null);break;case"groundreflectionfinal":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:wa}),null);break;case"bakedgroundshadow":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment),this.passRenderer.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(a=this.scene.userData)||void 0===a?void 0:a.environmentDefinition){const t=this.renderPassManager.aspect,n=new Q(-1,1,1/t,-1/t,-1,1),s=null===(r=this.scene.userData)||void 0===r?void 0:r.environmentDefinition.createDebugScene(e,this.scene,this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);s.background=new h(16777215),e.render(s,n)}}}}class oh extends gl{constructor(e){super(e),this.drawGround=!0,this.drawWithDebugMaterial=!1,this.grayDebugMaterial=new N({color:12632256,side:F,envMapIntensity:.4})}dispose(){super.dispose(),this.grayDebugMaterial.dispose()}renderPass(e){this.renderCacheManager.onBeforeRender("floorDepthWrite",this.scene),this.renderPassManager.setGroundVisibility(this.drawGround),this.drawWithDebugMaterial?this.renderCacheManager.render("debug",this.scene,()=>{this.passRenderer.renderWithOverrideMaterial(e,this.scene,this.camera,this.grayDebugMaterial,null,0,1)}):e.render(this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}}class lh{constructor(){this.applyAoAndShadowToAlpha=!1,this._aoPassMapUniform={value:null},this._aoPassMapScaleUniform={value:1},this._aoPassMapIntensityUniform={value:1},this._shPassMapIntensityUniform={value:1},this._reflectionPassMapUniform={value:null},this._reflectionPassMapScaleUniform={value:1},this._reflectionPassMapIntensityUniform={value:0},this.applyReflectionPassMap=!1}set aoPassMap(e){this._aoPassMapUniform.value=e}set aoPassMapScale(e){this._aoPassMapScaleUniform.value=e}set aoPassMapIntensity(e){this._aoPassMapIntensityUniform.value=e}set shPassMapIntensity(e){this._shPassMapIntensityUniform.value=e}set reflectionPassMap(e){this._reflectionPassMapUniform.value=e}set reflectionPassMapScale(e){this._reflectionPassMapScaleUniform.value=e}set reflectionPassMapIntensity(e){this._reflectionPassMapIntensityUniform.value=e}static addPlugin(e){if(void 0!==e.userData.postProcessingMaterialPlugin)return e.userData.postProcessingMaterialPlugin instanceof lh?e.userData.postProcessingMaterialPlugin:null;const t=new lh;return e.userData.postProcessingMaterialPlugin=t,e.onBeforeCompile=(e,n)=>t._onBeforeCompile(e,n),e.customProgramCacheKey=()=>t._customProgramCacheKey(),t}_isEnabled(){return void 0!==this._aoPassMapUniform.value&&null!==this._aoPassMapUniform.value}_customProgramCacheKey(){let e="";return this._isEnabled()&&(e+="aoPassMap"+(this.applyAoAndShadowToAlpha?"Alpha":"")),this.applyReflectionPassMap&&(e+="reflectionPassMap"),e}_onBeforeCompile(e,t){if(this._isEnabled()||this.applyReflectionPassMap){let t=this.applyAoAndShadowToAlpha?"#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n":"";t+=this.applyReflectionPassMap?"#define USE_REFLECTION_PASS_MAP\n":"",t+=hh,e.fragmentShader=e.fragmentShader.replace("#include <aomap_pars_fragment>",t),e.fragmentShader=e.fragmentShader.replace("#include <aomap_fragment>",dh),this._initUniforms(e)}}_initUniforms(e){e&&(e.uniforms.tAoPassMap=this._aoPassMapUniform,e.uniforms.aoPassMapScale=this._aoPassMapScaleUniform,e.uniforms.aoPassMapIntensity=this._aoPassMapIntensityUniform,e.uniforms.shPassMapIntensity=this._shPassMapIntensityUniform,e.uniforms.tReflectionPassMap=this._reflectionPassMapUniform,e.uniforms.reflectionPassMapScale=this._reflectionPassMapScaleUniform,e.uniforms.reflectionPassMapIntensity=this._reflectionPassMapIntensityUniform)}}const hh="\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n\n\tuniform highp sampler2D tAoPassMap;\n uniform float aoPassMapScale;\n uniform float aoPassMapIntensity;\n uniform float shPassMapIntensity;\n uniform sampler2D tReflectionPassMap;\n uniform float reflectionPassMapScale;\n uniform float reflectionPassMapIntensity;\n",dh="\n#ifndef AOPASSMAP_SWIZZLE\n\t#define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\t\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tambientOcclusion = texture2D( aoMap, vAoMapUv ).r;\n ambientOcclusion = ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;\n\n#endif\n\n vec4 aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 );\n vec2 aoAndShadow = aoAndShadowMap.rg;\n float depthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n const ivec2 aoOffsetArray[8] = ivec2[8](\n ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1), ivec2(1, 1), ivec2(-1, 1), ivec2(1, -1), ivec2(-1, -1));\n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n if (testDepthDelta < depthDelta) {\n aoAndShadow = aoAndShadowMap.rg;\n depthDelta = testDepthDelta;\n }\n }\n \n float aoPassMapValue = aoPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.r - 1.0) * aoPassMapIntensity + 1.0);\n shadowValue = shPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.g - 1.0) * shPassMapIntensity + 1.0);\n\n #ifdef USE_REFLECTION_PASS_MAP\n\n ivec2 reflectionPassMapSize = textureSize( tReflectionPassMap, 0 );\n vec2 reflectionPassMapUv = vec2( gl_FragCoord.x * reflectionPassMapScale, float(reflectionPassMapSize.y) - gl_FragCoord.y * reflectionPassMapScale );\n vec4 reflectionPassMapColor = texture2D( tReflectionPassMap, reflectionPassMapUv / vec2(reflectionPassMapSize) );\n if (reflectionPassMapColor.a > 0.0) reflectionPassMapColor.rgb /= reflectionPassMapColor.a;\n vec3 diffuseReflectionPassMapColor = reflectionPassMapColor.rgb * material.diffuseColor;\n reflectedLight.indirectDiffuse += diffuseReflectionPassMapColor * reflectionPassMapColor.a * reflectionPassMapIntensity;\n //reflectedLight.indirectDiffuse = mix(reflectedLight.indirectDiffuse, diffuseReflectionPassMapColor, reflectionPassMapColor.a * reflectionPassMapIntensity);\n\n #endif\n\n #if defined ( USE_APPLY_AO_AND_SHADOW_TO_ALPHA )\n diffuseColor.a = 1.0 - (1.0 - diffuseColor.a) * aoPassMapValue * shadowValue;\n #else\n ambientOcclusion = min( ambientOcclusion, aoPassMapValue );\n #endif\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n \n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n \n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n\t\treflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif \n \n\t#endif\n";class ch{get passRenderer(){return this._passRenderer}get scene(){return this._scene}get camera(){return this._camera}get aspect(){return this._sceneRenderer.width/this._sceneRenderer.height}get cameraChanged(){return this._cameraChanged}get noOStaticFrames(){return this._noOStaticFrames}get renderCacheManager(){return this._sceneRenderer.renderCacheManager}get parameters(){return this._sceneRenderer.parameters}get sceneRenderPass(){return this._sceneRenderPass}get bakedGroundContactShadowPass(){return this._bakedGroundContactShadowPass}get gBufferRenderPass(){return this._gBufferRenderPass}get groundReflectionPass(){return this._groundReflectionPass}get screenSpaceShadowMapPass(){return this._screenSpaceShadowMapPass}get shadowAndAoPass(){return this._shadowAndAoPass}get outlinePass(){return this._outlinePass}get outlineRenderer(){return this._sceneRenderer.outlineRenderer}get debugPass(){var e;return null!==(e=this._debugPass)&&void 0!==e||(this._debugPass=new rh(this)),this._debugPass}get debugOutput(){return this._sceneRenderer.debugOutput}constructor(e){this.materialsNeedUpdate=!0,this._passRenderer=new Ra,this._outlinePass=null,this._debugPass=null,this._cameraUpdate=new Aa,this._cameraChanged=!0,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._maxSamples=1,this._passUpdateStates={updateGroundReflection:!1,updateGBuffer:!1,updateScreenSpaceShadow:!1,updateShadowAndAoPass:!1,updateOutlinePass:!1,updateDebugPass:!1},this.aoPassMapTexture=null,this._sceneRenderer=e,this._maxSamples=this._sceneRenderer.renderer.capabilities.maxSamples,this._sceneRenderPass=new oh(this),this._bakedGroundContactShadowPass=new Il(this,this._sceneRenderer.renderer,this._sceneRenderer.groundGroup,{sharedShadowGroundPlane:this._sceneRenderer.shadowAndAoGroundPlane}),this._gBufferRenderPass=new Ll(this,{shared:!0,capabilities:this._sceneRenderer.renderer.capabilities,width:this._sceneRenderer.width,height:this._sceneRenderer.height,samples:1}),this._groundReflectionPass=new Ul(this,this._sceneRenderer.width,this._sceneRenderer.height,this._maxSamples,{}),this._screenSpaceShadowMapPass=new Vl(this,new a(this._sceneRenderer.width,this._sceneRenderer.height),{samples:1,alwaysUpdate:!1}),this._shadowAndAoPass=new Pl(this,this._sceneRenderer.width,this._sceneRenderer.height,1)}dispose(){var e;this._sceneRenderPass.dispose(),this._bakedGroundContactShadowPass.dispose(),this._gBufferRenderPass.dispose(),this._groundReflectionPass.dispose(),this._screenSpaceShadowMapPass.dispose(),this._shadowAndAoPass.dispose(),null===(e=this._outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._gBufferRenderPass.setSize(e,t),this._groundReflectionPass.setSize(e,t),this._screenSpaceShadowMapPass.setSize(e,t),this._shadowAndAoPass.setSize(e,t),null===(n=this._outlinePass)||void 0===n||n.setSize(e,t)}createOutlinePass(){return this._outlinePass||(this._outlinePass=new Jl(this,new a(this._sceneRenderer.width,this._sceneRenderer.height),this.scene,this.camera,[],{downSampleRatio:2,edgeDetectionFxaa:!0})),this._outlinePass}setGroundVisibility(e){this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e)}updatePasses(e,t,n){this._scene=t,this._camera=n,this._cameraChanged=this._cameraUpdate.changed(n);const s=this._evaluateIfShadowAndAoUpdateIsNeeded();this._updateSceneRenderPass(),this._updateBakedGroundContactShadowPass(),this._updateGBufferPass(s),this._updateGroundReflectionPass(s),this._updateScreenSpaceShadowPass(s),this._updateShadowAndAoPass(s),this._updateOutlinePass(),this._updateDebugPass()}_evaluateIfShadowAndAoUpdateIsNeeded(){const e=this._shadowAndAoPass.parameters.alwaysUpdate||this._screenSpaceShadowMapPass.needsUpdate||this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate;let t=(this._shadowAndAoPass.parameters.enabled||this._groundReflectionPass.parameters.enabled)&&this._cameraChanged,n=1;return t&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),e||(this._noUpdateNeededCount++,t=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,n=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),e||1!==n||this._noOStaticFrames++,t=e||t,{needsUpdate:t,shadowOnCameraChange:!t||n<.99?this.parameters.shadowOnCameraChange:"off",intensityScale:n}}_dynamicChanges(e){return e.needsUpdate||"off"!==e.shadowOnCameraChange}_updateSceneRenderPass(){this._sceneRenderPass.drawWithDebugMaterial=!1}_updateBakedGroundContactShadowPass(){const e=this._bakedGroundContactShadowPass.limitPlaneSize;this._bakedGroundContactShadowPass.limitPlaneSize=this._bakedGroundContactShadowPass.parameters.enabled,(e!==this._bakedGroundContactShadowPass.limitPlaneSize||this._bakedGroundContactShadowPass.needsUpdate)&&this._bakedGroundContactShadowPass.updateBounds(this._sceneRenderer.boundingVolume,this._sceneRenderer.groundLevel),this._sceneRenderPass.drawGround=this._bakedGroundContactShadowPass.parameters.enabled||this._shadowAndAoPass.parameters.applyToMaterial}_updateGBufferPass(e){this._passUpdateStates.updateGBuffer=!1,this._gBufferRenderPass.needsUpdate=e.needsUpdate||"poisson"===e.shadowOnCameraChange,this.gBufferRenderPass.drawGround=this._sceneRenderer.boundingVolumeSet&&this._shadowAndAoPass.parameters.aoOnGround}_updateGroundReflectionPass(e){this._passUpdateStates.updateGroundReflection=!1,this._groundReflectionPass.parameters.enabled&&this._dynamicChanges(e)&&(!this.parameters.suspendGroundReflection||e.needsUpdate)&&(this._groundReflectionPass.reflectionFadeInScale=this.parameters.suspendGroundReflection?e.intensityScale:1,this._passUpdateStates.updateGroundReflection=!0)}_updateScreenSpaceShadowPass(e){this._dynamicChanges(e)?(this._screenSpaceShadowMapPass.parameters.alwaysUpdate=this._shadowAndAoPass.parameters.alwaysUpdate,this._screenSpaceShadowMapPass.drawGround=this._shadowAndAoPass.parameters.shadowOnGround,this._passUpdateStates.updateScreenSpaceShadow=this._shadowAndAoPass.parameters.shadowIntensity>0,this._passUpdateStates.updateScreenSpaceShadow=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateScreenSpaceShadow=!1}_updateShadowAndAoPass(e){this._dynamicChanges(e)?(this._shadowAndAoPass.shadowAndAoPassSettings={shadowMapTexture:this._screenSpaceShadowMapPass.shadowTexture,shadowBlurType:e.needsUpdate?"full":e.shadowOnCameraChange,shadowFadeInBlurType:e.shadowOnCameraChange,shadowFadeInMix:1-e.intensityScale,noOStaticFrames:this.noOStaticFrames},this._passUpdateStates.updateShadowAndAoPass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateShadowAndAoPass=!1}_updateOutlinePass(){this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass?(this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.clearBackground=!1,this._passUpdateStates.updateOutlinePass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateOutlinePass=!1}_updateDebugPass(){if(this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput){if("outline"===this.debugOutput&&this.outlineRenderer.outlinePass)return this.outlineRenderer.outlinePass.clearBackground=!0,void(this._passUpdateStates.updateDebugPass=!1);if("color"===this.debugOutput||"grayscale"===this.debugOutput)return this._passUpdateStates.updateGroundReflection=!1,this._passUpdateStates.updateGBuffer=!1,this._passUpdateStates.updateScreenSpaceShadow=!1,this._passUpdateStates.updateShadowAndAoPass=!1,this._passUpdateStates.updateOutlinePass=!1,this._passUpdateStates.updateDebugPass=!1,void(this._sceneRenderPass.drawWithDebugMaterial="grayscale"===this.debugOutput);this.debugPass.debugOutput=this.debugOutput,this._passUpdateStates.updateDebugPass=!0}else this._passUpdateStates.updateDebugPass=!1}_updateMaterials(e,t){if(!this.materialsNeedUpdate||!this._shadowAndAoPass.parameters.applyToMaterial)return;this.aoPassMapTexture=this._shadowAndAoPass.denoiseRenderTargetTexture;const n=e.getPixelRatio();this.materialsNeedUpdate=!1,t.traverse(e=>{if(e.isMesh){const t=e.material;t instanceof N&&this._updateMaterial(e,t,n)}})}_updateMaterial(e,t,n){const s=lh.addPlugin(t);s&&(this._updatePlugInAo(s,e,t,n),this._updatePlugInReflection(s,e),t.needsUpdate=!1)}_updatePlugInAo(e,t,n,s){const i=this._shadowAndAoPass.parameters.enabled&&this._shadowAndAoPass.parameters.applyToMaterial&&null!==this.aoPassMapTexture&&("ShadowGroundPlaneMaterial"===n.name||t.receiveShadow&&(!n.transparent||n.alphaTest>=.9)),a=i&&this._shadowAndAoPass.parameters.aoIntensity>.01,r=i&&this._screenSpaceShadowMapPass.enabled&&this._shadowAndAoPass.parameters.shadowIntensity>.01;e.applyAoAndShadowToAlpha="ShadowGroundPlaneMaterial"===n.name,e.aoPassMapIntensity=a?2*this._shadowAndAoPass.parameters.aoIntensity:-1,e.shPassMapIntensity=r?2*this._shadowAndAoPass.parameters.shadowIntensity:-1,e.aoPassMapScale=1/s,e.aoPassMap=this.aoPassMapTexture}_updatePlugInReflection(e,t){const n=this._groundReflectionPass.intensityRenderTarget.texture,s=t.userData.isPlanFloor&&this._groundReflectionPass.parameters.enabled&&(null!==n||void 0!==n),i=this._groundReflectionPass.parameters.intensity;e.applyReflectionPassMap=s,e.reflectionPassMapIntensity=s?Math.pow(i,.25):0,e.reflectionPassMapScale=1/(this._groundReflectionPass.parameters.renderTargetDownScale*devicePixelRatio),e.reflectionPassMap=s?n:null}renderPasses(e,t){var n,s;e.setRenderTarget(null),this._bakedGroundContactShadowPass.renderPass(e),this._passUpdateStates.updateGBuffer&&this._gBufferRenderPass.renderPass(e),this._passUpdateStates.updateScreenSpaceShadow&&this._screenSpaceShadowMapPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&this._shadowAndAoPass.renderPass(e),this._updateMaterials(e,t),this._sceneRenderPass.renderPass(e),this._passUpdateStates.updateGroundReflection&&this._groundReflectionPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&!this._shadowAndAoPass.parameters.applyToMaterial&&this._shadowAndAoPass.renderToTarget(e),this._passUpdateStates.updateOutlinePass&&(null===(n=this._outlinePass)||void 0===n||n.renderPass(e)),this._passUpdateStates.updateDebugPass&&(null===(s=this._debugPass)||void 0===s||s.renderPass(e))}}class uh{get sceneRenderPass(){return this._renderPassManager.sceneRenderPass}get bakedGroundContactShadowPass(){return this._renderPassManager.bakedGroundContactShadowPass}get gBufferRenderPass(){return this._renderPassManager.gBufferRenderPass}get groundReflectionPass(){return this._renderPassManager.groundReflectionPass}get screenSpaceShadowMapPass(){return this._renderPassManager.screenSpaceShadowMapPass}get shadowAndAoPass(){return this._renderPassManager.shadowAndAoPass}get debugPass(){return this._renderPassManager.debugPass}get shadowAndAoGroundPlane(){return this._shadowAndAoGroundPlane}constructor(e,t,n){this.debugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.enableObjectSelection=!0,this.groundLevel=0,this.uiInteractionMode=!1,this.width=0,this.height=0,this.boundingVolume=new Ta,this.boundingVolumeSet=!1,this.renderCacheManager=new Tl,this.selectedObjects=[],this.groundGroup=new q,this._shadingType="default",this._qualityLevel="highest",this._qualityMap=new Map,this._customShadingParameters=null,this.width=t,this.height=n,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new Al(e=>e===this.groundGroup)),this.renderCacheManager.registerCache("debug",new Al),this.renderCacheManager.registerCache("floorDepthWrite",new Rl(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor})),this._shadowAndAoGroundPlane=new ml(null),this.groundGroup.rotateX(-Math.PI/2),this._renderPassManager=new ch(this),this.outlineRenderer=new Ml(this._renderPassManager,null,{}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderPass.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadowPass.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadowMapPass.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"off"},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",()=>{}),e.domElement.addEventListener("webglcontextrestored",()=>{this._forceEnvironmentMapUpdate(this.renderer)})}dispose(){var e;null===(e=this._copyMaterial)||void 0===e||e.dispose(),this._renderPassManager.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this._renderPassManager.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setShadingType(e){this._shadingType!==e&&(this._shadingType=e,this.applyCurrentParameters())}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}setCustomShadingParameters(e){this._customShadingParameters=e,this.applyCurrentParameters(),this.requestUpdateOfPasses()}setQualityMapAndShadingParameters(e,t){this._qualityMap=e,this._customShadingParameters=t,this.applyCurrentParameters(),this.requestUpdateOfPasses()}applyCurrentParameters(){const e=[];this._qualityMap.has(this._qualityLevel)&&e.push(this._qualityMap.get(this._qualityLevel));const t=(n=this._shadingType)&&"default"!==n&&"bright"===n?Ua:null;var n;t&&e.push(t);const s=this.uiInteractionMode?{groundReflectionParameters:{enabled:!1}}:null;if(s&&e.push(s),this._customShadingParameters&&e.push((e=>{const t={shAndAoPassParameters:{ao:{},shadow:{}},groundReflectionParameters:{},bakedGroundContactShadowParameters:{}};return((e,t)=>{void 0!==t.aoIntensity&&(e.shAndAoPassParameters.aoIntensity=Ba(t.aoIntensity)),void 0!==t.aoExtent&&(e.shAndAoPassParameters.ao.radius=.3*Ba(t.aoExtent),e.shAndAoPassParameters.ao.thickness=.1+.2*Ba(t.aoExtent))})(t,e),((e,t)=>{t.shBakedOnGround?(e.bakedGroundContactShadowParameters.enabled=!0,e.shAndAoPassParameters.shadowIntensity=0,void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.opacity=Ba(t.shadowIntensity)),void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.blurMax=.1*Ba(t.shadowIntensity),e.bakedGroundContactShadowParameters.blurMin=.01*e.bakedGroundContactShadowParameters.blurMax)):(void 0!==t.shBakedOnGround&&(e.bakedGroundContactShadowParameters.enabled=!1),void 0!==t.shadowIntensity&&(e.shAndAoPassParameters.shadowIntensity=Ba(t.shadowIntensity)),void 0!==t.shadowSoftening&&(e.shAndAoPassParameters.shadow.shadowRadius=.001+.2*Ba(t.shadowSoftening)))})(t,e),((e,t)=>{void 0!==t.grReflectIntensity&&(e.groundReflectionParameters.enabled=t.grReflectIntensity>0,e.groundReflectionParameters.intensity=Ba(t.grReflectIntensity)),void 0!==t.grReflectFadeOut&&(e.groundReflectionParameters.fadeOutDistance=4*(1-Ba(t.grReflectFadeOut)))})(t,e),t})(this._customShadingParameters)),e.length>0){const t=((...e)=>{if(0===e.length)return null;if(1===e.length)return e[0];let t=e[0];for(let n=1;n<e.length;n++)t=Ge(t,e[n]);return t})(...e);this.updateParameters(t),this.bakedGroundContactShadowPass.applyParameters()}}requestUpdateOfPasses(){this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.needsUpdate=!0,this.shadowAndAoPass.needsUpdate=!0,this.shadowAndAoPass.softShadowPass.needsUpdate=!0,this._renderPassManager.materialsNeedUpdate=!0}clearCache(){this.renderCacheManager.clearCache(),this._renderPassManager.materialsNeedUpdate=!0}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadowPass.needsUpdate=!0)}updateParameters(e){e.shadowType&&this.screenSpaceShadowMapPass.switchType(e.shadowType),void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadowPass.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadowMapPass.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadowMapPass.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadowMapPass.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadowMapPass.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache();const n=e.clone();n.min.y>this.groundLevel&&(n.min.y=this.groundLevel),this.boundingVolumeSet=!0,this.gBufferRenderPass.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(n);const s=this.boundingVolume.size,i=(s.x+s.y+s.z)/3,a=Math.min(s.x,s.y,s.z),r=Math.max(s.x,s.y,s.z),o=a<.5?a/.5:s.z>5?s.z/5:1;this.bakedGroundContactShadowPass.setScale(t?i:o,i),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,r)),this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume,i),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?i:Math.min(1,2*r))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,s;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const i=e.userData;if(i&&((null===(s=t.userData)||void 0===s?void 0:s.environmentDefinition.needsUpdate)||!i.environmentTexture||i.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(i.environmentDefinition=n,i.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==i?void 0:i.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.enableObjectSelection?this.selectedObjects:[]),this._renderPassManager.updatePasses(this.renderer,e,t),this._renderPassManager.renderPasses(this.renderer,e),e.remove(this.groundGroup)}}class ph{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const s=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(s,t);const i=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(i,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const r=e.addFolder("Outline");this._addOutlineGUI(r,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",w],["SRGBColorSpace",S]]),s=[];n.forEach((e,t)=>{s.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)}),e.add(this._sceneRenderer,"outputColorSpace",s).onChange(e=>{var s;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(s=n.get(e))&&void 0!==s?s:S,t())});const i=new Map([["NoToneMapping",jt],["LinearToneMapping",zt],["ReinhardToneMapping",Vt],["CineonToneMapping",Ht],["ACESFilmicToneMapping",Wt]]),a=[];i.forEach((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)}),e.add(this._sceneRenderer,"toneMapping",a).onChange(e=>{var n;i.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=i.get(e))&&void 0!==n?n:jt,t())})}_addDebugGUI(e,t){const n=new Map([["HIGHEST","highest"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"]]),s=[];n.forEach((e,t)=>s.push(t)),e.add(this,"_qualityLevel",s).onChange(e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:"highest")}),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow soft":"shadowsoft","shadow denoised":"shadowdenoise","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","material AO pass":"materialao","ground reflection base":"groundreflection","ground reflection final":"groundreflectionfinal","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange(()=>t())}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadowMapPass.shadowConfiguration,s=[];n.types.forEach((e,t)=>{s.push(t)});const i=()=>{this._sceneRenderer.screenSpaceShadowMapPass.needsUpdate=!0,this._sceneRenderer.screenSpaceShadowMapPass.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",s).onChange(e=>{this._sceneRenderer.screenSpaceShadowMapPass.switchType(e)&&(a.object=n.currentConfiguration,r.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),r.updateDisplay(),o.updateDisplay(),i())});const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange(()=>i()),r=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange(()=>i()),o=e.add(n.currentConfiguration,"radius",0,100).onChange(()=>i())}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.requestUpdateOfPasses(),t()},s=this._sceneRenderer.shadowAndAoPass.parameters,i=s.shadow,a=this._sceneRenderer.screenSpaceShadowMapPass.parameters,r=s.ao,o=s.poissonDenoise;e.add(s,"enabled").onChange(()=>n()),e.add(s,"applyToMaterial").onChange(()=>{n(),this._sceneRenderer.clearCache()});const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),h=Array.from(l.keys());l.forEach((e,t)=>{e===r.algorithm&&(this._ambientOcclusionType=t)}),e.add(s,"aoIntensity",0,1).onChange(()=>{n()}),e.add(s,"aoOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(s,"shadowOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(s,"shadowIntensity",0,1).onChange(()=>n()),e.add(s,"alwaysUpdate").onChange(()=>n()),e.add(s,"progressiveDenoiseIterations",0,3,1).onChange(()=>n());const d=e.addFolder("Environment Shadow");d.add(a,"maximumNumberOfLightSources",-1,10,1).onChange(()=>n()),d.add(a,"enableGroundBoundary").onChange(()=>n()),d.add(a,"directionalDependency",0,1,.01).onChange(()=>n()),d.add(a,"directionalExponent",0,2,.01).onChange(()=>n()),d.add(a,"groundBoundary",0,1,.01).onChange(()=>n()),d.add(a,"fadeOutDistance",0,5,.01).onChange(()=>n()),d.add(a,"fadeOutBlur",0,20,1).onChange(()=>n()),d.add(i,"shadowRadius",.001,.5).onChange(()=>n());const c=e.addFolder("AO");c.add(this,"_ambientOcclusionType",h).onChange(e=>{if(l.has(e)){const t=l.get(e);r.algorithm=void 0!==t?t:0,n()}}),c.add(r,"samples",1,64,1).onChange(()=>n()),c.add(r,"radius",.01,2,.01).onChange(()=>n()),c.add(r,"distanceExponent",.1,4,.1).onChange(()=>n()),c.add(r,"thickness",.01,2,.01).onChange(()=>n()),c.add(r,"distanceFallOff",0,1).onChange(()=>n()),c.add(r,"scale",.01,2,.01).onChange(()=>n()),c.add(r,"bias",1e-4,.01,1e-4).onChange(()=>n()),c.add(r,"screenSpaceRadius").onChange(()=>n());const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange(()=>n()),u.add(o,"samples",0,32,1).onChange(()=>n()),u.add(o,"rings",0,16,.125).onChange(()=>n()),u.add(o,"radiusExponent",.1,4,.01).onChange(()=>n()),u.add(o,"radius",0,50,1).onChange(()=>n()),u.add(o,"lumaPhi",0,20,.001).onChange(()=>n()),u.add(o,"depthPhi",0,20,.001).onChange(()=>n()),u.add(o,"normalPhi",0,20,.001).onChange(()=>n())}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange(()=>t()),e.add(n,"fadeOutDistance",0,4).onChange(()=>t()),e.add(n,"fadeOutExponent",.1,10).onChange(()=>t()),e.add(n,"brightness",0,2).onChange(()=>t()),e.add(n,"blurHorizontal",0,10).onChange(()=>t()),e.add(n,"blurVertical",0,10).onChange(()=>t())}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadowPass.applyParameters(),t()},s=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(s,"enabled").onChange(()=>n()),e.add(s,"cameraHelper").onChange(()=>n()),e.add(s,"alwaysUpdate"),e.add(s,"fadeIn"),e.add(s,"blurMin",0,.2,.001).onChange(()=>n()),e.add(s,"blurMax",0,.5,.01).onChange(()=>n()),e.add(s,"fadeoutFalloff",0,1,.01).onChange(()=>n()),e.add(s,"fadeoutBias",0,.5).onChange(()=>n()),e.add(s,"opacity",0,1,.01).onChange(()=>n()),e.add(s,"maximumPlaneSize",0,50,1).onChange(()=>n()),e.add(s,"cameraFar",.1,10,.1).onChange(()=>n())}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},s=this._sceneRenderer.outlineRenderer.parameters;e.add(s,"enabled"),e.add(s,"edgeStrength",.5,20).onChange(()=>n()),e.add(s,"edgeGlow",0,20).onChange(()=>n()),e.add(s,"edgeThickness",.5,20).onChange(()=>n()),e.add(s,"pulsePeriod",0,5).onChange(()=>n()),e.addColor(s,"visibleEdgeColor").onChange(()=>n()),e.addColor(s,"hiddenEdgeColor").onChange(()=>n())}}const mh={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"full"},gh={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:"poisson"},fh={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:"poisson"},_h={algorithm:0,samples:32,radius:.15,distanceExponent:2,thickness:.25,distanceFallOff:1,bias:.01},vh={iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:2,normalPhi:4},wh=e("a8",new Map([["highest",{...mh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["high",{...gh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["medium",{...fh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]])),bh=new Kt;bh.enable(3);const yh=new Kt;yh.disableAll(),yh.enable(9);const Sh={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:_h,poissonDenoise:vh},xh={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:{algorithm:2,samples:16,radius:.5,distanceExponent:2,thickness:.5,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:2,normalPhi:4}},Ph=xh,Mh={enabled:!0,fadeoutFalloff:.9,blurMax:.1,opacity:.5,hardLayers:null,softLayers:null,polygonOffset:2},Ch={enabled:!0,fadeoutFalloff:.8,blurMax:.15,opacity:.5,hardLayers:yh,softLayers:null,polygonOffset:-1},Th={enabled:!1},Ah=new Map([["highest",{...mh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["high",{...gh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["medium",{...fh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Mh}]]),Rh=new Map([["highest",{...mh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["high",{...gh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["medium",{...fh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}]]),Eh=new Map([["highest",{...mh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["high",{...gh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["medium",{...fh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}]]);class Ih{constructor(){this._index=0,this._prevTime=0,this._frames=0,this._fps=-1,this._fpsList=Array(2).fill(0),this._prevTime=(performance||Date).now(),this.reset()}update(){this._frames++;const e=(performance||Date).now();e>=this._prevTime+1e3&&(this._fpsList[this._index%2]=1e3*this._frames/(e-this._prevTime),this._index>=2&&(this._fps=this._fpsList.reduce((e,t)=>e+t)/this._fpsList.length),this._prevTime=e,this._frames=0,this._index++)}start(){this._prevTime=(performance||Date).now(),this._frames=0}reset(){this._fps=-1,this._fpsList=Array(2).fill(0),this._index=0}getFps(){return this._fps}}var Dh;e("ai",Dh),function(e){e[e.Mode3D=0]="Mode3D",e[e.Mode2D=1]="Mode2D"}(Dh||e("ai",Dh={}));class Oh{get renderer(){return this._renderer}get sceneRenderer(){return this._sceneRenderer}get screenSpaceShadowParameters(){return this.sceneRenderer.screenSpaceShadowMapPass.parameters}get shadowAndAoPassParameters(){return this._sceneRenderer.shadowAndAoPass.parameters}get bakedGroundContactShadowParameters(){return this.sceneRenderer.bakedGroundContactShadowPass.parameters}get groundReflectionParameters(){return this._sceneRenderer.groundReflectionPass.parameters}get outlineParameters(){return this._sceneRenderer.outlineRenderer.parameters}constructor(e,t,n){this.configuratorMode=!0,this.uiInteractionMode=!0,this._movingCamera=!1,this._boundingBox=new ge,this._boundingBoxNeedsUpdate=!1,this._cacheNeedsUpdate=!1,this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1,this._customShadingParameters=null,this._customShadingParametersMoc=null,this._renderer=e,this._sceneRenderer=new uh(this._renderer,t,n),this.outlineParameters.enabled=!0,this.outlineParameters.edgeStrength=2,this.outlineParameters.edgeGlow=1,this.outlineParameters.edgeThickness=2,this.outlineParameters.pulsePeriod=0,this.outlineParameters.usePatternTexture=!1,this.outlineParameters.visibleEdgeColor=16777215,this.outlineParameters.hiddenEdgeColor=16777215,Oh.enableRectAreaLightShadow&&($t.rectAreaLightReplacement=!1,$t.rectAreaLightLoadingListener=this.loadRectAreLight),this.sceneRenderer.setQualityLevel("highest"),this.SceneRendererGUI=new ph(this.sceneRenderer)}dispose(){this._sceneRenderer.dispose()}setSize(e,t){this._sceneRenderer.setSize(e,t)}setCameraType(e){this._cameraType=e}setShadingType(e){this.sceneRenderer.setShadingType(e)}setAutoQuality(e){!this._fpsCounter&&e?this._fpsCounter=new Ih:this._fpsCounter&&!e&&(this._fpsCounter=null)}setQualityLevel(e){this._sceneRenderer.setQualityLevel(e)}setQualityMap(e){this._sceneRenderer.setQualityMap(e)}setCustomShadingParameters(e,t){this._customShadingParameters=e,this._customShadingParametersMoc=t;const n=this.configuratorMode?this._customShadingParameters:this._customShadingParametersMoc;this._sceneRenderer.setCustomShadingParameters(n)}enableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!0,this._sceneRenderer.applyCurrentParameters()}disableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!1,this._sceneRenderer.applyCurrentParameters()}loadRectAreLight(e){Oh.rectAreaLightsNeedsUpdate=!0}updateRectAreaLight(e){let t=[];e.traverse(e=>{e instanceof o&&t.push(e)}),this._sceneRenderer.updateRectAreaLights(t,e),Oh.rectAreaLightsNeedsUpdate=!1}clearCache(){this._cacheNeedsUpdate=!0}forceShadowUpdates(e){this._shadowNeedsUpdate=!0,this._bakedGroundShadowNeedsUpdate=e}switchToConfigurator(){this.configuratorMode=!0,this._sceneRenderer.setQualityMapAndShadingParameters(Ah,this._customShadingParameters)}switchToPlanner(e){Dh.Mode3D,this.configuratorMode=!1,e===Dh.Mode3D?this._sceneRenderer.setQualityMapAndShadingParameters(Rh,this._customShadingParametersMoc):this._sceneRenderer.setQualityMapAndShadingParameters(Eh,null)}updateBounds(e){e&&(this._boundingBox.copy(e),this._boundingBoxNeedsUpdate=!0)}movingCameraStarts(){var e;this._movingCamera=!0,null===(e=this._fpsCounter)||void 0===e||e.start()}movingCameraStops(){this._movingCamera=!1}highlightObjects(e){this._sceneRenderer.selectObjects(e)}render(e,t){var n;this._doUpdatesBeforeRender(e,t);const s=Oh.updateNearAndFarPlaneOfPerspectiveCamera?this.createRenderCamera(t):t;if(this._sceneRenderer.render(e,s),this._movingCamera&&this._fpsCounter){null===(n=this._fpsCounter)||void 0===n||n.update();const e=this._sceneRenderer.getQualityLevel(),t=this._fpsCounter.getFps();t>0&&t<30&&"low"!==e&&("highest"===e?this.sceneRenderer.setQualityLevel("high"):"high"===e?this.sceneRenderer.setQualityLevel("medium"):"medium"===e&&this.sceneRenderer.setQualityLevel("low"),this._fpsCounter.reset())}}_doUpdatesBeforeRender(e,t){this._boundingBoxNeedsUpdate&&(this._sceneRenderer.updateBounds(this._boundingBox,!1),this._boundingBoxNeedsUpdate=!1),this._cacheNeedsUpdate&&(this._sceneRenderer.clearCache(),this._cacheNeedsUpdate=!1),this._shadowNeedsUpdate&&(this._sceneRenderer.forceShadowUpdates(this._bakedGroundShadowNeedsUpdate),this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1),Oh.rectAreaLightsNeedsUpdate&&this.updateRectAreaLight(e),t.updateMatrixWorld(),(t instanceof X||t instanceof Q)&&t.updateProjectionMatrix(),this._sceneRenderer.enableObjectSelection=!this._movingCamera&&this._cameraType!==ze.CAMERA_FP}createRenderCamera(e){const t=e.clone();return this.configuratorMode&&t instanceof X&&(this._sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(t,120),t.updateProjectionMatrix()),t}showGUI(e){const t=Zi();this.SceneRendererGUI.addGUI(t,e)}clear(){this.renderer.clear()}}e("a7",Oh),Oh.enableRectAreaLightShadow=!0,Oh.rectAreaLightsNeedsUpdate=!1,Oh.updateNearAndFarPlaneOfPerspectiveCamera=!1;class Lh{_getRenderer(){const e=this._globalInitData.e2e,t=this._globalInitData.e2eRoomleRendererForImages;if(!this._imageRenderer){const t=new qt({antialias:!e,alpha:!0});t.outputColorSpace=S,t.autoClear=!0,t.setSize(1024,1024),t.outputColorSpace=S,t.autoClear=!1,t.shadowMap.enabled=!0,t.shadowMap.type=Ut,this._imageRenderer=t}return e&&!t?this._imageRenderer:(this._roomleRenderer||(this._roomleRenderer=new Oh(this._imageRenderer,1024,1024),this._roomleRenderer.setQualityMap(wh),this._roomleRenderer.setSize(1024,1024)),this._roomleRenderer)}switchToPlannerSettings(){const e=this._getRenderer();e instanceof Oh&&e.switchToPlanner(Dh.Mode3D)}switchToConfiguratorSettings(){const e=this._getRenderer();e instanceof Oh&&e.switchToConfigurator()}updateBounds(e){const t=this._getRenderer();t instanceof Oh&&t.updateBounds(e)}static getCameraTargetForBBox(e,t=0){if(!e){const e=new r;return{center:e,bounds:e,diagonal:0}}const n=e.getSize(new r);return n.addScalar(t),{center:e.getCenter(new r),bounds:n,diagonal:Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2))}}preparePerspectiveImage(e,t,n,s,i={},a=0,r){return new Promise(o=>{const{size:l=1024,showDimensions:h}=i,d=this._getRenderer();d.setSize(l,l);const c=e.fog?e.fog.clone():null,u=e.background?e.background.clone():null;e.background=null,e.fog=null,n.layers.disable(2),n.layers.disable(6),n.layers.disable(5),h?n.layers.enable(8):n.layers.disable(8);const p=-30+vs(a);Lh.placeCameraForPerspectiveImage(n,s,-20,p),r&&(n.updateMatrixWorld(!0),r(n));const m=this._render(d,e,t,n);n.layers.enable(2),n.layers.enable(6),n.layers.enable(5),e.background=u,e.fog=c,o({image:m,width:l,height:l,blob:null})})}renderPerspectiveImage(e,t,n,s){return new Promise(i=>{s||(s=1024);const a=this._getRenderer();a.setSize(s,s);const r=e.fog?e.fog.clone():null,o=e.background?e.background.clone():null;e.background=null,e.fog=null,t.layers.disable(2),t.layers.disable(6),t.layers.disable(5),n?Lh.placeCameraForPerspectiveImage(t,n,-20,-30):(t.aspect=1,t.updateProjectionMatrix());const l=this._render(a,e,null,t);t.layers.enable(2),t.layers.enable(6),t.layers.enable(5),e.background=o,e.fog=r,i({image:l,width:s,height:s,blob:null})})}static placeCameraForPerspectiveImage(e,t,n,s){e.far=1e3,e.fov=15,e.aspect=1,e.position.copy(t.center),e.rotation.set(0,0,0),e.rotateY(_s(s)),e.rotateX(_s(n)),e.translateZ(3.8*t.diagonal),e.updateProjectionMatrix()}prepareTopImage(e,t,n,s={}){const{showDimensions:i=!1}=s;return new Promise(s=>{const a=this._getRenderer();let r=new Q(-n.bounds.x/2,n.bounds.x/2,n.bounds.z/2,-n.bounds.z/2,.5);r.position.copy(n.center),r.rotateX(_s(-90)),r.translateZ(n.bounds.y+1),r.far=r.position.y+.5,r.layers.mask=65535;let o=200*n.bounds.x,l=200*n.bounds.z;if(o>4096||l>4096){let e=0;o>4096?e=o/4096:l>4096&&(e=l/4096),o/=e,l/=e}a.setSize(o,l);let h=e.fog?e.fog.clone():null,d=e.background?e.background.clone():null;e.background=null,e.fog=null,r.layers.disable(2),r.layers.disable(6),r.layers.disable(5),i?r.layers.enable(8):r.layers.disable(8);const c=this._render(a,e,t,r);r.layers.enable(2),r.layers.enable(6),r.layers.enable(5),e.background=d,e.fog=h,s({image:c,width:o,height:l,blob:null})})}_render(e,t,n,s){const i=e instanceof qt?e:e.renderer;e instanceof qt||(e.forceShadowUpdates(!0),e.render(t,s)),e.render(t,s),n&&(i.autoClear=!1,i.clearDepth(),i.render(n,s),i.autoClear=!0);const a=i.domElement.toDataURL();return i.clear(),a}}e("s",Lh),on([hn],Lh.prototype,"_globalInitData",void 0);const kh=e=>new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}),Uh=(e,t)=>(e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},kh(e.transaction));class Bh{constructor(e){this._creator_=e,this.configStore=this._createStore("rml-idb","rml-config-store")}get allStores(){return[this.configStore]}_getValue(e,t){return t("readonly",t=>kh(t.get(e)))}_setValue(e,t,n){return n("readwrite",n=>(n.put(t,e),kh(n.transaction)))}_getEntries(e){return e("readonly",async t=>{if(t.getAll&&t.getAllKeys){const[e,n]=await Promise.all([kh(t.getAllKeys()),kh(t.getAll())]);return e.map((e,t)=>[e,n[t]])}const n=[];return await e("readonly",async e=>{await Uh(e,e=>n.push([e.key,e.value]))}),n})}deleteValue(e,t){return t("readwrite",t=>(t.delete(e),kh(t.transaction)))}_createStore(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const s=kh(n);return async(e,n)=>n((await s).transaction(t,e).objectStore(t))}getKey(...e){return e.join("_")}async setValue(e,t,n){const s=en(),i={id:e,data:t,lastModified:(new Date).toISOString(),referrer:s};await this._setValue(e,i,n),this._initData.debug}getValue(e,t){return this._getValue(e,t)}clearStore(e){return e("readwrite",e=>(e.clear(),kh(e.transaction)))}async pruneOldEntries(){for(const e of this.allStores){const t=await this._getEntries(e);for(const n of t){const t=n[1].lastModified,s=(new Date).toISOString(),i=new Date(s).getTime()-new Date(t).getTime();Math.floor(i/864e5)>30&&await this.deleteValue(n[0],e)}}}}on([hn],Bh.prototype,"_initData",void 0);const Nh=e("I",[new Yt("error-handler",class{constructor(){this._listeners={}}_subscribe(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}subscribe(e,t){this._subscribe(e,t)}dispatch(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let s=n.length;for(let e=0;e<s;e++){const s=n[e];s.apply(s,t)}}unsubscribe(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let s=n.length;for(let e=0;e<s;e++)if(n[e]===t)return n.splice(e,1),s--,void e--}softReject(e,t,n){return this.dispatch(n,[t]),e()}}),new Yt("form-data-util",Zt),new Yt("hdr-environment-loader",class{constructor(e){this._creator_=e;const t=new h("#DDDDDD");this._environmentMap=((e,t,n,s)=>{const i=new we;i.format=be,i.generateMipmaps=!1;for(let s=0;s<6;++s){const a=Bi(e,t,n,1);a.format=i.format,a.type=i.type,a.minFilter=i.minFilter,a.magFilter=i.magFilter,a.generateMipmaps=i.generateMipmaps,a.needsUpdate=!0,i.images[s]=a}return i.needsUpdate=!0,i})(t.r,t.g,t.b)}async loadUrl(e,t){const n=t.toLowerCase();this._environmentMap=n.endsWith(".exr")?await this._loadExr(t):await this._loadRgbe(t),this._environmentMap.mapping=xt;const s={url:t,environmentMap:this._environmentMap};return this._envChangedCallback(s),s}_loadExr(e){var t;return this._exrLoader=null!==(t=this._exrLoader)&&void 0!==t?t:new ul,this._exrLoader.setPath(e.startsWith("http")?"":n()),this._exrLoader.loadAsync(e)}_loadRgbe(e){var t;return this._rgbeLoader=null!==(t=this._rgbeLoader)&&void 0!==t?t:new pl,this._rgbeLoader.setPath(e.startsWith("http")?"":n()),this._rgbeLoader.loadAsync(e)}registerEnvironmentChangedCallback(e){this._envChangedCallback=e}}),new Yt("static-item-loader",class{constructor(e){this._gltfLoaderGuard=new _n,this._creator_=e,this._initLoaders()}_initLoaders(){this._gltfLoader=new yn;const e=new ps,t=e._loadLibrary.bind(e._loadLibrary);e._loadLibrary=(e,s)=>{const i=gs[e];if(!i)throw new Error('Can not load draco dependency "'+e+'" did three.js update DracoLoader lib? Available files'+JSON.stringify(gs));return t(n()+i,s)},e.setDecoderConfig({type:"wasm"}),this._gltfLoader.setDRACOLoader(e),this._gltfLoaderGuard.resolve(this._gltfLoader)}async loadGLB(e,t,n,s,i,a,r,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.load(e,e=>{l(this._handleGLTFScene("GLB",e,t,n,s,i,a,r))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}async loadGLTF(e,t,n,s,i,a,r,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.parse(e,null,e=>{l(this._handleGLTFScene("GLTF",e,t,n,s,i,a,r))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}_handleGLTFScene(e,t,n,s,i,a,o,l){if(!t||!t.scene||!t.scene.children||0===t.scene.children.length)return null;n&&t.scene.position.copy(n),s&&(t.scene.rotation.y=s);const d=new ge;if(d.setFromObject(t.scene),i){const{x:e,y:n,z:s}=d.getSize(new r);let a=new r(i.x/e,i.y/n,i.z/s);t.scene.scale.copy(a)}return a&&t.scene.scale.multiply(a),t.scene.type=e,t.scene.traverse(e=>{if(e instanceof z){if(e.layers.set(3),e.material instanceof N){const t=e.material;if(l&&o&&o>0){let e=new h(o);t.color=e.copySRGBToLinear(e),t.roughness=.5,t.metalness=.1}t.needsUpdate=!0}e.castShadow=!0,e.receiveShadow=!0}}),{boundingBox:d,scene:t.scene}}},0),new Yt("form-data-util",Zt),new Yt("single-promise-factory",class{constructor(e){this._promises=new Map,this._creator_=e}create(e,t,n){return new Promise((s,i)=>{let a=this._promises.get(e),r=!0;if(!a){const t=new Map;this._promises.set(e,t),a=this._promises.get(e),r=!1}a.get(t)||(a.set(t,[]),r=!1);const o=a.get(t);o.push({resolve:s,reject:i}),a.set(t,o);const l=()=>{a.delete(t),0===a.size&&this._promises.delete(e)};r||new Promise(n).then(e=>{a.get(t).forEach(({resolve:t})=>t(e)),l()},e=>{a.get(t).forEach(({reject:t})=>t(e)),l()})})}},1),new Yt("dynamic-light-setting-loader",$t),new Yt("network-layer",rn),new Yt("local-storage",class{constructor(e){this._context_=e}get _localStorage(){let e=null;try{e=window.localStorage}catch(e){console.error(e)}return e}getItem(e){if(!this._localStorage)return null;const t=this._localStorage.getItem(e);try{return JSON.parse(t)}catch(e){return t}}setItem(e,t){if(this._localStorage)try{const n=JSON.stringify(t);this._localStorage.setItem(e,n)}catch(e){console.error(e)}}}),new Yt("network-layer",rn),new Yt("kernel-io",cn,0),new Yt("data-syncer",fn),new Yt("memory-manager",class{constructor(){this._configurationStringSet=new Set,this._singleLoadCounter=0}loadingConfigurationString(){this._singleLoadCounter+=1}loadingConfiguration(e){this._configurationStringSet.add(e),this._singleLoadCounter+=1}shouldHardReset(){return this._configurationStringSet.size>=15||this._singleLoadCounter>=30}executedHardReset(){this._configurationStringSet.clear(),this._singleLoadCounter=0}}),new Yt("life-cycle-manager",class{constructor(){this._listeners=[]}addEventListener(e){this._listeners.push(e)}removeEventListener(e){const t=this._listeners;let n=t.length;if(n)for(let s=0;s<n;s++)t[s]===e&&(t.splice(s,1),s--,n--)}pause(){this._listeners.forEach(e=>e.pause())}resume(){this._listeners.forEach(e=>e.resume())}destroy(){this._listeners.forEach(e=>e.destroy())}},1),new Yt("local-storage-helper",fs),new Yt("cache-holder",class{constructor(){this._componentCache=new Map,this._geometryCache=new Map,this._materialCache=new Map}get componentCache(){return this._componentCache}get geometryCache(){return this._geometryCache}get materialCache(){return this._materialCache}clear(){for(const e of this._componentCache.values())ta(e);for(const e of this._materialCache.values())ia(e);for(const e of this._geometryCache.values())sa(e);this._componentCache.clear(),this._geometryCache.clear(),this._materialCache.clear()}},0),new Yt("kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Yt("configurator-kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}updatePossibleChildren(e,t,n){this._callbackListener.forEach(s=>s.updatePossibleChildren(e,t,n))}updateParameters(e,t,n,s){this._callbackListener.forEach(i=>i.updateParameters(e,t,n,s))}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Yt("configurator-context",class{constructor(){this.planObjectId=0,this.planElementId=0,this.rootComponentId=0,this.dockingRootComponentId=0,this.baseContext=null,this.rootComponentParametersAsGlobal=!1,this.lastLoadedRapiId=null,this.lastLoadedPlanId=null,this.selectedRuntimeComponentIds=[],this.selectionMode="standard"}get selectedRuntimeComponentId(){return this.selectedRuntimeComponentIds.length>0?this.selectedRuntimeComponentIds[0]:null}},1),new Yt("init-data",Na,1),new Yt("global-init-data",Ga,0),new Yt("global-callback",za,0),new Yt("dom-helper",Va,1),new Yt("unit-formatter",Bo,0),new Yt("plugin-system",Ha,1),new Yt("configurator-mesh-generator",qa),new Yt("configurator-input-manager",class extends $a{},1),new Yt("selection-handler",class extends Xa{constructor(){super(...arguments),this._selectionMode="standard",this._selectedComponents=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedComponents.size&&this._selectedComponents.forEach((e,t)=>{e.deselect(),this._selectedComponents.delete(t),this.dispatchEvent(1,new er({component:e}))})}_checkStandard(e){this._selectedComponents.has(e.runtimeId)?this.dispatchEvent(0,new er({component:e,consecutive:!0})):(this._selectedComponents.size>0&&this._selectedComponents.forEach((e,t)=>{this._selectedComponents.delete(t),this.dispatchEvent(1,new er({component:e,resetCamera:!1}))}),this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new er({component:e,consecutive:!1})))}_checkMulti(e){if(this._selectedComponents.has(e.runtimeId))return this._selectedComponents.delete(e.runtimeId),void this.dispatchEvent(1,new er({component:e,resetCamera:0===this._selectedComponents.size}));this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new er({component:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedComponents.size>0}getSelectedRuntimeComponentIds(){let e=[];return this._selectedComponents.forEach(t=>e.push(t.runtimeId)),e}isSelected(e){return this._selectedComponents.has(e.runtimeId)}},1),new Yt("component-dimensioning-helper",or,1),new Yt("component-dimensioning-helper",or,1),new Yt("planner-kernel-access",Io),new Yt("planner-mesh-generator",Do,1),new Yt("unit-formatter",Bo),new Yt("configurator-history",No,1),new Yt("roomle-planner-ui-callback",class extends ja{constructor(e){super(e),this.onItemsLoaded=()=>{},this.onCameraChanged=e=>{},this.onCameraIdle=()=>{},this.onTotalFloorAreaChanged=e=>{},this.onPlanInteractionHandlerCreated=e=>{},this.onPlannerKernelIsReady=e=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onSelectionChange=(e,t,n,s,i)=>{},this.onSelectionCancel=e=>{},this.onPlanChanged=()=>{},this.onPlanElementChanged=(e,t)=>{},this.onCompletelyLoaded=()=>{},this.onRotationCancel=()=>{},this.onHistoryChange=(e,t)=>{},this.onUpdateWallDimensions=e=>{},this.onUpdateMeasurementLineDimensions=e=>{},this.onUpdateConstructionElementsMeasurements=e=>{},this.onUpdateObjectMeasurements=e=>{},this.disableWallDimensions=()=>{},this.onUpdatePlanObjectPositions=e=>{},this.onDrawCancel=()=>{},this.onHandlerSwitchedPlans=()=>{},this.onDragElementStart=()=>{},this.onDragElementEnd=()=>{},this.onClickElement=e=>{},this.onMultiSelectionChange=e=>{},this.onSelectionModeChange=e=>{},this.onMeasurementLineStateChange=e=>{},this.onFloorPlanAreasUpdated=e=>{}}}),new Yt("configurator-ui-callbacks",class extends ja{constructor(e){super(e),this.onKernelIsReady=null,this.onComponentPositionsUpdated=null,this.onUpdateParameters=e=>{},this.onUpdatePossibleChildren=(e,t)=>{},this.onUpdatePrice=(e,t)=>{},this.onSelectionChange=(e,t,n,s)=>{},this.onSelectionCancel=()=>{},this.onPartListUpdate=(e,t)=>{},this.onBoundsUpdate=e=>{},this.onLoadConfiguration=()=>{},this.onConfigurationReady=(e,t,n)=>{},this.onOpenTag=e=>{},this.onOpenAddOns=()=>{},this.onClickOutside=()=>{},this.onNoDockingsAvailable=()=>{},this.onUiIntersectionChange=e=>{},this.onZoomChange=(e,t)=>{},this.onZoomToComponent=()=>{},this.onDimensionsVisibilityChange=e=>{},this.onErrorDueToOffline=e=>{},this.onError=e=>{},this.onElementDocked=(e,t)=>{},this.onDockingsPreviewRemoved=()=>{},this.onConfigurationHasChildren=e=>{},this.onTrackTiming=(e,t,n,s)=>{},this.onUserInitiatedDockDone=(e,t,n,s,i)=>{},this.onAddonPlusHover=()=>{},this.onAddonPlusHoverOff=()=>{},this.onAddonPlusShown=()=>{},this.onAddonPlusHidden=()=>{},this.onContentProblem=e=>{},this.onSyncStarted=()=>{},this.onSyncDone=()=>{},this.onOpenFloorMaterials=()=>{},this.onOpenPartList=()=>{},this.onComponentLoadError=(e,t)=>{},this.onConfigurationLoadError=()=>{},this.onChangeTypeChangeTag=e=>{},this.onRemoveTypeChangeTag=e=>{},this.onConfigurationLabelChange=(e,t,n)=>{},this.onMemoryCorruption=()=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onConfigurationSaved=e=>{},this.onCameraPositionChanges=()=>{},this.onHistoryChange=(e,t)=>{},this.onClickComponent=e=>{},this.onRequestExternalMesh=(e,t)=>{},this.onGeometryReady=e=>{},this.onGeometryNotReady=e=>{}}},1),new Yt("roomle-tools-core",Fo,0),new Yt("image-renderer",Lh,0),new Yt("idb-manager",Bh,0),new Yt("camera-behaviour-state",class{constructor(e){this._lastPlanBounds=new ge,this._creator_=e}isWithinPlanBounds(e,t){const n=this._lastPlanBounds.containsPoint(e);return t&&this._lastPlanBounds.copy(t),n}},1)]);class Fh{static _ensureContainer(){window.__RML__DI__||(window.__RML__DI__=new Xt,window.__RML__DI__.addDependencyInjectionAssignments(Nh))}static setup(e){Fh.addToContainer(e)}static lookup(e,t){return window.__RML__DI__?window.__RML__DI__.lookup(e,t):null}static getContext(e){return Fh._ensureContainer(),window.__RML__DI__.getContext(e)}static cleanUp(e){return window.__RML__DI__?window.__RML__DI__.cleanUp(e):null}static addToContainer(e){Fh._ensureContainer(),window.__RML__DI__.addDependencyInjectionAssignments(e)}}e("b",Fh)}}}));
9
- //# sourceMappingURL=roomle-dependency-injection-a1a06d1e.nomodule.js.map
8
+ var Go=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(Go(""))}catch(e){Go=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var jo=Uint8Array,zo=Uint16Array,Vo=Uint32Array,Ho=new jo([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wo=new jo([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ko=new jo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qo=function(e,t){for(var n=new zo(31),s=0;s<31;++s)n[s]=t+=1<<e[s-1];var i=new Vo(n[30]);for(s=1;s<30;++s)for(var a=n[s];a<n[s+1];++a)i[a]=a-n[s]<<5|s;return[n,i]},Xo=qo(Ho,2),Yo=Xo[0],Qo=Xo[1];Yo[28]=258,Qo[258]=28;for(var Zo=qo(Wo,0)[0],Jo=new zo(32768),$o=0;$o<32768;++$o){var el=(43690&$o)>>>1|(21845&$o)<<1;el=(61680&(el=(52428&el)>>>2|(13107&el)<<2))>>>4|(3855&el)<<4,Jo[$o]=((65280&el)>>>8|(255&el)<<8)>>>1}var tl=function(e,t,n){for(var s=e.length,i=0,a=new zo(t);i<s;++i)++a[e[i]-1];var r,o=new zo(t);for(i=0;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;if(n){r=new zo(1<<t);var l=15-t;for(i=0;i<s;++i)if(e[i])for(var h=i<<4|e[i],d=t-e[i],c=o[e[i]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)r[Jo[c]>>>l]=h}else for(r=new zo(s),i=0;i<s;++i)e[i]&&(r[i]=Jo[o[e[i]-1]++]>>>15-e[i]);return r},nl=new jo(288);for($o=0;$o<144;++$o)nl[$o]=8;for($o=144;$o<256;++$o)nl[$o]=9;for($o=256;$o<280;++$o)nl[$o]=7;for($o=280;$o<288;++$o)nl[$o]=8;var sl=new jo(32);for($o=0;$o<32;++$o)sl[$o]=5;var il=tl(nl,9,1),al=tl(sl,5,1),rl=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ol=function(e,t,n){var s=t/8|0;return(e[s]|e[s+1]<<8)>>(7&t)&n},ll=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},hl=new jo(0);function dl(e,t){return function(e,t,n){var s=e.length;if(!s||n&&!n.l&&s<5)return t||new jo(0);var i=!t||n,a=!n||n.i;n||(n={}),t||(t=new jo(3*s));var r,o=function(e){var n=t.length;if(e>n){var s=new jo(Math.max(2*n,e));s.set(t),t=s}},l=n.f||0,h=n.p||0,d=n.b||0,c=n.l,u=n.d,p=n.m,m=n.n,g=8*s;do{if(!c){n.f=l=ol(e,h,1);var f=ol(e,h+1,3);if(h+=3,!f){var _=e[(A=((r=h)/8|0)+(7&r&&1)+4)-4]|e[A-3]<<8,v=A+_;if(v>s){if(a)throw"unexpected EOF";break}i&&o(d+_),t.set(e.subarray(A,v),d),n.b=d+=_,n.p=h=8*v;continue}if(1==f)c=il,u=al,p=9,m=5;else{if(2!=f)throw"invalid block type";var w=ol(e,h,31)+257,b=ol(e,h+10,15)+4,y=w+ol(e,h+5,31)+1;h+=14;for(var S=new jo(y),x=new jo(19),P=0;P<b;++P)x[Ko[P]]=ol(e,h+3*P,7);h+=3*b;var M=rl(x),C=(1<<M)-1,T=tl(x,M,1);for(P=0;P<y;){var A,R=T[ol(e,h,C)];if(h+=15&R,(A=R>>>4)<16)S[P++]=A;else{var E=0,I=0;for(16==A?(I=3+ol(e,h,3),h+=2,E=S[P-1]):17==A?(I=3+ol(e,h,7),h+=3):18==A&&(I=11+ol(e,h,127),h+=7);I--;)S[P++]=E}}var D=S.subarray(0,w),O=S.subarray(w);p=rl(D),m=rl(O),c=tl(D,p,1),u=tl(O,m,1)}if(h>g){if(a)throw"unexpected EOF";break}}i&&o(d+131072);for(var k=(1<<p)-1,L=(1<<m)-1,U=h;;U=h){var B=(E=c[ll(e,h)&k])>>>4;if((h+=15&E)>g){if(a)throw"unexpected EOF";break}if(!E)throw"invalid length/literal";if(B<256)t[d++]=B;else{if(256==B){U=h,c=null;break}var N=B-254;if(B>264){var F=Ho[P=B-257];N=ol(e,h,(1<<F)-1)+Yo[P],h+=F}var G=u[ll(e,h)&L],j=G>>>4;if(!G)throw"invalid distance";if(h+=15&G,O=Zo[j],j>3&&(F=Wo[j],O+=ll(e,h)&(1<<F)-1,h+=F),h>g){if(a)throw"unexpected EOF";break}i&&o(d+131072);for(var z=d+N;d<z;d+=4)t[d]=t[d-O],t[d+1]=t[d+1-O],t[d+2]=t[d+2-O],t[d+3]=t[d+3-O];d=z}}n.l=c,n.p=U,n.b=d,c&&(l=1,n.m=p,n.d=u,n.n=m)}while(!l);return d==t.length?t:function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var s=new(e instanceof zo?zo:e instanceof Vo?Vo:jo)(n-t);return s.set(e.subarray(t,n)),s}(t,0,d)}((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var cl="undefined"!=typeof TextDecoder&&new TextDecoder;try{cl.decode(hl,{stream:!0})}catch(e){}class ul extends _t{constructor(e){super(e),this.type=vt}parse(e){const t=Math.pow(2.7182818,2.2),n={l:0,c:0,lc:0};function s(e,t,s,i,a){for(;s<e;)t=t<<8|L(i,a),s+=8;s-=e,n.l=t>>s&(1<<e)-1,n.c=t,n.lc=s}const i=new Array(59);function a(e){return 63&e}function r(e){return e>>6}const o={c:0,lc:0};function l(e,t,n,s){e=e<<8|L(n,s),t+=8,o.c=e,o.lc=t}const h={c:0,lc:0};function d(e,t,n,s,i,a,r,d,c){if(e==t){s<8&&(l(n,s,i,a),n=o.c,s=o.lc);let e=n>>(s-=8);if(e=new Uint8Array([e])[0],d.value+e>c)return!1;const t=r[d.value-1];for(;e-- >0;)r[d.value++]=t}else{if(!(d.value<c))return!1;r[d.value++]=e}h.c=n,h.lc=s}function c(e){return 65535&e}function u(e){const t=c(e);return t>32767?t-65536:t}const p={a:0,b:0};function m(e,t){const n=u(e),s=u(t),i=n+(1&s)+(s>>1),a=i,r=i-s;p.a=a,p.b=r}function g(e,t){const n=c(e),s=c(t),i=n-(s>>1)&65535,a=s+i-32768&65535;p.a=a,p.b=i}function f(e,t,n,s,i,a,r){const o=r<16384,l=n>i?i:n;let h,d,c=1;for(;c<=l;)c<<=1;for(c>>=1,h=c,c>>=1;c>=1;){d=0;const r=d+a*(i-h),l=a*c,u=a*h,f=s*c,_=s*h;let v,w,b,y;for(;d<=r;d+=u){let i=d;const a=d+s*(n-h);for(;i<=a;i+=_){const n=i+f,s=i+l,a=s+f;o?(m(e[i+t],e[s+t]),v=p.a,b=p.b,m(e[n+t],e[a+t]),w=p.a,y=p.b,m(v,w),e[i+t]=p.a,e[n+t]=p.b,m(b,y),e[s+t]=p.a,e[a+t]=p.b):(g(e[i+t],e[s+t]),v=p.a,b=p.b,g(e[n+t],e[a+t]),w=p.a,y=p.b,g(v,w),e[i+t]=p.a,e[n+t]=p.b,g(b,y),e[s+t]=p.a,e[a+t]=p.b)}if(n&c){const n=i+l;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}if(i&c){let i=d;const a=d+s*(n-h);for(;i<=a;i+=_){const n=i+f;o?m(e[i+t],e[n+t]):g(e[i+t],e[n+t]),v=p.a,e[n+t]=p.b,e[i+t]=v}}h=c,c>>=1}return d}function _(e,t,c,u,p,m){const g=c.value,f=k(t,c),_=k(t,c);c.value+=4;const v=k(t,c);if(c.value+=4,f<0||f>=65537||_<0||_>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const w=new Array(65537),b=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(b),function(e,t,a,r,o,l){const h=t;let d=0,c=0;for(;r<=o;r++){if(h.value-t.value>a)return!1;s(6,d,c,e,h);const i=n.l;if(d=n.c,c=n.lc,l[r]=i,63==i){if(h.value-t.value>a)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,c,e,h);let i=n.l+6;if(d=n.c,c=n.lc,r+i>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)l[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)l[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)i[e]=0;for(let t=0;t<65537;++t)i[e[t]]+=1;let t=0;for(let e=58;e>0;--e){const n=t+i[e]>>1;i[e]=t,t=n}for(let t=0;t<65537;++t){const n=e[t];n>0&&(e[t]=n|i[n]++<<6)}}(l)}(e,c,u-(c.value-g),f,_,w),v>8*(u-(c.value-g)))throw new Error("Something wrong with hufUncompress");!function(e,t,n,s){for(;t<=n;t++){const n=r(e[t]),i=a(e[t]);if(n>>i)throw new Error("Invalid table entry");if(i>14){const e=s[n>>i-14];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=new Array(1);e.p[e.lit-1]=t}else if(i){let e=0;for(let a=1<<14-i;a>0;a--){const a=s[(n<<14-i)+e];if(a.len||a.p)throw new Error("Invalid table entry");a.len=i,a.lit=t,e++}}}}(w,f,_,b),function(e,t,n,s,i,c,u,p,m){let g=0,f=0;const _=u,v=Math.trunc(s.value+(i+7)/8);for(;s.value<v;)for(l(g,f,n,s),g=o.c,f=o.lc;f>=14;){const i=t[g>>f-14&16383];if(i.len)f-=i.len,d(i.lit,c,g,f,n,s,p,m,_),g=h.c,f=h.lc;else{if(!i.p)throw new Error("hufDecode issues");let t;for(t=0;t<i.lit;t++){const u=a(e[i.p[t]]);for(;f<u&&s.value<v;)l(g,f,n,s),g=o.c,f=o.lc;if(f>=u&&r(e[i.p[t]])==(g>>f-u&(1<<u)-1)){f-=u,d(i.p[t],c,g,f,n,s,p,m,_),g=h.c,f=h.lc;break}}if(t==i.lit)throw new Error("hufDecode issues")}}const w=8-i&7;for(g>>=w,f-=w;f>0;){const e=t[g<<14-f&16383];if(!e.len)throw new Error("hufDecode issues");f-=e.len,d(e.lit,c,g,f,n,s,p,m,_),g=h.c,f=h.lc}}(w,b,e,c,v,_,m,p,{value:0})}function v(e){for(let t=1;t<e.length;t++){const n=e[t-1]+e[t]-128;e[t]=n}}function b(e,t){let n=0,s=Math.floor((e.length+1)/2),i=0;const a=e.length-1;for(;!(i>a||(t[i++]=e[n++],i>a));)t[i++]=e[s++]}function y(e){let t=e.byteLength;const n=new Array;let s=0;const i=new DataView(e);for(;t>0;){const e=i.getInt8(s++);if(e<0){const a=-e;t-=a+1;for(let e=0;e<a;e++)n.push(i.getUint8(s++))}else{const a=e;t-=2;const r=i.getUint8(s++);for(let e=0;e<a+1;e++)n.push(r)}}return n}function S(e,t,n){let s,i=1;for(;i<64;)s=t[e.value],65280==s?i=64:s>>8==255?i+=255&s:(n[i]=s,i++),e.value++}function x(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),s=.5*Math.cos(3.14159/8),i=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),r=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),h=new Array(4),d=new Array(4),c=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=s*e[p+2],l[1]=r*e[p+2],l[2]=s*e[p+6],l[3]=r*e[p+6],h[0]=n*e[p+1]+i*e[p+3]+a*e[p+5]+o*e[p+7],h[1]=i*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],h[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+i*e[p+7],h[3]=o*e[p+1]-a*e[p+3]+i*e[p+5]-n*e[p+7],d[0]=t*(e[p+0]+e[p+4]),d[3]=t*(e[p+0]-e[p+4]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[p+0]=c[0]+h[0],e[p+1]=c[1]+h[1],e[p+2]=c[2]+h[2],e[p+3]=c[3]+h[3],e[p+4]=c[3]-h[3],e[p+5]=c[2]-h[2],e[p+6]=c[1]-h[1],e[p+7]=c[0]-h[0]}for(let u=0;u<8;++u)l[0]=s*e[16+u],l[1]=r*e[16+u],l[2]=s*e[48+u],l[3]=r*e[48+u],h[0]=n*e[8+u]+i*e[24+u]+a*e[40+u]+o*e[56+u],h[1]=i*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],h[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+i*e[56+u],h[3]=o*e[8+u]-a*e[24+u]+i*e[40+u]-n*e[56+u],d[0]=t*(e[u]+e[32+u]),d[3]=t*(e[u]-e[32+u]),d[1]=l[0]+l[3],d[2]=l[1]-l[2],c[0]=d[0]+d[1],c[1]=d[3]+d[2],c[2]=d[3]-d[2],c[3]=d[0]-d[1],e[0+u]=c[0]+h[0],e[8+u]=c[1]+h[1],e[16+u]=c[2]+h[2],e[24+u]=c[3]+h[3],e[32+u]=c[3]-h[3],e[40+u]=c[2]-h[2],e[48+u]=c[1]-h[1],e[56+u]=c[0]-h[0]}function P(e){for(let t=0;t<64;++t){const n=e[0][t],s=e[1][t],i=e[2][t];e[0][t]=n+1.5747*i,e[1][t]=n-.1873*s-.4682*i,e[2][t]=n+1.8556*s}}function M(e,n,s){for(let a=0;a<64;++a)n[s+a]=St.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(t,Math.abs(i)-1));var i}function C(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function T(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(y(t)),s=new Uint8Array(n.length);return v(n),b(n,s),new DataView(s.buffer)}function A(e){const t=dl(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return v(t),b(t,n),new DataView(n.buffer)}function R(e){const t=e.viewer,n={value:e.offset.value},s=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),i=new Uint8Array(8192);let a=0;const r=new Array(e.channels);for(let t=0;t<e.channels;t++)r[t]={},r[t].start=a,r[t].end=r[t].start,r[t].nx=e.width,r[t].ny=e.lines,r[t].size=e.type,a+=r[t].nx*r[t].ny*r[t].size;const o=j(t,n),l=j(t,n);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let e=0;e<l-o+1;e++)i[e+o]=U(t,n);const h=new Uint16Array(65536),d=function(e,t){let n=0;for(let s=0;s<65536;++s)(0==s||e[s>>3]&1<<(7&s))&&(t[n++]=s);const s=n-1;for(;n<65536;)t[n++]=0;return s}(i,h),c=k(t,n);_(e.array,t,n,c,s,a);for(let t=0;t<e.channels;++t){const e=r[t];for(let n=0;n<r[t].size;++n)f(s,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,d)}!function(e,t,n){for(let s=0;s<n;++s)t[s]=e[t[s]]}(h,s,a);let u=0;const p=new Uint8Array(s.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.channels;t++){const e=r[t],n=e.nx*e.size,i=new Uint8Array(s.buffer,2*e.end,2*n);p.set(i,u),u+=2*n,e.end+=n}return new DataView(p.buffer)}function E(e){const t=dl(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.lines*e.channels*e.width,s=1==e.type?new Uint16Array(n):new Uint32Array(n);let i=0,a=0;const r=new Array(4);for(let n=0;n<e.lines;n++)for(let n=0;n<e.channels;n++){let n=0;switch(e.type){case 1:r[0]=i,r[1]=r[0]+e.width,i=r[1]+e.width;for(let i=0;i<e.width;++i)n+=t[r[0]++]<<8|t[r[1]++],s[a]=n,a++;break;case 2:r[0]=i,r[1]=r[0]+e.width,r[2]=r[1]+e.width,i=r[2]+e.width;for(let i=0;i<e.width;++i)n+=t[r[0]++]<<24|t[r[1]++]<<16|t[r[2]++]<<8,s[a]=n,a++}}return new DataView(s.buffer)}function I(e){const t=e.viewer,n={value:e.offset.value},s=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),i={version:B(t,n),unknownUncompressedSize:B(t,n),unknownCompressedSize:B(t,n),acCompressedSize:B(t,n),dcCompressedSize:B(t,n),rleCompressedSize:B(t,n),rleUncompressedSize:B(t,n),rleRawSize:B(t,n),totalAcUncompressedCount:B(t,n),totalDcUncompressedCount:B(t,n),acCompression:B(t,n)};if(i.version<2)throw new Error("EXRLoader.parse: "+q.compression+" version "+i.version+" is unsupported");const a=new Array;let r=j(t,n)-2;for(;r>0;){const e=D(t.buffer,n),s=U(t,n),i=s>>2&3,o=new Int8Array([(s>>4)-1])[0],l=U(t,n);a.push({name:e,index:o,type:l,compression:i}),r-=e.length+3}const o=q.channels,l=new Array(e.channels);for(let t=0;t<e.channels;++t){const n=l[t]={},s=o[t];n.name=s.name,n.compression=0,n.decoded=!1,n.type=s.pixelType,n.pLinear=s.pLinear,n.width=e.width,n.height=e.lines}const h={idx:new Array(3)};for(let t=0;t<e.channels;++t){const e=l[t];for(let n=0;n<a.length;++n){const s=a[n];e.name==s.name&&(e.compression=s.compression,s.index>=0&&(h.idx[s.index]=t),e.offset=t)}}let d,c,u;if(i.acCompressedSize>0)switch(i.acCompression){case 0:d=new Uint16Array(i.totalAcUncompressedCount),_(e.array,t,n,i.acCompressedSize,d,i.totalAcUncompressedCount);break;case 1:const s=dl(e.array.slice(n.value,n.value+i.totalAcUncompressedCount));d=new Uint16Array(s.buffer),n.value+=i.totalAcUncompressedCount}if(i.dcCompressedSize>0){const t={array:e.array,offset:n,size:i.dcCompressedSize};c=new Uint16Array(A(t).buffer),n.value+=i.dcCompressedSize}i.rleRawSize>0&&(u=y(dl(e.array.slice(n.value,n.value+i.rleCompressedSize)).buffer),n.value+=i.rleCompressedSize);let p=0;const m=new Array(l.length);for(let e=0;e<m.length;++e)m[e]=new Array;for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)m[t].push(p),p+=l[t].width*e.type*2;!function(e,t,n,s,i,a){let r=new DataView(a.buffer);const o=n[e.idx[0]].width,l=n[e.idx[0]].height,h=Math.floor(o/8),d=Math.ceil(o/8),c=Math.ceil(l/8),u=o-8*(d-1),p=l-8*(c-1),m={value:0},g=new Array(3),f=new Array(3),_=new Array(3),v=new Array(3),w=new Array(3);for(let n=0;n<3;++n)w[n]=t[e.idx[n]],g[n]=n<1?0:g[n-1]+d*c,f[n]=new Float32Array(64),_[n]=new Uint16Array(64),v[n]=new Uint16Array(64*d);for(let t=0;t<c;++t){let a=8;t==c-1&&(a=p);let o=8;for(let e=0;e<d;++e){e==d-1&&(o=u);for(let e=0;e<3;++e)_[e].fill(0),_[e][0]=i[g[e]++],S(m,s,_[e]),b=_[e],(y=f[e])[0]=G(b[0]),y[1]=G(b[1]),y[2]=G(b[5]),y[3]=G(b[6]),y[4]=G(b[14]),y[5]=G(b[15]),y[6]=G(b[27]),y[7]=G(b[28]),y[8]=G(b[2]),y[9]=G(b[4]),y[10]=G(b[7]),y[11]=G(b[13]),y[12]=G(b[16]),y[13]=G(b[26]),y[14]=G(b[29]),y[15]=G(b[42]),y[16]=G(b[3]),y[17]=G(b[8]),y[18]=G(b[12]),y[19]=G(b[17]),y[20]=G(b[25]),y[21]=G(b[30]),y[22]=G(b[41]),y[23]=G(b[43]),y[24]=G(b[9]),y[25]=G(b[11]),y[26]=G(b[18]),y[27]=G(b[24]),y[28]=G(b[31]),y[29]=G(b[40]),y[30]=G(b[44]),y[31]=G(b[53]),y[32]=G(b[10]),y[33]=G(b[19]),y[34]=G(b[23]),y[35]=G(b[32]),y[36]=G(b[39]),y[37]=G(b[45]),y[38]=G(b[52]),y[39]=G(b[54]),y[40]=G(b[20]),y[41]=G(b[22]),y[42]=G(b[33]),y[43]=G(b[38]),y[44]=G(b[46]),y[45]=G(b[51]),y[46]=G(b[55]),y[47]=G(b[60]),y[48]=G(b[21]),y[49]=G(b[34]),y[50]=G(b[37]),y[51]=G(b[47]),y[52]=G(b[50]),y[53]=G(b[56]),y[54]=G(b[59]),y[55]=G(b[61]),y[56]=G(b[35]),y[57]=G(b[36]),y[58]=G(b[48]),y[59]=G(b[49]),y[60]=G(b[57]),y[61]=G(b[58]),y[62]=G(b[62]),y[63]=G(b[63]),x(f[e]);P(f);for(let t=0;t<3;++t)M(f[t],v[t],64*e)}let l=0;for(let s=0;s<3;++s){const i=n[e.idx[s]].type;for(let e=8*t;e<8*t+a;++e){l=w[s][e];for(let t=0;t<h;++t){const n=64*t+8*(7&e);r.setUint16(l+0*i,v[s][n+0],!0),r.setUint16(l+2*i,v[s][n+1],!0),r.setUint16(l+4*i,v[s][n+2],!0),r.setUint16(l+6*i,v[s][n+3],!0),r.setUint16(l+8*i,v[s][n+4],!0),r.setUint16(l+10*i,v[s][n+5],!0),r.setUint16(l+12*i,v[s][n+6],!0),r.setUint16(l+14*i,v[s][n+7],!0),l+=16*i}}if(h!=d)for(let e=8*t;e<8*t+a;++e){const t=w[s][e]+8*h*2*i,n=64*h+8*(7&e);for(let e=0;e<o;++e)r.setUint16(t+2*e*i,v[s][n+e],!0)}}}var b,y;const C=new Uint16Array(o);r=new DataView(a.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;const s=n[e.idx[t]].type;if(2==n[t].type)for(let e=0;e<l;++e){const n=w[t][e];for(let e=0;e<o;++e)C[e]=r.getUint16(n+2*e*s,!0);for(let e=0;e<o;++e)r.setFloat32(n+2*e*s,G(C[e]),!0)}}}(h,m,l,d,c,s);for(let t=0;t<l.length;++t){const n=l[t];if(!n.decoded)switch(n.compression){case 2:let i=0,a=0;for(let r=0;r<e.lines;++r){let e=m[t][i];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)s[e++]=u[a+t*n.width*n.height];a++}i++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(s.buffer)}function D(e,t){const n=new Uint8Array(e);let s=0;for(;0!=n[t.value+s];)s+=1;const i=(new TextDecoder).decode(n.slice(t.value,t.value+s));return t.value=t.value+s+1,i}function O(e,t){const n=e.getInt32(t.value,!0);return t.value=t.value+4,n}function k(e,t){const n=e.getUint32(t.value,!0);return t.value=t.value+4,n}function L(e,t){const n=e[t.value];return t.value=t.value+1,n}function U(e,t){const n=e.getUint8(t.value);return t.value=t.value+1,n}const B=function(e,t){let n;return n="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function N(e,t){const n=e.getFloat32(t.value,!0);return t.value+=4,n}function F(e,t){return St.toHalfFloat(N(e,t))}function G(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function j(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function z(e,t){return G(j(e,t))}function V(e,t,n,s,i){return"string"===s||"stringvector"===s||"iccProfile"===s?function(e,t,n){const s=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,s}(t,n,i):"chlist"===s?function(e,t,n,s){const i=n.value,a=[];for(;n.value<i+s-1;){const s=D(t,n),i=O(e,n),r=U(e,n);n.value+=3;const o=O(e,n),l=O(e,n);a.push({name:s,pixelType:i,pLinear:r,xSampling:o,ySampling:l})}return n.value+=1,a}(e,t,n,i):"chromaticities"===s?function(e,t){return{redX:N(e,t),redY:N(e,t),greenX:N(e,t),greenY:N(e,t),blueX:N(e,t),blueY:N(e,t),whiteX:N(e,t),whiteY:N(e,t)}}(e,n):"compression"===s?function(e,t){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][U(e,t)]}(e,n):"box2i"===s?function(e,t){return{xMin:k(e,t),yMin:k(e,t),xMax:k(e,t),yMax:k(e,t)}}(e,n):"lineOrder"===s?function(e,t){return["INCREASING_Y"][U(e,t)]}(e,n):"float"===s?N(e,n):"v2f"===s?function(e,t){return[N(e,t),N(e,t)]}(e,n):"v3f"===s?function(e,t){return[N(e,t),N(e,t),N(e,t)]}(e,n):"int"===s?O(e,n):"rational"===s?function(e,t){return[O(e,t),k(e,t)]}(e,n):"timecode"===s?function(e,t){return[k(e,t),k(e,t)]}(e,n):"preview"===s?(n.value+=i,"skipped"):void(n.value+=i)}const H=new DataView(e),W=new Uint8Array(e),K={value:0},q=function(e,t,n){const s={};if(20000630!=e.getUint32(0,!0))throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");s.version=e.getUint8(4);const i=e.getUint8(5);s.spec={singleTile:!!(2&i),longName:!!(4&i),deepFormat:!!(8&i),multiPart:!!(16&i)},n.value=8;let a=!0;for(;a;){const i=D(t,n);if(0==i)a=!1;else{const a=D(t,n),r=V(e,t,n,a,k(e,n));void 0===r?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${a}'.`):s[i]=r}}if(0!=(-5&i))throw console.error("THREE.EXRHeader:",s),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return s}(H,e,K),X=function(e,t,n,s,i){const a={size:0,viewer:t,array:n,offset:s,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,channels:e.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:e.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:w};switch(e.compression){case"NO_COMPRESSION":a.lines=1,a.uncompress=C;break;case"RLE_COMPRESSION":a.lines=1,a.uncompress=T;break;case"ZIPS_COMPRESSION":a.lines=1,a.uncompress=A;break;case"ZIP_COMPRESSION":a.lines=16,a.uncompress=A;break;case"PIZ_COMPRESSION":a.lines=32,a.uncompress=R;break;case"PXR24_COMPRESSION":a.lines=16,a.uncompress=E;break;case"DWAA_COMPRESSION":a.lines=32,a.uncompress=I;break;case"DWAB_COMPRESSION":a.lines=256,a.uncompress=I;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}if(a.scanlineBlockSize=a.lines,1==a.type)switch(i){case wt:a.getter=z,a.inputSize=2;break;case vt:a.getter=j,a.inputSize=2}else{if(2!=a.type)throw new Error("EXRLoader.parse: unsupported pixelType "+a.type+" for "+e.compression+".");switch(i){case wt:a.getter=N,a.inputSize=4;break;case vt:a.getter=F,a.inputSize=4}}a.blockCount=(e.dataWindow.yMax+1)/a.scanlineBlockSize;for(let e=0;e<a.blockCount;e++)B(t,s);a.outputChannels=3==a.channels?4:a.channels;const r=a.width*a.height*a.outputChannels;switch(i){case wt:a.byteArray=new Float32Array(r),a.channels<a.outputChannels&&a.byteArray.fill(1,0,r);break;case vt:a.byteArray=new Uint16Array(r),a.channels<a.outputChannels&&a.byteArray.fill(15360,0,r);break;default:console.error("THREE.EXRLoader: unsupported type: ",i)}return a.bytesPerLine=a.width*a.inputSize*a.channels,4==a.outputChannels?(a.format=be,a.colorSpace=w):(a.format=bt,a.colorSpace=yt),a}(q,H,W,K,this.type),Y={value:0},Q={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<X.height/X.scanlineBlockSize;e++){const t=k(H,K);X.size=k(H,K),X.lines=t+X.scanlineBlockSize>X.height?X.height-t:X.scanlineBlockSize;const n=X.size<X.lines*X.bytesPerLine?X.uncompress(X):C(X);K.value+=X.size;for(let t=0;t<X.scanlineBlockSize;t++){const s=t+e*X.scanlineBlockSize;if(s>=X.height)break;for(let e=0;e<X.channels;e++){const i=Q[q.channels[e].name];for(let a=0;a<X.width;a++){Y.value=(t*(X.channels*X.width)+e*X.width+a)*X.inputSize;const r=(X.height-1-s)*(X.width*X.outputChannels)+a*X.outputChannels+i;X.byteArray[r]=X.getter(n,Y)}}}}return{header:q,width:X.width,height:X.height,data:X.byteArray,format:X.format,colorSpace:X.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,s){return super.load(e,(function(e,n){e.colorSpace=n.colorSpace,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}),n,s)}}class pl extends _t{constructor(e){super(e),this.type=vt}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},n=function(e,t,n){t=t||1024;let s=e.pos,i=-1,a=0,r="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));for(;0>(i=o.indexOf("\n"))&&a<t&&s<e.byteLength;)r+=o,a+=o.length,s+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),r+o.slice(0,i))},s=function(e,t,n,s){const i=e[t+3],a=Math.pow(2,i-128)/255;n[s+0]=e[t+0]*a,n[s+1]=e[t+1]*a,n[s+2]=e[t+2]*a,n[s+3]=1},i=function(e,t,n,s){const i=e[t+3],a=Math.pow(2,i-128)/255;n[s+0]=St.toHalfFloat(Math.min(e[t+0]*a,65504)),n[s+1]=St.toHalfFloat(Math.min(e[t+1]*a,65504)),n[s+2]=St.toHalfFloat(Math.min(e[t+2]*a,65504)),n[s+3]=St.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;const r=function(e){const s=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,r=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,h;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(h=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=h[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(s))&&(o.gamma=parseFloat(h[1])),(h=l.match(i))&&(o.exposure=parseFloat(h[1])),(h=l.match(a))&&(o.valid|=2,o.format=h[1]),(h=l.match(r))&&(o.valid|=4,o.height=parseInt(h[1],10),o.width=parseInt(h[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=r.width,l=r.height,h=function(e,n,s){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*s);a.length||t(4,"unable to allocate buffer space");let r=0,o=0;const l=4*i,h=new Uint8Array(4),d=new Uint8Array(l);let c=s;for(;c>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2==h[0]&&2==h[1]&&(h[2]<<8|h[3])==i||t(3,"bad rgbe scanline format");let n,s=0;for(;s<l&&o<e.byteLength;){n=e[o++];const i=n>128;if(i&&(n-=128),(0===n||s+n>l)&&t(3,"bad scanline data"),i){const t=e[o++];for(let e=0;e<n;e++)d[s++]=t}else d.set(e.subarray(o,o+n),s),s+=n,o+=n}const u=i;for(let e=0;e<u;e++){let t=0;a[r]=d[e+t],t+=i,a[r+1]=d[e+t],t+=i,a[r+2]=d[e+t],t+=i,a[r+3]=d[e+t],r+=4}c--}return a}(a.subarray(a.pos),o,l);let d,c,u;switch(this.type){case wt:u=h.length/4;const e=new Float32Array(4*u);for(let t=0;t<u;t++)s(h,4*t,e,4*t);d=e,c=wt;break;case vt:u=h.length/4;const t=new Uint16Array(4*u);for(let e=0;e<u;e++)i(h,4*e,t,4*e);d=t,c=vt;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:o,height:l,data:d,header:r.string,gamma:r.gamma,exposure:r.exposure,type:c}}setDataType(e){return this.type=e,this}load(e,t,n,s){return super.load(e,(function(e,n){switch(e.type){case wt:case vt:e.colorSpace=w,e.minFilter=D,e.magFilter=D,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,s)}}class ml extends z{constructor(e,t){super(new Pt(1,1,10,10),new x({color:ml.alphaMap?0:16777215,transparent:!0,depthWrite:!1,polygonOffset:!0,name:"ShadowGroundPlaneMaterial"})),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;ml.alphaMap?(t.alphaMap=e,t.map=null,t.color.set(0)):(t.alphaMap=null,t.map=e,t.color.set(16777215)),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}ml.alphaMap=!0;class gl extends class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}{get renderPassManager(){return this._renderPassManager}get renderCacheManager(){return this._renderPassManager.renderCacheManager}get scene(){return this._renderPassManager.scene}get camera(){return this._renderPassManager.camera}get gBufferTextures(){return this._renderPassManager.gBufferRenderPass}get passRenderer(){return this._renderPassManager.passRenderer}constructor(e){super(),this._renderPassManager=e}render(e,t,n,s,i){this.renderPass(e)}}const fl={uniforms:{tDiffuse:{value:null},intensity:{value:new a(1,1)}},vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 intensity;\n varying vec2 vUv;\n \n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n vec2 aoAndShadow = vec2(1.0) - intensity + intensity * textureColor.rg;\n gl_FragColor = vec4(vec3(aoAndShadow.r * aoAndShadow.g), 1.0);\n }"};class _l extends Te{constructor(e){super({uniforms:De.clone(fl.uniforms),vertexShader:fl.vertexShader,fragmentShader:fl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Ae,blendDst:Re,blendEquation:Ee,blendSrcAlpha:Ie,blendDstAlpha:Re,blendEquationAlpha:Ee}),this._intensity=new a(1,1),this.uniforms.intensity.value=this._intensity,this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),void 0!==(null==e?void 0:e.aoIntensity)&&(this._intensity.x=e.aoIntensity),void 0!==(null==e?void 0:e.shadowIntensity)&&(this._intensity.y=e.shadowIntensity),this}}const vl=(e,t,n)=>{const s=wl(e,t,n);let i="vec3[SAMPLES](";for(let t=0;t<e;t++){const n=s[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?",":")"}`}return i},wl=(e,t,n)=>{const s=[];for(let i=0;i<e;i++){const a=2*Math.PI*t*i/e,o=Math.pow(i/(e-1),n);s.push(new r(Math.cos(a),Math.sin(a),o))}return s},bl={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:vl(16,2,1),NV_ALIGNED_SAMPLES:0,SAMPLE_DISTRIBUTION:0,DEPTH_VALUE_SOURCE:0,LUMINANCE_TYPE:"float",SAMPLE_LUMINANCE:"dot(vec3(0.2125, 0.7154, 0.0721), a)",SCENE_CLIP_BOX:0,FRAGMENT_OUTPUT:"vec4(vec3(denoised), 1.)"},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new a},cameraProjectionMatrix:{value:new P},cameraProjectionMatrixInverse:{value:new P},cameraWorldMatrix:{value:new P},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:10},radiusExponent:{value:1},index:{value:0},sceneBoxMin:{value:new r(-1,-1,-1)},sceneBoxMax:{value:new r(1,1,1)}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\nvarying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform vec2 resolution;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraProjectionMatrixInverse;\nuniform mat4 cameraWorldMatrix;\nuniform float lumaPhi;\nuniform float depthPhi;\nuniform float normalPhi;\nuniform float radius;\nuniform float radiusExponent;\nuniform int index;\n#if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\n\n#include <common>\n#include <packing>\n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(vec3(denoised), 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout LUMINANCE_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = fetchDepth(ivec2(vec2(textureSize(tDepth, 0)) * vUv.xy));\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radius * 2.) {\n discard;\n return;\n }\n\t\t#endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n #if SAMPLE_DISTRIBUTION == 1\n vec3 randomVec = normalize(vec3(noiseVec.xy, 0.));\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n #endif\n\n LUMINANCE_TYPE totalWeight = LUMINANCE_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SAMPLE_DISTRIBUTION == 1\n vec3 offsetViewPos = viewPos + normalize(kernelMatrix * vec3(sampleDir.xy, 0.)) * sampleDir.z * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #else\n vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n vec2 sampleUv = vUv + offset;\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = FRAGMENT_OUTPUT;\n}"},yl={iterations:2,samples:16,rings:2,radiusExponent:1,radius:5,lumaPhi:10,depthPhi:.5,normalPhi:1,nvOrientatedSamples:!1};class Sl{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n,s){this.needsUpdate=!0,this.parameters={...yl},this._width=0,this._height=0,this._samples=0,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._passRenderer=new Ra,this._rgInputTexture=!1,this._width=e,this._height=t,this._samples=n,this._normalVectorSourceType=(null==s?void 0:s.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==s?void 0:s.depthValueSourceType)||"normalVectorAlpha",this._inputTexture=(null==s?void 0:s.inputTexture)||null,this.depthTexture=(null==s?void 0:s.depthTexture)||null,this.normalTexture=(null==s?void 0:s.normalTexture)||null,this._rgInputTexture=(null==s?void 0:s.rgInputTexture)||!1,this._luminanceType=(null==s?void 0:s.luminanceType)||"vec3",this._sampleLuminance=(null==s?void 0:s.sampleLuminance)||"a",this._fragmentOutput=(null==s?void 0:s.fragmentOutput)||"vec4(denoised.xyz, 1.)",(null==s?void 0:s.poissonDenoisePassParameters)&&(this.parameters=s.poissonDenoisePassParameters),s&&this.updateTextures(s)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ca,n=new Uint8Array(e*e*4);for(let s=0;s<e;s++)for(let i=0;i<e;i++){const a=s,r=i;n[4*(s*e+i)]=127.5*(t.noise(a,r)+1),n[4*(s*e+i)+1]=127.5*(t.noise(a+e,r)+1),n[4*(s*e+i)+2]=127.5*(t.noise(a,r+e)+1),n[4*(s*e+i)+3]=127.5*(t.noise(a+e,r+e)+1)}this._noiseTexture=new ye(n,e,e,be,Le),this._noiseTexture.wrapS=k,this._noiseTexture.wrapT=k,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;return this._pdMaterial||(this._pdMaterial=new Te({defines:Object.assign({},bl.defines),uniforms:De.clone(bl.uniforms),vertexShader:bl.vertexShader,fragmentShader:bl.fragmentShader,depthTest:!1,depthWrite:!1}),this._pdMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&this._updateShader(this._pdMaterial),this._updateUniforms(this._pdMaterial,e,n),this._pdMaterial}_updateShader(e){e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=vl(this.parameters.samples,this.parameters.rings,this.parameters.radiusExponent),e.defines.SAMPLE_DISTRIBUTION=this.parameters.nvOrientatedSamples?1:0,e.defines.NORMAL_VECTOR_TYPE="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_VALUE_SOURCE="normalVectorAlpha"===this._depthValueSourceType?1:0,e.needsUpdate=!0,e.defines.LUMINANCE_TYPE=this._luminanceType,e.defines.SAMPLE_LUMINANCE=this._sampleLuminance,e.defines.FRAGMENT_OUTPUT=this._fragmentOutput,e.defines.SCENE_CLIP_BOX=this._sceneClipBox?1:0,e.needsUpdate=!0}_updateUniforms(e,t,n){const s="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;e.uniforms.tDiffuse.value=this._inputTexture,e.uniforms.tNormal.value=this.normalTexture,e.uniforms.tDepth.value=s,e.uniforms.resolution.value.set(this._width,this._height),e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse),e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld),n&&(e.uniforms.lumaPhi.value=this.parameters.lumaPhi,e.uniforms.depthPhi.value=this.parameters.depthPhi,e.uniforms.normalPhi.value=this.parameters.normalPhi,e.uniforms.radius.value=this.parameters.radius,e.uniforms.radiusExponent.value=this.parameters.radiusExponent,this._sceneClipBox&&(e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min),e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)))}_getRenderTargets(){return this._renderTargets.length<2&&(this._renderTargets=[new Fe(this._width,this._height,{samples:this._samples,format:be,type:vt,magFilter:D,minFilter:D}),new Fe(this._width,this._height,{samples:this._samples,format:be,type:vt,magFilter:D,minFilter:D})]),this._renderTargets}dispose(){var e,t;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._pdMaterial)||void 0===t||t.dispose(),this._renderTargets.forEach(e=>e.dispose())}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach(n=>n.setSize(e,t)),this.needsUpdate=!0}updateBounds(e){this._sceneClipBox=(new ge).copy(e),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const s=this._getRenderTargets();for(let t=0;t<this.parameters.iterations;t++){const i=s[(t+1)%2];this._outputRenderTargetIndex=t%2;const a=s[this._outputRenderTargetIndex];n.uniforms.tDiffuse.value=0===t?this._inputTexture:i.texture,n.uniforms.index.value=t,this._passRenderer.renderScreenSpace(e,n,a,16777215,1)}}renderToTarget(e,t,n){const s=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,s,n,16777215,1)}}const xl={shadowRadius:.05};class Pl extends gl{get aoAndSoftShadowRenderTarget(){var e;return this._aoAndSoftShadowRenderTarget=null!==(e=this._aoAndSoftShadowRenderTarget)&&void 0!==e?e:new Fe(this._width,this._height,{samples:this._samples,format:Mt,magFilter:ne,minFilter:ne}),this._aoAndSoftShadowRenderTarget}get aoRenderPass(){return this._aoPass||(this._aoPass=new La(this._width,this._height,this._samples,!this.parameters.applyToMaterial,{normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",modulateRedChannel:!0,aoParameters:this.parameters.ao})),this._aoPass}get softShadowPass(){if(this._softShadowPass){const e=this._softShadowPass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._softShadowPass=new Sl(this._width,this._height,this._samples,{inputTexture:void 0,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,luminanceType:"float",sampleLuminance:"a.x",fragmentOutput:"vec4(1.0, denoised.x, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",poissonDenoisePassParameters:{iterations:1,samples:16,rings:2,radiusExponent:1,radius:this.parameters.shadow.shadowRadius,lumaPhi:10,depthPhi:.1,normalPhi:4,nvOrientatedSamples:!0}});return this._softShadowPass}get fadeRenderTarget(){var e;return this._fadeRenderTarget=null!==(e=this._fadeRenderTarget)&&void 0!==e?e:new Fe(this._width,this._height,{samples:this._samples,format:Mt,magFilter:ne,minFilter:ne}),this._fadeRenderTarget}get denoisePass(){if(this._poissonDenoisePass){const e=this._poissonDenoisePass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._poissonDenoisePass=new Sl(this._width,this._height,this._samples,{inputTexture:this.aoAndSoftShadowRenderTarget.texture,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,fragmentOutput:"vec4(denoised.xy, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",poissonDenoisePassParameters:this.parameters.poissonDenoise});return this._poissonDenoisePass}get denoiseRenderTargetTexture(){return this.denoisePass?this.denoisePass.texture:null}get finalTexture(){return this._finalTexture}constructor(e,t,n,s,i){var a,r,o,l,h,d,c,u;super(e),this.needsUpdate=!0,this.renderToRenderTarget=!1,this.shadowAndAoPassSettings={shadowMapTexture:null,shadowBlurType:"full",shadowFadeInBlurType:"full",shadowFadeInMix:0,noOStaticFrames:0},this._cameraUpdate=new Aa,this._finalTexture=null,this._onlyHardShadow=!1,this._width=t,this._height=n,this._samples=s,this.parameters={enabled:null===(a=null==i?void 0:i.enabled)||void 0===a||a,applyToMaterial:null===(r=null==i?void 0:i.applyToMaterial)||void 0===r||r,aoIntensity:null!==(o=null==i?void 0:i.aoIntensity)&&void 0!==o?o:.5,shadowIntensity:null!==(l=null==i?void 0:i.shadowIntensity)&&void 0!==l?l:.35,aoOnGround:null===(h=null==i?void 0:i.aoOnGround)||void 0===h||h,shadowOnGround:null!==(d=null==i?void 0:i.shadowOnGround)&&void 0!==d&&d,alwaysUpdate:null!==(c=null==i?void 0:i.alwaysUpdate)&&void 0!==c&&c,progressiveDenoiseIterations:null!==(u=null==i?void 0:i.progressiveDenoiseIterations)&&void 0!==u?u:0,shadow:{...xl},ao:{...ka},poissonDenoise:{...yl}},this._copyMaterial=new ba,this._blendMaterial=new ba({},"default"),this._blendAoAndShadowMaterial=new _l}dispose(){var e,t,n,s,i,a,r,o;super.dispose(),null===(e=this._aoAndSoftShadowRenderTarget)||void 0===e||e.dispose(),null===(t=this._softShadowPass)||void 0===t||t.dispose(),null===(n=this._aoPass)||void 0===n||n.dispose(),null===(s=this._fadeRenderTarget)||void 0===s||s.dispose(),null===(i=this._poissonDenoisePass)||void 0===i||i.dispose(),null===(a=this._copyMaterial)||void 0===a||a.dispose(),null===(r=this._blendMaterial)||void 0===r||r.dispose(),null===(o=this._blendAoAndShadowMaterial)||void 0===o||o.dispose()}setSize(e,t){var n,s,i,a,r;this._width=e,this._height=t,null===(n=this._aoAndSoftShadowRenderTarget)||void 0===n||n.setSize(e,t),null===(s=this._softShadowPass)||void 0===s||s.setSize(e,t),null===(i=this._aoPass)||void 0===i||i.setSize(e,t),null===(a=this._fadeRenderTarget)||void 0===a||a.setSize(e,t),null===(r=this._poissonDenoisePass)||void 0===r||r.setSize(this._width,this._height),this.needsUpdate=!0}updateParameters(e){void 0!==e.enabled&&(this.parameters.enabled=e.enabled),void 0!==e.applyToMaterial&&(this.parameters.applyToMaterial=e.applyToMaterial),void 0!==e.aoIntensity&&(this.parameters.aoIntensity=e.aoIntensity),void 0!==e.shadowIntensity&&(this.parameters.shadowIntensity=e.shadowIntensity),void 0!==e.aoOnGround&&(this.parameters.aoOnGround=e.aoOnGround),void 0!==e.shadowOnGround&&(this.parameters.shadowOnGround=e.shadowOnGround),void 0!==e.alwaysUpdate&&(this.parameters.alwaysUpdate=e.alwaysUpdate),this._updatePassParameters(e)}_updatePassParameters(e){var t,n;if(null==e?void 0:e.shadow){for(const t in e.shadow)this.parameters.shadow.hasOwnProperty(t)&&(this.parameters.shadow[t]=e.shadow[t]);this._softShadowPass&&(this._softShadowPass.needsUpdate=!0)}if(null==e?void 0:e.ao){for(const t in e.ao)this.parameters.ao.hasOwnProperty(t)&&(this.parameters.ao[t]=e.ao[t]);this._aoPass&&(null===(t=this._aoPass)||void 0===t||t.updateParameters(null==e?void 0:e.ao))}if(null==e?void 0:e.poissonDenoise)if(this._poissonDenoisePass)null===(n=this._poissonDenoisePass)||void 0===n||n.updateParameters(null==e?void 0:e.poissonDenoise);else for(const t in e.poissonDenoise)this.parameters.poissonDenoise.hasOwnProperty(t)&&(this.parameters.poissonDenoise[t]=e.poissonDenoise[t])}updateBounds(e,t){var n,s;null===(n=this._softShadowPass)||void 0===n||n.updateBounds(e.bounds),null===(s=this._aoPass)||void 0===s||s.updateBounds(e.bounds,t)}_getRenderConditions(e="full",t=0,n=0){const s="poisson"===e&&t>.001,i="hard"===e&&t>.001&&t<.999;return{fadeInPoissonShadow:s,fadeInHardShadow:i,onlyHardShadow:"hard"===e&&!i,progressiveDenoise:!s&&!i&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}renderPass(e){if(!this._setRenderState())return;const t=this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType,this.shadowAndAoPassSettings.shadowFadeInMix,this.shadowAndAoPassSettings.noOStaticFrames);let n=!1;!t.onlyHardShadow&&"full"===this.shadowAndAoPassSettings.shadowBlurType&&this._evaluateIfUpdateIsNeeded(this.camera)&&(this._renderShadowAndAo(e,this.scene,this.camera,this.shadowAndAoPassSettings.shadowMapTexture),n=!0);let s=t.onlyHardShadow?this.shadowAndAoPassSettings.shadowMapTexture:this.denoiseRenderTargetTexture;t.fadeInPoissonShadow&&(s=this._renderDynamicShadow(e,this.aoAndSoftShadowRenderTarget.texture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix),n=!0),n?s=this._renderDenoise(e,this.camera,t.fadeInPoissonShadow,!1):t.progressiveDenoise&&(s=this._renderDenoise(e,this.camera,!1,!0)),t.fadeInHardShadow&&(s=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix)),this._finalTexture=s,this._onlyHardShadow=t.onlyHardShadow,this.renderToRenderTarget&&this.renderToTarget(e)}_setRenderState(){return!(!this.parameters.enabled||!(null!==this.parameters.ao.algorithm||this.parameters.shadowIntensity>=.01)||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,s){var i;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;a||null===(i=this._aoPass)||void 0===i||i.clear(e,this.aoAndSoftShadowRenderTarget),this._renderSoftShadow(e,n,s),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const s=this.gBufferTextures.depthBufferTexture,i=this.gBufferTextures.gBufferTexture,a=this._aoAndSoftShadowRenderTarget,r=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=s,o.normalTexture=i,o.render(e,n,t,a),e.autoClear=r}_renderSoftShadow(e,t,n){const s=this.softShadowPass;s.parameters.radius=this.parameters.shadow.shadowRadius,s.inputTexture=n,this.softShadowPass.renderToTarget(e,t,this.aoAndSoftShadowRenderTarget)}_renderDynamicShadow(e,t,n,s=1){const i=s<.999;return i&&(this._copyMaterial.update({texture:t,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),s>.001&&(this._blendMaterial.update({texture:n,blending:i?Ue:Oe,colorTransform:(new P).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,i?s:1),multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,s){const i=this.denoisePass;return i.inputTexture=n?this.fadeRenderTarget.texture:s?i.texture:this.aoAndSoftShadowRenderTarget.texture,i.render(e,t),i.texture}renderToTarget(e){const t=this._onlyHardShadow?this.parameters.shadowIntensity:this.parameters.aoIntensity,n=this._onlyHardShadow?0:this.parameters.shadowIntensity;this.passRenderer.renderScreenSpace(e,this._blendAoAndShadowMaterial.update({texture:this._finalTexture,blending:Ue,aoIntensity:t,shadowIntensity:n}),e.getRenderTarget())}}Pl.shadowTransform=(new P).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class Ml{get isOutlinePassActivated(){return this.outlinePassActivated}get outlinePass(){return this._renderPassManager.outlinePass}constructor(e,t,n){this._effectComposer=null,this.outlinePassActivated=!1,this._renderPassManager=e,this._effectComposer=t,this.parameters={enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215,...n}}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const s=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!s&&this.outlinePassActivated||(!s&&this.outlinePass||this._renderPassManager.createOutlinePass(),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class Cl{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse(e=>{var t,n,s;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(s=this._cache)||void 0===s||s.addObject(e)}),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class Tl{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach(e=>{e.dispose()})}registerCache(e,t){this._cacheMap.set(e,new Cl(t))}clearCache(){this._cacheMap.forEach(e=>{e.clear()})}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const s=this._cacheMap.get(e);s&&(s.update(t),s.onBeforeRender()),n(),s&&s.onAfterRender()}}class Al{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach((e,t)=>{t.visible=!1})}onAfterRender(){this._visibilityCache.forEach((e,t)=>{t.visible=e})}}class Rl{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof N&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!1})}onAfterRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!0})}}class El{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach((e,t)=>{t instanceof z&&(t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),t.receiveShadow!==e.originalObjectData.receiveShadow&&(e.originalObjectData.receiveShadow=t.receiveShadow),t.castShadow!==e.originalObjectData.castShadow&&(e.originalObjectData.castShadow=t.castShadow),t.visible!==e.originalObjectData.visible&&(e.originalObjectData.visible=t.visible)),this._updateObject(t,e.updateObjectData)})}onAfterRender(){this._objectCache.forEach((e,t)=>{this._updateObject(t,e.originalObjectData)})}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof z?e.receiveShadow:void 0,material:e instanceof z?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof z&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof z&&void 0!==t.material&&(e.material=t.material)}}class Il extends gl{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new ml(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n,s){var i,a;super(e),this.limitPlaneSize=!0,this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=n,this.shadowMapSize=null!==(i=s.shadowMapSize)&&void 0!==i?i:2048,this.parameters=this._getDefaultParameters(s),this._groundShadowFar=this.parameters.cameraFar,this._renderer=t,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,new Al(e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name))),this.renderTarget=new Fe(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new Fe(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==s?void 0:s.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new Dl,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new Tt,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",ml.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=F,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new Ea(ya,{...s,passRenderer:this.renderPassManager.passRenderer}),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return{enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0,...e}}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFar<e.size.z&&(this._groundShadowFar=1.01*e.size.z);const s=Math.max(e.size.x,e.size.z);this.parameters.planeSize=s+2*Math.max(this._blurScale,null!==(n=this._shadowScale)&&void 0!==n?n:1,1),this.limitPlaneSize&&this.parameters.planeSize>this.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}renderPass(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,this.scene),!this.parameters.enabled)return void(this.needsUpdate&&(this.needsUpdate=!1,this.passRenderer.clear(e,this.renderTarget,0,1)));if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(this.scene),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this.renderCacheManager?this.renderCacheManager.render(this,e,()=>{this._renderer.render(e,this._groundContactCamera)}):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}Il.addTestMesh=!1;class Dl extends Q{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,s,i;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Ct(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(s=this.cameraHelper)||void 0===s?void 0:s.parent)&&(null===(i=this.cameraHelper)||void 0===i||i.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}class Ol extends Te{constructor(e){var t;super({defines:Object.assign({...Ol._normalAndDepthShader.defines,FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0}),uniforms:De.clone(Ol._normalAndDepthShader.uniforms),vertexShader:Ol._normalAndDepthShader.vertexShader,fragmentShader:Ol._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:Oe}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}Ol._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class kl extends gl{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new Ol({blending:Oe,floatBufferType:!0,linearDepth:!1}):new At({blending:Oe}),this._gBufferRenderMaterial instanceof Ol&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:wt,samples:this._samples});else{const e=new Rt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=Et,e.type=It,this._depthNormalRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new Fe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:wt,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,s,i,a,r,o,l,h,d;super(e),this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.drawGround=!0,this.floatRgbNormalAlphaDepth=null!==(s=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==s&&s,this.renderCacheManager&&(this._gBufferMaterialCache=new Ll,this.renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(i=null==t?void 0:t.depthNormalScale)&&void 0!==i?i:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:ne,this._targetMagnificationTextureFilter=null!==(r=null==t?void 0:t.textureMagnificationFilter)&&void 0!==r?r:ne,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(h=null==t?void 0:t.samples)&&void 0!==h?h:0,this._shared=null!==(d=null==t?void 0:t.shared)&&void 0!==d&&d}dispose(){var e,t;super.dispose(),null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}renderPass(e){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this.renderPassManager.setGroundVisibility(this.drawGround),this.renderCacheManager?this.renderCacheManager.render(this,this.scene,()=>{this._renderGBuffer(e,this.scene,this.camera)}):this._renderGBuffer(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this.passRenderer.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new ba),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:Oe,colorTransform:pa,colorBase:_a,multiplyChannels:0,uvTransform:va}),this.separateDeptRenderTarget)}}class Ll extends El{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof U&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof x&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class Ul extends gl{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n,s,i){super(e),this.reflectionFadeInScale=1,this._width=t,this._height=n,this._samples=null!=s?s:1,this.parameters={enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4,...i},this._copyMaterial=new ba({},"additive",!0,!0),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new Bl({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new Ea(ya,{...i,passRenderer:this.renderPassManager.passRenderer})}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,s={};if(e){const e=new Rt(t,n);s.depthTexture=e,s.samples=this._samples}else s.samples=1;return new Fe(t,n,{format:be,...s})}dispose(){var e,t,n;super.dispose(),null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,s,i,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(s=this._intensityRenderTarget)||void 0===s||s.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._blurRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const s=this.parameters.intensity*t,i=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new P).set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,s),multiplyChannels:0,uvTransform:wa}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}renderPass(e){if(!(this.parameters.enabled&&this.camera instanceof X))return;const t=this._createGroundReflectionCamera(this.camera);this.renderCacheManager.render("inivisibleGround",this.scene,()=>{this._renderGroundReflection(e,this.scene,t,this.reflectionRenderTarget)}),this._renderGroundReflectionIntensity(e,t,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,this.camera,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,this.reflectionFadeInScale),this.passRenderer.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,s){const i=e.getRenderTarget();s&&(e.setRenderTarget(s),this.passRenderer.clear(e,s,0,0)),e.render(t,n),s&&e.setRenderTarget(i)}_renderGroundReflectionIntensity(e,t,n){const s=e.getRenderTarget();e.setRenderTarget(n),this.passRenderer.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(s)}blurReflection(e,t,n){const s=new r(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),i=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(s.dot(new r(0,0,1)));this._blurPass.render(e,n,[4*i,4*a],[4*i*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class Bl extends Te{constructor(e){super({defines:Object.assign({},Bl.shader.defines),uniforms:De.clone(Bl.shader.uniforms),vertexShader:Bl.shader.vertexShader,fragmentShader:Bl.shader.fragmentShader,blending:Oe}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const s=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,i=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(s,i)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}Bl.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new a},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new P},cameraInverseProjectionMatrix:{value:new P},inverseViewMatrix:{value:new P},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:0,PREMULTIPLIED_ALPHA:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec2 diffuseTextureSize = vec2(textureSize(tDiffuse, 0 ));\n vec4 fragColor = texelFetch(tDiffuse, ivec2(uv * diffuseTextureSize), 0).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha * step(depth, 0.9999);\n #if PREMULTIPLIED_ALPHA == 1\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n #else\n gl_FragColor = fragColor;\n #endif\n }"};class Nl extends H{constructor(e,t){const n=new c;n.setAttribute("position",new ke([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new B({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const s=new c;s.setAttribute("position",new ke([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new z(s,new y({side:Dt,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class Fl extends Ot{constructor(e){super(e),this.customProgramCacheKey=this._customProgramCacheKey,this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,s,i,a,r){this._enableGroundBoundary=e,Fl._distributionProperties.set(t,n,s,i),Fl._shadowFadeOut.set(a,r)}static setBoundingBox(e){Fl._sceneBoxMin.copy(e.min),Fl._sceneBoxMax.copy(e.max)}_customProgramCacheKey(){return Fl._enableGroundBoundary?"GROUND_BOUNDARY":"NO_GROUND_BOUNDARY"}_onBeforeCompile(e,t){e.vertexShader=Gl,e.fragmentShader=jl,e.defines=Object.assign({...e.defines,DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:Fl._enableGroundBoundary?1:0});const n=e.uniforms;n&&(n.distributionProperties={value:Fl._distributionProperties},n.shadowFadeOut={value:Fl._shadowFadeOut},n.sceneBoxMin={value:Fl._sceneBoxMin},n.sceneBoxMax={value:Fl._sceneBoxMax})}}Fl._enableGroundBoundary=!1,Fl._shadowFadeOut=new a(.1,20),Fl._sceneBoxMin=new r(-1,-1,-1),Fl._sceneBoxMax=new r(1,1,1),Fl._distributionProperties=new Me(1,1,1,1);const Gl="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n #include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",jl="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include <common>\n#include <packing>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include <logdepthbuf_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include <opaque_fragment>\n\t#include <premultiplied_alpha_fragment>\n}\n",zl={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:"DirectionalLightShadow",maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class Vl extends gl{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var s,i,r;super(e),this.needsUpdate=!1,this.drawGround=!0,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Wl,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._cameraUpdate=new Aa,this._viewportSize=new a(t.x,t.y),this._samples=null!==(s=null==n?void 0:n.samples)&&void 0!==s?s:0,this._shadowMapSize=null!==(i=null==n?void 0:n.shadowMapSize)&&void 0!==i?i:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Hl,null===(r=this.renderCacheManager)||void 0===r||r.registerCache(this,this._shadowMapPassOverrideMaterialCache);const o=this._samples;this._shadowRenderTarget=new Fe(this._viewportSize.x,this._viewportSize.y,{samples:o,format:bt,magFilter:ne,minFilter:ne})}_getScreenSpaceShadowMapParameters(e){return{...zl,...e}}dispose(){super.dispose(),this._shadowLightSources.forEach(e=>e.dispose()),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const s=this._shadowScale;if(this._shadowScale=t,Math.abs(s-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach(t=>t.updateBounds(e)),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Q&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach(e=>e.forceShadowUpdate()),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map(e=>e.getShadowLight())}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find(t=>t.getOriginalLight()===e))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new ql(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){const n=this._shadowLightSources;this._shadowLightSources=this._createShadowLightSourceArray(!1);for(const s of n){if(s instanceof ql){const t=s.getRectAreaLight();e.includes(t)&&(s.updatePositionAndTarget(),this._shadowLightSources.push(s))}s.removeFrom(t),s.dispose()}e.forEach(e=>{this._shadowLightSources.find(t=>t instanceof ql&&t.getRectAreaLight()===e)||this.addRectAreaLight(e,t)}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){for(const t of this._shadowLightSources)t.removeFrom(e),t.dispose();this._shadowLightSources=this._createShadowLightSourceArray(!0);const n=1/(t.length>0?Math.max(...t.map(e=>e.maxIntensity)):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach(t=>{t.addTo(e),t.updatePositionAndTarget()}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach(e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new r(e.position.x,e.position.z,e.position.y).multiplyScalar(7),s=new Xl(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(s)}})}_createShadowLightSourceArray(e){const t=[];if(e){const e=new Yl(new r(0,7,0),{shadowMapSize:this._shadowMapSize});t.push(e)}return this.parameters.enableGroundBoundary=e,t}setSize(e,t){this._viewportSize=new a(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach(e=>e.updatePositionAndTarget())}renderPass(e){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(this.camera)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const t=this.scene.background,n=this.scene.environment,s=this.camera.layers.mask;this.scene.environment=null,this.scene.background=null,this.parameters.layers&&(this.camera.layers.mask=this.parameters.layers.mask),this.renderPassManager.setGroundVisibility(this.drawGround),this._renderSimpleShadowMapFromShadowLightSources(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.camera.layers.mask=s,this.scene.environment=n,this.scene.background=t}_renderSimpleShadowMapFromShadowLightSources(e,t,n){var s;this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const i=this._getSortedShadowLightSources();0===i.length?this.passRenderer.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(i),null===(s=this.renderCacheManager)||void 0===s||s.render(this,t,()=>{this.passRenderer.render(e,t,n,this._shadowRenderTarget,16777215,1)}),this._shadowLightSources.forEach(e=>e.finishRenderShadow()))}_getSortedShadowLightSources(){const e=[];return this._shadowLightSources.forEach(t=>e.push(...t.prepareRenderShadow())),e.sort((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity),e}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let s=0;e.forEach(e=>{(n<0||s<n)&&(t+=e.groundShadow?0:e.intensity,e.groundShadow||s++)}),s=0,e.forEach(e=>{var i;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||s<n)?(e.light.visible=!1,e.light.intensity=0,e.light.castShadow=!1):(e.light.visible=!0,e.light.intensity=e.groundShadow?e.intensity:e.intensity/t,(i=e.light).castShadow&&(i.castShadow=this.castShadow)),e.groundShadow||s++})}_updateShadowType(e){e.shadowMap.type=this.shadowConfiguration.currentConfiguration.type;const t=this.parameters.enableShadowMap&&this.shadowConfiguration.currentConfiguration.castShadow;e.shadowMap.enabled=t,e.shadowMap.needsUpdate=!0,this.castShadow=t&&this.shadowConfiguration.currentConfiguration.castShadow,this._shadowLightSources.forEach(e=>e._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}class Hl extends El{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial("default"),this._unlitMaterial=this._createShadowMaterial("unlit"),this._emissiveMaterial=this._createShadowMaterial("emissive"),this._receiveShadowMaterial=this._createShadowMaterial("shadow")}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,s,i,a,r){Fl.setShadowParameters(e,t,n,s,i,a,r)}setBoundingBox(e){this._boundingBoxSet=!0,Fl.setBoundingBox(e)}_createShadowMaterial(e){let t;return t="emissive"===e||"unlit"===e?new y({color:16777215,side:F}):"shadow"===e?new Nt({side:F}):Hl.useModifiedMaterial?this._createCustomerShadowMaterial():new Ft({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:F}),t}_createCustomerShadowMaterial(){return new Fl({side:F})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof B||t instanceof y?this.addToCache(e,{material:this._unlitMaterial}):t instanceof N?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}Hl.useModifiedMaterial=!0;class Wl{constructor(){var e;this.types=new Map([["off",Wl._noShadow],["BasicShadowMap",Wl._basicShadow],["PCFShadowMap",Wl._pcfShadow],["PCFSoftShadowMap",Wl._pcfSoftShadow],["VSMShadowMap",Wl._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Wl._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Wl._defaultType,!0)}}Wl._noShadow={castShadow:!1,type:kt,bias:0,normalBias:0,radius:0},Wl._basicShadow={castShadow:!0,type:Lt,bias:-5e-5,normalBias:.005,radius:0},Wl._pcfShadow={castShadow:!0,type:kt,bias:-5e-5,normalBias:.01,radius:4},Wl._pcfSoftShadow={castShadow:!0,type:Ut,bias:-5e-5,normalBias:.01,radius:1},Wl._vcmShadow={castShadow:!0,type:Bt,bias:1e-4,normalBias:0,radius:15},Wl._defaultType=Wl._pcfShadow;class Kl{constructor(e,t){var n,s;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(s=null==t?void 0:t.blurSamples)&&void 0!==s?s:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new a(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new r(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof l){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),s=Math.max(.001,Math.min(-n.min.z,-n.max.z)),i=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),r=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(r,a),s);t.aspect=1,t.near=s,t.far=i,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,s,i;if(this._shadowLightSource instanceof l){const n=t.clone().sub(e),s=n.length();n.normalize();const i=t.clone().sub(n.clone().multiplyScalar(4*s));this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.position.copy(i),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(i),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(s=this._shadowLightSource.shadow)||void 0===s||s.camera.lookAt(t);null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class ql extends Kl{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case"DirectionalLightShadow":n=new i(16777215,1);break;case"SpotLightShadow":n=new l(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new Nl(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class Xl extends Kl{constructor(e,t,n){const s=new i(16777215,t);s.position.copy(e),s.lookAt(0,0,0),s.updateMatrix(),s.castShadow=!0,super(s,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class Yl extends Kl{constructor(e,t){const n=new i(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}const Ql={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},Zl={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new a(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t\t//----------------------------------------------------------------------------------\n\t\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t\t// SDK Version: v3.00\n\t\t// Email: gameworks@nvidia.com\n\t\t// Site: http://developer.nvidia.com/\n\t\t//\n\t\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t\t//\n\t\t// Redistribution and use in source and binary forms, with or without\n\t\t// modification, are permitted provided that the following conditions\n\t\t// are met:\n\t\t// * Redistributions of source code must retain the above copyright\n\t\t// notice, this list of conditions and the following disclaimer.\n\t\t// * Redistributions in binary form must reproduce the above copyright\n\t\t// notice, this list of conditions and the following disclaimer in the\n\t\t// documentation and/or other materials provided with the distribution.\n\t\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t\t// contributors may be used to endorse or promote products derived\n\t\t// from this software without specific prior written permission.\n\t\t//\n\t\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t\t//\n\t\t//----------------------------------------------------------------------------------\n\n\t\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t\t/*--------------------------------------------------------------------------*/\n\n\t\t#define NUM_SAMPLES 5\n\n\t\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\t\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t\t}\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t// locate the edge\n\t\t\t\tvec2 dirToEdge;\n\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t// . 2 . . 1 .\n\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t// . 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 H\n\n\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t// V 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 .\n\n\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t// 1 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t// do a simple blur\n\t\t\t\t\treturn mix(\n\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t.4\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\titerationsUsed = i;\n\n\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\tif(!doneN) {\n\t\t\t\t\tnDist += increment;\n\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t}\n\n\t\t\t\tif(!doneP) {\n\t\t\t\t\tpDist += increment;\n\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t}\n\n\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\trgbaM,\n\t\t\t\trgbaN,\n\t\t\t\tdist * .5\n\t\t\t);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t\t}\n\t"};class Jl extends gl{constructor(e,t,n,s,i,r){var o;super(e),this.patternTexture=null,this.clearBackground=!1,this.renderScene=n,this.renderCamera=s,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new h(1,1,1),this.hiddenEdgeColor=new h(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==r?void 0:r.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==r?void 0:r.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==t?new a(t.x,t.y):new a(256,256);const l=Math.round(this.resolution.x/this.downSampleRatio),d=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Fe(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(o=this.gBufferTextures)||void 0===o?void 0:o.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=F,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new Te(Zl),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new Fe(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new Fe(l,d),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Fe(l,d),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Fe(Math.round(l/2),Math.round(d/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Fe(l,d),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Fe(Math.round(l/2),Math.round(d/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(l,d),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(l/2),Math.round(d/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const c=Ql;this.copyUniforms=De.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Te({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:Oe,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new h,this.oldClearAlpha=1,this.fsQuad=new Ma(void 0),this.tempPulseColor1=new h,this.tempPulseColor2=new h,this.textureMatrix=new P}dispose(){var e,t;super.dispose(),this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.prepareMaskMaterial.dispose(),null===(t=this.fxaaRenderMaterial)||void 0===t||t.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,s;this.renderTargetMaskBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,a),this.renderTargetBlurBuffer1.setSize(i,a),this.renderTargetEdgeBuffer1.setSize(i,a),this.separableBlurMaterial1.uniforms.texSize.value.set(i,a),i=Math.round(i/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(i,a),this.renderTargetEdgeBuffer2.setSize(i,a),this.separableBlurMaterial2.uniforms.texSize.value.set(i,a),null===(n=this.fxaaRenderMaterial)||void 0===n||n.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(s=this.renderTargetFxaaBuffer)||void 0===s||s.setSize(e,t)}_canBeHighlighted(e){return e.isMesh||Jl.highlightLines&&e.isLine}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;this.selectedObjects.forEach(n=>n.traverse(n=>{this._canBeHighlighted(n)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];this.selectedObjects.forEach(e=>e.traverse(e=>{this._canBeHighlighted(e)&&n.push(e)})),this.renderScene.traverse(s=>{if(this._canBeHighlighted(s)||s.isSprite){if(!1===n.some(e=>e.id===s.id)){const n=s.visible;!1!==e&&!0!==t.get(s)||(s.visible=e),t.set(s,n)}}else s.isPoints&&(!0===e?s.visible=t.get(s):(t.set(s,s.visible),s.visible=e))})}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,s,i){if(this.selectedObjects.length>0){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;this.clearBackground&&(e.setClearColor(0,255),e.clear(!0,!1,!1)),e.autoClear=!1,i&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const s=this.renderScene.background;this.renderScene.background=null,this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.gBufferTextures.textureWithDepthValue,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=s;let a=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),a=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=a.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Jl.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Jl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Jl.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Jl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=a.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}renderPass(e){this.render(e,null,null,0,!1)}_getPrepareMaskMaterial(e){return new Te({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new a(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new Te({uniforms:{maskTexture:{value:null},texSize:{value:new a(.5,.5)},visibleEdgeColor:{value:new r(1,1,1)},hiddenEdgeColor:{value:new r(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new Te({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new a(.5,.5)},direction:{value:new a(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new Te({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:Gt,depthTest:!1,depthWrite:!1,transparent:!0})}}Jl.BlurDirectionX=new a(1,0),Jl.BlurDirectionY=new a(0,1),Jl.highlightLines=!0;const $l=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new a(t,n)};class eh{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new Fe,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?wt:Le;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new Fe(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new nh(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new nh(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Q(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,s){var i;this.colorRenderTarget.setSize(n,s),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new z(new Pt(2,2),new y({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const r=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*s*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,s,o),{texture:r,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,s){var i;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),r=this.environmentMapDecodeTarget(e);r.setSize(n,s),a.setSourceTexture(t),this._planeMesh=null!==(i=this._planeMesh)&&void 0!==i?i:new z(new Pt(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(r),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=r.texture,h=r.texture.type===wt,d=h?new Float32Array(n*s*4):new Uint8Array(n*s*4);return e.readRenderTargetPixels(r,0,0,n,s,d),{texture:l,pixels:d,sRgbaPixels:h}}}const th={tDiffuse:{value:null}};class nh extends Te{constructor(e,t){super({uniforms:De.clone(th),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }",defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}e("a6",nh),e("a5",class{constructor(e){var t,n,s,i;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new ce,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new ce,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new ih(0),this.lightSources=[],this._grayScale=new r(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;n<e;n++){const s=n*Math.PI*(3-Math.sqrt(5)),i=1-n/(e-1)*2,a=Math.sqrt(1-i*i),o=Math.cos(s)*a,l=Math.sin(s)*a;t.push(new r(o,l,i))}return t},this._numberOfSamples=null!==(t=null==e?void 0:e.numberOfSamples)&&void 0!==t?t:1e3,this._width=null!==(n=null==e?void 0:e.width)&&void 0!==n?n:1024,this._height=null!==(s=null==e?void 0:e.height)&&void 0!==s?s:512,this._sampleThreshold=null!==(i=null==e?void 0:e.sampleThreshold)&&void 0!==i?i:.707,this.pointDistance=Math.sqrt(4*Math.PI)/Math.sqrt(this._numberOfSamples),this.pixelDistance=Math.sqrt(2)*Math.PI*2/this._width,this.samplePoints=this._createEquirectangularSamplePoints(this._numberOfSamples),this.sampleUVs=this.samplePoints.map(e=>$l(e))}detectLightSources(e,t,n){var s;this.textureData=n,this._textureConverter=null!==(s=this._textureConverter)&&void 0!==s?s:new eh,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort((e,t)=>t.maxIntensity-e.maxIntensity)}_redFromRgbaToNormalizedFloatArray(e,t,n){const s=new Float32Array(e.length/4);let i=1,a=0;for(let t=0;t<e.length/4;++t){const n=new h(...e.slice(4*t,4*t+3));e instanceof Float32Array&&n.convertSRGBToLinear();const o=new r(n.r,n.g,n.b).dot(this._grayScale);i=Math.min(i,o),a=Math.max(a,o),s[t]=o}if(n)for(let e=0;e<s.length;++e){const r=t?s[e]:(s[e]-i)/(a-i);s[e]=Math.pow(r,n)}else if(!t)for(let e=0;e<s.length;++e)s[e]=(s[e]-i)/(a-i);return s}_grayscaleTextureFromFloatArray(e,t,n){const s=t*n,i=new Uint8Array(4*s);for(let t=0;t<s;t++){const n=255*e[t];i[4*t+0]=n,i[4*t+1]=n,i[4*t+2]=n,i[4*t+3]=255}const a=new ye(i,t,n);return a.needsUpdate=!0,a}_filterLightSamples(e){const t=[];for(let n=0;n<this.sampleUVs.length;n++){const s=this.sampleUVs[n];this._detectorTextureLuminanceValueFromUV(s)>e&&t.push(new sh(this.samplePoints[n],s))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let s=0;for(let e=Math.max(0,t-2);e<Math.max(0,t+2);++e)for(let t=Math.max(0,n-2);t<Math.max(0,n+2);++t){const n=t*this.textureData._width+e,i=(this.textureData.data[4*n]+this.textureData.data[4*n+1]+this.textureData.data[4*n+2])/3;s=Math.max(s,i)}return s}_findClusterSegments(e,t){const n=2*this.pixelDistance,s=1.5*this.pointDistance,i=new ih(e.length);for(let a=0;a<e.length;a++)for(let r=a+1;r<e.length;r++)if(e[a].position.angleTo(e[r].position)<s){const s=e[r].position.clone().sub(e[a].position),o=Math.floor(s.length()/n);let l=!0,h=0;for(let n=1;n<o;n++){const i=s.clone().multiplyScalar(n/o),r=$l(e[a].position.clone().add(i).normalize());if(this._detectorTextureLuminanceValueFromUV(r)<t){if(h++,h>1){l=!1;break}}else h=0}l&&(i.adjacent[a].push(r),i.adjacent[r].push(a),i.edges.push([a,r]))}return i}createLightSourcesFromLightGraph(e,t){const n=t.components.filter(e=>e.length>1).map(t=>new ah(t.map(t=>e[t])));return n.forEach(e=>e.calculateLightSourceProperties(e=>this._originalLuminanceValueFromUV(e))),n}});class sh{constructor(e,t){this.position=e,this.uv=t}}class ih{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;t<e;t++)this.adjacent.push([])}findConnectedComponents(){const e=new Array(this.noOfNodes).fill(!1);this.components=[];for(let t=0;t<this.noOfNodes;t++)if(!e[t]){const n=[];this._dfs(t,e,n),this.components.push(n)}this.components.sort((e,t)=>t.length-e.length)}_dfs(e,t,n){t[e]=!0,n.push(e);for(const s of this.adjacent[e])t[s]||this._dfs(s,t,n)}}class ah{constructor(e){this.position=new r,this.uv=new a,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new r,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=$l(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class rh extends gl{constructor(e){super(e),this.debugOutput="",this._environmentMapDecodeMaterial=new nh(!0,!1),this._environmentMapDecodeMaterial.blending=Oe,this._environmentMapDecodeMaterial.depthTest=!1}dispose(){var e,t,n;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),null===(n=this._srgbToLinearCopyMaterial)||void 0===n||n.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new ba,this._copyMaterial.update(e)}getBlendAoAndShadowMaterial(e){var t;return this._blendAoAndShadowMaterial=null!==(t=this._blendAoAndShadowMaterial)&&void 0!==t?t:new _l({blending:Oe}),this._blendAoAndShadowMaterial.update(e)}getSrgbToLinearCopyMaterial(e){var t;return this._srgbToLinearCopyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new ba({},"additive",!0,!0),this._srgbToLinearCopyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new Sa({depthTexture:this.gBufferTextures.textureWithDepthValue,depthFilter:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?new Me(0,0,0,1):new Me(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}renderPass(e){var t,n,s,i,a,r;switch(this.debugOutput){default:break;case"lineardepth":this.passRenderer.renderScreenSpace(e,this._getDepthRenderMaterial(this.camera),null);break;case"g-normal":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(t=this.gBufferTextures)||void 0===t?void 0:t.gBufferTexture,blending:Oe,colorTransform:(new P).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new Me(.5,.5,.5,1),multiplyChannels:0,uvTransform:va}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(n=this.gBufferTextures)||void 0===n?void 0:n.gBufferTexture,blending:Oe,colorTransform:ua,colorBase:_a,multiplyChannels:0,uvTransform:va}),null);break;case"g-depth":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this.gBufferTextures)||void 0===s?void 0:s.gBufferTexture,blending:Oe,colorTransform:pa,colorBase:_a,multiplyChannels:0,uvTransform:va}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this.gBufferTextures)||void 0===i?void 0:i.depthBufferTexture,blending:Oe,colorTransform:ma,colorBase:_a,multiplyChannels:0,uvTransform:va}),null);break;case"ssao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"ssaodenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowmap":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,blending:Oe,colorTransform:ga,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowsoft":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowdenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowfadein":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,blending:Oe,colorTransform:Pl.shadowTransform,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"shadowandao":this.passRenderer.renderScreenSpace(e,this.getBlendAoAndShadowMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:Oe,aoIntensity:this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,shadowIntensity:this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity}),null);break;case"materialao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.aoPassMapTexture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"groundreflection":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:wa}),null);break;case"groundreflectionfinal":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:wa}),null);break;case"bakedgroundshadow":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,blending:Oe,colorTransform:ca,colorBase:fa,multiplyChannels:0,uvTransform:va}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment),this.passRenderer.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(a=this.scene.userData)||void 0===a?void 0:a.environmentDefinition){const t=this.renderPassManager.aspect,n=new Q(-1,1,1/t,-1/t,-1,1),s=null===(r=this.scene.userData)||void 0===r?void 0:r.environmentDefinition.createDebugScene(e,this.scene,this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);s.background=new h(16777215),e.render(s,n)}}}}class oh extends gl{constructor(e){super(e),this.drawGround=!0,this.drawWithDebugMaterial=!1,this.grayDebugMaterial=new N({color:12632256,side:F,envMapIntensity:.4})}dispose(){super.dispose(),this.grayDebugMaterial.dispose()}renderPass(e){this.renderCacheManager.onBeforeRender("floorDepthWrite",this.scene),this.renderPassManager.setGroundVisibility(this.drawGround),this.drawWithDebugMaterial?this.renderCacheManager.render("debug",this.scene,()=>{this.passRenderer.renderWithOverrideMaterial(e,this.scene,this.camera,this.grayDebugMaterial,null,0,1)}):e.render(this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}}class lh{constructor(){this.applyAoAndShadowToAlpha=!1,this._aoPassMapUniform={value:null},this._aoPassMapScaleUniform={value:1},this._aoPassMapIntensityUniform={value:1},this._shPassMapIntensityUniform={value:1},this._reflectionPassMapUniform={value:null},this._reflectionPassMapScaleUniform={value:1},this._reflectionPassMapIntensityUniform={value:0},this.applyReflectionPassMap=!1}set aoPassMap(e){this._aoPassMapUniform.value=e}set aoPassMapScale(e){this._aoPassMapScaleUniform.value=e}set aoPassMapIntensity(e){this._aoPassMapIntensityUniform.value=e}set shPassMapIntensity(e){this._shPassMapIntensityUniform.value=e}set reflectionPassMap(e){this._reflectionPassMapUniform.value=e}set reflectionPassMapScale(e){this._reflectionPassMapScaleUniform.value=e}set reflectionPassMapIntensity(e){this._reflectionPassMapIntensityUniform.value=e}static addPlugin(e){if(void 0!==e.userData.postProcessingMaterialPlugin)return e.userData.postProcessingMaterialPlugin instanceof lh?e.userData.postProcessingMaterialPlugin:null;const t=new lh;return e.userData.postProcessingMaterialPlugin=t,e.onBeforeCompile=(e,n)=>t._onBeforeCompile(e,n),e.customProgramCacheKey=()=>t._customProgramCacheKey(),t}_isEnabled(){return void 0!==this._aoPassMapUniform.value&&null!==this._aoPassMapUniform.value}_customProgramCacheKey(){let e="";return this._isEnabled()&&(e+="aoPassMap"+(this.applyAoAndShadowToAlpha?"Alpha":"")),this.applyReflectionPassMap&&(e+="reflectionPassMap"),e}_onBeforeCompile(e,t){if(this._isEnabled()||this.applyReflectionPassMap){let t=this.applyAoAndShadowToAlpha?"#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n":"";t+=this.applyReflectionPassMap?"#define USE_REFLECTION_PASS_MAP\n":"",t+=hh,e.fragmentShader=e.fragmentShader.replace("#include <aomap_pars_fragment>",t),e.fragmentShader=e.fragmentShader.replace("#include <aomap_fragment>",dh),this._initUniforms(e)}}_initUniforms(e){e&&(e.uniforms.tAoPassMap=this._aoPassMapUniform,e.uniforms.aoPassMapScale=this._aoPassMapScaleUniform,e.uniforms.aoPassMapIntensity=this._aoPassMapIntensityUniform,e.uniforms.shPassMapIntensity=this._shPassMapIntensityUniform,e.uniforms.tReflectionPassMap=this._reflectionPassMapUniform,e.uniforms.reflectionPassMapScale=this._reflectionPassMapScaleUniform,e.uniforms.reflectionPassMapIntensity=this._reflectionPassMapIntensityUniform)}}const hh="\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n\n\tuniform highp sampler2D tAoPassMap;\n uniform float aoPassMapScale;\n uniform float aoPassMapIntensity;\n uniform float shPassMapIntensity;\n uniform sampler2D tReflectionPassMap;\n uniform float reflectionPassMapScale;\n uniform float reflectionPassMapIntensity;\n",dh="\n#ifndef AOPASSMAP_SWIZZLE\n\t#define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\t\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tambientOcclusion = texture2D( aoMap, vAoMapUv ).r;\n ambientOcclusion = ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;\n\n#endif\n\n vec4 aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 );\n vec2 aoAndShadow = aoAndShadowMap.rg;\n float depthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n const ivec2 aoOffsetArray[8] = ivec2[8](\n ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1), ivec2(1, 1), ivec2(-1, 1), ivec2(1, -1), ivec2(-1, -1));\n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n if (testDepthDelta < depthDelta) {\n aoAndShadow = aoAndShadowMap.rg;\n depthDelta = testDepthDelta;\n }\n }\n \n float aoPassMapValue = aoPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.r - 1.0) * aoPassMapIntensity + 1.0);\n shadowValue = shPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.g - 1.0) * shPassMapIntensity + 1.0);\n\n #ifdef USE_REFLECTION_PASS_MAP\n\n ivec2 reflectionPassMapSize = textureSize( tReflectionPassMap, 0 );\n vec2 reflectionPassMapUv = vec2( gl_FragCoord.x * reflectionPassMapScale, float(reflectionPassMapSize.y) - gl_FragCoord.y * reflectionPassMapScale );\n vec4 reflectionPassMapColor = texture2D( tReflectionPassMap, reflectionPassMapUv / vec2(reflectionPassMapSize) );\n if (reflectionPassMapColor.a > 0.0) reflectionPassMapColor.rgb /= reflectionPassMapColor.a;\n vec3 diffuseReflectionPassMapColor = reflectionPassMapColor.rgb * material.diffuseColor;\n reflectedLight.indirectDiffuse += diffuseReflectionPassMapColor * reflectionPassMapColor.a * reflectionPassMapIntensity;\n //reflectedLight.indirectDiffuse = mix(reflectedLight.indirectDiffuse, diffuseReflectionPassMapColor, reflectionPassMapColor.a * reflectionPassMapIntensity);\n\n #endif\n\n #if defined ( USE_APPLY_AO_AND_SHADOW_TO_ALPHA )\n diffuseColor.a = 1.0 - (1.0 - diffuseColor.a) * aoPassMapValue * shadowValue;\n #else\n ambientOcclusion = min( ambientOcclusion, aoPassMapValue );\n #endif\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n \n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n \n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n\t\treflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif \n \n\t#endif\n";class ch{get passRenderer(){return this._passRenderer}get scene(){return this._scene}get camera(){return this._camera}get aspect(){return this._sceneRenderer.width/this._sceneRenderer.height}get cameraChanged(){return this._cameraChanged}get noOStaticFrames(){return this._noOStaticFrames}get renderCacheManager(){return this._sceneRenderer.renderCacheManager}get parameters(){return this._sceneRenderer.parameters}get sceneRenderPass(){return this._sceneRenderPass}get bakedGroundContactShadowPass(){return this._bakedGroundContactShadowPass}get gBufferRenderPass(){return this._gBufferRenderPass}get groundReflectionPass(){return this._groundReflectionPass}get screenSpaceShadowMapPass(){return this._screenSpaceShadowMapPass}get shadowAndAoPass(){return this._shadowAndAoPass}get outlinePass(){return this._outlinePass}get outlineRenderer(){return this._sceneRenderer.outlineRenderer}get debugPass(){var e;return null!==(e=this._debugPass)&&void 0!==e||(this._debugPass=new rh(this)),this._debugPass}get debugOutput(){return this._sceneRenderer.debugOutput}constructor(e){this.materialsNeedUpdate=!0,this._passRenderer=new Ra,this._outlinePass=null,this._debugPass=null,this._cameraUpdate=new Aa,this._cameraChanged=!0,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._maxSamples=1,this._passUpdateStates={updateGroundReflection:!1,updateGBuffer:!1,updateScreenSpaceShadow:!1,updateShadowAndAoPass:!1,updateOutlinePass:!1,updateDebugPass:!1},this.aoPassMapTexture=null,this._sceneRenderer=e,this._maxSamples=this._sceneRenderer.renderer.capabilities.maxSamples,this._sceneRenderPass=new oh(this),this._bakedGroundContactShadowPass=new Il(this,this._sceneRenderer.renderer,this._sceneRenderer.groundGroup,{sharedShadowGroundPlane:this._sceneRenderer.shadowAndAoGroundPlane}),this._gBufferRenderPass=new kl(this,{shared:!0,capabilities:this._sceneRenderer.renderer.capabilities,width:this._sceneRenderer.width,height:this._sceneRenderer.height,samples:1}),this._groundReflectionPass=new Ul(this,this._sceneRenderer.width,this._sceneRenderer.height,this._maxSamples,{}),this._screenSpaceShadowMapPass=new Vl(this,new a(this._sceneRenderer.width,this._sceneRenderer.height),{samples:1,alwaysUpdate:!1}),this._shadowAndAoPass=new Pl(this,this._sceneRenderer.width,this._sceneRenderer.height,1)}dispose(){var e;this._sceneRenderPass.dispose(),this._bakedGroundContactShadowPass.dispose(),this._gBufferRenderPass.dispose(),this._groundReflectionPass.dispose(),this._screenSpaceShadowMapPass.dispose(),this._shadowAndAoPass.dispose(),null===(e=this._outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._gBufferRenderPass.setSize(e,t),this._groundReflectionPass.setSize(e,t),this._screenSpaceShadowMapPass.setSize(e,t),this._shadowAndAoPass.setSize(e,t),null===(n=this._outlinePass)||void 0===n||n.setSize(e,t)}createOutlinePass(){return this._outlinePass||(this._outlinePass=new Jl(this,new a(this._sceneRenderer.width,this._sceneRenderer.height),this.scene,this.camera,[],{downSampleRatio:2,edgeDetectionFxaa:!0})),this._outlinePass}setGroundVisibility(e){this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e)}updatePasses(e,t,n){this._scene=t,this._camera=n,this._cameraChanged=this._cameraUpdate.changed(n);const s=this._evaluateIfShadowAndAoUpdateIsNeeded();this._updateSceneRenderPass(),this._updateBakedGroundContactShadowPass(),this._updateGBufferPass(s),this._updateGroundReflectionPass(s),this._updateScreenSpaceShadowPass(s),this._updateShadowAndAoPass(s),this._updateOutlinePass(),this._updateDebugPass()}_evaluateIfShadowAndAoUpdateIsNeeded(){const e=this._shadowAndAoPass.parameters.alwaysUpdate||this._screenSpaceShadowMapPass.needsUpdate||this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate;let t=(this._shadowAndAoPass.parameters.enabled||this._groundReflectionPass.parameters.enabled)&&this._cameraChanged,n=1;return t&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),e||(this._noUpdateNeededCount++,t=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,n=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),e||1!==n||this._noOStaticFrames++,t=e||t,{needsUpdate:t,shadowOnCameraChange:!t||n<.99?this.parameters.shadowOnCameraChange:"off",intensityScale:n}}_dynamicChanges(e){return e.needsUpdate||"off"!==e.shadowOnCameraChange}_updateSceneRenderPass(){this._sceneRenderPass.drawWithDebugMaterial=!1}_updateBakedGroundContactShadowPass(){const e=this._bakedGroundContactShadowPass.limitPlaneSize;this._bakedGroundContactShadowPass.limitPlaneSize=this._bakedGroundContactShadowPass.parameters.enabled,(e!==this._bakedGroundContactShadowPass.limitPlaneSize||this._bakedGroundContactShadowPass.needsUpdate)&&this._bakedGroundContactShadowPass.updateBounds(this._sceneRenderer.boundingVolume,this._sceneRenderer.groundLevel),this._sceneRenderPass.drawGround=this._bakedGroundContactShadowPass.parameters.enabled||this._shadowAndAoPass.parameters.applyToMaterial}_updateGBufferPass(e){this._passUpdateStates.updateGBuffer=!1,this._gBufferRenderPass.needsUpdate=e.needsUpdate||"poisson"===e.shadowOnCameraChange,this.gBufferRenderPass.drawGround=this._sceneRenderer.boundingVolumeSet&&this._shadowAndAoPass.parameters.aoOnGround}_updateGroundReflectionPass(e){this._passUpdateStates.updateGroundReflection=!1,this._groundReflectionPass.parameters.enabled&&this._dynamicChanges(e)&&(!this.parameters.suspendGroundReflection||e.needsUpdate)&&(this._groundReflectionPass.reflectionFadeInScale=this.parameters.suspendGroundReflection?e.intensityScale:1,this._passUpdateStates.updateGroundReflection=!0)}_updateScreenSpaceShadowPass(e){this._dynamicChanges(e)?(this._screenSpaceShadowMapPass.parameters.alwaysUpdate=this._shadowAndAoPass.parameters.alwaysUpdate,this._screenSpaceShadowMapPass.drawGround=this._shadowAndAoPass.parameters.shadowOnGround,this._passUpdateStates.updateScreenSpaceShadow=this._shadowAndAoPass.parameters.shadowIntensity>0,this._passUpdateStates.updateScreenSpaceShadow=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateScreenSpaceShadow=!1}_updateShadowAndAoPass(e){this._dynamicChanges(e)?(this._shadowAndAoPass.shadowAndAoPassSettings={shadowMapTexture:this._screenSpaceShadowMapPass.shadowTexture,shadowBlurType:e.needsUpdate?"full":e.shadowOnCameraChange,shadowFadeInBlurType:e.shadowOnCameraChange,shadowFadeInMix:1-e.intensityScale,noOStaticFrames:this.noOStaticFrames},this._passUpdateStates.updateShadowAndAoPass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateShadowAndAoPass=!1}_updateOutlinePass(){this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass?(this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.clearBackground=!1,this._passUpdateStates.updateOutlinePass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateOutlinePass=!1}_updateDebugPass(){if(this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput){if("outline"===this.debugOutput&&this.outlineRenderer.outlinePass)return this.outlineRenderer.outlinePass.clearBackground=!0,void(this._passUpdateStates.updateDebugPass=!1);if("color"===this.debugOutput||"grayscale"===this.debugOutput)return this._passUpdateStates.updateGroundReflection=!1,this._passUpdateStates.updateGBuffer=!1,this._passUpdateStates.updateScreenSpaceShadow=!1,this._passUpdateStates.updateShadowAndAoPass=!1,this._passUpdateStates.updateOutlinePass=!1,this._passUpdateStates.updateDebugPass=!1,void(this._sceneRenderPass.drawWithDebugMaterial="grayscale"===this.debugOutput);this.debugPass.debugOutput=this.debugOutput,this._passUpdateStates.updateDebugPass=!0}else this._passUpdateStates.updateDebugPass=!1}_updateMaterials(e,t){if(!this.materialsNeedUpdate||!this._shadowAndAoPass.parameters.applyToMaterial)return;this.aoPassMapTexture=this._shadowAndAoPass.denoiseRenderTargetTexture;const n=e.getPixelRatio();this.materialsNeedUpdate=!1,t.traverse(e=>{if(e.isMesh){const t=e.material;t instanceof N&&this._updateMaterial(e,t,n)}})}_updateMaterial(e,t,n){const s=lh.addPlugin(t);s&&(this._updatePlugInAo(s,e,t,n),this._updatePlugInReflection(s,e),t.needsUpdate=!1)}_updatePlugInAo(e,t,n,s){const i=this._shadowAndAoPass.parameters.enabled&&this._shadowAndAoPass.parameters.applyToMaterial&&null!==this.aoPassMapTexture&&("ShadowGroundPlaneMaterial"===n.name||t.receiveShadow&&(!n.transparent||n.alphaTest>=.9)),a=i&&this._shadowAndAoPass.parameters.aoIntensity>.01,r=i&&this._screenSpaceShadowMapPass.enabled&&this._shadowAndAoPass.parameters.shadowIntensity>.01;e.applyAoAndShadowToAlpha="ShadowGroundPlaneMaterial"===n.name,e.aoPassMapIntensity=a?2*this._shadowAndAoPass.parameters.aoIntensity:-1,e.shPassMapIntensity=r?2*this._shadowAndAoPass.parameters.shadowIntensity:-1,e.aoPassMapScale=1/s,e.aoPassMap=this.aoPassMapTexture}_updatePlugInReflection(e,t){const n=this._groundReflectionPass.intensityRenderTarget.texture,s=t.userData.isPlanFloor&&this._groundReflectionPass.parameters.enabled&&(null!==n||void 0!==n),i=this._groundReflectionPass.parameters.intensity;e.applyReflectionPassMap=s,e.reflectionPassMapIntensity=s?Math.pow(i,.25):0,e.reflectionPassMapScale=1/(this._groundReflectionPass.parameters.renderTargetDownScale*devicePixelRatio),e.reflectionPassMap=s?n:null}renderPasses(e,t){var n,s;e.setRenderTarget(null),this._bakedGroundContactShadowPass.renderPass(e),this._passUpdateStates.updateGBuffer&&this._gBufferRenderPass.renderPass(e),this._passUpdateStates.updateScreenSpaceShadow&&this._screenSpaceShadowMapPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&this._shadowAndAoPass.renderPass(e),this._updateMaterials(e,t),this._sceneRenderPass.renderPass(e),this._passUpdateStates.updateGroundReflection&&this._groundReflectionPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&!this._shadowAndAoPass.parameters.applyToMaterial&&this._shadowAndAoPass.renderToTarget(e),this._passUpdateStates.updateOutlinePass&&(null===(n=this._outlinePass)||void 0===n||n.renderPass(e)),this._passUpdateStates.updateDebugPass&&(null===(s=this._debugPass)||void 0===s||s.renderPass(e))}}class uh{get sceneRenderPass(){return this._renderPassManager.sceneRenderPass}get bakedGroundContactShadowPass(){return this._renderPassManager.bakedGroundContactShadowPass}get gBufferRenderPass(){return this._renderPassManager.gBufferRenderPass}get groundReflectionPass(){return this._renderPassManager.groundReflectionPass}get screenSpaceShadowMapPass(){return this._renderPassManager.screenSpaceShadowMapPass}get shadowAndAoPass(){return this._renderPassManager.shadowAndAoPass}get debugPass(){return this._renderPassManager.debugPass}get shadowAndAoGroundPlane(){return this._shadowAndAoGroundPlane}constructor(e,t,n){this.debugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.enableObjectSelection=!0,this.groundLevel=0,this.uiInteractionMode=!1,this.width=0,this.height=0,this.boundingVolume=new Ta,this.boundingVolumeSet=!1,this.renderCacheManager=new Tl,this.selectedObjects=[],this.groundGroup=new q,this._shadingType="default",this._qualityLevel="highest",this._qualityMap=new Map,this._customShadingParameters=null,this.width=t,this.height=n,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new Al(e=>e===this.groundGroup)),this.renderCacheManager.registerCache("debug",new Al),this.renderCacheManager.registerCache("floorDepthWrite",new Rl(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor})),this._shadowAndAoGroundPlane=new ml(null),this.groundGroup.rotateX(-Math.PI/2),this._renderPassManager=new ch(this),this.outlineRenderer=new Ml(this._renderPassManager,null,{}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderPass.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadowPass.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadowMapPass.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"off"},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",()=>{}),e.domElement.addEventListener("webglcontextrestored",()=>{this._forceEnvironmentMapUpdate(this.renderer)})}dispose(){var e;null===(e=this._copyMaterial)||void 0===e||e.dispose(),this._renderPassManager.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this._renderPassManager.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setShadingType(e){this._shadingType!==e&&(this._shadingType=e,this.applyCurrentParameters())}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}setCustomShadingParameters(e){this._customShadingParameters=e,this.applyCurrentParameters(),this.requestUpdateOfPasses()}setQualityMapAndShadingParameters(e,t){this._qualityMap=e,this._customShadingParameters=t,this.applyCurrentParameters(),this.requestUpdateOfPasses()}applyCurrentParameters(){const e=[];this._qualityMap.has(this._qualityLevel)&&e.push(this._qualityMap.get(this._qualityLevel));const t=(n=this._shadingType)&&"default"!==n&&"bright"===n?Ua:null;var n;t&&e.push(t);const s=this.uiInteractionMode?{groundReflectionParameters:{enabled:!1}}:null;if(s&&e.push(s),this._customShadingParameters&&e.push((e=>{const t={shAndAoPassParameters:{ao:{},shadow:{}},groundReflectionParameters:{},bakedGroundContactShadowParameters:{}};return((e,t)=>{void 0!==t.aoIntensity&&(e.shAndAoPassParameters.aoIntensity=Ba(t.aoIntensity)),void 0!==t.aoExtent&&(e.shAndAoPassParameters.ao.radius=.3*Ba(t.aoExtent),e.shAndAoPassParameters.ao.thickness=.1+.2*Ba(t.aoExtent))})(t,e),((e,t)=>{t.shBakedOnGround?(e.bakedGroundContactShadowParameters.enabled=!0,e.shAndAoPassParameters.shadowIntensity=0,void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.opacity=Ba(t.shadowIntensity)),void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.blurMax=.1*Ba(t.shadowIntensity),e.bakedGroundContactShadowParameters.blurMin=.01*e.bakedGroundContactShadowParameters.blurMax)):(void 0!==t.shBakedOnGround&&(e.bakedGroundContactShadowParameters.enabled=!1),void 0!==t.shadowIntensity&&(e.shAndAoPassParameters.shadowIntensity=Ba(t.shadowIntensity)),void 0!==t.shadowSoftening&&(e.shAndAoPassParameters.shadow.shadowRadius=.001+.2*Ba(t.shadowSoftening)))})(t,e),((e,t)=>{void 0!==t.grReflectIntensity&&(e.groundReflectionParameters.enabled=t.grReflectIntensity>0,e.groundReflectionParameters.intensity=Ba(t.grReflectIntensity)),void 0!==t.grReflectFadeOut&&(e.groundReflectionParameters.fadeOutDistance=4*(1-Ba(t.grReflectFadeOut)))})(t,e),t})(this._customShadingParameters)),e.length>0){const t=((...e)=>{if(0===e.length)return null;if(1===e.length)return e[0];let t=e[0];for(let n=1;n<e.length;n++)t=Ge(t,e[n]);return t})(...e);this.updateParameters(t),this.bakedGroundContactShadowPass.applyParameters()}}requestUpdateOfPasses(){this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.needsUpdate=!0,this.shadowAndAoPass.needsUpdate=!0,this.shadowAndAoPass.softShadowPass.needsUpdate=!0,this._renderPassManager.materialsNeedUpdate=!0}clearCache(){this.renderCacheManager.clearCache(),this._renderPassManager.materialsNeedUpdate=!0}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadowPass.needsUpdate=!0)}updateParameters(e){e.shadowType&&this.screenSpaceShadowMapPass.switchType(e.shadowType),void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadowPass.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadowMapPass.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadowMapPass.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadowMapPass.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadowMapPass.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache();const n=e.clone();n.min.y>this.groundLevel&&(n.min.y=this.groundLevel),this.boundingVolumeSet=!0,this.gBufferRenderPass.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(n);const s=this.boundingVolume.size,i=(s.x+s.y+s.z)/3,a=Math.min(s.x,s.y,s.z),r=Math.max(s.x,s.y,s.z),o=a<.5?a/.5:s.z>5?s.z/5:1;this.bakedGroundContactShadowPass.setScale(t?i:o,i),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,r)),this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume,i),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?i:Math.min(1,2*r))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,s;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const i=e.userData;if(i&&((null===(s=t.userData)||void 0===s?void 0:s.environmentDefinition.needsUpdate)||!i.environmentTexture||i.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(i.environmentDefinition=n,i.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==i?void 0:i.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.enableObjectSelection?this.selectedObjects:[]),this._renderPassManager.updatePasses(this.renderer,e,t),this._renderPassManager.renderPasses(this.renderer,e),e.remove(this.groundGroup)}}class ph{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const s=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(s,t);const i=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(i,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const r=e.addFolder("Outline");this._addOutlineGUI(r,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",w],["SRGBColorSpace",S]]),s=[];n.forEach((e,t)=>{s.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)}),e.add(this._sceneRenderer,"outputColorSpace",s).onChange(e=>{var s;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(s=n.get(e))&&void 0!==s?s:S,t())});const i=new Map([["NoToneMapping",jt],["LinearToneMapping",zt],["ReinhardToneMapping",Vt],["CineonToneMapping",Ht],["ACESFilmicToneMapping",Wt]]),a=[];i.forEach((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)}),e.add(this._sceneRenderer,"toneMapping",a).onChange(e=>{var n;i.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=i.get(e))&&void 0!==n?n:jt,t())})}_addDebugGUI(e,t){const n=new Map([["HIGHEST","highest"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"]]),s=[];n.forEach((e,t)=>s.push(t)),e.add(this,"_qualityLevel",s).onChange(e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:"highest")}),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow soft":"shadowsoft","shadow denoised":"shadowdenoise","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","material AO pass":"materialao","ground reflection base":"groundreflection","ground reflection final":"groundreflectionfinal","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange(()=>t())}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadowMapPass.shadowConfiguration,s=[];n.types.forEach((e,t)=>{s.push(t)});const i=()=>{this._sceneRenderer.screenSpaceShadowMapPass.needsUpdate=!0,this._sceneRenderer.screenSpaceShadowMapPass.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",s).onChange(e=>{this._sceneRenderer.screenSpaceShadowMapPass.switchType(e)&&(a.object=n.currentConfiguration,r.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),r.updateDisplay(),o.updateDisplay(),i())});const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange(()=>i()),r=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange(()=>i()),o=e.add(n.currentConfiguration,"radius",0,100).onChange(()=>i())}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.requestUpdateOfPasses(),t()},s=this._sceneRenderer.shadowAndAoPass.parameters,i=s.shadow,a=this._sceneRenderer.screenSpaceShadowMapPass.parameters,r=s.ao,o=s.poissonDenoise;e.add(s,"enabled").onChange(()=>n()),e.add(s,"applyToMaterial").onChange(()=>{n(),this._sceneRenderer.clearCache()});const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),h=Array.from(l.keys());l.forEach((e,t)=>{e===r.algorithm&&(this._ambientOcclusionType=t)}),e.add(s,"aoIntensity",0,1).onChange(()=>{n()}),e.add(s,"aoOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(s,"shadowOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(s,"shadowIntensity",0,1).onChange(()=>n()),e.add(s,"alwaysUpdate").onChange(()=>n()),e.add(s,"progressiveDenoiseIterations",0,3,1).onChange(()=>n());const d=e.addFolder("Environment Shadow");d.add(a,"maximumNumberOfLightSources",-1,10,1).onChange(()=>n()),d.add(a,"enableGroundBoundary").onChange(()=>n()),d.add(a,"directionalDependency",0,1,.01).onChange(()=>n()),d.add(a,"directionalExponent",0,2,.01).onChange(()=>n()),d.add(a,"groundBoundary",0,1,.01).onChange(()=>n()),d.add(a,"fadeOutDistance",0,5,.01).onChange(()=>n()),d.add(a,"fadeOutBlur",0,20,1).onChange(()=>n()),d.add(i,"shadowRadius",.001,.5).onChange(()=>n());const c=e.addFolder("AO");c.add(this,"_ambientOcclusionType",h).onChange(e=>{if(l.has(e)){const t=l.get(e);r.algorithm=void 0!==t?t:0,n()}}),c.add(r,"samples",1,64,1).onChange(()=>n()),c.add(r,"radius",.01,2,.01).onChange(()=>n()),c.add(r,"distanceExponent",.1,4,.1).onChange(()=>n()),c.add(r,"thickness",.01,2,.01).onChange(()=>n()),c.add(r,"distanceFallOff",0,1).onChange(()=>n()),c.add(r,"scale",.01,2,.01).onChange(()=>n()),c.add(r,"bias",1e-4,.01,1e-4).onChange(()=>n()),c.add(r,"screenSpaceRadius").onChange(()=>n());const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange(()=>n()),u.add(o,"samples",0,32,1).onChange(()=>n()),u.add(o,"rings",0,16,.125).onChange(()=>n()),u.add(o,"radiusExponent",.1,4,.01).onChange(()=>n()),u.add(o,"radius",0,50,1).onChange(()=>n()),u.add(o,"lumaPhi",0,20,.001).onChange(()=>n()),u.add(o,"depthPhi",0,20,.001).onChange(()=>n()),u.add(o,"normalPhi",0,20,.001).onChange(()=>n())}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange(()=>t()),e.add(n,"fadeOutDistance",0,4).onChange(()=>t()),e.add(n,"fadeOutExponent",.1,10).onChange(()=>t()),e.add(n,"brightness",0,2).onChange(()=>t()),e.add(n,"blurHorizontal",0,10).onChange(()=>t()),e.add(n,"blurVertical",0,10).onChange(()=>t())}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadowPass.applyParameters(),t()},s=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(s,"enabled").onChange(()=>n()),e.add(s,"cameraHelper").onChange(()=>n()),e.add(s,"alwaysUpdate"),e.add(s,"fadeIn"),e.add(s,"blurMin",0,.2,.001).onChange(()=>n()),e.add(s,"blurMax",0,.5,.01).onChange(()=>n()),e.add(s,"fadeoutFalloff",0,1,.01).onChange(()=>n()),e.add(s,"fadeoutBias",0,.5).onChange(()=>n()),e.add(s,"opacity",0,1,.01).onChange(()=>n()),e.add(s,"maximumPlaneSize",0,50,1).onChange(()=>n()),e.add(s,"cameraFar",.1,10,.1).onChange(()=>n())}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},s=this._sceneRenderer.outlineRenderer.parameters;e.add(s,"enabled"),e.add(s,"edgeStrength",.5,20).onChange(()=>n()),e.add(s,"edgeGlow",0,20).onChange(()=>n()),e.add(s,"edgeThickness",.5,20).onChange(()=>n()),e.add(s,"pulsePeriod",0,5).onChange(()=>n()),e.addColor(s,"visibleEdgeColor").onChange(()=>n()),e.addColor(s,"hiddenEdgeColor").onChange(()=>n())}}const mh={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"full"},gh={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:"poisson"},fh={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:"poisson"},_h={algorithm:0,samples:32,radius:.15,distanceExponent:2,thickness:.25,distanceFallOff:1,bias:.01},vh={iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:2,normalPhi:4},wh=e("a8",new Map([["highest",{...mh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["high",{...gh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["medium",{...fh,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:_h,poissonDenoise:vh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]])),bh=new Kt;bh.enable(3);const yh=new Kt;yh.disableAll(),yh.enable(9);const Sh={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:_h,poissonDenoise:vh},xh={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:{algorithm:2,samples:16,radius:.5,distanceExponent:2,thickness:.5,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,radius:5,radiusExponent:1,lumaPhi:10,depthPhi:2,normalPhi:4}},Ph=xh,Mh={enabled:!0,fadeoutFalloff:.9,blurMax:.1,opacity:.5,hardLayers:null,softLayers:null,polygonOffset:2},Ch={enabled:!0,fadeoutFalloff:.8,blurMax:.15,opacity:.5,hardLayers:yh,softLayers:null,polygonOffset:-1},Th={enabled:!1},Ah=new Map([["highest",{...mh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["high",{...gh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["medium",{...fh,shAndAoPassParameters:Sh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:Mh}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Mh}]]),Rh=new Map([["highest",{...mh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["high",{...gh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["medium",{...fh,shAndAoPassParameters:xh,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Ch}]]),Eh=new Map([["highest",{...mh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["high",{...gh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["medium",{...fh,shAndAoPassParameters:Ph,screenSpaceShadowMapParameters:{layers:bh},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:Th}]]);class Ih{constructor(){this._index=0,this._prevTime=0,this._frames=0,this._fps=-1,this._fpsList=Array(2).fill(0),this._prevTime=(performance||Date).now(),this.reset()}update(){this._frames++;const e=(performance||Date).now();e>=this._prevTime+1e3&&(this._fpsList[this._index%2]=1e3*this._frames/(e-this._prevTime),this._index>=2&&(this._fps=this._fpsList.reduce((e,t)=>e+t)/this._fpsList.length),this._prevTime=e,this._frames=0,this._index++)}start(){this._prevTime=(performance||Date).now(),this._frames=0}reset(){this._fps=-1,this._fpsList=Array(2).fill(0),this._index=0}getFps(){return this._fps}}var Dh;e("ai",Dh),function(e){e[e.Mode3D=0]="Mode3D",e[e.Mode2D=1]="Mode2D"}(Dh||e("ai",Dh={}));class Oh{get renderer(){return this._renderer}get sceneRenderer(){return this._sceneRenderer}get screenSpaceShadowParameters(){return this.sceneRenderer.screenSpaceShadowMapPass.parameters}get shadowAndAoPassParameters(){return this._sceneRenderer.shadowAndAoPass.parameters}get bakedGroundContactShadowParameters(){return this.sceneRenderer.bakedGroundContactShadowPass.parameters}get groundReflectionParameters(){return this._sceneRenderer.groundReflectionPass.parameters}get outlineParameters(){return this._sceneRenderer.outlineRenderer.parameters}constructor(e,t,n){this.configuratorMode=!0,this.uiInteractionMode=!0,this._movingCamera=!1,this._boundingBox=new ge,this._boundingBoxNeedsUpdate=!1,this._cacheNeedsUpdate=!1,this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1,this._customShadingParameters=null,this._customShadingParametersMoc=null,this._renderer=e,this._sceneRenderer=new uh(this._renderer,t,n),this.outlineParameters.enabled=!0,this.outlineParameters.edgeStrength=2,this.outlineParameters.edgeGlow=1,this.outlineParameters.edgeThickness=2,this.outlineParameters.pulsePeriod=0,this.outlineParameters.usePatternTexture=!1,this.outlineParameters.visibleEdgeColor=16777215,this.outlineParameters.hiddenEdgeColor=16777215,Oh.enableRectAreaLightShadow&&($t.rectAreaLightReplacement=!1,$t.rectAreaLightLoadingListener=this.loadRectAreLight),this.sceneRenderer.setQualityLevel("highest"),this.SceneRendererGUI=new ph(this.sceneRenderer)}dispose(){this._sceneRenderer.dispose()}setSize(e,t){this._sceneRenderer.setSize(e,t)}setCameraType(e){this._cameraType=e}setShadingType(e){this.sceneRenderer.setShadingType(e)}setAutoQuality(e){!this._fpsCounter&&e?this._fpsCounter=new Ih:this._fpsCounter&&!e&&(this._fpsCounter=null)}setQualityLevel(e){this._sceneRenderer.setQualityLevel(e)}setQualityMap(e){this._sceneRenderer.setQualityMap(e)}setCustomShadingParameters(e,t){this._customShadingParameters=e,this._customShadingParametersMoc=t;const n=this.configuratorMode?this._customShadingParameters:this._customShadingParametersMoc;this._sceneRenderer.setCustomShadingParameters(n)}enableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!0,this._sceneRenderer.applyCurrentParameters()}disableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!1,this._sceneRenderer.applyCurrentParameters()}loadRectAreLight(e){Oh.rectAreaLightsNeedsUpdate=!0}updateRectAreaLight(e){let t=[];e.traverse(e=>{e instanceof o&&t.push(e)}),this._sceneRenderer.updateRectAreaLights(t,e),Oh.rectAreaLightsNeedsUpdate=!1}clearCache(){this._cacheNeedsUpdate=!0}forceShadowUpdates(e){this._shadowNeedsUpdate=!0,this._bakedGroundShadowNeedsUpdate=e}switchToConfigurator(){this.configuratorMode=!0,this._sceneRenderer.setQualityMapAndShadingParameters(Ah,this._customShadingParameters)}switchToPlanner(e){Dh.Mode3D,this.configuratorMode=!1,e===Dh.Mode3D?this._sceneRenderer.setQualityMapAndShadingParameters(Rh,this._customShadingParametersMoc):this._sceneRenderer.setQualityMapAndShadingParameters(Eh,null)}updateBounds(e){e&&(this._boundingBox.copy(e),this._boundingBoxNeedsUpdate=!0)}movingCameraStarts(){var e;this._movingCamera=!0,null===(e=this._fpsCounter)||void 0===e||e.start()}movingCameraStops(){this._movingCamera=!1}highlightObjects(e){this._sceneRenderer.selectObjects(e)}render(e,t){var n;this._doUpdatesBeforeRender(e,t);const s=Oh.updateNearAndFarPlaneOfPerspectiveCamera?this.createRenderCamera(t):t;if(this._sceneRenderer.render(e,s),this._movingCamera&&this._fpsCounter){null===(n=this._fpsCounter)||void 0===n||n.update();const e=this._sceneRenderer.getQualityLevel(),t=this._fpsCounter.getFps();t>0&&t<30&&"low"!==e&&("highest"===e?this.sceneRenderer.setQualityLevel("high"):"high"===e?this.sceneRenderer.setQualityLevel("medium"):"medium"===e&&this.sceneRenderer.setQualityLevel("low"),this._fpsCounter.reset())}}_doUpdatesBeforeRender(e,t){this._boundingBoxNeedsUpdate&&(this._sceneRenderer.updateBounds(this._boundingBox,!1),this._boundingBoxNeedsUpdate=!1),this._cacheNeedsUpdate&&(this._sceneRenderer.clearCache(),this._cacheNeedsUpdate=!1),this._shadowNeedsUpdate&&(this._sceneRenderer.forceShadowUpdates(this._bakedGroundShadowNeedsUpdate),this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1),Oh.rectAreaLightsNeedsUpdate&&this.updateRectAreaLight(e),t.updateMatrixWorld(),(t instanceof X||t instanceof Q)&&t.updateProjectionMatrix(),this._sceneRenderer.enableObjectSelection=!this._movingCamera&&this._cameraType!==ze.CAMERA_FP}createRenderCamera(e){const t=e.clone();return this.configuratorMode&&t instanceof X&&(this._sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(t,120),t.updateProjectionMatrix()),t}showGUI(e){const t=Zi();this.SceneRendererGUI.addGUI(t,e)}clear(){this.renderer.clear()}}e("a7",Oh),Oh.enableRectAreaLightShadow=!0,Oh.rectAreaLightsNeedsUpdate=!1,Oh.updateNearAndFarPlaneOfPerspectiveCamera=!1;class kh{_getRenderer(){const e=this._globalInitData.e2e,t=this._globalInitData.e2eRoomleRendererForImages;if(!this._imageRenderer){const t=new qt({antialias:!e,alpha:!0});t.outputColorSpace=S,t.autoClear=!0,t.setSize(1024,1024),t.outputColorSpace=S,t.autoClear=!1,t.shadowMap.enabled=!0,t.shadowMap.type=Ut,this._imageRenderer=t}return e&&!t?this._imageRenderer:(this._roomleRenderer||(this._roomleRenderer=new Oh(this._imageRenderer,1024,1024),this._roomleRenderer.setQualityMap(wh),this._roomleRenderer.setSize(1024,1024)),this._roomleRenderer)}switchToPlannerSettings(){const e=this._getRenderer();e instanceof Oh&&e.switchToPlanner(Dh.Mode3D)}switchToConfiguratorSettings(){const e=this._getRenderer();e instanceof Oh&&e.switchToConfigurator()}updateBounds(e){const t=this._getRenderer();t instanceof Oh&&t.updateBounds(e)}static getCameraTargetForBBox(e,t=0){if(!e){const e=new r;return{center:e,bounds:e,diagonal:0}}const n=e.getSize(new r);return n.addScalar(t),{center:e.getCenter(new r),bounds:n,diagonal:Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2))}}preparePerspectiveImage(e,t,n,s,i={},a=0,r){return new Promise(o=>{const{size:l=1024,showDimensions:h}=i,d=this._getRenderer();d.setSize(l,l);const c=e.fog?e.fog.clone():null,u=e.background?e.background.clone():null;e.background=null,e.fog=null,n.layers.disable(2),n.layers.disable(6),n.layers.disable(5),h?n.layers.enable(8):n.layers.disable(8);const p=-30+vs(a);kh.placeCameraForPerspectiveImage(n,s,-20,p),r&&(n.updateMatrixWorld(!0),r(n));const m=this._render(d,e,t,n);n.layers.enable(2),n.layers.enable(6),n.layers.enable(5),e.background=u,e.fog=c,o({image:m,width:l,height:l,blob:null})})}renderPerspectiveImage(e,t,n,s){return new Promise(i=>{s||(s=1024);const a=this._getRenderer();a.setSize(s,s);const r=e.fog?e.fog.clone():null,o=e.background?e.background.clone():null;e.background=null,e.fog=null,t.layers.disable(2),t.layers.disable(6),t.layers.disable(5),n?kh.placeCameraForPerspectiveImage(t,n,-20,-30):(t.aspect=1,t.updateProjectionMatrix());const l=this._render(a,e,null,t);t.layers.enable(2),t.layers.enable(6),t.layers.enable(5),e.background=o,e.fog=r,i({image:l,width:s,height:s,blob:null})})}static placeCameraForPerspectiveImage(e,t,n,s){e.far=1e3,e.fov=15,e.aspect=1,e.position.copy(t.center),e.rotation.set(0,0,0),e.rotateY(_s(s)),e.rotateX(_s(n)),e.translateZ(3.8*t.diagonal),e.updateProjectionMatrix()}prepareTopImage(e,t,n,s={}){const{showDimensions:i=!1}=s;return new Promise(s=>{const a=this._getRenderer();let r=new Q(-n.bounds.x/2,n.bounds.x/2,n.bounds.z/2,-n.bounds.z/2,.5);r.position.copy(n.center),r.rotateX(_s(-90)),r.translateZ(n.bounds.y+1),r.far=r.position.y+.5,r.layers.mask=65535;let o=200*n.bounds.x,l=200*n.bounds.z;if(o>4096||l>4096){let e=0;o>4096?e=o/4096:l>4096&&(e=l/4096),o/=e,l/=e}a.setSize(o,l);let h=e.fog?e.fog.clone():null,d=e.background?e.background.clone():null;e.background=null,e.fog=null,r.layers.disable(2),r.layers.disable(6),r.layers.disable(5),i?r.layers.enable(8):r.layers.disable(8);const c=this._render(a,e,t,r);r.layers.enable(2),r.layers.enable(6),r.layers.enable(5),e.background=d,e.fog=h,s({image:c,width:o,height:l,blob:null})})}_render(e,t,n,s){const i=e instanceof qt?e:e.renderer;e instanceof qt||(e.forceShadowUpdates(!0),e.render(t,s)),e.render(t,s),n&&(i.autoClear=!1,i.clearDepth(),i.render(n,s),i.autoClear=!0);const a=i.domElement.toDataURL();return i.clear(),a}}e("s",kh),on([hn],kh.prototype,"_globalInitData",void 0);const Lh=e=>new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}),Uh=(e,t)=>(e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Lh(e.transaction));class Bh{constructor(e){this._creator_=e,this.configStore=this._createStore("rml-idb","rml-config-store")}get allStores(){return[this.configStore]}_getValue(e,t){return t("readonly",t=>Lh(t.get(e)))}_setValue(e,t,n){return n("readwrite",n=>(n.put(t,e),Lh(n.transaction)))}_getEntries(e){return e("readonly",async t=>{if(t.getAll&&t.getAllKeys){const[e,n]=await Promise.all([Lh(t.getAllKeys()),Lh(t.getAll())]);return e.map((e,t)=>[e,n[t]])}const n=[];return await e("readonly",async e=>{await Uh(e,e=>n.push([e.key,e.value]))}),n})}deleteValue(e,t){return t("readwrite",t=>(t.delete(e),Lh(t.transaction)))}_createStore(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const s=Lh(n);return async(e,n)=>n((await s).transaction(t,e).objectStore(t))}getKey(...e){return e.join("_")}async setValue(e,t,n){const s=en(),i={id:e,data:t,lastModified:(new Date).toISOString(),referrer:s};await this._setValue(e,i,n),this._initData.debug}getValue(e,t){return this._getValue(e,t)}clearStore(e){return e("readwrite",e=>(e.clear(),Lh(e.transaction)))}async pruneOldEntries(){for(const e of this.allStores){const t=await this._getEntries(e);for(const n of t){const t=n[1].lastModified,s=(new Date).toISOString(),i=new Date(s).getTime()-new Date(t).getTime();Math.floor(i/864e5)>30&&await this.deleteValue(n[0],e)}}}}on([hn],Bh.prototype,"_initData",void 0);const Nh=e("I",[new Yt("error-handler",class{constructor(){this._listeners={}}_subscribe(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}subscribe(e,t){this._subscribe(e,t)}dispatch(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let s=n.length;for(let e=0;e<s;e++){const s=n[e];s.apply(s,t)}}unsubscribe(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let s=n.length;for(let e=0;e<s;e++)if(n[e]===t)return n.splice(e,1),s--,void e--}softReject(e,t,n){return this.dispatch(n,[t]),e()}}),new Yt("form-data-util",Zt),new Yt("hdr-environment-loader",class{constructor(e){this._creator_=e;const t=new h("#DDDDDD");this._environmentMap=((e,t,n,s)=>{const i=new we;i.format=be,i.generateMipmaps=!1;for(let s=0;s<6;++s){const a=Bi(e,t,n,1);a.format=i.format,a.type=i.type,a.minFilter=i.minFilter,a.magFilter=i.magFilter,a.generateMipmaps=i.generateMipmaps,a.needsUpdate=!0,i.images[s]=a}return i.needsUpdate=!0,i})(t.r,t.g,t.b)}async loadUrl(e,t){const n=t.toLowerCase();this._environmentMap=n.endsWith(".exr")?await this._loadExr(t):await this._loadRgbe(t),this._environmentMap.mapping=xt;const s={url:t,environmentMap:this._environmentMap};return this._envChangedCallback(s),s}_loadExr(e){var t;return this._exrLoader=null!==(t=this._exrLoader)&&void 0!==t?t:new ul,this._exrLoader.setPath(e.startsWith("http")?"":n()),this._exrLoader.loadAsync(e)}_loadRgbe(e){var t;return this._rgbeLoader=null!==(t=this._rgbeLoader)&&void 0!==t?t:new pl,this._rgbeLoader.setPath(e.startsWith("http")?"":n()),this._rgbeLoader.loadAsync(e)}registerEnvironmentChangedCallback(e){this._envChangedCallback=e}}),new Yt("static-item-loader",class{constructor(e){this._gltfLoaderGuard=new _n,this._creator_=e,this._initLoaders()}_initLoaders(){this._gltfLoader=new yn;const e=new ps,t=e._loadLibrary.bind(e._loadLibrary);e._loadLibrary=(e,s)=>{const i=gs[e];if(!i)throw new Error('Can not load draco dependency "'+e+'" did three.js update DracoLoader lib? Available files'+JSON.stringify(gs));return t(n()+i,s)},e.setDecoderConfig({type:"wasm"}),this._gltfLoader.setDRACOLoader(e),this._gltfLoaderGuard.resolve(this._gltfLoader)}async loadGLB(e,t,n,s,i,a,r,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.load(e,e=>{l(this._handleGLTFScene("GLB",e,t,n,s,i,a,r))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}async loadGLTF(e,t,n,s,i,a,r,o){return await this._gltfLoaderGuard.wait(),new Promise((l,h)=>{this._gltfLoader.parse(e,null,e=>{l(this._handleGLTFScene("GLTF",e,t,n,s,i,a,r))},e=>{o&&o(e.loaded/e.total)},e=>{h(e)})})}_handleGLTFScene(e,t,n,s,i,a,o,l){if(!t||!t.scene||!t.scene.children||0===t.scene.children.length)return null;n&&t.scene.position.copy(n),s&&(t.scene.rotation.y=s);const d=new ge;if(d.setFromObject(t.scene),i){const{x:e,y:n,z:s}=d.getSize(new r);let a=new r(i.x/e,i.y/n,i.z/s);t.scene.scale.copy(a)}return a&&t.scene.scale.multiply(a),t.scene.type=e,t.scene.traverse(e=>{if(e instanceof z){if(e.layers.set(3),e.material instanceof N){const t=e.material;if(l&&o&&o>0){let e=new h(o);t.color=e.copySRGBToLinear(e),t.roughness=.5,t.metalness=.1}t.needsUpdate=!0}e.castShadow=!0,e.receiveShadow=!0}}),{boundingBox:d,scene:t.scene}}},0),new Yt("form-data-util",Zt),new Yt("single-promise-factory",class{constructor(e){this._promises=new Map,this._creator_=e}create(e,t,n){return new Promise((s,i)=>{let a=this._promises.get(e),r=!0;if(!a){const t=new Map;this._promises.set(e,t),a=this._promises.get(e),r=!1}a.get(t)||(a.set(t,[]),r=!1);const o=a.get(t);o.push({resolve:s,reject:i}),a.set(t,o);const l=()=>{a.delete(t),0===a.size&&this._promises.delete(e)};r||new Promise(n).then(e=>{a.get(t).forEach(({resolve:t})=>t(e)),l()},e=>{a.get(t).forEach(({reject:t})=>t(e)),l()})})}},1),new Yt("dynamic-light-setting-loader",$t),new Yt("network-layer",rn),new Yt("local-storage",class{constructor(e){this._context_=e}get _localStorage(){let e=null;try{e=window.localStorage}catch(e){console.error(e)}return e}getItem(e){if(!this._localStorage)return null;const t=this._localStorage.getItem(e);try{return JSON.parse(t)}catch(e){return t}}setItem(e,t){if(this._localStorage)try{const n=JSON.stringify(t);this._localStorage.setItem(e,n)}catch(e){console.error(e)}}}),new Yt("network-layer",rn),new Yt("kernel-io",cn,0),new Yt("data-syncer",fn),new Yt("memory-manager",class{constructor(){this._configurationStringSet=new Set,this._singleLoadCounter=0}loadingConfigurationString(){this._singleLoadCounter+=1}loadingConfiguration(e){this._configurationStringSet.add(e),this._singleLoadCounter+=1}shouldHardReset(){return this._configurationStringSet.size>=15||this._singleLoadCounter>=30}executedHardReset(){this._configurationStringSet.clear(),this._singleLoadCounter=0}}),new Yt("life-cycle-manager",class{constructor(){this._listeners=[]}addEventListener(e){this._listeners.push(e)}removeEventListener(e){const t=this._listeners;let n=t.length;if(n)for(let s=0;s<n;s++)t[s]===e&&(t.splice(s,1),s--,n--)}pause(){this._listeners.forEach(e=>e.pause())}resume(){this._listeners.forEach(e=>e.resume())}destroy(){this._listeners.forEach(e=>e.destroy())}},1),new Yt("local-storage-helper",fs),new Yt("cache-holder",class{constructor(){this._componentCache=new Map,this._geometryCache=new Map,this._materialCache=new Map}get componentCache(){return this._componentCache}get geometryCache(){return this._geometryCache}get materialCache(){return this._materialCache}clear(){for(const e of this._componentCache.values())ta(e);for(const e of this._materialCache.values())ia(e);for(const e of this._geometryCache.values())sa(e);this._componentCache.clear(),this._geometryCache.clear(),this._materialCache.clear()}},0),new Yt("kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Yt("configurator-kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}updatePossibleChildren(e,t,n){this._callbackListener.forEach(s=>s.updatePossibleChildren(e,t,n))}updateParameters(e,t,n,s){this._callbackListener.forEach(i=>i.updateParameters(e,t,n,s))}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new Yt("configurator-context",class{constructor(){this.planObjectId=0,this.planElementId=0,this.rootComponentId=0,this.dockingRootComponentId=0,this.baseContext=null,this.rootComponentParametersAsGlobal=!1,this.lastLoadedRapiId=null,this.lastLoadedPlanId=null,this.selectedRuntimeComponentIds=[],this.selectionMode="standard"}get selectedRuntimeComponentId(){return this.selectedRuntimeComponentIds.length>0?this.selectedRuntimeComponentIds[0]:null}},1),new Yt("init-data",Na,1),new Yt("global-init-data",Ga,0),new Yt("global-callback",za,0),new Yt("dom-helper",Va,1),new Yt("unit-formatter",Bo,0),new Yt("plugin-system",Ha,1),new Yt("configurator-mesh-generator",qa),new Yt("configurator-input-manager",class extends $a{},1),new Yt("selection-handler",class extends Xa{constructor(){super(...arguments),this._selectionMode="standard",this._selectedComponents=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedComponents.size&&this._selectedComponents.forEach((e,t)=>{e.deselect(),this._selectedComponents.delete(t),this.dispatchEvent(1,new er({component:e}))})}_checkStandard(e){this._selectedComponents.has(e.runtimeId)?this.dispatchEvent(0,new er({component:e,consecutive:!0})):(this._selectedComponents.size>0&&this._selectedComponents.forEach((e,t)=>{this._selectedComponents.delete(t),this.dispatchEvent(1,new er({component:e,resetCamera:!1}))}),this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new er({component:e,consecutive:!1})))}_checkMulti(e){if(this._selectedComponents.has(e.runtimeId))return this._selectedComponents.delete(e.runtimeId),void this.dispatchEvent(1,new er({component:e,resetCamera:0===this._selectedComponents.size}));this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new er({component:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedComponents.size>0}getSelectedRuntimeComponentIds(){let e=[];return this._selectedComponents.forEach(t=>e.push(t.runtimeId)),e}isSelected(e){return this._selectedComponents.has(e.runtimeId)}},1),new Yt("component-dimensioning-helper",or,1),new Yt("component-dimensioning-helper",or,1),new Yt("planner-kernel-access",Io),new Yt("planner-mesh-generator",Do,1),new Yt("unit-formatter",Bo),new Yt("configurator-history",No,1),new Yt("roomle-planner-ui-callback",class extends ja{constructor(e){super(e),this.onItemsLoaded=()=>{},this.onCameraChanged=e=>{},this.onCameraIdle=()=>{},this.onTotalFloorAreaChanged=e=>{},this.onPlanInteractionHandlerCreated=e=>{},this.onPlannerKernelIsReady=e=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onSelectionChange=(e,t,n,s,i)=>{},this.onSelectionCancel=e=>{},this.onPlanChanged=()=>{},this.onPlanElementChanged=(e,t)=>{},this.onCompletelyLoaded=()=>{},this.onRotationCancel=()=>{},this.onHistoryChange=(e,t)=>{},this.onUpdateWallDimensions=e=>{},this.onUpdateMeasurementLineDimensions=e=>{},this.onUpdateConstructionElementsMeasurements=e=>{},this.onUpdateObjectMeasurements=e=>{},this.disableWallDimensions=()=>{},this.onUpdatePlanObjectPositions=e=>{},this.onDrawCancel=()=>{},this.onDrawingStateChanged=e=>{},this.onHandlerSwitchedPlans=()=>{},this.onDragElementStart=()=>{},this.onDragElementEnd=()=>{},this.onClickElement=e=>{},this.onMultiSelectionChange=e=>{},this.onSelectionModeChange=e=>{},this.onMeasurementLineStateChange=e=>{},this.onFloorPlanAreasUpdated=e=>{}}}),new Yt("configurator-ui-callbacks",class extends ja{constructor(e){super(e),this.onKernelIsReady=null,this.onComponentPositionsUpdated=null,this.onUpdateParameters=e=>{},this.onUpdatePossibleChildren=(e,t)=>{},this.onUpdatePrice=(e,t)=>{},this.onSelectionChange=(e,t,n,s)=>{},this.onSelectionCancel=()=>{},this.onPartListUpdate=(e,t)=>{},this.onBoundsUpdate=e=>{},this.onLoadConfiguration=()=>{},this.onConfigurationReady=(e,t,n)=>{},this.onOpenTag=e=>{},this.onOpenAddOns=()=>{},this.onClickOutside=()=>{},this.onNoDockingsAvailable=()=>{},this.onUiIntersectionChange=e=>{},this.onZoomChange=(e,t)=>{},this.onZoomToComponent=()=>{},this.onDimensionsVisibilityChange=e=>{},this.onErrorDueToOffline=e=>{},this.onError=e=>{},this.onElementDocked=(e,t)=>{},this.onDockingsPreviewRemoved=()=>{},this.onConfigurationHasChildren=e=>{},this.onTrackTiming=(e,t,n,s)=>{},this.onUserInitiatedDockDone=(e,t,n,s,i)=>{},this.onAddonPlusHover=()=>{},this.onAddonPlusHoverOff=()=>{},this.onAddonPlusShown=()=>{},this.onAddonPlusHidden=()=>{},this.onContentProblem=e=>{},this.onSyncStarted=()=>{},this.onSyncDone=()=>{},this.onOpenFloorMaterials=()=>{},this.onOpenPartList=()=>{},this.onComponentLoadError=(e,t)=>{},this.onConfigurationLoadError=()=>{},this.onChangeTypeChangeTag=e=>{},this.onRemoveTypeChangeTag=e=>{},this.onConfigurationLabelChange=(e,t,n)=>{},this.onMemoryCorruption=()=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onConfigurationSaved=e=>{},this.onCameraPositionChanges=()=>{},this.onHistoryChange=(e,t)=>{},this.onClickComponent=e=>{},this.onRequestExternalMesh=(e,t)=>{},this.onGeometryReady=e=>{},this.onGeometryNotReady=e=>{}}},1),new Yt("roomle-tools-core",Fo,0),new Yt("image-renderer",kh,0),new Yt("idb-manager",Bh,0),new Yt("camera-behaviour-state",class{constructor(e){this._lastPlanBounds=new ge,this._creator_=e}isWithinPlanBounds(e,t){const n=this._lastPlanBounds.containsPoint(e);return t&&this._lastPlanBounds.copy(t),n}},1)]);class Fh{static _ensureContainer(){window.__RML__DI__||(window.__RML__DI__=new Xt,window.__RML__DI__.addDependencyInjectionAssignments(Nh))}static setup(e){Fh.addToContainer(e)}static lookup(e,t){return window.__RML__DI__?window.__RML__DI__.lookup(e,t):null}static getContext(e){return Fh._ensureContainer(),window.__RML__DI__.getContext(e)}static cleanUp(e){return window.__RML__DI__?window.__RML__DI__.cleanUp(e):null}static addToContainer(e){Fh._ensureContainer(),window.__RML__DI__.addDependencyInjectionAssignments(e)}}e("b",Fh)}}}));
9
+ //# sourceMappingURL=roomle-dependency-injection-b567df3a.nomodule.js.map