@vertexvis/viewer 1.1.1-testing.4 → 1.1.1-testing.5

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 (181) hide show
  1. package/dist/cjs/{config-BY0v6BSK.js → config-OELTgslY.js} +3 -3
  2. package/dist/cjs/{config-BY0v6BSK.js.map → config-OELTgslY.js.map} +1 -1
  3. package/dist/cjs/{entities-CEaa12yP.js → entities-rj-TEPKc.js} +4 -4
  4. package/dist/cjs/{entities-CEaa12yP.js.map → entities-rj-TEPKc.js.map} +1 -1
  5. package/dist/cjs/{geometry_pb-EVfAEuPO.js → geometry_pb-asn2mNvW.js} +3 -3
  6. package/dist/cjs/{geometry_pb-EVfAEuPO.js.map → geometry_pb-asn2mNvW.js.map} +1 -1
  7. package/dist/cjs/index.cjs.js +5 -5
  8. package/dist/cjs/{queries-LthBzEHD.js → queries-e19TP_oF.js} +4 -4
  9. package/dist/cjs/{queries-LthBzEHD.js.map → queries-e19TP_oF.js.map} +1 -1
  10. package/dist/cjs/{regl-component-B_JaaVlv.js → regl-component-DjVaO3t3.js} +3 -3
  11. package/dist/cjs/{regl-component-B_JaaVlv.js.map → regl-component-DjVaO3t3.js.map} +1 -1
  12. package/dist/cjs/{representation_pb-B6XR10pQ.js → representation_pb-BVBPrHLf.js} +3 -3
  13. package/dist/cjs/{representation_pb-B6XR10pQ.js.map → representation_pb-BVBPrHLf.js.map} +1 -1
  14. package/dist/cjs/{streamAttributes-nCF7u7lv.js → streamAttributes-M3UUIO3l.js} +117 -94
  15. package/dist/cjs/streamAttributes-M3UUIO3l.js.map +1 -0
  16. package/dist/cjs/vertex-scene-tree-notification-banner_4.cjs.entry.js +1 -1
  17. package/dist/cjs/vertex-scene-tree-notification-banner_4.cjs.entry.js.map +1 -1
  18. package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js +2 -2
  19. package/dist/cjs/vertex-scene-tree-table-cell.cjs.entry.js.map +1 -1
  20. package/dist/cjs/vertex-scene-tree.cjs.entry.js +2 -2
  21. package/dist/cjs/vertex-viewer-dom-element_2.cjs.entry.js +1 -1
  22. package/dist/cjs/vertex-viewer-hit-result-indicator.cjs.entry.js +2 -2
  23. package/dist/cjs/vertex-viewer-measurement-details.cjs.entry.js +2 -2
  24. package/dist/cjs/vertex-viewer-measurement-distance.cjs.entry.js +2 -2
  25. package/dist/cjs/vertex-viewer-measurement-line_2.cjs.entry.js +2 -2
  26. package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +4 -4
  27. package/dist/cjs/vertex-viewer-pin-group.cjs.entry.js +3 -3
  28. package/dist/cjs/vertex-viewer-pin-label_2.cjs.entry.js +2 -2
  29. package/dist/cjs/vertex-viewer-pin-label_2.cjs.entry.js.map +1 -1
  30. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js +3 -3
  31. package/dist/cjs/vertex-viewer-transform-widget.cjs.entry.js.map +1 -1
  32. package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +1 -1
  33. package/dist/cjs/vertex-viewer.cjs.entry.js +4 -4
  34. package/dist/collection/components/scene-tree-search/scene-tree-search.js +1 -1
  35. package/dist/collection/components/scene-tree-search/scene-tree-search.js.map +1 -1
  36. package/dist/collection/components/scene-tree-table-cell/scene-tree-table-cell.js +1 -1
  37. package/dist/collection/components/scene-tree-table-cell/scene-tree-table-cell.js.map +1 -1
  38. package/dist/collection/components/viewer-pin-label/viewer-pin-label.js +2 -2
  39. package/dist/collection/components/viewer-pin-label/viewer-pin-label.js.map +1 -1
  40. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget-components.js +1 -1
  41. package/dist/collection/components/viewer-transform-widget/viewer-transform-widget-components.js.map +1 -1
  42. package/dist/collection/workers/png-decoder-pool.js +4 -3
  43. package/dist/collection/workers/png-decoder-pool.js.map +1 -1
  44. package/dist/components/index.js +1 -1
  45. package/dist/components/{p-COznr3CH.js → p-5bk1mHRt.js} +2 -2
  46. package/dist/components/{p-D3bzgaCV.js → p-B8530k7R.js} +2 -2
  47. package/dist/components/{p-CWcvgy8e.js → p-BCuMPvZO.js} +2 -2
  48. package/dist/components/{p-DTwJX9HL.js → p-BgzjmANj.js} +2 -2
  49. package/dist/components/{p-DTwJX9HL.js.map → p-BgzjmANj.js.map} +1 -1
  50. package/dist/components/p-BjvjKoy7.js +5 -0
  51. package/dist/components/p-BjvjKoy7.js.map +1 -0
  52. package/dist/components/{p-Cxz4L6FA.js → p-Bwtyddca.js} +2 -2
  53. package/dist/components/{p-Ca253f0h.js → p-Bx42CNGV.js} +2 -2
  54. package/dist/components/p-C86HMDzi.js +5 -0
  55. package/dist/components/{p-Y8W_BXUk.js.map → p-C86HMDzi.js.map} +1 -1
  56. package/dist/components/p-CSVgoQU8.js +5 -0
  57. package/dist/components/{p-Cku0WCYo.js.map → p-CSVgoQU8.js.map} +1 -1
  58. package/dist/components/{p-D3in41xo.js → p-CTi-0-dI.js} +2 -2
  59. package/dist/components/{p-D1Vdomj_.js → p-D_h07qsA.js} +2 -2
  60. package/dist/components/{p-BNRm88jS.js → p-KidjtXKE.js} +2 -2
  61. package/dist/components/vertex-scene-tree-search.js +1 -1
  62. package/dist/components/vertex-scene-tree-table-cell.js +1 -1
  63. package/dist/components/vertex-scene-tree-table-cell.js.map +1 -1
  64. package/dist/components/vertex-scene-tree.js +1 -1
  65. package/dist/components/vertex-viewer-dom-renderer.js +1 -1
  66. package/dist/components/vertex-viewer-hit-result-indicator.js +1 -1
  67. package/dist/components/vertex-viewer-measurement-details.js +1 -1
  68. package/dist/components/vertex-viewer-measurement-distance.js +1 -1
  69. package/dist/components/vertex-viewer-measurement-overlays.js +1 -1
  70. package/dist/components/vertex-viewer-measurement-precise.js +1 -1
  71. package/dist/components/vertex-viewer-pin-group.js +1 -1
  72. package/dist/components/vertex-viewer-pin-label.js +1 -1
  73. package/dist/components/vertex-viewer-pin-tool.js +1 -1
  74. package/dist/components/vertex-viewer-transform-widget.js +1 -1
  75. package/dist/components/vertex-viewer-transform-widget.js.map +1 -1
  76. package/dist/components/vertex-viewer-view-cube.js +1 -1
  77. package/dist/components/vertex-viewer.js +1 -1
  78. package/dist/esm/{config-ss9ha12b.js → config-Cqrcty7U.js} +3 -3
  79. package/dist/esm/{config-ss9ha12b.js.map → config-Cqrcty7U.js.map} +1 -1
  80. package/dist/esm/{entities-DEFAhYdV.js → entities-CawBZH7i.js} +4 -4
  81. package/dist/esm/{entities-DEFAhYdV.js.map → entities-CawBZH7i.js.map} +1 -1
  82. package/dist/esm/{geometry_pb-D7fM1PYG.js → geometry_pb-COdZQiRi.js} +3 -3
  83. package/dist/esm/{geometry_pb-D7fM1PYG.js.map → geometry_pb-COdZQiRi.js.map} +1 -1
  84. package/dist/esm/index.js +5 -5
  85. package/dist/esm/index.mjs +5 -5
  86. package/dist/esm/{queries-BcmE5Zbq.js → queries-B4XotYyr.js} +4 -4
  87. package/dist/esm/{queries-BcmE5Zbq.js.map → queries-B4XotYyr.js.map} +1 -1
  88. package/dist/esm/{regl-component-gIonUTBJ.js → regl-component-B1_h3_s8.js} +3 -3
  89. package/dist/esm/{regl-component-gIonUTBJ.js.map → regl-component-B1_h3_s8.js.map} +1 -1
  90. package/dist/esm/{representation_pb-Bf023NuN.js → representation_pb-C4MJfZMo.js} +3 -3
  91. package/dist/esm/{representation_pb-Bf023NuN.js.map → representation_pb-C4MJfZMo.js.map} +1 -1
  92. package/dist/esm/{streamAttributes-Bj2xDHfI.js → streamAttributes-BW9JzMeG.js} +116 -93
  93. package/dist/esm/streamAttributes-BW9JzMeG.js.map +1 -0
  94. package/dist/esm/vertex-scene-tree-notification-banner_4.entry.js +1 -1
  95. package/dist/esm/vertex-scene-tree-notification-banner_4.entry.js.map +1 -1
  96. package/dist/esm/vertex-scene-tree-table-cell.entry.js +2 -2
  97. package/dist/esm/vertex-scene-tree-table-cell.entry.js.map +1 -1
  98. package/dist/esm/vertex-scene-tree.entry.js +2 -2
  99. package/dist/esm/vertex-viewer-dom-element_2.entry.js +1 -1
  100. package/dist/esm/vertex-viewer-hit-result-indicator.entry.js +2 -2
  101. package/dist/esm/vertex-viewer-measurement-details.entry.js +2 -2
  102. package/dist/esm/vertex-viewer-measurement-distance.entry.js +2 -2
  103. package/dist/esm/vertex-viewer-measurement-line_2.entry.js +2 -2
  104. package/dist/esm/vertex-viewer-measurement-precise.entry.js +4 -4
  105. package/dist/esm/vertex-viewer-pin-group.entry.js +3 -3
  106. package/dist/esm/vertex-viewer-pin-label_2.entry.js +2 -2
  107. package/dist/esm/vertex-viewer-pin-label_2.entry.js.map +1 -1
  108. package/dist/esm/vertex-viewer-transform-widget.entry.js +3 -3
  109. package/dist/esm/vertex-viewer-transform-widget.entry.js.map +1 -1
  110. package/dist/esm/vertex-viewer-view-cube.entry.js +1 -1
  111. package/dist/esm/vertex-viewer.entry.js +4 -4
  112. package/dist/types/workers/png-decoder-pool.d.ts +0 -1
  113. package/dist/viewer/index.esm.js +1 -1
  114. package/dist/viewer/{p-00540193.entry.js → p-1506f9a2.entry.js} +2 -2
  115. package/dist/viewer/{p-5cfb3047.entry.js → p-293d8f3f.entry.js} +2 -2
  116. package/dist/viewer/{p-9a39315d.entry.js → p-2faddbf8.entry.js} +2 -2
  117. package/dist/viewer/{p-7cb9c9bb.entry.js → p-36349a80.entry.js} +2 -2
  118. package/dist/viewer/p-36349a80.entry.js.map +1 -0
  119. package/dist/viewer/p-44395076.entry.js +5 -0
  120. package/dist/viewer/{p-e4913b06.entry.js.map → p-44395076.entry.js.map} +1 -1
  121. package/dist/viewer/{p-30a5748d.entry.js → p-45cc095e.entry.js} +2 -2
  122. package/dist/viewer/{p-d5a57757.entry.js → p-93311f46.entry.js} +2 -2
  123. package/dist/viewer/{p-CyiY_hsD.js → p-BEOO-Ypv.js} +2 -2
  124. package/dist/viewer/{p-CyiY_hsD.js.map → p-BEOO-Ypv.js.map} +1 -1
  125. package/dist/viewer/{p-CS8PfgcI.js → p-BJGbLthH.js} +2 -2
  126. package/dist/viewer/{p-CS8PfgcI.js.map → p-BJGbLthH.js.map} +1 -1
  127. package/dist/viewer/{p-D2IEHEGM.js → p-Br21pGVj.js} +2 -2
  128. package/dist/viewer/{p-D2IEHEGM.js.map → p-Br21pGVj.js.map} +1 -1
  129. package/dist/viewer/{p-kMZA0v7I.js → p-Bw_ryWU0.js} +2 -2
  130. package/dist/viewer/{p-kMZA0v7I.js.map → p-Bw_ryWU0.js.map} +1 -1
  131. package/dist/viewer/{p-DHK23fw4.js → p-C4_1Jc7H.js} +2 -2
  132. package/dist/viewer/{p-DHK23fw4.js.map → p-C4_1Jc7H.js.map} +1 -1
  133. package/dist/viewer/p-Cc3XhAoA.js +5 -0
  134. package/dist/viewer/p-Cc3XhAoA.js.map +1 -0
  135. package/dist/viewer/p-DYDhLlLS.js +5 -0
  136. package/dist/viewer/{p-_LpaX1ga.js.map → p-DYDhLlLS.js.map} +1 -1
  137. package/dist/viewer/{p-48020de1.entry.js → p-a94b626c.entry.js} +2 -2
  138. package/dist/viewer/{p-b79c295a.entry.js → p-ced98004.entry.js} +2 -2
  139. package/dist/viewer/{p-32a51a21.entry.js → p-dcb6ddfe.entry.js} +2 -2
  140. package/dist/viewer/p-dcb6ddfe.entry.js.map +1 -0
  141. package/dist/viewer/{p-cc835213.entry.js → p-ea45c3e9.entry.js} +2 -2
  142. package/dist/viewer/p-ebd9dd99.entry.js +5 -0
  143. package/dist/viewer/p-ebd9dd99.entry.js.map +1 -0
  144. package/dist/viewer/{p-edc2f914.entry.js → p-ecd594f2.entry.js} +2 -2
  145. package/dist/viewer/p-fec5a15d.entry.js +5 -0
  146. package/dist/viewer/p-fec5a15d.entry.js.map +1 -0
  147. package/dist/viewer/viewer.esm.js +1 -1
  148. package/package.json +9 -9
  149. package/dist/cjs/streamAttributes-nCF7u7lv.js.map +0 -1
  150. package/dist/components/p-Cku0WCYo.js +0 -5
  151. package/dist/components/p-CvEK3ZK1.js +0 -5
  152. package/dist/components/p-CvEK3ZK1.js.map +0 -1
  153. package/dist/components/p-Y8W_BXUk.js +0 -5
  154. package/dist/esm/streamAttributes-Bj2xDHfI.js.map +0 -1
  155. package/dist/viewer/p-32a51a21.entry.js.map +0 -1
  156. package/dist/viewer/p-4dd67d16.entry.js +0 -5
  157. package/dist/viewer/p-4dd67d16.entry.js.map +0 -1
  158. package/dist/viewer/p-7cb9c9bb.entry.js.map +0 -1
  159. package/dist/viewer/p-BhKTTmpL.js +0 -5
  160. package/dist/viewer/p-BhKTTmpL.js.map +0 -1
  161. package/dist/viewer/p-_LpaX1ga.js +0 -5
  162. package/dist/viewer/p-e4913b06.entry.js +0 -5
  163. package/dist/viewer/p-fd3a5837.entry.js +0 -5
  164. package/dist/viewer/p-fd3a5837.entry.js.map +0 -1
  165. /package/dist/components/{p-COznr3CH.js.map → p-5bk1mHRt.js.map} +0 -0
  166. /package/dist/components/{p-D3bzgaCV.js.map → p-B8530k7R.js.map} +0 -0
  167. /package/dist/components/{p-CWcvgy8e.js.map → p-BCuMPvZO.js.map} +0 -0
  168. /package/dist/components/{p-Cxz4L6FA.js.map → p-Bwtyddca.js.map} +0 -0
  169. /package/dist/components/{p-Ca253f0h.js.map → p-Bx42CNGV.js.map} +0 -0
  170. /package/dist/components/{p-D3in41xo.js.map → p-CTi-0-dI.js.map} +0 -0
  171. /package/dist/components/{p-D1Vdomj_.js.map → p-D_h07qsA.js.map} +0 -0
  172. /package/dist/components/{p-BNRm88jS.js.map → p-KidjtXKE.js.map} +0 -0
  173. /package/dist/viewer/{p-00540193.entry.js.map → p-1506f9a2.entry.js.map} +0 -0
  174. /package/dist/viewer/{p-5cfb3047.entry.js.map → p-293d8f3f.entry.js.map} +0 -0
  175. /package/dist/viewer/{p-9a39315d.entry.js.map → p-2faddbf8.entry.js.map} +0 -0
  176. /package/dist/viewer/{p-30a5748d.entry.js.map → p-45cc095e.entry.js.map} +0 -0
  177. /package/dist/viewer/{p-d5a57757.entry.js.map → p-93311f46.entry.js.map} +0 -0
  178. /package/dist/viewer/{p-48020de1.entry.js.map → p-a94b626c.entry.js.map} +0 -0
  179. /package/dist/viewer/{p-b79c295a.entry.js.map → p-ced98004.entry.js.map} +0 -0
  180. /package/dist/viewer/{p-cc835213.entry.js.map → p-ea45c3e9.entry.js.map} +0 -0
  181. /package/dist/viewer/{p-edc2f914.entry.js.map → p-ecd594f2.entry.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{r as t,c as i,h as s,H as n,a as e}from"./p-CCVkga9Q.js";import{p as o,v as a,a as r,b as h,r as c,c as l,d,e as u}from"./p-2UsvOTHJ.js";import{s as f}from"./p-BU0JYf18.js";import{t as p,p as m,S as w,a as v,c as g,W as y}from"./p-5kcpg4MZ.js";import{m as b,E as C,a as I,c as P,d as S,o as k,u as T,b as A}from"./p-CDM7zNn0.js";import{c as D}from"./p-Dw4-tG-V.js";import{u as x,I as M,p as E,C as R,W as B,S as j,V as z,M as L,a as V,b as $}from"./p--8q6LyIm.js";import{p as O}from"./p-DHK23fw4.js";import{s as H,r as K}from"./p-BNuMPeJ8.js";import{r as N,c as F,a as W}from"./p-CioaIHsi.js";import{i as q,j as U,k as _,l as J,m as Z,n as X,o as G,p as Q,q as Y,u as tt,t as it,r as st,s as nt,v as et,w as ot,x as at,y as rt,z as ht,B as ct,C as lt,E as dt,G as ut,H as ft,I as pt,J as mt,K as wt,L as vt,M as gt,N as yt,P as bt}from"./p-BhKTTmpL.js";import{t as Ct,m as It,n as Pt,j as St,M as kt,k as Tt,S as At}from"./p-_LpaX1ga.js";import{p as Dt}from"./p-kMZA0v7I.js";import{C as xt}from"./p-DxMDDbmh.js";import{g as Mt,c as Et}from"./p-D0aTA_2m.js";import{E as Rt}from"./p-BAhfr1Nx.js";import{V as Bt}from"./p-CeZe0Qql.js";import{B as jt,M as zt}from"./p-DIbJ8Ijj.js";import{w as Lt}from"./p-BxtKMwBH.js";import"./p-ux1ckSDN.js";import"./p-CG9AChtV.js";import"./p-CPk-nchx.js";const Vt=0;const $t=255;class Ot{constructor(t){this.viewer=t;this.handleInteractionStarted=()=>{this.invalidateStencilBuffer();this.pendingInteractionFinished=new Promise((t=>{this.pendingInteractionFinishedResolver=t}))};this.handleInteractionFinished=()=>{var t;(t=this.pendingInteractionFinishedResolver)===null||t===void 0?void 0:t.call(this);this.pendingInteractionFinished=undefined;this.pendingInteractionFinishedResolver=undefined};this.invalidateStencilBuffer=()=>{this.pendingStencilBuffer=undefined};t.addEventListener("interactionStarted",this.handleInteractionStarted);t.addEventListener("interactionFinished",this.handleInteractionFinished);t.addEventListener("frameReceived",(()=>{this.invalidateStencilBuffer()}))}async fetch(){var t;const i=await this.viewer.isSceneReady();const s=i?await this.viewer.scene():undefined;const n=s!=null?s.crossSectioning().current().sectionPlanes.length>0||this.viewer.featureLines!=null:false;const e=(t=this.viewer.frame)===null||t===void 0?void 0:t.scene.camera;if(n&&this.viewer.stream!=null&&e!=null){const t=await this.viewer.stream.getStencilBuffer({includeDepthBuffer:true});const{stencilBuffer:i,depthBuffer:s,imageAttributes:n}=q(t);const[o,a]=await Promise.all([U(new Uint8Array(i)),U(new Uint8Array(s))]);return Ht.fromPng(o,n,i,_.fromPng(a,e,n))}else return undefined}latest(){if(this.pendingStencilBuffer==null){this.pendingStencilBuffer=this.fetch()}return this.pendingStencilBuffer}async latestAfterInteraction(){await this.pendingInteractionFinished;return this.latest()}}class Ht{constructor(t,i,s,n,e){this.imageAttr=t;this.imageBytes=i;this.pixelBytes=s;this.imageChannels=n;this.depthBuffer=e}static fromPng(t,i,s,n){if(!(t.data instanceof Uint8Array)){throw new Error("Expected stencil PNG to have depth of 8-bit")}else if(t.channels!==1){throw new Error("Expected stencil PNG to have 1 color channel")}else{return new Ht(i,s,t.data,t.channels,n)}}getValue(t){const{width:i,height:s}=this.imageAttr.imageRect;const n=o.subtract(t,this.imageAttr.imageRect);const e=1/this.imageAttr.imageScale;const a=o.scale(n,e,e);if(a.x>=0&&a.y>=0&&a.x<i&&a.y<s){const t=Math.floor(a.x)+Math.floor(a.y)*i;const s=this.pixelBytes[t];return s}else return 0}hitTest(t){return this.getValue(t)!==Vt}snapToNearestPixel(t,i,s=()=>true){const n=i*2;const e=o.create(t.x-i,t.y-i);const a=[];for(let r=0;r<n*n;r++){const h=r%n;const c=Math.floor(r/n);const l=o.add(e,{x:h,y:c});if(o.distance(l,t)<=i){const t=this.getValue(l);if(t===$t&&s(t)){a.push(l)}}}const r=a.sort(((i,s)=>o.distance(i,t)-o.distance(s,t)));const h=r[0];return h!=null?o.create(Math.floor(h.x)+.5,Math.floor(h.y)+.5):t}}function Kt(t){return new Promise((i=>setTimeout(i,t)))}const Nt=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",Z),b.mapRequiredProp("modifiedAt",Z),b.mapProp("name",X),b.mapProp("suppliedId",X))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,name:n,suppliedId:e})));const Ft=b.ifInvalidThrow(Nt);const Wt=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",Z),b.mapRequiredProp("modifiedAt",Z),b.mapProp("suppliedId",X),b.mapRequiredProp("data",(t=>{if(t.callout!=null){return Ut(t.callout)}else if(t.customJson!=null){return _t(t.customJson)}else{throw new Error("Undefined or unknown annotation data.")}})))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,suppliedId:n,data:e})));const qt=b.ifInvalidThrow(Wt);const Ut=b.defineMapper(b.read(b.mapRequiredProp("position",G),b.mapProp("icon",X),b.mapProp("primaryColor",X),b.mapProp("accentColor",X)),(([t,i,s,n])=>({type:"callout",position:t,icon:i,primaryColor:s,accentColor:n})));const _t=b.defineMapper(b.read(b.requiredProp("type"),b.mapRequiredProp("jsonData",(t=>JSON.parse(t)))),(([t,i])=>({type:"custom",jsonType:t,jsonData:i})));class Jt{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s;this.onStateChange=new C}async addAnnotationSet(t){await N((async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.CreateSceneViewAnnotationSetRequest;const o=new x.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.createSceneViewAnnotationSet(e,n,i)}));return this.fetch()}disconnect(){if(this.connection!=null){this.connection.dispose();this.connection=undefined}}connect(t=1e4){this.disconnect();const i=this.pollAnnotationState(t);this.connection={dispose:()=>i.abort()}}async fetch(t={}){const i=await this.fetchAnnotationSetsAsArray();const s=await this.fetchAnnotationsAsArray(i);const n=(await Promise.all(s)).reduce(((t,[i,s])=>({annotations:{...t.annotations,[i.id]:s}})),{annotations:{}});if(t.signal==null||!t.signal.aborted){this.updateState(n)}return n}async removeAnnotationSet(t){await N((async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.DeleteSceneViewAnnotationSetRequest;const o=new x.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.deleteSceneViewAnnotationSet(e,n,i)}));return this.fetch()}pollAnnotationState(t){const i=new AbortController;const s=async t=>{await this.fetch({signal:i.signal});if(!i.signal.aborted){await Kt(t);await s(t)}};I.abort(i.signal,s(t));return i}fetchAnnotationSets(){return W((t=>async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.ListSceneViewAnnotationSetsRequest;if(t!=null){const i=new O.Pager;i.setCursor(t);i.setLimit(100);e.setPage(i)}this.client.listSceneViewAnnotationSets(e,n,i)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}async fetchAnnotationSetsAsArray(){return(await I.asArray(this.fetchAnnotationSets())).flatMap((t=>t.getSceneAnnotationSetsList())).map((t=>Ft(t)))}fetchAnnotations(t){return W((i=>async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.ListSceneAnnotationsRequest;const a=Ct(t);o.setSceneAnnotationSetId(a);if(i!=null){const t=new O.Pager;t.setCursor(i);t.setLimit(100);o.setPage(t)}this.client.listSceneAnnotations(o,e,s)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}fetchAnnotationsAsArray(t){const i=t.map((async t=>{const i=(await I.asArray(this.fetchAnnotations(t.id))).flatMap((t=>t.getSceneAnnotationsList())).map((t=>qt(t)));return[t,i]}));return Promise.all(i)}updateState(t){this.state=t;this.onStateChange.emit(t)}}const Zt=b.defineMapper(b.read(b.mapRequiredProp("color",Q),b.getProp("thickness")),(([t,i])=>({color:t,thickness:i})));const Xt=b.defineMapper(b.read(b.mapRequiredProp("color",Q)),(([t])=>({color:t})));const Gt=b.defineMapper(b.read(b.pickFirst(b.mapProp("arrow",b.ifDefined((t=>({...t,type:"arrow-end"})))),b.mapProp("circle",b.ifDefined((t=>({...t,type:"circle-end"})))),b.mapProp("dash",b.ifDefined((t=>({...t,type:"dash-end"})))))),(([t])=>t!==null&&t!==void 0?t:undefined));const Qt=b.defineMapper(b.read(b.mapRequiredProp("startPosition",Y),b.mapRequiredProp("endPosition",Y),b.mapProp("strokeStyle",b.ifDefined(Zt)),b.mapProp("fillStyle",b.ifDefined(Xt)),b.mapProp("startShape",b.ifDefined(Gt)),b.mapProp("endShape",b.ifDefined(Gt))),(([t,i,s,n,e,o])=>({type:"line-2d",startPosition:t,endPosition:i,strokeStyle:s,fillStyle:n,startShape:e!==null&&e!==void 0?e:undefined,endShape:o!==null&&o!==void 0?o:undefined})));const Yt=b.defineMapper(b.read(b.mapRequiredProp("topLeft",Y),b.mapRequiredProp("bottomRight",Y),b.mapProp("strokeStyle",b.ifDefined(Zt)),b.mapProp("fillStyle",b.ifDefined(Xt))),(([t,i,s,n])=>({type:"oval-2d",topLeftPosition:t,bottomRightPosition:i,strokeStyle:s,fillStyle:n})));const ti=b.defineMapper(b.read(b.mapRequiredProp("positionsList",b.mapArray(Y)),b.mapProp("strokeStyle",b.ifDefined(Zt)),b.mapProp("fillStyle",b.ifDefined(Xt))),(([t,i,s])=>({type:"freeform-2d",positions:t,strokeStyle:i,fillStyle:s})));const ii=b.defineMapper(b.read(b.mapRequiredProp("primaryColor",Q),b.mapRequiredProp("accentColor",Q),b.mapRequiredProp("position",G),b.mapProp("sceneItemId",b.ifDefined(J))),(([t,i,s,n])=>({type:"pin-2d",primaryColor:t,accentColor:i,position:s,sceneItemId:n!==null&&n!==void 0?n:undefined})));const si=b.defineMapper(b.read(b.mapRequiredProp("primaryColor",Q),b.mapRequiredProp("accentColor",Q),b.mapRequiredProp("anchorPosition",G),b.mapRequiredProp("textPosition",Y),b.getProp("text"),b.mapProp("sceneItemId",b.ifDefined(J))),(([t,i,s,n,e,o])=>({type:"callout",primaryColor:t,accentColor:i,anchorPosition:s,textPosition:n,text:e,sceneItemId:o!==null&&o!==void 0?o:undefined})));const ni=b.defineMapper(b.read(b.pickFirst(b.mapProp("line2d",b.ifDefined(Qt)),b.mapProp("oval",b.ifDefined(Yt)),b.mapProp("freeform",b.ifDefined(ti)),b.mapProp("pin",b.ifDefined(ii)),b.mapProp("callout",b.ifDefined(si)))),(([t])=>t!==null&&t!==void 0?t:undefined));const ei=b.defineMapper(b.read(b.mapRequiredProp("itemsList",b.mapArray(ni))),(([t])=>({items:t.filter((t=>t!=null))})));const oi=b.defineMapper(b.read(b.mapRequiredProp("canvas",b.mapRequiredProp("document",b.mapRequiredProp("v1",ei)))),(([t])=>t));const ai=b.ifInvalidThrow(oi);class ri{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s}async getCanvas({canvasId:t,sceneViewStateId:i}){if(t!=null&&i!=null){throw new Error("Invalid request. Only one lookup ID between `canvasId` and `sceneViewStateId` can be provided.")}const s=await N((async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.GetCanvasRequest;if(t!=null){const i=Ct(t);o.setCanvasId(i)}else if(i!=null){const t=Ct(i);o.setSceneViewStateId(t)}this.client.getCanvas(o,e,s)}));return ai(s.toObject())}}class hi{constructor(t,i,s){this.stream=t;this.configProvider=i;this.imageScaleProvider=s}predicate(t){return t.altKey&&!t.shiftKey}async fn(t){var i;const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:o.scale(t.position,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1)},true);if(((i=n.hitItems)===null||i===void 0?void 0:i.hits)!=null&&n.hitItems.hits.length>0){await this.stream.flyTo({itemId:n.hitItems.hits[0].itemId,animation:{duration:p(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit results found for fly to part [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}}class ci{constructor(t,i,s,n,e,o,a,r,h,c,l){this.stream=t;this.cursors=i;this.getConfig=s;this.getScene=n;this.getFrame=e;this.getViewport=o;this.tapEmitter=a;this.doubleTapEmitter=r;this.longPressEmitter=h;this.interactionStartedEmitter=c;this.interactionFinishedEmitter=l;this.tap=this.tap.bind(this);this.doubleTap=this.doubleTap.bind(this);this.longPress=this.longPress.bind(this);this.emitTapEvent=this.emitTapEvent.bind(this)}addCursor(t,i){return this.cursors.add(t,i)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async getEntityTypeAtPoint(t){var i;const s=this.getViewport();const n=await((i=this.getFrame())===null||i===void 0?void 0:i.featureMap());if(n!=null){const i=s.transformPointToFrame(t,n);return n.getEntityType(i)}else{return Rt.NO_GEOMETRY}}getRayFromPoint(t){const i=this.getViewport();const s=this.getFrame();if(s!=null){return i.transformPointToRay(t,s.image,s.scene.camera)}else throw new Error("Cannot get camera. Frame is undefined.")}async tap(t,i={},s=0){this.emitTapEvent(this.tapEmitter.emit,t,i,s)}async doubleTap(t,i={},s=0){this.emitTapEvent(this.doubleTapEmitter.emit,t,i,s)}async longPress(t,i={},s=0){this.emitTapEvent(this.longPressEmitter.emit,t,i,s)}async beginInteraction(t={}){if(!this.isInteracting()){this.activeRenderOptions=t;this.interactionStartedEmitter.emit();this.sceneLoadingPromise=this.getScene();this.currentCamera=(await this.sceneLoadingPromise).camera();this.sceneLoadingPromise=undefined;await this.stream.beginInteraction()}}async transformCamera(t,i){var s,n;if(i===void 0){i=(s=this.activeRenderOptions)!==null&&s!==void 0?s:{}}if(this.isInteracting()){const s=await this.getScene();const e=this.getViewport();const o=this.getFrame();const a=await(o===null||o===void 0?void 0:o.depthBuffer());this.currentCamera=this.currentCamera!=null&&e!=null&&o!=null?t({camera:this.currentCamera,viewport:e,scale:s.scale(),boundingBox:s.boundingBox(),frame:o,depthBuffer:a}):undefined;await((n=this.currentCamera)===null||n===void 0?void 0:n.render(i))}}async twistCamera(...t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(a.subtract(i.lookAt,i.position));if(t.length===1&&typeof t[0]==="number"){const s=r.toRadians(-t[0]);return i.rotateAroundAxis(s,n)}else if(t.length===1){const n=o.create(s.width/2,s.height/2);const e=r.toDegrees(r.fromPoints(n,t[0]));const h=this.lastAngle!=null?e-this.lastAngle:0;this.lastAngle=e;const c=a.normalize(a.subtract(i.lookAt,i.position));const l=r.toRadians(-h);return i.rotateAroundAxis(l,c)}return i}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,depthBuffer:e})=>{if(this.panData==null){const o=i.toFrameCamera();const a=o.direction;const r=n.transformPointToRay(t,s.image,o);const l=h.fromNormalAndCoplanarPoint(a,i.lookAt);const d=c.intersectPlane(r,l);if(d==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}const u=e!=null?this.getWorldPoint(t,e,d):d;const f=h.fromNormalAndCoplanarPoint(a,u);this.panData={hitPt:u,hitPlane:f,startingCamera:o}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const h=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(h,o);if(l!=null){const t=a.subtract(e,l);return i.update(r).moveBy(t)}}return i}))}async viewAll(){await(await this.getScene()).camera().viewAll().render({})}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(i.up);const e=a.normalize(a.subtract(i.lookAt,i.position));const o=a.cross(n,e);const r=a.cross(e,o);const h=a.normalize({x:t.x*o.x+t.y*r.x,y:t.x*o.y+t.y*r.y,z:t.x*o.z+t.y*r.z});const c=a.cross(h,e);const l=9.5*t.x/s.width;const d=9.5*t.y/s.height;const u=Math.abs(l)+Math.abs(d);return i.rotateAroundAxis(u,c)}))}async rotateCameraAtPoint(t,i){return this.transformCamera((({camera:s,viewport:n,depthBuffer:e})=>{if(this.worldRotationPoint==null){this.worldRotationPoint=e!=null?this.getWorldPoint(i,e,s.lookAt):s.lookAt}const o=a.normalize(s.up);const r=a.normalize(a.subtract(s.lookAt,s.position));const h=a.cross(o,r);const c=a.cross(r,h);const l=a.normalize({x:t.x*h.x+t.y*c.x,y:t.x*h.y+t.y*c.y,z:t.x*h.z+t.y*c.z});const d=a.cross(l,r);const u=9.5*t.x/n.width;const f=9.5*t.y/n.height;const p=Math.abs(u)+Math.abs(f);const m=s.rotateAroundAxisAtPoint(p,this.worldRotationPoint,d);return m.update({lookAt:a.add(a.scale(Math.abs(s.signedDistanceToBoundingBoxCenter())/a.magnitude(m.viewVector),m.viewVector),m.position)})}))}async zoomCamera(t){return this.transformCamera((({camera:i,viewport:s,frame:n,boundingBox:e})=>{if(s!=null&&n!=null){const o=i===null||i===void 0?void 0:i.toFrameCamera().isPerspective();if(o){const n=i.viewVector;const e=a.magnitude(n);const o=3*e*(t/s.height);const r=a.normalize(n);const h=a.scale(o,r);const c=a.add(i.position,h);const l=i.update({position:c});return l}else{const o=i;const r=i.toFrameCamera();const d=r.direction;const u=s.transformPointToRay(s.center,n.image,r);const f=4*(t/s.height);const p=a.magnitude(l.diagonal(e))*1e-5;const m=Math.max(p,o.fovHeight*(1-f));const w=h.fromNormalAndCoplanarPoint(d,r.lookAt);const v=c.intersectPlane(u,w);if(v!=null){const t=h.projectPoint(w,o.lookAt);const s=(o.fovHeight-m)/o.fovHeight;const n=a.scale(s,a.subtract(v,t));const e=a.add(o.lookAt,n);const r=i.update({lookAt:e,rotationPoint:e,fovHeight:m});return r}}}return i}))}async pivotCamera(t,i){return this.transformCamera((({camera:s})=>{const{position:n,up:e,lookAt:o}=s;const h=a.normalize(e);const c=a.normalize(s.viewVector);const l=a.cross(h,c);const d=a.cross(c,l);const u=a.rotateAboutAxis(r.toRadians(t),o,l,n);const f=a.rotateAboutAxis(r.toRadians(i),u,d,n);return s.update({...s,lookAt:f})}))}async endInteraction(){await this.sceneLoadingPromise;if(this.isInteracting()){this.currentCamera=undefined;this.worldRotationPoint=undefined;this.panData=undefined;this.zoomData=undefined;this.resetLastAngle();this.interactionFinishedEmitter.emit();await this.stream.endInteraction()}this.activeRenderOptions=undefined}resetLastAngle(){this.lastAngle=undefined}isInteracting(){return this.currentCamera!=null}pixelThreshold(t){const i=this.isCoarseInputDevice(t)?this.getConfig().coarsePointerThreshold:this.getConfig().finePointerThreshold;return i*window.devicePixelRatio}async hitItems(t){var i;const s=await(await this.getScene()).raycaster().hitItems(t);return(i=s===null||s===void 0?void 0:s.hits)!==null&&i!==void 0?i:[]}emitTapEvent(t,i,s={},n=0){const{altKey:e=false,ctrlKey:o=false,metaKey:a=false,shiftKey:r=false}=s;t({position:i,altKey:e,ctrlKey:o,metaKey:a,shiftKey:r,buttons:n})}isCoarseInputDevice(t){return t||window.matchMedia("(pointer: coarse)").matches}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}class li extends ci{constructor(t,i,s,n,e,o,a,r,h,c,l){super(t,i,s,n,e,o,a,r,h,c,l)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=a.normalize(i.up);const r=a.normalize(n);const h=o.scale(t,.5,.5);const c=a.magnitude(n);const l=h.x*c/s.width;const d=h.y*c/s.height;const u=a.cross(e,r);const f=a.cross(r,u);const p=a.add(a.scale(l,u),a.scale(d,f));return i.moveBy(p)}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,boundingBox:e})=>{if(this.panData==null){const e=i.toFrameCamera();const o=e.direction;const a=n.transformPointToRay(t,s.image,e);const r=h.fromNormalAndCoplanarPoint(o,i.lookAt);const l=c.intersectPlane(a,r);if(l==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}this.panData={hitPt:l,hitPlane:r,startingCamera:e}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const h=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(h,o);if(l!=null){const t=a.subtract(e,l);const s=a.add(r.lookAt,t);return i.update({lookAt:s,rotationPoint:s})}}return i}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:r,boundingBox:d})=>{if(this.orthographicZoomData==null||o.distance(t,this.orthographicZoomData.startingScreenPt)>2){const i=s.toFrameCamera();const o=i.direction;const a=n.transformPointToRay(t,e.image,i);const l=h.fromNormalAndCoplanarPoint(o,i.lookAt);const d=c.intersectPlane(a,l);if(d==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const u=r!=null?this.getWorldPoint(t,r,d):d;const f=h.fromNormalAndCoplanarPoint(o,u);this.orthographicZoomData={hitPt:u,hitPlane:f,startingScreenPt:t}}if(this.orthographicZoomData!=null){const{hitPt:t,hitPlane:e}=this.orthographicZoomData;const o=4*(i/n.height);const r=a.magnitude(l.diagonal(d))*1e-5;const c=Math.max(r,s.fovHeight*(1-o));const u=h.projectPoint(e,s.lookAt);const f=(s.fovHeight-c)/s.fovHeight;const p=a.scale(f,a.subtract(t,u));const m=a.add(s.lookAt,p);return s.update({lookAt:m,rotationPoint:m,fovHeight:c})}return s}))}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s,boundingBox:n})=>{var e;const o=a.normalize(i.up);const r=a.normalize(a.subtract(i.lookAt,i.position));const h=a.cross(o,r);const c=a.cross(r,h);const d=a.normalize({x:t.x*h.x+t.y*c.x,y:t.x*h.y+t.y*c.y,z:t.x*h.z+t.y*c.z});const u=a.cross(d,r);const f=9.5*t.x/s.width;const p=9.5*t.y/s.height;const m=Math.abs(f)+Math.abs(p);const w=i.rotationPoint!=null&&((e=i.rotationPoint)===null||e===void 0?void 0:e.x)!=null?i.rotationPoint:i.lookAt;const v=i.rotateAroundAxisAtPoint(m,w,u);const g=tt(v.lookAt,v.viewVector,l.center(n));return v.update({lookAt:g})}))}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}const di=.2;class ui extends ci{constructor(t,i,s,n,e,o,a,r,h,c,l){super(t,i,s,n,e,o,a,r,h,c,l)}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{var n;const e=i.viewVector;const r=a.normalize(i.up);const h=a.normalize(e);const c=o.scale(t,.25,.25);const l=a.magnitude(e)*Math.tan((n=i.fovY)!==null&&n!==void 0?n:45);const d=c.x*l/s.width;const u=c.y/s.width*l;const f=a.cross(r,h);const p=a.cross(h,f);const m=a.add(a.scale(d,f),a.scale(u,p));return i.moveBy(m)}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:o,boundingBox:r})=>{const l=e.scene.camera;const d=l.direction;const u=s.toFrameCamera();const f=n.transformPointToRay(t,e.image,u);if(this.zoomData==null){const i=h.fromNormalAndCoplanarPoint(d,l.lookAt);const n=c.intersectPlane(f,i);if(n==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const e=o!=null?this.getWorldPoint(t,o,n):n;const a=h.fromNormalAndCoplanarPoint(d,e);this.zoomData={hitPt:e,hitPlane:a}}if(this.zoomData!=null){const{hitPlane:t}=this.zoomData;const{position:e,distance:o,isPastHitPlane:l,keepCurrent:d}=this.computeZoomDistances(i,s,n,r,f,this.zoomData);if(l&&!d){const t=c.create({origin:e,direction:a.normalize(s.viewVector)});return s.update({position:e,lookAt:c.at(t,o)})}else if(!d){return s.update({position:e,lookAt:h.projectPoint(t,e)})}}return s}))}walk(t){this.transformCamera((({camera:i,boundingBox:s})=>{const{position:n,up:e,lookAt:o}=i;const r=a.normalize(e);const h=a.normalize(i.viewVector);const c=Math.min(...a.toArray(l.lengths(s)));const d=a.scale(c,t);const u=a.cross(r,h);const f=a.cross(u,r);const p=a.scale(d.x,a.normalize(u));const m=a.scale(d.y,a.normalize(r));const w=a.scale(d.z,a.normalize(f));const v=a.negate(a.add(p,m,w));return i.update({...i,position:a.add(n,v),lookAt:a.add(o,v)})}))}computeZoomDistances(t,i,s,n,e,o){const r=this.getConfig();const{hitPt:h,hitPlane:l}=o;const d=r.useMinimumPerspectiveZoomDistance?this.computeZoomMinimumDistance(i,n):-1;const u=a.distance(i.position,h);const f=Math.max(d,u);const p=6*f*t/s.height;const m=c.at(e,p);const w=c.create({origin:m,direction:a.normalize(i.viewVector)});const v=c.intersectPlane(w,l);if(v==null&&r.useMinimumPerspectiveZoomDistance){const i=6*d*t/s.height;const n=c.at(e,i);return{position:n,distance:d,isPastHitPlane:true,keepCurrent:false}}else if(v==null){return{position:i.position,distance:f,isPastHitPlane:true,keepCurrent:true}}return{position:m,distance:f,isPastHitPlane:false,keepCurrent:false}}computeZoomMinimumDistance(t,i){const s=Math.abs(i.min.x)+Math.abs(i.max.x);const n=Math.abs(i.min.y)+Math.abs(i.max.y);const e=Math.abs(i.min.z)+Math.abs(i.max.z);const o=Math.max(s,n,e);const r=Math.abs(a.dot(a.normalize(t.viewVector),a.right()));const h=Math.abs(a.dot(a.normalize(t.viewVector),a.up()));const c=Math.abs(a.dot(a.normalize(t.viewVector),a.back()));const l=s*r;const d=n*h;const u=e*c;const f=o/s;const p=o/n;const m=o/e;return(l+d+u)/(f+p+m)*di}}class fi{constructor(t,i,s,n){this.stream=t;this.configProvider=i;this.imageScaleProvider=s;this.sceneProvider=n}predicate(t){return t.altKey&&t.shiftKey}async fn(t){var i,s;const n=this.imageScaleProvider();const e=await this.stream.hitItems({point:o.scale(t.position,(n===null||n===void 0?void 0:n.x)||1,(n===null||n===void 0?void 0:n.y)||1)},true);if(((i=e.hitItems)===null||i===void 0?void 0:i.hits)!=null&&e.hitItems.hits.length>0&&e.hitItems.hits[0].hitPoint!=null){const i=await this.sceneProvider();const n=(await this.sceneProvider()).camera();const o=e.hitItems.hits[0];if(o.hitPoint!=null&&o.hitPoint.x!=null&&o.hitPoint.y!=null&&o.hitPoint.z!=null){const t=a.create(o.hitPoint.x,o.hitPoint.y,o.hitPoint.z);const s=await this.getLookAtPoint(i,t,n.viewVector);await this.stream.flyTo({camera:it(n.update({lookAt:s,rotationPoint:s}).toFrameCamera()),animation:{duration:p(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit position found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}, hit-id={${(s=o.itemId)===null||s===void 0?void 0:s.hex}}]`)}}else{console.debug(`No hit results found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}getLookAtPoint(t,i,s){if(t.isOrthographic()){return tt(i,s,l.center(t.boundingBox()))}else{return i}}}class pi{setPosition(t){this.currentPosition=t}getPosition(){return this.currentPosition}getType(){return this.type}beginDrag(t,i,s,n){}drag(t,i){}endDrag(t,i){if(this.currentPosition!=null){i.endInteraction();this.currentPosition=undefined}}async zoom(t,i){}}class mi extends pi{constructor(){super(...arguments);this.type="rotate"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCamera(n);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class wi extends pi{constructor(){super(...arguments);this.type="rotate-point"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.startingPosition=i;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.startingPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCameraAtPoint(n,this.startingPosition);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class vi extends pi{constructor(t){super();this.interactionConfigProvider=t;this.type="zoom";this.isTransforming=false}async beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.clientX,t.clientY);const i=n.getBoundingClientRect();const e=Mt(t,i);this.startPt=e;await s.beginInteraction()}}async drag(t,i){if(this.currentPosition!=null){const s=o.create(t.clientX,t.clientY);const n=o.subtract(s,this.currentPosition);if(this.startPt!=null){await i.zoomCameraToPoint(this.startPt,n.y);this.currentPosition=s}}}endDrag(t,i){super.endDrag(t,i);this.stopInteractionTimer();this.isTransforming=false;this.startPt=undefined}async zoom(t,i,s){await this.runWheelZoomInteraction(i,(()=>i.zoomCamera(this.getDirectionalDelta(t))),s)}async zoomToPoint(t,i,s,n){await this.runWheelZoomInteraction(s,(()=>s.zoomCameraToPoint(t,this.getDirectionalDelta(i))),n)}async beginInteraction(t){this.isTransforming=true;await t.beginInteraction()}async endInteraction(t){this.isTransforming=false;await t.endInteraction()}resetInteractionTimer(t,i){this.stopInteractionTimer();this.startInteractionTimer(t,i)}getDirectionalDelta(t){return this.interactionConfigProvider().reverseMouseWheelDirection?-t:t}getInteractionDelay(){return this.interactionConfigProvider().mouseWheelInteractionEndDebounce}startInteractionTimer(t,i=0){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.endInteraction(t)}),i+this.getInteractionDelay())}stopInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}async runWheelZoomInteraction(t,i,s){if(!this.isTransforming){await this.beginInteraction(t)}this.resetInteractionTimer(t,s);i()}}class gi extends pi{constructor(){super(...arguments);this.type="pan"}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.canvasRect!=null){const s=Mt(t,this.canvasRect);i.panCameraToScreenPoint(s);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class yi extends pi{constructor(){super(...arguments);this.type="twist"}beginDrag(t,i,s,n){this.currentPosition=o.create(t.offsetX,t.offsetY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}drag(t,i){const s=Mt(t,this.canvasRect);this.currentPosition=s;i.twistCamera(s)}endDrag(t,i){super.endDrag(t,i)}}class bi extends pi{constructor(){super(...arguments);this.type="pivot"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.pivotCamera(-.25*n.y,.25*n.x);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Ci extends jt{constructor(t,i=new mi,s=new wi,n=new vi((()=>t().interactions)),e=new gi,o=new yi,a=new bi){super("mousedown","mouseup","mousemove",i,s,n,e,o,a,t)}}function Ii(t){window.requestAnimationFrame(t)}class Pi{constructor(){this.previousFirstPoints=[];this.previousSecondPoints=[]}initialize(t,i){this.element=t;this.interactionApi=i}dispose(){this.element=undefined}beginTwoPointTouch(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i]}handleTwoPointTouchMove(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i];Ii((()=>{var t,i,s,n;if(this.previousFirstPoints.length>1&&this.previousSecondPoints.length>1&&this.previousFirstPoints.length===this.previousSecondPoints.length){const e=this.previousFirstPoints;const a=this.previousSecondPoints;this.previousFirstPoints=this.previousFirstPoints.slice(-1);this.previousSecondPoints=this.previousSecondPoints.slice(-1);const r=e.reduce(((t,i,s)=>{if(s<e.length-1){const n=e[s+1];const o=a[s];const r=a[s+1];return{deltas:[...t.deltas,this.computeDelta(i,o,n,r)],zooms:[...t.zooms,this.computeZoom(i,o,n,r)],angles:[...t.angles,this.computeAngle(i,o,n,r)]}}return t}),{deltas:[],zooms:[],angles:[]});const h=r.deltas.reduce(((t,i)=>o.add(t,i)),o.create());const c=r.zooms.reduce(((t,i)=>t+i),0);const l=r.angles.reduce(((t,i)=>t+i),0);const d=o.create((e[e.length-1].x+a[a.length-1].x)/2,(e[e.length-1].y+a[a.length-1].y)/2);(t=this.interactionApi)===null||t===void 0?void 0:t.beginInteraction();(i=this.interactionApi)===null||i===void 0?void 0:i.zoomCameraToPoint(d,c);(s=this.interactionApi)===null||s===void 0?void 0:s.panCameraByDelta(h);(n=this.interactionApi)===null||n===void 0?void 0:n.twistCamera(l)}}))}endTwoPointTouch(){this.previousFirstPoints=[];this.previousSecondPoints=[]}computeDelta(t,i,s,n){return o.add(o.subtract(s,t),o.subtract(n,i))}computeZoom(t,i,s,n){const e=o.distance(s,n)-o.distance(t,i);return e*.5}computeAngle(t,i,s,n){const e=d.create(o.subtract(t,i),o.subtract(s,n));return r.toDegrees(Math.atan2(d.determinant(e),d.dot(e)))}}class Si extends Pi{constructor(){super();this.touchPoints={};this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){const i=o.create(t.screenX,t.screenY);this.touchPoints={...this.touchPoints,[t.pointerId]:i};const s=Object.keys(this.touchPoints);if(s.length===1){window.addEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointerup",this.handlePointerUp)}else if(s.length===2){this.beginTwoPointTouch(this.touchPoints[0],this.touchPoints[1])}}handlePointerMove(t){if(this.touchPoints[t.pointerId]!=null){this.touchPoints[t.pointerId]=o.create(t.screenX,t.screenY)}const i=Object.keys(this.touchPoints);if(i.length===2){const t=this.touchPoints[i[0]];const s=this.touchPoints[i[1]];this.handleTwoPointTouchMove(t,s)}}handlePointerUp(t){var i;delete this.touchPoints[t.pointerId];const s=Object.keys(this.touchPoints);if(s.length===1){(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction()}if(s.length===0){window.removeEventListener("pointermove",this.handlePointerMove);window.removeEventListener("pointerup",this.handlePointerUp)}this.endTwoPointTouch()}}class ki extends zt{constructor(t,i=new mi,s=new wi,n=new vi((()=>t().interactions)),e=new gi,o=new yi,a=new bi){super("pointerdown","pointerup","pointermove",i,s,n,e,o,a,t);this.touchPoints=new Set;this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}addEventListenersToElement(t){t.addEventListener(this.downEvent,this.handleDownEvent);t.addEventListener("wheel",this.handleMouseWheel,{passive:false});return{dispose:()=>{t.removeEventListener(this.downEvent,this.handleDownEvent);t.removeEventListener("wheel",this.handleMouseWheel)}}}handlePointerDown(t){this.downPosition=o.create(t.screenX,t.screenY);this.touchPoints.add(t.pointerId);if(this.touchPoints.size===1){window.addEventListener("pointerup",this.handlePointerUp)}if(this.touchPoints.size===2){this.disableIndividualInteractions=true}}handlePointerUp(t){this.touchPoints.delete(t.pointerId);if(this.touchPoints.size<2){this.disableIndividualInteractions=false}if(this.touchPoints.size===0){window.removeEventListener("pointerup",this.handlePointerUp)}}}class Ti{constructor(t,i,s,n){this.downEvent=t;this.upEvent=i;this.moveEvent=s;this.getConfig=n;this.handleDown=this.handleDown.bind(this);this.handleUp=this.handleUp.bind(this);this.handleMove=this.handleMove.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerEnd=this.handlePointerEnd.bind(this);this.clearPositions=this.clearPositions.bind(this);this.restartDoubleTapTimer=this.restartDoubleTapTimer.bind(this);this.clearDoubleTapTimer=this.clearDoubleTapTimer.bind(this);this.restartLongPressTimer=this.restartLongPressTimer.bind(this);this.clearLongPressTimer=this.clearLongPressTimer.bind(this);this.setPointerPositions=this.setPointerPositions.bind(this);this.emit=this.emit.bind(this)}dispose(){var t,i;(t=this.element)===null||t===void 0?void 0:t.removeEventListener(this.downEvent,this.handleDown);(i=this.element)===null||i===void 0?void 0:i.removeEventListener("touchstart",this.handleTouchStart);this.element=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer()}initialize(t,i){this.element=t;this.interactionApi=i;t.addEventListener(this.downEvent,this.handleDown);t.addEventListener("touchstart",this.handleTouchStart,{passive:true})}handleTouchStart(t){if(t.touches.length===1){this.setPointerPositions(o.create(t.touches[0].clientX,t.touches[0].clientY));this.restartLongPressTimer();window.addEventListener("touchend",this.handleTouchEnd);window.addEventListener("touchmove",this.handleTouchMove)}}handleTouchMove(t){if(t.touches.length>0){this.handlePointerMove(o.create(t.touches[0].clientX,t.touches[0].clientY),true)}}handleTouchEnd(t){if(this.pointerDownPosition!=null){window.removeEventListener("touchend",this.handleTouchEnd);window.removeEventListener("touchmove",this.handleTouchMove)}this.handlePointerEnd(this.pointerDownPosition)}handleDown(t){this.setPointerPositions(o.create(t.clientX,t.clientY));this.buttons=t.buttons;const i={altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey};this.restartLongPressTimer(i);window.addEventListener(this.upEvent,this.handleUp);window.addEventListener(this.moveEvent,this.handleMove)}handleMove(t){this.handlePointerMove(o.create(t.clientX,t.clientY),this.isTouch(t))}handleUp(t){if(this.pointerDownPosition!=null){window.removeEventListener(this.upEvent,this.handleUp);window.removeEventListener(this.moveEvent,this.handleMove)}this.handlePointerEnd(o.create(t.clientX,t.clientY),{altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey},this.buttons,this.isTouch(t));this.buttons=undefined}handlePointerMove(t,i){var s;const n=((s=this.interactionApi)===null||s===void 0?void 0:s.pixelThreshold(i))||2;if(this.pointerDownPosition!=null&&o.distance(t,this.pointerDownPosition)>=n&&this.interactionTimer==null){this.clearPositions()}}handlePointerEnd(t,i={},s=0,n=false){var e,o;if(t!=null){if(this.longPressTimer!=null){this.emit((e=this.interactionApi)===null||e===void 0?void 0:e.tap)(t,i,s)}if(this.doubleTapTimer!=null&&this.secondPointerDownPosition!=null){this.emit((o=this.interactionApi)===null||o===void 0?void 0:o.doubleTap)(t,i,s,this.secondPointerDownPosition);this.clearDoubleTapTimer()}}this.pointerDownPosition=undefined;this.clearLongPressTimer()}emit(t){return(i,s={},n=0,e,a=false)=>{var r;const h=e||this.pointerDownPosition;const c=((r=this.interactionApi)===null||r===void 0?void 0:r.pixelThreshold(a))||1;let l;if(this.interactionTimer!=null){l=this.getCanvasPosition(h||i)}else if(h!=null&&o.distance(h,i)<=c){l=this.getCanvasPosition(i)}if(l!=null&&t!=null){t(l,s,n)}}}getCanvasPosition(t){var i;const s=(i=this.element)===null||i===void 0?void 0:i.getBoundingClientRect();const n=s!=null?o.create(s.left,s.top):undefined;return n!=null?o.subtract(o.create(t.x,t.y),n):undefined}clearPositions(){this.pointerDownPosition=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer();this.clearInteractionTimer()}clearDoubleTapTimer(){if(this.doubleTapTimer!=null){window.clearTimeout(this.doubleTapTimer)}this.doubleTapTimer=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined}restartDoubleTapTimer(){this.clearDoubleTapTimer();this.doubleTapTimer=window.setTimeout((()=>this.clearDoubleTapTimer()),this.getConfig().events.doubleTapThreshold)}clearLongPressTimer(){if(this.longPressTimer!=null){window.clearTimeout(this.longPressTimer)}this.longPressTimer=undefined}restartLongPressTimer(t={}){this.clearLongPressTimer();this.longPressTimer=window.setTimeout((()=>{var i;if(this.pointerDownPosition){this.emit((i=this.interactionApi)===null||i===void 0?void 0:i.longPress)(this.pointerDownPosition,t,this.buttons)}this.clearLongPressTimer()}),this.getConfig().events.longPressThreshold)}restartInteractionTimer(){this.clearInteractionTimer();this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined}),this.getConfig().interactions.interactionDelay)}clearInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}setPointerPositions(t){this.pointerDownPosition=t;this.restartInteractionTimer();if(this.firstPointerDownPosition==null){this.restartDoubleTapTimer();this.firstPointerDownPosition=t}else{this.secondPointerDownPosition=t}}isTouch(t){return window.PointerEvent!=null&&t instanceof PointerEvent?t.pointerType==="touch":false}}class Ai extends Pi{constructor(){super();this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("touchstart",this.handleTouchStart);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("touchstart",this.handleTouchStart)}handleTouchStart(t){if(t.touches.length>=1){t.preventDefault();const i=t.touches[0];this.currentPosition1=o.create(i.screenX,i.screenY);if(t.touches[1]!=null){this.beginTwoPointTouch(this.currentPosition1,o.create(t.touches[1].screenX,t.touches[1].screenY))}window.addEventListener("touchmove",this.handleTouchMove,{passive:false});window.addEventListener("touchend",this.handleTouchEnd)}}handleTouchMove(t){t.preventDefault();if(t.touches.length===1){this.handleOnePointTouchMove(t.touches[0])}else if(t.touches.length===2){const i=o.create(t.touches[0].clientX,t.touches[0].clientY);const s=o.create(t.touches[1].clientX,t.touches[1].clientY);this.handleTwoPointTouchMove(i,s)}}handleTouchEnd(t){var i;t.preventDefault();(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction();this.isInteracting=false;window.removeEventListener("touchmove",this.handleTouchMove);window.removeEventListener("touchend",this.handleTouchEnd);this.endTwoPointTouch()}handleOnePointTouchMove(t){var i,s,n;const e=o.create(t.screenX,t.screenY);if(this.currentPosition1!=null){const t=o.subtract(e,this.currentPosition1);const a=((i=this.interactionApi)===null||i===void 0?void 0:i.pixelThreshold(true))||2;if(o.distance(e,this.currentPosition1)>=a||this.isInteracting){(s=this.interactionApi)===null||s===void 0?void 0:s.beginInteraction();(n=this.interactionApi)===null||n===void 0?void 0:n.rotateCamera(t);this.isInteracting=true}}this.currentPosition1=e}}const Di={clearMarks:()=>undefined,clearMeasures:()=>undefined,getEntriesByName:()=>[],mark:()=>undefined,measure:()=>undefined};function xi(){var t;if(typeof window!=="undefined"){return window.performance}return(t=globalThis.performance)!==null&&t!==void 0?t:Di}class Mi{constructor(t,i=xi()){this.name=t;this.perf=i;this.measures=new Set;this.nextId=0}clearMeasurements(){this.perf.clearMeasures(this.name)}measure(t){if(t instanceof Promise){const i=this.begin();return t.finally((()=>this.end(i)))}else if(typeof t==="function"){const i=this.begin();const s=t();this.end(i);return s}else{throw new Error("Input must be a function or Promise")}}takeMeasurements(){const t=this.perf.getEntriesByName(this.name);this.clearMeasurements();return t}takeLastMeasurement(){const t=this.takeMeasurements();return t[t.length-1]}begin(){const t=`${this.name}-${this.nextId++}`;this.measures.add(t);this.perf.mark(t);return t}end(t){this.perf.measure(this.name,t);this.perf.clearMarks(t);this.measures.delete(t)}}const Ei=new Mi("paint_time");function Ri(t){const i=new Uint8Array(t.byteLength);i.set(t);return i.buffer}function Bi(t){return new Promise(((i,s)=>{const n=new Blob([Ri(t)]);const e=URL.createObjectURL(n);const o=new Image;o.addEventListener("load",(()=>{i({image:o,dispose:()=>undefined});URL.revokeObjectURL(e)}));o.addEventListener("error",(()=>{s(new M("Failed to load image data"));URL.revokeObjectURL(e)}));o.src=e}))}async function ji(t){const i=new Blob([Ri(t)]);const s=await window.createImageBitmap(i);return{image:s,dispose:()=>s.close()}}function zi(t){if(window.createImageBitmap!=null){return ji(t)}else{return Bi(t)}}const Li=1e3;function Vi(t,i){const s=i.viewport.calculateDrawRect(i.frame.image);i.canvas.clearRect(0,0,i.canvasDimensions.width,i.canvasDimensions.height);i.canvas.drawImage(t.image,s.x,s.y,s.width,s.height)}function $i(t,i){const s=t.takeMeasurements();if(s.length>0){i(s)}}function Oi(t,i,s,n,e=Li){let o;let a=0;let r;let h=[];function c(){a++;if(o==null){o=setInterval((()=>{$i(t,n);if(a===0){d()}}),e)}}function l(){a--}function d(){if(o!=null){clearInterval(o);o=undefined}}if(s){setInterval((()=>{if(r!=null){if(h.length===5){h=[...h.slice(1),r]}else{h.push(r)}const t=h.reduce(((t,i)=>t+i),0)/h.length;console.debug(`Paint rate: ${r}fps`);console.debug(`Paint rate (avg): ${t}`);r=undefined}}),1e3)}return s=>{c();return t.measure((async()=>{const t=await i(s);r=r==null?1:r+1;return t})).finally((()=>l()))}}function Hi(){let t=[];function i(i){if(i!=null){const s=i.copy({correlationIds:[...i.correlationIds,...t.filter((t=>!i.correlationIds.includes(t)))]});t=[];return s}return i}function s(){let t=-1;return async i=>{if(i.frame.sequenceNumber>t){const s=await zi(i.frame.image.imageBytes);t=i.frame.sequenceNumber;return s}}}function n(){let t=-1;return async(i,s)=>{var n;if(s!=null&&i.frame.sequenceNumber>t){t=i.frame.sequenceNumber;(n=i.beforeDraw)===null||n===void 0?void 0:n.call(i);Vi(s,i);s.dispose();return i.frame}s===null||s===void 0?void 0:s.dispose()}}const e=s();const o=n();return async s=>{var n,a;const r=(a=(n=s.predicate)===null||n===void 0?void 0:n.call(s))!==null&&a!==void 0?a:true;t=[...t,...s.frame.correlationIds];if(r){return e(s).then((t=>o(s,t).then(i)))}}}function Ki(t){return i=>{var s;const n=(s=i.request.requestId)===null||s===void 0?void 0:s.value;if(n!=null){t(n)(i)}}}function Ni(t){return i=>{const{drawFrame:s}=i.request;if(s!=null){t(s)(i)}}}const Fi=1*60;function Wi(t){let i=false;return s=>{const n=t();if(n!=null){const t=n.remoteTime(new Date(Date.now()));const e=p(s,t);const o=m(e).getTime();if(o>=0){return e}else{if(!i){console.warn(`Possible erroneous send to receive timing. Muting for ${Fi}s. [sent-at=${s.toISOString()}, received-at=${t.toISOString()}, remote-time=${n.knownRemoteTime.toISOString()}]`);i=true;setTimeout((()=>i=false),Fi*1e3)}return undefined}}}}function qi(t,i){const s=Wi(i);return Ki((i=>Ni((n=>n=>{const e=m(n.sentAtTime);if(e!=null){t.replyResult(i,{drawFrame:{sendToReceiveDuration:s(e)}})}}))))}var Ui=K();const _i=b.defineMapper(b.read(b.requiredProp("d"),b.requiredProp("ns"),b.mapRequiredProp("ka",st),b.mapRequiredProp("kd",st),b.mapRequiredProp("ks",st),b.mapRequiredProp("ke",st)),(([t,i,s,n,e,o])=>({opacity:t,glossiness:i,ambient:s,diffuse:n,specular:e,emissive:o})));const Ji=b.defineMapper(b.read(b.mapRequiredProp("defaultMaterial",(()=>It)),b.mapRequiredProp("colorMaterial",_i)),(([t,i])=>({defaultMaterial:t,colorMaterial:i})));const Zi=b.defineMapper(b.read(b.requiredProp("name"),b.requiredProp("category")),(([t,i])=>({name:t,category:i})));const Xi=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"string",value:t})));const Gi=b.mapProp("string",b.ifDefined(Xi));const Qi=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"long",value:t})));const Yi=b.mapProp("pb_long",b.ifDefined(Qi));const ts=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"double",value:t})));const is=b.mapProp("pb_double",b.ifDefined(ts));const ss=b.defineMapper(b.read(b.requiredProp("value")),(([t])=>({type:"timestamp",value:t})));const ns=b.mapProp("date",b.ifDefined(ss));const es=b.compose(b.pickFirst(Gi,Yi,is,ns),b.required("value"));const os=b.defineMapper(b.read(b.requiredProp("id"),b.mapProp("key",b.ifDefined(Zi)),b.mapProp("value",b.ifDefined(es))),(([t,i,s])=>({id:t,key:i,value:s})));const as=b.defineMapper(b.read(b.mapProp("cursor",nt),b.mapRequiredProp("entriesList",b.mapArray(os))),(([t,i])=>({paging:{next:t},entries:i})));const rs=b.ifInvalidThrow(as);const hs=b.defineMapper(b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",et),b.mapProp("materialOverride",b.ifDefined(Ji)),b.mapProp("transform",b.ifDefined(ot)),b.mapProp("isVisible",b.ifDefined(at)),b.mapProp("isSelected",b.ifDefined(at)),b.mapProp("isPhantom",b.ifDefined(at)),b.mapProp("endItem",b.ifDefined(at))),(([t,i,s,n,e,o,a,r])=>({id:t,createdAt:i,materialOverride:s,transform:n,isVisible:e,isSelected:o,isPhantom:a,endItem:r})));const cs=b.defineMapper(b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",et),b.mapRequiredProp("name",X),b.mapProp("parentId",b.ifDefined(J)),b.mapProp("suppliedId",b.ifDefined(X)),b.mapProp("boundingBox",b.ifDefined(rt)),b.mapProp("worldTransform",b.ifDefined(ot)),b.mapProp("override",b.ifDefined(hs))),(([t,i,s,n,e,o,a,r])=>({id:t,createdAt:i,name:s,parentId:n!==null&&n!==void 0?n:undefined,suppliedId:e,boundingBox:o,worldTransform:a,override:r})));const ls=b.ifInvalidThrow(b.defineMapper(b.read(b.mapProp("item",b.ifDefined(cs))),(([t])=>t!==null&&t!==void 0?t:undefined)));class ds{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s}async getSceneViewItem(t,i,s){const n=await N((async n=>{const e=this.deviceIdProvider();const o=await F(this.jwtProvider,e);const a=new H.GetSceneViewItemRequest;a.setSceneItemId(Ct(t));a.setViewId(Ct(i));const r=new Ui.FieldMask;if(s.includeBoundingBox){r.addPaths("bounding_box")}if(s.includeWorldTransform){r.addPaths("world_transform")}if(s.includeOverride){r.addPaths("override")}a.setAdditionalFields(r);this.client.getSceneViewItem(a,o,n)}));return ls(n.toObject())}async listSceneItemMetadata(t,i){const s=await N((async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.ListSceneItemMetadataRequest;o.setItemId(Ct(t));const a=new E.Pager;if(i.size!=null){a.setLimit(i.size)}if(i.cursor!=null){a.setCursor(i.cursor)}o.setPager(a);this.client.listSceneItemMetadata(o,e,s)}));return rs(s.toObject())}}var us;(function(t){t["DEVICE_ID"]="vertexvis:device-id"})(us||(us={}));function fs(){if(typeof window==="undefined"){throw new Error("Local storage is not available.")}return window.localStorage}function ps(t,i,s=fs()){const n=s.getItem(t);if(n!=null){const e={...JSON.parse(n),...i};s.setItem(t,JSON.stringify(e))}else{s.setItem(t,JSON.stringify(i))}}function ms(t,i,s=fs()){const n=s.getItem(t);if(n!=null){return i(JSON.parse(n))}}function ws(t,i,s,n){return I.retry((()=>{if(!t.aborted){return i()}return Promise.resolve(s)}),n)}class vs extends w{constructor(t,i={}){var s,n,e,o,a;super(t,{loggingEnabled:i.loggingEnabled});this.state={type:"disconnected"};this.stateChanged=new C;this.dimensions=u.create(0,0);this.streamAttributes={};this.enableTemporalRefinement=(s=i.enableTemporalRefinement)!==null&&s!==void 0?s:true;this.frameBgColor=P.create(255,255,255);this.config=Dt("platprod");this.options={tokenRefreshOffsetInSeconds:(n=i.tokenRefreshOffsetInSeconds)!==null&&n!==void 0?n:30,offlineThresholdInSeconds:(e=i.offlineThresholdInSeconds)!==null&&e!==void 0?e:30,loadTimeoutInSeconds:(o=i.loadTimeoutInSeconds)!==null&&o!==void 0?o:15,enableTemporalRefinement:(a=i.enableTemporalRefinement)!==null&&a!==void 0?a:true}}isPaused(){return this.pausedState!=null}getState(){return this.state}disconnect(){if(this.state.type!=="disconnected"&&this.state.type!=="connection-failed"){console.debug("Disconnecting websocket");this.state.connection.dispose();this.updateState({type:"disconnected"})}}async load(t,i,s,n=Dt("platprod"),e){this.clientId=i;this.deviceId=s;this.config=n;if(this.state.type==="disconnected"){await this.loadIfDisconnected(t,e)}else if(this.state.type==="connection-failed"){await this.loadIfDisconnected(t,e)}else{await this.loadIfConnectingOrConnected(t,this.state,e)}return this.state}update(t){this.frameBgColor=t.frameBgColor?t.frameBgColor:this.frameBgColor;if(t.dimensions!=null&&!S(t.dimensions,this.dimensions)){this.dimensions=t.dimensions;this.ifState("connected",(()=>this.updateDimensions({dimensions:this.getDimensions(),resolution:Cs(this.getResolution())})))}const i=!S(this.streamAttributes,t.streamAttributes);if(t.streamAttributes!=null&&i){this.streamAttributes=t.streamAttributes;this.ifState("connected",(()=>this.updateStream({streamAttributes:gs(this.streamAttributes)})))}if(t.enableTemporalRefinement!=null&&t.enableTemporalRefinement!==this.enableTemporalRefinement){this.enableTemporalRefinement=t.enableTemporalRefinement;if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}}pause(){if(this.state.type==="connected"){this.pausedState=this.state;console.debug(`Stream paused [stream-id=${this.pausedState.streamId}, scene-id=${this.pausedState.sceneId}, scene-view-id=${this.pausedState.sceneViewId}]`);this.disconnect()}}async resume(){if(this.pausedState!=null){console.debug(`Stream resumed [stream-id=${this.pausedState.streamId}, scene-id=${this.pausedState.sceneId}, scene-view-id=${this.pausedState.sceneViewId}]`);await this.connectToExistingStream(this.pausedState);this.pausedState=undefined}}async loadIfConnectingOrConnected(t,i,s){var n;const{resource:e,subResource:o}=i.resource;const a=Pt(t);const r=!k.isEqual(e,a.resource);const h=!k.isEqual(o,a.subResource);const c=i.type==="connecting"||i.type==="reconnecting";const l=i.type==="connected";if(r||c&&h){this.disconnect();return this.loadIfDisconnected(t)}else if(l&&h&&((n=a.subResource)===null||n===void 0?void 0:n.type)==="scene-view-state"){const t=a.queries.find((t=>t.type==="supplied-id"));const n={...a.subResource.id!=null?{sceneViewStateId:{hex:a.subResource.id}}:{},...t!=null?{sceneViewStateSuppliedId:{value:t.id}}:{},...s!=null?{cameraType:bs(s)}:{}};await this.loadSceneViewState(n);this.updateState({...i,resource:a})}}async loadIfDisconnected(t,i){try{await this.connectWithNewStream(Pt(t),i)}catch(t){if(t instanceof R){this.updateState({type:"connection-failed",message:`Cannot load scene. ${t.message}`,error:t})}else if(t instanceof v){this.updateState({type:"connection-failed",message:`Cannot load scene. Stream request failed to start stream.`,error:t})}else{this.updateState({type:"connection-failed",message:`Cannot load scene for unknown reason. See console logs.`,error:t})}throw t}}connectWithNewStream(t,i){return this.openWebsocketStream(t,"connecting",(()=>this.requestNewStream(t,i)))}connectToExistingStream(t){return this.openWebsocketStream(t.resource,"reconnecting",(()=>this.requestReconnectStream(t)),{maxRetries:Number.POSITIVE_INFINITY})}async openWebsocketStream(t,i,s,{maxRetries:n=3}={}){var e;const o=Ps(Ss(this.config,t.resource,this.clientId,this.deviceId));console.debug(`Initiating WS connection [uri=${o.url}]`);(e=this.abortController)===null||e===void 0?void 0:e.abort();const a=new AbortController;this.abortController=a;const r=Is(this.config);this.updateState({type:i,resource:t,connection:{dispose:()=>{this.dispose();a.abort()}}});const h=await I.abort(a.signal,ws(a.signal,(()=>this.connect(o,r)),{dispose:()=>{}},{maxRetries:n,delaysInMs:vs.WS_RECONNECT_DELAYS})).catch((t=>{throw new B("Websocket connection failed.",t instanceof Error?t:undefined)}));if(!h.aborted){return this.requestNewOrExistingStream(t,h.result,s)}else{this.updateState({type:"disconnected"})}}async requestNewOrExistingStream(t,i,s){const n=this.requestClock();const e=await s();console.debug(`Stream connected [stream-id=${e.streamId}, scene-id=${e.sceneId}, scene-view-id=${e.sceneViewId}]`);const o=this.onRequest((t=>{const i=t.request.drawFrame;if(i!=null){const t=ut(e.worldOrientation)(i);if(this.state.type==="connected"){if(t.depthBufferBytes!=null||this.state.frame.temporalRefinementCorrelationId!==t.temporalRefinementCorrelationId){this.updateState({...this.state,frame:t,fallbackDepthBufferBytes:t.depthBufferBytes})}else{this.updateState({...this.state,frame:t.copy({depthBufferBytes:this.state.fallbackDepthBufferBytes})})}}}}));const a=this.reconnectWhenNeeded();const r=this.refreshTokenWhenExpired(e.token);const h=this.acknowledgeFrameRequests();const c=e.frame==null?await this.waitForFrame(e.worldOrientation,this.options.loadTimeoutInSeconds):e.frame;const l=await n;console.debug(`Synchronized clocks [local-time=${l.knownLocalTime.toISOString()}, remote-time=${l.knownRemoteTime.toISOString()}]`);this.updateState({type:"connected",connection:{dispose:()=>{a.dispose();o.dispose();r.dispose();h.dispose();i.dispose()}},resource:t,streamId:e.streamId,deviceId:e.deviceId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,worldOrientation:e.worldOrientation,token:e.token,frame:c,clock:l,fallbackDepthBufferBytes:undefined})}async requestNewStream(t,i){var s,n;const e=t.queries.find((t=>t.type==="supplied-id"));const o=ft(await this.startStream({streamKey:{value:t.resource.id},dimensions:this.getDimensions(),resolution:Cs(this.getResolution()),frameBackgroundColor:ys(this.frameBgColor),clientSupportsTemporalRefinement:this.enableTemporalRefinement,streamAttributes:gs(this.streamAttributes),sceneViewStateId:((s=t.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"&&t.subResource.id!=null?{hex:t.subResource.id}:undefined,sceneViewStateSuppliedId:((n=t.subResource)===null||n===void 0?void 0:n.type)==="scene-view-state"&&e!=null?{value:e.id}:undefined,cameraType:i!=null?bs(i):undefined}));return{resource:t,streamId:o.streamId,sceneId:o.sceneId,sceneViewId:o.sceneViewId,deviceId:o.sessionId,token:o.token,worldOrientation:o.worldOrientation,frame:undefined,fallbackDepthBufferBytes:undefined}}async requestReconnectStream(t){const i=pt(await this.reconnect({streamId:{hex:t.streamId},dimensions:this.getDimensions(),frameBackgroundColor:ys(this.frameBgColor),streamAttributes:gs(this.streamAttributes),clientSupportsTemporalRefinement:this.enableTemporalRefinement}));return{...t,token:i.token}}async requestClock(){const t=mt(await this.syncTime({requestTime:g()}));return new St(t)}reconnectWhenNeeded(){const t=this.onClose((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}));const i=this.onRequest((t=>{const i=t.request.gracefulReconnection!=null;if(i&&this.state.type==="connected"){console.debug("Received request for graceful reconnect. Closing connection and attempting reconnect.");this.closeAndReconnect(this.state)}}));const s=this.reconnectWhenOffline();return{dispose:()=>{t.dispose();i.dispose();s.dispose()}}}refreshTokenWhenExpired(t){let i;const s=t=>{const{tokenRefreshOffsetInSeconds:n}=this.options;const e=t.remainingTimeInMs(n);i=window.setTimeout((async()=>{const t=await this.refreshToken();const i=wt(t);s(i);if(this.state.type==="connected"){this.updateState({...this.state,token:i})}}),e)};s(t);return{dispose:()=>clearTimeout(i)}}reconnectWhenOffline(){let t;const i=()=>window.clearTimeout(t);const s=()=>{i();const s=this.options.offlineThresholdInSeconds;console.debug(`Detected that host is offline. Will attempt reconnect in ${s}s.`);t=window.setTimeout((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}),s*1e3)};const n=()=>{console.debug("Detected that host is online.");i()};const e=()=>s();window.addEventListener("offline",e);window.addEventListener("online",n);return{dispose:()=>{i();window.removeEventListener("offline",e);window.removeEventListener("online",n)}}}closeAndReconnect(t){t.connection.dispose();return this.connectToExistingStream(t)}async waitForFrame(t,i){let s;try{return await I.timeout(i*1e3,new Promise((i=>{s=this.onRequest((n=>{try{const s=n.request.drawFrame;if(s!=null){const n=ut(t)(s);i(n)}}finally{s===null||s===void 0?void 0:s.dispose()}}))})))}catch(t){throw new j(`Frame timed out after ${i}s`,t instanceof Error?t:undefined)}finally{s===null||s===void 0?void 0:s.dispose()}}acknowledgeFrameRequests(){return this.onRequest(qi(this,(()=>this.state.type==="connected"?this.state.clock:undefined)))}updateState(t){if(this.state!==t){this.state=t;this.stateChanged.emit(this.state)}}getDimensions(){if(u.area(this.dimensions)===0){return u.create(1,1)}return this.dimensions}getResolution(){if(window.devicePixelRatio!=null){return 96*window.devicePixelRatio}else{return 96}}ifState(t,i){if(this.state.type===t){return i()}}onStateChanged(t){return this.stateChanged.on(t)}}vs.WS_RECONNECT_DELAYS=[0,1e3,1e3,5e3];const gs=b.ifInvalidThrow(ht);const ys=b.ifInvalidThrow(ct);const bs=b.ifInvalidThrow(lt);const Cs=b.ifInvalidThrow(dt);function Is(t){return{EXPERIMENTAL_frameDelivery:{...t.EXPERIMENTAL_frameDelivery,rateLimitingEnabled:t.flags.throttleFrameDelivery},EXPERIMENTAL_adaptiveRendering:{...t.EXPERIMENTAL_adaptiveRendering,enabled:t.flags.adaptiveRendering},EXPERIMENTAL_qualityOfService:{...t.EXPERIMENTAL_qualityOfService}}}function Ps(t){return{url:T.toString(t),protocols:["ws.vertexvis.com"]}}function Ss(t,i,s,n){if(s!=null){return T.appendPath(T.toString(T.parseAndAddParams("/ws",{clientId:s,deviceId:n})),T.parse(t.network.renderingHost))}else{return T.appendPath(`/stream-keys/${i.id}/session`,T.parse(t.network.renderingHost))}}class ks{constructor(t){this.callback=t;this.handleVisibilityChange=this.handleVisibilityChange.bind(this);this.emitVisibilityChange=this.emitVisibilityChange.bind(this);this.mutationObservers=[]}isVisible(t){if("checkVisibility"in t){return t.checkVisibility({visibilityProperty:true,opacityProperty:true})}return true}observe(t){this.targetElement=t;this.watchElementVisibility(t)}unobserve(){if(this.targetElement!=null){this.mutationObservers.forEach((t=>t.disconnect()));this.mutationObservers=[]}this.targetElement=undefined}disconnect(){this.mutationObservers.forEach((t=>t.disconnect()));this.mutationObservers=[]}watchElementVisibility(t){if(t!=null){const i=new MutationObserver(this.handleVisibilityChange);i.observe(t,{attributes:true,attributeFilter:["style","class","hidden"]});this.mutationObservers=[...this.mutationObservers,i];this.watchElementVisibility(t.parentElement)}}handleVisibilityChange(){if(this.targetElement!=null){this.emitVisibilityChange(this.targetElement)}}emitVisibilityChange(t){const i=t!=null?this.isVisible(t):true;console.debug(`Detected visibility change [visible={${i}}]`);this.callback(i)}}const Ts=15e3;function As(t){return t.getBoundingClientRect()}function Ds(t,i){const s=window.getComputedStyle(t);const n=s.getPropertyValue(i);return n!==""?n:undefined}const xs=()=>`button{border:none;background:transparent;cursor:pointer;margin:0;padding:0}.button{padding:0.5rem;border-radius:0.25rem}.button-secondary{color:var(--neutral-800);background-color:var(--neutral-300)}.button-secondary:hover{color:var(--neutral-900)}.button-secondary:hover:enabled{box-shadow:0 2px 2px rgb(0 0 0 / 20%)}.button-secondary:disabled{opacity:0.8}.button-secondary:hover:disabled{cursor:not-allowed}:host{--image-background:var(--image-background);--viewer-background:var(--viewer-background);display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}.enable-pointer-events{touch-action:none}.viewer-container{width:100%;height:100%;overflow:hidden}.error-message-wrapper{align-items:center;display:flex;flex-direction:column;gap:1rem;position:absolute;top:50%;width:100%;transform:translateY(-50%);text-align:center}.error-message{font-size:0.875rem}`;const Ms=class{constructor(s){t(this,s);this.tap=i(this,"tap");this.doubletap=i(this,"doubletap");this.longpress=i(this,"longpress");this.frameReceived=i(this,"frameReceived");this.frameDrawn=i(this,"frameDrawn");this.tokenExpired=i(this,"tokenExpired");this.connectionChange=i(this,"connectionChange");this.sceneReady=i(this,"sceneReady");this.sceneChanged=i(this,"sceneChanged");this.interactionStarted=i(this,"interactionStarted");this.interactionFinished=i(this,"interactionFinished");this.cameraTypeChanged=i(this,"cameraTypeChanged");this.annotationStateChanged=i(this,"annotationStateChanged");this.deviceIdChange=i(this,"deviceIdChange");this.dimensionschange=i(this,"dimensionschange");this.configEnv="platprod";this.cameraControls=true;this.cameraType="perspective";this.keyboardControls=true;this.rotateAroundTapPoint=true;this.phantom={opacity:.1};this.noDefaultLights=false;this.enableTemporalRefinement=true;this.experimentalRenderingOptions="";this.crossSectioning={endCapEnabled:true,endCapColor:undefined};this.resizeDebounce=100;this.viewport=Bt.fromDimensions(u.create(0,0));this.experimentalSkipVisibilityCheck=false;this.stateMap={cursorManager:new xt,streamState:{type:"disconnected"}};this.isVisible=false;this.frameRenderVersion=0;this.interactionHandlers=[];this.defaultInteractionHandlerDisposables=[];this.tapKeyInteractions=[];this.defaultTapKeyInteractions=[];this.internalFrameDrawnDispatcher=new C;this.handleUpdateStreamAttributesWithTimer=()=>{const t=50;if(this.streamAttributesUpdateTimer==null){this.streamAttributesUpdateTimer=setTimeout((()=>{this.streamAttributesUpdateTimer=undefined;this.updateStreamAttributes()}),t)}};this.handleRetry=()=>{this.reload().catch((t=>{console.error("Error reloading scene",t)}))};this.handleElementResize=this.handleElementResize.bind(this);this.handleVisibilityChange=this.handleVisibilityChange.bind(this)}connectedCallback(){var t,i,s;(t=this.stencilBuffer)!==null&&t!==void 0?t:this.stencilBuffer=new Ot(this.hostElement);this.visibilityObserver=new ks(this.handleVisibilityChange);this.isVisible=this.visibilityObserver.isVisible(this.hostElement);if(!this.isVisible){(i=this.visibilityObserver)===null||i===void 0?void 0:i.observe(this.hostElement)}(s=this.stream)===null||s===void 0?void 0:s.resume()}componentWillLoad(){var t;this.updateResolvedConfig();this.calculateComponentDimensions();this.resizeObserver=new ResizeObserver(this.handleElementResize);this.registerSlotChangeListeners();const i=this.getResolvedConfig();const s=new f.SceneViewAPIClient(i.network.sceneViewHost);this.annotations=new Jt(s,(()=>this.token),(()=>this.deviceId));this.annotations.onStateChange.on((t=>{this.annotationStateChanged.emit(t);const i=Object.keys(t.annotations).length;this.handleAnnotationSetsChange(i)}));this.stream=(t=this.stream)!==null&&t!==void 0?t:new vs(new y,{loggingEnabled:i.flags.logWsMessages,enableTemporalRefinement:this.enableTemporalRefinement});this.addStreamListeners();this.modelViews=new kt(s,this.stream,(()=>this.token),(()=>this.deviceId));this.pmi=new Tt(s,(()=>this.token),(()=>this.deviceId));this.sceneItems=new ds(s,(()=>this.token),(()=>this.deviceId));this.canvases=new ri(s,(()=>this.token),(()=>this.deviceId));this.updateStreamAttributes();this.stateMap.cursorManager.onChanged.on((()=>this.handleCursorChanged()))}async componentDidLoad(){var t,i,s;this.interactionApi=this.createInteractionApi();this.isVisible=(i=(t=this.visibilityObserver)===null||t===void 0?void 0:t.isVisible(this.hostElement))!==null&&i!==void 0?i:true;if(this.canvasContainerElement!=null){(s=this.resizeObserver)===null||s===void 0?void 0:s.observe(this.canvasContainerElement)}this.loadOrResumeStream().catch((t=>{console.error("Error loading scene",t)}));await this.initializeDefaultInteractionHandlers();this.injectViewerApi()}disconnectedCallback(){var t,i,s;(t=this.visibilityObserver)===null||t===void 0?void 0:t.disconnect();(i=this.annotations)===null||i===void 0?void 0:i.disconnect();(s=this.stream)===null||s===void 0?void 0:s.pause()}render(){var t;return s(n,{key:"9f432c1405929448b4ded4c458d70c36781d4a7d"},s("div",{key:"1963c4b6d17b168e87a652da2190d10923ea4ce5",ref:t=>this.viewerContainerElement=t,class:"viewer-container",style:{cursor:Et((t=this.cursor)!==null&&t!==void 0?t:"")},onContextMenu:t=>t.preventDefault()},s("div",{key:"dc2a675091f94c47c87f24a43cf7e9cd603a8af2",ref:t=>this.canvasContainerElement=t,class:D("canvas-container",{"enable-pointer-events ":window.PointerEvent!=null})},s("canvas",{key:"604cdad20b6fc50c6a06e3e5ec4fdc8ee6b71d8f",ref:t=>{this.canvasElement=t;this.stateMap.interactionTarget=t},class:"canvas"}),this.errorMessage!=null?s("div",{class:"error-message-wrapper",role:"alert"},s("span",{class:"error-message"},this.errorMessage),s("slot",{name:"retry"},s("button",{class:"button button-secondary",type:"button",onClick:this.handleRetry},"Retry"))):null),s("slot",{key:"a09eb09541a5b3bfb8943a62e0d37f100a2fde25"})))}async dispatchFrameDrawn(t){this.frame=t;this.internalFrameDrawnDispatcher.emit(t);this.frameDrawn.emit(t)}async registerInteractionHandler(t){this.interactionHandlers.push(t);this.initializeInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerBasicInteractionHandler(t){this.interactionHandlers.push(t);this.initializeBasicInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerTapKeyInteraction(t){this.tapKeyInteractions=[...this.tapKeyInteractions,t]}async getInteractionTarget_DEPRECATED(){if(this.stateMap.interactionTarget!=null){return this.stateMap.interactionTarget}else throw new Error("Interaction target is undefined.")}async addCursor(t,i){return this.stateMap.cursorManager.add(t,i)}async getInteractionHandlers(){return this.interactionHandlers}async getKeyInteractions(){return this.tapKeyInteractions}async getBaseInteractionHandler(){return this.baseInteractionHandler}async getJwt(){return this.token}handleSrcChanged(t){if(t!=null){this.load(t,{cameraType:this.cameraType})}else{this.unload()}}handleCameraControlsChanged(){this.initializeDefaultCameraInteractionHandlers()}handleKeyboardControlsChanged(){this.initializeDefaultKeyboardInteractionHandlers()}handleRotateAboutTapPointChanged(){var t,i;this.updateStreamAttributes();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}else{(i=this.baseInteractionHandler)===null||i===void 0?void 0:i.setPrimaryInteractionType("rotate")}}handleCameraTypeChanged(t,i){if(t!==i){this.updateCameraType()}}handleStreamAttributesChanged(){this.handleUpdateStreamAttributesWithTimer()}handleEnableTemporalRefinementChanged(){this.updateEnableTemporalRefinement()}handleConfigChanged(){this.updateResolvedConfig()}handleConfigEnvChanged(){this.updateResolvedConfig()}async load(t,i){var s,n;const e=this.experimentalSkipVisibilityCheck||this.isVisible;if(!e){console.debug("Detected the viewer is hidden. Delaying load until visible.");return}if(this.stream!=null&&this.dimensions!=null){const{EXPERIMENTAL_annotationPollingIntervalInMs:e}=this.getResolvedConfig();this.calculateComponentDimensions();this.stream.update({streamAttributes:this.getStreamAttributes(),config:Dt(this.configEnv,this.config),dimensions:this.dimensions,frameBgColor:this.getBackgroundColor()});const o=await((s=this.stream)===null||s===void 0?void 0:s.load(t,this.clientId,this.getDeviceId(),this.getResolvedConfig(),i===null||i===void 0?void 0:i.cameraType));if(o.type==="connected"){this.sceneReady.emit();if(e!==undefined){(n=this.annotations)===null||n===void 0?void 0:n.connect(e)}}}else{throw new z("Cannot load scene. Viewer has not been initialized.")}}async unload(){var t;if(this.stream!=null){this.frameRenderVersion+=1;(t=this.annotations)===null||t===void 0?void 0:t.disconnect();this.stream.disconnect();this.frame=undefined;this.errorMessage=undefined}if(this.canvasElement!=null){const t=this.canvasElement.getContext("2d");if(t!=null){t.clearRect(0,0,this.canvasElement.width,this.canvasElement.height)}}}async reload(){if(this.src!=null){await this.unload();await this.load(this.src,{cameraType:this.cameraType})}}async scene(){return this.createScene()}async isSceneReady(){return this.stateMap.streamState.type==="connected"}async handleTapEvent(t){this.tapKeyInteractions.filter((i=>i.predicate(t.detail))).forEach((i=>i.fn(t.detail)))}emitConnectionChange(t){if(t.status==="connected"){if(t.jwt.length===0){throw new L("JWT is empty")}}if(!this.hostElement.isConnected){return}this.connectionChange.emit(t)}handleElementResize(t){const i=t.length>0&&this.dimensions!=null&&!u.isEqual(t[0].contentRect,this.viewport);if(i){if(this.resizeTimer!=null){clearTimeout(this.resizeTimer);this.resizeTimer=undefined}if(!this.isResizing){this.resizeTimer=setTimeout((()=>{this.isResizing=true;this.isResizeUpdate=true;this.recalculateComponentDimensions()}),this.resizeDebounce)}}}handleVisibilityChange(t){var i;this.isVisible=t;if(this.isVisible){(i=this.visibilityObserver)===null||i===void 0?void 0:i.disconnect();this.loadOrResumeStream()}}async loadOrResumeStream(){var t,i,s;const n=(i=(t=this.stream)===null||t===void 0?void 0:t.isPaused())!==null&&i!==void 0?i:false;if(this.src!=null&&!n){await this.load(this.src,{cameraType:this.cameraType})}else if(n){(s=this.stream)===null||s===void 0?void 0:s.resume()}}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((t=>this.injectViewerApi()));this.mutationObserver.observe(this.hostElement,{childList:true,subtree:true});this.styleObserver=new MutationObserver((t=>this.syncViewerStyles()));this.styleObserver.observe(this.hostElement,{attributes:true,attributeFilter:["style"]})}injectViewerApi(){function t(t){return Array.from(t.querySelectorAll("*"))}const i=t(this.hostElement);i.filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((i,s)=>[...i,s,...t(s)]),[]).forEach((t=>{t.viewer=this.hostElement}))}syncViewerStyles(){var t;const i=this.getBackgroundColor();(t=this.stream)===null||t===void 0?void 0:t.update({frameBgColor:i,streamAttributes:this.getStreamAttributes()})}calculateComponentDimensions(){var t;const i=2073600;const s=this.getBounds();if((s===null||s===void 0?void 0:s.width)!=null&&(s===null||s===void 0?void 0:s.height)!=null){const n=u.create(s.width,s.height);const e=u.scaleFit(i,n);this.hostDimensions=n;this.dimensions=e!=null?u.create(e.width,e.height):undefined;this.viewport=Bt.fromDimensions((t=this.getCanvasDimensions())!==null&&t!==void 0?t:u.create(0,0))}}recalculateComponentDimensions(){var t;if(this.isResizing){this.calculateComponentDimensions();this.isResizing=false;if(((t=this.stream)===null||t===void 0?void 0:t.getState().type)==="connected"){this.updateDimensions(this.dimensions)}}}reportPerformance(t){if(this.stateMap.streamState.type==="connected"){const i={timings:t.map((t=>({receiveToPaintDuration:p(t.duration)})))};this.getStream().recordPerformance(i,false)}}addStreamListeners(){this.stateMap.streamListeners=this.getStream().stateChanged.on((t=>{this.handleStreamStateChanged(this.stateMap.streamState,t)}))}handleStreamStateChanged(t,i){this.stateMap.streamState=i;if(i.type==="connecting"){this.handleConnecting(t,i)}else if(i.type==="connected"){this.handleConnected(t,i)}else if(i.type==="connection-failed"){this.handleConnectionFailed(t,i)}else if(i.type==="disconnected"){this.handleDisconnected(t,i)}}handleConnecting(t,i){if(t.type!=="connecting"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"connecting"})}}handleConnected(t,i){var s;this.token=i.token.token;if(t.type!=="connected"){this.errorMessage=undefined;this.canvasRenderer=Oi(Ei,Hi(),this.getResolvedConfig().flags.logFrameRate,(t=>this.reportPerformance(t)));this.emitConnectionChange({status:"connected",jwt:i.token.token});this.deviceIdChange.emit(i.deviceId)}if(((s=this.frame)===null||s===void 0?void 0:s.getId())!==i.frame.getId()){this.updateFrame(i.frame)}this.updateDimensions(this.dimensions)}handleConnectionFailed(t,i){if(t.type!=="connection-failed"){this.token=undefined;this.errorMessage=i.message;this.emitConnectionChange({status:"connection-failed",errorMessage:i.message})}}handleDisconnected(t,i){if(t.type!=="disconnected"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"disconnected"})}}updateDimensions(t){var i;(i=this.stream)===null||i===void 0?void 0:i.update({dimensions:t});this.dimensionschange.emit(t)}async updateFrame(t){var i;const s=this.getCanvasDimensions();const n=this.frameRenderVersion;if(this.canvasElement!=null&&s!=null&&((i=this.frame)===null||i===void 0?void 0:i.getId())!==t.getId()){const i=this.canvasElement.getContext("2d");if(i!=null){const e=this.frame;this.frame=vt(t,e);this.updateInteractionApi(e);const o={canvas:i,canvasDimensions:s,dimensions:this.dimensions,frame:this.frame,viewport:this.viewport,beforeDraw:()=>{this.updateCanvasDimensions(s);this.isResizeUpdate=false},predicate:()=>{if(this.isResizeUpdate){return this.dimensions==null||u.isEqual(this.dimensions,o.frame.image.imageAttr.frameDimensions)}return true}};this.frameReceived.emit(this.frame);if(this.frame.scene.hasChanged){this.sceneChanged.emit()}const a=await this.canvasRenderer(o);if(a!=null&&n===this.frameRenderVersion){this.updateViewerBackground();this.dispatchFrameDrawn(a)}}}}updateViewerBackground(){const t=this.getBackgroundColor();Lt((()=>{var i,s;(i=this.viewerContainerElement)===null||i===void 0?void 0:i.style.setProperty("background",t!=null?P.toHexString(t):"#ffffff");(s=this.canvasContainerElement)===null||s===void 0?void 0:s.style.setProperty("background",t!=null?P.toHexString(t):"#ffffff")}))}async initializeDefaultInteractionHandlers(){var t;await this.initializeDefaultCameraInteractionHandlers();await this.initializeDefaultTapInteractionHandler();this.initializeDefaultKeyboardInteractionHandlers();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}}clearDefaultCameraInteractionHandlers(){this.defaultInteractionHandlerDisposables.forEach((t=>t.dispose()));this.defaultInteractionHandlerDisposables=[]}clearDefaultKeyboardInteractions(){this.defaultTapKeyInteractions.forEach((t=>{const i=this.tapKeyInteractions.indexOf(t);if(i!==-1){this.tapKeyInteractions.splice(i,1)}}));this.tapKeyInteractions=[]}async initializeDefaultCameraInteractionHandlers(){var t,i;this.clearDefaultCameraInteractionHandlers();if(this.cameraControls){if(window.PointerEvent!=null){this.baseInteractionHandler=(t=this.baseInteractionHandler)!==null&&t!==void 0?t:new ki((()=>this.getResolvedConfig()));const i=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Si);this.defaultInteractionHandlerDisposables=[i,s]}else{this.baseInteractionHandler=(i=this.baseInteractionHandler)!==null&&i!==void 0?i:new Ci((()=>this.getResolvedConfig()));const t=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Ai);this.defaultInteractionHandlerDisposables=[t,s]}}}initializeDefaultKeyboardInteractionHandlers(){var t;this.clearDefaultKeyboardInteractions();if(this.keyboardControls&&this.stream!=null){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setDefaultKeyboardControls(this.keyboardControls);const i=new hi(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()));const s=new fi(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()),(()=>this.createScene()));this.registerTapKeyInteraction(i);this.registerTapKeyInteraction(s);this.defaultTapKeyInteractions=[i,s]}}async initializeDefaultTapInteractionHandler(){if(this.tapHandlerDisposable==null){if(window.PointerEvent!=null){const t=new Ti("pointerdown","pointerup","pointermove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}else{const t=new Ti("mousedown","mouseup","mousemove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}}}initializeInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new V("Cannot initialize interaction handler. Interaction target is undefined.")}if(this.interactionApi==null){throw new V("Cannot initialize interaction handler. Interaction APi is undefined.")}t.initialize(this.stateMap.interactionTarget,this.interactionApi)}initializeBasicInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new V("Cannot initialize interaction handler. Interaction target is undefined.")}t.initialize(this.stateMap.interactionTarget)}createInteractionApi(){if(this.stream==null){throw new $("Cannot create interaction API. Component has not been initialized.")}return this.frame==null||this.frame.scene.camera.isPerspective()?new ui(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished):new li(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished)}handleCursorChanged(){window.requestAnimationFrame((()=>{this.cursor=this.stateMap.cursorManager.getActiveCursor()}))}async createScene(){const t=await this.waitForConnectedState();const i=gt();const{frame:s,sceneId:n,sceneViewId:e,worldOrientation:o}=t;return new At(this.getStream(),s,ut(o),i,(()=>this.getImageScale()),this.viewport,n,e)}getBackgroundColor(){if(this.canvasContainerElement!=null){const t=Ds(this.hostElement,"--image-background");const i=Ds(this.hostElement,"--viewer-background");const s=t!==null&&t!==void 0?t:i;return s!=null?P.fromCss(s):P.create(255,255,255)}}getBounds(){return As(this.hostElement)}getCanvasDimensions(){return this.getResolvedConfig().flags.letterboxFrames?this.dimensions:this.hostDimensions}getImageScale(){const t=this.getCanvasDimensions();if(this.dimensions!=null&&t!=null){return o.create(this.dimensions.width/t.width,this.dimensions.height/t.height)}}getStreamAttributes(){return{depthBuffers:this.getDepthBufferStreamAttributesValue(),experimentalRenderingOptions:this.experimentalRenderingOptions,featureHighlighting:this.featureHighlighting,featureLines:this.featureLines,featureMaps:this.featureMaps,frames:{frameBackgroundColor:this.getBackgroundColor()},noDefaultLights:this.noDefaultLights,phantom:this.phantom,sceneComparison:this.sceneComparison,selectionHighlighting:this.selectionHighlighting,crossSectioning:this.crossSectioning}}updateCanvasDimensions(t){if(this.canvasElement!=null){this.canvasElement.width=t.width;this.canvasElement.height=t.height}}updateStreamAttributes(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({streamAttributes:this.getStreamAttributes()})}updateEnableTemporalRefinement(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({enableTemporalRefinement:this.enableTemporalRefinement})}updateInteractionApi(t){if(this.frame!=null){const i=(t==null||t.scene.camera.isPerspective())&&this.frame.scene.camera.isOrthographic();const s=(t==null||t.scene.camera.isOrthographic())&&this.frame.scene.camera.isPerspective();if(i||s){this.interactionApi=this.createInteractionApi();this.cameraType=this.frame.scene.camera.isPerspective()?"perspective":"orthographic";this.cameraTypeChanged.emit(this.cameraType);this.interactionHandlers.forEach((t=>this.initializeInteractionHandler(t)))}}}updateCameraType(){var t,i;if(this.frame!=null){if(this.cameraType==="orthographic"&&this.frame.scene.camera.isPerspective()){(t=this.stream)===null||t===void 0?void 0:t.replaceCamera({camera:it(yt(this.frame.scene.camera,this.frame.scene.boundingBox))})}else if(this.cameraType==="perspective"&&this.frame.scene.camera.isOrthographic()){(i=this.stream)===null||i===void 0?void 0:i.replaceCamera({camera:it(bt(this.frame.scene.camera))})}}}handleAnnotationSetsChange(t){if(t>0&&this.getDepthBufferStreamAttributesValue()==null){this.stateMap.depthBuffersOverrideForAnnotations=true;this.updateStreamAttributes()}else if(t===0&&this.stateMap.depthBuffersOverrideForAnnotations){this.stateMap.depthBuffersOverrideForAnnotations=false;this.updateStreamAttributes()}}getDepthBufferStreamAttributesValue(){var t;const i=(t=this.depthBuffers)!==null&&t!==void 0?t:this.rotateAroundTapPoint||this.stateMap.depthBuffersOverrideForAnnotations?"final":undefined;return i}updateResolvedConfig(){this.resolvedConfig=Dt(this.configEnv,this.config)}getResolvedConfig(){return Es("Resolved config is undefined",(()=>this.resolvedConfig))}getStream(){return Es("Stream is undefined",(()=>this.stream))}getDeviceId(){if(this.deviceId==null){try{this.deviceId=ms(us.DEVICE_ID,(t=>t["device-id"]))}catch(t){console.warn("Cannot read device ID. Local storage is not supported.")}if(this.deviceId==null){this.deviceId=A.create();try{ps(us.DEVICE_ID,{["device-id"]:this.deviceId})}catch(t){console.warn("Cannot write device ID. Local storage is not supported.")}}}return this.deviceId}async waitForConnectedState(){if(this.stateMap.streamState.type!=="connected"){console.debug("Stream was not in a connected state. Waiting for successful connection.");return new Promise(((t,i)=>{const s=this.getStream().onStateChanged((i=>{if(i.type==="connected"){t(i)}}));setTimeout((()=>{s.dispose();i(new Error("Timed out waiting for connected state."))}),Ts)}))}return this.stateMap.streamState}get hostElement(){return e(this)}static get watchers(){return{src:[{handleSrcChanged:0}],cameraControls:[{handleCameraControlsChanged:0}],keyboardControls:[{handleKeyboardControlsChanged:0}],rotateAroundTapPoint:[{handleRotateAboutTapPointChanged:0}],cameraType:[{handleCameraTypeChanged:0}],crossSectioning:[{handleStreamAttributesChanged:0}],depthBuffers:[{handleStreamAttributesChanged:0}],experimentalRenderingOptions:[{handleStreamAttributesChanged:0}],featureHighlighting:[{handleStreamAttributesChanged:0}],featureLines:[{handleStreamAttributesChanged:0}],featureMaps:[{handleStreamAttributesChanged:0}],noDefaultLights:[{handleStreamAttributesChanged:0}],phantom:[{handleStreamAttributesChanged:0}],sceneComparison:[{handleStreamAttributesChanged:0}],selectionHighlighting:[{handleStreamAttributesChanged:0}],enableTemporalRefinement:[{handleEnableTemporalRefinementChanged:0}],config:[{handleConfigChanged:0}],configEnv:[{handleConfigEnvChanged:0}]}}};function Es(t,i){const s=i();if(s!=null){return s}else throw new Error(t)}Ms.style=xs();export{Ms as vertex_viewer};
5
- //# sourceMappingURL=p-edc2f914.entry.js.map
4
+ import{r as t,c as i,h as s,H as n,a as e}from"./p-CCVkga9Q.js";import{p as o,v as a,a as r,b as h,r as c,c as l,d,e as u}from"./p-2UsvOTHJ.js";import{s as f}from"./p-BU0JYf18.js";import{t as p,p as m,S as w,a as v,c as g,W as y}from"./p-5kcpg4MZ.js";import{m as b,E as C,a as P,c as I,d as S,o as k,u as T,b as A}from"./p-CDM7zNn0.js";import{c as D}from"./p-Dw4-tG-V.js";import{u as x,I as M,p as E,C as R,W as B,S as j,V as z,M as L,a as V,b as $}from"./p--8q6LyIm.js";import{p as O}from"./p-C4_1Jc7H.js";import{s as H,r as N}from"./p-BNuMPeJ8.js";import{r as K,c as F,a as W}from"./p-CioaIHsi.js";import{i as U,j as _,k as q,l as J,m as X,n as Z,o as G,p as Y,q as Q,u as tt,t as it,r as st,s as nt,v as et,w as ot,x as at,y as rt,z as ht,B as ct,C as lt,E as dt,G as ut,H as ft,I as pt,J as mt,K as wt,L as vt,M as gt,N as yt,P as bt}from"./p-Cc3XhAoA.js";import{t as Ct,m as Pt,n as It,j as St,M as kt,k as Tt,S as At}from"./p-DYDhLlLS.js";import{p as Dt}from"./p-Bw_ryWU0.js";import{C as xt}from"./p-DxMDDbmh.js";import{g as Mt,c as Et}from"./p-D0aTA_2m.js";import{E as Rt}from"./p-BAhfr1Nx.js";import{V as Bt}from"./p-CeZe0Qql.js";import{B as jt,M as zt}from"./p-DIbJ8Ijj.js";import{w as Lt}from"./p-BxtKMwBH.js";import"./p-ux1ckSDN.js";import"./p-CG9AChtV.js";import"./p-CPk-nchx.js";const Vt=0;const $t=255;class Ot{constructor(t){this.viewer=t;this.handleInteractionStarted=()=>{this.invalidateStencilBuffer();this.pendingInteractionFinished=new Promise((t=>{this.pendingInteractionFinishedResolver=t}))};this.handleInteractionFinished=()=>{var t;(t=this.pendingInteractionFinishedResolver)===null||t===void 0?void 0:t.call(this);this.pendingInteractionFinished=undefined;this.pendingInteractionFinishedResolver=undefined};this.invalidateStencilBuffer=()=>{this.pendingStencilBuffer=undefined};t.addEventListener("interactionStarted",this.handleInteractionStarted);t.addEventListener("interactionFinished",this.handleInteractionFinished);t.addEventListener("frameReceived",(()=>{this.invalidateStencilBuffer()}))}async fetch(){var t;const i=await this.viewer.isSceneReady();const s=i?await this.viewer.scene():undefined;const n=s!=null?s.crossSectioning().current().sectionPlanes.length>0||this.viewer.featureLines!=null:false;const e=(t=this.viewer.frame)===null||t===void 0?void 0:t.scene.camera;if(n&&this.viewer.stream!=null&&e!=null){const t=await this.viewer.stream.getStencilBuffer({includeDepthBuffer:true});const{stencilBuffer:i,depthBuffer:s,imageAttributes:n}=U(t);const[o,a]=await Promise.all([_(new Uint8Array(i)),_(new Uint8Array(s))]);return Ht.fromPng(o,n,i,q.fromPng(a,e,n))}else return undefined}latest(){if(this.pendingStencilBuffer==null){this.pendingStencilBuffer=this.fetch()}return this.pendingStencilBuffer}async latestAfterInteraction(){await this.pendingInteractionFinished;return this.latest()}}class Ht{constructor(t,i,s,n,e){this.imageAttr=t;this.imageBytes=i;this.pixelBytes=s;this.imageChannels=n;this.depthBuffer=e}static fromPng(t,i,s,n){if(!(t.data instanceof Uint8Array)){throw new Error("Expected stencil PNG to have depth of 8-bit")}else if(t.channels!==1){throw new Error("Expected stencil PNG to have 1 color channel")}else{return new Ht(i,s,t.data,t.channels,n)}}getValue(t){const{width:i,height:s}=this.imageAttr.imageRect;const n=o.subtract(t,this.imageAttr.imageRect);const e=1/this.imageAttr.imageScale;const a=o.scale(n,e,e);if(a.x>=0&&a.y>=0&&a.x<i&&a.y<s){const t=Math.floor(a.x)+Math.floor(a.y)*i;const s=this.pixelBytes[t];return s}else return 0}hitTest(t){return this.getValue(t)!==Vt}snapToNearestPixel(t,i,s=()=>true){const n=i*2;const e=o.create(t.x-i,t.y-i);const a=[];for(let r=0;r<n*n;r++){const h=r%n;const c=Math.floor(r/n);const l=o.add(e,{x:h,y:c});if(o.distance(l,t)<=i){const t=this.getValue(l);if(t===$t&&s(t)){a.push(l)}}}const r=a.sort(((i,s)=>o.distance(i,t)-o.distance(s,t)));const h=r[0];return h!=null?o.create(Math.floor(h.x)+.5,Math.floor(h.y)+.5):t}}function Nt(t){return new Promise((i=>setTimeout(i,t)))}const Kt=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",X),b.mapRequiredProp("modifiedAt",X),b.mapProp("name",Z),b.mapProp("suppliedId",Z))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,name:n,suppliedId:e})));const Ft=b.ifInvalidThrow(Kt);const Wt=b.defineMapper(b.compose((t=>t.toObject()),b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",X),b.mapRequiredProp("modifiedAt",X),b.mapProp("suppliedId",Z),b.mapRequiredProp("data",(t=>{if(t.callout!=null){return _t(t.callout)}else if(t.customJson!=null){return qt(t.customJson)}else{throw new Error("Undefined or unknown annotation data.")}})))),(([t,i,s,n,e])=>({id:t,createdAt:i,modifiedAt:s,suppliedId:n,data:e})));const Ut=b.ifInvalidThrow(Wt);const _t=b.defineMapper(b.read(b.mapRequiredProp("position",G),b.mapProp("icon",Z),b.mapProp("primaryColor",Z),b.mapProp("accentColor",Z)),(([t,i,s,n])=>({type:"callout",position:t,icon:i,primaryColor:s,accentColor:n})));const qt=b.defineMapper(b.read(b.requiredProp("type"),b.mapRequiredProp("jsonData",(t=>JSON.parse(t)))),(([t,i])=>({type:"custom",jsonType:t,jsonData:i})));class Jt{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s;this.onStateChange=new C}async addAnnotationSet(t){await K((async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.CreateSceneViewAnnotationSetRequest;const o=new x.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.createSceneViewAnnotationSet(e,n,i)}));return this.fetch()}disconnect(){if(this.connection!=null){this.connection.dispose();this.connection=undefined}}connect(t=1e4){this.disconnect();const i=this.pollAnnotationState(t);this.connection={dispose:()=>i.abort()}}async fetch(t={}){const i=await this.fetchAnnotationSetsAsArray();const s=await this.fetchAnnotationsAsArray(i);const n=(await Promise.all(s)).reduce(((t,[i,s])=>({annotations:{...t.annotations,[i.id]:s}})),{annotations:{}});if(t.signal==null||!t.signal.aborted){this.updateState(n)}return n}async removeAnnotationSet(t){await K((async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.DeleteSceneViewAnnotationSetRequest;const o=new x.Uuid;o.setHex(t);e.setSceneAnnotationSetId(o);this.client.deleteSceneViewAnnotationSet(e,n,i)}));return this.fetch()}pollAnnotationState(t){const i=new AbortController;const s=async t=>{await this.fetch({signal:i.signal});if(!i.signal.aborted){await Nt(t);await s(t)}};P.abort(i.signal,s(t));return i}fetchAnnotationSets(){return W((t=>async i=>{const s=this.deviceIdProvider();const n=await F(this.jwtProvider,s);const e=new H.ListSceneViewAnnotationSetsRequest;if(t!=null){const i=new O.Pager;i.setCursor(t);i.setLimit(100);e.setPage(i)}this.client.listSceneViewAnnotationSets(e,n,i)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}async fetchAnnotationSetsAsArray(){return(await P.asArray(this.fetchAnnotationSets())).flatMap((t=>t.getSceneAnnotationSetsList())).map((t=>Ft(t)))}fetchAnnotations(t){return W((i=>async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.ListSceneAnnotationsRequest;const a=Ct(t);o.setSceneAnnotationSetId(a);if(i!=null){const t=new O.Pager;t.setCursor(i);t.setLimit(100);o.setPage(t)}this.client.listSceneAnnotations(o,e,s)}),(t=>{var i;return(i=t.toObject().nextCursor)===null||i===void 0?void 0:i.next}))}fetchAnnotationsAsArray(t){const i=t.map((async t=>{const i=(await P.asArray(this.fetchAnnotations(t.id))).flatMap((t=>t.getSceneAnnotationsList())).map((t=>Ut(t)));return[t,i]}));return Promise.all(i)}updateState(t){this.state=t;this.onStateChange.emit(t)}}const Xt=b.defineMapper(b.read(b.mapRequiredProp("color",Y),b.getProp("thickness")),(([t,i])=>({color:t,thickness:i})));const Zt=b.defineMapper(b.read(b.mapRequiredProp("color",Y)),(([t])=>({color:t})));const Gt=b.defineMapper(b.read(b.pickFirst(b.mapProp("arrow",b.ifDefined((t=>({...t,type:"arrow-end"})))),b.mapProp("circle",b.ifDefined((t=>({...t,type:"circle-end"})))),b.mapProp("dash",b.ifDefined((t=>({...t,type:"dash-end"})))))),(([t])=>t!==null&&t!==void 0?t:undefined));const Yt=b.defineMapper(b.read(b.mapRequiredProp("startPosition",Q),b.mapRequiredProp("endPosition",Q),b.mapProp("strokeStyle",b.ifDefined(Xt)),b.mapProp("fillStyle",b.ifDefined(Zt)),b.mapProp("startShape",b.ifDefined(Gt)),b.mapProp("endShape",b.ifDefined(Gt))),(([t,i,s,n,e,o])=>({type:"line-2d",startPosition:t,endPosition:i,strokeStyle:s,fillStyle:n,startShape:e!==null&&e!==void 0?e:undefined,endShape:o!==null&&o!==void 0?o:undefined})));const Qt=b.defineMapper(b.read(b.mapRequiredProp("topLeft",Q),b.mapRequiredProp("bottomRight",Q),b.mapProp("strokeStyle",b.ifDefined(Xt)),b.mapProp("fillStyle",b.ifDefined(Zt))),(([t,i,s,n])=>({type:"oval-2d",topLeftPosition:t,bottomRightPosition:i,strokeStyle:s,fillStyle:n})));const ti=b.defineMapper(b.read(b.mapRequiredProp("positionsList",b.mapArray(Q)),b.mapProp("strokeStyle",b.ifDefined(Xt)),b.mapProp("fillStyle",b.ifDefined(Zt))),(([t,i,s])=>({type:"freeform-2d",positions:t,strokeStyle:i,fillStyle:s})));const ii=b.defineMapper(b.read(b.mapRequiredProp("primaryColor",Y),b.mapRequiredProp("accentColor",Y),b.mapRequiredProp("position",G),b.mapProp("sceneItemId",b.ifDefined(J))),(([t,i,s,n])=>({type:"pin-2d",primaryColor:t,accentColor:i,position:s,sceneItemId:n!==null&&n!==void 0?n:undefined})));const si=b.defineMapper(b.read(b.mapRequiredProp("primaryColor",Y),b.mapRequiredProp("accentColor",Y),b.mapRequiredProp("anchorPosition",G),b.mapRequiredProp("textPosition",Q),b.getProp("text"),b.mapProp("sceneItemId",b.ifDefined(J))),(([t,i,s,n,e,o])=>({type:"callout",primaryColor:t,accentColor:i,anchorPosition:s,textPosition:n,text:e,sceneItemId:o!==null&&o!==void 0?o:undefined})));const ni=b.defineMapper(b.read(b.pickFirst(b.mapProp("line2d",b.ifDefined(Yt)),b.mapProp("oval",b.ifDefined(Qt)),b.mapProp("freeform",b.ifDefined(ti)),b.mapProp("pin",b.ifDefined(ii)),b.mapProp("callout",b.ifDefined(si)))),(([t])=>t!==null&&t!==void 0?t:undefined));const ei=b.defineMapper(b.read(b.mapRequiredProp("itemsList",b.mapArray(ni))),(([t])=>({items:t.filter((t=>t!=null))})));const oi=b.defineMapper(b.read(b.mapRequiredProp("canvas",b.mapRequiredProp("document",b.mapRequiredProp("v1",ei)))),(([t])=>t));const ai=b.ifInvalidThrow(oi);class ri{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s}async getCanvas({canvasId:t,sceneViewStateId:i}){if(t!=null&&i!=null){throw new Error("Invalid request. Only one lookup ID between `canvasId` and `sceneViewStateId` can be provided.")}const s=await K((async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.GetCanvasRequest;if(t!=null){const i=Ct(t);o.setCanvasId(i)}else if(i!=null){const t=Ct(i);o.setSceneViewStateId(t)}this.client.getCanvas(o,e,s)}));return ai(s.toObject())}}class hi{constructor(t,i,s){this.stream=t;this.configProvider=i;this.imageScaleProvider=s}predicate(t){return t.altKey&&!t.shiftKey}async fn(t){var i;const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:o.scale(t.position,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1)},true);if(((i=n.hitItems)===null||i===void 0?void 0:i.hits)!=null&&n.hitItems.hits.length>0){await this.stream.flyTo({itemId:n.hitItems.hits[0].itemId,animation:{duration:p(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit results found for fly to part [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}}class ci{constructor(t,i,s,n,e,o,a,r,h,c,l){this.stream=t;this.cursors=i;this.getConfig=s;this.getScene=n;this.getFrame=e;this.getViewport=o;this.tapEmitter=a;this.doubleTapEmitter=r;this.longPressEmitter=h;this.interactionStartedEmitter=c;this.interactionFinishedEmitter=l;this.tap=this.tap.bind(this);this.doubleTap=this.doubleTap.bind(this);this.longPress=this.longPress.bind(this);this.emitTapEvent=this.emitTapEvent.bind(this)}addCursor(t,i){return this.cursors.add(t,i)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async getEntityTypeAtPoint(t){var i;const s=this.getViewport();const n=await((i=this.getFrame())===null||i===void 0?void 0:i.featureMap());if(n!=null){const i=s.transformPointToFrame(t,n);return n.getEntityType(i)}else{return Rt.NO_GEOMETRY}}getRayFromPoint(t){const i=this.getViewport();const s=this.getFrame();if(s!=null){return i.transformPointToRay(t,s.image,s.scene.camera)}else throw new Error("Cannot get camera. Frame is undefined.")}async tap(t,i={},s=0){this.emitTapEvent(this.tapEmitter.emit,t,i,s)}async doubleTap(t,i={},s=0){this.emitTapEvent(this.doubleTapEmitter.emit,t,i,s)}async longPress(t,i={},s=0){this.emitTapEvent(this.longPressEmitter.emit,t,i,s)}async beginInteraction(t={}){if(!this.isInteracting()){this.activeRenderOptions=t;this.interactionStartedEmitter.emit();this.sceneLoadingPromise=this.getScene();this.currentCamera=(await this.sceneLoadingPromise).camera();this.sceneLoadingPromise=undefined;await this.stream.beginInteraction()}}async transformCamera(t,i){var s,n;if(i===void 0){i=(s=this.activeRenderOptions)!==null&&s!==void 0?s:{}}if(this.isInteracting()){const s=await this.getScene();const e=this.getViewport();const o=this.getFrame();const a=await(o===null||o===void 0?void 0:o.depthBuffer());this.currentCamera=this.currentCamera!=null&&e!=null&&o!=null?t({camera:this.currentCamera,viewport:e,scale:s.scale(),boundingBox:s.boundingBox(),frame:o,depthBuffer:a}):undefined;await((n=this.currentCamera)===null||n===void 0?void 0:n.render(i))}}async twistCamera(...t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(a.subtract(i.lookAt,i.position));if(t.length===1&&typeof t[0]==="number"){const s=r.toRadians(-t[0]);return i.rotateAroundAxis(s,n)}else if(t.length===1){const n=o.create(s.width/2,s.height/2);const e=r.toDegrees(r.fromPoints(n,t[0]));const h=this.lastAngle!=null?e-this.lastAngle:0;this.lastAngle=e;const c=a.normalize(a.subtract(i.lookAt,i.position));const l=r.toRadians(-h);return i.rotateAroundAxis(l,c)}return i}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,depthBuffer:e})=>{if(this.panData==null){const o=i.toFrameCamera();const a=o.direction;const r=n.transformPointToRay(t,s.image,o);const l=h.fromNormalAndCoplanarPoint(a,i.lookAt);const d=c.intersectPlane(r,l);if(d==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}const u=e!=null?this.getWorldPoint(t,e,d):d;const f=h.fromNormalAndCoplanarPoint(a,u);this.panData={hitPt:u,hitPlane:f,startingCamera:o}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const h=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(h,o);if(l!=null){const t=a.subtract(e,l);return i.update(r).moveBy(t)}}return i}))}async viewAll(){await(await this.getScene()).camera().viewAll().render({})}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=a.normalize(i.up);const e=a.normalize(a.subtract(i.lookAt,i.position));const o=a.cross(n,e);const r=a.cross(e,o);const h=a.normalize({x:t.x*o.x+t.y*r.x,y:t.x*o.y+t.y*r.y,z:t.x*o.z+t.y*r.z});const c=a.cross(h,e);const l=9.5*t.x/s.width;const d=9.5*t.y/s.height;const u=Math.abs(l)+Math.abs(d);return i.rotateAroundAxis(u,c)}))}async rotateCameraAtPoint(t,i){return this.transformCamera((({camera:s,viewport:n,depthBuffer:e})=>{if(this.worldRotationPoint==null){this.worldRotationPoint=e!=null?this.getWorldPoint(i,e,s.lookAt):s.lookAt}const o=a.normalize(s.up);const r=a.normalize(a.subtract(s.lookAt,s.position));const h=a.cross(o,r);const c=a.cross(r,h);const l=a.normalize({x:t.x*h.x+t.y*c.x,y:t.x*h.y+t.y*c.y,z:t.x*h.z+t.y*c.z});const d=a.cross(l,r);const u=9.5*t.x/n.width;const f=9.5*t.y/n.height;const p=Math.abs(u)+Math.abs(f);const m=s.rotateAroundAxisAtPoint(p,this.worldRotationPoint,d);return m.update({lookAt:a.add(a.scale(Math.abs(s.signedDistanceToBoundingBoxCenter())/a.magnitude(m.viewVector),m.viewVector),m.position)})}))}async zoomCamera(t){return this.transformCamera((({camera:i,viewport:s,frame:n,boundingBox:e})=>{if(s!=null&&n!=null){const o=i===null||i===void 0?void 0:i.toFrameCamera().isPerspective();if(o){const n=i.viewVector;const e=a.magnitude(n);const o=3*e*(t/s.height);const r=a.normalize(n);const h=a.scale(o,r);const c=a.add(i.position,h);const l=i.update({position:c});return l}else{const o=i;const r=i.toFrameCamera();const d=r.direction;const u=s.transformPointToRay(s.center,n.image,r);const f=4*(t/s.height);const p=a.magnitude(l.diagonal(e))*1e-5;const m=Math.max(p,o.fovHeight*(1-f));const w=h.fromNormalAndCoplanarPoint(d,r.lookAt);const v=c.intersectPlane(u,w);if(v!=null){const t=h.projectPoint(w,o.lookAt);const s=(o.fovHeight-m)/o.fovHeight;const n=a.scale(s,a.subtract(v,t));const e=a.add(o.lookAt,n);const r=i.update({lookAt:e,rotationPoint:e,fovHeight:m});return r}}}return i}))}async pivotCamera(t,i){return this.transformCamera((({camera:s})=>{const{position:n,up:e,lookAt:o}=s;const h=a.normalize(e);const c=a.normalize(s.viewVector);const l=a.cross(h,c);const d=a.cross(c,l);const u=a.rotateAboutAxis(r.toRadians(t),o,l,n);const f=a.rotateAboutAxis(r.toRadians(i),u,d,n);return s.update({...s,lookAt:f})}))}async endInteraction(){await this.sceneLoadingPromise;if(this.isInteracting()){this.currentCamera=undefined;this.worldRotationPoint=undefined;this.panData=undefined;this.zoomData=undefined;this.resetLastAngle();this.interactionFinishedEmitter.emit();await this.stream.endInteraction()}this.activeRenderOptions=undefined}resetLastAngle(){this.lastAngle=undefined}isInteracting(){return this.currentCamera!=null}pixelThreshold(t){const i=this.isCoarseInputDevice(t)?this.getConfig().coarsePointerThreshold:this.getConfig().finePointerThreshold;return i*window.devicePixelRatio}async hitItems(t){var i;const s=await(await this.getScene()).raycaster().hitItems(t);return(i=s===null||s===void 0?void 0:s.hits)!==null&&i!==void 0?i:[]}emitTapEvent(t,i,s={},n=0){const{altKey:e=false,ctrlKey:o=false,metaKey:a=false,shiftKey:r=false}=s;t({position:i,altKey:e,ctrlKey:o,metaKey:a,shiftKey:r,buttons:n})}isCoarseInputDevice(t){return t||window.matchMedia("(pointer: coarse)").matches}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}class li extends ci{constructor(t,i,s,n,e,o,a,r,h,c,l){super(t,i,s,n,e,o,a,r,h,c,l)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=a.normalize(i.up);const r=a.normalize(n);const h=o.scale(t,.5,.5);const c=a.magnitude(n);const l=h.x*c/s.width;const d=h.y*c/s.height;const u=a.cross(e,r);const f=a.cross(r,u);const p=a.add(a.scale(l,u),a.scale(d,f));return i.moveBy(p)}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,boundingBox:e})=>{if(this.panData==null){const e=i.toFrameCamera();const o=e.direction;const a=n.transformPointToRay(t,s.image,e);const r=h.fromNormalAndCoplanarPoint(o,i.lookAt);const l=c.intersectPlane(a,r);if(l==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}this.panData={hitPt:l,hitPlane:r,startingCamera:e}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const h=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(h,o);if(l!=null){const t=a.subtract(e,l);const s=a.add(r.lookAt,t);return i.update({lookAt:s,rotationPoint:s})}}return i}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:r,boundingBox:d})=>{if(this.orthographicZoomData==null||o.distance(t,this.orthographicZoomData.startingScreenPt)>2){const i=s.toFrameCamera();const o=i.direction;const a=n.transformPointToRay(t,e.image,i);const l=h.fromNormalAndCoplanarPoint(o,i.lookAt);const d=c.intersectPlane(a,l);if(d==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const u=r!=null?this.getWorldPoint(t,r,d):d;const f=h.fromNormalAndCoplanarPoint(o,u);this.orthographicZoomData={hitPt:u,hitPlane:f,startingScreenPt:t}}if(this.orthographicZoomData!=null){const{hitPt:t,hitPlane:e}=this.orthographicZoomData;const o=4*(i/n.height);const r=a.magnitude(l.diagonal(d))*1e-5;const c=Math.max(r,s.fovHeight*(1-o));const u=h.projectPoint(e,s.lookAt);const f=(s.fovHeight-c)/s.fovHeight;const p=a.scale(f,a.subtract(t,u));const m=a.add(s.lookAt,p);return s.update({lookAt:m,rotationPoint:m,fovHeight:c})}return s}))}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s,boundingBox:n})=>{var e;const o=a.normalize(i.up);const r=a.normalize(a.subtract(i.lookAt,i.position));const h=a.cross(o,r);const c=a.cross(r,h);const d=a.normalize({x:t.x*h.x+t.y*c.x,y:t.x*h.y+t.y*c.y,z:t.x*h.z+t.y*c.z});const u=a.cross(d,r);const f=9.5*t.x/s.width;const p=9.5*t.y/s.height;const m=Math.abs(f)+Math.abs(p);const w=i.rotationPoint!=null&&((e=i.rotationPoint)===null||e===void 0?void 0:e.x)!=null?i.rotationPoint:i.lookAt;const v=i.rotateAroundAxisAtPoint(m,w,u);const g=tt(v.lookAt,v.viewVector,l.center(n));return v.update({lookAt:g})}))}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}const di=.2;class ui extends ci{constructor(t,i,s,n,e,o,a,r,h,c,l){super(t,i,s,n,e,o,a,r,h,c,l)}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{var n;const e=i.viewVector;const r=a.normalize(i.up);const h=a.normalize(e);const c=o.scale(t,.25,.25);const l=a.magnitude(e)*Math.tan((n=i.fovY)!==null&&n!==void 0?n:45);const d=c.x*l/s.width;const u=c.y/s.width*l;const f=a.cross(r,h);const p=a.cross(h,f);const m=a.add(a.scale(d,f),a.scale(u,p));return i.moveBy(m)}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:o,boundingBox:r})=>{const l=e.scene.camera;const d=l.direction;const u=s.toFrameCamera();const f=n.transformPointToRay(t,e.image,u);if(this.zoomData==null){const i=h.fromNormalAndCoplanarPoint(d,l.lookAt);const n=c.intersectPlane(f,i);if(n==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const e=o!=null?this.getWorldPoint(t,o,n):n;const a=h.fromNormalAndCoplanarPoint(d,e);this.zoomData={hitPt:e,hitPlane:a}}if(this.zoomData!=null){const{hitPlane:t}=this.zoomData;const{position:e,distance:o,isPastHitPlane:l,keepCurrent:d}=this.computeZoomDistances(i,s,n,r,f,this.zoomData);if(l&&!d){const t=c.create({origin:e,direction:a.normalize(s.viewVector)});return s.update({position:e,lookAt:c.at(t,o)})}else if(!d){return s.update({position:e,lookAt:h.projectPoint(t,e)})}}return s}))}walk(t){this.transformCamera((({camera:i,boundingBox:s})=>{const{position:n,up:e,lookAt:o}=i;const r=a.normalize(e);const h=a.normalize(i.viewVector);const c=Math.min(...a.toArray(l.lengths(s)));const d=a.scale(c,t);const u=a.cross(r,h);const f=a.cross(u,r);const p=a.scale(d.x,a.normalize(u));const m=a.scale(d.y,a.normalize(r));const w=a.scale(d.z,a.normalize(f));const v=a.negate(a.add(p,m,w));return i.update({...i,position:a.add(n,v),lookAt:a.add(o,v)})}))}computeZoomDistances(t,i,s,n,e,o){const r=this.getConfig();const{hitPt:h,hitPlane:l}=o;const d=r.useMinimumPerspectiveZoomDistance?this.computeZoomMinimumDistance(i,n):-1;const u=a.distance(i.position,h);const f=Math.max(d,u);const p=6*f*t/s.height;const m=c.at(e,p);const w=c.create({origin:m,direction:a.normalize(i.viewVector)});const v=c.intersectPlane(w,l);if(v==null&&r.useMinimumPerspectiveZoomDistance){const i=6*d*t/s.height;const n=c.at(e,i);return{position:n,distance:d,isPastHitPlane:true,keepCurrent:false}}else if(v==null){return{position:i.position,distance:f,isPastHitPlane:true,keepCurrent:true}}return{position:m,distance:f,isPastHitPlane:false,keepCurrent:false}}computeZoomMinimumDistance(t,i){const s=Math.abs(i.min.x)+Math.abs(i.max.x);const n=Math.abs(i.min.y)+Math.abs(i.max.y);const e=Math.abs(i.min.z)+Math.abs(i.max.z);const o=Math.max(s,n,e);const r=Math.abs(a.dot(a.normalize(t.viewVector),a.right()));const h=Math.abs(a.dot(a.normalize(t.viewVector),a.up()));const c=Math.abs(a.dot(a.normalize(t.viewVector),a.back()));const l=s*r;const d=n*h;const u=e*c;const f=o/s;const p=o/n;const m=o/e;return(l+d+u)/(f+p+m)*di}}class fi{constructor(t,i,s,n){this.stream=t;this.configProvider=i;this.imageScaleProvider=s;this.sceneProvider=n}predicate(t){return t.altKey&&t.shiftKey}async fn(t){var i,s;const n=this.imageScaleProvider();const e=await this.stream.hitItems({point:o.scale(t.position,(n===null||n===void 0?void 0:n.x)||1,(n===null||n===void 0?void 0:n.y)||1)},true);if(((i=e.hitItems)===null||i===void 0?void 0:i.hits)!=null&&e.hitItems.hits.length>0&&e.hitItems.hits[0].hitPoint!=null){const i=await this.sceneProvider();const n=(await this.sceneProvider()).camera();const o=e.hitItems.hits[0];if(o.hitPoint!=null&&o.hitPoint.x!=null&&o.hitPoint.y!=null&&o.hitPoint.z!=null){const t=a.create(o.hitPoint.x,o.hitPoint.y,o.hitPoint.z);const s=await this.getLookAtPoint(i,t,n.viewVector);await this.stream.flyTo({camera:it(n.update({lookAt:s,rotationPoint:s}).toFrameCamera()),animation:{duration:p(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit position found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}, hit-id={${(s=o.itemId)===null||s===void 0?void 0:s.hex}}]`)}}else{console.debug(`No hit results found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}getLookAtPoint(t,i,s){if(t.isOrthographic()){return tt(i,s,l.center(t.boundingBox()))}else{return i}}}class pi{setPosition(t){this.currentPosition=t}getPosition(){return this.currentPosition}getType(){return this.type}beginDrag(t,i,s,n){}drag(t,i){}endDrag(t,i){if(this.currentPosition!=null){i.endInteraction();this.currentPosition=undefined}}async zoom(t,i){}}class mi extends pi{constructor(){super(...arguments);this.type="rotate"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCamera(n);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class wi extends pi{constructor(){super(...arguments);this.type="rotate-point"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.startingPosition=i;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.startingPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCameraAtPoint(n,this.startingPosition);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class vi extends pi{constructor(t){super();this.interactionConfigProvider=t;this.type="zoom";this.isTransforming=false}async beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.clientX,t.clientY);const i=n.getBoundingClientRect();const e=Mt(t,i);this.startPt=e;await s.beginInteraction()}}async drag(t,i){if(this.currentPosition!=null){const s=o.create(t.clientX,t.clientY);const n=o.subtract(s,this.currentPosition);if(this.startPt!=null){await i.zoomCameraToPoint(this.startPt,n.y);this.currentPosition=s}}}endDrag(t,i){super.endDrag(t,i);this.stopInteractionTimer();this.isTransforming=false;this.startPt=undefined}async zoom(t,i,s){await this.runWheelZoomInteraction(i,(()=>i.zoomCamera(this.getDirectionalDelta(t))),s)}async zoomToPoint(t,i,s,n){await this.runWheelZoomInteraction(s,(()=>s.zoomCameraToPoint(t,this.getDirectionalDelta(i))),n)}async beginInteraction(t){this.isTransforming=true;await t.beginInteraction()}async endInteraction(t){this.isTransforming=false;await t.endInteraction()}resetInteractionTimer(t,i){this.stopInteractionTimer();this.startInteractionTimer(t,i)}getDirectionalDelta(t){return this.interactionConfigProvider().reverseMouseWheelDirection?-t:t}getInteractionDelay(){return this.interactionConfigProvider().mouseWheelInteractionEndDebounce}startInteractionTimer(t,i=0){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.endInteraction(t)}),i+this.getInteractionDelay())}stopInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}async runWheelZoomInteraction(t,i,s){if(!this.isTransforming){await this.beginInteraction(t)}this.resetInteractionTimer(t,s);i()}}class gi extends pi{constructor(){super(...arguments);this.type="pan"}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.canvasRect!=null){const s=Mt(t,this.canvasRect);i.panCameraToScreenPoint(s);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class yi extends pi{constructor(){super(...arguments);this.type="twist"}beginDrag(t,i,s,n){this.currentPosition=o.create(t.offsetX,t.offsetY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}drag(t,i){const s=Mt(t,this.canvasRect);this.currentPosition=s;i.twistCamera(s)}endDrag(t,i){super.endDrag(t,i)}}class bi extends pi{constructor(){super(...arguments);this.type="pivot"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.pivotCamera(-.25*n.y,.25*n.x);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Ci extends jt{constructor(t,i=new mi,s=new wi,n=new vi((()=>t().interactions)),e=new gi,o=new yi,a=new bi){super("mousedown","mouseup","mousemove",i,s,n,e,o,a,t)}}function Pi(t){window.requestAnimationFrame(t)}class Ii{constructor(){this.previousFirstPoints=[];this.previousSecondPoints=[]}initialize(t,i){this.element=t;this.interactionApi=i}dispose(){this.element=undefined}beginTwoPointTouch(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i]}handleTwoPointTouchMove(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i];Pi((()=>{var t,i,s,n;if(this.previousFirstPoints.length>1&&this.previousSecondPoints.length>1&&this.previousFirstPoints.length===this.previousSecondPoints.length){const e=this.previousFirstPoints;const a=this.previousSecondPoints;this.previousFirstPoints=this.previousFirstPoints.slice(-1);this.previousSecondPoints=this.previousSecondPoints.slice(-1);const r=e.reduce(((t,i,s)=>{if(s<e.length-1){const n=e[s+1];const o=a[s];const r=a[s+1];return{deltas:[...t.deltas,this.computeDelta(i,o,n,r)],zooms:[...t.zooms,this.computeZoom(i,o,n,r)],angles:[...t.angles,this.computeAngle(i,o,n,r)]}}return t}),{deltas:[],zooms:[],angles:[]});const h=r.deltas.reduce(((t,i)=>o.add(t,i)),o.create());const c=r.zooms.reduce(((t,i)=>t+i),0);const l=r.angles.reduce(((t,i)=>t+i),0);const d=o.create((e[e.length-1].x+a[a.length-1].x)/2,(e[e.length-1].y+a[a.length-1].y)/2);(t=this.interactionApi)===null||t===void 0?void 0:t.beginInteraction();(i=this.interactionApi)===null||i===void 0?void 0:i.zoomCameraToPoint(d,c);(s=this.interactionApi)===null||s===void 0?void 0:s.panCameraByDelta(h);(n=this.interactionApi)===null||n===void 0?void 0:n.twistCamera(l)}}))}endTwoPointTouch(){this.previousFirstPoints=[];this.previousSecondPoints=[]}computeDelta(t,i,s,n){return o.add(o.subtract(s,t),o.subtract(n,i))}computeZoom(t,i,s,n){const e=o.distance(s,n)-o.distance(t,i);return e*.5}computeAngle(t,i,s,n){const e=d.create(o.subtract(t,i),o.subtract(s,n));return r.toDegrees(Math.atan2(d.determinant(e),d.dot(e)))}}class Si extends Ii{constructor(){super();this.touchPoints={};this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){const i=o.create(t.screenX,t.screenY);this.touchPoints={...this.touchPoints,[t.pointerId]:i};const s=Object.keys(this.touchPoints);if(s.length===1){window.addEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointerup",this.handlePointerUp)}else if(s.length===2){this.beginTwoPointTouch(this.touchPoints[0],this.touchPoints[1])}}handlePointerMove(t){if(this.touchPoints[t.pointerId]!=null){this.touchPoints[t.pointerId]=o.create(t.screenX,t.screenY)}const i=Object.keys(this.touchPoints);if(i.length===2){const t=this.touchPoints[i[0]];const s=this.touchPoints[i[1]];this.handleTwoPointTouchMove(t,s)}}handlePointerUp(t){var i;delete this.touchPoints[t.pointerId];const s=Object.keys(this.touchPoints);if(s.length===1){(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction()}if(s.length===0){window.removeEventListener("pointermove",this.handlePointerMove);window.removeEventListener("pointerup",this.handlePointerUp)}this.endTwoPointTouch()}}class ki extends zt{constructor(t,i=new mi,s=new wi,n=new vi((()=>t().interactions)),e=new gi,o=new yi,a=new bi){super("pointerdown","pointerup","pointermove",i,s,n,e,o,a,t);this.touchPoints=new Set;this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}addEventListenersToElement(t){t.addEventListener(this.downEvent,this.handleDownEvent);t.addEventListener("wheel",this.handleMouseWheel,{passive:false});return{dispose:()=>{t.removeEventListener(this.downEvent,this.handleDownEvent);t.removeEventListener("wheel",this.handleMouseWheel)}}}handlePointerDown(t){this.downPosition=o.create(t.screenX,t.screenY);this.touchPoints.add(t.pointerId);if(this.touchPoints.size===1){window.addEventListener("pointerup",this.handlePointerUp)}if(this.touchPoints.size===2){this.disableIndividualInteractions=true}}handlePointerUp(t){this.touchPoints.delete(t.pointerId);if(this.touchPoints.size<2){this.disableIndividualInteractions=false}if(this.touchPoints.size===0){window.removeEventListener("pointerup",this.handlePointerUp)}}}class Ti{constructor(t,i,s,n){this.downEvent=t;this.upEvent=i;this.moveEvent=s;this.getConfig=n;this.handleDown=this.handleDown.bind(this);this.handleUp=this.handleUp.bind(this);this.handleMove=this.handleMove.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerEnd=this.handlePointerEnd.bind(this);this.clearPositions=this.clearPositions.bind(this);this.restartDoubleTapTimer=this.restartDoubleTapTimer.bind(this);this.clearDoubleTapTimer=this.clearDoubleTapTimer.bind(this);this.restartLongPressTimer=this.restartLongPressTimer.bind(this);this.clearLongPressTimer=this.clearLongPressTimer.bind(this);this.setPointerPositions=this.setPointerPositions.bind(this);this.emit=this.emit.bind(this)}dispose(){var t,i;(t=this.element)===null||t===void 0?void 0:t.removeEventListener(this.downEvent,this.handleDown);(i=this.element)===null||i===void 0?void 0:i.removeEventListener("touchstart",this.handleTouchStart);this.element=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer()}initialize(t,i){this.element=t;this.interactionApi=i;t.addEventListener(this.downEvent,this.handleDown);t.addEventListener("touchstart",this.handleTouchStart,{passive:true})}handleTouchStart(t){if(t.touches.length===1){this.setPointerPositions(o.create(t.touches[0].clientX,t.touches[0].clientY));this.restartLongPressTimer();window.addEventListener("touchend",this.handleTouchEnd);window.addEventListener("touchmove",this.handleTouchMove)}}handleTouchMove(t){if(t.touches.length>0){this.handlePointerMove(o.create(t.touches[0].clientX,t.touches[0].clientY),true)}}handleTouchEnd(t){if(this.pointerDownPosition!=null){window.removeEventListener("touchend",this.handleTouchEnd);window.removeEventListener("touchmove",this.handleTouchMove)}this.handlePointerEnd(this.pointerDownPosition)}handleDown(t){this.setPointerPositions(o.create(t.clientX,t.clientY));this.buttons=t.buttons;const i={altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey};this.restartLongPressTimer(i);window.addEventListener(this.upEvent,this.handleUp);window.addEventListener(this.moveEvent,this.handleMove)}handleMove(t){this.handlePointerMove(o.create(t.clientX,t.clientY),this.isTouch(t))}handleUp(t){if(this.pointerDownPosition!=null){window.removeEventListener(this.upEvent,this.handleUp);window.removeEventListener(this.moveEvent,this.handleMove)}this.handlePointerEnd(o.create(t.clientX,t.clientY),{altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey},this.buttons,this.isTouch(t));this.buttons=undefined}handlePointerMove(t,i){var s;const n=((s=this.interactionApi)===null||s===void 0?void 0:s.pixelThreshold(i))||2;if(this.pointerDownPosition!=null&&o.distance(t,this.pointerDownPosition)>=n&&this.interactionTimer==null){this.clearPositions()}}handlePointerEnd(t,i={},s=0,n=false){var e,o;if(t!=null){if(this.longPressTimer!=null){this.emit((e=this.interactionApi)===null||e===void 0?void 0:e.tap)(t,i,s)}if(this.doubleTapTimer!=null&&this.secondPointerDownPosition!=null){this.emit((o=this.interactionApi)===null||o===void 0?void 0:o.doubleTap)(t,i,s,this.secondPointerDownPosition);this.clearDoubleTapTimer()}}this.pointerDownPosition=undefined;this.clearLongPressTimer()}emit(t){return(i,s={},n=0,e,a=false)=>{var r;const h=e||this.pointerDownPosition;const c=((r=this.interactionApi)===null||r===void 0?void 0:r.pixelThreshold(a))||1;let l;if(this.interactionTimer!=null){l=this.getCanvasPosition(h||i)}else if(h!=null&&o.distance(h,i)<=c){l=this.getCanvasPosition(i)}if(l!=null&&t!=null){t(l,s,n)}}}getCanvasPosition(t){var i;const s=(i=this.element)===null||i===void 0?void 0:i.getBoundingClientRect();const n=s!=null?o.create(s.left,s.top):undefined;return n!=null?o.subtract(o.create(t.x,t.y),n):undefined}clearPositions(){this.pointerDownPosition=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer();this.clearInteractionTimer()}clearDoubleTapTimer(){if(this.doubleTapTimer!=null){window.clearTimeout(this.doubleTapTimer)}this.doubleTapTimer=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined}restartDoubleTapTimer(){this.clearDoubleTapTimer();this.doubleTapTimer=window.setTimeout((()=>this.clearDoubleTapTimer()),this.getConfig().events.doubleTapThreshold)}clearLongPressTimer(){if(this.longPressTimer!=null){window.clearTimeout(this.longPressTimer)}this.longPressTimer=undefined}restartLongPressTimer(t={}){this.clearLongPressTimer();this.longPressTimer=window.setTimeout((()=>{var i;if(this.pointerDownPosition){this.emit((i=this.interactionApi)===null||i===void 0?void 0:i.longPress)(this.pointerDownPosition,t,this.buttons)}this.clearLongPressTimer()}),this.getConfig().events.longPressThreshold)}restartInteractionTimer(){this.clearInteractionTimer();this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined}),this.getConfig().interactions.interactionDelay)}clearInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}setPointerPositions(t){this.pointerDownPosition=t;this.restartInteractionTimer();if(this.firstPointerDownPosition==null){this.restartDoubleTapTimer();this.firstPointerDownPosition=t}else{this.secondPointerDownPosition=t}}isTouch(t){return window.PointerEvent!=null&&t instanceof PointerEvent?t.pointerType==="touch":false}}class Ai extends Ii{constructor(){super();this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("touchstart",this.handleTouchStart);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("touchstart",this.handleTouchStart)}handleTouchStart(t){if(t.touches.length>=1){t.preventDefault();const i=t.touches[0];this.currentPosition1=o.create(i.screenX,i.screenY);if(t.touches[1]!=null){this.beginTwoPointTouch(this.currentPosition1,o.create(t.touches[1].screenX,t.touches[1].screenY))}window.addEventListener("touchmove",this.handleTouchMove,{passive:false});window.addEventListener("touchend",this.handleTouchEnd)}}handleTouchMove(t){t.preventDefault();if(t.touches.length===1){this.handleOnePointTouchMove(t.touches[0])}else if(t.touches.length===2){const i=o.create(t.touches[0].clientX,t.touches[0].clientY);const s=o.create(t.touches[1].clientX,t.touches[1].clientY);this.handleTwoPointTouchMove(i,s)}}handleTouchEnd(t){var i;t.preventDefault();(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction();this.isInteracting=false;window.removeEventListener("touchmove",this.handleTouchMove);window.removeEventListener("touchend",this.handleTouchEnd);this.endTwoPointTouch()}handleOnePointTouchMove(t){var i,s,n;const e=o.create(t.screenX,t.screenY);if(this.currentPosition1!=null){const t=o.subtract(e,this.currentPosition1);const a=((i=this.interactionApi)===null||i===void 0?void 0:i.pixelThreshold(true))||2;if(o.distance(e,this.currentPosition1)>=a||this.isInteracting){(s=this.interactionApi)===null||s===void 0?void 0:s.beginInteraction();(n=this.interactionApi)===null||n===void 0?void 0:n.rotateCamera(t);this.isInteracting=true}}this.currentPosition1=e}}const Di={clearMarks:()=>undefined,clearMeasures:()=>undefined,getEntriesByName:()=>[],mark:()=>undefined,measure:()=>undefined};function xi(){var t;if(typeof window!=="undefined"){return window.performance}return(t=globalThis.performance)!==null&&t!==void 0?t:Di}class Mi{constructor(t,i=xi()){this.name=t;this.perf=i;this.measures=new Set;this.nextId=0}clearMeasurements(){this.perf.clearMeasures(this.name)}measure(t){if(t instanceof Promise){const i=this.begin();return t.finally((()=>this.end(i)))}else if(typeof t==="function"){const i=this.begin();const s=t();this.end(i);return s}else{throw new Error("Input must be a function or Promise")}}takeMeasurements(){const t=this.perf.getEntriesByName(this.name);this.clearMeasurements();return t}takeLastMeasurement(){const t=this.takeMeasurements();return t[t.length-1]}begin(){const t=`${this.name}-${this.nextId++}`;this.measures.add(t);this.perf.mark(t);return t}end(t){this.perf.measure(this.name,t);this.perf.clearMarks(t);this.measures.delete(t)}}const Ei=new Mi("paint_time");function Ri(t){const i=new Uint8Array(t.byteLength);i.set(t);return i.buffer}function Bi(t){return new Promise(((i,s)=>{const n=new Blob([Ri(t)]);const e=URL.createObjectURL(n);const o=new Image;o.addEventListener("load",(()=>{i({image:o,dispose:()=>undefined});URL.revokeObjectURL(e)}));o.addEventListener("error",(()=>{s(new M("Failed to load image data"));URL.revokeObjectURL(e)}));o.src=e}))}async function ji(t){const i=new Blob([Ri(t)]);const s=await window.createImageBitmap(i);return{image:s,dispose:()=>s.close()}}function zi(t){if(window.createImageBitmap!=null){return ji(t)}else{return Bi(t)}}const Li=1e3;function Vi(t,i){const s=i.viewport.calculateDrawRect(i.frame.image);i.canvas.clearRect(0,0,i.canvasDimensions.width,i.canvasDimensions.height);i.canvas.drawImage(t.image,s.x,s.y,s.width,s.height)}function $i(t,i){const s=t.takeMeasurements();if(s.length>0){i(s)}}function Oi(t,i,s,n,e=Li){let o;let a=0;let r;let h=[];function c(){a++;if(o==null){o=setInterval((()=>{$i(t,n);if(a===0){d()}}),e)}}function l(){a--}function d(){if(o!=null){clearInterval(o);o=undefined}}if(s){setInterval((()=>{if(r!=null){if(h.length===5){h=[...h.slice(1),r]}else{h.push(r)}const t=h.reduce(((t,i)=>t+i),0)/h.length;console.debug(`Paint rate: ${r}fps`);console.debug(`Paint rate (avg): ${t}`);r=undefined}}),1e3)}return s=>{c();return t.measure((async()=>{const t=await i(s);r=r==null?1:r+1;return t})).finally((()=>l()))}}function Hi(){let t=[];function i(i){if(i!=null){const s=i.copy({correlationIds:[...i.correlationIds,...t.filter((t=>!i.correlationIds.includes(t)))]});t=[];return s}return i}function s(){let t=-1;return async i=>{if(i.frame.sequenceNumber>t){const s=await zi(i.frame.image.imageBytes);t=i.frame.sequenceNumber;return s}}}function n(){let t=-1;return async(i,s)=>{var n;if(s!=null&&i.frame.sequenceNumber>t){t=i.frame.sequenceNumber;(n=i.beforeDraw)===null||n===void 0?void 0:n.call(i);Vi(s,i);s.dispose();return i.frame}s===null||s===void 0?void 0:s.dispose()}}const e=s();const o=n();return async s=>{var n,a;const r=(a=(n=s.predicate)===null||n===void 0?void 0:n.call(s))!==null&&a!==void 0?a:true;t=[...t,...s.frame.correlationIds];if(r){return e(s).then((t=>o(s,t).then(i)))}}}function Ni(t){return i=>{var s;const n=(s=i.request.requestId)===null||s===void 0?void 0:s.value;if(n!=null){t(n)(i)}}}function Ki(t){return i=>{const{drawFrame:s}=i.request;if(s!=null){t(s)(i)}}}const Fi=1*60;function Wi(t){let i=false;return s=>{const n=t();if(n!=null){const t=n.remoteTime(new Date(Date.now()));const e=p(s,t);const o=m(e).getTime();if(o>=0){return e}else{if(!i){console.warn(`Possible erroneous send to receive timing. Muting for ${Fi}s. [sent-at=${s.toISOString()}, received-at=${t.toISOString()}, remote-time=${n.knownRemoteTime.toISOString()}]`);i=true;setTimeout((()=>i=false),Fi*1e3)}return undefined}}}}function Ui(t,i){const s=Wi(i);return Ni((i=>Ki((n=>n=>{const e=m(n.sentAtTime);if(e!=null){t.replyResult(i,{drawFrame:{sendToReceiveDuration:s(e)}})}}))))}var _i=N();const qi=b.defineMapper(b.read(b.requiredProp("d"),b.requiredProp("ns"),b.mapRequiredProp("ka",st),b.mapRequiredProp("kd",st),b.mapRequiredProp("ks",st),b.mapRequiredProp("ke",st)),(([t,i,s,n,e,o])=>({opacity:t,glossiness:i,ambient:s,diffuse:n,specular:e,emissive:o})));const Ji=b.defineMapper(b.read(b.mapRequiredProp("defaultMaterial",(()=>Pt)),b.mapRequiredProp("colorMaterial",qi)),(([t,i])=>({defaultMaterial:t,colorMaterial:i})));const Xi=b.defineMapper(b.read(b.requiredProp("name"),b.requiredProp("category")),(([t,i])=>({name:t,category:i})));const Zi=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"string",value:t})));const Gi=b.mapProp("string",b.ifDefined(Zi));const Yi=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"long",value:t})));const Qi=b.mapProp("pb_long",b.ifDefined(Yi));const ts=b.defineMapper(b.read(b.getProp("value")),(([t])=>({type:"double",value:t})));const is=b.mapProp("pb_double",b.ifDefined(ts));const ss=b.defineMapper(b.read(b.requiredProp("value")),(([t])=>({type:"timestamp",value:t})));const ns=b.mapProp("date",b.ifDefined(ss));const es=b.compose(b.pickFirst(Gi,Qi,is,ns),b.required("value"));const os=b.defineMapper(b.read(b.requiredProp("id"),b.mapProp("key",b.ifDefined(Xi)),b.mapProp("value",b.ifDefined(es))),(([t,i,s])=>({id:t,key:i,value:s})));const as=b.defineMapper(b.read(b.mapProp("cursor",nt),b.mapRequiredProp("entriesList",b.mapArray(os))),(([t,i])=>({paging:{next:t},entries:i})));const rs=b.ifInvalidThrow(as);const hs=b.defineMapper(b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",et),b.mapProp("materialOverride",b.ifDefined(Ji)),b.mapProp("transform",b.ifDefined(ot)),b.mapProp("isVisible",b.ifDefined(at)),b.mapProp("isSelected",b.ifDefined(at)),b.mapProp("isPhantom",b.ifDefined(at)),b.mapProp("endItem",b.ifDefined(at))),(([t,i,s,n,e,o,a,r])=>({id:t,createdAt:i,materialOverride:s,transform:n,isVisible:e,isSelected:o,isPhantom:a,endItem:r})));const cs=b.defineMapper(b.read(b.mapRequiredProp("id",J),b.mapRequiredProp("createdAt",et),b.mapRequiredProp("name",Z),b.mapProp("parentId",b.ifDefined(J)),b.mapProp("suppliedId",b.ifDefined(Z)),b.mapProp("boundingBox",b.ifDefined(rt)),b.mapProp("worldTransform",b.ifDefined(ot)),b.mapProp("override",b.ifDefined(hs))),(([t,i,s,n,e,o,a,r])=>({id:t,createdAt:i,name:s,parentId:n!==null&&n!==void 0?n:undefined,suppliedId:e,boundingBox:o,worldTransform:a,override:r})));const ls=b.ifInvalidThrow(b.defineMapper(b.read(b.mapProp("item",b.ifDefined(cs))),(([t])=>t!==null&&t!==void 0?t:undefined)));class ds{constructor(t,i,s){this.client=t;this.jwtProvider=i;this.deviceIdProvider=s}async getSceneViewItem(t,i,s){const n=await K((async n=>{const e=this.deviceIdProvider();const o=await F(this.jwtProvider,e);const a=new H.GetSceneViewItemRequest;a.setSceneItemId(Ct(t));a.setViewId(Ct(i));const r=new _i.FieldMask;if(s.includeBoundingBox){r.addPaths("bounding_box")}if(s.includeWorldTransform){r.addPaths("world_transform")}if(s.includeOverride){r.addPaths("override")}a.setAdditionalFields(r);this.client.getSceneViewItem(a,o,n)}));return ls(n.toObject())}async listSceneItemMetadata(t,i){const s=await K((async s=>{const n=this.deviceIdProvider();const e=await F(this.jwtProvider,n);const o=new H.ListSceneItemMetadataRequest;o.setItemId(Ct(t));const a=new E.Pager;if(i.size!=null){a.setLimit(i.size)}if(i.cursor!=null){a.setCursor(i.cursor)}o.setPager(a);this.client.listSceneItemMetadata(o,e,s)}));return rs(s.toObject())}}var us;(function(t){t["DEVICE_ID"]="vertexvis:device-id"})(us||(us={}));function fs(){if(typeof window==="undefined"){throw new Error("Local storage is not available.")}return window.localStorage}function ps(t,i,s=fs()){const n=s.getItem(t);if(n!=null){const e={...JSON.parse(n),...i};s.setItem(t,JSON.stringify(e))}else{s.setItem(t,JSON.stringify(i))}}function ms(t,i,s=fs()){const n=s.getItem(t);if(n!=null){return i(JSON.parse(n))}}function ws(t,i,s,n){return P.retry((()=>{if(!t.aborted){return i()}return Promise.resolve(s)}),n)}class vs extends w{constructor(t,i={}){var s,n,e,o,a;super(t,{loggingEnabled:i.loggingEnabled});this.state={type:"disconnected"};this.stateChanged=new C;this.dimensions=u.create(0,0);this.streamAttributes={};this.enableTemporalRefinement=(s=i.enableTemporalRefinement)!==null&&s!==void 0?s:true;this.frameBgColor=I.create(255,255,255);this.config=Dt("platprod");this.options={tokenRefreshOffsetInSeconds:(n=i.tokenRefreshOffsetInSeconds)!==null&&n!==void 0?n:30,offlineThresholdInSeconds:(e=i.offlineThresholdInSeconds)!==null&&e!==void 0?e:30,loadTimeoutInSeconds:(o=i.loadTimeoutInSeconds)!==null&&o!==void 0?o:15,enableTemporalRefinement:(a=i.enableTemporalRefinement)!==null&&a!==void 0?a:true}}isPaused(){return this.pausedState!=null}getState(){return this.state}disconnect(){if(this.state.type!=="disconnected"&&this.state.type!=="connection-failed"){console.debug("Disconnecting websocket");this.state.connection.dispose();this.updateState({type:"disconnected"})}}async load(t,i,s,n=Dt("platprod"),e){this.clientId=i;this.deviceId=s;this.config=n;if(this.state.type==="disconnected"){await this.loadIfDisconnected(t,e)}else if(this.state.type==="connection-failed"){await this.loadIfDisconnected(t,e)}else{await this.loadIfConnectingOrConnected(t,this.state,e)}return this.state}update(t){this.frameBgColor=t.frameBgColor?t.frameBgColor:this.frameBgColor;if(t.dimensions!=null&&!S(t.dimensions,this.dimensions)){this.dimensions=t.dimensions;this.ifState("connected",(()=>this.updateDimensions({dimensions:this.getDimensions(),resolution:Cs(this.getResolution())})))}const i=!S(this.streamAttributes,t.streamAttributes);if(t.streamAttributes!=null&&i){this.streamAttributes=t.streamAttributes;this.ifState("connected",(()=>this.updateStream({streamAttributes:gs(this.streamAttributes)})))}if(t.enableTemporalRefinement!=null&&t.enableTemporalRefinement!==this.enableTemporalRefinement){this.enableTemporalRefinement=t.enableTemporalRefinement;if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}}pause(){if(this.state.type==="connected"){this.pausedState=this.state;console.debug(`Stream paused [stream-id=${this.pausedState.streamId}, scene-id=${this.pausedState.sceneId}, scene-view-id=${this.pausedState.sceneViewId}]`);this.disconnect()}}async resume(){if(this.pausedState!=null){console.debug(`Stream resumed [stream-id=${this.pausedState.streamId}, scene-id=${this.pausedState.sceneId}, scene-view-id=${this.pausedState.sceneViewId}]`);await this.connectToExistingStream(this.pausedState);this.pausedState=undefined}}async loadIfConnectingOrConnected(t,i,s){var n;const{resource:e,subResource:o}=i.resource;const a=It(t);const r=!k.isEqual(e,a.resource);const h=!k.isEqual(o,a.subResource);const c=i.type==="connecting"||i.type==="reconnecting";const l=i.type==="connected";if(r||c&&h){this.disconnect();return this.loadIfDisconnected(t)}else if(l&&h&&((n=a.subResource)===null||n===void 0?void 0:n.type)==="scene-view-state"){const t=a.queries.find((t=>t.type==="supplied-id"));const n={...a.subResource.id!=null?{sceneViewStateId:{hex:a.subResource.id}}:{},...t!=null?{sceneViewStateSuppliedId:{value:t.id}}:{},...s!=null?{cameraType:bs(s)}:{}};await this.loadSceneViewState(n);this.updateState({...i,resource:a})}}async loadIfDisconnected(t,i){try{await this.connectWithNewStream(It(t),i)}catch(t){if(t instanceof R){this.updateState({type:"connection-failed",message:`Cannot load scene. ${t.message}`,error:t})}else if(t instanceof v){this.updateState({type:"connection-failed",message:`Cannot load scene. Stream request failed to start stream.`,error:t})}else{this.updateState({type:"connection-failed",message:`Cannot load scene for unknown reason. See console logs.`,error:t})}throw t}}connectWithNewStream(t,i){return this.openWebsocketStream(t,"connecting",(()=>this.requestNewStream(t,i)))}connectToExistingStream(t){return this.openWebsocketStream(t.resource,"reconnecting",(()=>this.requestReconnectStream(t)),{maxRetries:Number.POSITIVE_INFINITY})}async openWebsocketStream(t,i,s,{maxRetries:n=3}={}){var e;const o=Is(Ss(this.config,t.resource,this.clientId,this.deviceId));console.debug(`Initiating WS connection [uri=${o.url}]`);(e=this.abortController)===null||e===void 0?void 0:e.abort();const a=new AbortController;this.abortController=a;const r=Ps(this.config);this.updateState({type:i,resource:t,connection:{dispose:()=>{this.dispose();a.abort()}}});const h=await P.abort(a.signal,ws(a.signal,(()=>this.connect(o,r)),{dispose:()=>{}},{maxRetries:n,delaysInMs:vs.WS_RECONNECT_DELAYS})).catch((t=>{throw new B("Websocket connection failed.",t instanceof Error?t:undefined)}));if(!h.aborted){return this.requestNewOrExistingStream(t,h.result,s)}else{this.updateState({type:"disconnected"})}}async requestNewOrExistingStream(t,i,s){const n=this.requestClock();const e=await s();console.debug(`Stream connected [stream-id=${e.streamId}, scene-id=${e.sceneId}, scene-view-id=${e.sceneViewId}]`);const o=this.onRequest((t=>{const i=t.request.drawFrame;if(i!=null){const t=ut(e.worldOrientation)(i);if(this.state.type==="connected"){if(t.depthBufferBytes!=null||this.state.frame.temporalRefinementCorrelationId!==t.temporalRefinementCorrelationId){this.updateState({...this.state,frame:t,fallbackDepthBufferBytes:t.depthBufferBytes})}else{this.updateState({...this.state,frame:t.copy({depthBufferBytes:this.state.fallbackDepthBufferBytes})})}}}}));const a=this.reconnectWhenNeeded();const r=this.refreshTokenWhenExpired(e.token);const h=this.acknowledgeFrameRequests();const c=e.frame==null?await this.waitForFrame(e.worldOrientation,this.options.loadTimeoutInSeconds):e.frame;const l=await n;console.debug(`Synchronized clocks [local-time=${l.knownLocalTime.toISOString()}, remote-time=${l.knownRemoteTime.toISOString()}]`);this.updateState({type:"connected",connection:{dispose:()=>{a.dispose();o.dispose();r.dispose();h.dispose();i.dispose()}},resource:t,streamId:e.streamId,deviceId:e.deviceId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,worldOrientation:e.worldOrientation,token:e.token,frame:c,clock:l,fallbackDepthBufferBytes:undefined})}async requestNewStream(t,i){var s,n;const e=t.queries.find((t=>t.type==="supplied-id"));const o=ft(await this.startStream({streamKey:{value:t.resource.id},dimensions:this.getDimensions(),resolution:Cs(this.getResolution()),frameBackgroundColor:ys(this.frameBgColor),clientSupportsTemporalRefinement:this.enableTemporalRefinement,streamAttributes:gs(this.streamAttributes),sceneViewStateId:((s=t.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"&&t.subResource.id!=null?{hex:t.subResource.id}:undefined,sceneViewStateSuppliedId:((n=t.subResource)===null||n===void 0?void 0:n.type)==="scene-view-state"&&e!=null?{value:e.id}:undefined,cameraType:i!=null?bs(i):undefined}));return{resource:t,streamId:o.streamId,sceneId:o.sceneId,sceneViewId:o.sceneViewId,deviceId:o.sessionId,token:o.token,worldOrientation:o.worldOrientation,frame:undefined,fallbackDepthBufferBytes:undefined}}async requestReconnectStream(t){const i=pt(await this.reconnect({streamId:{hex:t.streamId},dimensions:this.getDimensions(),frameBackgroundColor:ys(this.frameBgColor),streamAttributes:gs(this.streamAttributes),clientSupportsTemporalRefinement:this.enableTemporalRefinement}));return{...t,token:i.token}}async requestClock(){const t=mt(await this.syncTime({requestTime:g()}));return new St(t)}reconnectWhenNeeded(){const t=this.onClose((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}));const i=this.onRequest((t=>{const i=t.request.gracefulReconnection!=null;if(i&&this.state.type==="connected"){console.debug("Received request for graceful reconnect. Closing connection and attempting reconnect.");this.closeAndReconnect(this.state)}}));const s=this.reconnectWhenOffline();return{dispose:()=>{t.dispose();i.dispose();s.dispose()}}}refreshTokenWhenExpired(t){let i;const s=t=>{const{tokenRefreshOffsetInSeconds:n}=this.options;const e=t.remainingTimeInMs(n);i=window.setTimeout((async()=>{const t=await this.refreshToken();const i=wt(t);s(i);if(this.state.type==="connected"){this.updateState({...this.state,token:i})}}),e)};s(t);return{dispose:()=>clearTimeout(i)}}reconnectWhenOffline(){let t;const i=()=>window.clearTimeout(t);const s=()=>{i();const s=this.options.offlineThresholdInSeconds;console.debug(`Detected that host is offline. Will attempt reconnect in ${s}s.`);t=window.setTimeout((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}),s*1e3)};const n=()=>{console.debug("Detected that host is online.");i()};const e=()=>s();window.addEventListener("offline",e);window.addEventListener("online",n);return{dispose:()=>{i();window.removeEventListener("offline",e);window.removeEventListener("online",n)}}}closeAndReconnect(t){t.connection.dispose();return this.connectToExistingStream(t)}async waitForFrame(t,i){let s;try{return await P.timeout(i*1e3,new Promise((i=>{s=this.onRequest((n=>{try{const s=n.request.drawFrame;if(s!=null){const n=ut(t)(s);i(n)}}finally{s===null||s===void 0?void 0:s.dispose()}}))})))}catch(t){throw new j(`Frame timed out after ${i}s`,t instanceof Error?t:undefined)}finally{s===null||s===void 0?void 0:s.dispose()}}acknowledgeFrameRequests(){return this.onRequest(Ui(this,(()=>this.state.type==="connected"?this.state.clock:undefined)))}updateState(t){if(this.state!==t){this.state=t;this.stateChanged.emit(this.state)}}getDimensions(){if(u.area(this.dimensions)===0){return u.create(1,1)}return this.dimensions}getResolution(){if(window.devicePixelRatio!=null){return 96*window.devicePixelRatio}else{return 96}}ifState(t,i){if(this.state.type===t){return i()}}onStateChanged(t){return this.stateChanged.on(t)}}vs.WS_RECONNECT_DELAYS=[0,1e3,1e3,5e3];const gs=b.ifInvalidThrow(ht);const ys=b.ifInvalidThrow(ct);const bs=b.ifInvalidThrow(lt);const Cs=b.ifInvalidThrow(dt);function Ps(t){return{EXPERIMENTAL_frameDelivery:{...t.EXPERIMENTAL_frameDelivery,rateLimitingEnabled:t.flags.throttleFrameDelivery},EXPERIMENTAL_adaptiveRendering:{...t.EXPERIMENTAL_adaptiveRendering,enabled:t.flags.adaptiveRendering},EXPERIMENTAL_qualityOfService:{...t.EXPERIMENTAL_qualityOfService}}}function Is(t){return{url:T.toString(t),protocols:["ws.vertexvis.com"]}}function Ss(t,i,s,n){if(s!=null){return T.appendPath(T.toString(T.parseAndAddParams("/ws",{clientId:s,deviceId:n})),T.parse(t.network.renderingHost))}else{return T.appendPath(`/stream-keys/${i.id}/session`,T.parse(t.network.renderingHost))}}class ks{constructor(t){this.callback=t;this.handleVisibilityChange=this.handleVisibilityChange.bind(this);this.emitVisibilityChange=this.emitVisibilityChange.bind(this);this.mutationObservers=[]}isVisible(t){if("checkVisibility"in t){return t.checkVisibility({visibilityProperty:true,opacityProperty:true})}return true}observe(t){this.targetElement=t;this.watchElementVisibility(t)}unobserve(){if(this.targetElement!=null){this.mutationObservers.forEach((t=>t.disconnect()));this.mutationObservers=[]}this.targetElement=undefined}disconnect(){this.mutationObservers.forEach((t=>t.disconnect()));this.mutationObservers=[]}watchElementVisibility(t){if(t!=null){const i=new MutationObserver(this.handleVisibilityChange);i.observe(t,{attributes:true,attributeFilter:["style","class","hidden"]});this.mutationObservers=[...this.mutationObservers,i];this.watchElementVisibility(t.parentElement)}}handleVisibilityChange(){if(this.targetElement!=null){this.emitVisibilityChange(this.targetElement)}}emitVisibilityChange(t){const i=t!=null?this.isVisible(t):true;console.debug(`Detected visibility change [visible={${i}}]`);this.callback(i)}}const Ts=15e3;function As(t){return t.getBoundingClientRect()}function Ds(t,i){const s=window.getComputedStyle(t);const n=s.getPropertyValue(i);return n!==""?n:undefined}const xs=()=>`button{border:none;background:transparent;cursor:pointer;margin:0;padding:0}.button{padding:0.5rem;border-radius:0.25rem}.button-secondary{color:var(--neutral-800);background-color:var(--neutral-300)}.button-secondary:hover{color:var(--neutral-900)}.button-secondary:hover:enabled{box-shadow:0 2px 2px rgb(0 0 0 / 20%)}.button-secondary:disabled{opacity:0.8}.button-secondary:hover:disabled{cursor:not-allowed}:host{--image-background:var(--image-background);--viewer-background:var(--viewer-background);display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}.enable-pointer-events{touch-action:none}.viewer-container{width:100%;height:100%;overflow:hidden}.error-message-wrapper{align-items:center;display:flex;flex-direction:column;gap:1rem;position:absolute;top:50%;width:100%;transform:translateY(-50%);text-align:center}.error-message{font-size:0.875rem}`;const Ms=class{constructor(s){t(this,s);this.tap=i(this,"tap");this.doubletap=i(this,"doubletap");this.longpress=i(this,"longpress");this.frameReceived=i(this,"frameReceived");this.frameDrawn=i(this,"frameDrawn");this.tokenExpired=i(this,"tokenExpired");this.connectionChange=i(this,"connectionChange");this.sceneReady=i(this,"sceneReady");this.sceneChanged=i(this,"sceneChanged");this.interactionStarted=i(this,"interactionStarted");this.interactionFinished=i(this,"interactionFinished");this.cameraTypeChanged=i(this,"cameraTypeChanged");this.annotationStateChanged=i(this,"annotationStateChanged");this.deviceIdChange=i(this,"deviceIdChange");this.dimensionschange=i(this,"dimensionschange");this.configEnv="platprod";this.cameraControls=true;this.cameraType="perspective";this.keyboardControls=true;this.rotateAroundTapPoint=true;this.phantom={opacity:.1};this.noDefaultLights=false;this.enableTemporalRefinement=true;this.experimentalRenderingOptions="";this.crossSectioning={endCapEnabled:true,endCapColor:undefined};this.resizeDebounce=100;this.viewport=Bt.fromDimensions(u.create(0,0));this.experimentalSkipVisibilityCheck=false;this.stateMap={cursorManager:new xt,streamState:{type:"disconnected"}};this.isVisible=false;this.frameRenderVersion=0;this.interactionHandlers=[];this.defaultInteractionHandlerDisposables=[];this.tapKeyInteractions=[];this.defaultTapKeyInteractions=[];this.internalFrameDrawnDispatcher=new C;this.handleUpdateStreamAttributesWithTimer=()=>{const t=50;if(this.streamAttributesUpdateTimer==null){this.streamAttributesUpdateTimer=setTimeout((()=>{this.streamAttributesUpdateTimer=undefined;this.updateStreamAttributes()}),t)}};this.handleRetry=()=>{this.reload().catch((t=>{console.error("Error reloading scene",t)}))};this.handleElementResize=this.handleElementResize.bind(this);this.handleVisibilityChange=this.handleVisibilityChange.bind(this)}connectedCallback(){var t,i,s;(t=this.stencilBuffer)!==null&&t!==void 0?t:this.stencilBuffer=new Ot(this.hostElement);this.visibilityObserver=new ks(this.handleVisibilityChange);this.isVisible=this.visibilityObserver.isVisible(this.hostElement);if(!this.isVisible){(i=this.visibilityObserver)===null||i===void 0?void 0:i.observe(this.hostElement)}(s=this.stream)===null||s===void 0?void 0:s.resume()}componentWillLoad(){var t;this.updateResolvedConfig();this.calculateComponentDimensions();this.resizeObserver=new ResizeObserver(this.handleElementResize);this.registerSlotChangeListeners();const i=this.getResolvedConfig();const s=new f.SceneViewAPIClient(i.network.sceneViewHost);this.annotations=new Jt(s,(()=>this.token),(()=>this.deviceId));this.annotations.onStateChange.on((t=>{this.annotationStateChanged.emit(t);const i=Object.keys(t.annotations).length;this.handleAnnotationSetsChange(i)}));this.stream=(t=this.stream)!==null&&t!==void 0?t:new vs(new y,{loggingEnabled:i.flags.logWsMessages,enableTemporalRefinement:this.enableTemporalRefinement});this.addStreamListeners();this.modelViews=new kt(s,this.stream,(()=>this.token),(()=>this.deviceId));this.pmi=new Tt(s,(()=>this.token),(()=>this.deviceId));this.sceneItems=new ds(s,(()=>this.token),(()=>this.deviceId));this.canvases=new ri(s,(()=>this.token),(()=>this.deviceId));this.updateStreamAttributes();this.stateMap.cursorManager.onChanged.on((()=>this.handleCursorChanged()))}async componentDidLoad(){var t,i,s;this.interactionApi=this.createInteractionApi();this.isVisible=(i=(t=this.visibilityObserver)===null||t===void 0?void 0:t.isVisible(this.hostElement))!==null&&i!==void 0?i:true;if(this.canvasContainerElement!=null){(s=this.resizeObserver)===null||s===void 0?void 0:s.observe(this.canvasContainerElement)}this.loadOrResumeStream().catch((t=>{console.error("Error loading scene",t)}));await this.initializeDefaultInteractionHandlers();this.injectViewerApi()}disconnectedCallback(){var t,i,s;(t=this.visibilityObserver)===null||t===void 0?void 0:t.disconnect();(i=this.annotations)===null||i===void 0?void 0:i.disconnect();(s=this.stream)===null||s===void 0?void 0:s.pause()}render(){var t;return s(n,{key:"9f432c1405929448b4ded4c458d70c36781d4a7d"},s("div",{key:"1963c4b6d17b168e87a652da2190d10923ea4ce5",ref:t=>this.viewerContainerElement=t,class:"viewer-container",style:{cursor:Et((t=this.cursor)!==null&&t!==void 0?t:"")},onContextMenu:t=>t.preventDefault()},s("div",{key:"dc2a675091f94c47c87f24a43cf7e9cd603a8af2",ref:t=>this.canvasContainerElement=t,class:D("canvas-container",{"enable-pointer-events ":window.PointerEvent!=null})},s("canvas",{key:"604cdad20b6fc50c6a06e3e5ec4fdc8ee6b71d8f",ref:t=>{this.canvasElement=t;this.stateMap.interactionTarget=t},class:"canvas"}),this.errorMessage!=null?s("div",{class:"error-message-wrapper",role:"alert"},s("span",{class:"error-message"},this.errorMessage),s("slot",{name:"retry"},s("button",{class:"button button-secondary",type:"button",onClick:this.handleRetry},"Retry"))):null),s("slot",{key:"a09eb09541a5b3bfb8943a62e0d37f100a2fde25"})))}async dispatchFrameDrawn(t){this.frame=t;this.internalFrameDrawnDispatcher.emit(t);this.frameDrawn.emit(t)}async registerInteractionHandler(t){this.interactionHandlers.push(t);this.initializeInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerBasicInteractionHandler(t){this.interactionHandlers.push(t);this.initializeBasicInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerTapKeyInteraction(t){this.tapKeyInteractions=[...this.tapKeyInteractions,t]}async getInteractionTarget_DEPRECATED(){if(this.stateMap.interactionTarget!=null){return this.stateMap.interactionTarget}else throw new Error("Interaction target is undefined.")}async addCursor(t,i){return this.stateMap.cursorManager.add(t,i)}async getInteractionHandlers(){return this.interactionHandlers}async getKeyInteractions(){return this.tapKeyInteractions}async getBaseInteractionHandler(){return this.baseInteractionHandler}async getJwt(){return this.token}handleSrcChanged(t){if(t!=null){this.load(t,{cameraType:this.cameraType})}else{this.unload()}}handleCameraControlsChanged(){this.initializeDefaultCameraInteractionHandlers()}handleKeyboardControlsChanged(){this.initializeDefaultKeyboardInteractionHandlers()}handleRotateAboutTapPointChanged(){var t,i;this.updateStreamAttributes();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}else{(i=this.baseInteractionHandler)===null||i===void 0?void 0:i.setPrimaryInteractionType("rotate")}}handleCameraTypeChanged(t,i){if(t!==i){this.updateCameraType()}}handleStreamAttributesChanged(){this.handleUpdateStreamAttributesWithTimer()}handleEnableTemporalRefinementChanged(){this.updateEnableTemporalRefinement()}handleConfigChanged(){this.updateResolvedConfig()}handleConfigEnvChanged(){this.updateResolvedConfig()}async load(t,i){var s,n;const e=this.experimentalSkipVisibilityCheck||this.isVisible;if(!e){console.debug("Detected the viewer is hidden. Delaying load until visible.");return}if(this.stream!=null&&this.dimensions!=null){const{EXPERIMENTAL_annotationPollingIntervalInMs:e}=this.getResolvedConfig();this.calculateComponentDimensions();this.stream.update({streamAttributes:this.getStreamAttributes(),config:Dt(this.configEnv,this.config),dimensions:this.dimensions,frameBgColor:this.getBackgroundColor()});const o=await((s=this.stream)===null||s===void 0?void 0:s.load(t,this.clientId,this.getDeviceId(),this.getResolvedConfig(),i===null||i===void 0?void 0:i.cameraType));if(o.type==="connected"){this.sceneReady.emit();if(e!==undefined){(n=this.annotations)===null||n===void 0?void 0:n.connect(e)}}}else{throw new z("Cannot load scene. Viewer has not been initialized.")}}async unload(){var t;if(this.stream!=null){this.frameRenderVersion+=1;(t=this.annotations)===null||t===void 0?void 0:t.disconnect();this.stream.disconnect();this.frame=undefined;this.errorMessage=undefined}if(this.canvasElement!=null){const t=this.canvasElement.getContext("2d");if(t!=null){t.clearRect(0,0,this.canvasElement.width,this.canvasElement.height)}}}async reload(){if(this.src!=null){await this.unload();await this.load(this.src,{cameraType:this.cameraType})}}async scene(){return this.createScene()}async isSceneReady(){return this.stateMap.streamState.type==="connected"}async handleTapEvent(t){this.tapKeyInteractions.filter((i=>i.predicate(t.detail))).forEach((i=>i.fn(t.detail)))}emitConnectionChange(t){if(t.status==="connected"){if(t.jwt.length===0){throw new L("JWT is empty")}}if(!this.hostElement.isConnected){return}this.connectionChange.emit(t)}handleElementResize(t){const i=t.length>0&&this.dimensions!=null&&!u.isEqual(t[0].contentRect,this.viewport);if(i){if(this.resizeTimer!=null){clearTimeout(this.resizeTimer);this.resizeTimer=undefined}if(!this.isResizing){this.resizeTimer=setTimeout((()=>{this.isResizing=true;this.isResizeUpdate=true;this.recalculateComponentDimensions()}),this.resizeDebounce)}}}handleVisibilityChange(t){var i;this.isVisible=t;if(this.isVisible){(i=this.visibilityObserver)===null||i===void 0?void 0:i.disconnect();this.loadOrResumeStream()}}async loadOrResumeStream(){var t,i,s;const n=(i=(t=this.stream)===null||t===void 0?void 0:t.isPaused())!==null&&i!==void 0?i:false;if(this.src!=null&&!n){await this.load(this.src,{cameraType:this.cameraType})}else if(n){(s=this.stream)===null||s===void 0?void 0:s.resume()}}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((t=>this.injectViewerApi()));this.mutationObserver.observe(this.hostElement,{childList:true,subtree:true});this.styleObserver=new MutationObserver((t=>this.syncViewerStyles()));this.styleObserver.observe(this.hostElement,{attributes:true,attributeFilter:["style"]})}injectViewerApi(){function t(t){return Array.from(t.querySelectorAll("*"))}const i=t(this.hostElement);i.filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((i,s)=>[...i,s,...t(s)]),[]).forEach((t=>{t.viewer=this.hostElement}))}syncViewerStyles(){var t;const i=this.getBackgroundColor();(t=this.stream)===null||t===void 0?void 0:t.update({frameBgColor:i,streamAttributes:this.getStreamAttributes()})}calculateComponentDimensions(){var t;const i=2073600;const s=this.getBounds();if((s===null||s===void 0?void 0:s.width)!=null&&(s===null||s===void 0?void 0:s.height)!=null){const n=u.create(s.width,s.height);const e=u.scaleFit(i,n);this.hostDimensions=n;this.dimensions=e!=null?u.create(e.width,e.height):undefined;this.viewport=Bt.fromDimensions((t=this.getCanvasDimensions())!==null&&t!==void 0?t:u.create(0,0))}}recalculateComponentDimensions(){var t;if(this.isResizing){this.calculateComponentDimensions();this.isResizing=false;if(((t=this.stream)===null||t===void 0?void 0:t.getState().type)==="connected"){this.updateDimensions(this.dimensions)}}}reportPerformance(t){if(this.stateMap.streamState.type==="connected"){const i={timings:t.map((t=>({receiveToPaintDuration:p(t.duration)})))};this.getStream().recordPerformance(i,false)}}addStreamListeners(){this.stateMap.streamListeners=this.getStream().stateChanged.on((t=>{this.handleStreamStateChanged(this.stateMap.streamState,t)}))}handleStreamStateChanged(t,i){this.stateMap.streamState=i;if(i.type==="connecting"){this.handleConnecting(t,i)}else if(i.type==="connected"){this.handleConnected(t,i)}else if(i.type==="connection-failed"){this.handleConnectionFailed(t,i)}else if(i.type==="disconnected"){this.handleDisconnected(t,i)}}handleConnecting(t,i){if(t.type!=="connecting"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"connecting"})}}handleConnected(t,i){var s;this.token=i.token.token;if(t.type!=="connected"){this.errorMessage=undefined;this.canvasRenderer=Oi(Ei,Hi(),this.getResolvedConfig().flags.logFrameRate,(t=>this.reportPerformance(t)));this.emitConnectionChange({status:"connected",jwt:i.token.token});this.deviceIdChange.emit(i.deviceId)}if(((s=this.frame)===null||s===void 0?void 0:s.getId())!==i.frame.getId()){this.updateFrame(i.frame)}this.updateDimensions(this.dimensions)}handleConnectionFailed(t,i){if(t.type!=="connection-failed"){this.token=undefined;this.errorMessage=i.message;this.emitConnectionChange({status:"connection-failed",errorMessage:i.message})}}handleDisconnected(t,i){if(t.type!=="disconnected"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"disconnected"})}}updateDimensions(t){var i;(i=this.stream)===null||i===void 0?void 0:i.update({dimensions:t});this.dimensionschange.emit(t)}async updateFrame(t){var i;const s=this.getCanvasDimensions();const n=this.frameRenderVersion;if(this.canvasElement!=null&&s!=null&&((i=this.frame)===null||i===void 0?void 0:i.getId())!==t.getId()){const i=this.canvasElement.getContext("2d");if(i!=null){const e=this.frame;this.frame=vt(t,e);this.updateInteractionApi(e);const o={canvas:i,canvasDimensions:s,dimensions:this.dimensions,frame:this.frame,viewport:this.viewport,beforeDraw:()=>{this.updateCanvasDimensions(s);this.isResizeUpdate=false},predicate:()=>{if(this.isResizeUpdate){return this.dimensions==null||u.isEqual(this.dimensions,o.frame.image.imageAttr.frameDimensions)}return true}};this.frameReceived.emit(this.frame);if(this.frame.scene.hasChanged){this.sceneChanged.emit()}const a=await this.canvasRenderer(o);if(a!=null&&n===this.frameRenderVersion){this.updateViewerBackground();this.dispatchFrameDrawn(a)}}}}updateViewerBackground(){const t=this.getBackgroundColor();Lt((()=>{var i,s;(i=this.viewerContainerElement)===null||i===void 0?void 0:i.style.setProperty("background",t!=null?I.toHexString(t):"#ffffff");(s=this.canvasContainerElement)===null||s===void 0?void 0:s.style.setProperty("background",t!=null?I.toHexString(t):"#ffffff")}))}async initializeDefaultInteractionHandlers(){var t;await this.initializeDefaultCameraInteractionHandlers();await this.initializeDefaultTapInteractionHandler();this.initializeDefaultKeyboardInteractionHandlers();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}}clearDefaultCameraInteractionHandlers(){this.defaultInteractionHandlerDisposables.forEach((t=>t.dispose()));this.defaultInteractionHandlerDisposables=[]}clearDefaultKeyboardInteractions(){this.defaultTapKeyInteractions.forEach((t=>{const i=this.tapKeyInteractions.indexOf(t);if(i!==-1){this.tapKeyInteractions.splice(i,1)}}));this.tapKeyInteractions=[]}async initializeDefaultCameraInteractionHandlers(){var t,i;this.clearDefaultCameraInteractionHandlers();if(this.cameraControls){if(window.PointerEvent!=null){this.baseInteractionHandler=(t=this.baseInteractionHandler)!==null&&t!==void 0?t:new ki((()=>this.getResolvedConfig()));const i=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Si);this.defaultInteractionHandlerDisposables=[i,s]}else{this.baseInteractionHandler=(i=this.baseInteractionHandler)!==null&&i!==void 0?i:new Ci((()=>this.getResolvedConfig()));const t=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Ai);this.defaultInteractionHandlerDisposables=[t,s]}}}initializeDefaultKeyboardInteractionHandlers(){var t;this.clearDefaultKeyboardInteractions();if(this.keyboardControls&&this.stream!=null){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setDefaultKeyboardControls(this.keyboardControls);const i=new hi(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()));const s=new fi(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()),(()=>this.createScene()));this.registerTapKeyInteraction(i);this.registerTapKeyInteraction(s);this.defaultTapKeyInteractions=[i,s]}}async initializeDefaultTapInteractionHandler(){if(this.tapHandlerDisposable==null){if(window.PointerEvent!=null){const t=new Ti("pointerdown","pointerup","pointermove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}else{const t=new Ti("mousedown","mouseup","mousemove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}}}initializeInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new V("Cannot initialize interaction handler. Interaction target is undefined.")}if(this.interactionApi==null){throw new V("Cannot initialize interaction handler. Interaction APi is undefined.")}t.initialize(this.stateMap.interactionTarget,this.interactionApi)}initializeBasicInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new V("Cannot initialize interaction handler. Interaction target is undefined.")}t.initialize(this.stateMap.interactionTarget)}createInteractionApi(){if(this.stream==null){throw new $("Cannot create interaction API. Component has not been initialized.")}return this.frame==null||this.frame.scene.camera.isPerspective()?new ui(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished):new li(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished)}handleCursorChanged(){window.requestAnimationFrame((()=>{this.cursor=this.stateMap.cursorManager.getActiveCursor()}))}async createScene(){const t=await this.waitForConnectedState();const i=gt();const{frame:s,sceneId:n,sceneViewId:e,worldOrientation:o}=t;return new At(this.getStream(),s,ut(o),i,(()=>this.getImageScale()),this.viewport,n,e)}getBackgroundColor(){if(this.canvasContainerElement!=null){const t=Ds(this.hostElement,"--image-background");const i=Ds(this.hostElement,"--viewer-background");const s=t!==null&&t!==void 0?t:i;return s!=null?I.fromCss(s):I.create(255,255,255)}}getBounds(){return As(this.hostElement)}getCanvasDimensions(){return this.getResolvedConfig().flags.letterboxFrames?this.dimensions:this.hostDimensions}getImageScale(){const t=this.getCanvasDimensions();if(this.dimensions!=null&&t!=null){return o.create(this.dimensions.width/t.width,this.dimensions.height/t.height)}}getStreamAttributes(){return{depthBuffers:this.getDepthBufferStreamAttributesValue(),experimentalRenderingOptions:this.experimentalRenderingOptions,featureHighlighting:this.featureHighlighting,featureLines:this.featureLines,featureMaps:this.featureMaps,frames:{frameBackgroundColor:this.getBackgroundColor()},noDefaultLights:this.noDefaultLights,phantom:this.phantom,sceneComparison:this.sceneComparison,selectionHighlighting:this.selectionHighlighting,crossSectioning:this.crossSectioning}}updateCanvasDimensions(t){if(this.canvasElement!=null){this.canvasElement.width=t.width;this.canvasElement.height=t.height}}updateStreamAttributes(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({streamAttributes:this.getStreamAttributes()})}updateEnableTemporalRefinement(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({enableTemporalRefinement:this.enableTemporalRefinement})}updateInteractionApi(t){if(this.frame!=null){const i=(t==null||t.scene.camera.isPerspective())&&this.frame.scene.camera.isOrthographic();const s=(t==null||t.scene.camera.isOrthographic())&&this.frame.scene.camera.isPerspective();if(i||s){this.interactionApi=this.createInteractionApi();this.cameraType=this.frame.scene.camera.isPerspective()?"perspective":"orthographic";this.cameraTypeChanged.emit(this.cameraType);this.interactionHandlers.forEach((t=>this.initializeInteractionHandler(t)))}}}updateCameraType(){var t,i;if(this.frame!=null){if(this.cameraType==="orthographic"&&this.frame.scene.camera.isPerspective()){(t=this.stream)===null||t===void 0?void 0:t.replaceCamera({camera:it(yt(this.frame.scene.camera,this.frame.scene.boundingBox))})}else if(this.cameraType==="perspective"&&this.frame.scene.camera.isOrthographic()){(i=this.stream)===null||i===void 0?void 0:i.replaceCamera({camera:it(bt(this.frame.scene.camera))})}}}handleAnnotationSetsChange(t){if(t>0&&this.getDepthBufferStreamAttributesValue()==null){this.stateMap.depthBuffersOverrideForAnnotations=true;this.updateStreamAttributes()}else if(t===0&&this.stateMap.depthBuffersOverrideForAnnotations){this.stateMap.depthBuffersOverrideForAnnotations=false;this.updateStreamAttributes()}}getDepthBufferStreamAttributesValue(){var t;const i=(t=this.depthBuffers)!==null&&t!==void 0?t:this.rotateAroundTapPoint||this.stateMap.depthBuffersOverrideForAnnotations?"final":undefined;return i}updateResolvedConfig(){this.resolvedConfig=Dt(this.configEnv,this.config)}getResolvedConfig(){return Es("Resolved config is undefined",(()=>this.resolvedConfig))}getStream(){return Es("Stream is undefined",(()=>this.stream))}getDeviceId(){if(this.deviceId==null){try{this.deviceId=ms(us.DEVICE_ID,(t=>t["device-id"]))}catch(t){console.warn("Cannot read device ID. Local storage is not supported.")}if(this.deviceId==null){this.deviceId=A.create();try{ps(us.DEVICE_ID,{["device-id"]:this.deviceId})}catch(t){console.warn("Cannot write device ID. Local storage is not supported.")}}}return this.deviceId}async waitForConnectedState(){if(this.stateMap.streamState.type!=="connected"){console.debug("Stream was not in a connected state. Waiting for successful connection.");return new Promise(((t,i)=>{const s=this.getStream().onStateChanged((i=>{if(i.type==="connected"){t(i)}}));setTimeout((()=>{s.dispose();i(new Error("Timed out waiting for connected state."))}),Ts)}))}return this.stateMap.streamState}get hostElement(){return e(this)}static get watchers(){return{src:[{handleSrcChanged:0}],cameraControls:[{handleCameraControlsChanged:0}],keyboardControls:[{handleKeyboardControlsChanged:0}],rotateAroundTapPoint:[{handleRotateAboutTapPointChanged:0}],cameraType:[{handleCameraTypeChanged:0}],crossSectioning:[{handleStreamAttributesChanged:0}],depthBuffers:[{handleStreamAttributesChanged:0}],experimentalRenderingOptions:[{handleStreamAttributesChanged:0}],featureHighlighting:[{handleStreamAttributesChanged:0}],featureLines:[{handleStreamAttributesChanged:0}],featureMaps:[{handleStreamAttributesChanged:0}],noDefaultLights:[{handleStreamAttributesChanged:0}],phantom:[{handleStreamAttributesChanged:0}],sceneComparison:[{handleStreamAttributesChanged:0}],selectionHighlighting:[{handleStreamAttributesChanged:0}],enableTemporalRefinement:[{handleEnableTemporalRefinementChanged:0}],config:[{handleConfigChanged:0}],configEnv:[{handleConfigEnvChanged:0}]}}};function Es(t,i){const s=i();if(s!=null){return s}else throw new Error(t)}Ms.style=xs();export{Ms as vertex_viewer};
5
+ //# sourceMappingURL=p-ecd594f2.entry.js.map
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
+ */
4
+ import{h as i,r as t,c as s,H as n,a as o}from"./p-CCVkga9Q.js";import{p as l,v as h,r as e,b as r,a,m as d,h as u,g as v,q as c,e as f,c as w}from"./p-2UsvOTHJ.js";import{c as p}from"./p-Dw4-tG-V.js";import{w as x,r as g}from"./p-BxtKMwBH.js";import{T as y}from"./p-C12jtCFb.js";import{A as m,D as b}from"./p-Cc3XhAoA.js";import"./p-BAhfr1Nx.js";import{E as z}from"./p-CDM7zNn0.js";import{d as T,T as C,R as D,e as R,r as A,s as P,x as j,A as S,b as E,y as N,z as H,f as O,g as U,h as I,i as M,j as $}from"./p-BJGbLthH.js";import"./p-CG9AChtV.js";import"./p-5kcpg4MZ.js";import"./p-BT9d9jRt.js";import"./p-CeZe0Qql.js";function B(i){if(window.document.activeElement!==i){i.focus();i.setSelectionRange(i.value.length,i.value.length)}}function F(i,t){return t!=null?l.create(i.x-t.left,i.y-t.top):undefined}function k(i,t,s,n){const o=n!=null?h.fromMatrixPosition(n):undefined;if(i!=null&&t!=null&&s!=null&&o!=null){const n=s.transformPointToRay(i,t.image,t.scene.camera);if(t.scene.camera.isOrthographic()){const i=e.at(e.create({origin:o,direction:t.scene.camera.direction}),h.magnitude(t.scene.camera.viewVector)*2);return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,i))}else{return e.intersectPlane(n,r.fromNormalAndCoplanarPoint(t.scene.camera.direction,o))}}return undefined}function J(i,t,s,n,o,l){return d.multiply(q(t,s,n,o,l),i)}function q(i,t,s,n,o){const l=new b(n);const e=new m(o);const r=()=>e.convertFrom(t-s);const a=()=>l.convertRealValueToWorld(t-s);switch(i){case"x-translate":return d.makeTranslation(h.create(a(),0,0));case"y-translate":return d.makeTranslation(h.create(0,a(),0));case"z-translate":return d.makeTranslation(h.create(0,0,a()));case"x-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.left(),r())));case"y-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.down(),r())));case"z-rotate":return d.transpose(d.makeRotation(c.fromAxisAngle(h.forward(),r())));default:return d.makeIdentity()}}function _(i){switch(i){case"x-rotate":return"xyz";case"y-rotate":return"yzx";case"z-rotate":return"zxy";default:return"xyz"}}function V(i,t,s,n,o){const l=new b(n);const e=new m(o);const r=()=>d.makeRotation(c.fromMatrixRotation(t));const v=()=>d.multiply(d.invert(s),t);const f=()=>h.multiplyByTransformMatrixColumnMajor(h.fromMatrixPosition(v()),r());const w=()=>u.fromRotationMatrix(d.multiply(s,r()),_(i));switch(i){case"x-translate":return l.convertWorldValueToReal(f().x);case"y-translate":return l.convertWorldValueToReal(f().y);case"z-translate":return l.convertWorldValueToReal(f().z);case"x-rotate":return e.convertTo(a.normalizeRadians(w().x));case"y-rotate":return e.convertTo(a.normalizeRadians(w().y));case"z-rotate":return e.convertTo(a.normalizeRadians(w().z));default:return 0}}function L(i,t,s,n,o,l){return X(i,h.subtract(s,t),n,o,l)}function X(i,t,s,n,o){switch(o){case"x-translate":return K(i,t,h.right());case"y-translate":return K(i,t,h.up());case"z-translate":return K(i,t,h.back());case"xy-translate":return Q(i,t,h.create(0,0,1));case"xz-translate":return Q(i,t,h.create(0,1,0));case"yz-translate":return Q(i,t,h.create(1,0,0));case"x-rotate":return Z(i,s,h.right(),n);case"y-rotate":return Z(i,s,h.up(),n);case"z-rotate":return Z(i,s,h.forward(),n);default:return i}}function Z(i,t,s,n){const o=G(i,t,s);const l=c.fromAxisAngle(o,n);const h=d.transpose(d.makeRotation(l));return d.multiply(h,i)}function G(i,t,s){const n=d.makeRotation(c.fromMatrixRotation(i));const o=h.multiplyByTransformMatrixRowMajor(s,n);const l=h.multiplyByTransformMatrixRowMajor(h.negate(s),n);return h.dot(t,o)>h.dot(t,l)?s:h.negate(s)}function K(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.project(t,l);const r=d.makeTranslation(e);return d.multiply(i,r)}function Q(i,t,s){const n=h.normalize(s);const o=d.makeRotation(c.fromMatrixRotation(i));const l=h.multiplyByTransformMatrixRowMajor(n,o);const e=h.fromMatrixPosition(i);const a=r.fromNormalAndCoplanarPoint(l,e);const u=r.projectPoint(a,t);const v=h.add(u,h.scale(a.constant,a.normal));const f=d.makeTranslation(v);return d.multiply(i,f)}function Y(i,t,s){if(s.length===0){throw new Error("Unable to compute input position. At least one shape point must be provided.")}const n=v.pad(t,5);const o=s.map((t=>i.transformNdcPointToViewport(t)));const h=v.topLeft(n);const e=l.add(h,l.create(n.width,0));const r=v.bottomRight(n);const a=l.subtract(r,l.create(n.width,0));const d=l.scale(o.reduce(((i,t)=>l.add(i,t)),l.create()),1/o.length,1/o.length);const u=[e,a,r].reduce(((i,t)=>l.distance(d,t)<l.distance(d,i)?t:i),h);switch(u){case h:return{point:u,placement:"top-left"};case e:return{point:u,placement:"top-right"};case a:return{point:u,placement:"bottom-left"};default:return{point:u,placement:"bottom-right"}}}function W(i,t,s,n,o,l){const h=t==="alt"&&i.altKey||t==="ctrl"&&i.ctrlKey||t==="meta"&&i.metaKey||t==="shift"&&i.shiftKey;if(h&&l!=null&&l>0&&Number.isInteger(l)){const i=s-n;const t=a.toDegrees(i);const h=Math.round(t/l)*l;if(o!=null){const i=Math.round(o/l)*l;const t=o-i;const s=h-t;const e=a.toRadians(s);return e+n}else{const i=a.toRadians(h);return i+n}}else{return s}}const ii=({ref:t,bounds:s,viewport:n,point:o,placement:l,displayUnit:h},e)=>{const r=ni(n,s!==null&&s!==void 0?s:f.create(0,0),o,l);return i("div",{ref:t,class:"widget-input wrapper",style:{...r,height:(s===null||s===void 0?void 0:s.height)!=null?`${s.height}px`:undefined}},e,i("div",{class:"widget-input units"},h.unit.abbreviatedName))};const ti=({ref:t,identifier:s,disabled:n,onChange:o,onIncrement:l,onDecrement:h,onBlur:e,onUndo:r})=>{const a=i=>{if(i.target!=null){const t=Number.parseFloat(i.target.value);if(!Number.isNaN(t)){o===null||o===void 0?void 0:o(Number.parseFloat(i.target.value))}}};const d=i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="ArrowUp"){l===null||l===void 0?void 0:l()}else if(i.key==="ArrowDown"){h===null||h===void 0?void 0:h()}else if(i.key==="z"&&t&&r){i.preventDefault();r()}};return i("input",{ref:t,disabled:n,class:`widget-input ${s}`,type:"text",onChange:a,onKeyDown:d,onBlur:e,"aria-label":"Transform widget input"})};function si(i,t){return Math.min(i,Math.max(0,t))}function ni(i,t,s,n,o=5){const{width:l,height:h}=i.dimensions;const e=t.width+o;const r=t.height+o;function a(i){return`${i}px`}switch(n){case"top-left":return{right:a(si(l-e,l-s.x)),bottom:a(si(h-r,h-s.y))};case"top-right":return{left:a(si(l-e,s.x)),bottom:a(si(h-r,h-s.y))};case"bottom-left":return{right:a(si(l-e,l-s.x)),top:a(si(h-r,s.y))};case"bottom-right":default:return{left:a(si(l-e,s.x)),top:a(si(h-r,s.y))}}}function oi(i,t,s=3,n=1,o=1){return ei(i,t,h.back(),h.up(),s,n,o)}function li(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.back(),s,n,o)}function hi(i,t,s=3,n=1,o=1){return ei(i,t,h.right(),h.up(),s,n,o)}function ei(i,t,s,n,o,l=1,r=1){const u=h.multiplyByTransformMatrixRowMajor(h.add(s,n),d.makeRotation(c.fromMatrixRotation(i)));const v=h.multiplyByTransformMatrixRowMajor(s,d.makeRotation(c.fromMatrixRotation(i)));const f=h.multiplyByTransformMatrixRowMajor(n,d.makeRotation(c.fromMatrixRotation(i)));const w=10*r**.25;const p=h.fromMatrixPosition(i);const x=h.add(p,h.scale(o*w,u));const g=e.create({origin:x,direction:v});const y=e.create({origin:x,direction:f});const m=h.cross(v,f);const b=h.rotateAboutAxis(a.toRadians(45),e.at(y,-(o*l)),m,x);const z=h.rotateAboutAxis(a.toRadians(45),e.at(g,o*l),m,x);const C=h.rotateAboutAxis(a.toRadians(45),e.at(y,o*l),m,x);const D=h.rotateAboutAxis(a.toRadians(45),e.at(g,-(o*l)),m,x);return new T(h.dot(v,t.direction)!==-1&&h.dot(f,t.direction)!==-1,b,D,z,C,h.multiplyByTransformMatrixColumnMajor(b,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(D,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(z,t.projectionViewMatrix),h.multiplyByTransformMatrixColumnMajor(C,t.projectionViewMatrix))}function ri(i,t,s,n){if(i instanceof C){return ai(i,t,s,n)}return false}function ai(i,t,s,n){return di([i.points.worldLeft,i.points.worldRight,i.points.worldTip],t,s,n)||di([i.points.worldLeft,i.points.worldRight,i.points.worldBase],t,s,n)}function di(i,t,s,n){var o;if(i.length===3){const l=s.transformPointToRay(n,t.image,t.scene.camera);const e=h.subtract(i[1],i[0]);const r=h.subtract(i[2],i[0]);const a=w.epsilon((o=w.fromVectors([l.direction,l.origin,e,r]))!==null&&o!==void 0?o:w.create(e,r));const d=h.cross(l.direction,r);const u=h.dot(e,d);if(!(Math.abs(u)>=a)){return false}const v=h.subtract(l.origin,i[0]);const c=h.dot(v,d)/u;if(c<0||c>1){return false}const f=h.cross(v,e);const p=h.dot(l.direction,f)/u;if(p<0||c+p>1){return false}const x=h.dot(r,f)/u;return!Number.isNaN(x)&&(x>0||t.scene.camera.isOrthographic())}return false}class ui extends D{constructor(i,t={},s={}){var n,o,l,h,e,r,a,d,u,v,c,f,w,p;super(i);this.customization=t;this.disabledAxis={xTranslation:false,yTranslation:false,zTranslation:false,xyTranslation:false,xzTranslation:false,yzTranslation:false,xRotation:false,yRotation:false,zRotation:false};this.axisLines=[];this.rotationLines=[];this.translationMeshes=[];this.rotationMeshes=[];this.hoveredChanged=new z;this.xArrowFillColor=(n=t.colors)===null||n===void 0?void 0:n.xArrow;this.yArrowFillColor=(o=t.colors)===null||o===void 0?void 0:o.yArrow;this.zArrowFillColor=(l=t.colors)===null||l===void 0?void 0:l.zArrow;this.hoveredArrowFillColor=(h=t.colors)===null||h===void 0?void 0:h.hovered;this.outlineColor=(e=t.colors)===null||e===void 0?void 0:e.outline;this.disabledAxis.xTranslation=(r=s.xTranslation)!==null&&r!==void 0?r:false;this.disabledAxis.yTranslation=(a=s.yTranslation)!==null&&a!==void 0?a:false;this.disabledAxis.zTranslation=(d=s.zTranslation)!==null&&d!==void 0?d:false;this.disabledAxis.xyTranslation=(u=s.xyTranslation)!==null&&u!==void 0?u:false;this.disabledAxis.xzTranslation=(v=s.xzTranslation)!==null&&v!==void 0?v:false;this.disabledAxis.yzTranslation=(c=s.yzTranslation)!==null&&c!==void 0?c:false;this.disabledAxis.xRotation=(f=s.xRotation)!==null&&f!==void 0?f:false;this.disabledAxis.yRotation=(w=s.yRotation)!==null&&w!==void 0?w:false;this.disabledAxis.zRotation=(p=s.zRotation)!==null&&p!==void 0?p:false}dispose(){var i;(i=this.reglFrameDisposable)===null||i===void 0?void 0:i.cancel()}getDrawableElements(){return this.drawableElements}getFullBounds(){return this.fullBounds}boundsContainsPoint(i){return this.interactiveBounds!=null&&this.frame!=null&&v.containsPoints(this.interactiveBounds,i)}updateDisabledAxis(i){this.disabledAxis={...this.disabledAxis,...i};this.updateDisabledOnDrawables()}updateCursor(i){this.cursor=i;if(i!=null&&this.frame!=null){this.updateHovered()}else{this.clearHovered()}}updateTransform(i){var t;this.transform=i;if(i!=null&&this.frame!=null){this.updateAndDraw()}else{this.clear();(t=this.reglFrameDisposable)===null||t===void 0?void 0:t.cancel();this.reglFrameDisposable=undefined}}updateColors(i={}){var t,s,n,o,l,h,e,r,a,d,u,v,c,f,w,p;this.xArrowFillColor=(t=i.xArrow)!==null&&t!==void 0?t:this.xArrowFillColor;this.yArrowFillColor=(s=i.yArrow)!==null&&s!==void 0?s:this.yArrowFillColor;this.zArrowFillColor=(n=i.zArrow)!==null&&n!==void 0?n:this.zArrowFillColor;this.twoAxesSquareFillColor=(o=i.twoAxesSquare)!==null&&o!==void 0?o:this.twoAxesSquareFillColor;this.hoveredArrowFillColor=(l=i.hovered)!==null&&l!==void 0?l:this.hoveredArrowFillColor;this.outlineColor=(h=i.outline)!==null&&h!==void 0?h:this.outlineColor;(e=this.xArrow)===null||e===void 0?void 0:e.updateFillColor(this.getXTranslationColor(),true);(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.getYTranslationColor(),true);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.getZTranslationColor(),true);(d=this.xRotation)===null||d===void 0?void 0:d.updateFillColor(this.getXRotationColor(),true);(u=this.yRotation)===null||u===void 0?void 0:u.updateFillColor(this.getYRotationColor(),true);(v=this.zRotation)===null||v===void 0?void 0:v.updateFillColor(this.getZRotationColor(),true);(c=this.xyTranslation)===null||c===void 0?void 0:c.updateFillColor(this.getTwoAxesTranslationColor(),true);(f=this.xzTranslation)===null||f===void 0?void 0:f.updateFillColor(this.getTwoAxesTranslationColor(),true);(w=this.yzTranslation)===null||w===void 0?void 0:w.updateFillColor(this.getTwoAxesTranslationColor(),true);(p=this.hoveredElement)===null||p===void 0?void 0:p.updateFillColor(this.hoveredArrowFillColor)}updateScalars(i){this.customization={...this.customization,scalars:i};if(this.transform!=null&&this.frame!=null){this.updateElements(this.transform,this.frame)}}onHoveredChanged(i){return this.hoveredChanged.on(i)}updateDisabledOnDrawables(){var i,t,s,n,o,l,h,e,r,a,d,u,v,c,f;(i=this.xRotation)===null||i===void 0?void 0:i.setDisabled(this.disabledAxis.xRotation);(t=this.xyRotationLine)===null||t===void 0?void 0:t.setDisabled(this.disabledAxis.xRotation);(s=this.xzRotationLine)===null||s===void 0?void 0:s.setDisabled(this.disabledAxis.xRotation);(n=this.yRotation)===null||n===void 0?void 0:n.setDisabled(this.disabledAxis.yRotation);(o=this.yzRotationLine)===null||o===void 0?void 0:o.setDisabled(this.disabledAxis.yRotation);(l=this.yxRotationLine)===null||l===void 0?void 0:l.setDisabled(this.disabledAxis.yRotation);(h=this.zRotation)===null||h===void 0?void 0:h.setDisabled(this.disabledAxis.zRotation);(e=this.zxRotationLine)===null||e===void 0?void 0:e.setDisabled(this.disabledAxis.zRotation);(r=this.zyRotationLine)===null||r===void 0?void 0:r.setDisabled(this.disabledAxis.zRotation);(a=this.xArrow)===null||a===void 0?void 0:a.setDisabled(this.disabledAxis.xTranslation);(d=this.yArrow)===null||d===void 0?void 0:d.setDisabled(this.disabledAxis.yTranslation);(u=this.zArrow)===null||u===void 0?void 0:u.setDisabled(this.disabledAxis.zTranslation);(v=this.xyTranslation)===null||v===void 0?void 0:v.setDisabled(this.disabledAxis.xyTranslation);(c=this.xzTranslation)===null||c===void 0?void 0:c.setDisabled(this.disabledAxis.xzTranslation);(f=this.yzTranslation)===null||f===void 0?void 0:f.setDisabled(this.disabledAxis.yzTranslation);this.updateColors()}updateHovered(){var i,t,s,n,o,l,h,e,r,a;const d=this.hoveredElement;const u=this.frame;if(u!=null){this.hoveredElement=[...this.translationMeshes,...this.rotationMeshes].filter((i=>i.points.valid&&!i.isDisabled())).find((i=>this.cursor!=null?ri(i,u,this.viewport,this.cursor):false));if(this.hoveredElement!==d){this.hoveredChanged.emit(this.hoveredElement);(i=this.hoveredElement)===null||i===void 0?void 0:i.updateFillColor(this.hoveredArrowFillColor);this.clearFillColorOfPreviouslyHovered(d);if(((t=this.hoveredElement)===null||t===void 0?void 0:t.identifier)==="xy-translate"){(s=this.xArrow)===null||s===void 0?void 0:s.updateFillColor(this.hoveredArrowFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor(this.hoveredArrowFillColor)}else if(((o=this.hoveredElement)===null||o===void 0?void 0:o.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor(this.hoveredArrowFillColor);(h=this.zArrow)===null||h===void 0?void 0:h.updateFillColor(this.hoveredArrowFillColor)}else if(((e=this.hoveredElement)===null||e===void 0?void 0:e.identifier)==="yz-translate"){(r=this.yArrow)===null||r===void 0?void 0:r.updateFillColor(this.hoveredArrowFillColor);(a=this.zArrow)===null||a===void 0?void 0:a.updateFillColor(this.hoveredArrowFillColor)}}}}clearHovered(){const i=this.hoveredElement;this.hoveredElement=undefined;if(this.hoveredElement!==i){this.hoveredChanged.emit(this.hoveredElement);this.clearFillColorOfPreviouslyHovered(i)}}clearFillColorOfPreviouslyHovered(i){var t,s,n,o,l,h,e,r,a,d,u,v;i===null||i===void 0?void 0:i.updateFillColor(i===null||i===void 0?void 0:i.initialFillColor);if((i===null||i===void 0?void 0:i.identifier)==="xy-translate"){(t=this.xArrow)===null||t===void 0?void 0:t.updateFillColor((s=this.xArrow)===null||s===void 0?void 0:s.initialFillColor);(n=this.yArrow)===null||n===void 0?void 0:n.updateFillColor((o=this.yArrow)===null||o===void 0?void 0:o.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="xz-translate"){(l=this.xArrow)===null||l===void 0?void 0:l.updateFillColor((h=this.xArrow)===null||h===void 0?void 0:h.initialFillColor);(e=this.zArrow)===null||e===void 0?void 0:e.updateFillColor((r=this.zArrow)===null||r===void 0?void 0:r.initialFillColor)}else if((i===null||i===void 0?void 0:i.identifier)==="yz-translate"){(a=this.yArrow)===null||a===void 0?void 0:a.updateFillColor((d=this.yArrow)===null||d===void 0?void 0:d.initialFillColor);(u=this.zArrow)===null||u===void 0?void 0:u.updateFillColor((v=this.zArrow)===null||v===void 0?void 0:v.initialFillColor)}}hasData(){return this.transform!=null}createOrUpdateElements(){if(this.transform!=null&&this.frame!=null){if(this.xArrow==null||this.yArrow==null||this.zArrow==null){this.createElements(this.transform,this.frame)}else{this.updateElements(this.transform,this.frame)}this.interactiveBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes);this.fullBounds=R(this.viewport,...this.rotationMeshes,...this.translationMeshes,...this.axisLines)}}createElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f;this.reglCommand=A({canvas:this.canvasElement,extensions:"angle_instanced_arrays"});const{createShape:w}=P(this.reglCommand);const p=this.computeTriangleSize(h.fromMatrixPosition(i),t);this.xArrow=new C(w,"x-translate",j(i,t.scene.camera,p,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation),this.outlineColor,this.getXTranslationColor());this.xRotation=new C(w,"x-rotate",oi(i,t.scene.camera,p,(n=this.customization.scalars)===null||n===void 0?void 0:n.xRotation,(o=this.customization.scalars)===null||o===void 0?void 0:o.xTranslation),this.outlineColor,this.getXRotationColor());this.xAxis=new S(w,"x-axis",E(i,t.scene.camera,this.xArrow),this.outlineColor,this.getXTranslationColor());this.yArrow=new C(w,"y-translate",N(i,t.scene.camera,p,(l=this.customization.scalars)===null||l===void 0?void 0:l.yTranslation),this.outlineColor,this.getYTranslationColor());this.yRotation=new C(w,"y-rotate",li(i,t.scene.camera,p,(e=this.customization.scalars)===null||e===void 0?void 0:e.yRotation,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation),this.outlineColor,this.getYRotationColor());this.yAxis=new S(w,"y-axis",E(i,t.scene.camera,this.yArrow),this.outlineColor,this.getYTranslationColor());this.zArrow=new C(w,"z-translate",H(i,t.scene.camera,p,(a=this.customization.scalars)===null||a===void 0?void 0:a.zTranslation),this.outlineColor,this.getZTranslationColor());this.zAxis=new S(w,"z-axis",E(i,t.scene.camera,this.zArrow),this.outlineColor,this.getZTranslationColor());this.zRotation=new C(w,"z-rotate",hi(i,t.scene.camera,p,(d=this.customization.scalars)===null||d===void 0?void 0:d.zRotation,(u=this.customization.scalars)===null||u===void 0?void 0:u.zTranslation),this.outlineColor,this.getZRotationColor());this.xyTranslation=new C(w,"xy-translate",O(i,t.scene.camera,p,(v=this.customization.scalars)===null||v===void 0?void 0:v.xyTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.xzTranslation=new C(w,"xz-translate",U(i,t.scene.camera,p,(c=this.customization.scalars)===null||c===void 0?void 0:c.xzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.yzTranslation=new C(w,"yz-translate",I(i,t.scene.camera,p,(f=this.customization.scalars)===null||f===void 0?void 0:f.yzTranslation),this.outlineColor,this.getTwoAxesTranslationColor());this.createRotationLines(w,i,t);this.axisLines=[this.xAxis,this.yAxis,this.zAxis];this.translationMeshes=[this.xArrow,this.yArrow,this.zArrow,this.xyTranslation,this.xzTranslation,this.yzTranslation];this.rotationMeshes=[this.xRotation,this.yRotation,this.zRotation];this.updateDisabledOnDrawables();this.availableElements=[...this.axisLines,...this.rotationLines,...this.translationMeshes,...this.rotationMeshes]}getXRotationColor(){return this.xArrowFillColor}getYRotationColor(){return this.yArrowFillColor}getZRotationColor(){return this.zArrowFillColor}getXTranslationColor(){return this.xArrowFillColor}getYTranslationColor(){return this.yArrowFillColor}getZTranslationColor(){return this.zArrowFillColor}getTwoAxesTranslationColor(){return this.twoAxesSquareFillColor}createRotationLines(i,t,s){var n,o,l,e,r,a;const d=this.computeTriangleSize(h.fromMatrixPosition(t),s);const u=M(s.scene.camera,this.xRotation,(n=this.yArrow)===null||n===void 0?void 0:n.points.worldTip,d);const v=M(s.scene.camera,this.xRotation,(o=this.zArrow)===null||o===void 0?void 0:o.points.worldTip,d);const c=M(s.scene.camera,this.yRotation,(l=this.xArrow)===null||l===void 0?void 0:l.points.worldTip,d);const f=M(s.scene.camera,this.yRotation,(e=this.zArrow)===null||e===void 0?void 0:e.points.worldTip,d);const w=M(s.scene.camera,this.zRotation,(r=this.xArrow)===null||r===void 0?void 0:r.points.worldTip,d);const p=M(s.scene.camera,this.zRotation,(a=this.yArrow)===null||a===void 0?void 0:a.points.worldTip,d);if(u!=null){this.xyRotationLine=new $(i,"xy-rotation-line",u,this.outlineColor)}if(v!=null){this.xzRotationLine=new $(i,"xz-rotation-line",v,this.outlineColor)}if(c!=null){this.yxRotationLine=new $(i,"yx-rotation-line",c,this.outlineColor)}if(f!=null){this.yzRotationLine=new $(i,"yz-rotation-line",f,this.outlineColor)}if(w!=null){this.zxRotationLine=new $(i,"zx-rotation-line",w,this.outlineColor)}if(p!=null){this.zyRotationLine=new $(i,"zy-rotation-line",p,this.outlineColor)}this.rotationLines=[this.xyRotationLine,this.xzRotationLine,this.yxRotationLine,this.yzRotationLine,this.zxRotationLine,this.zyRotationLine].filter((i=>i!=null))}updateElements(i,t){var s,n,o,l,e,r,a,d,u,v,c,f,w,p,x,g,y,m,b,z,T,C,D,R,A,P,S,$,B,F;const k=this.computeTriangleSize(h.fromMatrixPosition(i),t);if(this.xArrow!=null){this.xArrow.updatePoints(j(i,t.scene.camera,k,(s=this.customization.scalars)===null||s===void 0?void 0:s.xTranslation));(n=this.xAxis)===null||n===void 0?void 0:n.updatePoints(E(i,t.scene.camera,this.xArrow))}(o=this.xRotation)===null||o===void 0?void 0:o.updatePoints(oi(i,t.scene.camera,k,(l=this.customization.scalars)===null||l===void 0?void 0:l.xRotation,(e=this.customization.scalars)===null||e===void 0?void 0:e.xTranslation));if(this.yArrow!=null){this.yArrow.updatePoints(N(i,t.scene.camera,k,(r=this.customization.scalars)===null||r===void 0?void 0:r.yTranslation));(a=this.yAxis)===null||a===void 0?void 0:a.updatePoints(E(i,t.scene.camera,this.yArrow))}(d=this.yRotation)===null||d===void 0?void 0:d.updatePoints(li(i,t.scene.camera,k,(u=this.customization.scalars)===null||u===void 0?void 0:u.yRotation,(v=this.customization.scalars)===null||v===void 0?void 0:v.yTranslation));if(this.zArrow!=null){this.zArrow.updatePoints(H(i,t.scene.camera,k,(c=this.customization.scalars)===null||c===void 0?void 0:c.zTranslation));(f=this.zAxis)===null||f===void 0?void 0:f.updatePoints(E(i,t.scene.camera,this.zArrow))}(w=this.zRotation)===null||w===void 0?void 0:w.updatePoints(hi(i,t.scene.camera,k,(p=this.customization.scalars)===null||p===void 0?void 0:p.zRotation,(x=this.customization.scalars)===null||x===void 0?void 0:x.zTranslation));(g=this.xyRotationLine)===null||g===void 0?void 0:g.updatePoints(M(t.scene.camera,this.xRotation,(y=this.yArrow)===null||y===void 0?void 0:y.points.worldTip,k));(m=this.xzRotationLine)===null||m===void 0?void 0:m.updatePoints(M(t.scene.camera,this.xRotation,(b=this.zArrow)===null||b===void 0?void 0:b.points.worldTip,k));(z=this.yxRotationLine)===null||z===void 0?void 0:z.updatePoints(M(t.scene.camera,this.yRotation,(T=this.xArrow)===null||T===void 0?void 0:T.points.worldTip,k));(C=this.yzRotationLine)===null||C===void 0?void 0:C.updatePoints(M(t.scene.camera,this.yRotation,(D=this.zArrow)===null||D===void 0?void 0:D.points.worldTip,k));(R=this.zxRotationLine)===null||R===void 0?void 0:R.updatePoints(M(t.scene.camera,this.zRotation,(A=this.xArrow)===null||A===void 0?void 0:A.points.worldTip,k));(P=this.zyRotationLine)===null||P===void 0?void 0:P.updatePoints(M(t.scene.camera,this.zRotation,(S=this.yArrow)===null||S===void 0?void 0:S.points.worldTip,k));if(this.xyTranslation!=null){this.xyTranslation.updatePoints(O(i,t.scene.camera,k,($=this.customization.scalars)===null||$===void 0?void 0:$.xyTranslation))}if(this.xzTranslation!=null){this.xzTranslation.updatePoints(U(i,t.scene.camera,k,(B=this.customization.scalars)===null||B===void 0?void 0:B.xzTranslation))}if(this.yzTranslation!=null){this.yzTranslation.updatePoints(I(i,t.scene.camera,k,(F=this.customization.scalars)===null||F===void 0?void 0:F.yzTranslation))}}}const vi=()=>`:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;--viewer-transform-widget-x-axis-arrow-color:var(--x-axis-color);--viewer-transform-widget-y-axis-arrow-color:var(--y-axis-color);--viewer-transform-widget-z-axis-arrow-color:var(--z-axis-color);--viewer-transform-widget-two-axes-square-color:var(--two-axes-color);--viewer-transform-widget-hovered-arrow-color:#ffff00;--viewer-transform-widget-input-width:8em}.widget{position:absolute;top:0;left:0}.widget.hovered{pointer-events:auto}.widget-input.wrapper{position:absolute;pointer-events:auto;display:flex;align-items:center;border:1px solid #444444;border-radius:4px;width:var(--viewer-transform-widget-input-width);text-align:center;background-color:white;box-sizing:border-box}.widget-input.units{position:relative;width:25%;height:100%;padding:0 0.25rem;font-size:0.8125rem;color:#444444}input.widget-input{position:relative;text-align:center;box-sizing:border-box;width:75%;height:100%;outline:none;border-width:0 1px 0 0;border-color:#444444;border-radius:2px 0 0 2px;font-size:0.875rem;color:#444444}input.widget-input.x-translate,input.widget-input.x-rotate{border-left:5px solid var(--viewer-transform-widget-x-axis-arrow-color)}input.widget-input.y-translate,input.widget-input.y-rotate{border-left:5px solid var(--viewer-transform-widget-y-axis-arrow-color)}input.widget-input.z-translate,input.widget-input.z-rotate{border-left:5px solid var(--viewer-transform-widget-z-axis-arrow-color)}input.widget-input:disabled{color:#888888}input.widget-input:focus{outline:none}`;const ci=class{constructor(i){t(this,i);this.positionChanged=s(this,"positionChanged");this.rotationChanged=s(this,"rotationChanged");this.interactionEnded=s(this,"interactionEnded");this.interactionStarted=s(this,"interactionStarted");this.xRotationDisabled=false;this.yRotationDisabled=false;this.zRotationDisabled=false;this.xTranslationDisabled=false;this.yTranslationDisabled=false;this.zTranslationDisabled=false;this.xyTranslationDisabled=false;this.xzTranslationDisabled=false;this.yzTranslationDisabled=false;this.showInputs=true;this.distanceUnit="millimeters";this.angleUnit="degrees";this.decimalPlaces=1;this.rotationSnapKey="shift";this.translationHandleScalar=1;this.rotationHandleScalar=1;this.interactionThrottle=75;this.EXPERIMENTAL_undoKeybindings=false;this.inputValue=0;this.isEndingTransform=false;this.inputShouldFocus=false;this.xArrowColor="#ea3324";this.yArrowColor="#4faf32";this.zArrowColor="#0000ff";this.twoAxesSquareColor="#e0e0e0";this.hoveredColor="#ffff00";this.lastAngle=0;this.handleHoveredDrawableChanged=i=>{this.hovered=i};this.handleViewerFrameDrawn=()=>{this.updatePropsFromViewer()};this.handleViewerDimensionsChange=()=>{x((()=>{if(this.viewer!=null&&this.canvasRef!=null){this.canvasRef.width=this.viewer.viewport.width;this.canvasRef.height=this.viewer.viewport.height;this.updateCanvasBounds(this.canvasRef)}}))};this.handleResize=()=>{if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef)}};this.handleInputResize=()=>{if(this.inputWrapperRef!=null){const i=this.inputWrapperRef;g((()=>{this.inputBounds=i.getBoundingClientRect()}))}};this.handleStyleChange=()=>{g((()=>{const i=window.getComputedStyle(this.hostEl);this.xArrowColor=i.getPropertyValue("--viewer-transform-widget-x-axis-arrow-color").trim();this.yArrowColor=i.getPropertyValue("--viewer-transform-widget-y-axis-arrow-color").trim();this.zArrowColor=i.getPropertyValue("--viewer-transform-widget-z-axis-arrow-color").trim();this.twoAxesSquareColor=i.getPropertyValue("--viewer-transform-widget-two-axes-square-color").trim();this.hoveredColor=i.getPropertyValue("--viewer-transform-widget-hovered-arrow-color").trim();this.getTransformWidget().updateColors({xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor})}))};this.handlePointerMove=i=>{if(this.dragging==null){const t=F(l.create(i.clientX,i.clientY),this.getCanvasBounds());const s=this.getTransformWidget();if(t!=null&&s.boundsContainsPoint(t)){s.updateCursor(t)}else{s.updateCursor(undefined);this.hovered=undefined}}};this.handleBeginDrag=async i=>{var t,s,n;const o=this.getCanvasBounds();if(this.hovered!=null&&o!=null&&this.viewer!=null&&this.position!=null&&this.viewer.frame!=null){this.dragging=this.hovered;if(this.dragging.identifier!==((t=this.lastDragged)===null||t===void 0?void 0:t.identifier)){this.inputValue=0;this.dragStartTransform=this.currentTransform;this.updateInputPosition();this.updateInputValue()}this.lastDragged=undefined;const h=F(l.create(i.clientX,i.clientY),o);const e=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);this.lastAngle=h!=null?a.fromPoints(e,h):0;this.lastWorldPosition=k(h,(s=this.viewer)===null||s===void 0?void 0:s.frame,(n=this.viewer)===null||n===void 0?void 0:n.viewport,this.currentTransform);this.interactionStarted.emit();window.removeEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointermove",this.handleDragWithTimer);window.addEventListener("pointerup",this.handleEndTransform)}};this.handleDragWithTimer=async i=>{if(i!=null){i.preventDefault();this.lastMouseEvent=i}if(this.interactionTimer==null){this.interactionTimer=window.setTimeout((async()=>{this.interactionTimer=undefined;await this.handleDrag();this.lastMouseEvent=undefined}),this.interactionThrottle)}};this.handleDrag=async()=>{var i,t,s;const n=this.getCanvasBounds();if(this.dragging!=null&&this.lastWorldPosition!=null&&n!=null&&this.viewer!=null&&this.viewer.frame!=null&&this.position!=null&&this.lastMouseEvent!=null){await((i=this.controller)===null||i===void 0?void 0:i.beginTransform());const o=F(l.create(this.lastMouseEvent.clientX,this.lastMouseEvent.clientY),n);const h=this.viewer.viewport.transformWorldToViewport(this.position,this.viewer.frame.scene.camera.projectionViewMatrix);const e=k(o,(t=this.viewer)===null||t===void 0?void 0:t.frame,(s=this.viewer)===null||s===void 0?void 0:s.viewport,this.currentTransform);if(e!=null&&o!=null&&h!=null){const i=a.fromPoints(h,o);const t=W(this.lastMouseEvent,this.rotationSnapKey,i,this.lastAngle,this.getDisplayedAngle(),this.rotationSnapDegrees);this.transform(this.lastWorldPosition,e,t-this.lastAngle);this.updateInputPosition();this.updateInputValue();this.lastWorldPosition=e;this.lastAngle=t}}};this.handleEndTransform=async i=>{var t,s;const n=F(l.create(i.clientX,i.clientY),this.getCanvasBounds());const o=this.getTransformWidget();this.lastDragged=this.dragging;this.dragging=undefined;this.lastWorldPosition=undefined;this.lastAngle=0;this.updateInputPosition();this.updateInputValue();o.updateCursor(n);o.updateTransform(this.currentTransform);this.beginEndTransform();window.removeEventListener("pointermove",this.handleDragWithTimer);window.removeEventListener("pointerup",this.handleEndTransform);try{const i=(t=this.controller)===null||t===void 0?void 0:t.getCurrentDelta();await((s=this.controller)===null||s===void 0?void 0:s.endTransform());this.interactionEnded.emit(i)}catch(i){console.error("Failed to end transform interaction",i)}window.addEventListener("pointermove",this.handlePointerMove);this.completeEndTransform()};this.handleInputStep=async i=>{if(this.inputValue!=null&&this.lastInputValue!=null){if(this.isModifyingAngleUnits()){const t=new m(this.angleUnit);const s=t.convertFrom(this.lastInputValue);const n=a.normalizeRadians(s+a.toRadians(i));this.inputValue=t.convertTo(n)}else{this.inputValue=this.lastInputValue+i}await this.updateTransformFromInput(this.inputValue)}};this.handleInputChange=async i=>{await this.updateTransformFromInput(i)};this.handleKeyDown=async i=>{const t=i.ctrlKey||i.metaKey;if(i.key==="z"&&t&&this.EXPERIMENTAL_undoKeybindings){i.stopPropagation();await this.EXPERIMENTAL_undo()}};this.updateTransformFromInput=async i=>{var t,s,n;if(this.lastDragged!=null&&this.currentTransform!=null&&this.startingTransform!=null&&this.lastInputValue!=null){this.currentTransform=J(this.currentTransform,this.lastDragged.identifier,i,this.lastInputValue,this.distanceUnit,this.angleUnit);this.updateInputValue();this.lastInputValue=i;await((t=this.controller)===null||t===void 0?void 0:t.beginTransform());this.getTransformWidget().updateTransform(this.currentTransform);await((s=this.controller)===null||s===void 0?void 0:s.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform)));this.updateInputPosition();await((n=this.controller)===null||n===void 0?void 0:n.endTransformDebounced(this.beginEndTransform,this.completeEndTransform))}};this.updatePropsFromViewer=()=>{const{frame:i}=this.viewer||{};if(i!=null){const t=this.getTransformWidget();t.updateFrame(i,this.dragging==null);this.updateInputPosition()}};this.setupTransformWidget=i=>{var t,s;console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null}]`);const n=this.getTranslationScalar();const o=this.getRotationScalar();this.widget=new ui(i,{colors:{xArrow:this.xArrowColor,yArrow:this.yArrowColor,zArrow:this.zArrowColor,twoAxesSquare:this.twoAxesSquareColor,hovered:this.hoveredColor},scalars:{xTranslation:n,yTranslation:n,zTranslation:n,xyTranslation:o,xzTranslation:o,yzTranslation:o,xRotation:o,yRotation:o,zRotation:o}});if(this.rotation!=null){this.currentTransform=this.getTransformForNewRotation(this.rotation);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(this.position!=null){this.currentTransform=this.getTransformForNewPosition(this.position);this.startingTransform=this.currentTransform;this.widget.updateTransform(this.currentTransform)}if(((s=this.viewer)===null||s===void 0?void 0:s.frame)!=null){this.widget.updateFrame(this.viewer.frame,true)}this.handleSettingDisabledAxis();this.hoveredChangeDisposable=this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);return this.widget};this.updateCanvasBounds=i=>{g((()=>{this.canvasBounds=i.getBoundingClientRect();this.getTransformWidget().updateDimensions(i)}))};this.updateInputValue=()=>{var i,t,s;const n=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const o=(n===null||n===void 0?void 0:n.identifier)==="xy-translate"||(n===null||n===void 0?void 0:n.identifier)==="xz-translate"||(n===null||n===void 0?void 0:n.identifier)==="yz-translate";if(n!=null&&this.currentTransform!=null&&this.dragStartTransform!=null&&!o){this.lastInputValue=this.inputValue;this.inputValue=V(n.identifier,this.currentTransform,this.dragStartTransform,this.distanceUnit,this.angleUnit);if(this.inputRef!=null){const i=(s=(t=this.getDisplayedDistance())!==null&&t!==void 0?t:this.getDisplayedAngle())!==null&&s!==void 0?s:0;const n=`${Number.parseFloat(i.toFixed(this.decimalPlaces))}`;this.inputRef.value=n}}};this.updateInputPosition=()=>{var i,t;const s=(i=this.dragging)!==null&&i!==void 0?i:this.lastDragged;const n=(s===null||s===void 0?void 0:s.identifier)==="xy-translate"||(s===null||s===void 0?void 0:s.identifier)==="xz-translate"||(s===null||s===void 0?void 0:s.identifier)==="yz-translate";if(this.showInputs&&((t=this.viewer)===null||t===void 0?void 0:t.frame)!=null&&this.position!=null&&s!=null&&!n){const i=this.getTransformWidget();const t=i.getFullBounds();this.inputPosition=t!=null?Y(this.viewer.viewport,t,s.points.toArray()):undefined}else if(n){this.inputPosition=undefined}};this.beginEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:true,yRotation:true,zRotation:true,xTranslation:true,yTranslation:true,zTranslation:true,xyTranslation:true,xzTranslation:true,yzTranslation:true});this.isEndingTransform=true};this.completeEndTransform=()=>{const i=this.getTransformWidget();i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled});this.isEndingTransform=false;this.inputShouldFocus=true;if(this.currentTransform!=null){this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}};this.isModifyingAngleUnits=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;return!!(n===null||n===void 0?void 0:n.includes("rotate"))};this.getTranslationScalar=()=>{if(this.translationHandleScalar>0){return this.translationHandleScalar}console.warn("Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getRotationScalar=()=>{if(this.rotationHandleScalar>0){return this.rotationHandleScalar}console.warn("Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.");return 1};this.getDisplayedUnits=()=>{if(this.isModifyingAngleUnits()){return new m(this.angleUnit)}return new b(this.distanceUnit)};this.getDisplayedAngle=()=>{if(this.isModifyingAngleUnits()){return this.inputValue}};this.getDisplayedDistance=()=>{var i,t,s;const n=(t=(i=this.dragging)===null||i===void 0?void 0:i.identifier)!==null&&t!==void 0?t:(s=this.lastDragged)===null||s===void 0?void 0:s.identifier;if(n===null||n===void 0?void 0:n.includes("translate")){return this.inputValue}};this.getTransformForNewPosition=i=>{if(i!=null){const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.transpose(d.makeRotation(c.fromMatrixRotation(t)));const n=d.makeTranslation(i);return d.multiply(s,n)}};this.getTransformForNewRotation=i=>{const t=this.currentTransform!=null?this.currentTransform:d.makeIdentity();const s=d.makeRotation(c.fromMatrixRotation(t));const n=d.makeRotation(c.fromEuler(i));const o=d.multiply(s,t);return d.multiply(d.transpose(n),o)};this.getCanvasBounds=()=>{if(this.canvasBounds!=null){return this.canvasBounds}else if(this.canvasRef!=null){this.updateCanvasBounds(this.canvasRef);return this.canvasBounds}};this.getTransformWidget=()=>{if(this.widget==null&&this.canvasRef!=null){return this.setupTransformWidget(this.canvasRef)}else if(this.widget!=null){return this.widget}else{throw new Error("Transform widget was not initialized. The canvas element may not have been initialized.")}}}componentDidLoad(){window.addEventListener("pointermove",this.handlePointerMove);this.canvasResizeObserver=new ResizeObserver(this.handleResize);this.inputResizeObserver=new ResizeObserver(this.handleInputResize);this.hostStyleObserver=new MutationObserver(this.handleStyleChange);if(this.canvasRef!=null){this.canvasResizeObserver.observe(this.canvasRef);this.setupTransformWidget(this.canvasRef)}this.hostStyleObserver.observe(this.hostEl,{attributes:true,attributeFilter:["style"]});this.handleViewerChanged(this.viewer,undefined);this.handleStyleChange()}disconnectedCallback(){var i,t,s,n,o;window.removeEventListener("pointermove",this.handlePointerMove);(i=this.canvasResizeObserver)===null||i===void 0?void 0:i.disconnect();(t=this.inputResizeObserver)===null||t===void 0?void 0:t.disconnect();(s=this.hostStyleObserver)===null||s===void 0?void 0:s.disconnect();(n=this.hoveredChangeDisposable)===null||n===void 0?void 0:n.dispose();(o=this.widget)===null||o===void 0?void 0:o.dispose()}componentDidRender(){if(this.inputShouldFocus&&this.inputRef!=null){B(this.inputRef);this.inputShouldFocus=false}}async EXPERIMENTAL_undo(){var i,t;const s=await((i=this.controller)===null||i===void 0?void 0:i.EXPERIMENTAL_undoTransform());if(this.currentTransform!=null&&s!=null){this.currentTransform=d.multiply(this.currentTransform,s);(t=this.widget)===null||t===void 0?void 0:t.updateTransform(this.currentTransform);this.updateInputPosition();this.updateInputValue();this.lastInputValue=this.inputValue;this.position=h.fromMatrixPosition(this.currentTransform);this.rotation=u.fromRotationMatrix(this.currentTransform)}}handleViewerChanged(i,t){var s;t===null||t===void 0?void 0:t.removeEventListener("frameDrawn",this.handleViewerFrameDrawn);t===null||t===void 0?void 0:t.removeEventListener("dimensionschange",this.handleViewerDimensionsChange);i===null||i===void 0?void 0:i.addEventListener("frameDrawn",this.handleViewerFrameDrawn);i===null||i===void 0?void 0:i.addEventListener("dimensionschange",this.handleViewerDimensionsChange);if((i===null||i===void 0?void 0:i.stream)!=null){(s=this.controller)===null||s===void 0?void 0:s.dispose();this.controller=new y(i.stream)}}handleDisabledPropertyChanged(){var i;(i=this.widget)===null||i===void 0?void 0:i.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}handleTransformHandleScalarChanged(){var i;const t=this.getTranslationScalar();const s=this.getRotationScalar();(i=this.widget)===null||i===void 0?void 0:i.updateScalars({xTranslation:t,yTranslation:t,zTranslation:t,xyTranslation:s,xzTranslation:s,yzTranslation:s,xRotation:s,yRotation:s,zRotation:s})}handleRotationChanged(i,t){var s;const n=i!==null&&i!==void 0?i:u.create();this.currentTransform=this.getTransformForNewRotation(n);this.startingTransform=this.currentTransform;if(i==null&&this.currentTransform!=null&&d.isIdentity(this.currentTransform)){this.currentTransform=undefined;this.startingTransform=this.currentTransform}(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);console.debug(`Updating widget rotation [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);this.rotationChanged.emit(i)}handlePositionChanged(i,t){var s,n;this.currentTransform=this.getTransformForNewPosition(i);this.startingTransform=this.currentTransform;console.debug(`Updating widget position [previous=${JSON.stringify(t)}, current=${JSON.stringify(i)}]`);(s=this.widget)===null||s===void 0?void 0:s.updateTransform(this.currentTransform);if(i==null){this.lastDragged=undefined;this.inputPosition=undefined;(n=this.controller)===null||n===void 0?void 0:n.clearTransform()}this.positionChanged.emit(i)}handleInputFormattingChanged(){this.updateInputValue();this.lastInputValue=this.inputValue}render(){var t,s,o,l,h,e;return i(n,{key:"fdc062cb3cafa311baca827e03a765052e1ab2c8"},i("canvas",{key:"c6c9d413e971ef3db3b3eed7e9ff6c8387fff1d1",ref:i=>{this.canvasRef=i},class:p("widget",{hovered:this.hovered!=null}),tabindex:"0",width:(t=this.viewer)===null||t===void 0?void 0:t.viewport.width,height:(s=this.viewer)===null||s===void 0?void 0:s.viewport.height,onPointerDown:this.handleBeginDrag,onKeyDown:this.handleKeyDown}),this.showInputs&&this.inputPosition&&((o=this.viewer)===null||o===void 0?void 0:o.viewport)&&i(ii,{key:"7eb3550df7db8c95f3597d1bd8d7b05c70e11696",ref:i=>{var t,s;if(i!=null){(t=this.inputResizeObserver)===null||t===void 0?void 0:t.observe(i)}else if(this.inputRef!=null){(s=this.inputResizeObserver)===null||s===void 0?void 0:s.unobserve(this.inputRef)}this.inputWrapperRef=i},bounds:this.inputBounds,viewport:this.viewer.viewport,point:this.inputPosition.point,placement:this.inputPosition.placement,displayUnit:this.getDisplayedUnits()},i(ti,{key:"84e2ff6825856c6d5f0ffff1771861ed6087bedb",ref:i=>{this.inputRef=i},identifier:(h=(l=this.dragging)===null||l===void 0?void 0:l.identifier)!==null&&h!==void 0?h:(e=this.lastDragged)===null||e===void 0?void 0:e.identifier,disabled:this.isEndingTransform,onChange:this.handleInputChange,onIncrement:()=>this.handleInputStep(1),onDecrement:()=>this.handleInputStep(-1),onBlur:()=>{this.inputShouldFocus=false},onUndo:this.EXPERIMENTAL_undoKeybindings?()=>this.EXPERIMENTAL_undo():undefined})))}transform(i,t,s){var n,o;if(this.position!=null&&this.startingTransform!=null&&this.currentTransform!=null&&this.dragging!=null&&this.viewer!=null&&this.viewer.frame!=null){this.currentTransform=L(this.currentTransform,i,t,(n=this.viewer)===null||n===void 0?void 0:n.frame.scene.camera.viewVector,s,this.dragging.identifier);this.getTransformWidget().updateTransform(this.currentTransform);(o=this.controller)===null||o===void 0?void 0:o.updateTransform(d.multiply(d.invert(this.startingTransform),this.currentTransform))}}handleSettingDisabledAxis(){if(this.widget){this.widget.updateDisabledAxis({xRotation:this.xRotationDisabled,yRotation:this.yRotationDisabled,zRotation:this.zRotationDisabled,xTranslation:this.xTranslationDisabled,yTranslation:this.yTranslationDisabled,zTranslation:this.zTranslationDisabled,xyTranslation:this.xyTranslationDisabled,xzTranslation:this.xzTranslationDisabled,yzTranslation:this.yzTranslationDisabled})}else{console.warn("Cannot set disabled values - no widget defined")}}get hostEl(){return o(this)}static get watchers(){return{viewer:[{handleViewerChanged:0}],xTranslationDisabled:[{handleDisabledPropertyChanged:0}],yTranslationDisabled:[{handleDisabledPropertyChanged:0}],zTranslationDisabled:[{handleDisabledPropertyChanged:0}],xyTranslationDisabled:[{handleDisabledPropertyChanged:0}],xzTranslationDisabled:[{handleDisabledPropertyChanged:0}],yzTranslationDisabled:[{handleDisabledPropertyChanged:0}],xRotationDisabled:[{handleDisabledPropertyChanged:0}],yRotationDisabled:[{handleDisabledPropertyChanged:0}],zRotationDisabled:[{handleDisabledPropertyChanged:0}],translationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotationHandleScalar:[{handleTransformHandleScalarChanged:0}],rotation:[{handleRotationChanged:0}],position:[{handlePositionChanged:0}],distanceUnit:[{handleInputFormattingChanged:0}],angleUnit:[{handleInputFormattingChanged:0}],decimalPlaces:[{handleInputFormattingChanged:0}]}}};ci.style=vi();export{ci as vertex_viewer_transform_widget};
5
+ //# sourceMappingURL=p-fec5a15d.entry.js.map