胶州空管前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1 lines
2.2 MiB

!function(){"use strict";var e=window.Glodon=window.Glodon||{};e.Version="2024-10-16-16-6",function(){function t(e,t){let i=t.split("."),n=e,o=i.length;for(let e=0;e<o;e++)void 0===n[i[e]]&&(n[i[e]]={}),n=n[i[e]];return n}t(e,"Web.Lang.Utility.Namespace").ensureNamespace=t}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Common"),i=function(e){"string"==typeof e&&(e=JSON.parse(res)),this.code=e.code,this.message=e.message};i.prototype={getErrorCode:function(){return this.code},getErrorMessage:function(){return this.message}},t.Error=i}(),function(t){const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Common.Flexible");let n=!1,o=!1,s="37.5px";var r,a=t.document,l=a.documentElement,h=a.querySelector('meta[name="viewport"]');if(t.addEventListener("resize",(function(){clearTimeout(r),r=setTimeout(c,300)}),!1),t.addEventListener("pageshow",(function(e){e.persisted&&(clearTimeout(r),r=setTimeout(c,300))}),!1),!h)if((h=a.createElement("meta")).setAttribute("name","viewport"),h.setAttribute("content","initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"),l.firstElementChild)l.firstElementChild.appendChild(h);else{var d=a.createElement("div");d.appendChild(h),a.write(d.innerHTML)}function c(){let e=t.screen.availWidth||375,i=t.screen.availHeight||667;n=e>i;var r=navigator.userAgent,a=/(?:Android)/.test(r),l=/(?:Firefox)/.test(r),h=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;o=/(?:iPad|PlayBook)/.test(r)||a&&!/(?:Mobile)/.test(r)||l&&/(?:Tablet)/.test(r)||h;var d=Math.min(e,i);e=d<=320?320:d>320&&d<=414?d:d>414&&d<1024?420:450,s=e/10+"px"}c();i.getIsHorizontal=()=>n,i.getIsTablet=()=>o,i.getFontSize=()=>s}(window);class t{constructor(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}clone(){return new this.constructor(this.x,this.y,this.z)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}distanceToSquared(e){var t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}}class i{constructor(e,i){this.min=e||new t(1/0,1/0,1/0),this.max=i||new t(-1/0,-1/0,-1/0)}getSize(){return new t(this.max.x-this.min.x,this.max.y-this.min.y,this.max.z-this.min.z)}setFromCenterAndSize(e,i){let n=new t(i.x,i.y).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}getCenter(){return new t(this.min.x+this.max.x,this.min.y+this.max.y,this.min.z+this.max.z).multiplyScalar(.5)}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}union(e){return this.min.min(e.min),this.max.max(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}expandByPoint(e){return this.min.min(e),this.max.max(e),this}setFromPoints(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}}!function(){let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Algorithm");n.MeanShift=class{constructor(e,t){this.points=e,this.searchRangeSquared=t**2,this.EPSILON_SQR=.1,this.clusters=[]}setSearchRange(e){this.searchRangeSquared=e**2}setPoints(e){this.points=e}meanShift(e){let t=e.clone(),i=[];for(;;){let e=this.rangeSearch(t);i=this.connect(i,e);let n=this.mean(e);if(t.distanceToSquared(n)<=this.EPSILON_SQR)break;t=n}return i}mean(e){let i=new t;for(const t of e)i.add(t);return i.multiplyScalar(1/e.length),i}rangeSearch(e){let t=[];for(const i of this.points)e.distanceToSquared(i)<=this.searchRangeSquared&&t.push(i);return t}clustering(e,t){0===this.clusters.length?this.clusteringPrepare():this.clusteringAfter(e,t),this.clusters.forEach((e=>{this.resetPointStatus(e.points)}))}clusteringPrepare(){for(const e of this.points){if(e.stopMoving)continue;const t=this.meanShift(e),i=t.length,n=`${t[0].index}_${i}`;this.mergeClusters({points:t,center:this.mean(t),id:n,parent:null,children:[]})}}clusteringAfter(e,t){this.tmpPoints=this.points,this.points=[];let i=[...this.clusters];if(this.clusters=[],!1!==e){for(let e=0;e<i.length;e++){const n=i[e];let o=[];t||this.resetClusterPoints(n.points),this.points=n.points,this.clusteringZoomIn(n,o),this.clusters.push.apply(this.clusters,o)}this.clusters.forEach((e=>{this.resetPointStatus(e.points)}))}else this.clusteringZoomOut(i,t)}clusteringZoomIn(e,t){for(const i of e.points){if(i.stopMoving)continue;const n=this.meanShift(i),o=n.length,s=`${n[0].index}_${o}`;this.mergeClustersInTarget({points:n,center:this.mean(n),id:s,parent:e.id,children:[]},t)}}clusteringZoomOut(e,t){for(let i=0;i<e.length;i++){const n=e[i];t||this.resetClusterPoints(n.points),n.center=this.mean(n.points),this.updateClusterBbox(n),n.children=[],n.parent=null,n.isMerged=!1}for(let t=0;t<e.length;t++){const i=Object.assign({},e[t]);if(!0===i.isMerged)continue;let n=[i.id];for(let o=t+1;o<e.length;o++){const t=e[o];if(!0===t.isMerged)continue;i.center.distanceToSquared(t.center)<=4*this.searchRangeSquared&&(t.isMerged=!0,i.points=this.connect(i.points,t.points,!0),n.push(t.id))}if(i.isMerged=!0,n.length>1){i.center=this.mean(i.points),this.updateClusterBbox(i);const e=i.points.length,t=`${i.points[0].index}_${e}`;i.id=t,i.children=n}this.clusters.push(i)}this.clusters.forEach((e=>{delete e.isMerged,this.resetPointStatus(e.points)}))}mergeClusters(e){let t=!1;for(const i of this.clusters){const n=e.center.distanceToSquared(i.center)<=4*this.searchRangeSquared,o=i.parent==i.parent;if(n&&o){i.points=this.connect(i.points,e.points,!0),i.center=this.mean(i.points),this.updateClusterBbox(i);const n=i.points.length,o=`${i.points[0].index}_${n}`;i.id=o,i.children=[],t=!0;break}}!1===t&&(this.updateClusterBbox(e),this.clusters.push(e))}mergeClustersInTarget(e,t){let i=!1;for(const n of t){if(e.center.distanceToSquared(n.center)<=4*this.searchRangeSquared){n.points=this.connect(n.points,e.points,!0),n.center=this.mean(n.points),this.updateClusterBbox(n);const t=n.points.length,o=`${n.points[0].index}_${t}`;n.id=o,n.children=[],i=!0;break}}!1===i&&(this.updateClusterBbox(e),t.push(e))}removeNodeFromParents(e,t){let i=t.indexOf(e);i>=0&&t.splice(i,1)}updateClusterBbox(e){let t=(new i).setFromPoints(e.points);e.bbox=t}connect(e,t,i){let n=[...e];for(const e of t)e.stopMoving&&!i||n.push(e),e.stopMoving=!0;return n}resetPointStatus(e){for(const t of e)t.stopMoving=!1}resetClusterPoints(e){for(let t=0;t<e.length;t++)for(let i=0;i<this.tmpPoints.length;i++)if(e[t].index===this.tmpPoints[i].index){e[t]=this.tmpPoints[i];break}}}}();class n{constructor(e,t){this.x=e||0,this.y=t||0}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}normalize(){return this.multiplyScalar(1/this.length())}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}addScalar(e){return this.x+=e,this.y+=e,this}rotateAround(e,t){var i=Math.cos(t),n=Math.sin(t),o=this.x-e.x,s=this.y-e.y;return this.x=o*i-s*n+e.x,this.y=o*n+s*i+e.y,this}setLength(e){return this.multiplyScalar(e/this.length())}angle(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e}distanceToSquared(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}}class o{constructor(e,t){this.min=e||new n(1/0,1/0),this.max=t||new n(-1/0,-1/0)}getSize(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}setFromCenterAndSize(e,t){let i=new n(t.x,t.y).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}getCenter(){return new n(this.min.x+this.max.x,this.min.y+this.max.y).multiplyScalar(.5)}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}union(e){return this.min.min(e.min),this.max.max(e.max),this}expandByPoint(e){return this.min.min(e),this.max.max(e),this}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Algorithm");class i{constructor(){}}i.toThreeJsBox2=function(e,t=0){let i=[];for(const s of e){let e=Math.min(t,100)/100,r=Math.max(s[1][1]-s[0][1],s[1][0]-s[0][0])*e,a=new n(s[0][0],s[0][1]),l=new n(s[1][0],s[1][1]),h=new o(a,l),d=h.getSize();i.push((new o).setFromCenterAndSize(h.getCenter(),d.addScalar(2*r)))}let s=0;for(const e of i)e.indices=[s++];return i},i.toDrawingBox2=function(e){let t=[];for(const i of e){let e=[];e.push([i.min.x,i.min.y]),e.push([i.max.x,i.max.y]),t.push(e)}return t},i.merge=function(e,t){let i=e.length;for(let n=0;n<=i;n++){if(n===i){e.push(t);break}let o=e[n];if(o.intersectsBox(t)){o.union(t),o.indices=o.indices.concat(t.indices);break}}},i.mergeBoundingBox=function(e){let t=e,n=[];for(;;){for(let e=0;e<t.length;e++)i.merge(n,t[e]);if(n.length===t.length)break;t=n.slice(0,n.length),n=[]}return n},t.BoundingBoxUtil=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Type").inheritPrototype=function(e,t){var i=function(e){function t(){}return t.prototype=e,new t}(t.prototype);i.constructor=e,e.prototype=i},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),i={},n=function(e,t){var i=Object.assign({type:"get",cache:!0,headers:{"Content-type":"application/x-www-form-urlencoded"},data:null,async:!0,success:null,failure:null},e);const n=e=>{i.success&&i.success(e.responseText,e.responseXML)},o=e=>{i.failure&&i.failure(e)},s=(e,t)=>{var n;(n=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")).onreadystatechange=function(){if(4==n.readyState){var i=n.status;if(i>=200&&i<300||304==i||0===i&&"file:"===window.location.protocol){let{responseText:t,responseXML:i}=n;e({responseText:t,responseXML:i})}else t(i)}},n.open(i.type,i.url,i.async);for(let e in i.headers)n.setRequestHeader(e,i.headers[e]);n.send(i.data)};t?CLOUD.Storage.IndexedDBHelper.loadWithStorage("InfoData",i.url,(()=>new Promise(s)),n,o):s(n,o)},o=function(e,t,n){if(void 0===i[e]){let o=document.createElement("script");o.type="text/javascript",o.src=e,document.head.appendChild(o),i[e]={callbacks:[],failCallbacks:[]},i[e].callbacks.push(t),i[e].failCallbacks.push(n),o.readyState?o.onreadystatechange=function(){"loaded"==o.readyState||"complete"==o.readyState?(o.onreadystatechange=null,i[e].callbacks.map((e=>{e&&e()})),i[e]=!0):"uninitialized"==o.readyState&&(o.onreadystatechange=null,i[e].failCallbacks.map((e=>{e&&e()})),i[e]=!1)}:(o.onload=function(){i[e].callbacks.map((e=>{e&&e()})),i[e]=!0},o.onerror=function(){i[e].failCallbacks.map((e=>{e&&e()})),i[e]=!1})}else!0===i[e]?t&&t():!1===i[e]?n&&n():(i[e].callbacks.push(t),i[e].failCallbacks.push(n))},s=function(e,t,i){let o;return o="string"==typeof e?{url:e,status:t}:e,new Promise((function(e,s){n(Object.assign({},o,{success:function(i){try{var n=JSON.parse(i)}catch(t){return e(i)}"success"==n.code||"noCode"==o.status||"bimfaceservice-0000"==n.code?e("noCode"==t?n:n.data):s(`requestError,dataCode:${n.code}, dataMessage:${n.message}`)},failure:e=>{s(e)}}),i)}))},r={singleModel:"fileId",integrateModel:"integrateId",compareModel:"compareId"};t.ajax=n,t.promiseJSONRequest=s,t.getScript=o,t.getScripts=function(e,t){e.length<=1?o(e.shift(),t):Promise.all(e.map((e=>new Promise(((t,i)=>{o(e,(()=>{t()}))}))))).then((()=>{t&&t()}))},t.promiseJsonFunction=function(e){if("Fast"===(e.loadMode||"Fast"))return s(e.url,e.status,e.enableStorage);{let{APIHost:t,path:i,fileId:n,viewToken:o,modelType:a}=e;return s(`${t}/data/v1/databag/resource-stream?${r[a]||"fileId"}=${n}&view_token=${o}&path=${i}`,e.status,e.enableStorage)}},t.getUrl=function(e){if("Strict"==(e.loadMode||"Fast")){let{APIHost:t,path:i,fileId:n,viewToken:o,modelType:s,workerType:a}=e;return`${t}/data/v1/databag/resource-stream?${a?"workerType="+a+"&":""}${r[s]||"fileId"}=${n}&view_token=${o}&path=${i}`}return e.url}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.FullScreen");t.fullScreen=function(e){if(!e)return!1;e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()},t.exitFullScreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()},t.onFullScreenChanged=function(e){var t=function(){e&&e()};document.onfullscreenchange=t,"onwebkitfullscreenchange"in document?document.onwebkitfullscreenchange=t:document.documentElement.onwebkitfullscreenchange=t,document.onmozfullscreenchange=t,document.onmsfullscreenchange=t},t.isFullScreen=function(){return document.webkitIsFullScreen||!!document.mozFullScreenElement||!!document.msFullScreenElement||!1}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.ClientHelper"),i=null;if(t.getIsDesktop)return;var n=function(e,t,i){i=i||"asc";var n=!1;return t?t.indexOf(".")>-1&&(n=!0):t="name",e=e.sort((function(e,o){if(n){var s=r(e,t),a=r(o,t);return"asc"==i?s.localeCompare(a):a.localeCompare(s)}return"asc"==i?e[t].localeCompare(o[t]):o[t].localeCompare(e[t])})),s(e,t,n)};var o=function(e,t){return function(i,n){var o,s;t?(o=r(i,e),s=r(n,e)):(o=i[e],s=n[e]);var a,l,h=1,d=0,c=0,u=String.alphabet;function g(e,t,i){if(i){for(a=t;(i=g(e,a))<76&&i>65;)++a;return+e.slice(t-1,a)}return(i=u&&u.indexOf(e.charAt(t)))>-1?i+76:(i=e.charCodeAt(t)||0)<45||i>127?i:i<46?65:i<48?i-1:i<58?i+18:i<65?i-11:i<91?i+11:i<97?i-37:i<123?i+5:i-63}if((o+="")!=(s+=""))for(;h;)if(l=g(o,d++),h=g(s,c++),l<76&&h<76&&l>66&&h>66&&(l=g(o,d,d),h=g(s,c,d=a),c=a),l!=h)return l<h?-1:1;return 0}},s=function(e,t,i){let n=[],o=[],s=[],a=[];return e.map((function(e,l){var h;h=i?r(e,t):e[t],/^[a-zA-Z]*$/.test(h.slice(0,1))?n.push(e):/^[\u4e00-\u9fa5]*$/.test(h.slice(0,1))?o.push(e):/^\d+(\.\d+)?$/.test(h.slice(0,1))?s.push(e):a.push(e)})),a.concat(s,n,o)},r=function(e,t){var i=t.split("."),n=e;return i.map((function(e,t){n=n[e]})),n};t.getIsDesktop=function(){if("Mobile"===i)return!1;if("Web"===i)return!0;var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),n=/(?:SymbianOS)/.test(e)||t,o=/(?:Android)/.test(e),s=/(?:Firefox)/.test(e),r=(/(?:Chrome|CriOS)/.test(e),/(?:iPad|PlayBook)/.test(e)||o&&!/(?:Mobile)/.test(e)||s&&/(?:Tablet)/.test(e)),a=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;return!(/(?:iPhone)/.test(e)&&!r||o||n||r||a)},t.getIsMac=()=>/macintosh|mac os x/i.test(navigator.userAgent),t.getIsChrome=()=>/(?:Chrome|CriOS)/.test(navigator.userAgent),t.setNavigatorType=function(e){i=e},t.getIsIphone=function(){var e=navigator.userAgent;return/(?:iPhone)/.test(e)},t.getIsTablet=function(){var e=navigator.userAgent,t=/(?:Android)/.test(e),i=/(?:Firefox)/.test(e),n=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;return/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||i&&/(?:Tablet)/.test(e)||n},t.getDeviceType=function(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),i=/(?:SymbianOS)/.test(e)||t,n=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),s=/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),r=/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1,a=/(?:iPhone)/.test(e)&&!s;return s||r?"PAD":a||n||i?"MOBILE":"PC"},t.getBrowserType=function(){var e=navigator.userAgent,t="";return e.indexOf("Opera")>-1||e.indexOf("OPR")>-1?t="Opera":e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1||window.ActiveXObject||"ActiveXObject"in window?t="IE":e.indexOf("Edge")>-1?t="Edge":e.indexOf("Firefox")>-1?t="Firefox":e.indexOf("Safari")>-1&&-1==e.indexOf("Chrome")?t="Safari":e.indexOf("Safari")>-1&&e.indexOf("Chrome")>-1&&(t="Chrome"),t},t.getBrowserVersion=function(){var e,t={},i=navigator.userAgent.toLowerCase();return(e=i.match(/rv:([\d.]+)\) like gecko/))||(e=i.match(/msie ([\d\.]+)/))?t.ie=e[1]:(e=i.match(/edge\/([\d\.]+)/))?t.edge=e[1]:(e=i.match(/firefox\/([\d\.]+)/))?t.firefox=e[1]:(e=i.match(/(?:opera|opr).([\d\.]+)/))?t.opera=e[1]:(e=i.match(/chrome\/([\d\.]+)/))?t.chrome=e[1]:(e=i.match(/version\/([\d\.]+).*safari/))&&(t.safari=e[1]),t.ie?t.ie:t.edge?t.edge:t.firefox?t.firefox:t.chrome?t.chrome:t.opera?t.opera:t.safari?t.safari:"Unkonwn"},t.formatTime=(e="",t=(new Date).getTime())=>{let i,n,o;e=e||"YYYY-mm-dd HH:MM:SS",n=10==t.toString().length?new Date(1e3*parseInt(t)):new Date(parseInt(t));const s={Y:n.getFullYear().toString(),m:(n.getMonth()+1).toString(),d:n.getDate().toString(),H:n.getHours().toString(),M:n.getMinutes().toString(),S:n.getSeconds().toString()};for(var r in s)i=new RegExp("("+r+"+)").exec(e),i&&(o=1==i[1].length?s[r]:s[r].padStart(i[1].length,"0"),e=e.replace(i[1],o));return e},t.getDesktopType=function(){var e=navigator.userAgent.toLowerCase(),t="",i="";return e.indexOf("win")>-1?(t="Windows",e.indexOf("windows nt 5.0")>-1?t="Windows 2000":e.indexOf("windows nt 5.1")>-1||e.indexOf("windows nt 5.2")>-1?t="Windows XP":e.indexOf("windows nt 6.0")>-1?t="Windows Vista":e.indexOf("windows nt 6.1")>-1||e.indexOf("windows 7")>-1?t="Windows 7":e.indexOf("windows nt 6.2")>-1||e.indexOf("windows 8")>-1?t="Windows 8":e.indexOf("windows nt 6.3")>-1?t="Windows 8.1":(e.indexOf("windows nt 6.2")>-1||e.indexOf("windows nt 10.0")>-1)&&(t="Windows 10"),e.indexOf("win64")>-1?i="win64":e.indexOf("win32")>-1&&(i="win32")):e.indexOf("mac")>-1?t="Mac":e.indexOf("x11")>-1||e.indexOf("unix")>-1||e.indexOf("sunname")>-1||e.indexOf("bsd")>-1?t="Unix":e.indexOf("linux")>-1&&(t="Linux"),{name:t,type:i}},t.getIsIE=function(){return!(!window.ActiveXObject&&!("ActiveXObject"in window))},t.formatURL=function(e){var t=function(e){return e.replace("viewToken.json","").replace(/\.\//g,"/").replace(/\/\//g,"/")};if(e.indexOf("://")>-1){var i=e.split("://");e=i[0]+"://"+t(i[1])}else e="//"===e.slice(0,2)?"//"+t(e.slice(2)):"./"!=e.slice(0,2)?t(e):"."+t(e.slice(1));return e},t.sortByName=n,t.sortByRules=function(e,t,i){i=i||"asc";var n=!1;return t?t.indexOf(".")>-1&&(n=!0):t="name",e=e.sort(o(t,n)),s(e,t,n)},t.PointToLineDistance=function(e,t,i,n,o,s){let r,a,l,h,d=0;const c=Math.sqrt((i-e)*(i-e)+(n-t)*(n-t));if(0===c)return[0,{x:i,y:n}];const u=Math.sqrt((o-e)*(o-e)+(s-t)*(s-t));if(0===u)return[0,{x:o,y:s}];const g=Math.sqrt((i-o)*(i-o)+(n-s)*(n-s));if(0===g)return d=c,[d,{x:i,y:n}];if(c<u){if(n===s?r=i<o?0:Math.PI:(h=(o-i)/g,h-1>1e-5&&(h=1),r=Math.acos(h),n>s&&(r=2*Math.PI-r)),h=(e-i)/c,h-1>1e-5&&(h=1),a=Math.acos(h),n>t&&(a=2*Math.PI-a),l=a-r,l<0&&(l=-l),l>Math.PI&&(l=2*Math.PI-l),l>Math.PI/2)return[c,{x:i,y:n}];if(i===o)return[u*Math.sin(l),{x:i,y:t}];if(n===s)return[u*Math.sin(l),{x:e,y:n}];let d=0,p=0;const m=(s-n)/o-i,f=-1/m,w=t-e*f;return d=(s-o*m-w)/(f-m),p=f*d+w,[c*Math.sin(l),{x:d,y:p}]}if(n===s?r=i<o?Math.PI:0:(h=(i-o)/g,h-1>1e-5&&(h=1),r=Math.acos(h),s>n&&(r=2*Math.PI-r)),h=(e-o)/u,h-1>1e-5&&(h=1),a=Math.acos(h),s>t&&(a=2*Math.PI-a),l=a-r,l<0&&(l=-l),l>Math.PI&&(l=2*Math.PI-l),l>Math.PI/2)return[u,{x:o,y:s}];if(i===o)return[u*Math.sin(l),{x:i,y:t}];if(n===s)return[u*Math.sin(l),{x:e,y:n}];let p=0,m=0;const f=(s-n)/o-i,w=-1/f,y=t-e*w;return p=(s-o*f-y)/(w-f),m=w*p+y,[u*Math.sin(l),{x:p,y:m}]},t.isWebGLAvailable=function(){try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},t.isWebGL2Available=function(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},t.sortByGroupName=function(e,t,i,o){let s=((e,t)=>e.reduce(((e,i)=>({...e,[i[t]]:[...e[i[t]]||[],i]})),{}))(e,t),r=[];for(let e in s)r=[...r,...n(s[e],i,o)];return r}}();var s,r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAbCAYAAAH3zbSEAAAAAXNSR0IArs4c6QAAAn5JREFUSA29lr9uGkEQxu8A47MTKSf5j2RbjnDhAAUVVKbhBeiiNHmLPIxbt64i+QF4A3iBpEiUIkWUCEVBcSz/uXy/1S1aH3fxcoKM9LG7szv77c7MzhEEQRAKFWEutXkvCKoMqkmS3Foly+vCa6ugjdwBm907imoo+8QqwjCMavp5axVqzWTUarWuNKg6E/MurJvCS2F+lHR2Q+0XFkSiuU6VjxrRbaHg3OyyIJVut3sj7cHCjBTWOZ+zkzJKrLMa2UnGISvyJtAZy/F4vDDf6/VMUAaaOVyYDYKv6OpsPZ1Ok06nc6Hxs5yFharNfr9/qdmGkOvuIksTBjH/KVpQpJ9MJhF+fCha8ITe2EXcOU/+pdfGhrmQIC8E7mLuDEgzmwrufFGfI99iiIcJNv27FGqeliPuOhwOyekTwZu9KSPSeSAslRg8r7NljbhXLNBOBR/ZZhFOiRW7Tz4Wdo0y6QSmhrArfBd8xKzFcE+M33ws7Box7mN4qmh8sEqfVmXnFTHzjpuzaaWMkbEvbUg4ZjrzG7Uku49Qi2c4x01yH0PK4p013FJIfmWt4jg+H41G76SHpWzlyG5rxnwETqkaVFAeS7vdfi8duX8k8D0r7UfZ5gqbGtKUbKBxQ+CFLlWFtd5LcC+BfCHwQCkJPFDqifuB1rC0wAHwFiFK6KCoyb0fUQgIB8EDqwAeO9D+5MWesEHqQmyLXUv9mUC5XZXA8TzdjPYnt+QfxU6K3yiFVZMSPurljxSG9JjsdWUdYxEeC3VcC0zVVrtugQc+kyzN7M3cW6+iz/7iasJnWGH+n0JmcQJT4vj3t2Yx75Tsperwx9hm2DpuD5l9Gdd/AVIlXMI9fgkPAAAAAElFTkSuQmCC",a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAABBpJREFUWAntVUtLG1EUniRjEo2amKjVxBiFqlAXRUVFEBFKF6KLgii47kIKXVX36rra0lXRnd1IFftYqFAoBFyJ2AdUixqoMU18a3ylSZwk/b6pCRmfP6AZuJlz7znfd8797rkTQUg9KQVSCqQUSClwgwKxWEzV0NBgrq6u/tbf36/m/IZw2cUYxhJD7G0Y9XWEJGlsbKw5Ozv7qlKp7h8eHuoGBgZuLYAxjCWGWHKQ67o8VxISMDMz8yASiUyUlZUZV1ZWhNra2jvRaPTAarVGpqamHsF+AVLHObFbrVY/a21t/eDz+TSwc+bn57fKy8uF1dXVQ41G09HS0vIZvNGLhVyqjMmR4LEkSZ/a2tqMw8PDMgZzQzgc1kxPT7cj+WRzc7ODPg7aXKOPMYwliD5ykIucVymhKKCjo4MJXoFspKurS+jr6xOysrLkAtLS0rSwtfANIaEwODgo1NTUyIM21+hjDGMJIpYc5CInuZlDJjz/kQtgo9TV1VnW1tZGIftTVCr09PQkxwk4U7Xb7S5ErJ2EFx+u0RcKhQyMTfaTi5zkZg7mijenHNjZ2aluamoK4ux0ycBkGzvQYGeyHNzZdQ+SZzL2Oj9zMBdzMkb+qaysVB0dHaVXVVU9B/l7Vjs0NKTg4K4sFksIBDsjIyMKHydjY2MCfUjOY1I0N7nISW7mYC7mJE4hFSSKVVRUvMvPz39LQlwp4fj4mHGJJzc3943T6RR6e3uFhYUFgTeENtfgG00EwiCWHOQiJ7mZIzlGPJ/wegS0Wu02Agx2u33GYDD40LlPlpeX9YzBmUUxwkVFRU7s1DQ7O9uOpCb6cM38BQUFkzabzQmlwhjyUXZ3dwsulytYWlr62mw2f8f6b+bA9yEAmHwlE1KxOx0Ohx7yWJDADhkdfr+/en19vQsAa319/T1cJz9IbPDdxTsfI50FoLA/GNvAufD2iqJompubW0LP+IqLi8dMJtMX+NzAebKzs/fQzMGJiYkIsYlmWVpaimEHUcgYCgQCQZBIOp3uBIAf+/v7FbA/Go3GDRTBZpWADeN9iiL8SLoF28PkiDvd3d214mv4EB+ilzj3n/D9wvdhHfaex+MJxZOzgIQCnPBBs6hxVbR6vT4bUxtIefUkyOzC2sbBwUEMdgZGJpLLUsMfwtGdYARycnJUwWCwEDZVEjE2wOPF2lFJSUkY/Iqv4aUC4kXgLe7s7GShcgtsqJm2h/k+uldaXFwkToNzl/Gbm5tsrAh8MfjEvLw8M46NuDOc+R7m7GTpYnKsXVaAi3ywKxWaCCch6kAi4ljC2L1Cvn+Ryl/2ElTQZWRkaFE8TkwK4ZMsQQlF98dRimsYX+SbAAJxfQJer/cYf0LB8fFxhXzJ8XGbMYwlhtibkscxqXdKgf9bgb8e4D98kWiZrgAAAABJRU5ErkJggg==",l="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjFweCIgaGVpZ2h0PSIyMXB4IiB2aWV3Qm94PSIwIDAgMjEgMjEiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+5b2i54q257uT5ZCIPC90aXRsZT4KICAgIDxkZWZzPgogICAgICAgIDxwYXRoIGQ9Ik0xMSw1IEwxMSwxMCBMMTYsMTAgTDE2LDExIEwxMSwxMSBMMTEsMTYgTDEwLDE2IEwxMCwxMSBMNSwxMSBMNSwxMCBMMTAsMTAgTDEwLDUgTDExLDUgWiIgaWQ9InBhdGgtMSI+PC9wYXRoPgogICAgICAgIDxmaWx0ZXIgeD0iLTYzLjYlIiB5PSItNjMuNiUiIHdpZHRoPSIyMjcuMyUiIGhlaWdodD0iMjI3LjMlIiBmaWx0ZXJVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giIGlkPSJmaWx0ZXItMiI+CiAgICAgICAgICAgIDxmZU1vcnBob2xvZ3kgcmFkaXVzPSIxIiBvcGVyYXRvcj0iZGlsYXRlIiBpbj0iU291cmNlQWxwaGEiIHJlc3VsdD0ic2hhZG93U3ByZWFkT3V0ZXIxIj48L2ZlTW9ycGhvbG9neT4KICAgICAgICAgICAgPGZlT2Zmc2V0IGR4PSIwIiBkeT0iMCIgaW49InNoYWRvd1NwcmVhZE91dGVyMSIgcmVzdWx0PSJzaGFkb3dPZmZzZXRPdXRlcjEiPjwvZmVPZmZzZXQ+CiAgICAgICAgICAgIDxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjIiIGluPSJzaGFkb3dPZmZzZXRPdXRlcjEiIHJlc3VsdD0ic2hhZG93Qmx1ck91dGVyMSI+PC9mZUdhdXNzaWFuQmx1cj4KICAgICAgICAgICAgPGZlQ29tcG9zaXRlIGluPSJzaGFkb3dCbHVyT3V0ZXIxIiBpbjI9IlNvdXJjZUFscGhhIiBvcGVyYXRvcj0ib3V0IiByZXN1bHQ9InNoYWRvd0JsdXJPdXRlcjEiPjwvZmVDb21wb3NpdGU+CiAgICAgICAgICAgIDxmZUNvbG9yTWF0cml4IHZhbHVlcz0iMCAwIDAgMCAwICAgMCAwIDAgMCAwICAgMCAwIDAgMCAwICAwIDAgMCAwLjUgMCIgdHlwZT0ibWF0cml4IiBpbj0ic2hhZG93Qmx1ck91dGVyMSI+PC9mZUNvbG9yTWF0cml4PgogICAgICAgIDwvZmlsdGVyPgogICAgPC9kZWZzPgogICAgPGcgaWQ9IuWFtuS7luWKn+iDvSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IuW9oueKtue7k+WQiCI+CiAgICAgICAgICAgIDx1c2UgZmlsbD0iYmxhY2siIGZpbGwtb3BhY2l0eT0iMSIgZmlsdGVyPSJ1cmwoI2ZpbHRlci0yKSIgeGxpbms6aHJlZj0iI3BhdGgtMSI+PC91c2U+CiAgICAgICAgICAgIDxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLXdpZHRoPSIxIiBkPSJNMTEuNSw0LjUgTDExLjUsOS41IEwxNi41LDkuNSBMMTYuNSwxMS41IEwxMS41LDExLjUgTDExLjUsMTYuNSBMOS41LDE2LjUgTDkuNSwxMS41IEw0LjUsMTEuNSBMNC41LDkuNSBMOS41LDkuNSBMOS41LDQuNSBMMTEuNSw0LjUgWiIgZmlsbD0iI0ZGRkZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=",h="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAbCAYAAAH3zbSEAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAHaADAAQAAAABAAAAGwAAAABRO+PxAAADA0lEQVRIDbWWzW5SQRTHuQUpYhNbPwpipLcYaNPEBFrcdGP6AG7rW/AMvoE7l76AMXHhyoUvUEi61hhxVRottYmmfhb/v8kMXO7l41LtSQ5zvs/MmXOGm0iMgEsB2cOUGK8ncEIjqNfrjh+9LlhxVuvckL/nefOpkL+H9fzu7i5ZMjAWlm3mFBYoqsLfVukWdrRvDGR96qTBVTkvB/kovbW1Re7toObw8LC3ubn5GdndoMLSGJc8PFut1v2wgeR7RhlWOJ5tJ5rNpuP7K8WZ6MlZk4rfL4Tyz0v2sx9iQCRrtdoTnf9Rt9tda7fbX1Bl7HF3RF8Z2EaolUaj0aMMGxsbz6VNY5G2zlwxVzIJCb5k7dNsmwgV4YGwv33R44Ai3RK+xcBsm44gYtwVvyFn4xnjx247Y6qtCHmha2sCToOvMuhMMxqrT0qzoC38KBQKj3O5XLbT6byRrD+HztP3/cVSqfQxn88XZfMaefn4+LhXqVReiC4I5xCGIEVrUwbuV7pl9GXr5ItmB6MgTTPgRHPIYIUCXRcyYtzrH+EoYBd3hPeEtKGZWarKJZsp0zoOSILdNeF3CFprVWgaWus0WJTBB6LQTmz1SBgHONopGVMq1vs4Hs5GY1fk0DyCs0J21J3FCnJuR854FnqZ42Q8o6pMBpWNm/1Mtgc4gjjRbo4XmcAgiMjiAvEc4hOJwzN0270iDAv/PerrZ5L7Qpor7kmwy1ar1afusXSzgQydi8UztEZSkmnQXorfEfpCEo4bOKkiwAFW9LQfkcwBNDJ0QmwS/C8U7cm2RfvCWZPJxQANspzJZB6sr6+/UqITEBoZOiE25mfRvp9L4oNfFOhnBSpDGUnAyVZZbXwaL0lWjBjyhBRd1guEG4p9YI7qkthPgBPxv5zsP6xU7qoOtOdikZR2/oYgqIC/ACAP+Uwjlal5EC6CV64y+ZgrTxiZw/A3U5iXzxCE9WHeGpt8kWRDkSYwY4JO8Biozp10EGJ2itLyQtwUUm/Wf51ThYgA0/BJ+I71L+HkiMry77z4AAAAAElFTkSuQmCC";e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.MouseMotion").setCursor=function(t){let i,n=!1,o=t.getDomElement(),s=!1,r=!1,a=!1,l=null;function h(){n&&"walk"==t.getViewer().getEditorManager().editor.name||(o.addClass("motion-zoom"),i=Date.now(),setTimeout((()=>{Date.now()-i>180&&o.removeClass("motion-zoom")}),200))}function d(e){const t=e.keyCode||e.which||e.charCode;17==t?s=!0:18==t&&(r=!0)}function c(e){const t=e.keyCode||e.which||e.charCode;17==t?s=!1:18==t&&(r=!1)}function u(e){t._opt.enableZoomRect||s||r||(l={x:e.clientX,y:e.clientY})}function g(e){if(l&&!a&&!s&&!r&&!(Math.abs(l.x-e.clientX)<2&&Math.abs(l.y-e.clientY)<2)){if(n){let i=t.getUseLeftHandedInput();if("walk"==t.getViewer().getEditorManager().editor.name)1==e.buttons&&o.addClass("motion-rotate");else{let n=t._getIsCursorEnabled();1==e.buttons?n&&o.addClass(i?"motion-rotate":"motion-translate"):o.addClass(i?"motion-translate":"motion-rotate")}}else 1==e.buttons&&o.addClass("motion-translate");a=!0}}function p(e){l=!1,a=!1,o.removeClass("motion-translate"),o.removeClass("motion-rotate")}return e.Bimface.Viewer.Viewer3D&&"Viewer3D"===t.viewerType&&(n=!0),document.addEventListener("keydown",d),document.addEventListener("keyup",c),o.addEventListener("mousedown",u),o.addEventListener("mousemove",g),o.addEventListener("mousewheel",h,!1),o.addEventListener("DOMMouseScroll",h,!1),o.addEventListener("mouseup",p),function(){o.removeEventListener("mousemove",g),o.removeEventListener("mousewheel",h),o.removeEventListener("DOMMouseScroll",h),o.removeEventListener("mousedown",u),o.removeEventListener("mouseup",p),document.removeEventListener("keydown",d),document.removeEventListener("keyup",c)}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").create=function(e,t){var i=document.createElement(e);return i.setAttribute("class",t),i},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").createNS=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return i.setAttribute("class",t),i},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").select=function(e){return e.indexOf("#")>-1?document.getElementById(e.replace("#",""))||[]:e.indexOf(".")>-1?document.getElementsByClassName(e.replace(".","")):document.getElementsByTagName(e)},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").drag=function(t){let i=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),n=Object.assign({element:null,handle:null,axis:"all",cursor:"move",distance:0,start:null,move:null,stop:null,bBoxDetection:!1},t),o=n.element;if(!o)return!1;let s,r=n.handle||o,a=!1,l=this;this.resize=function(e,t,i){t=t||{x:0,y:0};let o=e.getBoundingClientRect(),s=e.parentElement.getBoundingClientRect(),r=o.left-s.left,a=o.top-s.top;var l=e.offsetWidth,h=e.offsetHeight,d=e.parentElement.offsetWidth,c=e.parentElement.offsetHeight,u=Math.min(r+t.x,d-l),g=Math.min(a+t.y,c-h),p=r+t.x<0?0:u>0&&u||0,m=a+t.y<0?0:g>0&&g||0;i&&0!=p&&0!=m||(e.style.left=`${p}px`,e.style.top=`${m}px`,e.style.transform="none",n.record&&n.record(p,m))};let h=function(e){var t,o,a=e;if(i){if(t=a.button,!((o=navigator.userAgent).indexOf("compatible")>-1&&o.indexOf("MSIE")>-1&&!isOpera?1==t:0==t))return;s={x:a.clientX,y:a.clientY},document.addEventListener("mousemove",d)}else s={x:a.touches[0].clientX,y:a.touches[0].clientY},r.addEventListener("touchmove",d);n.start&&n.start(s)},d=function(e){var t=e;if(i)var r={x:t.clientX,y:t.clientY};else r={x:t.touches[0].clientX,y:t.touches[0].clientY};var h={x:r.x-s.x,y:r.y-s.y};a?(n.move&&n.move(s,r,h),s=r,function(e){let t=o.getBoundingClientRect(),i=o.parentElement.getBoundingClientRect(),s=t.left-i.left,r=t.top-i.top;if(n.bBoxDetection)l.resize(o,e);else{let t=s+e.x,i=r+e.y;switch(n.axis){case"x":o.style.left=`${t}px`;break;case"y":o.style.top=`${i}px`;break;default:o.style.left=`${t}px`,o.style.top=`${i}px`}}}(h)):a=function(e){return Math.pow(e.x,2)+Math.pow(e.y,2)>Math.pow(n.distance,2)&&(n.start&&n.start(s),!0)}(h),e.preventDefault(),e.stopPropagation()},c=function(){a&&n.end&&n.end(s),a=!1,document.removeEventListener("mousemove",d),r.removeEventListener("touchmove",d)};i?(r.style.cursor=n.cursor,r.style.userSelect="none",r.addEventListener("mousedown",h),document.addEventListener("mouseup",c)):(r.addEventListener("touchend",c),r.addEventListener("touchstart",h))},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.sizable=function(e){let i=Object.assign({element:null,axis:"all",minWidth:100,minHeight:100,distance:0,start:null,sizable:null,stop:null},e),n=i.element;if(!n)return!1;let o,s=!1,r=t.create("div","bf-resize");var a,l;let h=function(e){a=n.clientWidth,l=n.clientHeight;var t,i,s=e;(t=s.button,(i=navigator.userAgent).indexOf("compatible")>-1&&i.indexOf("MSIE")>-1&&!isOpera?1==t:0==t)&&(o={x:s.clientX,y:s.clientY},document.addEventListener("mousemove",d),document.addEventListener("touchmove",d))},d=function(e){var t=e,r={x:t.clientX,y:t.clientY},h={x:r.x-o.x,y:r.y-o.y};s?(i.sizable&&i.sizable(o,r,h),function(e){var t=n.offsetLeft,o=n.offsetTop,s=a+e.x<i.minWidth?i.minWidth:a+e.x,r=l+e.y<i.minHeight?i.minHeight:l+e.y;switch(i.resize&&i.resize(s,r),n.style.left=`${t}px`,n.style.top=`${o}px`,i.axis){case"x":n.style.width=`${s}px`;break;case"y":n.style.height=`${r}px`;break;default:n.style.width=`${s}px`,n.style.height=`${r}px`}}(h)):s=function(e){return Math.pow(e.x,2)+Math.pow(e.y,2)>Math.pow(i.distance,2)&&(i.start&&i.start(o),!0)}(h)},c=function(){s&&i.end&&i.end(o),s=!1,document.removeEventListener("mousemove",d),document.removeEventListener("touchmove",d)};n.addClass("bf-sizable"),n.appendChild(r),r.addEventListener("mousedown",h),r.addEventListener("touchstart",h),document.addEventListener("mouseup",c),document.addEventListener("touchend",c)}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=function(e){let i=this,n=Object.assign({element:null,min:0,max:100,cur:50,step:1,isShowProgress:!0,input:null,change:null,currentColor:"#11dab7",defaultColor:"#999"},e);this._opt=n;let o=t.create("div","bf-range"),s=t.create("input","bf-input-range");i.input=s,s.setAttribute("type","range"),s.setAttribute("step",n.step),s.setAttribute("min",n.min),s.setAttribute("max",n.max),s.setAttribute("value",n.cur);let r=t.create("span","bf-range-min");r.innerText=n.min;let a=t.create("span","bf-range-cur");i.cur=a,a.innerText=n.cur;let l=t.create("span","bf-range-max");l.innerText=n.max;let h=t.create("span","bf-range-progress");o.appendChild(s),n.isShowProgress&&(o.appendChild(r),o.appendChild(a),o.appendChild(l)),o.appendChild(h),n.element.appendChild(o),i.setProgress(n.cur),s.addEventListener("input",(function(){i.setProgress(this.value),n.input&&n.input(this.value)})),s.addEventListener("change",(function(){i.setProgress(this.value),n.change&&n.change(this.value)}))};i.prototype.setProgress=function(e){var t=this._opt,i=t.max-t.min,n=this.input,o=this.cur,s=(e-t.min)/i*100;n.value=e,n.style.background=`linear-gradient(to right,${t.currentColor} 0%,${t.currentColor} ${s}%,${t.defaultColor} ${s}%, ${t.defaultColor} 100%)`,o.innerText=e},i.prototype.reset=function(){this.setProgress(this._opt.cur)},t.range=i}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=function(e){this._opt=Object.assign({element:null,min:0,max:100,from:null,to:null,step:1,currentColor:"#11dab7",defaultColor:"#999",change:null,callback:null},e),this._opt.from=this._opt.from||this._opt.min,this._opt.to=this._opt.to||this._opt.max,this.init()};i.prototype={init:function(){var e=t.create("div","bf-multiple-range"),i=t.create("div","bf-range-track"),n=t.create("span","bf-slider bf-slider-min");n.id="minSlider",n.type="minimum";var o=t.create("span","bf-slider bf-slider-max");o.id="maxSlider",o.type="maximum",this._state={from:this._opt.from,to:this._opt.to},i.style.backgroundColor=this._opt.currentColor,e.style.backgroundColor=this._opt.defaultColor,e.appendChild(i),e.appendChild(n),e.appendChild(o),this._opt.element.appendChild(e),this._track=i,this._sliders={min:n,max:o},this._element=e,this.bindEvent(),this.update(!1)},bindEvent:function(){var e,t,i=this,n=!1,o=function(i){i=i||event;t=i.screenX,e=this,n=!0};this._sliders.min.addEventListener("mousedown",o),this._sliders.max.addEventListener("mousedown",o),document.addEventListener("mousemove",(function(o){if(n){var s=(o=o||event).screenX-t,r=Math.round(s/i._pix/i._opt.step)*i._opt.step;0!=r&&(t=r*i._pix+t,"minimum"==e.type?i._state.from+=r:i._state.to+=r,i.recalculate(e),i.update(!0))}})),document.addEventListener("mouseup",(function(){n?(n=!1,e=null,i._opt.callback&&i._opt.callback()):(e=null,n=!1)}))},update:function(e){var t=this._sliders.min.offsetWidth,i=this._sliders.max.offsetWidth;if(!this._pix){var n=(this._element.offsetWidth-t-i)/(this._opt.max-this._opt.min);this._pix=n}var o=(this._state.from-this._opt.min)*this._pix,s=(this._state.to-this._opt.min)*this._pix+t+i;this._track.style.left=`${o+t/2}px`,this._track.style.width=s-o-t/2-i/2+"px",this._sliders.min.style.left=`${o}px`,this._sliders.max.style.left=`${s}px`,this._opt.change&&e&&this._opt.change(this._state)},recalculate:function(e){this._state.to>=this._opt.max&&(this._state.to=this._opt.max),this._state.from<=this._opt.min&&(this._state.from=this._opt.min),e&&("maximum"==e.type&&this._state.to<=this._state.from&&(this._state.to=this._state.from),"minimum"==e.type&&this._state.from>=this._state.to&&(this._state.from=this._state.to))},getProgress:function(){return this._state},setProgress:function(e){this._state=e,this.recalculate(),this.update(!1)}},t.multipleRange=i}(),HTMLElement.prototype.tap=function(e){var t;this.addEventListener("touchstart",(function(e){t=Date.now()})),this.addEventListener("touchend",(function(i){Date.now()-t<200&&e(i)}))},(window.ActiveXObject||"ActiveXObject"in window)&&(HTMLElement.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)},window.Element&&((s=Element.prototype).matches=s.matches||s.matchesSelector||s.webkitMatchesSelector||s.msMatchesSelector||function(e){for(var t=this,i=(t.parentNode||t.document).querySelectorAll(e),n=-1;i[++n]&&i[n]!=t;);return!!i[n]}),window.Element&&function(e){e.closest=e.closest||function(e){for(var t=this;t.matches&&!t.matches(e);)t=t.parentNode;return t.matches?t:null}}(Element.prototype)),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.UUID").createUUID=function(){let e=[],t="0123456789abcdef";for(let i=0;i<36;i++)e[i]=t.substr(Math.floor(16*Math.random()),1);return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("")},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").throttle=function(e,t){let i=null,n=Date.now();return null==t&&(t=30),function(){let o=Date.now(),s=t-(o-n);const r=this,a=arguments;clearTimeout(i),s<=0?(e.apply(r,a),n=Date.now()):i=setTimeout(e,s)}};const d=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");d.DataUtil={assertType(e,t){const i=t=>Object.prototype.toString.call(e)===`[object ${t}]`;switch(t){case"obj":case"Obj":case"object":case"Object":return i("Object");case"arr":case"Arr":case"array":case"Array":return i("Array");case"num":case"Num":case"number":case"Number":return i("Number");case"func":case"Func":case"function":case"Function":return i("Function");case"str":case"Str":case"string":case"String":return i("String");default:return i(t)}},assertParamsType(...e){if(e.length>1){const[t]=e.splice(e.length-1,1);let i=!0;return e.every((e=>(i=this.assertType(e,t),i))),i}},hasProperty(e,t){return!!this.assertType(e,"obj")&&e.hasOwnProperty(t)},hasProperties(e,...t){if(!t)return!1;let i=!0;return t.every((t=>i=this.hasProperty(e,t))),i},hasChildProperty(e,...t){if(!t||0===t.length)return!1;let i=e;for(let e=0;e<t.length;e++){let n=t[e];if(!this.hasProperty(i,n))return!1;i=i[n]}return!0},getChildProperty(e,...t){if(this.hasChildProperty(e,...t)){let i=e;return t.forEach((e=>i=i[e])),i}},limitTransformationDecimal(e){for(let t=0;t<e.length;t++)t<=11?e[t]=Number(e[t].toFixed(6)):t>11&&t<=14&&(e[t]=Number(e[t].toFixed(3)));return e}};var c=d.DataUtil;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Utils").Transformation={getTranslation(e){const t=this._getDecompose(e);return{x:t.position.x,y:t.position.y,z:t.position.z}},getQuaternion(e){const t=this._getDecompose(e);return{x:t.quaternion._x,y:t.quaternion._y,z:t.quaternion._z,w:t.quaternion._w}},getScaling(e){const t=this._getDecompose(e);return{x:t.scale.x,y:t.scale.y,z:t.scale.z}},quaternionToEulerAngles(e,t){const i=new THREE.Euler,n=new THREE.Quaternion(e.x,e.y,e.z,e.w),o=i.setFromQuaternion(n,t||"XYZ");return{x:o._x,y:o._y,z:o._z,order:o._order}},eulerAnglesToQuaternion(e){const t=new THREE.Quaternion,i=new THREE.Euler(e.x,e.y,e.z,e.order),n=t.setFromEuler(i);return{x:n._x,y:n._y,z:n._z,w:n._w}},_getDecompose(e){const t=new THREE.Matrix4,i=new THREE.Vector3,n=new THREE.Quaternion,o=new THREE.Vector3;return t.fromArray(e),t.decompose(i,n,o),{position:i,quaternion:n,scale:o}}};const u=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");u.performance={throttleAndDebounce(e,t=300){let i=null,n=null;return function(...o){n&&(clearTimeout(n),n=null),n=setTimeout((()=>{clearTimeout(i),i=null,e(...o)}),t),i||(i=setTimeout((()=>{e(...o),clearTimeout(i),i=null}),t))}},throttle(e,t=300){let i=null;return function(...n){i||(i=setTimeout((()=>{e(...n),clearTimeout(i),i=null}),t))}},debounce(e,t=300){let i=null;return function(...n){i&&(clearTimeout(i),i=null),i=setTimeout((()=>{e(...n)}),t)}}},u.performance,function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang");let i=function(){this.container={}};i.prototype.addEvent=function(e,t,i){return"string"==typeof e&&"function"==typeof t&&(void 0===this.container[e]?this.container[e]=[t]:!0===i?this.container[e].unshift(t):this.container[e].push(t)),this},i.prototype.fireEvent=function(e){if(e&&this.container[e]){var t=Array.prototype.slice.call(arguments);t.shift();for(var i=[...this.container[e]],n=i.length,o=0;o<n;o++){var s=i[o];if(!0===s.apply(null,t))return this}}return this},i.prototype.removeEvent=function(e,t){if("function"==typeof t&&"string"==typeof e){var i=this.container[e];if(i instanceof Array){for(var n=0,o=i.length;n<o;n+=1)if(i[n]===t){i.splice(n,1);break}0==i.length&&delete this.container[e]}return this}},t.EventManager=i}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Geometry"),i=function(e,t,i){this.x=e,this.y=t,this.z=i};i.prototype={get:function(){return{x:this.x,y:this.y,z:this.z}},set:function(e,t,i){this.x=e,this.y=t,this.z=i}},t.Point3d=i}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Geometry");t.BoundingBox=function(e,i){var n={},o=new t.Point3d,s=new t.Point3d;return o.set(e.x,e.y,e.z),s.set(i.x,i.y,i.z),n.min=o,n.max=s,n}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics.Utility").RGBToHex=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t};var g=window.hostConfig||{APIHost:"https://api.bimface.com",resourceHost:"https://m.bimface.com",staticHost:"https://static.bimface.com",dataEnvType:"BIMFACE",securityApi:!0};function p(e,t,i){!e[t]&&Object.defineProperty(e,t,{value:i,enumerable:!1})}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics.Utility.Relation");t.getViews=function(t,i,n){e.Web.Lang.Utility.HttpRequest.ajax({url:`${g.resourceHost}/${t}/metadata/views.json`,success:function(e){var o=JSON.parse(e).viewList;e=[];for(var s in o){var r=o[s];r.viewType==i&&(r.preview.path=`${g.resourceHost}/${t}/${r.preview.path}`,e.push(r))}n&&n(e)}})},t.getDrawingSheets=function(t,i,n,o=null,s={}){e.Web.Lang.Utility.HttpRequest.ajax({url:e.Web.Lang.Utility.HttpRequest.getUrl({url:`${g.resourceHost}/${t}/metadata/drawings.json`,path:"metadata/drawings.json",...s}),success:function(e){for(var t=JSON.parse(e).drawingList,s=0;s<t.length;s++){var r=t[s];if(o){if(r.fileId==o&&r.viewInfo.id==i){n&&n(r);break}}else if(r.viewInfo.id==i){n&&n(r);break}}}})},t.point2DToPoint3D=function(t,i){if("DrawingSheet"==i.viewType)return function(e,t){if("DrawingSheet"!=t.viewType)return null;var i=t.viewInfo;let n=i.preview.width,o=i.preview.height,s=i.outline[0],r=i.outline[2],a=i.outline[1],l=i.outline[3],h=r-s,d=l-a;function c(e){return"FloorPlan"==e||"CeilingPlan"==e}function u(t,i,r,l,c){let u=e.x/n,g=(o-e.y)/o;if("Elevation"==c.viewType){g=(n-e.x)/n,u=e.y/o;var p=c.viewPoint.viewDirection;1!=Math.round(p[0])&&-1!=Math.round(p[1])||(u=(o-e.y)/o)}let m=(t-s)/h,f=(i-s)/h;if(u<m||u>f)return null;let w=(r-a)/d,y=(l-a)/d;if(g<w||g>y)return null;let v=(u-m)/(f-m),b=(g-w)/(y-w),E=((c.outline[2]-c.outline[0])*v+c.outline[0])*c.viewPoint.scale,M=((c.outline[3]-c.outline[1])*b+c.outline[1])*c.viewPoint.scale;return new THREE.Vector3(E,M,0)}let g=(i=t).portsAndViews;for(var p=0;p<g.length;p++){let e=g[p];if(!c(e.viewType))continue;let t=u(e.viewport[0],e.viewport[3],e.viewport[1],e.viewport[4],e);if(null!=t){if(c(e.viewType))null!==t&&(t.z=e.elevation);else if("Elevation"==e.viewType){var m=e.viewPoint.viewDirection,f=e.cropBox;0!=Math.round(m[0])?null!==t&&(t.z=t.y,t.y=t.x,t.x=m[0]<0?f[3]:f[0]):0!=Math.round(m[1])&&null!==t&&(t.z=t.y,t.y=m[1]<0?f[4]:f[1])}return t}}return null}(t,i);if("FloorPlan"!=i.viewType)return console.warn("Not support yet!"),null;var n=i.preview.width,o=i.preview.height,s=i.outline[0],r=i.outline[2],a=i.outline[1],l=i.outline[3],h=r-s,d=l-a,c=(0-s)/h,u=l/d,g=(t.x-n*c)/n,p=(o*u-t.y)/o;return g=g*h*i.viewPoint.scale,p=p*d*i.viewPoint.scale,new e.Web.Geometry.Point3d(g,p,i.elevation)},t.point3DToPoint2D=function(e,t){let i=[];if(function(e,t,i){if("DrawingSheet"!=t.viewType)return!1;var n=t.preview.width,o=t.preview.height,s=t.outline[0],r=t.outline[2],a=t.outline[1],l=t.outline[3];let h=t.portsAndViews;for(let t in h){let d=h[t];if("FloorPlan"!==d.viewType)continue;let c=d.viewPoint.scale,u=d.outline[0]*c,g=d.outline[2]*c,p=d.outline[1]*c,m=d.outline[3]*c;if(e.x<u||e.x>g)continue;if(e.y<p||e.y>m)continue;let f=(e.x-u)/(g-u),w=(e.y-p)/(m-p),y=d.viewport[3]-d.viewport[0],v=d.viewport[4]-d.viewport[1];i(n*((d.viewport[0]+y*f-s)/(r-s)),o-o*((d.viewport[1]+v*w-a)/(l-a)),d)}return!0}(e,t,(function(e,t,n){i.append({x:e,y:t})})))return 0==i.length?null:i;if("FloorPlan"!=t.viewType)return console.warn("Not support yet!"),null;var n=t.preview.width,o=t.preview.height,s=t.outline[0],r=t.outline[2],a=t.outline[1],l=t.outline[3],h=r-s,d=l-a,c=(0-s)/(r-s),u=l/(l-a),g=e.x/(h*t.viewPoint.scale),p=e.y/(d*t.viewPoint.scale);return{x:g=g*n+n*c,y:p=o*u-p*o,z:0}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics.Utility").ImageContainer=function(e){var t=new Image;return new Promise((function(i,n){t.onload=function(){i(t)},t.onerror=function(e){n(e)},t.crossOrigin="anonymous",t.src=e,!0===t.complete&&i(t)}))},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Graphics"),i=e.Web.Graphics.Utility.RGBToHex,n=function(e,t,i,n){this.red=e,this.green=t,this.blue=i,this.alpha=n},o=function(e,t){/^#[0-9a-fA-F]{6}$/.test(e)&&(this.red=parseInt(e.slice(1,3),16),this.green=parseInt(e.slice(3,5),16),this.blue=parseInt(e.slice(5),16)),"number"==typeof t?(t>1&&(t=1),t<0&&(t=0),this.alpha=t):this.alpha=1},s=function(){arguments.length<4?o.apply(this,arguments):n.apply(this,arguments)};s.prototype={getRGB:function(){return`rgba(${this.red},${this.green},${this.blue})`},getRGBA:function(){return`rgba(${this.red},${this.green},${this.blue},${this.alpha})`},getHEX:function(){return`${i(this.red)}${i(this.green)}${i(this.blue)}`},getAlpha:function(){return this.alpha},fromObject:function(e){return this.red=e.red,this.green=e.green,this.blue=e.blue,this.alpha=e.alpha,this}},t.Color=s}(),SVGElement.prototype.getClass=HTMLElement.prototype.getClass=function(e){return this.getAttribute("class")},SVGElement.prototype.hasClass=HTMLElement.prototype.hasClass=function(e){let t=this.getClass();return!!t&&(t&&t.split(" ")).indexOf(e)>-1},SVGElement.prototype.addClass=HTMLElement.prototype.addClass=function(e){let t=this.getClass();var i=t&&t.split(" ");return t?-1==i.indexOf(e)&&(i.push(e),t=i.join(" "),this.setAttribute("class",`${t}`)):this.setAttribute("class",`${e}`),this},SVGElement.prototype.removeClass=HTMLElement.prototype.removeClass=function(e){if(!this.hasClass(e))return this;let t=this.getClass().replace(e,"").trim();return t?this.setAttribute("class",`${t}`):this.removeAttribute("class"),this},SVGElement.prototype.toggleClass=HTMLElement.prototype.toggleClass=function(e,t){this.getClass();var i=this.hasClass(e);return null!=t?(t&&!i&&this.addClass(e),t||this.removeClass(e)):i?this.removeClass(e):this.addClass(e),!i},p(Array.prototype,"getObjectByAttribute",(function(e,t){for(var i=this,n=i.length,o=0;o<n;o++)if(i[o][e]==t)return i[o];return!1})),p(Array.prototype,"removeObjectByAttribute",(function(e,t){for(var i=this,n=i.length,o=0;o<n;o++)if(i[o][e]==t)return i=i.splice(o,1);return!1})),p(Array.prototype,"getAllObjectByAttribute",(function(e,t){for(var i=this,n=i.length,o=0,s=[];o<n;o++)i[o][e]==t&&s.push(i[o]);return s})),p(Array.prototype,"removeByValue",(function(e){for(var t=this,i=t.length-1;i>=0;i--)t[i]==e&&t.splice(i,1);return t})),p(Array.prototype,"insert",(function(e,t){return this.splice(e,0,t),this})),p(Array.prototype,"insertAfter",(function(e,t){let i=e.length;for(;i>0&&-1==this.indexOf(e[i-1]);)i--;return i<1?this.splice(e.length,0,t):this.splice(i,0,t),{res:this,index:i}})),p(Array.prototype,"unique",(function(e){for(var t=[],i=0;i<e.length;i++)t.indexOf(-1===e[i])&&t.push(e[i]);return t})),SVGElement.prototype.setCss=HTMLElement.prototype.setCss=function(e){if(e)for(var t in e)this.style[t]=e[t]},SVGElement.prototype.getCss=HTMLElement.prototype.getCss=function(){return this.style},function(){let t=Object.freeze({Google:"Google",Tianditu:"Tianditu",OSM:"OSM",Amap:"Amap",ArcGIS:"ArcGIS",BingMap:"BingMap",Tencent:"Tencent",None:"None",Custom:"Custom"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").Credit=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").ImageStyle=Object.freeze({DarkBlue:"DarkBlue",DarkGreen:"DarkGreen",CustomColor:"CustomColor"}),function(){let t=Object.freeze({Millimeter:"Millimeter",Centimeter:"Centimeter",Meter:"Meter",Kilometer:"Kilometer",None:"None"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common.Units").LengthUnits=t}();class m{constructor(){let e=[["EPSG:4214","+proj=longlat +ellps=krass +towgs84=15.8,-154.4,-82.3,0,0,0,0 +no_defs"],["EPSG:4490","+proj=longlat +ellps=GRS80 +no_defs"],["EPSG:4610","+proj=longlat +a=6378140 +b=6356755.288157528 +no_defs"],["EPSG:3395","+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"]];for(let t=0;t<21;t++)e.push([`EPSG:45${13+t}`,`+proj=tmerc +lat_0=0 +lon_0=${75+3*t} +k=1 +x_0=${255e5+1e6*t} +y_0=0 +ellps=GRS80 +units=m +no_defs`]);for(let t=0;t<21;t++)e.push([`EPSG:45${34+t}`,`+proj=tmerc +lat_0=0 +lon_0=${75+3*t} +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs`]);proj4.defs(e)}translateXY(e,t,i){if(c.assertParamsType(t,i,"str")&&c.hasProperties(e,"x","y")&&proj4(t)&&"longlat"!==proj4(t).oProj.projName&&proj4(i)){let n=proj4(t,i,e);return"longlat"===proj4(i).oProj.projName?{lat:n.y,lon:n.x}:{x:n.x,y:n.y}}}translateLatLon(e,t,i){if(c.assertParamsType(t,i,"str")&&c.hasProperties(e,"lat","lon")&&proj4(t)&&"longlat"===proj4(t).oProj.projName&&proj4(i)){let n={x:e.lon,y:e.lat},o=proj4(t,i,n);return"longlat"===proj4(i).oProj.projName?{lat:o.y,lon:o.x}:{x:o.x,y:o.y}}}defineCustomCoordSys(e,t){const{falseEasting:i,falseNorthing:n,centralMeridian:o,latitudeOfOrigin:s}=t,r=[e,`+proj=tmerc ${s?`+lat_0=${s}`:""} ${o?`+lon_0=${o}`:""} +k=1 ${i?`+x_0=${i}`:""} ${n?`+y_0=${n}`:""} +ellps=GRS80 +units=m +no_defs`];proj4.defs([r])}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").CoordinateConvertor=m;const f=Object.freeze({EPSG_4214:"EPSG:4214",EPSG_4326:"EPSG:4326",EPSG_4490:"EPSG:4490",EPSG_4610:"EPSG:4610",EPSG_4513:"EPSG:4513",EPSG_4514:"EPSG:4514",EPSG_4515:"EPSG:4515",EPSG_4516:"EPSG:4516",EPSG_4517:"EPSG:4517",EPSG_4518:"EPSG:4518",EPSG_4519:"EPSG:4519",EPSG_4520:"EPSG:4520",EPSG_4521:"EPSG:4521",EPSG_4522:"EPSG:4522",EPSG_4523:"EPSG:4523",EPSG_4524:"EPSG:4524",EPSG_4525:"EPSG:4525",EPSG_4526:"EPSG:4526",EPSG_4527:"EPSG:4527",EPSG_4528:"EPSG:4528",EPSG_4529:"EPSG:4529",EPSG_4530:"EPSG:4530",EPSG_4531:"EPSG:4531",EPSG_4532:"EPSG:4532",EPSG_4533:"EPSG:4533",EPSG_4534:"EPSG:4534",EPSG_4535:"EPSG:4535",EPSG_4536:"EPSG:4536",EPSG_4537:"EPSG:4537",EPSG_4538:"EPSG:4538",EPSG_4539:"EPSG:4539",EPSG_4540:"EPSG:4540",EPSG_4541:"EPSG:4541",EPSG_4542:"EPSG:4542",EPSG_4543:"EPSG:4543",EPSG_4544:"EPSG:4544",EPSG_4545:"EPSG:4545",EPSG_4546:"EPSG:4546",EPSG_4547:"EPSG:4547",EPSG_4548:"EPSG:4548",EPSG_4549:"EPSG:4549",EPSG_4550:"EPSG:4550",EPSG_4551:"EPSG:4551",EPSG_4552:"EPSG:4552",EPSG_4553:"EPSG:4553",EPSG_4554:"EPSG:4554",EPSG_3857:"EPSG:3857",EPSG_3395:"EPSG:3395"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").Coordinates=f,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common").Direction=Object.freeze({Horizontal:"Horizontal",Vertical:"Vertical"}),function(){let t=Object.freeze({PrismPoint:"PrismPoint",CurveAnimation:"CurveAnimation",WallEffect:"WallEffect",FanScan:"FanScan",WaterEffect:"WaterEffect",RingScan:"RingScan",SkyBoxManager:"SkyBoxManager",Rain:"Rain",FireEffect:"FireEffect",MapStyle:"MapStyle"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Common.Type").EffectType=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Authentication").AuthenticationConfig=function(){return{APIHost:g.APIHost,viewToken:null,enableStorage:!1}};class w extends class{constructor(e){this.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.msIndexedDB,this.indexedDB||console.log("IndexedDB not supported"),this._db=null,this._opt=e}open(e,t){const i=e||this._opt.name,n=t||this._opt.version||1,o=this.indexedDB.open(i,n);return new Promise(((e,t)=>{o.onsuccess=t=>{this._db=o.result,e(this._db)},o.onupgradeneeded=e=>{let t=this._db=e.target.result;(this._opt.storeList||[]).forEach((e=>!t.objectStoreNames.contains(e)&&t.createObjectStore(e)))},o.onerror=e=>{t(e)}}))}getDB(){return new Promise(((e,t)=>{this._db?e(this._db):this.open().then(e).catch(t)}))}addObject(e,t,i){return new Promise(((n,o)=>{this.getDB().then((s=>{const r=s.transaction(e,"readwrite");r.objectStore(e).put(t,i).onsuccess=e=>{n(e.target.result)},r.onerror=e=>{o(e)}})).catch(o)}))}getObject(e,t){return new Promise(((i,n)=>{this.getDB().then((o=>{const s=o.transaction(e,"readonly");s.objectStore(e).get(t).onsuccess=e=>{let t=e.target.result;t?i(t):n(e)},s.onerror=e=>{n(e)}})).catch(n)}))}deleteObject(e,t){return new Promise(((i,n)=>{this.getDB().then((o=>{const s=o.transaction(e,"readwrite");s.objectStore(e).delete(t).onsuccess=e=>{i(e.target.result)},s.onerror=e=>{n(e)}})).catch(n)}))}clearStore(e){return new Promise(((t,i)=>{this.getDB().then((n=>{const o=n.transaction(e,"readwrite");o.objectStore(e).clear().onsuccess=e=>{t(e.target.result)},o.onerror=e=>{i(e)}})).catch(i)}))}deleteDB(e){return new Promise((t=>{this.indexedDB.deleteDatabase(e),t()}))}getAllKeys(e){return new Promise(((t,i)=>{this.getDB().then((n=>{const o=n.transaction(e,"readonly");o.objectStore(e).getAllKeys().onsuccess=e=>t(e.target.result),o.onerror=i})).catch(i)}))}getAll(e){return new Promise(((t,i)=>{this.getDB().then((n=>{const o=n.transaction(e,"readonly");o.objectStore(e).getAll().onsuccess=e=>t(e.target.result),o.onerror=i})).catch(i)}))}}{constructor(){super({name:"Bf_Loader",version:1,storeList:["d","t"]})}getDatabagInfo(e,t){return new Promise(((i,n)=>{t?this.getObject("d",e).then((e=>this.addTemp(e,t).then((()=>i(e))).catch(n))).catch(n):this.getObject("d",e).then(i).catch(n)}))}addDatabagInfo(e,t){return new Promise(((i,n)=>{const o=e.modelId,s=()=>Promise.all([this.addObject("d",e,o),this.addTemp(e,t)]).then(i).catch(n);this.getDatabagInfo(o).then((t=>{t.databagId!==e.databagId&&this.deleteDB(`Bf_${data.databagId}`),s()})).catch((()=>{s()}))}))}deleteDatabagInfo(e){return new Promise(((t,i)=>{this.deleteObject("d",e).then(t).catch(i)}))}addTemp(e,t){return new Promise(((i,n)=>{this.clearStore("t").then((()=>{this.addObject("t",e,t).then(i).catch(n)})).catch(n)}))}getTemp(e){return new Promise(((t,i)=>{this.getObject("t",e).then(t).catch(i)}))}deleteStorageByModelId(e){return new Promise((t=>{this.getDatabagInfo(e).then((i=>{let n="gisView"===i.renderType?`Bg_${i.modelId}`:`Bf_${i.databagId}`;Promise.allSettled([this.deleteDB(n),this.deleteDatabagInfo(e)]).then(t)})).catch(t)}))}getStoredModelIds(){return this.getAllKeys("d")}getStoredModelInfo(){return new Promise(((e,t)=>{this.getAll("d").then((t=>{let i=t.map((e=>{let{modelId:t,name:i,renderType:n}=e;return{modelId:t,name:i,type:n}}));e(i)})).catch(t)}))}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Authentication");e.Web;let i=e.Web.Lang.Utility.HttpRequest;var n=function(e){this.config=e};n.prototype.authenticate=function(e,t){let n=this,o=n.config;const s=()=>{const s=n.config.securityApi;let r=`${o.APIHost}/inside/databag`,a="post",l=o.viewToken;s||(r=`${r}?viewToken=${o.viewToken}`,a="get",l=void 0),i.ajax({url:r,type:a,data:l,headers:{"Content-type":"text/plain;charset=UTF-8"},async:!0,success:function(i){var s=JSON.parse(i);"success"==s.code?(s.data.viewToken=o.viewToken,n.data=s.data,e&&e(s.data)):t&&t(s)},failure:e=>{var i=JSON.parse(e);t&&t(i)}})};o.enableStorage?(new w).getTemp(o.viewToken).then((t=>{t.viewToken=o.viewToken,n.data=t,e&&e(t)})).catch(s):s()},t.AuthenticationManager=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").MetaDataManagerConfig=function(){return{APIHost:g.APIHost,resourceHost:g.resourceHost,viewToken:null,modelId:null,modelType:"singleModel",dataEnvType:g.dataEnvType||"BIMFACE"}};var y=window.CLOUD=window.CLOUD||{};const v=function(e){return e.map((e=>{const t={positions:[]},i=e.end.x-e.start.x,n=e.end.y-e.start.y,o=e.end.z-e.start.z,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2)+Math.pow(o,2)),r=i/s,a=n/s,l=o/s,h={x:e.start.x-r,y:e.start.y-a,z:e.start.z-l},d={x:e.end.x+r,y:e.end.y+a,z:e.end.z+l};t.positions.push(h,d);const c=[{startPoint:e.start,endPoint:e.end,lineType:"Line"}];return{id:e.id,name:e.name,label:t,geometry:c}}))};var b,E,M,C,x,T;function P(e){c.assertType(e,"obj")&&(Object.defineProperty(e,"_isVue",{enumerable:!1,value:"ForSkipVueObserver"}),Object.defineProperty(e,"__v_skip",{enumerable:!1,value:"ForSkipVueObserver"}))}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data");var i=e.Web.Lang.Utility.HttpRequest.promiseJSONRequest,n=e.Web.Lang.Utility.HttpRequest.ajax,o={getFamilyTypes:function(e){const t=`${e.resourcePath}${e.databagId}/metadata/familyInfo.json`;return i(t)},getFamilyData:function(e){const t=`${e.relativeUrl}/metadata/assetProperties.json`;return i(t)},getAreas:function(e){var t=`${e.relativeUrl}/data/spaces.json`;return i(t)},getMepSystem:function(e,t){if("integrateModel"==t.modelType)var n=`${t.relativeUrl}/metadata/${e}/mepsystem.json`;else n=`${t.relativeUrl}/metadata/mepsystem.json`;return i(n,"noCode")},getTreeOldData:function(e){if("singleModel"==e.modelType)var t=`${e.relativeUrl}/data/tree.json`;else t=`${e.relativeUrl}/data/specialtyTree.json`;return i(t)},getTreeNewData:function(e){var t=`${e.relativeUrl}/data/tree.json`;return i(t)},getSectionData:function(e){var t=`${e.relativeUrl}/metadata/sectionCut.json`;return i(t)},getObjectData:function(t,i){return new Promise((function(n,o){if(i._objectData)n(i._objectData);else{let o=new e.Bimface.Data.ObjectPropertyManager(`${t.relativeUrl}/property`);o.load((function(){i._objectData=o,n(i._objectData)}))}}))},getMaterialProperty:function(e,t){var n=t.split(".");if("singleModel"==e.modelType)var o=`${e.relativeUrl}/metadata/materialmap.json`;else o=`${e.relativeUrl}/metadata/${n[0]}/materialmap.json`;return i(o,"noCode")},getMaterialPropertyItem:function(e,t,n){var o=t.split("."),s="singleModel"==e.modelType?`${e.relativeUrl}/metadata/materials/${n}.json`:`${e.relativeUrl}/metadata/${o[0]}/materials/${n}.json`;return i(s,"noCode")},getAreaProperty:function(e,t){var n=e.split("_");if("singleModel"==t.modelType)var o=`${t.relativeUrl}/metadata/areas.json`;else o=`${t.relativeUrl}/metadata/${n[0]}/areas.json`;return i(o,"noCode")},getRoomProperty:function(e,t){var n=e.split("_");if("singleModel"==t.modelType)var o=`${t.relativeUrl}/metadata/rooms.json`;else o=`${t.relativeUrl}/metadata/${n[0]}/rooms.json`;return i(o,"noCode")},getFiles:function(e){var t=`${e.relativeUrl}/data/files.json`;return i(t)},getDrawingsheets:function(e,t){var n=`${e.relativeUrl}/metadata/drawings.json`;return i(n,"noCode")},getMapInfo:function(e,t){this._opt;var i={},o=[];this._helper;2===t||"integrateModel"!==e.modelType?n({url:`${e.relativeUrl}/metadata/axisgrids/grids.json.gz`,async:!1,success:function(e){var t=y.AxisGridManager.adaptGridData(JSON.parse(e));i.Grids=t.grids}}):n({url:`${e.relativeUrl}/metadata/grids.json`,async:!1,success:function(e){var t=JSON.parse(e);i.Grids=v(t.grids)}}),n({async:!1,url:`${e.relativeUrl}/metadata/levels.json`,success:function(e){i.Levels=JSON.parse(e).levels}}),n({async:!1,url:`${e.relativeUrl}/resource/v3/maps/output.json`,dataType:"text",success:function(t){var i=JSON.parse(t);for(var n in i){var s=i[n];null==s.id&&(s.id=n),s.path=`${e.relativeUrl}/resource/v3/maps/${s.id}.png`,s.name=n,o.push(s)}}});let s=i.Levels;if(s){let e=e=>{let t=!1;return o.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t<s.length;t++)e(s[t].id)||(s.splice(t,1),t--)}return{axisGrid:i,floors:o}},getMapInfoAsync:function(e,t){return new Promise(((n,o)=>{let s={Grids:[]},r=[];const a="integrateModel"===e.modelType&&2!==t,l=`${e.relativeUrl}/metadata/${a?"grids.json":"axisgrids/grids.json.gz"}`;Promise.allSettled([i(l,"noCode"),i(`${e.relativeUrl}/metadata/levels.json`,"noCode"),i(`${e.relativeUrl}/resource/v3/maps/output.json`,"noCode")]).then((t=>{let[i,o,l]=t;if(i.value)if(a)s.Grids=v(i.value.grids);else{var h=y.AxisGridManager.adaptGridData(i.value);s.Grids=h.grids}s.Levels=o.value.levels,(t=>{for(var i in t){var o=t[i];null==o.id&&(o.id=i),o.path=`${e.relativeUrl}/resource/v3/maps/${o.id}.png`,o.name=i,r.push(o)}let a=s.Levels;if(a){let e=e=>{let t=!1;return r.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t<a.length;t++)e(a[t].id)||(a.splice(t,1),t--)}n({axisGrid:s,floors:r})})(l.value)})).catch(o)}))},getLevels:function(e,t){let n=`${t.relativeUrl}/metadata/levels.json`;return e&&(n=`${t.relativeUrl}/metadata/${e}/levels.json`),i(n,"noCode")},getExplosionFloorsInfo:function(e){let t={};return n({async:!1,url:`${e.relativeUrl}/metadata/levels.json`,success:function(e){const i=JSON.parse(e);t.levels=i.levels,t.version=i.version}}),t.version&&t.version>1||n({async:!1,url:`${e.relativeUrl}/resource/v3/maps/output.json`,dataType:"text",success:function(e){const i=JSON.parse(e);t.floors=i}}),t},getLinksJson:function(e){var t=`${e.relativeUrl}/metadata/links.json`;return"singleModel"==e.modelType&&(t=`${e.relativeUrl}/metadata/rvtLinks.json`),i(t,"noCode")},getFloors:function(e){let t=`${e.relativeUrl}/data/spaces.json`;return i(t,"noCode")},getViews:function(e){var t={data:null,resourceHost:"./"};return n({url:`${e.relativeUrl}/metadata/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewsById:function(e){var t={data:null,resourceHost:"./"};return n({url:`${e.relativeUrl}/metadata/${e.fileId}/views.json`,async:!1,success:function(e){t.data=e}}),t},getViewData:function(e){let t=`${e.relativeUrl}/metadata/viewStates/${e.viewId}.json`;return i(t,"noCode")},getRooms:function(e){let t=`${e.resourceHost}/${e.databagId}/metadata/rooms.json`;return i(t,"noCode")},getRoomBoundary:function(e,t){let n=`${t.resourceHost}/${t.databagId}/metadata/roomsboundary/${e}.json`;return i(n,"noCode")},getAllDrawingsheets:function(e){var t=`${e.relativeUrl}/metadata/drawings.json`;return i(t,"noCode")},decodeElementId:function(e,t){if(/^[0-9]*\.*[0-9]*$/.test(t))return Promise.resolve(t);var i=t.split("."),n=i[0];return this.getFiles(e).then((function(e){for(let t of e)for(let e of t.linkedBy)if(e==n)return t.fileId+"."+i[1]})).then((function(e){return e}))},getCategoryVisibility:function(e){var t=`${e.relativeUrl}/metadata/categoryVisibility.json`;return i(t,"noCode")},getText:function(e){var t=`${e.relativeUrl}/metadata/text.json`;return i(t,"noCode")},getSegmentGroups:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups?view_token=${e.viewToken}`;return i(t,"noCode")},getSegmentFromGroups:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups/${t}/segments?view_token=${e.viewToken}`;return i(n,"noCode")},getSegmentTree:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentTree?view_token=${e.viewToken}`;return i(t,"noCode")},getSegmentById:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}?view_token=${e.viewToken}`;return i(n,"noCode")},getSegmentElementIds:function(e,t){var n=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}/elementIds?view_token=${e.viewToken}`;return i(n,"noCode")},getPartialElementsMetadata:function(e,t){var n=`${e.relativeUrlWithoutDatabagId}/${t}/metadata/partial_elements_metadata.json`;return i(n,"noCode")},getPartialElementsMetadataFile:function(e,t){return`${e.relativeUrlWithoutDatabagId}/${t}/metadata/partial_elements_metadata.json`},getDatabagResource:function(e,t){return`${e.relativeUrlWithoutDatabagId}/${t}/resource/v3/model`},getModelGroup:function(e,t){var n=`${e.relativeUrl}/metadata/modelSetsTree.json`;return i(n,"noCode")},getManifest:function(e){var t=`${e.relativeUrl}/manifest.json`;return i(t,"noCode")},getNestedComponents:function(e){var t=`${e.relativeUrl}/metadata/nestedComponents.json`;return i(t,"noCode")},getObjectMap:function(e){var t=`${e.relativeUrl}/metadata/objectMap.json.gz`;return i(t,"noCode")},getWalkthrough:function(e){var t=`${e.relativeUrl}/data_ext/walkthrough.json`;return i(t,"noCode")},getProjectInfo:function(e){var t=`${e.relativeUrl}/metadata/project.json`;return i(t,"noCode")},getModelInfo:function(e){var t=`${e.relativeUrl}/resource/v3/model/config.json`;return i(t,"noCode")},getBimtileInfo:function(e,t){return i(`${e}/resource/v3/model/${t}`,"noCode")},getFeatureStyle:function(e){var t=`${e.relativeUrl}/resource/v3/model/featureStyle.json`;return i(t,"noCode")},getDimensions:function(e,t){let n=`${t.relativeUrl}/metadata/ModelDimensions.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/ModelDimensions.json`),i(n,"noCode")},getLevelmapping:function(e){var t=`${e.relativeUrl}/metadata/levelmapping.json`;return i(t,"noCode")},getDrawingTree:function(e,t){var n=`${t.relativeUrl}/metadata/drawingsTree.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/drawingsTree.json`),i(n,"noCode")},getViewsTree:function(e,t){var n=`${t.relativeUrl}/metadata/viewsTree.json`;return"integrateModel"==t.modelType&&(n=`${t.relativeUrl}/metadata/${e}/viewsTree.json`),i(n,"noCode")}};t.OfflineDataProdiver=o}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data.OfflineDataProdiver");function n(e){this._config=e}n.prototype={getFamilyTypes:function(e,t){i.getFamilyTypes(this._config).then((function(t){var i=JSON.parse(t),n=i.Types||i.types;for(let e=0,t=n.length;e<t;e++)n[e].id=n[e].Id||n[e].id,n[e].name=n[e].Name||n[e].name,delete n[e].Id,delete n[e].Name;e&&e(n)})).catch((function(e){t&&t(e)}))},getFamilyProperty:function(e,t,n){if(!e)return console.warn("familyTypeId must not be empty!."),void(n&&n());i.getFamilyData(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getComponentProperty:function(e,t,n){var o=this;if(!e)return console.warn("elementId must not be empty!."),void(n&&n());var s=null;i.getObjectData(this._config,this).then((function(t){return s=t,i.decodeElementId(o._config,e)})).then((function(e){var i=s.getBoundingBox(e),n=s.getElementProperties(e);let o={};for(var r of n[0].items)o[r.key]=r.value;t({boundingBox:i,elementId:o.ID,familyGuid:"",guid:o.GUID,name:o.name||o.familyType,properties:n})}))},getMaterialProperty:function(e,t,n){var o=this;i.decodeElementId(o._config,e).then((function(e){i.getMaterialProperty(o._config,e).then((function(s){var r=e.split("."),a=[];if(s[r="singleModel"==o._config.modelType?r[0]:r[1]]){for(var l of s[r])a.push(i.getMaterialPropertyItem(o._config,e,l));Promise.all(a).then((e=>{t&&t(e)}))}else n&&n(s)}))}))},getAreas:function(e,t){i.getAreas(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getMepSystem:function(e,t,n){var o=this;i.getMepSystem(e,o._config).then((function(e){t&&t(e,o._config.modelType)})).catch((function(e){n&&n(e)}))},getTreeOldData:function(e,t){var n=this;i.getTreeOldData(n._config).then((function(t){e&&e(t,n._config.modelType,"old")})).catch((function(e){t&&t(e)}))},getTreeNewData:function(e,t){var n=this;i.getTreeNewData(n._config).then((function(t){var i=!0,o=e=>{"familyType"===e.type?e.items&&0!==e.items.length||(i=!1):e.items&&e.items.length>0&&o(e.items[0])};t&&t.length>0&&o(t[0]),e&&e(t,n._config.modelType,i?void 0:"old")})).catch((function(e){t&&t(e)}))},getSectionData:function(e,t){i.getSectionData(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomProperty:function(e,t,n){var o=this;i.getRoomProperty(e,this._config).then((function(n){var s="singleModel"==o._config.modelType?e:e.split("_")[1];for(var r of n)if(r.id==s)return void i.getObjectData(o._config,o).then((function(i){e="singleModel"==o._config.modelType?e:`${e.split("_")[0]}.${e.split("_")[1]}`;var n=i.getElementProperties(e);n.splice(0,1),r.properties=n,t&&t(r)}))}))},getAreaProperty:function(e,t,n){var o=this;i.getAreaProperty(e,this._config).then((function(n){var s="singleModel"==o._config.modelType?e:e.split("_")[1];for(var r of n.areas)r.id==s&&i.getObjectData(o._config,o).then((function(i){e="singleModel"==o._config.modelType?e:`${e.split("_")[0]}.${e.split("_")[1]}`;var n=i.getElementProperties(e);n.splice(0,1),r.properties=n,t&&t(r)}))}))},getModelGroup:function(e,t){i.getModelGroup(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getFiles:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getLinkGraph:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingsheets(e,t,n,o){var s=this;i.getDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType,s._config.dataEnvType)}))},getLinksJson(e,t,n,o){var s=this;e=e||s._config.modelId,i.getLinksJson(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getFloors:function(e,t){var n=this;i.getFloors(this._config).then((function(t){for(let e of t.data)e.miniMap=`${n._config.databagId}/resource/v3/maps/${e.name}.png`;e&&e(t.data)}))},getElementByConditions:function(e,t,n){var o=this;i.getObjectData(this._config,o).then((function(i){n&&n(i.getElementByConditions(e,t,o._config))}))},getMapInfo:function(e,t){var n=i.getMapInfo(this._config,t);e&&e(n)},getMapInfoAsync:function(e,t,n){i.getMapInfoAsync(this._config,n).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getExplosionFloorsInfo:function(e,t){const n=i.getExplosionFloorsInfo(this._config);e&&e(n)},getLevels:function(e,t,n){i.getLevels(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getViews:function(e){var t=i.getViews(this._config);e&&e(t)},getViewsById:function(e,t){var n=this._config;n.fileId=e;var o=i.getViewsById(n);t&&t(o)},getViewData:function(e,t){var n=Object.assign({},this._config);n.viewId=e,i.getViewData(n).then((function(e){"[object Function]"===Object.prototype.toString.call(t)&&t(e)})).catch((function(e){"[object Function]"===Object.prototype.toString.call(failure)&&failure(e)}))},getRooms:function(e,t){i.getRooms(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomBoundary:function(e,t,n){i.getRoomBoundary(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getAllDrawingsheets:function(e,t,n,o){var s=this;i.getAllDrawingsheets(this._config).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){n&&n({drawingList:[]},s._config.modelType)}))},getCategoryVisibility:function(e,t){i.getCategoryVisibility(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getText:function(e,t){i.getText(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentGroups:function(e,t){i.getSegmentGroups(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentFromGroups:function(e,t,n){i.getSegmentFromGroups(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentTree:function(e,t){i.getSegmentTree(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentById:function(e,t,n){i.getSegmentById(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentElementIds:function(e,t,n){i.getSegmentElementIds(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadata:function(e,t,n){i.getPartialElementsMetadata(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadataFile:function(e){return i.getPartialElementsMetadataFile(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getManifest:function(e,t){i.getManifest(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getNestedComponents:function(e,t){i.getNestedComponents(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getObjectMap:function(e,t){i.getObjectMap(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getWalkthrough:function(e,t){i.getWalkthrough(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getProjectInfo:function(e,t){var n=this;i.getProjectInfo(n._config).then((function(t){e&&e(t,n._config.modelType)})).catch((function(e){t&&t(e)}))},getModelInfo:function(e,t){i.getModelInfo(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getBimtileInfo:function(e,t,n,o){const s=`${this._config.relativeUrlWithoutDatabagId}/${e}`;i.getBimtileInfo(s,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getFeatureStyle:function(e,t){i.getFeatureStyle(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDimensions:function(e,t,n){i.getDimensions(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getLevelmapping:function(e,t){i.getLevelmapping(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingTree:function(e,t){i.getDrawingTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))},getViewsTree:function(e,t){i.getViewsTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))}},t.OfflineDataManager=n}(),b=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),E=(t,i)=>e.Web.Lang.Utility.HttpRequest.promiseJSONRequest(t,i,y.EnableStorage),M=t=>e.Web.Lang.Utility.HttpRequest.promiseJsonFunction(t),C=t=>e.Web.Lang.Utility.HttpRequest.getUrl(t),x=e.Web.Lang.Utility.HttpRequest.ajax,T={getMepSystem:function(e,t){if("integrateModel"==t.modelType)var i=`${t.resourceHost}/${t.databagId}/metadata/${e}/mepsystem.json`;else i=`${t.resourceHost}/${t.databagId}/metadata/mepsystem.json`;let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/mepsystem.json`:"metadata/mepsystem.json",status:"noCode",...t.httpDefaultParams};return M(n)},getTreeNewData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/data/tree.json`,path:"data/tree.json",status:"noCode",...e.httpDefaultParams};return M(t)},getTreeOldData:function(e){if("singleModel"==e.modelType)var t=`${e.APIHost}/data/v2/files/${e.modelId}/tree?v=2.0&view_token=${e.viewToken}`;else t=`${e.APIHost}/data/v2/integrations/${e.modelId}/tree?view_token=${e.viewToken}&treeType=specialty`;return E(t)},getSectionData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/sectionCut.json`,path:"metadata/sectionCut.json",status:"noCode",...e.httpDefaultParams};return M(t)},getDrawingList:function(e){return e=e,{fromSingleModel:function(t,i){var n=`${e.APIHost}/data/v2/files/${t}/drawingsheets?elementId=${i}&view_token=${e.viewToken}`;return E(n)},fromIntegrateModel:function(t,i,n){var o=`${e.APIHost}/data/v2/integrations/${t}/drawingsheets?fileIdHash=${i}&elementId=${n}&view_token=${e.viewToken}`;return E(o)}}},getAreas:function(e){if("singleModel"==e.modelType)var t=`${e.APIHost}/data/v2/files/${e.modelId}/floors?includeRoom=true&includeArea=true&view_token=${e.viewToken}`;else t=`${e.APIHost}/data/v2/integrations/${e.modelId}/floors?includeRoom=true&includeArea=true&view_token=${e.viewToken}`;return E(t)},getRoomProperty:function(e,t){if("singleModel"==t.modelType)var i=`${t.APIHost}/data/v2/files/${t.modelId}/rooms/${e}?view_token=${t.viewToken}`;else i=`${t.APIHost}/data/v2/integrations/${t.modelId}/rooms/${e}?view_token=${t.viewToken}`;return E(i)},getAreaProperty:function(e,t){if("singleModel"==t.modelType)var i=`${t.APIHost}/data/v2/files/${t.modelId}/areas/${e}?view_token=${t.viewToken}`;else i=`${t.APIHost}/data/v2/integrations/${t.modelId}/areas/${e}?view_token=${t.viewToken}`;return E(i)},getObjectData:function(e,t){if("singleModel"==e.modelType)var i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`;else if("integrateModel"==e.modelType){var n=t.split(".");i=1==n.length?e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?view_token=${e.viewToken}`}else i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/sections/${e.modelId}/elements/${t}?view_token=${e.viewToken}`;return E(i)},getFamilyData:function(e,t){let i=`${e.APIHost}/data/v2/rfaFiles/${e.modelId}/familyTypes/${t}?view_token=${e.viewToken}`;return E(i)},getEditedObjectData:function(e,t){if("singleModel"==e.modelType)var i=e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/files/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/files/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`;else{var n=t.split(".");i=1==n.length?e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/elements/${t}?includeOverrides=true&view_token=${e.viewToken}`:e.enableComponentCut?`${e.APIHost}/data/v1/component-segmentation/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?includeOverrides=true&view_token=${e.viewToken}`:`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${n[0]}/elements/${n[1]}?includeOverrides=true&view_token=${e.viewToken}`}return E(i)},getFiles:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/files?includeDrawingSheet=true&view_token=${e.viewToken}`;return E(t)},getMaterialOverride:function(e,t,i){t=null==t?i.viewToken:t,e=null==e?i.modelId:e;var n=`${i.APIHost}/data/v2/materialoverridesets/${e}?materialFormat=FULL_INSTANCE_JSON&sort=true&view_token=${t}&compact=true`;return E(n)},getLinkGraph:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/linkGraph?view_token=${e.viewToken}`;return E(t)},getMaterialProperty:function(e,t){if(t){var i=t.split(".");if("singleModel"==e.modelType)var n=`${e.APIHost}/data/v2/files/${e.modelId}/elements/${i[0]}/materials?view_token=${e.viewToken}`;else n="integrateModel"==e.modelType?`${e.APIHost}/data/v2/integrations/${e.modelId}/files/${i[0]}/elements/${i[1]}/materials?view_token=${e.viewToken}`:`${e.APIHost}/data/v2/sections/${e.modelId}/elements/${t}/materials?view_token=${e.viewToken}`;return E(n)}failure&&failure({})},getDrawingsheets:function(e,t){var i=`${e.APIHost}/data/v2/files/${t}/drawingsheets?fileId=${t}&view_token=${e.viewToken}`;return E(i)},getAllDrawingsheets:function(e,t){let i={url:`${e.resourceHost}/${e.integrateDrawings&&e.integrateDrawings.databagId||e.databagId}/metadata/drawings.json`,path:"metadata/drawings.json",status:"noCode",...e.httpDefaultParams};return M(i)},getLinksJson:function(e,t){var i=`${e.resourceHost}/${e.databagId}/metadata/links.json`;"singleModel"==e.modelType&&(i=`${e.resourceHost}/${e.databagId}/metadata/rvtLinks.json`);let n={url:i,path:"metadata/links.json",status:"noCode",...e.httpDefaultParams};return M(n)},getFloors:function(e){if("singleModel"==e.modelType)var t=`${e.APIHost}/data/v2/files/${e.modelId}/floors?view_token=${e.viewToken}`;else t=`${e.APIHost}/data/v2/integrations/${e.modelId}/floors?view_token=${e.viewToken}`;return E(t)},getElementByConditions:function(e,t,i){var n="";for(let e in i)n+=`&${e}=${i[e]}`;if("singleModel"==e.modelType)var o=`${e.APIHost}/data/element/id?fileId=${t}${n}&view_token=${e.viewToken}`;else o=`${e.APIHost}/data/v2/integrations/${t}/elementIds?view_token=${e.viewToken}${n}`;return E(o)},getComponentsByConditions:function(e,t,i,n,o){var s={targetIds:[String(t)],targetType:"integrateModel"===e.modelType?"integration":"file",query:{boolOr:[]}};for(let e=0;e<i.length;e++){let t=i[e],n={boolAnd:[]};for(let e in t)n.boolAnd.push({match:{["levelName"===e?"floor":e]:t[e]}});1==n.boolAnd.length&&n.boolAnd.push(n.boolAnd[0]),s.query.boolOr.push(n)}1==s.query.boolOr.length&&s.query.boolOr.push(s.query.boolOr[0]);var r=`${e.APIHost}/data/v2/query/elementIds?view_token=${e.viewToken}`;return E({url:r,type:"post",data:JSON.stringify(s),headers:{"Content-Type":"application/json"}})},getMaterialJson:function(e,t,i){return E({url:`https://apigate.glodon.com/ggpassets/materiallibrary/libraries/${t}/materials?materialIds=${i}&instance=true`,type:"get",data:null,headers:{Authorization:"Bearer "+e,"Content-Type":"application/json",engine:"COMMON"}})},getTextureJson:function(e,t,i){return E({url:`https://apigate.glodon.com/ggpassets/materiallibrary/libraries/${t}/resources/${i}`,type:"get",data:null,headers:{Authorization:"Bearer "+e,"Content-Type":"application/json",engine:"GGP"}})},getMapInfo:function(e,t){this._opt;var i={},n=[];this._helper,2===t||"integrateModel"!==e.modelType?x({url:C({url:`${e.resourceHost}/${e.databagId}/metadata/axisgrids/grids.json.gz`,path:"metadata/axisgrids/grids.json.gz",...e.httpDefaultParams}),async:!1,success:function(e){var t=y.AxisGridManager.adaptGridData(JSON.parse(e));i.Grids=t.grids}}):x({url:C({url:`${e.resourceHost}/${e.databagId}/metadata/grids.json`,path:"metadata/grids.json",...e.httpDefaultParams}),async:!1,success:function(e){var t=JSON.parse(e);i.Grids=v(t.grids)}}),x({async:!1,url:C({url:`${e.resourceHost}/${e.databagId}/metadata/levels.json`,path:"metadata/levels.json",...e.httpDefaultParams}),success:function(e){i.Levels=JSON.parse(e).levels}}),x({async:!1,url:C({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,path:"resource/model/maps/output.json",...e.httpDefaultParams}),dataType:"text",success:function(t){var i=JSON.parse(t);for(var o in i){var s=i[o];null==s.id&&(s.id=o),s.path=C({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/${s.id}.png`,path:`resource/model/maps/${s.id}.png`,...e.httpDefaultParams}),s.name=o,n.push(s)}}});let o=i.Levels;if(o){let e=e=>{let t=!1;return n.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t<o.length;t++)e(o[t].id)||(o.splice(t,1),t--)}return{axisGrid:i,floors:n}},getMapInfoAsync:function(e,t){return new Promise(((i,n)=>{let o={Grids:[]},s=[];const r="integrateModel"===e.modelType&&2!==t,a=`${e.resourceHost}/${e.databagId}/metadata/${r?"grids.json":"axisgrids/grids.json.gz"}`,l="metadata/"+(r?"grids.json":"axisgrids/grids.json.gz");Promise.allSettled([M({url:a,path:l,status:"noCode",...e.httpDefaultParams}),M({url:`${e.resourceHost}/${e.databagId}/metadata/levels.json`,path:"metadata/levels.json",status:"noCode",...e.httpDefaultParams}),M({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,path:"resource/model/maps/output.json",status:"noCode",...e.httpDefaultParams})]).then((t=>{let[n,a,l]=t;if(n.value)if(r)o.Grids=v(n.value.grids);else{var h=y.AxisGridManager.adaptGridData(n.value);o.Grids=h.grids}o.Levels=a.value.levels,(t=>{for(var n in t){var r=t[n];null==r.id&&(r.id=n),r.path=C({url:`${e.resourceHost}/${e.databagId}/resource/model/maps/${r.id}.png`,path:`resource/model/maps/${r.id}.png`,...e.httpDefaultParams}),r.name=n,s.push(r)}let a=o.Levels;if(a){let e=e=>{let t=!1;return s.some((i=>(t=i.id.toString()===e.toString(),t))),t};for(let t=0;t<a.length;t++)e(a[t].id)||(a.splice(t,1),t--)}i({axisGrid:o,floors:s})})(l.value)})).catch(n)}))},getExplosionFloorsInfo:function(e){let t={};return x({async:!1,url:`${e.resourceHost}/${e.databagId}/metadata/levels.json`,success:function(e){const i=JSON.parse(e);t.levels=i.levels,t.version=i.version}}),t.version&&t.version>1||x({async:!1,url:`${e.resourceHost}/${e.databagId}/resource/model/maps/output.json`,dataType:"text",success:function(e){const i=JSON.parse(e);t.floors=i}}),t},getExplosionFloorsInfoAsync:function(e){let t={};return new Promise(((i,n)=>{const o=`${e.resourceHost}/${e.databagId}/metadata/levels.json`;E(o,"noCode").then((o=>{t.levels=o.levels,t.levels.length>0&&t.levels[0].boundingBox?i(t):E(`${e.resourceHost}/${e.databagId}/resource/v3/maps/output.json`,"noCode").then((e=>{t.floors=e,i(t)})).catch(n)})).catch(n)}))},getLevels:function(e,t){let i=`${t.resourceHost}/${t.databagId}/metadata/levels.json`,n="metadata/levels.json";e&&(i=`${t.resourceHost}/${t.databagId}/metadata/${e}/levels.json`,n=`metadata/${e}/levels.json`);let o={url:i,path:n,status:"noCode",...t.httpDefaultParams};return M(o)},getViews:function(e){var t={data:null,resourceHost:e.resourceHost};return x({url:C({url:`${e.resourceHost}/${e.databagId}/metadata/views.json`,path:"metadata/views.json",...e.httpDefaultParams}),async:!1,success:function(e){t.data=e}}),t},getViewsById:function(e){var t={data:null,resourceHost:e.resourceHost};return x({url:C({url:`${e.resourceHost}/${e.databagId}/metadata/${e.fileId}/views.json`,path:`metadata/${e.fileId}/views.json`,...e.httpDefaultParams}),async:!1,success:function(e){t.data=e}}),t},getViewData:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/viewStates/${e.viewId}.json`,path:`metadata/viewStates/${e.viewId}.json`,status:"noCode",...e.httpDefaultParams};return M(t)},getRooms:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/rooms.json`,path:"metadata/rooms.json",status:"noCode",...e.httpDefaultParams};return M(t)},getRoomBoundary:function(e,t){let i={url:`${t.resourceHost}/${t.databagId}/metadata/roomsboundary/${e}.json`,path:`metadata/roomsboundary/${e}.json`,status:"noCode",...t.httpDefaultParams};return M(i)},getCategoryVisibility:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/categoryVisibility.json`,path:"metadata/categoryVisibility.json",status:"noCode",...e.httpDefaultParams};return M(t)},getText:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/text.json`,path:"metadata/text.json",status:"noCode",...e.httpDefaultParams};return M(t)},getScheduleList:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/schedule.json`,path:"metadata/schedule.json",status:"noCode",...e.httpDefaultParams};return M(t)},getScheduleById:function(e,t){let i={url:`${t.resourceHost}/${t.databagId}/metadata/schedule/${e}.txt`,path:`metadata/schedule/${e}.txt`,status:"noCode",...t.httpDefaultParams};return M(i)},getSegmentGroups:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups?view_token=${e.viewToken}`;return E(t,"noCode")},getSegmentFromGroups:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentGroups/${t}/segments?view_token=${e.viewToken}`;return E(i,"noCode")},getSegmentTree:function(e){var t=`${e.APIHost}/data/v2/integrations/${e.modelId}/segmentTree?view_token=${e.viewToken}`;return E(t,"noCode")},getSegmentById:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}?view_token=${e.viewToken}`;return E(i,"noCode")},getSegmentElementIds:function(e,t){var i=`${e.APIHost}/data/v2/integrations/${e.modelId}/segments/${t}/elementIds?view_token=${e.viewToken}`;return E(i,"noCode")},getPartialElementsMetadata:function(e,t){let i={url:`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`,path:"metadata/partial_elements_metadata.json",status:"noCode",...e.httpDefaultParams};return M(i)},getPartialElementsMetadataFile:function(e,t){return C({url:`${e.resourceHost}/${t}/metadata/partial_elements_metadata.json`,path:"metadata/partial_elements_metadata.json",...e.httpDefaultParams})},getDatabagResource:function(e,t){return C({url:`${e.resourceHost}/${t}/resource/v3/model`,path:"resource/v3/model",...e.httpDefaultParams})},getModelGroup:function(e,t){let i={url:`${e.resourceHost}/${e.databagId}/metadata/modelSetsTree.json`,path:"metadata/modelSetsTree.json",status:"noCode",...e.httpDefaultParams};return M(i)},getManifest:function(e){let t={url:`${e.resourceHost}/${e.databagId}/manifest.json`,path:"manifest.json",status:"noCode",...e.httpDefaultParams};return M(t)},getNestedComponents:function(e){let t={url:`${e.relativeUrl}/metadata/nestedComponents.json`,path:"metadata/nestedComponents.json",status:"noCode",...e.httpDefaultParams};return M(t)},getObjectMap:function(e){let t={url:`${e.relativeUrl}/metadata/objectMap.json.gz`,path:"metadata/objectMap.json.gz",status:"noCode",...e.httpDefaultParams};return M(t)},getWalkthrough:function(e){let t={url:`${e.relativeUrl}/data_ext/walkthrough.json`,path:"data_ext/walkthrough.json",status:"noCode",...e.httpDefaultParams};return M(t)},getProjectInfo:function(e){let t={url:`${e.resourceHost}/${e.databagId}/metadata/project.json`,path:"metadata/project.json",status:"noCode",...e.httpDefaultParams};return M(t)},getModelInfo:function(e){let t={url:`${e.relativeUrl}/resource/v3/model/config.json`,path:"resource/v3/model/config.json",status:"noCode",...e.httpDefaultParams};return M(t)},getBimtileInfo:function(e,t,i){let n={url:`${e}/resource/v3/model/${t}`,path:`resource/v3/model/${t}`,status:"noCode",...i.httpDefaultParams};return M(n)},getFeatureStyle:function(e){let t={url:`${e.relativeUrl}/resource/v3/model/featureStyle.json`,path:"resource/v3/model/featureStyle.json",status:"noCode",...e.httpDefaultParams};return M(t)},getDimensions:function(e,t){let i=`${t.relativeUrl}/metadata/ModelDimensions.json`;return"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/ModelDimensions.json`),i=C({url:i,path:"integrateModel"==t.modelType?"metadata/ModelDimensions.json":`metadata/${e}/ModelDimensions.json`,...t.httpDefaultParams}),E(i,"noCode")},getLevelmapping:function(e){let t={url:`${e.relativeUrl}/metadata/levelmapping.json`,path:"metadata/levelmapping.json",status:"noCode",...e.httpDefaultParams};return M(t)},getDrawingTree:function(e,t){var i=`${t.relativeUrl}/metadata/drawingsTree.json`;"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/drawingsTree.json`);let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/drawingsTree.json`:"metadata/drawingsTree.json",status:"noCode",...t.httpDefaultParams};return M(n)},getViewsTree:function(e,t){var i=`${t.relativeUrl}/metadata/viewsTree.json`;"integrateModel"==t.modelType&&(i=`${t.relativeUrl}/metadata/${e}/viewsTree.json`);let n={url:i,path:"integrateModel"==t.modelType?`metadata/${e}/viewsTree.json`:"metadata/viewsTree.json",status:"noCode",...t.httpDefaultParams};return M(n)}},b.OnlineDataProdiver=T,function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data.OnlineDataProdiver");function n(e){this._config=e,this._config.httpDefaultParams={APIHost:e.APIHost,loadMode:e.loadMode,fileId:e.modelId,viewToken:e.viewToken,modelType:e.modelType}}n.prototype={getOfflineDataManager(){return this._offlineDatamanager=this._offlineDatamanager||new t.OfflineDataManager(this._config),this._offlineDatamanager},getComponentProperty:function(e,t,n){const o=this;if(!e)return console.warn("elementId must not be empty!."),void(n&&n());i.getObjectData(this._config,e).then((function(e){t&&t(e)})).catch((function(i){y.EnableStorage&&!o._config.isGlobeScene?o.getOfflineDataManager().getComponentProperty(e,t,n):n&&n(i)}))},getFamilyProperty:function(e,t,n){if(!e)return console.warn("familyTypeId must not be empty!."),void(n&&n());i.getFamilyData(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getComponentOverriddenProperty:function(e,t,n){if(!e)return console.warn("elementId must not be empty!."),void(n&&n());i.getEditedObjectData(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getMaterialProperty:function(e,t,n){var o=this;i.getMaterialProperty(this._config,e).then((function(e){t&&t(e)})).catch((function(i){y.EnableStorage?o.getOfflineDataManager().getMaterialProperty(e,t,n):n&&n(i)}))},getTreeOldData:function(e,t){var n=this;i.getTreeOldData(n._config).then((function(t){e&&e(t,n._config.modelType,"old")})).catch((function(e){t&&t(e)}))},getTreeNewData:function(e,t,n=!0){var o=this;i.getTreeNewData(o._config).then((function(t){e&&(!n&&e(t,o._config.modelType),n&&e(t.data,o._config.modelType))})).catch((function(e){t&&t(e)}))},getSectionData:function(e,t,n=!0){var o=this;i.getSectionData(o._config).then((function(t){e&&(!n&&e(t,o._config.modelType),n&&e(t.data,o._config.modelType))})).catch((function(e){t&&t(e)}))},getMepSystem:function(e,t,n){var o=this;i.getMepSystem(e,o._config).then((function(e){t&&t(e,o._config.modelType)})).catch((function(e){n&&n(e)}))},getAreas:function(e,t){i.getAreas(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomProperty:function(e,t,n){i.getRoomProperty(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getDrawingList:function(e,t,n,o){var s=this._config.modelType;if("integrateModel"==s){var r=t.split(".")[0],a=t.split(".")[1];i.getDrawingList(this._config).fromIntegrateModel(e,r,a).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))}else"singleModel"==s&&i.getDrawingList(this._config).fromSingleModel(e,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getModelGroup:function(e,t){i.getModelGroup(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getAreaProperty:function(e,t,n){i.getAreaProperty(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getFiles:function(e,t){i.getFiles(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getMaterialOverride:function(e,t,n,o){i.getMaterialOverride(e,t,this._config).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getLinkGraph:function(e,t){i.getLinkGraph(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingsheets(e,t,n,o){var s=this;e=e||s._config.modelId,i.getDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getAllDrawingsheets(e,t,n,o){var s=this;e=e||s._config.modelId,i.getAllDrawingsheets(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getLinksJson(e,t,n,o){var s=this;e=e||s._config.modelId,i.getLinksJson(this._config,e).then((function(e){n&&n(e,s._config.modelType)})).catch((function(e){o&&o(e)}))},getFloors(e,t){i.getFloors(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getElementByConditions(e,t,n,o){i.getElementByConditions(this._config,e,t).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getComponentsByConditions(e,t,n,o){i.getComponentsByConditions(this._config,e,t).then((function(e){n&&n(e&&e[0].elementIds)})).catch((function(e){o&&o(e)}))},getMaterialJson(e,t,n,o,s){i.getMaterialJson(e,t,n).then((function(e){o&&o(e)})).catch((function(e){s&&s(e)}))},getTextureJson:function(e,t,n,o,s){i.getTextureJson(e,t,n).then((function(e){o&&o(e)})).catch((function(e){s&&s(e)}))},getMapInfo:function(e,t){var n=i.getMapInfo(this._config,t);e&&e(n)},getMapInfoAsync:function(e,t,n){i.getMapInfoAsync(this._config,n).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getExplosionFloorsInfo:function(e,t){const n=i.getExplosionFloorsInfo(this._config);e&&e(n)},getLevels:function(e,t,n){i.getLevels(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getViews:function(e){var t=i.getViews(this._config);e&&e(t)},getViewsById:function(e,t){var n=this._config;n.fileId=e;var o=i.getViewsById(n);t&&t(o)},getViewData:function(e,t,n){var o=Object.assign({},this._config);o.viewId=e,i.getViewData(o).then((function(e){"[object Function]"===Object.prototype.toString.call(t)&&t(e)})).catch((function(e){"[object Function]"===Object.prototype.toString.call(n)&&n(e)}))},getRooms:function(e,t){i.getRooms(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getRoomBoundary:function(e,t,n){i.getRoomBoundary(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getCategoryVisibility:function(e,t){i.getCategoryVisibility(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getText:function(e,t){i.getText(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getScheduleList:function(e,t){i.getScheduleList(this._config).then((function(t){e&&e(t.scheduleList)})).catch((function(e){t&&t(e)}))},getScheduleById:function(e,t,n){i.getScheduleById(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentGroups:function(e,t){i.getSegmentGroups(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentFromGroups:function(e,t,n){i.getSegmentFromGroups(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentTree:function(e,t){i.getSegmentTree(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getSegmentById:function(e,t,n){i.getSegmentById(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getSegmentElementIds:function(e,t,n){i.getSegmentElementIds(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadata:function(e,t,n){i.getPartialElementsMetadata(this._config,e).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getPartialElementsMetadataFile:function(e){return i.getPartialElementsMetadataFile(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getDatabagResource:function(e){return i.getDatabagResource(this._config,e)},getManifest:function(e,t){i.getManifest(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getNestedComponents:function(e,t){i.getNestedComponents(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getObjectMap:function(e,t){i.getObjectMap(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getWalkthrough:function(e,t){i.getWalkthrough(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getProjectInfo:function(e,t){var n=this;i.getProjectInfo(n._config).then((function(t){e&&e(t,n._config.modelType)})).catch((function(e){t&&t(e)}))},getModelInfo:function(e,t){i.getModelInfo(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getBimtileInfo:function(e,t,n,o){const s=`${this._config.relativeUrlWithoutDatabagId}/${e}`;i.getBimtileInfo(s,t,this._config).then((function(e){n&&n(e)})).catch((function(e){o&&o(e)}))},getFeatureStyle:function(e,t){i.getFeatureStyle(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDimensions:function(e,t,n){i.getDimensions(e,this._config).then((function(e){t&&t(e)})).catch((function(e){n&&n(e)}))},getLevelmapping:function(e,t){i.getLevelmapping(this._config).then((function(t){e&&e(t)})).catch((function(e){t&&t(e)}))},getDrawingTree:function(e,t){i.getDrawingTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))},getViewsTree:function(e,t){i.getViewsTree(e,this._config).then((function(e){t&&t(e)})).catch((function(e){t&&t({})}))}},t.OnlineDataManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=function(e){if(this._config=e,this._objectData=null,this._cache={},"Local"==e.dataEnvType?this.dataManager=new t.OfflineDataManager(e):this.dataManager=new t.OnlineDataManager(e),!e.viewToken)return!1};i.prototype={getFamilyTypes:function(e,t){this.dataManager.getFamilyTypes(e,t)},getComponentProperty:function(e,t,i){this.dataManager.getComponentProperty(e,t,i)},getFamilyProperty:function(e,t,i){this.dataManager.getFamilyProperty(e,t,i)},getComponentOverriddenProperty:function(e,t,i){this.dataManager.getComponentOverriddenProperty(e,t,i)},getDrawingList:function(e,t,i,n){this.dataManager.getDrawingList(e,t,i,n)},getTreeOldData:function(e,t){this.dataManager.getTreeOldData(e,t)},getTreeNewData:function(e,t,i=!1){this.dataManager.getTreeNewData(e,t,i)},getSectionData:function(e,t,i=!1){this.dataManager.getSectionData(e,t,i)},getMepSystem:function(e,t,i){this.dataManager.getMepSystem(e,t,i)},getModeTree:function(e,t){console.warn("This function is deprecated. Please use getTreeOldData instead."),this.getTreeOldData(e,t)},getFloors:function(e,t){this.dataManager.getFloors(e,t)},getAreas:function(e,t){this.dataManager.getAreas(e,t)},getAreaProperty:function(e,t,i){this.dataManager.getAreaProperty(e,t,i)},getModelGroup:function(e,t){this.dataManager.getModelGroup(e,t)},getMaterialProperty:function(e,t,i){this.dataManager.getMaterialProperty(e,t,i)},getRoomProperty:function(e,t,i){this.dataManager.getRoomProperty(e,t,i)},getFiles:function(e,t){this.dataManager.getFiles(e,t)},getMaterialOverride:function(e,t,i,n){this.dataManager.getMaterialOverride(e,t,i,n)},getLinkGraph:function(e,t){this.dataManager.getLinkGraph(e,t)},getDrawingsheets:function(e,t,i,n){this.dataManager.getDrawingsheets(e,t,i,n)},getElementByConditions:function(e,t,i,n){this.dataManager.getElementByConditions(e,t,i,n)},getComponentsByConditions:function(e,t,i,n){this.dataManager.getComponentsByConditions(e,t,i,n)},getMaterialJson(e,t,i,n,o){this.dataManager.getMaterialJson(e,t,i,n,o)},getTextureJson:function(e,t,i,n,o){this.dataManager.getTextureJson(e,t,i,n,o)},getAllDrawingsheets:function(e,t,i,n){this.dataManager.getAllDrawingsheets(e,t,i,n)},getLinksJson:function(e,t,i,n){this.dataManager.getLinksJson(e,t,i,n)},getMapInfo:function(e,t){this.dataManager.getMapInfo(e,t)},getMapInfoAsync:function(e,t,i){this.dataManager.getMapInfoAsync(e,t,i)},getExplosionFloorsInfo:function(e,t){this.dataManager.getExplosionFloorsInfo(e,t)},getCategoryVisibility:function(e,t){this.dataManager.getCategoryVisibility(e,t)},getText:function(e,t){this.dataManager.getText(e,t)},getScheduleList:function(e,t){this.dataManager.getScheduleList(e,t)},getScheduleById:function(e,t,i){this.dataManager.getScheduleById(e,t,i)},getSegmentGroups:function(e,t){this.dataManager.getSegmentGroups(e,t)},getSegmentFromGroups:function(e,t,i){this.dataManager.getSegmentFromGroups(e,t,i)},getSegmentTree:function(e,t){this.dataManager.getSegmentTree(e,t)},getSegmentById:function(e,t,i){this.dataManager.getSegmentById(e,t,i)},getSegmentElementIds:function(e,t,i){this.dataManager.getSegmentElementIds(e,t,i)},getPartialElementsMetadata:function(e,t,i){this.dataManager.getPartialElementsMetadata(e,t,i)},getPartialElementsMetadataFile:function(e){return this.dataManager.getPartialElementsMetadataFile(e)},getDatabagResource:function(e){return this.dataManager.getDatabagResource(e)},getManifest:function(e,t){return this.dataManager.getManifest(e,t)},getNestedComponents:function(e){return this.dataManager.getNestedComponents(e)},getObjectMap:function(e){return this.dataManager.getObjectMap(e)},getWalkthrough:function(e){return this.dataManager.getWalkthrough(e)},getViews:function(e){return this.dataManager.getViews(e)},getViewData:function(e,t,i){return this.dataManager.getViewData(e,t,i)},getProjectInfo:function(e,t){this.dataManager.getProjectInfo(e,t)},getModelInfo:function(e,t){return this.dataManager.getModelInfo(e,t)},getBimtileInfo:function(e,t,i,n){return this.dataManager.getBimtileInfo(e,t,i,n)},getFeatureStyle:function(e,t){return this.dataManager.getFeatureStyle(e,t)},getDimensions:function(e,t,i){return this.dataManager.getDimensions(e,t,i)},getLevelmapping:function(e){return this.dataManager.getLevelmapping(e)},getDrawingTree:function(e,t){return this.dataManager.getDrawingTree(e,t)},getViewsTree:function(e,t){return this.dataManager.getViewsTree(e,t)}},t.MetaDataManager=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").FamilyDataManagerConfig=function(){return{resourceHost:g.resourceHost,databagId:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.HttpRequest,n=function(e){if(!e.databagId)return!1;this.__config=e};n.prototype.getFamilyTypes=function(e,t){let n,o=this.__config;"Local"==o.dataEnvType?(n=`./${o.databagId}/metadata/familyInfo.json`,o.resourcePath&&(n=`${o.resourcePath}/${o.databagId}/metadata/familyInfo.json`)):n=i.getUrl({url:`${o.resourceHost}/${o.databagId}/metadata/familyInfo.json`,path:"metadata/familyInfo.json",...this.__config.httpDefaultParams}),i.ajax({url:n,success:function(t){var i=(t=JSON.parse(t)).Types||t.types;for(let e=0,t=i.length;e<t;e++)i[e].id=i[e].Id||i[e].id,i[e].name=i[e].Name||i[e].name,delete i[e].Id,delete i[e].Name;e&&e(i)},failure:e=>{var i=JSON.parse(e);t&&t(i)}})},t.FamilyDataManager=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").IBLManagerConfig=function(){return{resourceHost:g.staticHost}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.HttpRequest,n=function(e){this.__config=e};n.prototype.getIBLConfig=function(e,t){let n,o=this.__config;if("Local"==o.dataEnvType)return!1;n=`${o.resourceHost}/resources/IBL/IBLConfig.json`,i.ajax({url:n,success:function(t){var i=JSON.parse(t);e&&e(i)},failure:e=>{var i=JSON.parse(e);t&&t(i)}})},t.IBLManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i={version:1,EnumObjectTableIndex:{OTI_OBJECTS_VALUES:0,OTI_PROPERTY_SCHEMAS:1,OTI_ELEMENT_PROPERTIES:2,OTI_FAMILY_PROPERTIES:3,OTI_FAMILIES:4,OTI_ELEMENTS:5,OTI_BOUNDING_BOX:6,OTI_ELEMENTS_CLASS:7}},n=function(e){this.url=e,this.objectsDB=[]};n.prototype={load:function(e){var t=this,i=["Values.json","Schemas.json","ElementProperties.json","FamilyTypeProperties.json","Families.json","Elements.json","BoundingBox.json"],n=i.length;i.forEach(((i,o)=>{const s=t.url+"/"+i+CLOUD.GlobalData.ZipResourcePostfix;CLOUD.Storage.IndexedDBHelper.loadWithStorage("InfoData",s,(()=>new Promise(((e,t)=>{(new THREE.FileLoader).load(s,e,void 0,t)}))),(t=>{this.objectsDB[o]=JSON.parse(t),0==(n-=1)&&e()}))}))},getFamilyTypeProperties:function(e){var t=this.objectsDB[i.EnumObjectTableIndex.OTI_FAMILIES][e];if(void 0===t)return null;for(var n=this.objectsDB[i.EnumObjectTableIndex.OTI_OBJECTS_VALUES],o=this.objectsDB[i.EnumObjectTableIndex.OTI_FAMILY_PROPERTIES],s=this.objectsDB[i.EnumObjectTableIndex.OTI_PROPERTY_SCHEMAS],r=0,a=0,l=0,h={},d=[],c=0,u=0,g=t[2],p=t[1];u<g;++u){a=4*o[r=2*(p+u)],l=o[r+1];var m=h[c=s[a]];void 0===m&&(m=[],h[c]=m,d.push(c)),m.push({key:n[s[a+1]],unit:n[s[a+3]],valueType:s[a+2],value:n[l]})}for(var f=[],w=(u=0,d.length);u<w;++u)c=d[u],f.push({group:n[c],items:h[c]});return f},getElementProperties:function(e){if(null==e)return null;var t=this.objectsDB[i.EnumObjectTableIndex.OTI_ELEMENTS][e];if(void 0===t)return null;for(var n=this.objectsDB[i.EnumObjectTableIndex.OTI_OBJECTS_VALUES],o=this.objectsDB[i.EnumObjectTableIndex.OTI_ELEMENT_PROPERTIES],s=this.objectsDB[i.EnumObjectTableIndex.OTI_PROPERTY_SCHEMAS],r=0,a=0,l=0,h={},d=[],c=0,u=0,g=t[2],p=t[1];u<g;++u){a=4*o[r=2*(p+u)],l=o[r+1];var m=h[c=s[a]];void 0===m&&(m=[],h[c]=m,d.push(c)),m.push({key:n[s[a+1]],unit:n[s[a+3]],valueType:s[a+2],value:n[l]})}for(var f=[],w=(u=0,d.length);u<w;++u)c=d[u],f.push({group:n[c],items:h[c]});var y=this.getFamilyTypeProperties(t[3]);if(!y)return f;var v={},b=[];for(var E of f=y.concat(f))if(v[E.group]){var M=[].concat.apply(v[E.group].items,E.items),C=[];for(var x of M){var T=!0;for(var P of C)x.key==P.key&&(T=!1);T&&C.push(x)}v[E.group]={group:v[E.group].group,items:C}}else v[E.group]=E;for(var E in v)"基本属性"==v[E].group?b.unshift(v[E]):b.push(v[E]);return b},getElementByConditions:function(e,t,n){var o=this.objectsDB[i.EnumObjectTableIndex.OTI_ELEMENTS_CLASS],s=Object.keys(t),r=[],a=[],l={},h={min:{x:null,y:null,z:null},max:{x:null,y:null,z:null}},d=[];for(let e of s)d.push({typeIndex:this._getGroupsKey(e,t[e],o),typeValue:t[e]});for(let e=0;e<o.groups.length;e+=3){let t=!0;for(let i of d){let n=o.groups[e][i.typeIndex];if(o.values[n]!=i.typeValue){t=!1;break}}if(t)if("singleModel"==n.modelType)r=r.concat(o.groups[e+1][""]);else{var c=o.groups[e+1],u=o.groups[e+2];for(var g in c)for(var p of c[g])a.push({fileId:g,elementId:p});(h.min.x>u[0]||null==h.min.x)&&(h.min.x=u[0]),(h.min.y>u[1]||null==h.min.y)&&(h.min.y=u[1]),(h.min.z>u[2]||null==h.min.z)&&(h.min.z=u[2]),(h.max.x<u[3]||null==h.max.x)&&(h.max.x=u[3]),(h.max.y<u[4]||null==h.max.y)&&(h.max.y=u[4]),(h.max.z<u[5]||null==h.max.z)&&(h.max.z=u[5])}}return"singleModel"==n.modelType?r:0==a.length?[]:(l.elements=a,l.boundingBox=h,l)},_getGroupsKey:function(e,t,i){var n=0;for(let t=0;t<i.keys.length;t++)if(i.keys[t]==e){n=t;break}return n},getBoundingBox:function(e){if(null==e)return null;var t=this.objectsDB[i.EnumObjectTableIndex.OTI_BOUNDING_BOX],n="";try{n={min:{x:t[e][0],y:t[e][1],z:t[e][2]},max:{x:t[e][3],y:t[e][4],z:t[e][5]}}}catch(e){console.log("no boundingBox Data"),n=""}return n}},t.ObjectPropertyManager=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data").FileManagerConfig=function(){return{APIHost:g.APIHost,resourceHost:g.resourceHost,viewToken:null,modelId:null,modelType:"singleModel",dataEnvType:g.dataEnvType||"BIMFACE"}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Data"),i=e.Web.Lang.Utility.HttpRequest,n=function(e){this.__config=e};n.prototype.getViewToken=function(e,t,n){let o,s=this.__config;if("singleModel"==s.modelType)return!1;"Local"!=s.dataEnvType?(o=`${s.APIHost}/data/v2/integrations/${s.modelId}/files/${e}/viewToken?view_token=${s.viewToken}`,i.ajax({url:o,type:"post",success:function(e){var i=JSON.parse(e);t&&t(i.data)},failure:e=>{var t=JSON.parse(e);n&&n(t)}})):t&&t()},t.FileManager=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable(),o=(Object.freeze({TranslucentOthers:"",HideOthers:""}),function(){let t=new e.Web.Lang.EventManager;this.viewerType="Viewer",this.isFullScreen=!1,this._defaultUnit=void 0,P(this),this.getEventManager=function(){return t}});o.prototype.destroy=function(){this.getEventManager=null,this.authenticate=null},o.prototype.init=function(){},o.prototype.getViewerType=function(e){return this.viewerType},o.prototype.addView=function(t,i,o){if(!n)return;this.loadTime||(this.loadTime=(new Date).getTime());let s=this,r=e.Bimface.Authentication.AuthenticationManager,a=(s._opt,new e.Bimface.Authentication.AuthenticationConfig);a.viewToken=t,a.APIHost=this._opt.APIHost,a.enableStorage=this.enableStorage,a.securityApi=this._opt.securityApi,(this.authenticate=new r(a)).authenticate((function(e){"bimView"==e.renderType&&("pdf-transfer"!==e.workerType?e.renderType="3DView":e.renderType="pdfView"),s.loadViewCore(e,i,o)}),(function(t){var i=e.Bimface.Viewer.Viewer3DEvent;s.getEventManager().fireEvent(i.Error,t)}))},o.prototype.loadViewCore=function(){},o.prototype.addEventListener=function(e,t,i){this.getEventManager().addEvent(e,t,i)},o.prototype.removeEventListener=function(e,t){this.getEventManager().removeEvent(e,t)},o.prototype.enableFullScreen=function(t){var i=this._opt.domElement,n=this;this.isFullScreen=t,t?e.Web.Lang.Utility.FullScreen.fullScreen(i):e.Web.Lang.Utility.FullScreen.exitFullScreen(),setTimeout((function(){n.resize()}),200)},o.prototype._loadNotSuportPromptPage=function(e){let t=i.create("div","bf-waring-container"),n=i.create("div","bf-waring"),o=i.create("span","bf-waring-icon"),s=i.create("span","bf-waring-text");s.innerText=BimfaceLanguage.bf_browser_notSupported,n.appendChild(o),n.appendChild(s),t.appendChild(n);let r=i.create("div","bf-suggestion");r.innerText=BimfaceLanguage.bf_browser_suggestion,t.appendChild(r);let a=i.create("div","bf-logo");t.appendChild(a),e.appendChild(t)},o.prototype.getUnit=function(){return"m"===this._defaultUnit?e.Bimface.Common.Units.LengthUnits.Meter:e.Bimface.Common.Units.LengthUnits.Millimeter},o.prototype.getNetwork=function(){const e=window.performance;if(!e)return function(){console.log("您的浏览器不支持performance属性")};const t=[];function i(e,t){const i=e.timing,n={timing:e.timing};return n.redirectTime=i.redirectEnd-i.redirectStart,n.lookupDomainTime=i.domainLookupEnd-i.domainLookupStart,n.connectTime=i.connectEnd-i.connectStart,n.requestTime=i.responseEnd-i.responseStart,n.domReadyTime=i.domComplete-i.domInteractive,n.whiteTime=i.responseStart-i.navigationStart,n.domLoadTime=i.domContentLoadedEventEnd-i.navigationStart,n.loadTime=i.loadEventEnd-i.navigationStart,n.resourceTiming=function(e){const t={entries:e.length,transferSize:0,encodedBodySize:0,decodedBodySize:0};let i=1/0,n=-1/0;return e.forEach((e=>{void 0!==e.duration&&void 0!==e.startTime&&(i=Math.min(i,e.startTime),n=Math.max(n,e.startTime+e.duration)),e.transferSize&&(t.transferSize+=e.transferSize),e.encodedBodySize&&(t.encodedBodySize+=e.encodedBodySize),e.decodedBodySize&&(t.decodedBodySize+=e.decodedBodySize)})),t.transferSize&&(t.transferSize=t.transferSize/1048576),t.encodedBodySize&&(t.encodedBodySize=t.encodedBodySize/1048576),t.decodedBodySize&&(t.decodedBodySize=t.decodedBodySize/1048576),t.finishTime=8*Math.ceil((n-i)/8),t}(t),n.requests=n.resourceTiming.entries,n.transferred=n.resourceTiming.transferSize,n.resourcesSize=n.resourceTiming.decodedBodySize,n.finishTime=n.resourceTiming.finishTime,n}return new PerformanceObserver((e=>{for(let i of e.getEntries())t.push(i)})).observe({entryTypes:["resource","navigation","longtask"]}),function(){return i(e,t)}}(),t.Viewer=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ImageRenderConfig=function(){return{domElement:null,unit:512,currentScale:1,position:new e.Web.Geometry.Point3d(0,0,0),delay:100,navigationMode:"Pan"}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom")),n=(e.Bimface.Viewer.Viewer2DEvent,function(t){let n=new e.Web.Lang.EventManager;var o=t.domElement,s=i.create("div","bf-image"),r=i.create("div","bf-image-scene"),a=i.create("div","bf-image-view");this._eventManager=n,r.appendChild(a),s.appendChild(r),o.appendChild(s),this._scene={width:o.offsetWidth,height:o.offsetHeight},this._navigationMode=t.navigationMode,this._domElement=o,this._imageView=a,this._imageScene=r,this._container=s,this._position=t.position,this._maxLevel=1,this._currentScale=t.currentScale,this._currentLevel=this.scaleToLevel(t.currentScale),this._opt=t,this._zooming,this._moving,this.bindEvent(),this.bindMobileEvent()});n.prototype={addEventListener:function(e,t){this._eventManager.addEvent(e,t)},removeEventListener:function(e,t){this._eventManager.removeEvent(e,t)},getDomElement:function(){return this._container},bindEvent:function(){var e,t,i,n,o=this,s=this._container,r=!1;s.addEventListener("mousedown",(function(i){i.preventDefault();var s=o._navigationMode;r=!0,e=o.getScale(),n=(new Date).getTime(),t=o.getClientPosition(i),"RectZoom"==s&&o.drawRect(t)})),s.addEventListener("mousemove",(function(n){if(n.preventDefault(),!r||window.hasDragBoxPanel)return!1;var s=o._navigationMode,a={x:(i=o.getClientPosition(n)).x-t.x,y:i.y-t.y};if("Pan"==s)o.move(a),t=i;else if("Zoom"==s){var l=i.y-t.y;Math.abs(l)>10&&o.setScale(e+l/200+e/10,t)}else o.drawRect(t,a)})),document.addEventListener("mouseup",(function(e){if(e.preventDefault(),"RectZoom"==o._navigationMode){var s,a=o._scene,l=o.getScale(),h={x:(i=o.getClientPosition(e)).x-t.x,y:i.y-t.y},d={x:(i.x+t.x)/2,y:(i.y+t.y)/2};s=a.width/a.height>h.x/h.y?a.height/h.y:a.width/h.x,o.setScale(s*l,d),o._imageScene.removeChild(o._rect),o._rect=null}else{if((new Date).getTime()-n<300){var c=o.getClientPosition(e),u=o.clientToWorld(c);o._eventManager.fireEvent("Clicked",{worldPosition:u,clientPosition:c})}}r=!1,t=i=l=null})),s.addEventListener("mousewheel",(function(e){e.preventDefault();var t=e.wheelDelta&&(e.wheelDelta>0?1:-1)||e.detail&&(e.detail>0?-1:1),i=o.getScale(),n=i+t*i/20,s=(o._container.getBoundingClientRect(),o.getClientPosition(e));o.setScale(n,s)})),s.addEventListener("DOMMouseScroll",(function(e){e.preventDefault();var t=e.wheelDelta&&(e.wheelDelta>0?1:-1)||e.detail&&(e.detail>0?-1:1),i=o.getScale(),n=i+t*i/20,s=(o._container.getBoundingClientRect(),o.getClientPosition(e));o.setScale(n,s)}))},bindMobileEvent:function(){var e,t,i,n,o=this,s=o._container;window.addEventListener("resize",(function(){o.resize()})),s.addEventListener("touchstart",(function(n){n.preventDefault(),(n=o.getMobileEvent(n)).isMulti?(e=o.getScale(),i=n.distance,t=n.point[0]):t=n.point})),s.addEventListener("touchend",(function(o){e=t=i=n=null})),s.addEventListener("touchmove",(function(s){if((s=o.getMobileEvent(s)).isMulti){n=s.distance;var r=e*n/i;o.setScale(r)}else{var a=s.point,l={x:a.x-t.x,y:a.y-t.y};o.move(l),t=a}}))},getMobileEvent:function(e){for(var t=[],i=null,n=0,o=(e=e.originalEvent||e).touches.length;n<o;n++)i=e.touches[n],t.push({x:i.pageX,y:i.pageY});return t.length<=1?{isMulti:!1,point:t[0]}:{isMulti:!0,distance:Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),point:t}},load:function(e){this._maxLevel=e.file.Attributes.DwgLevel,this._maxScale=Math.pow(2,this._maxLevel-1),this._item=e,this._imageView.innerHTML="",this.setBackgroundImage(`${e.file.Path}/L1/Model_0_0.${e.file.Attributes.DwgExt}`),this.showImagesLevel(this._currentLevel),this.fit()},addModel:function(e){this._maxScale=e.maxScale,this.showImages(e.images),this.fit()},showImagesLevel:function(e){var t=Math.pow(2,e-1),i=this._item,n=[];this._currentLevel=e;for(var o=0;o<t;o++)for(var s=0;s<t;s++){var r=`${i.file.Path}/L${e}/Model_${o}_${s}.${i.file.Attributes.DwgExt}`;n.push({row:o,col:s,src:r,level:e})}this.showImages(n)},fit:function(){var e=this,t=e._opt.unit,i=e._scene,n={x:(t-i.width)/2,y:(t-i.height)/2};e.setScale(1),e.setPosition(n)},resize:function(){var e=this._domElement;this._scene={width:e.offsetWidth,height:e.offsetHeight}},showImages:function(e){if(!e||0==e.length)return!1;this._currentImages=e,this.updateImages()},resizeImages:function(e){var t=this,i=t._opt,n=t._imageView.querySelectorAll(".bf-image-item"),o=n.length;t._backgroundImage&&(t._backgroundImage.style.width=i.unit*e+"px",t._backgroundImage.style.height=i.unit*e+"px",e<t._currentScale&&(t._backgroundImage.style.display="block"));for(var s=0;s<o;s++){var r=n[s],a=r.getAttribute("col"),l=r.getAttribute("row"),h=r.getAttribute("level"),d=e/Math.pow(2,h-1);"image"==r.nodeName?r.width>r.height?r.style.width=t._opt.unit*d+"px":r.style.height=t._opt.unit*d+"px":(r.style.width=t._opt.unit*d+"px",r.style.height=t._opt.unit*d+"px"),r.style.left=a*t._opt.unit*d+"px",r.style.top=l*t._opt.unit*d+"px"}},setBackgroundImage:function(e){var t=i.create("img","bf-image-background"),n=this._imageView,o=this._opt,s=this._currentScale;t.src=e.replace(/[#+? ]/g,(function(e){return escape(e)})),t.style.left=0,t.style.top=0,t.style.width=o.unit*s+"px",t.style.height=o.unit*s+"px",n.appendChild(t),this._backgroundImage=t},updateImages:function(){for(var e=this,t=e._opt,n=e._currentLevel,o=this._currentScale/Math.pow(2,n-1),s=e._imageView,r=s.querySelectorAll(".bf-image-item"),a=e._currentImages,l=e.getShowImages(a),h=l.length,d=0,c=function(t){if(d++,h==d&&r){for(var i=0;i<r.length;i++)try{s.removeChild(r[i])}catch(e){}e._backgroundImage&&(e._backgroundImage.style.display="none")}s.appendChild(t.item.domElement),e.render()},u=function(e){var n=i.create("img","bf-image-item");e.domElement=n,e.type="image",e.src=e.src.replace(/[#+? ]/g,(function(e){return escape(e)})),n.src=e.src,n.setAttribute("col",e.col),n.setAttribute("row",e.row),n.setAttribute("level",e.level),n.onload=function(){n.style.left=e.col*t.unit*o+"px",n.style.top=e.row*t.unit*o+"px",this.width>this.height?this.style.width=t.unit*o+"px":this.style.height=t.unit*o+"px",e.width=this.width,e.height=this.height,c({code:"success",item:e})},n.onabort=n.onerror=function(){var n=i.create("div","bf-image-item");n.setAttribute("col",e.col),n.setAttribute("row",e.row),n.setAttribute("level",e.level),n.style.left=e.col*t.unit*o+"px",n.style.top=e.row*t.unit*o+"px",n.style.width=t.unit*o+"px",n.style.height=t.unit*o+"px",e.domElement=n,e.type="default",c({code:"error",item:e})}},g=0;g<h;g++){u(l[g])}},getImages:function(){return this._currentImages},setScale:function(e,t){var i,n=this,o=n._container,s=n._opt;if(e>n._maxScale?e=n._maxScale:e<1&&(e=1),e==this._currentScale)return!1;t||(t={x:o.offsetWidth/2,y:o.offsetHeight/2}),i=n.clientToWorld(t),n.resizeImages(e),this._currentScale=e;var r=n.worldToClient(i),a={x:r.x-t.x,y:r.y-t.y},l=n.clientToWorld(a);n.setWorldPosition(l),n._zooming&&clearTimeout(n._zooming);var h=n.scaleToLevel(e);n._zooming=setTimeout((function(){h!=n._currentLevel?n.showImagesLevel(h):n.updateImages()}),s.delay),n._eventManager.fireEvent("Zooming",e),n.render()},getScale:function(){return this._currentScale},getCurrentLevel:function(){return this._currentLevel},setPosition:function(e){var t=this,i=this._imageScene.querySelector(".bf-image-view");i.style.left=-e.x+"px",i.style.top=-e.y+"px",this._position=e,clearTimeout(t._update),t._update=setTimeout((function(){t.updateImages(),t._eventManager.fireEvent("Moved",e),t.render()}),t._opt.delay)},setWorldPosition:function(e){this.setPosition({x:e.x/this._maxScale*this._currentScale,y:e.y/this._maxScale*this._currentScale})},getWorldPosition:function(){return this.clientToWorld({x:0,y:0})},clientToWorld:function(e){var t=this._position,i=t.x+e.x,n=t.y+e.y;return{x:i/this._currentScale*this._maxScale,y:n/this._currentScale*this._maxScale}},worldToClient:function(e){var t=this._position,i=e.x*this._currentScale/this._maxScale,n=e.y*this._currentScale/this._maxScale;return{x:i-t.x,y:n-t.y}},move:function(e){console.log("move");var t=this,i=t._position,n={x:i.x-e.x,y:i.y-e.y};t.setPosition(n),t._eventManager.fireEvent("Moving",n),t.render()},getShowImages:function(e){for(var t=this._opt.unit,i=this._position,n=this._currentScale,o=this._currentLevel,s=this._scene,r=n/Math.pow(2,o-1),a=[],l=0,h=e.length;l<h;l++){var d=e[l];(1+d.col)*t*r>i.x&&(1+d.row)*t*r>i.y&&d.col*t*r<i.x+s.width&&d.row*t*r<i.y+s.height&&a.push(d)}return a},scaleToLevel:function(e){var t=this._maxLevel,i=Math.ceil(Math.log(e)/Math.log(2))+1;return i>=t&&(i=t),i},isInViewFrustum:function(e){var t=this._scene,i=this.worldToClient(e);return i.x>0&&i.x<t.width&&i.y>0&&i.y<t.height},setNavigationMode:function(e){this._navigationMode=e},createSnapshotAsync:function(t,n){var o=this,s=i.create("canvas","bf-canvas"),r=s.getContext("2d"),a=o._scene,l=o.getScale(),h=o.getCurrentLevel(),d=o._position,c=o.getShowImages(o._currentImages),u=c.length,g=o._opt.unit,p=l/Math.pow(2,h-1),m=function(t){new e.Web.Graphics.Utility.ImageContainer(t.src).then((function(e){t.isLoad=!0,r.drawImage(e,t.col*g*p-d.x,t.row*g*p-d.y,g*p,g*p),f()}),(function(e){t.isLoad=!0,f()}))},f=function(){if(0==--u){var e=s.toDataURL("image/png");n&&n(e)}};s.setAttribute("width",a.width),s.setAttribute("height",a.height),r.rect(0,0,a.width,a.height),t instanceof e.Web.Graphics.Color?r.fillStyle=t.getRGBA():r.fillStyle="#000",r.fillRect(0,0,a.width,a.height);for(var w=0;w<u;w++)m(c[w])},drawRect:function(e,t){this._rect&&t?(this._rect.style.width=`${t.x}px`,this._rect.style.height=`${t.y}px`):(this._rect=i.create("div","bf-image-rect"),this._rect.style.left=`${e.x}px`,this._rect.style.top=`${e.y}px`,this._imageScene.appendChild(this._rect))},getClientPosition:function(e){var t=this._domElement.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},render:function(){this._eventManager.fireEvent("Render")}},t.ImageRender=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").Viewer2DConfig=function(){return{domElement:null,resourceHost:g.resourceHost,APIHost:g.APIHost,securityApi:g.securityApi,useCustomResources:g.useCustomResources}},function(){let t=Object.freeze({Loaded:"Loaded",MouseClicked:"MouseClicked",ZoomFactorChanged:"ZoomFactorChanged",Rendered:"Rendered",ViewChanged:"ViewChanged",ViewMoving:"ViewMoving",ViewMoved:"ViewMoved",ViewZooming:"ViewZooming",ViewZoomed:"ViewZoomed",DrawingMeasure:"DrawingMeasure",Error:"Error"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").Viewer2DEvent=t}(),function(){let t=Object.freeze({Pan:"Pan",RectZoom:"RectZoom",Zoom:"Zoom"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").NavigationMode2D=t}(),function(){var t="Glodon.Bimface.Viewer.Viewer2D",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),s=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest")),r=e.Bimface.Viewer.Viewer2DEvent,a=function(t){n.Viewer.call(this);var i=t.domElement;this._opt=t,this._scaleLevel=1,this.screenWidth=i.offsetWidth,this.screenHeight=i.offsetHeight,this._viewLoaded=!1;var o=new e.Bimface.Viewer.ImageRenderConfig;o.domElement=i,this._imageRender=new e.Bimface.Viewer.ImageRender(o),this.getDomElement=function(){return this._imageRender.getDomElement()},this.hookImageRender()};o.Type.inheritPrototype(a,n.Viewer),a.prototype=Object.assign({},n.Viewer.prototype,{hookImageRender:function(){var t=this,i=this._imageRender,n=e.Bimface.Viewer.Viewer2DEvent,o=this.getEventManager();i.addEventListener("Zooming",(function(e){o.fireEvent(n.ViewZooming,e)})),i.addEventListener("Moving",(function(e){o.fireEvent(n.ViewMoving,e)})),i.addEventListener("Moved",(function(e){t.render()})),i.addEventListener("Render",(function(e){t.render()})),i.addEventListener("Clicked",(function(e){e.worldPosition.x=e.worldPosition.x/t._scaleLevel,e.worldPosition.y=e.worldPosition.y/t._scaleLevel,o.fireEvent(n.MouseClicked,e)}))},load:function(e){0==this._viewLoaded&&(this._viewLoaded=!0,this.addView(e))},showImage:function(e,t){var i=this,n=this._imageRender,o=new Image;t=t;o.src=e,o.onload=function(){var o=this.width>this.height?this.width:this.height;t=t||o/512,i._scaleLevel=512*t/o,n.addModel({maxScale:t,images:[{row:0,col:0,src:e}]})}},loadViewCore:function(t){var i=this,n=i._opt,o=t.databagId;i._data=t,s.ajax({async:!1,url:`${n.resourceHost}/${t.databagId}/manifest.json`,success:function(t){var s=JSON.parse(t);if(s.Views){for(var a=[],l=0,h=s.Views.length;l<h;l++){var d=s.Views[l],c=d.Representations.getObjectByAttribute("MIME","image/tiles");c.Path=`${n.resourceHost}/${o}/${c.Path}`,a.push({name:d.Name,id:d.ID,file:c})}i._views=a,i.showViewById(a[0].id),i.getEventManager().fireEvent(r.Loaded,i),e.Web.Lang.Utility.MouseMotion.setCursor(i)}}})},showViewById:function(e){if(i.send(t,"showViewById"),this._currentViewId!=e){var n=this._views.getObjectByAttribute("id",e),o=this._imageRender;n&&n!=this._currenItem&&(this._currenItem=n,this._currentViewId=e,o.load(n),this.getEventManager().fireEvent(r.ViewChanged,e))}},getCurrentViewId:function(){return this._currentViewId},home:function(){this._imageRender.fit()},setNavigationMode:function(e){i.send(t,"setNavigationMode"),this._imageRender.setNavigationMode(e)},rectZoom:function(){this._opt.enableZoomRect=!0,this._imageRender.setNavigationMode(e.Bimface.Viewer.NavigationMode2D.RectZoom)},zoomIn:function(){var e=this._imageRender.getScale();this._imageRender.setScale(1.6*e)},zoomOut:function(){var e=this._imageRender.getScale();this._imageRender.setScale(e/1.6)},getWorldPosition:function(){var e=this._imageRender.getWorldPosition();return this.imageToWorld(e)},getViews:function(){return this._views},resize:function(){this._imageRender.resize()},worldToClient:function(e){var t=this.worldToImage(e);return this._imageRender.worldToClient(t)},clientToWorld:function(e){var t=this._imageRender.clientToWorld(e);return this.imageToWorld(t)},isInViewFrustum:function(e){var t=this.worldToImage(e);return this._imageRender.isInViewFrustum(t)},getMaxLevel:function(){return this._imageRender.getMaxLevel()},getCurrentLevel:function(){return this._imageRender.getCurrentLevel()},getZoomScale:function(){return this._imageRender.getScale()},getCurrentState:function(){var e=this._imageRender,t=e._position;return{viewTop:t.x,viewLeft:t.y,level:e.getCurrentLevel(),zoomScale:e.getScale(),viewId:this._currentViewId}},setState:function(e){var t=this,i=t._imageRender;t._currentViewId!=e.viewId&&t.showViewById(e.viewId),i.setScale(e.zoomScale),i.setPosition({x:e.viewTop,y:e.viewLeft})},createSnapshotAsync:function(e,n){i.send(t,"createSnapshotAsync"),this._imageRender.createSnapshotAsync(e,n)},worldToImage:function(e){return{x:e.x*this._scaleLevel,y:e.y*this._scaleLevel}},imageToWorld:function(e){return{x:e.x/this._scaleLevel,y:e.y/this._scaleLevel}},render:function(){var t=e.Bimface.Viewer.Viewer2DEvent;this.getEventManager().fireEvent(t.Rendered)}}),n.Viewer2D=a}();var I=["-2001350","-2001180","-2001160","-2001340","-2001260","-2000180","-2000011","-2000035","-2000170","-2000171","-2000340","-2000100","-2000126","-2000032","-2000120","-2001120","-2000014","-2000996","-2001354","-2001300","-2001330","-2001336","-2001320","-2001327","-2009030","-2001220","-2000023","-2000038","-2000946","-2001390","-2003400"];!function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Common");t.CoordSysUtil=class{constructor(){}LatLonToXY(e,t,i=120){const n=e/180*Math.PI,o=(t-i)/180*Math.PI,s=0*Math.PI,r=6399593.6258,a=.00673949674227,l=.00673949674227,h=r/Math.sqrt(1+l),d=.9949771060858016,c=d-1,u=21152428336119405e-21,g=-1.1086345825495088e-7,p=315/1024*a**4,m=r*(d*s+(c*Math.cos(s)+u*Math.cos(s)**3+g*Math.cos(s)**5+p*Math.cos(s)**7)*Math.sin(s));let f=r*(d*n+(c*Math.cos(n)+u*Math.cos(n)**3+g*Math.cos(n)**5+p*Math.cos(n)**7)*Math.sin(n))+o**2*h/2*Math.sin(n)*Math.cos(n)+o**4*h/24*Math.sin(n)*Math.cos(n)**3*(5-Math.tan(n)**2+9*l+4*l**2)+o**6*h/720*Math.sin(n)*Math.cos(n)**5*(61-58*Math.tan(n)**2+Math.tan(n)**4);const w=o*h*Math.cos(n)+o**3*h/6*Math.cos(n)**3*(1-Math.tan(n)**2+l)+o**5*h/120*Math.cos(n)**5*(5-18*Math.tan(n)**2+Math.tan(n)**4);return f-=m+o**2*h/2*Math.sin(s)*Math.cos(s)+o**4*h/24*Math.sin(s)*Math.cos(s)**3*(5-Math.tan(s)**2+9*l+4*l**2)+o**6*h/720*Math.sin(s)*Math.cos(s)**5*(61-58*Math.tan(s)**2+Math.tan(s)**4),[w,f]}XYToLatLon(e,t,i=120){const n=this.LatLonToXY(1,i+1,i);let o=(e-=5e5)/n[0]+i,s=t/n[1]+0;for(;;){const r=this.LatLonToXY(s,o,i),a=r[0]-e,l=r[1]-t;if(a<100&&l<100)break;o-=a/n[0],s-=l/n[1]}return[s,o]}}}(),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t});let S=Object.freeze({Release:"Release",Debug:"Debug"}),B=Object.freeze({Normal:"Normal",DrawingView:"drawingView"}),_=Object.freeze({BIMFACE:"BIMFACE",Local:"Local"}),L=Object.freeze({zh_CN:"zh_CN",en_GB:"en_GB",sv_SE:"sv_SE",zh_TW:"zh_TW"}),D=Object.freeze({Normal:"Normal",Bake:"Bake"});window.BimfaceSDKLoaderConfig=function(){if(window.hostConfig){for(let e in window.hostConfig)g[e]=window.hostConfig[e];g.securityApi=window.hostConfig.securityApi}return{staticHost:`${g.staticHost}/api`,APIHost:g.APIHost,language:"zh_CN",viewToken:null,configuration:S.Release,dataEnvType:g.dataEnvType||"BIMFACE",viewType:B.Normal,visualStyle:D.Bake,version:"",securityApi:g.securityApi}},window.BimfaceEnvOption=_,window.BimfaceLanguageOption=L,window.BimfaceConfigrationOption=S,window.BimfaceViewTypeOption=B;const A="Glodon.Bimface.Model.Model",V="Glodon.Bimface.Model.BimModel",R=e.Bimface.Data.StatisticsDataManager.getInstance(),O=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Model"),k=e.Web.Lang.Utility.DataUtil;let H=new THREE.Vector3;O.Model=class{constructor(t,i,n,o={},s){i.viewToken=i.viewToken||i.databagId,this.viewToken=i.viewToken,this.globalUnitUtil=t.globalUnitUtil,this._viewer=t,this._layer=s,this.viewerType=this._viewer.viewerType,P(this),this.isViewerType=e=>this._viewer.viewerType===e,this.executeByViewer=e=>{for(let t in e)this.isViewerType(t)&&"[object Function]"===Object.prototype.toString.call(e[t])&&e[t]()},this.console=this._viewer.console,this._cloudViewer=t.getViewer();const r=t._opt;this._opt=r;let a,l,h=r.databagResource||e.Web.Lang.Utility.ClientHelper.formatURL(`/${i.databagId}/resource/v3/model`),d=r.resourceHost;if(i.shell){let t=r.shellDatabagResource||e.Web.Lang.Utility.ClientHelper.formatURL(`/${i.shell.databagId}/${i.databagId}/resource/v3/model`);i.shell.path&&(t=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.shell.path}/${i.shell.databagId}/${i.databagId}/resource/v3/model`)),a=y.Utils.clone(i.shell,!0),a.databagId=t}if(i.path&&(h=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.path}/${i.databagId}/resource/v3/model`),d=""),!1!==this._opt.enableWireframe&&!1!==o.enableBorderLine?o.enableBorderLine=!0:o.enableBorderLine=!1,!0===this._opt.disableUserData&&(o.disableUserData=!0),this.wireFrameVisibilityOption=o.componentsFrame,o.wireFrameVisibilityOption=o.componentsFrame,"Normal"!=BimfaceLoaderConfig.visualStyle&&i.bake&&"success"==i.bake.status&&(l="/"+i.bake.databagId+"/resource/baking"),this._data=i,this._dataModelId=i.modelId,this._data.databagResource=h,this.modelId=y.Utils.isDefined(o.modelId)?o.modelId:i.modelId,this._componentTreeData={viewer:this._viewer,modelId:this.modelId},i.isVirtualModel)return;this.isViewerType("Viewer3D")&&(this.isDefault=!1,this._modelIndex=t._lastModelIndex,t._lastModelIndex+=1,0===t.getModelCount()&&this.setDefault());const c=()=>this._manifest.Metadata&&this._manifest.Metadata.Content&&this._manifest.Metadata.Content.Type.indexOf("bimtile")>=0?"bimtiles":"bmd",u=t=>void 0!==this._opt.unit?this._opt.unit===e.Bimface.Common.Units.LengthUnits.Meter?"m":"mm":this._manifest.Metadata&&this._manifest.Metadata.Unit?this._manifest.Metadata.Unit:"bmd"===t?"mm":"m";t._models[this.modelId]=this;const g=s=>{this._manifest=s;let r=!0;if(this.executeByViewer({Viewer3D:()=>{this.isDefault?(t._defaultModelType=c(),t._defaultUnit=u(t._defaultModelType),t._manifest=Object.assign({},s),this.isBimtilesModelByManifest()?(this.getCloudViewer().setLightPreset(4),this.isShadowDafault()&&(y.GlobalData.EnableShadowMap=!0)):(this.getCloudViewer().setLightPreset(3),this.isShadowDafault()&&(y.GlobalData.EnableShadowMap=!0,this.getCloudViewer().setLightPreset(6)))):(t._updateManifest(),c()!==t._defaultModelType&&(this.console.error("Bimtiles and bmd files cannot be loaded in the same viewer."),delete t._models[this.modelId],r=!1))},ViewerGIS:()=>{c()!==t._defaultModelType&&(this.console.error("Adding bmd files is not supported."),this._layer.getParent().remove(this._layer),delete t._models[this.modelId],this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.ModelAddFailed,this._layer?this._layer.id:this.modelId),r=!1)}}),!r)return;0!==this._modelIndex&&(o.zoomAll=!1);let g=d;if("Local"!=this._viewer._data.dataEnvType&&(h="Strict"==this._viewer._data.loadMode?"resource/v3/model":h,d=e.Web.Lang.Utility.HttpRequest.getUrl({url:d,path:"",viewToken:i.viewToken,fileId:i.modelId,modelType:i.modelType,loadMode:this._viewer._data.loadMode,APIHost:this._viewer._opt.APIHost}),l&&(l="Strict"==this._viewer._data.loadMode?"resource/baking":l,g=e.Web.Lang.Utility.HttpRequest.getUrl({url:g,path:"",viewToken:i.viewToken,fileId:i.modelId,modelType:i.modelType,loadMode:this._viewer._data.loadMode,APIHost:this._viewer._opt.APIHost,workerType:"md-baking"}))),this.getCloudViewer().load({type:n||this.isViewerType("ViewerGIS")?"bimTiles":void 0,modelId:o.modelId,modelFileId:i.modelId,metaData:i.metaData,coordinateSystem:i.coordinateSystem,count:i.count,databagId:h,serverUrl:d,lightmapServerUrl:g,lightmapDatabagId:l,loadConfig:o,shell:a,fileType:s.Metadata.FileType}),"rfa"===s.Metadata.FileType){const i=this.modelId;t.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,(function(){t.getModel(i)&&t.getModel(i).getFamilyTypes((function(e){e&&e[0]&&t.getModel(i).showFamilyTypeById(e[0].id)}))}))}};if(i.metaData&&i.metaData.asset){let e={Metadata:{}};e.Metadata.Content={},e.Metadata.Content.Type=i.metaData.asset,g(e)}else this.getManifest((e=>{this.setManifestData(e,g)}),(e=>{this.setManifestData(e,g)}));this._modelAddedCallback=t=>{t.modelId&&this.modelId&&t.modelId.toString()===this.modelId.toString()&&(this.onModelLoaded(),this.executeByViewer({Viewer3D:()=>{let t=()=>{this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,this.modelId),0===this._modelIndex?this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewAdded,this.getViewer()):this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,this.getViewer()._manifest)};!0===this._opt.disableUserData?requestAnimationFrame((()=>{let e=this.getViewer().getViewer().getModelManager().getModel(this.modelId);let i=0;e._config.count&&e._config.count.element&&(i=1e3*parseInt(e._config.count.element/1e5)),e&&e.loadBusinessResources&&setTimeout((()=>{e.loadBusinessResources(t)}),i),e&&!e.loadBusinessResources&&t()})):t()},ViewerGIS:()=>{this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,this._layer?this._layer.id:this.modelId),this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.ViewChanged,this._layer?this._layer.id:this.modelId)}}))},this.getCloudViewer().registerEventListener(y.EVENTS.ON_LOAD_COMPLETE,this._modelAddedCallback),this._emptyModelAddedCallback=t=>{if(t.modelId&&this.modelId&&t.modelId.toString()===this.modelId.toString()){if(this.isEmptyModel=!0,0===this._modelIndex){let e,t;"bmd"===this._manifest.Metadata.Content.Type?(e=new THREE.Box3(new THREE.Vector3(-500,-500,0),new THREE.Vector3(1e3,1e3,1e3)),t={name:"persp",position:{x:-4e4,y:-4e4,z:4e4},target:{x:0,y:0,z:0},up:{x:0,y:0,z:1},near:0,far:1e5,zoom:1,version:1,fov:45,aspect:1,coordinateSystem:"world"}):(e=new THREE.Box3(new THREE.Vector3(-.5,-.5,0),new THREE.Vector3(1,1,1)),t={name:"persp",position:{x:-40,y:-40,z:40},target:{x:0,y:0,z:0},up:{x:0,y:0,z:1},near:0,far:100,zoom:1,version:1,fov:45,aspect:1,coordinateSystem:"world"}),this._viewer.getViewer().getScene().setBoundingBoxWorld(e),this._viewer.setCameraStatus(t),this._viewer.defaultHomeview=t,this.getViewer().showViewHouse(),this.getViewer().recordCustomHomeview(t)}0===this._modelIndex?this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewAdded,this.getViewer()):this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,this.getViewer()._manifest)}},this.getCloudViewer().registerEventListener(y.EVENTS.ON_LOAD_EMPTY_SCENE,this._emptyModelAddedCallback)}onModelLoaded(){this._loaded=!0,this.setBorderLineWithFilter(this._opt),this.wireFrameVisibilityOption&&this.setWireFrameVisibilityCondition(this.wireFrameVisibilityOption),this._opt.enableExplosion&&this.loadFloorsForExplosion&&this.loadFloorsForExplosion();const t=this.getViewer()._data;t.dataEnvType==_.Local?t.sdkPath:g.staticHost;if("Viewer3D"===this.viewerType){const i=t.config;if(this.isBimtilesModel()){i&&"true"==i.loadOnDemand&&this.hideAllComponents();const t=e.Web.Lang.Utility.ClientHelper.getIsDesktop();this.getViewer()._opt.enableSSAO&&t&&0===this._modelIndex&&this.getViewer().enableSSAOEffect(!0)}}if("ViewerGIS"===this.viewerType){if(!this._layer._config.transformation||"[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]"===JSON.stringify(this._layer._config.transformation)){let e=this._layer._config.config||this.getCloudViewer().getModelManager().getModel(this.modelId)._config,t="EPSG:4490",i=new m,n=!1,o=null;if(k.hasChildProperty(e,"coordinateSystem","projCS","centralMeridian")){const t=e.coordinateSystem.projCS,{name:n}=t;o=`Custom_${n||"自定义"}`,i.defineCustomCoordSys(o,t)}if(o||k.hasChildProperty(e,"coordinateSystem","projCS","epsg")||k.hasChildProperty(e,"coordinateSystem","projCS","EPSG")){let s=e.coordinateSystem.projCS,r=o||`EPSG:${s.epsg||s.EPSG}`,{rotation:a}=s;if(isNaN(a)||0===a||this.setModelRotationZ({x:0,y:0,z:0},a*Math.PI/180),o||Object.values(f).includes(r)){let e,a,l;if(!s.offset||0===s.offset[0]&&0===s.offset[1]){let t=this.getCloudViewer().getModelManager().getModel(this.modelId).getBoundingBoxWorld().getCenter(H);t&&(e=t.x,a=t.y,l=0)}else e=s.offset[0],a=s.offset[1],l=s.offset[2]||0;if(void 0!==e&&void 0!==a){let s=i.translateXY({x:e,y:a},r,t);if(s&&Math.abs(s.lat)<=90&&Math.abs(s.lon)<=180){let e=this.getViewer().latLonToWorld({latLon:s});e.z=l,this.setModelTranslation(e),n=!0,this.console.info(`layer[${this._layer.id}] is transformed by projected coordinate system [${o?o.split("Custom_")[1]:r}]`)}}}}if(!n&&(k.hasChildProperty(e,"coordinateSystem","geogCS","epsg")||k.hasChildProperty(e,"coordinateSystem","geogCS","EPSG"))){let o=e.coordinateSystem.geogCS,s=`EPSG:${o.epsg||o.EPSG}`;if(Object.values(f).includes(s)&&o.latLon){let e=i.translateLatLon({lat:o.latLon[0],lon:o.latLon[1]},s,t),r=this.getViewer().latLonToWorld({latLon:e}),{altitude:a,origin:l}=o;isNaN(a)||0===a?r.z=0:r.z=a,k.assertType(l,"arr")&&(r.x-=l[0],r.y-=l[1],r.z-=l[2]),this.setModelTranslation(r),n=!0,this.console.info(`layer[${this._layer.id}] is transformed by geographic coordinate system [${s}]`)}}if(!k.hasChildProperty(e,"coordinateSystem","projCS")&&!k.hasChildProperty(e,"coordinateSystem","geogCS")){let e=this.getViewer().getBasePoint(),t=this.getViewer().latLonToWorld({latLon:e});this.setModelTranslation(t),n=!0}}this.getViewer().getViewer().setColorSaturation(.94)}}isBimtilesModel(){return this.getCloudViewer().getModelManager().getModel(this.modelId)instanceof y.BimTilesModel}getModelContent(){const e=this.getCloudViewer().getModelManager().getModel(this.modelId)._config;return e.metadata&&e.metadata.content}setShellVisibility(e){this.getCloudViewer().getModelManager().setModelShellVisibility(this.modelId,e)}setDefault(){const e=this.getViewer();e.getModels().some((e=>{if(e.isDefault)return e.isDefault=!1,!0})),this.isDefault=!0,e._data=this.getMetaData(),e._defaultModel=this}getMetaData(){return this._data}_getMetaDataManager(){if(this._metaDataManager)return this._metaDataManager;{const t=this.getMetaData();let i=new e.Bimface.Data.MetaDataManagerConfig;return t.integrateDrawings&&"success"==t.integrateDrawings.status&&(i.integrateDrawings=t.integrateDrawings),i.APIHost=this._opt.APIHost,i.resourceHost=this._opt.resourceHost,i.viewToken=t.viewToken,i.databagId=t.databagId,i.modelId=t.modelId,i.modelType=t.modelType,i.dataEnvType=t.dataEnvType||i.dataEnvType,i.loadMode="Local"!=t.dataEnvType?this._viewer._data.loadMode:"",i.enableComponentCut=!!t.enableComponentCut,t.path?(i.relativeUrlWithoutDatabagId=e.Web.Lang.Utility.ClientHelper.formatURL(t.path),i.relativeUrl=e.Web.Lang.Utility.ClientHelper.formatURL(t.path+"/"+i.databagId)):(i.relativeUrlWithoutDatabagId=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.resourceHost}`),i.relativeUrl=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.resourceHost}/${i.databagId}`)),this._metaDataManager=new e.Bimface.Data.MetaDataManager(i),this._metaDataManager}}getManifest(e,t){R.send(A,"getManifest"),this._getMetaDataManager().getManifest(e,t)}setManifestData(e,t){const i=this.getMetaData();let n=!1,o=!1,s=!1;i.config&&(o=!!i.config["integrate-with-links"],n=!!i.config.exportSetsTree),s="integrateModel"==i.modelType?i.isSupportDrawing:!(!i.config||"true"!==i.config.exportDrawing),"object"!=typeof e&&(e={}),e.Features||(e.Features={HasComponentProperty:i.isSupportComponentProperty,HasMaterialProperty:i.isSupportMaterialProperty,HasMiniMap:i.isSupportMiniMap,HasComponentStructure:i.isSupportModelTree,HasFileList:"integrateModel"==i.modelType,HasRoom:i.isSupportRoomArea,HasArea:i.isSupportRoomArea,HasDrawing:i.isSupportDrawing&&s,HasMEPSystem:i.workerType&&-1!=i.workerType.indexOf("rvt-"),HasGroup:n,HasAssemble:n,HasLinkRelation:o,HasFamilyTypeList:i.isSupportFamilyTypeList,HasLayout:!0,HasSplitDrawing:!0}),e.Features&&null==e.Features.HasFamilyTypeList&&(e.Features.HasFamilyTypeList=i.isSupportFamilyTypeList),e.Metadata||(e.Metadata={FileType:null}),t&&t(e)}destroy(){const t=this.modelId;this.getCloudViewer().unload(t);const i=this.getViewer();this._modelAddedCallback&&this.getCloudViewer().unregisterEventListener(y.EVENTS.ON_LOAD_COMPLETE,this._modelAddedCallback),this._emptyModelAddedCallback&&this.getCloudViewer().unregisterEventListener(y.EVENTS.ON_LOAD_EMPTY_SCENE,this._emptyModelAddedCallback),this.executeByViewer({Viewer3D:()=>{if(delete i._models[t],i.getModelCount(),0===i.getModelCount())delete i._manifest,i.fireEvent(e.Bimface.Viewer.Viewer3DEvent.RemoveView,0),i._lastModelIndex=0;else{if(this.isDefault){let e=i._lastModelIndex,t=i.getModels()[0];i.getModels().forEach((i=>{i._modelIndex<e&&(e=i._modelIndex,t=i)})),t.setDefault(),i._manifest=Object.assign({},t._manifest)}i._updateManifest(),i.fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,i._manifest)}},ViewerGIS:()=>{i.fireEvent(e.Bimface.Viewer.ViewerGISEvent.ModelRemoved,this.modelId),i.fireEvent(e.Bimface.Viewer.ViewerGISEvent.ViewChanged,this.modelId)}})}isShadowDafault(){const e=this._manifest,t=this.getMetaData();let i=!1;if(e.Metadata.FileType){const t=e.Metadata.FileType;i="rfa"==t||"stp"==t||"step"==t||"stl"==t}else i=!(!t.workerType||-1==t.workerType.indexOf("rfa-")&&-1==t.workerType.indexOf("stp-")&&-1==t.workerType.indexOf("omni-"));return i}isBimtilesModelByManifest(){const e=this._manifest;this.getMetaData();return!(!e.Metadata.Content||"bimtiles"!=e.Metadata.Content.Type)}_isRfa(){const e=this._manifest,t=this.getMetaData();let i=!1;if(e.Metadata.FileType){i="rfa"==e.Metadata.FileType}else i=!(!t.workerType||-1==t.workerType.indexOf("rfa-"));return i}setVisible(e){this.getCloudViewer().showScene(this.modelId,e)}getViewer(){return this._viewer}getCloudViewer(){return this._cloudViewer}setBorderLineWithFilter(e){if(e.wireframeColor&&this.getCloudViewer().setWireframeColor(e.wireframeColor),e.borderLineVisibility)this.setBorderLine(e.borderLineVisibility);else{if(!this._data)return;const e=this._manifest;let t;e&&(e.FileType?t=e.FileType:e.Metadata&&e.Metadata.FileType&&(t=e.Metadata.FileType)),"rvt"===t&&this.setRvtBorderLine()}}setRvtBorderLine(){this.getCloudViewer().getFilter().setConditions(y.EnumConditionType.BORDERLINE,[{categoryId:I}],this.modelId)}setBorderLine(e){this.getCloudViewer().getFilter().setConditions(y.EnumConditionType.BORDERLINE,e,this.modelId)}setWireFrameVisibilityCondition(e){this.getCloudViewer().getFilter().setWireFrameVisibilityCondition(e,this.modelId)}isUserIdExist(e){return this.getCloudViewer().modelManager.isUserIdExist(e,this.modelId)}getMatchIds(e){return this.getCloudViewer().getFilter().getMatchIds(e,this.modelId)}_executeByCondition(e,t){e&&((e=this._parseCondition(e)).all?k.assertType(t.all,"func")&&t.all():(e.objectData&&e.objectData.length>0&&k.assertType(t.objectData,"func")&&t.objectData(e.objectData),e.ids&&e.ids.length>0&&k.assertType(t.ids,"func")&&t.ids(e.ids),e.noObjectData&&e.noObjectData.length>0&&k.assertType(t.noObjectData,"func")&&t.noObjectData(e.noObjectData),e.noIds&&e.noIds.length>0&&k.assertType(t.noIds,"func")&&t.noIds(e.noIds)))}_parseCondition(e){let t;if(k.assertType(e,"str"))t=this._codeToCondition(e);else if(k.assertType(e,"arr")){let i=[],n=[];e.forEach((e=>{k.assertType(e,"obj")?n.push(e):i.push(e)})),t={ids:i,objectData:n}}else k.assertType(e,"obj")&&(t=e);return t}getObjectData(){const e=this.getCloudViewer().getModelManager().getModel(this.modelId);if(e instanceof y.BimTilesModel){if(e.tilesLoader&&e.tilesLoader.tileReader&&e.tilesLoader.tileReader.globalUserdataBuffer)return e.tilesLoader.tileReader.globalUserdataBuffer.getBlobHeader().getKeysList()}else{let t=Object.values(e.getLoader().getDescriptor().mapNodeInfoByUserId);if(t&&t.length>0)for(let e=0;e<t.length;e++){let i=t[e];if(i&&i.length>0)for(let e=0;e<i.length;e++){let t=i[e];if(t&&t.userData)return Object.keys(t.userData)}}}}getComponentContours(e){let t=null;const i=this.getCloudViewer().getFilter();if(e.ids)t=e.ids;else if(e.userData)t=i.getMatchIds(e.userData,this.modelId);else{if(!e.all)return void this.console.warn("Parameter condition is invalid.");t=i.getMatchIds([],this.modelId)}this.getCloudViewer().getModelManager().getModel(this.modelId).calculateClippingContours(t);let n=[];const o=y.FillClipPlaneManager.getInstance(this.getCloudViewer().getScene()).capsIntersectContour;for(const e in o){const t=o[e];for(const e in t){let i={};i.modelId=this.modelId,i.objectId=e,i.contours=[];const o=y.ClipPlaneContourManager.concatContours(t[e].clippingContours),s=y.ClipPlaneContourManager.searchInnerRing(o);let r=[];Object.values(s).map((e=>{e.map((e=>{r.push(e)}))})),o.map(((n,a)=>{let l={},h=(e,t)=>{e.outerRing=[],t.map((t=>{const i={x:t.x,y:t.y,z:t.z};e.outerRing.push(i)}))};if(s[a]){h(l,n);let e=[];s[a].map((t=>{e.push(o[t])})),e.length>0&&(l.innerRing=[]),e.map((e=>{let t=[];e.map((e=>{const i={x:e.x,y:e.y,z:e.z};t.push(i)})),l.innerRing.push(t)}))}else{if(r.indexOf(a)>-1)return;h(l,n)}i.colors=t[e].colors,i.contours.push(l)})),n.push(i)}}return n}getObjectDataById(e){return R.send(A,"getObjectDataById"),this.getCloudViewer().getUserdataByUserId(e,this.modelId)}restoreDefault(){R.send(A,"restoreDefault"),this.activateAllComponents(),this.getViewer().clearAllRooms(),this.clearIsolation(),this.clearSelectedComponents(),this.showAllComponents(),this.opaqueAllComponents()}restoreAllDefault(){R.send(A,"restoreAllDefault"),this._clearOverrideColorComponentsAndWireFrame(),this.restoreDefault()}getComponentStatus(e){if(this.isUserIdExist(e)){const t=this.getCloudViewer().getFilter(),i=t.isHidden(e,this.modelId),n=t.isFrozen(e,this.modelId);return i?"hidden":n?"translucent":"show"}}isIsolate(){return this.getCloudViewer().getFilter().isIsolate(this.modelId)}isFiltering(){return this.getCloudViewer().getFilter().isFiltering(this.modelId)}isolateComponentsById(e,t,i=!0){R.send(A,"isolateComponentsById"),this.getCloudViewer().getFilter().addToIsolateList(e,t,this.modelId),this._componentTreeData.selectionList=e}isolateComponentsByObjectData(e,t){R.send(A,"isolateComponentsByObjectData");const i=this.getCloudViewer().getFilter();let n={MakeOthersTranslucent:3,HideOthers:1};i.clearAllIsolateConditions(this.modelId),e&&i.setIsolateConditions(e,n[t],this.modelId)}clearIsolation(e=!0){R.send(A,"clearIsolation"),this.getCloudViewer().getFilter().clearIsolation(this.modelId),e&&this._viewer.fireEvent("ClearModelIsolation",this._componentTreeData),e&&this._viewer.fireEvent("ShowModelComponents",this._componentTreeData)}isolateByBox(e,t){const i=this.getCloudViewer();this.clearIsolation(),this.getViewer().render(),e=this.globalUnitUtil.translateBBox(e);const n=i.getObjectsInBox(e);this.isolateComponentsById(n,t)}setIsolatedComponentColor(e){R.send(A,"setIsolatedComponentColor");const t=this.getCloudViewer().getFilter();let i={color:parseInt(e.getHEX(),16),opacity:e.getAlpha()};t.setFrozonMaterial(i,this.modelId)}setTransparentedComponentColor(e){R.send(A,"setTransparentedComponentColor");const t=this.getCloudViewer().getFilter();let i={color:parseInt(e.getHEX(),16),opacity:e.getAlpha()};t.setFrozonMaterial(i,this.modelId)}restoreIsolatedComponentColor(){R.send(A,"restoreIsolatedComponentColor");this.getCloudViewer().getFilter().setFrozonMaterial({color:void 0,opacity:void 0},this.modelId)}getIsolatedComponentColor(){const t=this.getCloudViewer().getFilter().getFrozonMaterial(this.modelId),i=t.color,n=t.opacity;return new e.Web.Graphics.Color(255*i.r,255*i.g,255*i.b,n)}showComponentsById(e,t=!0){R.send(A,"showComponentsById"),this.getCloudViewer().getFilter().showByIds(e,this.modelId),t&&(this._componentTreeData.selectionList=e)}getConditionIds(e){let t=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);if(!t[0]){const i=/^L\d+$/,n=e.find((e=>Object.keys(e).find((e=>i.test(e)))));n&&(t="string"==typeof Object.values(n)[0]?[Object.values(n)[0]]:[...Object.values(n)[0]])}return t}showComponentsByObjectData(e,t=!0){if(R.send(A,"showComponentsByObjectData"),this.getCloudViewer().getFilter().showByConditions(e,this.modelId),t){const t=this.getConditionIds(e);this._componentTreeData.selectionList=t}}showAllComponents(t,i,n=!0){if("oap-osgb2bimtiles"===this._data.workerType)t&&t(),this.setVisible(!0),i&&i();else{R.send(A,"showAllComponents");const e=this.getCloudViewer();y.GlobalData.LoadMpkOnDemand?e.loadMpkOnDemand(null,t,(t=>{e.getFilter().showAll(this.modelId),e.render(),i&&i()})):e.getFilter().showAll(this.modelId)}this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ModelVisibleChanged,!0),n&&this._viewer.fireEvent("ShowModelComponents",this._componentTreeData)}showExclusiveComponentsByObjectData(e,t,i){R.send(A,"showExclusiveComponentsByObjectData");const n=this.getCloudViewer(),o=n.getFilter(),s=e=>{if("all"==e)o.showAll(this.modelId);else if(e instanceof Array&&0==e.length)o.hideAll(this.modelId);else{if(!(e instanceof Array))return void this.console.warn("Parameter conditions is invalid.");o.showScene(this.modelId),o.hideOthersByConditions(e,this.modelId),o.showByConditions(e,this.modelId)}};y.GlobalData.LoadMpkOnDemand?n.loadMpkOnDemand(e,t,(e=>{s(e),n.render(),i&&i()})):s(e);const r=o.getMatchIds(e,this.modelId);this._componentTreeData.selectionList=r}hideComponentsById(e,t=!0){R.send(A,"hideComponentsById"),this.getCloudViewer().getFilter().hideByIds(e,this.modelId),t&&(this._componentTreeData.selectionList=e)}hideComponentsByObjectData(e,t=!0){if(R.send(A,"hideComponentsByObjectData"),this.getCloudViewer().getFilter().hideByConditions(e,this.modelId),t){const t=this.getConditionIds(e);this._componentTreeData.selectionList=t}}hideAllComponents(t=!0){"oap-osgb2bimtiles"===this._data.workerType?this.setVisible(!1):(R.send(A,"hideAllComponents"),this.getCloudViewer().getFilter().hideAll(this.modelId)),this.getViewer().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ModelVisibleChanged,!1),t&&this._viewer.fireEvent("HideModelComponents",this._componentTreeData)}transparentComponentsById(e,t=!0){R.send(A,"transparentComponentsById"),this.getCloudViewer().getFilter().makeTranslucentByIds(e,this.modelId)}transparentComponentsByObjectData(e,t=!0){if(R.send(A,"transparentComponentsByObjectData"),this.getCloudViewer().getFilter().makeTranslucentByConditions(e,this.modelId),t){const t=this.getConditionIds(e);this._componentTreeData.selectionList=t,this._viewer.fireEvent("TranslucentComponents",this._componentTreeData)}}transparentAllComponents(){R.send(A,"transparentAllComponents"),this.getCloudViewer().getFilter().makeTranslucentOthersByIds([],this.modelId)}opaqueComponentsById(e,t=!0){R.send(A,"opaqueComponentsById"),this.getCloudViewer().getFilter().opaqueByIds(e,this.modelId),t&&(this._componentTreeData.selectionList=e)}opaqueComponentsByObjectData(e,t=!0){if(R.send(A,"opaqueComponentsByObjectData"),this.getCloudViewer().getFilter().opaqueByConditions(e,this.modelId),t){const t=this.getConditionIds(e);this._componentTreeData.selectionList=t}}opaqueAllComponents(e=!0){R.send(A,"opaqueAllComponents");this.getCloudViewer().getFilter().opaqueAll(this.modelId),e&&this._viewer.fireEvent("OpaqueModelComponents",this._componentTreeData)}setComponentsOpacity(e,t,i=!0){R.send(A,"setComponentsOpacity"),this._componentTreeData.selectionList=e,"Translucent"==t?this.transparentComponentsById(e,i):"Opaque"==t&&this.opaqueComponentsById(e,i)}addSelectedComponentsById(e){R.send(A,"addSelectedComponentsById"),this.getCloudViewer().addToSelection(e,this.modelId)}setSelectedComponentsById(e){R.send(A,"setSelectedComponentsById"),void 0!==e?this.getCloudViewer().setSelection(e,this.modelId):this.clearSelectedComponents()}addSelectedComponentsByObjectData(e){R.send(A,"addSelectedComponentsByObjectData");const t=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);this.getCloudViewer().addToSelection(t,this.modelId)}setSelectedComponentsByObjectData(e){R.send(A,"setSelectedComponentsByObjectData");const t=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);this.getCloudViewer().setSelection(t,this.modelId)}getSelectedComponents(){return R.send(A,"getSelectedComponents"),this.getCloudViewer().getSelection(this.modelId)}removeSelectedId(e){R.send(A,"removeSelectedId"),this.getCloudViewer().removeFromSelection(e,this.modelId)}clearSelectedComponents(e=!0){this.getCloudViewer().clearSelection(this.modelId),e&&this._viewer.fireEvent("ClearModelSelection",this._componentTreeData)}zoomToSelectedComponents(e,t,i){R.send(A,"zoomToSelectedComponents"),1===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[0])?(e=1,t=arguments[0]):2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1])?(e=arguments[0],i=arguments[1]):2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1])?(e=arguments[0],t=arguments[1]):e=e||1,void 0===i&&(i=1e3),this.getCloudViewer().zoomToSelection(e,void 0,"[object Function]"===Object.prototype.toString.call(t)?t:void 0,this.modelId,i)}deactivateComponentsById(e){this.getCloudViewer().getFilter().deactivateByIds(e,this.modelId)}activateComponentsById(e){const t=this.getCloudViewer().getFilter().getInactivatedIdMap(this.modelId);let i=Object.keys(t);i=i.filter((t=>!e.includes(t.toString()))),this.activateAllComponents(),this.deactivateComponentsById(i)}deactivateComponentsByObjectData(e){const t=this.getCloudViewer().getFilter();let i=t.getMatchIds(e,this.modelId);t.deactivateByIds(i,this.modelId)}activateComponentsByObjectData(e){let t=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);this.activateComponentsById(t)}activateAllComponents(){this.getCloudViewer().getFilter().clearInactivatedIdMap(this.modelId)}addBlinkComponentsById(e,t){this.getCloudViewer().addBlinkComponentsById(e,this.modelId,t)}setBlinkComponentsById(e,t){this.getCloudViewer().setBlinkComponentsById(e,this.modelId,t)}addBlinkComponentsByObjectData(e,t){let i=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);this.getCloudViewer().addBlinkComponentsById(i,this.modelId,t)}getBlinkComponents(){return this.getCloudViewer().getBlinkComponents(this.modelId)}clearBlinkComponentsById(e){this.getCloudViewer().clearBlinkComponentsById(e,this.modelId)}clearBlinkComponentsByObjectData(e){let t=this.getCloudViewer().getFilter().getMatchIds(e,this.modelId);this.getCloudViewer().clearBlinkComponentsById(t,this.modelId)}clearAllBlinkComponents(){this.getCloudViewer().clearAllBlinkComponents(this.modelId)}setBlinkColor(e){const t={color:parseInt(e.getHEX(),16),opacity:e.getAlpha()};this.getCloudViewer().setBlinkColor(t,this.modelId)}setBlinkIntervalTime(e){this.getCloudViewer().setBlinkIntervalTime(e,this.modelId)}overrideComponentsColorById(e,t){R.send(A,"overrideComponentsColorById");const i=this.getCloudViewer().getFilter(),n={color:parseInt(t.getHEX(),16),opacity:t.getAlpha()};i.addToOverrideListByColor(e,n,this.modelId)}overrideComponentsColorByObjectData(e,t){R.send(A,"overrideComponentsColorByObjectData");const i=this.getCloudViewer().getFilter(),n={color:parseInt(t.getHEX(),16),opacity:t.getAlpha()};i.addToOverrideListByConditions(e,n,this.modelId)}restoreComponentsColorById(e){R.send(A,"restoreComponentsColorById"),this.getCloudViewer().getFilter().addToOverrideListByColor(e,null,this.modelId)}restoreComponentsColorByObjectData(e){R.send(A,"restoreComponentsColorByObjectData"),this.getCloudViewer().getFilter().addToOverrideListByConditions(e,null,this.modelId)}getMaterialsByComponentId(e){if(R.send(V,"getMaterialsByComponentId"),"string"==typeof e)return this.getCloudViewer().getMaterialsByComponentId(this.modelId,e);this.console.warn("Parameter componentId must be type of string.")}overrideComponentsMaterialById(e,t){if(!(e instanceof Array&&t instanceof THREE.Material))return void this.console.warn("Parameter componentIds must be type of Array and material must be type of THREE.Material.");this.getCloudViewer().getFilter().addToOverrideListByMaterialAndId(e,t,this.modelId)}restoreComponentsMaterialById(e){e instanceof Array?this.getCloudViewer().getFilter().addToOverrideListByMaterialAndId(e,null,this.modelId):this.console.warn("Parameter componentIds must be type of Array.")}overrideComponentsOpacityById(e,t){if(R.send(A,"overrideComponentsOpacityById"),"[object Array]"!==Object.prototype.toString.call(e))return;if("[object Number]"!==Object.prototype.toString.call(t))return;t=t>1?1:t<0?0:t,t=Math.floor(10*t)/10;const i={type:"ids",param:e};this.getCloudViewer().getFilter().addToOverrideListByOpacity(i,t,this.modelId)}overrideComponentsOpacityByObjectData(e,t){if(R.send(A,"overrideComponentsOpacityByObjectData"),"[object Array]"!==Object.prototype.toString.call(e))return;if("[object Number]"!==Object.prototype.toString.call(t))return;t=t>1?1:t<0?0:t,t=Math.floor(10*t)/10;const i={type:"conditions",param:e};this.getCloudViewer().getFilter().addToOverrideListByOpacity(i,t,this.modelId)}restoreComponentsOpacityById(e){if(R.send(A,"restoreComponentsOpacityById"),"[object Array]"!==Object.prototype.toString.call(e))return;const t={type:"ids",param:e};this.getCloudViewer().getFilter().restoreComponentsOpacity(t,this.modelId)}restoreComponentsOpacityByObjectData(e){if(R.send(A,"restoreComponentsOpacityByObjectData"),"[object Array]"!==Object.prototype.toString.call(e))return;const t={type:"conditions",param:e};this.getCloudViewer().getFilter().restoreComponentsOpacity(t,this.modelId)}_restoreAllComponentsOpacityByObjectData(e){if("[object Array]"!==Object.prototype.toString.call(e))return;const t={type:"conditions",param:e};this.getCloudViewer().getFilter().restoreComponentsOpacity(t,this.modelId)}clearOverrideColorComponents(){R.send(A,"clearOverrideColorComponents"),this.getCloudViewer().getFilter().clearAllComponentsOverrideList(this.modelId)}overrideComponentsFrameColorById(e,t){R.send(A,"overrideComponentsFrameColorById"),this.getCloudViewer().getFilter().addToOverrideListForWireFrameByColor(e,{color:parseInt(t.getHEX(),16),opacity:t.getAlpha()},this.modelId)}restoreComponentsFrameColorById(e){R.send(A,"restoreComponentsFrameColorById"),this.getCloudViewer().getFilter().addToOverrideListForWireFrameByColor(e,null,this.modelId)}overrideComponentsFrameColorByObjectData(e,t){R.send(A,"overrideComponentsFrameColorByObjectData"),this.getCloudViewer().getFilter().addToOverrideListForWireFrameByConditions(e,{color:parseInt(t.getHEX(),16),opacity:t.getAlpha()},this.modelId)}restoreComponentsFrameColorByObjectData(e){R.send(A,"restoreComponentsFrameColorByObjectData"),this.getCloudViewer().getFilter().addToOverrideListForWireFrameByConditions(e,null,this.modelId)}setWireframeColor(e){R.send(A,"setWireframeColor"),this.overrideComponentsFrameColorByObjectData([],e)}restoreWireframeColor(){R.send(A,"restoreWireframeColor"),this.restoreComponentsFrameColorByObjectData([])}overrideAllComponentsColor(e){R.send(A,"overrideAllComponentsColor");const t=this.getCloudViewer().getFilter(),i={color:parseInt(e.getHEX(),16),opacity:e.getAlpha()};t.addAllComponentsToOverrideListByColor(i,this.modelId)}_overrideAllComponentsFrameColor(e){const t=this.getCloudViewer().getFilter(),i={color:parseInt(e.getHEX(),16),opacity:e.getAlpha()};t.addToOverrideListForAllWireFrame(i,this.modelId)}_restoreAllComponentsFrameColor(){this.getCloudViewer().getFilter().addToOverrideListForRestoreAllWireFrame(this.modelId)}highlightComponentsById(e,t,i){if(!i)return!1;this.getCloudViewer().getFilter().setOverriderByUserIds(i,e,{Red:"red",Orange:"beforeEdit",Yellow:"yellow",Green:"green",Blue:"blue",Black:"black"}[t],this.modelId)}highlightComponentsByObjectData(e,t){const i=this.getCloudViewer().getFilter(),n={Red:"red",Orange:"beforeEdit",Yellow:"yellow",Green:"green",Blue:"blue",Black:"black "};let o=[];for(var s=0,r=e.length;s<r;s++)o.push({condition:e[s],material:n[t]});i.setConditionOverrider(o,this.modelId)}localClippingComponentsById(e){const t={type:"ids",param:e};this.getCloudViewer().getFilter().addToLocalClippingList(t,this.modelId)}localClippingComponentsByObjectData(e){const t={type:"conditions",param:e};this.getCloudViewer().getFilter().addToLocalClippingList(t,this.modelId)}clearLocalClipping(){this.getCloudViewer().getFilter().clearLocalClippingList(this.modelId)}getBoundingBoxById(e){const t=this.getViewer().externalComponentManager;if(t&&t.isUserIdExist(e))return this.globalUnitUtil.revertTranslate(t.getBoundingBoxById(e),["x","y","z"]);if(this.isUserIdExist(e)){let t=this.getCloudViewer().getBoundingBoxByIds([e],this.modelId,!0),i=this.getViewer().sceneToWorld(t.min.clone()),n=this.getViewer().sceneToWorld(t.max.clone()),o=new THREE.Vector3(i.x,i.y,i.z),s=new THREE.Vector3(n.x,n.y,n.z);return(new THREE.Box3).setFromPoints([o,s])}}getBoundingBoxByIds(e){let t,i={x:1/0,y:1/0,z:1/0},n={x:-1/0,y:-1/0,z:-1/0};if(e.forEach((e=>{let o=this.getBoundingBoxById(e);o&&(t=!0,i={x:Math.min(i.x,o.min.x),y:Math.min(i.y,o.min.y),z:Math.min(i.z,o.min.z)},n={x:Math.max(n.x,o.max.x),y:Math.max(n.y,o.max.y),z:Math.max(n.z,o.max.z)})})),t){let e=new THREE.Vector3(i.x,i.y,i.z),t=new THREE.Vector3(n.x,n.y,n.z);return(new THREE.Box3).setFromPoints([e,t])}}getBoundingBoxByModelId(e,t){this.console.obsolete("BimModel.getBoundingBoxByModelId(modeld, callback)","BimModel.getBoundingBox(fileId, callback)");this._data.path||this._opt.resourceHost,this._data.databagId;const i=this._data.modelType;if("singleModel"==i){let i=this.getCloudViewer().modelManager.getModel(e);if(null!=i){let e=i.getBoundingBoxWorld();t&&t(e)}else t&&t(null)}else if("integrateModel"==i){let i=!1;if(this._data.config&&(i="true"==this._data.config["integrate-with-links"]),i){const i=this._getMetaDataManager();let n=(e,t)=>{let i=null;for(let o=0;o<t.length;o++){const s=t[o];if(s.linkPathHash===e)return i={},i.databagId=s.databagId,i.linkTransform=s.linkTransform,i;if(s.links.length>0&&(i=n(e,s.links),null!=i))return i}return i};(()=>new Promise(((e,t)=>{i.getLinkGraph((t=>{e(t)}))})))().then((i=>{let o=n(e,i);if(null!=o){let e=new THREE.Matrix4;""!=o.linkTransform&&e.fromArray(JSON.parse(o.linkTransform)),this.getModelInfo((i=>{let n=i.view,o=(new THREE.Box3).setFromArray(n.bbox);o.applyMatrix4(e),t&&t(o)}),(e=>{t&&t(null)}))}else t&&t(null)}))}else this.getFiles((i=>{let n=null;for(let t=0;t<i.length;t++){const o=i[t];if(o.fileId.toString()===e){n={},n.databagId=o.databagId.toString();break}}let o=this.getCloudViewer().modelManager.getModel(e);null!=n||o?this.getModelInfo((e=>{if(e.metadata&&"bimtiles"==e.metadata.asset)if(n)this.getBimtileInfo(n.databagId,e.metadata.root,(e=>{const i=e.root.boundingVolume;let n=(new THREE.Box3).setFromArray(i);t&&t(n)}),(()=>{t&&t(null)}));else if(o){let e=o.getBoundingBoxWorld();t&&t(e)}else t&&t(null);else{let i=e.view,n=(new THREE.Box3).setFromArray(i.bbox);t&&t(n)}}),(e=>{t&&t(null)})):t&&t(null)}))}}constructNormalBoundingPoints(e,t){const i=t.x,n=t.y,o=t.z,s=e.x,r=e.y,a=e.z;return[[i,n,a],[i,r,a],[i,r,o],[s,n,a],[s,r,a],[s,r,o]]}calculateMaxMInBoundingAfterMatrix(e,t,i){const n=this.constructNormalBoundingPoints(e,t),o=i.elements?t.applyMatrix4(i):t,s=i.elements?e.applyMatrix4(i):e;let r=o.x>s.x?s.x:o.x,a=o.y>s.y?s.y:o.y,l=o.z>s.z?s.z:o.z,h=o.x>s.x?o.x:s.x,d=o.y>s.y?o.y:s.y,c=o.z>s.z?o.z:s.z;for(let e=0;e<6;e++){let t=i.elements?(new THREE.Box3).setFromArray(n[e]).applyMatrix4(i):(new THREE.Box3).setFromArray(n[e]);t.min.x<r&&(r=t.min.x),t.min.y<a&&(a=t.min.y),t.min.z<l&&(l=t.min.z),t.max.x>h&&(h=t.max.x),t.max.y>d&&(d=t.max.y),t.max.z>c&&(c=t.max.z)}return this.globalUnitUtil.revertTranslate({min:{x:r,y:a,z:l},max:{x:h,y:d,z:c}},["x","y","z"])}getBoundingBox(e,t){const i=this._data.modelType;let n=this.getCloudViewer().modelManager,o=this;if(1==arguments.length&&"function"==typeof e){let s=n.getModel(this.modelId);if(null!=s){const r={originalBoundingBox:this.globalUnitUtil.revertBBox(s.getRawBoundingBox()),currentBoundingBox:this.globalUnitUtil.revertBBox(s.getBoundingBoxWorld())};e&&e(r)}else e&&e(null)}else if("singleModel"==i){e=e.toString();let a=n.getModel(e);if(null!=a){const l={originalBoundingBox:this.globalUnitUtil.revertBBox(a.getRawBoundingBox()),currentBoundingBox:this.globalUnitUtil.revertBBox(a.getBoundingBoxWorld())};2==arguments.length&&t&&t(l)}else t&&t(null)}else if("integrateModel"==i){e=e.toString();let h=!1;if(this._data.config&&(h="true"==this._data.config["integrate-with-links"]||"sharedCoordinates"==this._data.config.positioning),h){const c=this._getMetaDataManager();let u=(e,t)=>{let i=null;for(let n=0;n<t.length;n++){const o=t[n];if(o.linkPathHash===e)return i={},i.databagId=o.databagId,i.linkTransform=o.linkTransform,i;if(o.links.length>0&&(i=u(e,o.links),null!=i))return i}return i};(()=>new Promise(((e,t)=>{c.getLinkGraph((t=>{e(t)}))})))().then((i=>{let n=u(e,i);if(null!=n){let e=new THREE.Matrix4;""!=n.linkTransform&&e.fromArray(JSON.parse(n.linkTransform)),d(n,t,e)}else t&&t(null)}))}else this.getFiles((i=>{let n=null;for(let t=0;t<i.length;t++){const o=i[t];if(o.fileId.toString()===e){n={},n.databagId=o.databagId.toString();break}}let o=this.getCloudViewer().modelManager.getModel(e);if(null!=n)d(n,t);else if(o){const e={originalBoundingBox:this.globalUnitUtil.revertTranslate(o.getRawBoundingBox(),["x","y","z"]),currentBoundingBox:o.getBoundingBoxWorld()};t&&t(e)}else t&&t(null)}));function d(e,t,i){o.getModelInfo((n=>{var s=n.metadata&&"bimtiles"==n.metadata.asset;i&&s&&(i.elements[12]=i.elements[12]/1e3,i.elements[13]=i.elements[13]/1e3,i.elements[14]=i.elements[14]/1e3),o.getBimtileInfo(e.databagId,"config.json",(n=>{if(n.metadata&&"bimtiles"==n.metadata.asset)e?o.getBimtileInfo(e.databagId,n.metadata.root,(e=>{const n=e.root.boundingVolume;let r=(new THREE.Box3).setFromArray(s?n:[1e3*n[0],1e3*n[1],1e3*n[2],1e3*n[3],1e3*n[4],1e3*n[5]]),a=(new THREE.Box3).setFromArray(s?n:[1e3*n[0],1e3*n[1],1e3*n[2],1e3*n[3],1e3*n[4],1e3*n[5]]);const l=new THREE.Matrix4;l.elements=o.getModelTransformationAdaptedUnit(),i&&l.multiply(i);let h=new Object;h.originalBoundingBox=o.globalUnitUtil.revertTranslate(r,["x","y","z"]),h.currentBoundingBox=o.calculateMaxMInBoundingAfterMatrix(a.max,a.min,l),t&&t(h)}),(()=>{t&&t(null)})):t&&t(null);else{let e=n.view,r=(new THREE.Box3).setFromArray(s?[e.bbox[0]/1e3,e.bbox[1]/1e3,e.bbox[2]/1e3,e.bbox[3]/1e3,e.bbox[4]/1e3,e.bbox[5]/1e3]:e.bbox),a=(new THREE.Box3).setFromArray(s?[e.bbox[0]/1e3,e.bbox[1]/1e3,e.bbox[2]/1e3,e.bbox[3]/1e3,e.bbox[4]/1e3,e.bbox[5]/1e3]:e.bbox);const l=new THREE.Matrix4;l.elements=o.getModelTransformationAdaptedUnit(),i&&l.multiply(i);let h=new Object;h.originalBoundingBox=o.globalUnitUtil.revertTranslate(r,["x","y","z"]),h.currentBoundingBox=o.calculateMaxMInBoundingAfterMatrix(a.max,a.min,l),t&&t(h)}}),(()=>{t&&t(null)}))}))}}}getModelTree(e,t=!0){R.send(A,"getModelTree");const i=this._getMetaDataManager();i.getTreeNewData(e,(function(){i.getTreeOldData(e)}),t)}getElementByConditions(e,t,i){R.send(A,"getElementByConditions"),this.console.obsolete("Viewer3D.getModel(modelId).getElementByConditions","Viewer3D.getModel(modelId).getComponentsByConditions");this._getMetaDataManager().getElementByConditions(e,t,i)}getComponentsByConditions(e,t,i){R.send(A,"getComponentsByConditions");const n=this._getMetaDataManager();if("Local"!=this.getMetaData().dataEnvType)n.getComponentsByConditions(this.modelId,e,t,i);else{let i=this.getMatchIds(e);t&&t(i)}}getFiles(e){R.send(A,"getFiles");this._getMetaDataManager().getFiles(e)}getDimensions(e,t,i){R.send(A,"getDimensions");this._getMetaDataManager().getDimensions(e,(e=>{t&&("2.0"===e.version&&e.data&&e.data.length&&e.data[0].dimension&&(e=this.globalUnitUtil.excute(e,e.data[0].dimension.pointUnit,this.globalUnitUtil.getGlobalUnit(),["x","y","z"])).data.forEach((e=>e.dimension.pointUnit=this.globalUnitUtil.getGlobalUnit()||e.dimension.pointUnit)),t(e))}),i)}getComponentProperty(e,t,i){R.send(A,"getComponentProperty");const n=this._getMetaDataManager(),o=this._data.config,s=this.getCloudViewer();n.getComponentProperty(e,(i=>{i=this.globalUnitUtil.revertTranslate(i,["x","y","z"]);let n=!1;if(o&&(n="true"==o["integrate-with-links"]),0==n)t&&t(i);else{const n=s.getComponentInfoByUserId(e);n&&(i.boundingBox=n.boundingBox),t&&t(i)}}),i)}getFamilyProperty(e,t,i){R.send(A,"getFamilyProperty");this._getMetaDataManager().getFamilyProperty(e,(e=>{t&&t(e)}),i)}getComponentOverriddenProperty(e,t,i){R.send(A,"getComponentOverriddenProperty");this._getMetaDataManager().getComponentOverriddenProperty(e,(e=>t(this.globalUnitUtil.revertTranslate(e,["x","y","z"]))),i)}getMaterialProperty(e,t,i){R.send(A,"getMaterialProperty");this._getMetaDataManager().getMaterialProperty(e,t,i)}getMinimumComponentDistanceById(e,t){if(R.send(A,"getMinimumComponentDistanceById"),this.isUserIdExist(e)&&this.isUserIdExist(t))return this.getViewer().viewerAdapter.calculateMinDistance(e,t)}getInformation(){R.send(A,"getInformation");const e=this.getCloudViewer(this.modelId);return{elements:e.getNumOfElements(this.modelId),renderables:e.getNumOfRenderables(this.modelId),triangles:e.getNumOfTriangles(this.modelId),vertices:e.getNumOfVertices(this.modelId)}}getIntegrateTranslation(e){R.send(A,"getIntegrateTranslation"),this.getModelInfo((t=>{let i=t.view.translation||null;i&&(i={x:i[0],y:i[1],z:i[2]}),e&&e(i)}),(t=>{e&&e(null)}))}getModelInfo(e,t){R.send(A,"getModelInfo");this._getMetaDataManager().getModelInfo((t=>{e&&(t.coordinateSystem?t.coordinateSystem=this.transCoordinateSystems(t.coordinateSystem):t.view&&t.metadata&&t.metadata.model_unit&&(t.view.position&&(t.view.position=this.globalUnitUtil.excute(t.view.position,t.metadata.model_unit,this.globalUnitUtil.getGlobalUnit())),t.view.bbox&&(t.view.bbox=this.globalUnitUtil.excute(t.view.bbox,t.metadata.model_unit,this.globalUnitUtil.getGlobalUnit()))),e(t))}),t)}transCoordinateSystem(e){return e.internalOrigin&&e.internalOrigin.position&&(e.internalOrigin.position=this.globalUnitUtil.revertTranslate(e.internalOrigin.position),e.internalOrigin.transform.splice(12,3,...e.internalOrigin.position)),e.projectBasePoint&&e.projectBasePoint.position&&(e.projectBasePoint.position=this.globalUnitUtil.revertTranslate(e.projectBasePoint.position),e.projectBasePoint.transform.splice(12,3,...e.projectBasePoint.position)),e}getBimtileInfo(e,t,i,n){R.send(A,"getBimtileInfo");this._getMetaDataManager().getBimtileInfo(e,t,i,n)}_getModelGroup(){const e=this.getCloudViewer();let t="Model|"+this.modelId,i=e.getScene().getObjectGroup(t),n="BimTilesGroup|"+this.modelId,o=e.getScene().getObjectGroup(n);return i||o}_fireWhenModelChanged(){const t=this.getCloudViewer().getScene(),i=this.getModelTransformationAdaptedUnit();y.AxisGridManager.updateTransformation(t,this.modelId),y.ExtrudeBodyManager.getInstance(this._cloudViewer).updateTransformation&&y.ExtrudeBodyManager.getInstance(this._cloudViewer).updateTransformation(i,this.modelId),y.ContactShadow.getInstance()&&y.ContactShadow.getInstance().update();let n=e.Bimface.Viewer.Viewer3DEvent.ModelTransformed;const o={modelId:this.modelId,transformation:i};this._layer&&(o.layerId=this._layer.id),this._viewer.getEventManager().fireEvent(n,o),this._viewer.updateSceneBoundingBox(!1)}setModelTranslation(e){if(!e)return void console.log("Parameter translation is required.");let t=this.getCloudViewer(),i=this._getModelGroup();if(!i)return;e=this.globalUnitUtil.translateVector(e);let n=new THREE.Vector3(e.x,e.y,e.z),o=t.modelManager.getModel(this.modelId);o.translate(n),i.transformMatrix=o.getTransformMatrix(),t.modelManager.updateScene(),t.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}_setModelRotation(e,t,i){if(!e||!i)return void console.log("Parameter basePoint and rotation is required.");let n=this.getCloudViewer(),o=this._getModelGroup();if(!o)return;let s=this.globalUnitUtil.translateVector(e),r=n.modelManager.getModel(this.modelId);r.rotateOnBasePoint(s,t,i),o.transformMatrix=r.getTransformMatrix(),n.modelManager.updateScene(),n.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}setModelRotationX(e,t){let i=new THREE.Vector3(1,0,0);this._setModelRotation(e,i,t)}setModelRotationY(e,t){let i=new THREE.Vector3(0,1,0);this._setModelRotation(e,i,t)}setModelRotationZ(e,t){let i=new THREE.Vector3(0,0,1);this._setModelRotation(e,i,t)}setModelScale(e,t){if(!e||!t)return void console.log("Parameter basePoint and scale is required.");if(0===t)return void console.log("Invalid argument, value of scale must a number except zero.");let i=this.getCloudViewer(),n=this._getModelGroup();if(!n)return;let o="number"==typeof t?new THREE.Vector3(t,t,t):t,s=this.globalUnitUtil.translateVector(e),r=i.modelManager.getModel(this.modelId);r.scaleOnBasePoint(s,o),n.transformMatrix=r.getTransformMatrix(),i.modelManager.updateScene(),i.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}getModelTransformation(){const e=this.getCloudViewer().modelManager.getModel(this.modelId);if(!e)return;let t=e.getRawTransformMatrix().elements;return t[12]=this.globalUnitUtil.revertTranslate(t[12]),t[13]=this.globalUnitUtil.revertTranslate(t[13]),t[14]=this.globalUnitUtil.revertTranslate(t[14]),k.limitTransformationDecimal(t)}_getModelTransformation(){const e=this.getCloudViewer().modelManager.getModel(this.modelId);if(!e)return;return e.getRawTransformMatrix().elements}getModelTransformationAdaptedUnit(){const e=this.getCloudViewer().modelManager.getModel(this.modelId);if(!e)return;const t=e.getTransformMatrix();return k.limitTransformationDecimal(t.elements)}setModelTransformation(e){if(!e)return void console.log("Parameter modelTransformation is required.");if(["[object Float32Array]","[object Array]"].indexOf(Object.prototype.toString.call(e))<0)return void console.log("Parameter modelTransformation should be a array.");const t=this.getCloudViewer(),i=this._getModelGroup();if(!i)return;const n=(new THREE.Matrix4).fromArray(e);let o=new THREE.Vector3,s=new THREE.Quaternion,r=new THREE.Vector3;n.decompose(o,s,r),o=this.globalUnitUtil.translateVector(o),n.compose(o,s,r);t.modelManager.getModel(this.modelId).setTransformMatrix(n),i.transformMatrix=n,t.modelManager.updateScene();t.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}getSegmentGroups(e,t){this._getMetaDataManager().getSegmentGroups((t=>{e&&e(t)}),(e=>{t&&t(e)}))}getSegmentFromGroups(e,t,i){this._getMetaDataManager().getSegmentFromGroups(e,(e=>{t&&t(e)}),(e=>{i&&i(e)}))}getSegmentTree(e,t){this._getMetaDataManager().getSegmentTree((t=>{e&&e(t)}),(e=>{t&&t(e)}))}getSegmentById(e,t,i){this._getMetaDataManager().getSegmentById(e,(e=>{t&&t(e)}),(e=>{i&&i(e)}))}getSegmentElementIds(e,t,i){this._getMetaDataManager().getSegmentElementIds(e,(e=>{t&&t(e)}),(e=>{i&&i(e)}))}getPartialElementsMetadata(e,t,i){this._getMetaDataManager().getPartialElementsMetadata(e,(e=>{t&&t(e)}),(e=>{i&&i(e)}))}getPartialElementsMetadataFile(e){return this._getMetaDataManager().getPartialElementsMetadataFile(e)}getDatabagResource(e){return this._getMetaDataManager().getDatabagResource(e)}splitComponentByStretchedPlane(e,t){return R.send(V,"splitComponentByStretchedPlane"),this.splitComponentByPlane(e,t)}splitComponentByPlane(t,i){let n=[],o=new y.ExternalObjectConverterGroup,s=new y.ExternalObjectConverterGroup;i.point=this.globalUnitUtil.translate(i.point,["x","y","z"]);let r=[];const a=(e,t,i,n)=>{if("INFINITE"==n){let i=new THREE.Matrix4,n=(e._modelMatrix?i.copy(e._modelMatrix):i).clone().invert(),o=(e.matrix.clone().premultiply(n),t.clone().applyMatrix4(n)),s=y.GeomUtil.getGeometrySplitByPlane(e,o),r=e.material,a=new THREE.Mesh(s.geometry,r);return r.needsUpdate=!0,a.matrix.copy(s.nodeInfoMatrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a}if("FINITE"==n){let n,o=new THREE.Vector3(t.point.x,t.point.y,t.point.z),s=new THREE.Vector3(t.normal.x,t.normal.y,t.normal.z);n=0!=s.y?new THREE.Vector3(1,-s.x/s.y,0):0!=s.x?new THREE.Vector3(-s.y/s.x,1,0):new THREE.Vector3(1,0,0),n.normalize().multiplyScalar(t.range.width/2);let r=s.clone().cross(n);r.normalize().multiplyScalar(t.range.height/2);const a=(new THREE.Matrix4).copy(i).invert(),l=(new THREE.Matrix3).getNormalMatrix(a);let h={center:o.applyMatrix4(a),normal:s.applyNormalMatrix(l),x:n.applyMatrix4(a),y:r.applyMatrix4(a)},d=y.GeomUtil.getGeometrySplitByFinitePlane(e,h);for(let t=0,i=d.length;t<i;t++){let i=e[t].object.material,n=new THREE.Mesh(d[t][0].geometry,i),o=new THREE.Mesh(d[t][1].geometry,i);i.needsUpdate=!0,n.matrix.copy(d[t][0].nodeInfoMatrix),n.matrix.decompose(n.position,n.quaternion,n.scale),o.matrix.copy(d[t][1].nodeInfoMatrix),o.matrix.decompose(o.position,o.quaternion,o.scale),d[t]=[n,o]}return d}if("MULTI"==n){let n=new THREE.Vector3(0,0,0);"X"==t.stretch.direction?n.x=1:"Y"==t.stretch.direction?n.y=1:"Z"==t.stretch.direction?n.z=1:console.log("stretch direction should be one of X/Y/Z");const o=(new THREE.Matrix4).copy(i).invert();let s={points:t.points.map((e=>new THREE.Vector3(e.x,e.y,e.z).applyMatrix4(o))),stretch:n.applyMatrix4(o).normalize()},r=y.GeomUtil.getGeometrySplitByMultiPlane(e,s);for(let t=0,i=r.length;t<i;t++){let i=e[t].object.material,n=new THREE.Mesh(r[t][0].geometry,i),o=new THREE.Mesh(r[t][1].geometry,i);i.needsUpdate=!0,n.matrix.copy(r[t][0].nodeInfoMatrix),n.matrix.decompose(n.position,n.quaternion,n.scale),o.matrix.copy(r[t][1].nodeInfoMatrix),o.matrix.decompose(o.position,o.quaternion,o.scale),r[t]=[n,o]}return r}console.log("unknow split mode")};let l="FINITE";null!=i.range&&null!=i.range.width&&null!=i.range.height||(l="INFINITE"),i.points&&i.stretch&&(l="MULTI");const h=(e,t)=>{if(e instanceof THREE.Mesh)if("INFINITE"==l){let n=new THREE.Plane;n.setFromNormalAndCoplanarPoint(new THREE.Vector3(i.normal.x,i.normal.y,i.normal.z),new THREE.Vector3(i.point.x,i.point.y,i.point.z));let r=n.clone();r.normal.multiplyScalar(-1),r.constant*=-1,o.add(a(e,n,t,l)),s.add(a(e,r,t,l))}else r.push({object:e,parentMatrix:t});let n=e.children;for(let e=0,i=n.length;e<i;e++){let i=t.clone();i.multiplyMatrices(t,n[e].matrix),h(n[e],i)}};let d;if("Viewer3D"==this.getViewer().viewerType){if(d=this.getViewer().getExternalObjectByName(t),!d){let i=e.Web.Lang.Utility.UUID.createUUID();d=this.getViewer().convertToExternalObject(i,t,!1)}}else{let i=e.Web.Lang.Utility.UUID.createUUID();d=new y.ExternalObjectConverter(this.getCloudViewer()).convertToExternalObject(i,t,!1)}const c=this.getCloudViewer().modelManager.getModel(this.modelId);if(!c)return;const u=c.getTransformMatrix();if(d instanceof Array)for(var g=0;g<d.length;g++){let e=new THREE.Matrix4;e.copy(d[g].matrix),h(d[g],e)}else{let e=new THREE.Matrix4;e.copy(d.matrix),h(d,e)}if("INFINITE"!=l){a(r,i,u,l).forEach((e=>{o.add(e[0]),s.add(e[1])}))}return o.applyMatrix4(u),s.applyMatrix4(u),o._modelId=this.modelId,s._modelId=this.modelId,o._externalNeedScale=!1,s._externalNeedScale=!1,n.push(o),n.push(s),n}setGlowEffectById(t,i){R.send(A,"setGlowEffectById");var n=new THREE.Color("#11DAB7"),o="body",s=.3,r=3;null!=i&&(null!=i.type&&(o=i.type),null!=i.color&&i.color instanceof e.Web.Graphics.Color&&(n=new THREE.Color(i.color.red/255,i.color.green/255,i.color.blue/255)),null!=i.intensity&&(s=i.intensity),null!=i.spread&&(r=i.spread)),this.getCloudViewer().setGlowEffectById(this.modelId,t,{color:n,type:o,intensity:s,spread:r,isGis:!0}),this.getViewer().render()}removeGlowEffectById(e){if(R.send(A,"removeGlowEffectById"),null==e||0==e.length)return void console.warn("没有发光效果被删除。");this.getCloudViewer().removeGlowEffectById(this.modelId,e),this.getViewer().render()}clearGlowEffect(){R.send(A,"clearGlowEffect"),this.getCloudViewer().removeGlowEffectById(this.modelId),this.getViewer().render()}_clearOverrideColorComponentsAndWireFrame(){this.getCloudViewer().getFilter().clearAllOverrideList(this.modelId)}_overrideAllComponentsOpacityByObjectData(e,t){if(R.send(A,"overrideComponentsOpacityByObjectData"),"[object Array]"!==Object.prototype.toString.call(e))return;if("[object Number]"!==Object.prototype.toString.call(t))return;t=t>1?1:t<0?0:t,t=Math.floor(10*t)/10;const i={type:"conditions",param:e};this.getCloudViewer().getFilter().addToOverrideListByOpacity(i,t,this.modelId,!0)}_restoreAllDefaultFilter(){this._clearOverrideColorComponentsAndWireFrame(),this.activateAllComponents(),this.getViewer().clearAllRooms(),this.clearIsolation(),this.clearSelectedComponents(),this.showAllComponents(),this.opaqueAllComponents()}},function(){const t="Glodon.Bimface.FeatureData.PipeSystem",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.FeatureData"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");n.PipeSystem=class{constructor(e,t){this.viewer=e,this.model=t,this.materials=[],this.console=e.console,P(this)}getBaseInfo(){return{apiHost:this.model._opt.APIHost,modelType:this.model._data.modelType,viewToken:this.model._data.viewToken}}getSystems(e){i.send(t,"getSystems");const{apiHost:n,modelType:o,viewToken:s}=this.getBaseInfo();let r="";if("singleModel"===o){r=`${n}/data/v1/pipe/files/${this.model._dataModelId}/systems?view_token=${s}`}else{r=`${n}/data/v1/pipe/integrations/${this.model._dataModelId}/systems?view_token=${s}`}return this.load({url:r},e)}getComponentsBySystemId(e,n,o){if(i.send(t,"getComponentsBySystemId"),!e)return Promise.reject();if(!e.systemId)return this.console.warn("SystemId is not given"),Promise.reject("SystemId is not given");const{apiHost:s,modelType:r,viewToken:a}=this.getBaseInfo();let l="";if("singleModel"===r){l=`${s}/data/v1/pipe/files/${this.model._dataModelId}/systems/${e.systemId}/element-ids?view_token=${a}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");l=`${s}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/systems/${e.systemId}/element-ids?view_token=${a}`}return this.load({url:l,type:"post",data:JSON.stringify(n)},o)}getTopologyPropertiesById(e,n){if(i.send(t,"getTopologyPropertiesById"),!e)return Promise.reject();if(!e.componentId)return this.console.warn("ComponentId is not given"),Promise.reject("ComponentId is not given");const{apiHost:o,modelType:s,viewToken:r}=this.getBaseInfo();let a="";if("singleModel"===s){a=`${o}/data/v1/pipe/files/${this.model._dataModelId}/elements/${e.componentId}/properties?view_token=${r}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");a=`${o}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/${e.componentId}/properties?view_token=${r}`}return this.load({url:a},n)}getTopologyPropertiesByIds(e,n){if(i.send(t,"getTopologyPropertiesByIds"),!e)return Promise.reject();if(!e.componentIds)return this.console.warn("ComponentIds are not given"),Promise.reject("ComponentIds are not given");const{apiHost:o,modelType:s,viewToken:r}=this.getBaseInfo();let a="";if("singleModel"===s){return a=`${o}/data/v1/pipe/files/${this.model._dataModelId}/elements/properties?view_token=${r}`,this.load({url:a,type:"post",data:JSON.stringify(e.componentIds)},n)}{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");let t=this.model._dataModelId,i=e.fileId;return a=`${o}/data/v1/pipe/integrations/${t}/elements/properties?view_token=${r}`,this.load({url:a,type:"post",data:JSON.stringify([{fileIdHash:i,elementIds:e.componentIds}])},n)}}getFlowPathByIds(e,n){if(i.send(t,"getFlowPathByIds"),!e)return Promise.reject();if(!e.startComponentId)return this.console.warn("Start componentId is not given"),Promise.reject("Start componentId is not given");if(!e.endComponentId)return this.console.warn("End componentId is not given"),Promise.reject("End componentId is not given");const{apiHost:o,modelType:s,viewToken:r}=this.getBaseInfo();let a="";if("singleModel"===s){return a=`${o}/data/v1/pipe/files/${this.model._dataModelId}/elements/paths?view_token=${r}&startElement=${e.startComponentId}&endElement=${e.endComponentId}`,e.limit&&(a+=`&limit=${e.limit}`),this.load({url:a},n)}if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");return a=`${o}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/paths?view_token=${r}&startElement=${e.startComponentId}&endElement=${e.endComponentId}`,e.limit&&(a+=`&limit=${e.limit}`),this.load({url:a,data:e},n)}getDownstreamComponentsById(e,n,o){if(i.send(t,"getDownstreamComponentsById"),!e)return Promise.reject();if(!e.componentId)return this.console.warn("ComponentId is not given"),Promise.reject("ComponentId is not given");const{apiHost:s,modelType:r,viewToken:a}=this.getBaseInfo();let l="";if("singleModel"===r){l=`${s}/data/v1/pipe/files/${this.model._dataModelId}/elements/${e.componentId}/flow?view_token=${a}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");l=`${s}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/${e.componentId}/flow?view_token=${a}`}return this.load({url:l,type:"post",data:JSON.stringify({type:"downstream",filter:n})},o)}getUpstreamComponentsById(e,n,o){if(i.send(t,"getUpstreamComponentsById"),!e)return Promise.reject();if(!e.componentId)return this.console.warn("ComponentId is not given"),Promise.reject("ComponentId is not given");const{apiHost:s,modelType:r,viewToken:a}=this.getBaseInfo();let l="";if("singleModel"===r){l=`${s}/data/v1/pipe/files/${this.model._dataModelId}/elements/${e.componentId}/flow?view_token=${a}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");l=`${s}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/${e.componentId}/flow?view_token=${a}`}return this.load({url:l,type:"post",data:JSON.stringify({type:"upstream",filter:n})},o)}getConnectedComponentsByConditions(e,n,o){if(i.send(t,"getConnectedComponentsByConditions"),!e)return Promise.reject();if(!e.componentId)return this.console.warn("ComponentId is not given"),Promise.reject("ComponentId is not given");const{apiHost:s,modelType:r,viewToken:a}=this.getBaseInfo();let l="";if("singleModel"===r){l=`${s}/data/v1/pipe/files/${this.model._dataModelId}/elements/${e.componentId}/neighbors?view_token=${a}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");l=`${s}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/${e.componentId}/neighbors?view_token=${a}`}return this.load({url:l,type:"post",data:JSON.stringify(n)},o)}getAdjacentComponentsByConditions(e,n,o){if(i.send(t,"getAdjacentComponentsByConditions"),!e)return Promise.reject();if(!e.componentId)return this.console.warn("ComponentId is not given"),Promise.reject("ComponentId is not given");if(!n||!n.type||!n.filter)return this.console.warn("Must give condition"),Promise.reject("Must give condition");const{apiHost:s,modelType:r,viewToken:a}=this.getBaseInfo();let l="";if("singleModel"===r){l=`${s}/data/v1/pipe/files/${this.model._dataModelId}/elements/${e.componentId}/relations?view_token=${a}`}else{if(!e.fileId)return this.console.warn("Must give fileId in integrate model"),Promise.reject("Must give fileId in integrate model");l=`${s}/data/v1/pipe/integrations/${this.model._dataModelId}/files/${e.fileId}/elements/${e.componentId}/relations?view_token=${a}`}return this.load({url:l,type:"post",data:JSON.stringify(n)},o)}setFlowEffectMaterialByIds(e,n){if(i.send(t,"setFlowEffectMaterialByIds"),!e)return Promise.reject();if(!e.componentIds)return this.console.warn("ComponentIds are not given"),Promise.reject("ComponentIds are not given");const{apiHost:o,modelType:s,viewToken:r}=this.getBaseInfo();let a,l="";if("singleModel"===s){let t=this.model._dataModelId;l=`${o}/data/v1/pipe/files/${t}/elements/uv-direction?view_token=${r}`,a=e.componentIds}else{let t=this.model._dataModelId,i=e.fileId;l=`${o}/data/v1/pipe/integrations/${t}/elements/uv-direction?view_token=${r}`,a=[{fileIdHash:i,elementIds:e.componentIds}]}return new Promise(((t,i)=>{this.load({url:l,type:"post",data:JSON.stringify(a)},(i=>{"integrateModel"===s&&i.forEach((t=>t.id=`${e.fileId}.${t.id}`)),this.setMaterial(i,(e=>{n&&n(e),t(e)}))}))}))}clearFlowEffectMaterial(){i.send(t,"clearFlowEffectMaterial"),this.materials.map((e=>{e.clearOverrideComponentsMaterial(this.model.modelId)}))}setMaterial(t,i){if(t instanceof Array){this.materials=[];let n=new e.Bimface.Plugins.Material.MaterialContainer,o=[],s=[];t.map((e=>{"1"!=e.uvDirection&&"2"!=e.uvDirection||("1"==e.uvDirection?o.push(e.id):s.push(e.id))})),o.length>0&&(this.positiveMaterial||(this.positiveMaterial=this.initMaterial(90)),this.positiveMaterial.overrideComponentsMaterialById(o,this.model.modelId),n.addMaterial(this.positiveMaterial),this.materials.push(this.positiveMaterial)),s.length>0&&(this.reverseMaterial||(this.reverseMaterial=this.initMaterial(-90)),this.reverseMaterial.overrideComponentsMaterialById(s,this.model.modelId),n.addMaterial(this.reverseMaterial),this.materials.push(this.reverseMaterial)),i&&i(this.materials)}}initMaterial(t){let i=new e.Bimface.Plugins.Material.MaterialConfig;return i.viewer=this.viewer,i.src="https://static.bimface.com/attach/34d0d3aeb2e348aea5f3203b760ca667_flow5.png",i.rotation=t,i.scale=[1,1],i.callback=()=>this.viewer.render(),new e.Bimface.Plugins.Material.Material(i)}load(e,t){e.headers=e.headers||("post"===e.type?{"Content-type":"application/json;charset=UTF-8"}:{});return new Promise((function(i,n){o.ajax({async:!0,type:e.type||"get",url:e.url,headers:e.headers||{},data:e.data||null,success:function(e){"bimfaceservice-0000"===(e=JSON.parse(e)).code?(t&&t(e.data),i(e.data)):n(e.message)},failure:function(e){n(e)}})}))}}}(),function(){const t="Glodon.Bimface.Model.BimModel",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Model"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");class s extends e.Bimface.Model.Model{constructor(t,i,n,o,s){if(super(t,i,n,o,s),this.getIntegratedFileIds(),this.httpDefaultParams="Local"!=t._data.dataEnvType?{APIHost:t._opt.APIHost,loadMode:t._data.loadMode,fileId:i.modelId,viewToken:i.viewToken,modelType:i.modelType}:{},"Viewer3D"==t.getViewerType()){const r=this.getCloudViewer().getScene();let a,l=this;function h(e){a.removeSectionPlaneIntersectionNodes(),l.timerPlane&&(clearTimeout(l.timerPlane),l.timerPlane=null),l.timerPlane=setTimeout((()=>{a.drawSectionPlaneIntersectionAxis(e)}),200)}function d(e){a.removeSectionPlaneIntersectionNodes(),l.timerBox&&(clearTimeout(l.timerBox),l.timerBox=null),l.timerBox=setTimeout((()=>{a.drawSectionBoxIntersectionAxis(e)}),200)}t.addEventListener(e.Bimface.Plugins.Section.SectionPlaneEvent.SectionPlaneChanged,(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),h(e)})),t.addEventListener("SectionPlaneMobileChanged",(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),h(e)})),t.addEventListener("SectionPlaneStateChanged",(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),a.drawSectionPlaneIntersectionAxis(e)})),t.addEventListener("SectionPlaneVisibleChanged",(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),a.showOrHideSectionPlaneAxis(e)})),t.addEventListener(e.Bimface.Plugins.Section.SectionBoxEvent.SectionBoxUpdate,(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),d(e)})),t.addEventListener("SectionBoxVisibleChanged",(e=>{a||(a=y.AxisGridManager.getInstance(r,this.modelId)),a.showOrHideSectionBoxAxis(e)}))}}getFamilyTypes(t){const i=this.getMetaData(),n=new e.Bimface.Data.FamilyDataManagerConfig;n.databagId=i.databagId,n.dataEnvType=i.dataEnvType,n.resourcePath=i.path,n.resourceHost=this._opt.resourceHost,n.httpDefaultParams=this.httpDefaultParams;new e.Bimface.Data.FamilyDataManager(n).getFamilyTypes((e=>{t&&t(e)}))}showFamilyTypeById(n){i.send(t,"showFamilyTypeById");var o=e.Bimface.Viewer.IsolateOption;this.isolateComponentsByObjectData([{typeId:n}],o.HideOthers),this.getViewer().getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.FamilyTypeChanged,n)}enableShowGridBubblesAlongWithAxis(e){y.AxisGridManager.getInstance(this.getCloudViewer().getScene(),this.modelId).enableShowGridBubblesAlongWithAxis(e),this.getViewer().render()}showAllAxisGrids(){i.send(t,"showAllAxisGrids"),this.getViewer()._activeAxisGridManager();const e=this._data.path||this._opt.resourceHost,n=this._data.databagId,s=this._data.modelType;let r={},a=this;(()=>new Promise(((t,i)=>{"singleModel"==s?(r.default={},o.promiseJsonFunction({url:`${e}/${n}/metadata/levels.json`,path:"metadata/levels.json",status:"noCode",...a.httpDefaultParams}).then((e=>{r.default=e.levels,t(r)}))):"integrateModel"==s&&this.getFiles((e=>{let i=e.length;e.forEach((e=>{const n=e.fileId.toString();r[n]={},this.getFloorsbyFileIdV2(n,(e=>{r[n]=e,i--,0==i&&t(r)}))}))}))})))().then((t=>{0==t.length&&console.error("get level error");const i="grids.json"+y.GlobalData.ZipResourcePostfix,s=this.getCloudViewer().getScene();for(let r in t){const a=t[r],l=y.AxisGridManager.getInstance(s,this.modelId);for(let t=0;t<a.length;t++){let s=o.getUrl({url:`${e}/${n}/metadata/${r}/axisgrids/${i}`,path:`metadata/${r}/axisgrids/${i}`,...this.httpDefaultParams});null!=r&&""!=r.trim()&&"default"!=r||(s=o.getUrl({url:`${e}/${n}/metadata/axisgrids/${i}`,path:`metadata/axisgrids/${i}`,...this.httpDefaultParams}));const h=a[t].elevation,d=a[t].id;l.loadAxisGridsByHeight(s,r,h,d,(()=>{this.getViewer().render()}),this.getCloudViewer())}}}),(e=>{console.error("error",e)}))}getNearestAxisGrids(e,n,s){e=this.globalUnitUtil.translateVector(e),i.send(t,"getNearestAxisGrids");let r=!1;if(this._data.config&&(r="true"==this._data.config["integrate-with-links"]),r)return void console.log("We do not supprot link-integrate model now.");let a=this._data.modelType,l=this._data.path||this._opt.resourceHost,h=this._data.databagId,d=new y.AxisGridManager;d.modelTransformation=(new THREE.Matrix4).fromArray(this.getModelTransformationAdaptedUnit());let c="singleModel"==a;n=c?null:n;let u="grids.json"+y.GlobalData.ZipResourcePostfix,g=o.getUrl({url:`${l}/${h}/metadata/axisgrids/${u}`,path:`metadata/axisgrids/${u}`,...this.httpDefaultParams});0==c&&(g=`${l}/${h}/metadata/${n}/axisgrids/${u}`,g=o.getUrl({url:`${l}/${h}/metadata/${n}/axisgrids/${u}`,path:`metadata/${n}/axisgrids/${u}`,...this.httpDefaultParams})),(new THREE.FileLoader).load(g,(t=>{let i=y.AxisGridManager.adaptGridData(JSON.parse(t)),o={};for(let e of i.grids)o[e.name]=e.id;this._getMetaDataManager().dataManager.getLevels(n,(t=>{let r=[],a=[];for(let e of t.levels)r.push(e.id.toString()),a.push(e.elevation);let l={dist:Number.MAX_SAFE_INTEGER,intersect:null};d.formatHidedAxisGridIndex(n,i,r);for(let t=0;t<r.length;t++){let o=d.getHidedAxisGridIndex(n,r[t]);d.prepareGridLines(i,null,o),d.calculateIntersections();let s=d.getNearestIntersection(e,a[t]);s.dist<l.dist&&(l=s)}let h=l.intersect.name,c=d.getIntersectLines(h),u=[];u.push({id:o[c[0].name],name:c[0].name,offset:{x:this.globalUnitUtil.revertTranslate(e.x-c[0][0]),y:0}}),u.push({id:o[c[1].name],name:c[1].name,offset:{x:0,y:this.globalUnitUtil.revertTranslate(e.y-c[1][1])}}),d.destroy(),d=null,s&&s(u)}),(e=>{console.log(e)}))}))}showAxisGridsByFloor(e,n,s){i.send(t,"showAxisGridsByFloor"),this.getViewer()._activeAxisGridManager();const r=this._data.path||this._opt.resourceHost,a=this._data.databagId,l=this._data.modelType,h="grids.json"+y.GlobalData.ZipResourcePostfix,d=this.getCloudViewer().getScene();let c,u=!1;this._data.config&&(u="true"==this._data.config["integrate-with-links"]);let g=this;const p=()=>{this.getViewer().render()};1==u?(t=>new Promise(((i,n)=>{var s=`${r}/${a}/metadata/${e}/levels.json`;o.promiseJsonFunction({url:s,path:`metadata/${e}/levels.json`,status:"noCode",...g.httpDefaultParams}).then((e=>{const n=e.levels;for(let e=0;e<n.length;e++)if(n[e].id==t){i(n[e]);break}}))})))(n).then((t=>{let i=0;const l=y.AxisGridManager.getInstance(d,this.modelId);if(t.hasOwnProperty("transform")){const i=t.transform.splice(12,3);l.setLinkFloorId(e,n,t.linkId),l.setTranslation(e,n,i[0],i[1],t.elevation)}else i=t.elevation;c=o.getUrl({url:r+"/"+a+"/metadata/"+e+"/axisgrids/"+h,path:"metadata/"+e+"/axisgrids/"+h,...g.httpDefaultParams}),l.loadAxisGridsByHeight(c,e,i,n,(function(){p(),s&&s(),l.setLinkFloorId(null),l.setTranslation(0,0,0)}),this.getCloudViewer())})):new Promise((function(t,i){let s;"singleModel"==l?(c=o.getUrl({url:`${r}/${a}/metadata/axisgrids/${h}`,path:`metadata/axisgrids/${h}`,...g.httpDefaultParams}),o.promiseJsonFunction({url:`${r}/${a}/metadata/levels.json`,path:"metadata/levels.json",status:"noCode",...g.httpDefaultParams}).then((e=>{const i=e.levels;for(let e=0;e<i.length;e++)if(i[e].id==n){s=i[e].elevation;break}t(s)}))):"integrateModel"==l&&(c=o.getUrl({url:`${r}/${a}/metadata/${e}/axisgrids/${h}`,path:`metadata/${e}/axisgrids/${h}`,...g.httpDefaultParams}),o.promiseJsonFunction({url:`${r}/${a}/metadata/${e}/levels.json`,path:`metadata/${e}/levels.json`,status:"noCode",...g.httpDefaultParams}).then((e=>{const i=e.levels;for(let e=0;e<i.length;e++)if(i[e].id==n){s=i[e].elevation;break}t(s)})))})).then((t=>{if(null==t)return void console.error("get height error");const i=y.AxisGridManager.getInstance(d,this.modelId);"singleModel"==l&&(e="default"),i.loadAxisGridsByHeight(c,e,t,n,(()=>{p(),s&&s()}),this.getCloudViewer())}))}showAxisGridsByElevation(e,n,s){i.send(t,"showAxisGridsByElevation"),this.getViewer()._activeAxisGridManager();const r=this._data.path||this._opt.resourceHost,a=this._data.databagId,l="grids.json"+y.GlobalData.ZipResourcePostfix;let h=null;const d=this._data.modelType,c=this.getCloudViewer().getScene();if(null==n)return void console.error("get height error");const u=y.AxisGridManager.getInstance(c,this.modelId);"singleModel"==d?(e="default",h=o.getUrl({url:`${r}/${a}/metadata/axisgrids/${l}`,path:`metadata/axisgrids/${l}`,...this.httpDefaultParams})):"integrateModel"==d&&(h=o.getUrl({url:`${r}/${a}/metadata/${e}/axisgrids/${l}`,path:`metadata/${e}/axisgrids/${l}`,...this.httpDefaultParams}));const g="_"+(n=this.globalUnitUtil.translate(n));u.loadAxisGridsByHeight(h,e,n,g,(()=>{this.getViewer().render(),s&&s()}),this.getCloudViewer())}bringAxisGridsToFront(e){const t=this.getCloudViewer().getScene();y.AxisGridManager.getInstance(t,this.modelId).enableDepthTest(!e),this.getViewer().bIsBringAxisGridsToFront=e}removeAxisGridsByFloor(e,t,i){const n=this.getCloudViewer().getScene(),o=y.AxisGridManager.getInstance(n,this.modelId);"singleModel"==this._data.modelType&&(e="default"),o.unloadAxisGridsByFloor(e,t),this.getViewer().render(),i&&i()}removeAxisGridsByElevation(e,t){const i=this.getCloudViewer().getScene(),n=y.AxisGridManager.getInstance(i,this.modelId);"singleModel"==this._data.modelType&&(e="default");let o="_"+(t=this.globalUnitUtil.translate(t));n.unloadAxisGridsByFloor(e,o),this.getViewer().render()}getCurrentAxisGridsState(){const t=this.getCloudViewer().getScene(),i=y.AxisGridManager.getInstance(t,this.modelId);let n=i.getAxisGridState();n=this.globalUnitUtil.revertTranslate(n,"height");const o=n.gridLineColor,s=n.gridBubbleColor;return"string"==typeof o&&(n.gridLineColor=new e.Web.Graphics.Color(o,1)),"string"==typeof s&&(n.gridBubbleColor=new e.Web.Graphics.Color(s,1)),n.bIsBringToFront=this.getViewer().bIsBringAxisGridsToFront,n.bIsEnableHover=i.getIsEnableHover(),n}setGridBubblesColor(e){const t=this.getCloudViewer().getScene();y.AxisGridManager.getInstance(t,this.modelId).setGridBubblesColor(e),this.getViewer().render()}getGridBubblesColor(){const t=this.getCloudViewer().getScene();let i=y.AxisGridManager.getInstance(t,this.modelId).getGridBubblesColor();return"string"==typeof i&&(i=new e.Web.Graphics.Color(i,1)),i}setGridLinesColor(e){const t=this.getCloudViewer().getScene();y.AxisGridManager.getInstance(t,this.modelId).setGridLinesColor(e),this.getViewer().render()}getGridLinesColor(){const t=this.getCloudViewer().getScene();let i=y.AxisGridManager.getInstance(t,this.modelId).getGridLinesColor();return"string"==typeof i&&(i=new e.Web.Graphics.Color(i,1)),i}setAxisGridsState(t){t=this.globalUnitUtil.translate(t,"height"),this.removeAllAxisGrids(),this.getViewer()._activeAxisGridManager(),t.gridLineColor=(new e.Web.Graphics.Color).fromObject(t.gridLineColor),t.gridBubbleColor=(new e.Web.Graphics.Color).fromObject(t.gridBubbleColor);const i=this._data.path||this._opt.resourceHost,n=this._data.databagId,s="grids.json"+y.GlobalData.ZipResourcePostfix,r=this.getCloudViewer().getScene(),a=y.AxisGridManager.getInstance(r,this.modelId),l=()=>{this.getViewer().render()};let h=!1;this._data.config&&(h="true"==this._data.config["integrate-with-links"]);let d=!!t.fileInfos;if(!d||0!=t.fileInfos.length)if("singleModel"==this._data.modelType){const e=o.getUrl({url:`${i}/${n}/metadata/axisgrids/${s}`,path:`metadata/axisgrids/${s}`,...this.httpDefaultParams}),r=d?t.fileInfos[0].floorInfos:t.floorInfos;let h=0;for(let i=0;r&&i<r.length;i++){const n=r[i].id,o=r[i].height;a.loadAxisGridsByHeight(e,"default",o,n,(()=>{l&&l(),++h==r.length&&(this.setGridLinesColor(t.gridLineColor),this.setGridBubblesColor(t.gridBubbleColor))}),this.getCloudViewer())}}else if(1==h){let e=0,i=0;const n=d?t.fileInfos:Object.keys(t);for(let o of n){let n=o.fileId,s=o.floorInfos;0==d&&(n=o,s=t[n]);for(let o=0;s instanceof Array&&o<s.length;o++){i++;const r=s[o].id;-1==r.indexOf("_")?this.showAxisGridsByFloor(n,r,(()=>{l&&l(),++e==i&&(this.setGridLinesColor(t.gridLineColor),this.setGridBubblesColor(t.gridBubbleColor))})):this.showAxisGridsByElevation(n,s[o].height,(()=>{++e==i&&this.getViewer().render()}))}}}else{let e=0,r=0;const h=d?t.fileInfos:Object.keys(t);for(let c of h){let h=c.fileId,u=c.floorInfos;0==d&&(h=c,u=t[h]);for(let d=0;u instanceof Array&&d<u.length;d++){r++;const c=u[d].id,g=u[d].height,p=o.getUrl({url:`${i}/${n}/metadata/${h}/axisgrids/${s}`,path:`metadata/${h}/axisgrids/${s}`,...this.httpDefaultParams});a.loadAxisGridsByHeight(p,h,g,c,(()=>{l&&l(),++e==r&&(this.setGridLinesColor(t.gridLineColor),this.setGridBubblesColor(t.gridBubbleColor))}),this.getCloudViewer())}}}}showAxisGrid(e,t,i){const n=this._data.path||this._opt.resourceHost,s=this._data.databagId,r=t+".json"+y.GlobalData.ZipResourcePostfix,a=this.getCloudViewer().getScene();let l=o.getUrl({url:`${n}/${s}/metadata/axisgrids/${r}`,path:`metadata/axisgrids/${r}`,...this.httpDefaultParams});"string"==typeof e&&""!=e.trim()&&(l=o.getUrl({url:`${n}/${s}/metadata/${e}/axisgrids/${r}`,path:`metadata/${e}/axisgrids/${r}`,...this.httpDefaultParams}));y.AxisGridManager.getInstance(a,this.modelId).loadAxisGrid(l,e,i,void 0,t,(()=>{this.getViewer().render()}))}removeAxisGrid(e,t,i){const n=this.getCloudViewer().getScene();y.AxisGridManager.getInstance(n,this.modelId).unloadAxisGrid(e,t,i),this.getViewer().render()}removeAllAxisGrids(){const e=this.getCloudViewer().getScene();y.AxisGridManager.getInstance(e,this.modelId).unloadAllAxisGrids(),this.getViewer().render()}getAxisGridsIntersection(e,n,o){i.send(t,"getAxisGridsIntersection"),o||"[object Array]"!==Object.prototype.toString.call(n)?e||(e="default"):(o=n,n=e,e="default");const s=this.getCloudViewer().getScene(),r=y.AxisGridManager.getInstance(s,this.modelId);if(!r.mapFileIdGridjson[e])return void this.console.warn("getAxisGridsIntersection - 请先加载对应轴网,再调用接口.");const a=r.getAxisGridsIntersection(e,n,o);return 0===a.length&&this.console.warn("getAxisGridsIntersection - The input axes do not intersect."),this.globalUnitUtil.revertTranslate(a,["x","y","z"])}createRoomByAxisGrids(e,n,o,s,r,a){if(i.send(t,"createRoomByAxisGrids"),"[object Array]"===Object.prototype.toString.call(e)?(a=r,r=s,s=o,o=n,n=e,e="default"):e||(e="default"),"[object Array]"!==Object.prototype.toString.call(o))return void this.console.warn("createRoomByAxisGrids - elevations参数需传入数组形式,包含底标高和顶标高两个数值");o.sort();const l=this.getCloudViewer().getScene(),h=y.AxisGridManager.getInstance(l,this.modelId);if(!h.mapFileIdGridjson[e])return void this.console.warn("createRoomByAxisGrids - 请先加载对应轴网,再调用接口.");let d=h.getPartitionByAxisGrids(e,n),c=[],u=(new THREE.Matrix4).fromArray(this.getModelTransformationAdaptedUnit()).invert();for(let e=0;e<d.length;e++)c.push(d[e].clone().applyMatrix4(u));d=c;let g=[];if(d&&d.length>0){d.forEach((e=>{g.push([e.x,e.y,this.globalUnitUtil.translate(o[0])])})),g=this.globalUnitUtil.revertTranslate(g);let e=this.getViewer().createBoundary(g);this.getViewer().createRoom(e,o[1]-o[0],s,r,a),this.getViewer().bindRoomByModelId(s,this.modelId),this.getViewer().render()}else this.console.warn("createRoomByAxisGrids - 所选轴线未形成闭合区域,或传入了多余轴线.")}getFloorBoundingBoxById(e,n){i.send(t,"getFloorBoundingBoxById");const o=this._getMetaDataManager(),s=t=>{let i=new THREE.Box3;for(let n=0;n<t.floors.length;n++){const o=t.floors[n];if(o.id.toString()===e.toString()){const e=o.BoundingBox.Min,t=o.BoundingBox.Max;i.min=new THREE.Vector3(e.X,e.Y,e.Z),i.max=new THREE.Vector3(t.X,t.Y,t.Z);break}}n&&n(this.globalUnitUtil.revertBBox(i))};o._cache.mapInfo?s(o._cache.mapInfo):o.getMapInfo((e=>{o._cache.mapInfo=e,s(e)}),this._getMiniMapGridVersion())}loadFloorsForExplosion(){if(this._isRfa())return;const e=this._getMetaDataManager(),t=this;e.getExplosionFloorsInfo((e=>{let i=e.levels;const n=e.floors;if(i&&0!=i.length){for(let e=0;e<i.length;e++){let t=null;if(n){const o=n[i[e].name]&&n[i[e].name].BoundingBox;o&&(t=new THREE.Box3(new THREE.Vector3(o.Min.X,o.Min.Y,o.Min.Z),new THREE.Vector3(o.Max.X,o.Max.Y,o.Max.Z)))}else{const n=i[e].bbox;n&&(t=new THREE.Box3(new THREE.Vector3(n.min.x,n.min.y,n.min.z),new THREE.Vector3(n.max.x,n.max.y,n.max.z)))}t?(i[e].boundingBox=t,i[e].elevation=parseFloat(i[e].elevation)):(i.splice(e,1),e--)}0!=i.length&&(i.sort(((e,t)=>e.elevation-t.elevation)),t._viewer.getViewer().setFloorInfos(i,t.modelId),t._opt.floorExplosion=!0)}}))}getExplosionExtent(){return this.getCloudViewer().getExplosionExtent(this.modelId)}setExplosionExtent(e){const t=this.getCloudViewer();e>3||e<0?console.log("Warning::extent should be in a range of [0,3]"):(0!=this.getFloorExplosionExtent()&&this._opt.floorExplosion&&this.clearFloorExplosion(),t.setExplosionExtent(e,this.modelId))}setExplosionCenter(e){if(this.getExplosionExtent()>0)return;const t=this.getCloudViewer();e=e||{};const{position:i,type:n}=e;"userDefined"!==n||void 0!==i.x&&void 0!==i.y&&void 0!==i.z?t.setExplosionCenter(e,this.modelId):this.console.warn("option invalid!")}clearExplosion(){this.setExplosionExtent(0);this.getCloudViewer().setExplosionCenter({type:void 0},this.modelId)}setFloorExplosion(e,n,o){i.send(t,"bf_c_explosion_floor");const s=this.getCloudViewer();if(null==e)return void console.log("Warning::extent is undefined ");if(e>30||e<0)return void console.log("Warning::extent should be in a range of [0,30]");if(void 0!==o&&(void 0===o.x||void 0===o.y||void 0===o.z))return void console.log("Warning::direction should be undefined or has xyz");let r=new THREE.Vector3(0,0,1);null!=o&&(r.x=o.x,r.y=o.y,r.z=o.z,r.normalize()),0!==this.getExplosionExtent()&&this.setExplosionExtent(0),this._opt.floorExplosion?s.setFloorExplosion(e,n,r,this.modelId):console.log("Warning:: there is no floors information!")}getFloorExplosionExtent(){return this.getCloudViewer().getFloorExplosionExtent(this.modelId)}getFloorExplosionDirection(){return this.getCloudViewer().getFloorExplosionDirection(this.modelId)}getFloorExplosionList(){return this.getCloudViewer().getFloorExplosionList(this.modelId)}clearFloorExplosion(){const e=this.getCloudViewer(),t=e.getFloorExplosionDirection(this.modelId);e.setFloorExplosion(0,void 0,t,this.modelId)}searchText(e,t){if(void 0===e||""===e||!t)return console.error("搜索文本内容和回调函数不能为空");if(this._data.text)this._getTextWord(e,t);else{this._getMetaDataManager().getText((i=>{this._data.text=i.text,this._getTextWord(e,t)}),(e=>{t(e)}))}}_getTextWord(e,t){let i=this._data.text,n=[];for(let t=0;t<i.length;t++){let o=i[t];if(o.content.indexOf(e)>-1){let e=[],t=o.bbox;e.push({max:{x:t[3],y:t[4],z:t[5]},min:{x:t[0],y:t[1],z:t[2]}}),n.push({content:o.content,boundingBox:this.globalUnitUtil.revertTranslate(e,["x","y","z"])})}}t(n)}getIntegratedFileIds(){if(i.send(t,"getIntegratedFileIds"),"rvt-integrate"==this.getMetaData().workerType){this._getMetaDataManager().getFiles((e=>{const t=e;let i={RVT:[],notRVT:[]},n=!0;for(let e=0,o=t.length;e<o;e++){let o=t[e];if(void 0===o.fileType){n=!1;break}let s=o.linkedBy,r="rvt"===o.fileType.toLowerCase()?"RVT":"notRVT";for(let e=0,t=s.length;e<t;e++)i[r].push(s[e])}this.getMetaData().integratedFileIds=n?i:void 0}),(e=>{this.getMetaData().integratedFileIds=void 0,console.error("request data error!")}))}else this.getMetaData().integratedFileIds=void 0}getCategoryVisibility(e,t){this._getMetaDataManager().getCategoryVisibility((t=>{e&&e(t)}),(e=>{t&&t(e)}))}getRoomProperty(e,t){this._getMetaDataManager().getRoomProperty(e,(e=>{e?(e.boundary&&(e.boundary=JSON.parse(e.boundary)),e=this.globalUnitUtil.revertTranslate(e,["area","x","y","z","perimeter"]),(e=this.globalUnitUtil.revertTranslate(e,["area"])).boundary=JSON.stringify(e.boundary),t&&t(e)):t&&t(e)}))}getSetByComponentId(e,t){if(!e)return;e=e.toString();this._getMetaDataManager().getModelGroup((i=>{const n={id:null,name:"",type:"assembly",elements:[]},o=t=>{if(!t||0===t.length)return!1;for(let i=0;i<t.length;i++){const o=t[i].types;for(let t=0;t<o.length;t++){const i=o[t].name,s=o[t].instances;for(let t=0;t<s.length;t++){const o=s[t].id,r=s[t].elements;if(r.indexOf(e)>=0)return n.id=o,n.name=i,n.elements=r,!0}}}return!1};let s=o(i.assemblies);s||(n.type="group",s=o(i.groups)),s&&"[object Function]"===Object.prototype.toString.call(t)&&t(n)}))}getComponentsBySetId(e,t){if(!e)return;this._getMetaDataManager().getModelGroup((i=>{let n=null;const o=t=>{if(!t||0===t.length)return!1;for(let i=0;i<t.length;i++){const o=t[i].types;for(let t=0;t<o.length;t++){const i=o[t].instances;for(let t=0;t<i.length;t++){if(i[t].id.toString()===e.toString())return n=i[t].elements,!0}}}return!1};let s=o(i.assemblies);s||(s=o(i.groups)),s&&"[object Function]"===Object.prototype.toString.call(t)&&t(n)}))}getAreaProperty(e,t){this._getMetaDataManager().getAreaProperty(e,(e=>{e.boundary=JSON.parse(e.boundary),e=this.globalUnitUtil.revertTranslate(e,["area","x","y","z","perimeter"]),(e=this.globalUnitUtil.revertTranslate(e,["area"])).boundary=JSON.stringify(e.boundary),t(e)}))}_getMiniMapGridVersion(){return this._manifest&&this._manifest.Features&&this._manifest.Features.HasAxisGrids?2:1}getMapInfo(e){this._getMetaDataManager().getMapInfo((t=>e(this.globalUnitUtil.revertTranslate(t,["x","y","z","X","Y","Z","elevation","arch_elev","stru_elev"]))),this._getMiniMapGridVersion())}getMapInfoAsync(e,t){this._getMetaDataManager().getMapInfoAsync((t=>e(this.globalUnitUtil.revertTranslate(t,["x","y","z","X","Y","Z","elevation","arch_elev","stru_elev"]))),t,this._getMiniMapGridVersion())}getExplosionFloorsInfo(e){this._getMetaDataManager().getExplosionFloorsInfo((t=>e(this.globalUnitUtil.revertTranslate(t,["x","y","z","X","Y","Z","elevation","arch_elev","stru_elev"]))))}getLinkGraph(e){this._getMetaDataManager().getLinkGraph(e)}getDrawingsheets(e,n,o){if(i.send(t,"getDrawingsheets"),!e&&""!=e)return;"[object Function]"===Object.prototype.toString.call(e)&&(n=e,e="");this._getMetaDataManager().getDrawingsheets(e,"",n,o)}getAllDrawingsheets(e){i.send(t,"getAllDrawingsheets");this._getMetaDataManager().getAllDrawingsheets("","",e)}getDrawingListbyId(e,n,o){if(void 0===n)return;i.send(t,"getDrawingListbyId");this._getMetaDataManager().getDrawingList(e,n,(e=>{o&&(e.forEach((e=>{e.viewInfo&&(e.viewInfo.cropBox&&(e.viewInfo.cropBox=this.globalUnitUtil.revertTranslate(e.viewInfo.cropBox)),e.viewInfo.outline&&(e.viewInfo.outline=this.globalUnitUtil.revertTranslate(e.viewInfo.outline)))})),o(e))}),(e=>{401==e?console.log("Unauthorized."):403==e?console.log("Forbidden."):404==e&&console.log("Not Found.")}))}_isPlan(e){return 0===e[0]&&0===e[1]&&1===e[2]}_getRotatePoint(e,t,i){return function(e,t){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),s=i/o,r=n/o,a=Math.cos(t),l=Math.sin(t),h=r*a+s*l;return{x:(o*(s*a-r*l)).toFixed(4)-0,y:(o*h).toFixed(4)-0}}(i,((i,n)=>{let o=Math.sqrt(i.reduce(((e,t)=>e+Math.pow(t,2)),0)),s=Math.sqrt(n.reduce(((e,t)=>e+Math.pow(t,2)),0)),r=Math.acos(i.reduce(((e,t,i)=>e+t*n[i]),0)/(o*s));return r=e[0]*t[1]-e[1]*t[0]<0?r:2*Math.PI-r,r})(e,t))}getModelPosition(n,s){i.send(t,"getModelPosition");const r=this;let a,{sheetId:l,point:h}=n;a=h&&void 0!==h.x&&void 0!==h.y?h:Array.isArray(h)?{x:h[0],y:h[1]}:{x:0,y:0};const d=this._data.databagId;e.Web.Graphics.Utility.Relation.getDrawingSheets(d,l,(e=>{const t=e.portsAndViews[0],i=t.elevation||0,h=t.viewPoint.upDirection,c=this._data.path||this._opt.resourceHost;if(this._isPlan(t.viewPoint.viewDirection)){let e=a;o.promiseJsonFunction({url:`${c}/${d}/resource/drawing/${l}/viewport.json.gz`,path:`resource/drawing/${l}/viewport.json.gz`,status:"noCode",...r.httpDefaultParams}).then((t=>{const o=t.layoutInfo,l=n.viewId||0,d=o.find((e=>e.layoutId==l));if(d){const t=d.viewports.find((e=>e.outline[0]<=a.x&&e.outline[1]<=a.y&&e.outline[2]>=a.x&&e.outline[3]>=a.y));if(t){const n=new THREE.Matrix4;n.elements=t.transformation,e=new THREE.Vector3(e.x,e.y,i).applyMatrix4(n)}}e=this._getRotatePoint([h[0],h[1]],[0,1],e),s&&s({x:r.globalUnitUtil.translateToIncomeUnit(e.x),y:r.globalUnitUtil.translateToIncomeUnit(e.y),z:r.globalUnitUtil.translateMToIncomeUnit(i)})})).catch((e=>{this.console.warn(e)}))}else s&&s(null)}),null,this.httpDefaultParams)}getLinksJson(e){this._getMetaDataManager().getLinksJson("","",e)}getLinksInfo(e){i.send(t,"getLinksInfo");this._getMetaDataManager().getLinksJson("","",e)}getModelSet(e,n){i.send(t,"getModelSet");this._getMetaDataManager().getModelGroup(e,n)}getAreas(e,n){let o=this;i.send(t,"getAreas");this._getMetaDataManager().getAreas((t=>e(function(e){return(e=o.globalUnitUtil.revertTranslate(e,["archElev","elevation","height","structElev"])).forEach((e=>{e.areas&&e.areas.forEach((e=>{e.boundary&&(e.boundary=JSON.parse(e.boundary),(e=o.globalUnitUtil.revertTranslate(e,["x","y","z"],!1)).boundary=JSON.stringify(e.boundary))})),e.rooms&&e.rooms.forEach((e=>{e.boundary&&(e.boundary=JSON.parse(e.boundary),(e=o.globalUnitUtil.revertTranslate(e,["x","y","z"],!1)).boundary=JSON.stringify(e.boundary))}))})),e}(t))),n)}getAreas4Tree(e,n){i.send(t,"getAreas");this._getMetaDataManager().getAreas(e,n)}getFloors(e){i.send(t,"getFloors");this._getMetaDataManager().getFloors((t=>e(this.globalUnitUtil.revertTranslate(this.globalUnitUtil.revertTranslate(t,["archElev","elevation","height","structElev","areas"]),["areas"]))))}getProjectInfo(e,n){i.send(t,"getProjectInfo"),this._getMetaDataManager().getProjectInfo((t=>{e&&(t.coordinateSystems&&(t.coordinateSystems=this.transCoordinateSystems(t.coordinateSystems)),e(t))}),n)}transCoordinateSystems(e){return e.internalOrigin&&e.internalOrigin.position&&(e.internalOrigin.position=this.globalUnitUtil.revertTranslate(e.internalOrigin.position),e.internalOrigin.transform.splice(12,3,...e.internalOrigin.position)),e.projectBasePoint&&e.projectBasePoint.position&&(e.projectBasePoint.position=this.globalUnitUtil.revertTranslate(e.projectBasePoint.position),e.projectBasePoint.transform.splice(12,3,...e.projectBasePoint.position)),e}getFloorsbyFileId(e,t){const i=this,n=this._data.path||this._opt.resourceHost,s=this._data.databagId;o.promiseJsonFunction({url:`${n}/${s}/metadata/${e}/levels.json`,path:`metadata/${e}/levels.json`,status:"noCode",...this.httpDefaultParams}).then((e=>{var n=e.levels;t&&t(i.globalUnitUtil.revertTranslate(n,["elevation"]))}))}getFloorsbyFileIdV2(e,t){const i=this._data.path||this._opt.resourceHost,n=this._data.databagId;o.promiseJsonFunction({url:`${i}/${n}/metadata/${e}/levels.json`,path:`metadata/${e}/levels.json`,status:"noCode",...this.httpDefaultParams}).then((e=>{var i=e.levels;t&&t(i)}))}getScheduleList(e){i.send(t,"getScheduleList");this._getMetaDataManager().getScheduleList(e)}getScheduleById(e,n){i.send(t,"getScheduleById");this._getMetaDataManager().getScheduleById(e,n)}getOutlinerInfo(e){const t=this._data.path||this._opt.resourceHost,i=this._data.databagId;o.ajax({async:!0,url:o.getUrl({url:`${t}/${i}/metadata/outliner`+y.GlobalData.ZipResourcePostfix,path:"metadata/outliner"+y.GlobalData.ZipResourcePostfix,...this.httpDefaultParams}),success:t=>{e&&e(t)}})}getMepSystem(e,n,o){i.send(t,"getMepSystem");this._getMetaDataManager().getMepSystem(e,(e=>n(this.globalUnitUtil.revertTranslate(e,["in","out"]))),o)}getObjectMap(e){i.send(t,"getObjectMap");this._getMetaDataManager().getObjectMap(e)}getNestedComponents(e){i.send(t,"getNestedComponents"),this._getMetaDataManager().getNestedComponents(e)}get3DViewStates(n){if(i.send(t,"get3DViewStates"),this._viewStates){let e=this.getViewer().getCurrentState();this._viewStates.views.forEach((t=>{t.state.axisGrid=e.axisGrid})),"[object Function]"===Object.prototype.toString.call(n)&&n(this._viewStates)}else{let t,i;const o=()=>{let o=this.getViewer().getCameraStatus(),s=new THREE.Vector3(o.position.x,o.position.y,o.position.z),r=!1,a=new THREE.Vector3(o.target.x,o.target.y,o.target.z).sub(s).length();for(let n in i){const o=i[n];let s=this.getViewer().getCurrentState();if(o.sectionBox){let t=o.sectionBox,i=this.getViewer()._sectionBox;if(!i){var l=new e.Bimface.Plugins.Section.SectionBoxConfig;l.viewer=this.getViewer(),l.id="SectionBox",i=new e.Bimface.Plugins.Section.SectionBox(l),r=!0,s=this.getViewer().getCurrentState()}let n={x:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.min[0]),y:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.max[1]),z:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.min[2])},a={x:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.max[0]),y:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.min[1]),z:this.getViewer().globalUnitUtil.translateToIncomeUnit(t.max[2])},h=this.getViewer().worldToScene(n),d=this.getViewer().worldToScene(a),c=s.sectionBoxState.cubeSize;s.sectionBoxState.center=this.getViewer().globalUnitUtil.translateVector(s.sectionBoxState.center);let u=s.sectionBoxState.center,g=u.clone().sub(c.clone().multiplyScalar(.5)),p=u.clone().add(c.clone().multiplyScalar(.5));h.set(Math.max(h.x,g.x),Math.max(h.y,g.y),Math.max(h.z,g.z)),d.set(Math.min(d.x,p.x),Math.min(d.y,p.y),Math.min(d.z,p.z));let m=h.clone().add(d).multiplyScalar(.5);s.sectionBoxState.position=m;let f=d.clone().sub(h).clone().divide(c);s.sectionBoxState.scale=f,s.sectionBoxState.planeOffset[0]=d.x-p.x,s.sectionBoxState.planeOffset[1]=h.x-g.x,s.sectionBoxState.planeOffset[2]=d.y-p.y,s.sectionBoxState.planeOffset[3]=h.y-g.y,s.sectionBoxState.planeOffset[4]=d.z-p.z,s.sectionBoxState.planeOffset[5]=h.z-g.z,s.sectionBoxState.rotate=t.rotate,s.sectionBoxState.center=this.getViewer().globalUnitUtil.revertVector(s.sectionBoxState.center),s.sectionBoxState.position=this.getViewer().globalUnitUtil.revertVector(s.sectionBoxState.position)}else s.sectionBoxState=void 0;s.sectionPlaneState=void 0,s.selection=[];const[h]=t.viewList.filter((e=>e.id===n));if(h){const{origin:e,upDirection:t,viewDirection:i,cameraType:n,target:o}=h.viewPoint;s.camera.position={x:this.globalUnitUtil.revertTranslate(e[0]),y:this.globalUnitUtil.revertTranslate(e[1]),z:this.globalUnitUtil.revertTranslate(e[2])},s.camera.target=o?{x:this.globalUnitUtil.revertTranslate(o[0]),y:this.globalUnitUtil.revertTranslate(o[1]),z:this.globalUnitUtil.revertTranslate(o[2])}:{x:this.globalUnitUtil.revertTranslate(e[0])-i[0]*a,y:this.globalUnitUtil.revertTranslate(e[1])-i[1]*a,z:this.globalUnitUtil.revertTranslate(e[2])-i[2]*a},s.camera.up={x:t[0],y:t[1],z:t[2]};let r=n||h.cameraType;r&&(s.camera.name=r)}let d;for(let e in s.state){s.state[e]={actions:[],isolateAction:null,sceneState:0,version:"1.0"};let t=o.invisibleElements;t&&t.length>0&&s.state[e].actions.push({className:"VisibleIdsFA",flag:!0,ids:t,isVisible:!1});let i=o.overrideElements;if(i&&Object.keys(i).length>0){if(!d){d=[];for(let e in i){let t=i[e],n={className:"OverrideIdsFA",flag:!0,ids:t.ids,material:y.MaterialUtil.createStandardMaterial({color:Number(t.color),opacity:Number(t.opacity||1),transparent:!(Math.abs(t.opacity-1)<.001)})};d.push(n)}}s.state[e].actions=s.state[e].actions.concat(d)}}let c={id:n,name:h.name,state:s};this._viewStates.views.push(c),d=null}r&&this.getViewer()._sectionBox.exit(),"[object Function]"===Object.prototype.toString.call(n)&&n(this._viewStates),r&&this.getViewer().render()};this._viewStates={};const s=this._getMetaDataManager();s.getViews((e=>{t=JSON.parse(e.data);const n=t.exported3DViews;if(n){this._viewStates.primary3DView=t.primary3DView,this._viewStates.views=[],i={};let e=0;n.forEach((t=>{s.getViewData(t,(s=>{i[t]=s,e+=1,e===n.length&&o()}),(t=>{e+=1,e===n.length&&o()}))}))}}))}}loadMaterialOverrideSet(e,t,i,n,o){const s=this.getCloudViewer().modelManager;this._getMetaDataManager().getMaterialOverride(e,t,(e=>{e&&(s.createMaterialOverrideSet(e,o),i&&i())}),(e=>{e="loading materialOverrideSet error:"+e,n&&n(e)}))}applyMaterialOverrideSet(e,t,i,n,o){const s=this.getCloudViewer(),r=new y.MaterialOverriderSet,a=()=>{const e=r.overriders,t=s.getFilter();for(let i=0,n=e.length;i<n;i++){const n=e[i].material,o=e[i].condition;n&&t.addToOverrideListByMaterial(o,n,this.modelId)}s.render(),n&&n()},l=()=>{o&&o()};this._getMetaDataManager().getMaterialOverride(e,t,(e=>{if(!e)return;const t=s.modelManager.getConditions();r.load(e,t,i,a,l)}),(e=>{e="loading materialOverrideSet error:"+e,o&&o(e)}))}changeMaterialOverrideSetMode(e){const t=this.getCloudViewer();t.enableTextureMapping(!e),t.render()}restoreMaterialByMaterialId(e){this.getCloudViewer().restoreMaterialByMaterialId(this.modelId,e)}overrideMaterialByMaterialId(e,t,i,n,o,s){const r=this._getMetaDataManager(),a=this;let l=null;const h=a.getCloudViewer();function d(t){h.overrideMaterialByMaterialId(a.modelId,e,l,t)?o&&o():(console.log("ERROR: there is no material id witch equal to "+e),s&&s())}function c(e){let t=e.url;y.MaterialUtil.loadTexture(t,d,s)}function u(e){if(!(e&&e[0]&&e[0].common&&e[0].common.instance))return console.log("ERROR: there is no material instance!"),void(s&&s());if(l=JSON.parse(e[0].common.instance),!l.diffuse_texture||""==l.diffuse_texture)return console.log("ERROR: there is no diffuse_texture of the material!"),void(s&&s());let n=l.diffuse_texture.texture_file;r.getTextureJson(t,i,n,c,s)}h.loadMaterialIds(a.modelId,(function(){r.getMaterialJson(t,i,n,u,s)}),s)}getAllMaterialIds(e,t){this.getCloudViewer().loadMaterialIds(this.modelId,e,t)}setSelectedNodesByMaterialId(e){this.getCloudViewer().setSelectionByMaterialId(this.modelId,e)}setDetailRatio(e){if(e<.1||e>5)return void this.console.warn("the ratio must in [0.1,5]");const t=this.getCloudViewer().getModelManager().getModel(this.modelId);t.tilesLoader?t.setDetailRatio(e):this.console.warn("the model is not bimtileModel")}getDetailRatio(){const e=this.getCloudViewer().getModelManager().getModel(this.modelId);if(e.tilesLoader)return e.getDetailRatio();console.warn("the model is not bimtileModel")}loadOnDemand(e){if(!Array.isArray(e))return void console.warn("the condition must be Array.");const t=this.getCloudViewer().getModelManager().getModel(this.modelId);t.tilesLoader?t.loadOnDemand(e):this.console.warn("the model is not bimtileModel")}debugShowGeometricError(e){const t=this.getCloudViewer().getModelManager().getModel(this.modelId);t.tilesLoader?t.debugShowGeometricError(e):this.console.warn("the model is not bimtileModel")}getMaxDetailLevel(){return this.getCloudViewer().getModelManager().getModel(this.modelId).getMaxDetailLevel()}setMaxDetailLevel(e){if(!this.isBimtilesModel())return void console.warn("Only bimtiles has visual range");this.getCloudViewer().getModelManager().getModel(this.modelId).setMaxDetailLevel(e)}setVisualRange(e){if(!this.isBimtilesModel())return void console.warn("Only bimtiles has visual range");this.getCloudViewer().getModelManager().getModel(this.modelId).setVisualRange(e)}getVisualRange(){if(!this.isBimtilesModel())return void console.warn("Only bimtiles has visual range");return this.getCloudViewer().getModelManager().getModel(this.modelId).getVisualRange()}getRootGeoErrDistance(){if(!this.isBimtilesModel())return void console.warn("Only bimtiles has visual range");return this.getCloudViewer().getModelManager().getModel(this.modelId).getRootGeoErrDistance()}rayCastVertical(e){if(!this.isBimtilesModel())return void console.warn("Only bimtiles need vertical ray cast");return this.getCloudViewer().getModelManager().getModel(this.modelId).rayCastVertical(e)}overrideComponentsFrameColor(e,t){const i={all:()=>this._overrideAllComponentsFrameColor(t),objectData:e=>this.overrideComponentsFrameColorByObjectData(e,t),ids:e=>this.overrideComponentsFrameColorById(e,t),noObjectData:e=>this.restoreComponentsFrameColorByObjectData(e),noIds:e=>this.restoreComponentsFrameColorById(e)};this._executeByCondition(e,i)}restoreComponentsFrameColor(e){const t={all:()=>this._restoreAllComponentsFrameColor(),objectData:e=>this.restoreComponentsFrameColorByObjectData(e),ids:e=>this.restoreComponentsFrameColorById(e)};this._executeByCondition(e,t)}setComponentsFrameVisibility(e){this.wireFrameVisibilityOption=e}getComponentsFrameVisibility(){return this.wireFrameVisibilityOption}restoreComponentsOpacityById(e){super.restoreComponentsOpacityById(e)}restoreComponentsOpacityByObjectData(e){super.restoreComponentsOpacityByObjectData(e)}_restoreAllComponentsOpacityByObjectData(e){super._restoreAllComponentsOpacityByObjectData(e)}getDrawingPosition(n,o,s){let r=null;"object"==typeof n&&(s=o,o=n.point,r=n.fileId,n=n.sheetId),i.send(t,"getDrawingPosition");let a,l=this._data.databagId;a=o&&void 0!==o.x&&void 0!==o.y?o:Array.isArray(o)?{x:o[0],y:o[1]}:{x:0,y:0},e.Web.Graphics.Utility.Relation.getDrawingSheets(l,n,(e=>{const t=e.portsAndViews[0],i=t.viewPoint.upDirection;this._isPlan(t.viewPoint.viewDirection)?(a=this._getRotatePoint([0,1],[i[0],i[1]],a),s&&s(new THREE.Vector2(a.x,a.y))):s&&s(null)}),r,this.httpDefaultParams)}_getRotatePoint(e,t,i){return function(e,t){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),s=i/o,r=n/o,a=Math.cos(t),l=Math.sin(t),h=r*a+s*l;return{x:(o*(s*a-r*l)).toFixed(4)-0,y:(o*h).toFixed(4)-0}}(i,((i,n)=>{let o=Math.sqrt(i.reduce(((e,t)=>e+Math.pow(t,2)),0)),s=Math.sqrt(n.reduce(((e,t)=>e+Math.pow(t,2)),0)),r=Math.acos(i.reduce(((e,t,i)=>e+t*n[i]),0)/(o*s));return r=e[0]*t[1]-e[1]*t[0]<0?r:2*Math.PI-r,r})(e,t))}_isPlan(e){return 0===e[0]&&0===e[1]&&1===e[2]}getFeatureData(t="pipeSystem"){const i=this._viewer.console;return"pipeSystem"==t?this._data.extractType&&this._data.extractType.pipeSystem?(this._pipeSystem||(this._pipeSystem=new e.Bimface.FeatureData.PipeSystem(this.getViewer(),this)),this._pipeSystem):(i.warn("当前模型未进行元素信息抽提"),null):null}getLevelMapping(e){i.send(t,"getLevelMapping"),this._getMetaDataManager().getLevelmapping(e)}getDrawingTree(e,n){i.send(t,"getDrawingTree"),"[object Function]"===Object.prototype.toString.call(e)&&(n=e,e=""),this._getMetaDataManager().getDrawingTree(e,(e=>n(this.globalUnitUtil.excute(e,"mm",this.globalUnitUtil.getGlobalUnit(),["cropBox","outline","elevation"]))))}getComponetsBySections(e,n){i.send(t,"getComponetsBySections");this._getMetaDataManager().getSectionData((function(t){const i=t.sections.find((t=>t.sectionId===e));n(i)}))}getRoomManager(){if(!this.roomModelManager){this.getViewer().getRoomManager();const t=new e.Bimface.Plugins.Rooms.RoomManagerConfig;t.viewer=this.getViewer(),t.modelId=this.modelId,t.modelMode=!0,this.roomModelManager=new e.Bimface.Plugins.Rooms.RoomModelManager(t)}return this.roomModelManager}}n.BimModel=s}();class U{constructor(t){this.viewer=t;let i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom").create("div","bf-rotating-conext");i.style.position="absolute",i.style.left=0,i.style.top=0,i.style.width="100%",i.style.height="100%",this.domContainer=i,this.viewer.getDomElement().appendChild(i),this.rotateCenterSize=[26,26],this.rotateCenter=null,this.initialize()}destroy(){this.domContainer.parentNode&&this.domContainer.parentNode.removeChild(this.domContainer),this.domContainer=null,this.rotateCenter=null,this.rotateCenterSize=null,this.opacityControler=null,this.viewer=null}initialize(){this.rotateCenterId=e.Web.Lang.Utility.UUID.createUUID();let t=this.getRotateCenterHtml();this.domContainer.innerHTML=t,this.setOpacity(0),this.hookEvents(),this.opacityControler=new N}hookEvents(){let e=this.viewer.getViewer();e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_BEGIN,(e=>{this.startPoint=e.startPt})),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ROTATING,(()=>{this.opacityControler.setIsActive(!0),this.opacityControler.increment();let e=this.calcRotatingCenter();e&&this.translate(e.x,e.y);let t=this.opacityControler.getPercentage();this.setOpacity(t)}));let t=[];t.push(CLOUD.EVENTS.ON_EDITOR_END),t.push(CLOUD.EVENTS.ON_TOOL_END);for(const i of t)e.registerEventListener(i,(()=>{this.opacityControler.setIsActive(!1),this.rotateCenter=null,this.fadeOut()}))}fadeOut(){let e=setInterval((()=>{if(this.opacityControler){if(!this.opacityControler.getIsActive()){this.opacityControler.resetLastRecordTime(),this.opacityControler.decrement();let t=this.opacityControler.getPercentage();this.setOpacity(t),0===t&&clearInterval(e)}}else clearInterval(e)}),25)}calcRotatingCenter(){if(this.rotateCenter)return this.rotateCenter;let e=this.viewer.getViewer().cameraControl.calculatePivot(CLOUD.EditorConfig.RotatePivotMode,this.startPoint);if(!e)return null;let t=this.viewer.sceneToWorld(e),i=this.viewer.worldToClient(t);return i.x-=this.rotateCenterSize[0]/2,i.y-=this.rotateCenterSize[1]/2,this.rotateCenter=i,i}getRotateCenterHtml(){return`<svg id="${this.rotateCenterId}" width="26px" height="26px" version="1.1" transform="translate(150,50)"><defs><path d="M13,0 L13.0010997,2.04948449 C17.7249658,2.51902358 21.481539,6.27589662 21.9506147,10.9998991 L24,11 L24,13 L21.9505155,13.0010997 C21.4810095,17.7246329 17.7246329,21.4810095 13.0010997,21.9505155 L13,24 L11,24 L10.9998991,21.9506147 C6.27589662,21.481539 2.51902358,17.7249658 2.04948449,13.0010997 L0,13 L0,11 L2.04938526,10.9998991 C2.51849404,6.27556368 6.27556368,2.51849404 10.9998991,2.04938526 L11,0 L13,0 Z M12,4 C7.581722,4 4,7.581722 4,12 C4,16.418278 7.581722,20 12,20 C16.418278,20 20,16.418278 20,12 C20,7.581722 16.418278,4 12,4 Z" id="path-1"></path><filter x="-6.2%" y="-6.2%" width="112.5%" height="112.5%" filterUnits="objectBoundingBox" id="filter-2"><feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset><feGaussianBlur stdDeviation="0.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur><feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix></filter><circle id="path-3" cx="12" cy="12" r="5"></circle><filter x="-30.0%" y="-30.0%" width="160.0%" height="160.0%" filterUnits="objectBoundingBox" id="filter-4"><feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur><feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"></feComposite><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix></filter></defs><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g fill-rule="nonzero"><use fill="black" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"></use><use fill-opacity="0.7" fill="#FFFFFF" xlink:href="#path-1"></use></g><g><use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-3"></use><circle stroke="#FFFFFF" stroke-width="1" stroke-linejoin="square" fill="#32D3A6" fill-rule="evenodd" cx="12" cy="12" r="4.5"></circle></g></g></svg>`}translate(e,t){let i=document.getElementById(this.rotateCenterId);!i||isNaN(e)||isNaN(t)||i.setAttribute("transform",`translate(${e},${t})`)}setOpacity(e){let t=document.getElementById(this.rotateCenterId);t&&(t.style.opacity=e)}}class N{constructor(){this.thresholdTimes=200,this.incrementTimes=0,this.lastRecordTime=null,this.isActive=!1}increment(){this.lastRecordTime?(this.incrementTimes+=performance.now()-this.lastRecordTime,this.lastRecordTime=performance.now(),this.incrementTimes>this.thresholdTimes&&(this.incrementTimes=this.thresholdTimes)):this.lastRecordTime=performance.now()}decrement(){this.incrementTimes-=25,this.incrementTimes<0&&(this.incrementTimes=0)}getIsActive(){return this.isActive}setIsActive(e){this.isActive=e}resetLastRecordTime(){this.lastRecordTime=null}getPercentage(){return this.incrementTimes/this.thresholdTimes}}class G{constructor(e){this.viewer=e,this.unitMap={mm:"Millimeter",cm:"Centimeter",m:"Meter",km:"Kilometer",Millimeter:"Millimeter",Centimeter:"Centimeter",Meter:"Meter",Kilometer:"Kilometer"},this.unitTransMultiplyingMap={"Millimeter-Millimeter":1,"Millimeter-Centimeter":.1,"Millimeter-Meter":.001,"Millimeter-Kilometer":1e-7,"Centimeter-Millimeter":10,"Centimeter-Centimeter":1,"Centimeter-Meter":.01,"Centimeter-Kilometer":1e-6,"Meter-Millimeter":1e3,"Meter-Centimeter":100,"Meter-Meter":1,"Meter-Kilometer":.001,"Kilometer-Millimeter":1e6,"Kilometer-Centimeter":1e5,"Kilometer-Meter":1e3,"Kilometer-Kilometer":1}}getDataType(e){return Object.prototype.toString.call(e).slice(8,-1)}excute(e,t,i,n,o=!0){if(!e||!t||!i)return e;if(t=this.unitMap[t],i=this.unitMap[i],t===i)return e;o&&(e=JSON.parse(JSON.stringify(e)));const s=this.getDataType(e),r=this.unitTransMultiplyingMap[`${t}-${i}`];if(!n||n&&0===n.length)if("Array"===s)for(let o=0;o<e.length;o++)e[o]=this.excute(e[o],t,i,n,!1);else"String"!==s&&"Number"!==s||(e="String"===s?e*r+"":e*r);else if("Object"===s)Object.keys(e).forEach((o=>{let s=e[o];const a=this.getDataType(s);if(n.includes(o))if("String"!==a&&"Number"!==a||!n.includes(o)){if("Array"===a)if("in"===o||"out"===o)e[o]=this.trans4Array(e[o],t,i);else for(let s=0;s<e[o].length;s++){let a=this.getDataType(e[o][s]);e[o][s]="String"===a||"Number"===a?"String"===a?e[o][s]*r+"":e[o][s]*r:this.excute(e[o][s],t,i,n,!1)}}else e[o]="linkTransform"===o?e[o]?this.trans4LinkTransform(e[o],t,i):e[o]:"String"===a?s*r+"":s*r;else this.excute(e[o],t,i,n,!1)}));else if("Array"===s)for(let o=0;o<e.length;o++)e[o]=this.excute(e[o],t,i,n,!1);return e}translate(e,t,i=!0){const n=this.getGlobalUnit(),o=this.isBimtilesAsset()?"m":this.getDefaultUnit();return this.excute(e,n,o,t,i)}revertTranslate(e,t,i=!0){const n=this.getGlobalUnit(),o=this.isBimtilesAsset()?"m":this.getDefaultUnit();return this.excute(e,o,n,t,i)}translateVector(e,t=["x","y","z"],i=!0){if(!e)return e;const n=this.getGlobalUnit(),o=this.isBimtilesAsset()?"m":this.getDefaultUnit();return e=this.excute(e,n,o,t,i),new THREE.Vector3(...Object.values(e))}revertVector(e,t=["x","y","z"],i=!0){if(!e)return e;const n=this.getGlobalUnit(),o=this.isBimtilesAsset()?"m":this.getDefaultUnit();return e=this.excute(e,o,n,t,i),new THREE.Vector3(...Object.values(e))}translateBBox(e){e=this.translate(e,["x","y","z"]);let t=new THREE.Vector3(e.min.x,e.min.y,e.min.z),i=new THREE.Vector3(e.max.x,e.max.y,e.max.z);return(new THREE.Box3).setFromPoints([t,i])}revertBBox(e){e=this.revertTranslate(e,["x","y","z"]);let t=new THREE.Vector3(e.min.x,e.min.y,e.min.z),i=new THREE.Vector3(e.max.x,e.max.y,e.max.z);return(new THREE.Box3).setFromPoints([t,i])}translateBBox2(e){e=this.translate(e,["x","y"]);let t=new THREE.Vector3(e.min.x,e.min.y),i=new THREE.Vector3(e.max.x,e.max.y);return(new THREE.Box2).setFromPoints([t,i])}revertBBox2(e){e=this.revertTranslate(e,["x","y"]);let t=new THREE.Vector3(e.min.x,e.min.y),i=new THREE.Vector3(e.max.x,e.max.y);return(new THREE.Box2).setFromPoints([t,i])}trans4LinkTransform(e,t,i){const n=this.unitTransMultiplyingMap[`${t}-${i}`];if(1===n)return e;let o=JSON.parse(e);return"Array"===this.getDataType(o)&&16===o.length&&(o[12]*=n,o[13]*=n,o[14]*=n),JSON.stringify(o)}trans4Array(e,t,i){const n=this.unitTransMultiplyingMap[`${t}-${i}`];if(1===n)return e;for(let t=0;t<e.length;t++){let i=e[t];for(let e=0;e<i.length;e++)i[e]=i[e]*n}return e}getGlobalUnit(){return this.viewer instanceof Glodon.Bimface.Viewer.ViewerGIS?"m":this.unitMap[this.viewer._opt.globalUnit]||this.unitMap[this.viewer.getUnit()]}getDefaultUnit(){return this.viewer._manifest&&this.viewer._manifest.Metadata&&this.viewer._manifest.Metadata.Unit||("bimtiles"===this.viewer._defaultModelType?"m":"mm")}isBimtilesAsset(){return this.viewer.getViewer().modelManager.isBimtilesAsset()}getEngineUnit(){return this.isBimtilesAsset()?"m":this.getDefaultUnit()}translateToMm(e){const t=this.getGlobalUnit();return e*this.unitTransMultiplyingMap[`${t}-Millimeter`]}translateToIncomeUnit(e){const t=this.getGlobalUnit();return e*this.unitTransMultiplyingMap[`Millimeter-${t}`]}translateMToIncomeUnit(e){const t=this.getGlobalUnit();return e*this.unitTransMultiplyingMap[`Meter-${t}`]}}class j{constructor(e,t){this.viewer=e,this.cloudViewer=t,this.globalUnitUtil=this.viewer.globalUnitUtil}rotateOnBasePoint4ExtCom(e,t,i,n){t=this.globalUnitUtil.translateVector(t),this.viewer.externalComponentManager.rotateOnBasePoint(e,t,i,n)}getBoundingBoxById4ExtCom(e){let t=this.viewer.externalComponentManager.getBoundingBoxById(e),i=this.globalUnitUtil.revertVector(t.min),n=this.globalUnitUtil.revertVector(t.max);return(new THREE.Box3).setFromPoints([i,n])}getBoundingBoxWorld(){let e=this.cloudViewer.getBoundingBoxWorld(),t=this.globalUnitUtil.revertVector(e.min),i=this.globalUnitUtil.revertVector(e.max);return(new THREE.Box3).setFromPoints([t,i])}setFloorInfos(e,t){this.cloudViewer.setFloorInfos(this.globalUnitUtil.translate(e,["x","y","z","elevation"]),t)}getComponentsByRaycaster(e,t,i){e=this.globalUnitUtil.translateVector(e);let n=this.cloudViewer.getComponentsByRaycaster(e,t,i);return n.forEach((e=>{e.position=this.globalUnitUtil.revertVector(e.position),e.distance=this.globalUnitUtil.revertTranslate(e.distance)})),n}getRotationCenter(){return this.globalUnitUtil.revertVector(this.cloudViewer.getRotationCenter())}calculateMinDistance(e,t){var i=this.cloudViewer.calculateMinDistance(e,t);return-1!==i&&i.minDistance>=0&&(i.start=this.globalUnitUtil.revertVector(i.start),i.end=this.globalUnitUtil.revertVector(i.end),i.minDistance=this.globalUnitUtil.revertTranslate(i.minDistance)),i}pickByPoint(e){var t=this.cloudViewer.pickByPoint(e);if(t){if(t.worldBoundingBox){let e=this.globalUnitUtil.revertVector(t.worldBoundingBox.min),i=this.globalUnitUtil.revertVector(t.worldBoundingBox.max);t.worldBoundingBox=(new THREE.Box3).setFromPoints([e,i])}t.worldPosition&&(t.worldPosition=this.globalUnitUtil.revertVector(t.worldPosition))}return t}getBoundingBoxByIds(e,t){let i=this.cloudViewer.getBoundingBoxByIds(e,t),n=this.globalUnitUtil.revertVector(i.min),o=this.globalUnitUtil.revertVector(i.max);return(new THREE.Box3).setFromPoints([n,o])}zoomToBBox(e,t,i,n,o=1e3,s){e=this.globalUnitUtil.translate(e,["x","y","z"]),this.cloudViewer.zoomToBBox(e,t,i,n,o,s)}worldToDrawing(e){return e=this.globalUnitUtil.translateVector(e),this.cloudViewer.worldToDrawing(e)}drawingToWorld(e){return this.globalUnitUtil.revertVector(this.cloudViewer.drawingToWorld(e))}worldToCanvas(e){return e=this.globalUnitUtil.translateVector(e),this.cloudViewer.worldToCanvas(e)}canvasToWorld(e){return this.globalUnitUtil.revertVector(this.cloudViewer.canvasToWorld(e))}isInViewFrustum(e){return this.cloudViewer.insideCamera(this.globalUnitUtil.translate(e,["x","y","z"]))}addPlane(e,t,i,n){this.cloudViewer.addPlane.apply(viewer,[this.globalUnitUtil.translate(e,["x","y","z"]),this.globalUnitUtil.translate(t,["x","y","z"]),i,n])}worldPointsToClient(e,t){return this.cloudViewer.worldPointsToClient(this.globalUnitUtil.translate(e,["x","y","z"]),this.globalUnitUtil.translate(t,["x","y","z"]))}getObjectsInBox(e){return this.cloudViewer.getObjectsInBox(this.globalUnitUtil.translate(e,["x","y","z"]))}isBimtilesAsset(){return this.cloudViewer.modelManager.isBimtilesAsset()}}!function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Common");t.Console=class{constructor(){this.consoleType="log",this._enable=!0}formatData(e){return"."!==(e=e.toString())[e.length-1]&&(e+="."),e}setConsoleType(e){["log","warn","error","info"].indexOf(e)>=0&&(this.consoleType=e)}warn(e){this._enable&&console[this.consoleType](`[BIMFACE WARN]: ${this.formatData(e)}`)}info(e){this._enable&&console[this.consoleType](`[BIMFACE INFO]: ${this.formatData(e)}`)}error(e){this._enable&&console[this.consoleType](`[BIMFACE ERROR]: ${this.formatData(e)}`)}obsolete(e,t,i=!0){if(!this._enable)return;const n=e=>(")"!==(e=e.toString())[e.length-1]&&(e+="()"),e);i&&(e=n(e),t=n(t));const o=`${e} is obsolete, please use ${t} instead.`;this.setConsoleType("warn"),this.warn(o)}updateDataSource(e){this._enable&&console.error(`[BIMFACE ERROR]:${e} is not compatible with the data source. Please upgrade the data source and try again.`)}open(){this._enable=!0,this.info("Console opened")}close(){this.info("Console closed"),this._enable=!1}}}(),function(){let t=Object.freeze({ViewAdded:"ViewAdded",ViewLoading:"ViewLoading",Rendered:"Rendered",PureRender:"PureRender",CameraPositionChanged:"CameraPositionChanged",ComponentsSelectionChanged:"ComponentsSelectionChanged",ComponentsHoverChanged:"ComponentsHoverChanged",SelectionChanged:"SelectionChanged",SelectionChangedInModel:"SelectionChangedInModel",MouseClicked:"MouseClicked",MouseDragged:"MouseDragged",MouseDoubleClicked:"MouseDoubleClicked",ContextMenu:"ContextMenu",RectSelection:"RectSelection",Error:"Error",AddView:"AddView",RemoveView:"RemoveView",FamilyTypeChanged:"FamilyTypeChanged",MissingDrawingElement:"MissingDrawingElement",ToolbarHomeClick:"ToolbarHomeClick",DemandLoaded:"DemandLoaded",DemandLoading:"DemandLoading",DemandLoadStart:"DemandLoadStart",ButtonOnToolbarClicked:"ButtonOnToolbarClicked",AxisGridHover:"AxisGridHover",ModelExplosion:"ModelExplosion",FloorExplosion:"FloorExplosion",Hover:"Hover",MouseMove:"MouseMove",ViewChanged:"ViewChanged",ModelAdded:"ModelAdded",ModelTransformed:"ModelTransformed",ExternalObjectTransformed:"ExternalObjectTransformed",ZoomEnd:"ZoomEnd",Initialized:"Initialized",CurrentViewLoading:"CurrentViewLoading",ViewLoaded:"ViewLoaded",ModelVisibleChanged:"ModelVisibleChanged",Tap:"Tap",LongTap:"LongTap",Resized:"Resized"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").Viewer3DEvent=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").Viewer3DConfig=function(t){let i=e.Bimface.Viewer.OrbitButton,n=e.Bimface.Viewer.ViewOption,o=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),s="Local"==BimfaceLoaderConfig.dataEnvType?`${BimfaceLoaderConfig.staticHost}Glodon/bimface/resources`:`${BimfaceLoaderConfig.staticHost}/../resources`,r={domElement:null,APIHost:g.APIHost,resourceHost:g.resourceHost,staticResourcesHost:s,securityApi:g.securityApi,useCustomResources:g.useCustomResources,initialViewOption:n.Home,homeViewOption:n.Home,enableViewHouse:!0,enableReplaceMaterial:!1,enableSplitComponent:!1,enableExplosion:!1,loadOnDemand:!0,minimumFPS:15,enableOrbit:!0,orbitButton:i.Left,suffix:".gz",loading:!0,MaxMemeorySizeToFullRender:o?1500:500,enableToggleContextMenuDisplay:!0,enableHover:!1,enableMouseMovePick:!1,enableBorderLine:!0,enableWireframe:!0,wireframeColor:null,borderLineVisibility:null,exposure:0,backgroundColor:[{color:new e.Web.Graphics.Color(246,250,255,1),stop:"10%"},{color:new e.Web.Graphics.Color(214,224,235,1),stop:"70%"}],enableIBLBackground:!1,enableSkyBox:!1,enableConstraintZoom:!0,enableLogarithmicDepthBuffer:!1,loadIBLScene:{IBLSceneOption:"",withBackground:!1},enableShortcutKey:!0,renderMode:"auto",enableStorage:!1,globalUnit:void 0,memoryThreshold:void 0,enableRealisticMiniMap:!1,walkRotationSpeed:o?1:.5,enableCoordinateSystem:!1,avatar:e.Bimface.Viewer.AvatarOption.OfficeMale,avatarHeight:1.9,enableSSAO:!0,enableCSMShadow:!0,enableDoubleClickZoom:!0,visualization:{active:!0,mode:"Render",option:{}}};return Object.assign({},r,t)},function(){let t=Object.freeze({HideOthers:"HideOthers",MakeOthersTranslucent:"MakeOthersTranslucent"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").IsolateOption=t}(),function(){let t=Object.freeze({Home:"Home",Top:"Top",Bottom:"Bottom",North:"North",South:"South",West:"West",East:"East",SouthEast:"SouthEast",SouthWest:"SouthWest",NorthEast:"NorthEast",NorthWest:"NorthWest",NorthEastIsometricTop:"NorthEastIsometricTop",NorthWestIsometricTop:"NorthWestIsometricTop",SouthEastIsometricTop:"SouthEastIsometricTop",SouthWestIsometricTop:"SouthWestIsometricTop",NorthEastIsometricBottom:"NorthEastIsometricBottom",NorthWestIsometricBottom:"NorthWestIsometricBottom",SouthEastIsometricBottom:"SouthEastIsometricBottom",SouthWestIsometricBottom:"SouthWestIsometricBottom",NorthTop:"NorthTop",SouthTop:"SouthTop",WestTop:"WestTop",EastTop:"EastTop",NorthBottom:"NorthBottom",SouthBottom:"SouthBottom",WestBottom:"WestBottom",EastBottom:"EastBottom"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewOption=t}(),function(){let t=Object.freeze({Red:"Red",Yellow:"Yellow",Green:"Green",Blue:"Blue",Black:"Black"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ColorOption=t}(),function(){let t=Object.freeze({Fly:"Fly",Orbit:"Orbit",Select:"Select",Zoom:"Zoom",OrbitWithModelCenter:"OrbitWithModelCenter",PickWithRect:"PickWithRect",ZoomWithRect:"ZoomWithRect",Walk:"Walk",ThirdPerson:"ThirdPerson",ThirdPersonRun:"ThirdPersonRun"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").NavigationMode3D=t}(),function(){let t=Object.freeze({ConstructionWorker:"ConstructionWorker",OfficeMale:"OfficeMale",personTypeMap:{OfficeMale:0,ConstructionWorker:1}});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").AvatarOption=t}(),function(){let t=Object.freeze({Translucent:"Translucent",Opaque:"Opaque"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").OpacityOption=t}(),function(){let t=Object.freeze({Left:"Left",Right:"Right"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").OrbitButton=t}(),function(){let t=Object.freeze({X:"X",Y:"Y",Z:"Z"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").AxisOption=t}(),function(){let t=Object.freeze({Default:"Default",Rotate:"Rotate"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").SectionBoxMode=t}(),function(){let t=Object.freeze({Up:"Up",Down:"Down",Left:"Left",Right:"Right"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").Direction=t}(),function(){let t=Object.freeze({Gray:"Gray",HarborSunRise:"HarborSunRise",ParkingLot:"ParkingLot",RiverSide:"RiverSide",Sunrise:"Sunrise",SunsetGrass:"SunsetGrass"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").IBLSceneOption=t}(),function(){let t=Object.freeze({Render:"Render",Performance:"Performance",White:"White"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").VisualizaionMode=t}(),function(){let t=Object.freeze({Phong:"Phong",IBL:"IBL"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").LightingMode=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").loadersConfig=function(){return{"3DS":{loaderName:"TDSLoader",loaderFiles:["TDSLoader.js"]},FBX:{loaderName:"FBXLoader",loaderFiles:["fflate.min.js","FBXLoader.js"]},OBJ:{loaderName:"OBJLoader",loaderFiles:["OBJLoader.js"]},MTL:{loaderName:"MTLLoader",loaderFiles:["MTLLoader.js"]}}},function(){var t="Bimface.Plugins.ExternalObject.ExternalObjectManager",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.HttpRequest,o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject");o.ExternalObjectManager=class{constructor(n){if(i.send(t,"bf_c_extObjMng_new"),n._plugins&&n._plugins.externalObjectManager)return n._plugins.externalObjectManager;n._plugins&&(n._plugins.externalObjectManager=this),this._viewer=n,n.externalComponentManager&&!n.externalComponentManager.isDestroyed()||(n.externalComponentManager=new CLOUD.ExternalComponentManager(n.getViewer()),n.externalComponentManager._objects={}),this._manager=n.externalComponentManager,this._objects=this._manager._objects,this.modelId="ExternalComponent";let o=new e.Web.Lang.EventManager;return this.getEventManager=function(){return o},this._sceneScale=n.globalUnitUtil.translateVector(new THREE.Vector3(1,1,1)),this._scaledIdMap={},this.urlMap={},n.externalObjectManager=this,this.enableLight=!1,this.console=new e.Web.Common.Console,P(this),this}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}addObject(e,n,o){return i.send(t,"bf_c_extObjMng_addObj"),console.warn("[BIMFACE WARN]: ExternalObjectManager.addObject(name, object, modelId) is obsolete, please use ExternalObjectManager.loadObject(option, successCallback, failureCallback) instead."),this._addObject(e,n,o)}_isBuildInGeometry(t){return t instanceof e.Bimface.Plugins.Geometry.SplineCurve||t instanceof e.Bimface.Plugins.Geometry.SpatialPlane||t instanceof e.Bimface.Plugins.Geometry.Plane||t instanceof e.Bimface.Plugins.Geometry.Pipe||t instanceof e.Bimface.Plugins.Geometry.Band||t instanceof e.Bimface.Plugins.Geometry.PlaneBufferGeometry}_addObject(t,i,n,o){if(i.viewer||(i.viewer=this._viewer),!this.getObjectIdByName(t)){if(!this.enableLight){let e=i.children.filter((e=>"AmbientLight"!==e.type));i.children=e}this._isBuildInGeometry(i)&&(i=i._rebuild?i._rebuild(this._viewer):i);var s=e.Web.Lang.Utility.UUID.createUUID();return this._manager.addNode(s,i),this._objects[s]=t,this._viewer.getViewer().render(),"Viewer3D"===this._viewer.getViewerType()&&this._manager.bindModel(s,n||i._modelId||this._viewer.getDefaultModel().modelId,o),this._isBuildInGeometry(i)||!1===i._externalNeedScale?this._scaledIdMap[s]=!1:(this.scale(s,this._sceneScale),this._scaledIdMap[s]=!0),s}console.warn(`[ExternalObjectManager.addObject] 已有名为 "${t}" 的ExternalObject,请更换名称后再执行ExternalObjectManager.addObject()`)}_isNameRepeated(e,t){const i=this.urlMap[e].optionList;for(const e of i)if(e.name===t)return!0;return!1}addObjectByUrl(e,t,i,n,o){console.warn("[BIMFACE WARN]: ExternalObjectManager.addObjectByUrl(name, objectUrl, callback, modelId) is obsolete, please use ExternalObjectManager.loadObject(option, successCallback, failureCallback) instead."),this.loadObject({name:e,url:{objectUrl:t.url,mtlUrl:t.mtlUrl},association:{modelId:n}},i,o)}loadObject(t,i,o){const s=t.name,r=t.url,a=r&&r.objectUrl;if(!s||!a&&!t.object)return console.warn("[BIMFACE WARN]: option.name and (option.url.objectUrl or option.object) must not be undefined"),void(o&&o());void 0!==t.enableLight&&(this.enableLight=t.enableLight);const l=t.association&&t.association.modelId,h=t.association&&t.association.objectId;let d=this;function c(){if(CLOUD.Utils.isDefined(t.objectData)){let e=d.getObjectIdByName(s);d.setObjectData(e,t.objectData)}i&&i()}if(CLOUD.Utils.isDefined(t.object)){const e=this._addObject(s,t.object,l,h);if(e)return c(),e;o&&o()}else if(CLOUD.Utils.isDefined(r)){if(this.urlMap[a]&&!0===this.urlMap[a].pending){this.urlMap[a].callbackList.push(c),o&&this.urlMap[a].errorCallbackList.push(o);const e={name:s,modelId:l,bindObjectId:h};if(this._isNameRepeated(a,s))return;return void this.urlMap[a].optionList.push(e)}if(this.urlMap[a]&&!1===this.urlMap[a].pending)return this.cloneWithModelId(this.urlMap[a].originId,s,l,h),void c();this.urlMap[a]={},this.urlMap[a].pending=!0,this.urlMap[a].callbackList=[],this.urlMap[a].callbackList.push(c),this.urlMap[a].errorCallbackList=[],o&&this.urlMap[a].errorCallbackList.push(o);const t={name:s,modelId:l,bindObjectId:h};this.urlMap[a].optionList=[t];new Promise(((t,i)=>{const o=window.BimfaceLoaderConfig.fullStaticHost,a=e.Bimface.Plugins.ExternalObject.loadersConfig();let d=[];for(let e in r){if(void 0===r[e])continue;let t=r[e].split(".").pop().toUpperCase(),i=a[t]&&a[t].loaderFiles;if(void 0===i)return console.warn("File format not supported, currently supported formats: 3DS, FBX, OBJ."),!1;i.forEach((e=>{d.push(`${o}/lib/loaders/${e}`)}))}n.getScripts(d,(()=>{const{objectUrl:e,mtlUrl:n}=r,o=e.split(".").pop().toUpperCase(),d=a[o].loaderName;let c=new THREE[d];if(void 0===n)c.load(e,(i=>{const n=this._addObject(s,i,l,h);this.urlMap[e].originId=n,this.urlMap[e].pending=!1,t()}),(()=>{}),(()=>{i()}));else{(new THREE.MTLLoader).load(n,(n=>{n.preload(),c.setMaterials(n),c.load(e,(i=>{const n=this._addObject(s,i,l,h);this.urlMap[e].originId=n,this.urlMap[e].pending=!1,t()}),(()=>{}),(()=>{i()}))}),(()=>{}),(()=>{i()}))}}))})).then((()=>{this.urlMap[a].callbackList.map(((e,t)=>{const{name:i,modelId:n,bindObjectId:o}=this.urlMap[a].optionList[t];this.cloneWithModelId(this.urlMap[a].originId,i,n,o),e()}))})).catch((()=>{for(let e of this.urlMap[a].errorCallbackList)e();this.urlMap[a]=null}))}}cloneWithModelId(e,t,i,n){let o=this.clone(e,t);"Viewer3D"===this._viewer.getViewerType()&&this._manager.bindModel(o,i||this._viewer.getDefaultModel().modelId,n)}getAssociatedInfo(e){return this._manager.getBindedInfo(e)}clone(t,i){if(!this._objects[t])return void console.warn(`[ExternalObjectManager.clone] 没有id为 "${t}" 的ExternalObject,先执行ExternalObjectManager.addObject()`);if(this.getObjectIdByName(i))return;const n=e.Web.Lang.Utility.UUID.createUUID();return this._manager.cloneNode(t,n),this._objects[n]=i,1==this._scaledIdMap[t]?(this.scale(n,this._sceneScale),this._scaledIdMap[n]=!0):this._scaledIdMap[n]=!1,n}getObjectIdByName(e){for(var t in this._objects)if(this._objects[t]===e)return t}overrideColor(e,n){i.send(t,"overrideColor");const o=this._viewer.getViewer().getFilter(),s={color:parseInt(n.getHEX(),16),opacity:n.getAlpha()};e.all?o.addToOverrideListByConditions([],s,this.modelId):(e.ids&&o.addToOverrideListByColor(e.ids,s,this.modelId),e.objectData&&o.addToOverrideListByConditions(e.objectData,s,this.modelId))}restoreColor(e){i.send(t,"restoreColor"),e.all?this._viewer.getViewer().getFilter().addToOverrideListByConditions([],null,this.modelId):(e.ids&&this._viewer.getViewer().getFilter().addToOverrideListByColor(e.ids,null,this.modelId),e.objectData&&this._viewer.getViewer().getFilter().addToOverrideListByConditions(e.objectData,null,this.modelId))}getAllObjectIds(){return Object.keys(this._objects)}removeById(e){if(this._objects[e]){this.clearRelationshipById(e),this.removeGlowEffectById([e]),this._manager.removeNodeById(e),delete this._objects[e];const t=this._getCloneOriginUrlById(e);void 0!==t&&delete this.urlMap[t],this._viewer.getViewer().render()}}removeByIds(e){this.removeGlowEffectById(e);for(var t=0;t<e.length;t++){const i=e[t];if(this.clearRelationshipById(i),!this._objects[i])continue;this._manager.removeNodeById(i),delete this._objects[i];const n=this._getCloneOriginUrlById(i);void 0!==n&&delete this.urlMap[n]}this._viewer.getViewer().render()}clear(){var e=Object.keys(this._objects);e.length>0&&this.removeGlowEffectById(e),this._manager.clearNodes(),this._objects={},this._manager._objects={},this.urlMap={},this.relationshipsMap=null,this._viewer.getViewer().render()}hide(e){if(!CLOUD.Utils.isDefined(e))return;const t=this._manager.getFilter();if(!CLOUD.Utils.isDefined(t))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return void t.hideAll();let i=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(t.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0!==i.length&&t.hideByIds(i)}show(e){if(!CLOUD.Utils.isDefined(e))return;const t=this._manager.getFilter();if(!CLOUD.Utils.isDefined(t))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return void t.showAll();let i=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(t.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0!==i.length&&t.showByIds(i)}select(e){let t=this._viewer.getViewer();if(!CLOUD.Utils.isDefined(e))return;const i=this._manager.getFilter();if(!CLOUD.Utils.isDefined(i))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return t.addToSelection(this.getAllObjectIds(),this.modelId),void t.render();let n=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),n=n.concat(i.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(n=n.concat(e.ids)),n=Array.from(new Set(n)),0!==n.length&&(t.addToSelection(n,this.modelId),t.render())}removeSelection(e){let t=this._viewer.getViewer();if(!CLOUD.Utils.isDefined(e))return;const i=this._manager.getFilter();if(!CLOUD.Utils.isDefined(i))return;if(CLOUD.Utils.isDefined(e.all)&&1==e.all)return t.clearSelection(),void t.render();let n=[];CLOUD.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),n=n.concat(i.getMatchIds(e.objectData))),CLOUD.Utils.isDefined(e.ids)&&(n=n.concat(e.ids)),n=Array.from(new Set(n)),0!==n.length&&(t.removeFromSelection(n,this.modelId),t.render())}convert(e,t){!1!==t&&(t=!0);const i=c.assertType(e,"obj")&&e.modelId?`${e.modelId}_${e.objectId}`:e;let n=this._viewer.getExternalObjectConverter().convertToExternalObject(i,e,t);return n._externalNeedScale=!1,n}_fireTransformedEvent(t){this.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ExternalObjectTransformed,t,this.getPosition(t)),this._viewer.getViewer().updateGlowEffect(this.modelId,t),this._viewer.updateSceneBoundingBox(!1)}translate(e,t){let i=new THREE.Vector3(t.x,t.y,t.z);i.multiply(new THREE.Vector3(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z));let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateTransform(e,i))),this._manager.setAccumulateTransform(e,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}_getMatrixWorld(e){return(new THREE.Matrix4).fromArray(this.getTransformation(e))}rotateOnBasePoint(e,t,i,n){t=this._viewer.globalUnitUtil.translateVector(t),i=new THREE.Vector3(i.x,i.y,i.z);const o=this.relationshipsMap&&this.relationshipsMap.get(e);let s,r,a;o&&o.father&&(s=this._getMatrixWorld(o.father),r=s.clone().invert());const l=this._getMatrixWorld(e);if(a=l.clone().invert(),s){this._manager.applyTransformMatrix(e,l.clone().multiply(r),!0);const n=this._getMatrixWorld(e).clone().invert();t.applyMatrix4(n),i=new THREE.Vector4(i.x,i.y,i.z,0).applyMatrix4(n),i=new THREE.Vector3(i.x,i.y,i.z).normalize()}if(this._manager.rotateOnBasePoint(e,t,i,n),s){const t=this._getMatrixWorld(e);this._manager.applyTransformMatrix(e,t.clone().multiply(s),!0)}((e,t,i)=>{let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>{const n=this._getMatrixWorld(e),o=i.clone().multiply(t.clone().multiply(n));this._manager.applyTransformMatrix(e,o,!0)}))})(e,a,this._getMatrixWorld(e)),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}scaleOnBasePoint(e,t,i){t=this._viewer.globalUnitUtil.translateVector(t),this._manager.scaleOnBasePoint(e,t,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}getBoundingBoxById(e){return this._viewer.globalUnitUtil.revertBBox(this._manager.getBoundingBoxById(e))}_getValid3dParam(e){if("[object Object]"===Object.prototype.toString.call(e)&&e.hasOwnProperty("x")&&e.hasOwnProperty("y")&&e.hasOwnProperty("z"))return new THREE.Vector3(e.x,e.y,e.z)}setPosition(e,t){var i=this._getValid3dParam(t);i&&(i.applyMatrix4((new THREE.Matrix4).makeScale(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z)),this._manager.setTransform(e,i,void 0,void 0,void 0,!0),this._viewer.getViewer().render(),this._fireTransformedEvent(e))}getPosition(e){var t=this._manager.getGroupTransform(e);if(t&&t.position){var i=t.position;return this._viewer.globalUnitUtil.revertTranslate({x:i.x,y:i.y,z:i.z},["x","y","z"])}}offset(e,t){var i=this._getValid3dParam(this._viewer.globalUnitUtil.translate(t,["x","y","z"]));if(!i)return;let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateOffset(e,i))),this._manager.setAccumulateOffset(e,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}offsetX(e,t){this.offset(e,{x:t,y:0,z:0})}offsetY(e,t){this.offset(e,{x:0,y:t,z:0})}offsetZ(e,t){this.offset(e,{x:0,y:0,z:t})}rotate(e,t){var i=this._getValid3dParam(t);if(!i)return;let n=this.getAllChildrenId(e);n&&n.length>0&&n.forEach((e=>this._manager.setAccumulateTransform(e,void 0,void 0,i))),this._manager.setAccumulateTransform(e,void 0,void 0,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}rotateX(e,t){this.rotate(e,{x:t,y:0,z:0})}rotateY(e,t){this.rotate(e,{x:0,y:t,z:0})}rotateZ(e,t){this.rotate(e,{x:0,y:0,z:t})}setRotationX(e,t,i){let n=new THREE.Vector3(1,0,0);this.rotateOnBasePoint(e,t,n,i)}setRotationY(e,t,i){let n=new THREE.Vector3(0,1,0);this.rotateOnBasePoint(e,t,n,i)}setRotationZ(e,t,i){let n=new THREE.Vector3(0,0,1);this.rotateOnBasePoint(e,t,n,i)}scale(e,t){var i=this._getValid3dParam(t);i&&0!==i.x&&0!==i.y&&0!==i.z&&(this._manager.setAccumulateTransform(e,void 0,i),this._viewer.getViewer().render(),this._fireTransformedEvent(e))}scaleX(e,t){this.scale(e,{x:t,y:1,z:1})}scaleY(e,t){this.scale(e,{x:1,y:t,z:1})}scaleZ(e,t){this.scale(e,{x:1,y:1,z:t})}getTransformation(e){if(!this._manager._hasObjectId(e))return;const[t]=this._manager.meshes[e];if(t){const i=t.matrix.clone();return 1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(1/this._sceneScale.x,1/this._sceneScale.y,1/this._sceneScale.z)),i.elements[12]*=1/this._sceneScale.x,i.elements[13]*=1/this._sceneScale.y,i.elements[14]*=1/this._sceneScale.z,c.limitTransformationDecimal(i.elements)}}setTransformation(e,t){if(!this._manager._hasObjectId(e))return;if(["[object Float32Array]","[object Array]"].indexOf(Object.prototype.toString.call(t))<0)return;const i=new THREE.Matrix4;i.fromArray(t),1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z)),i.elements[12]*=this._sceneScale.x,i.elements[13]*=this._sceneScale.y,i.elements[14]*=this._sceneScale.z,this._manager.applyTransformMatrix(e,i,!0),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}setGlowEffectById(n,o){i.send(t,"setGlowEffectById");var s=new THREE.Color("#11DAB7"),r="body",a=.3,l=3,h=!1;null!=o&&(null!=o.type&&(r=o.type),null!=o.color&&o.color instanceof e.Web.Graphics.Color&&(s=new THREE.Color(o.color.red/255,o.color.green/255,o.color.blue/255)),null!=o.intensity&&(a=o.intensity),null!=o.spread&&(l=o.spread),null!=o.isGis&&(h=o.isGis)),this._viewer.getViewer().setGlowEffectById(this.modelId,n,{color:s,type:r,intensity:a,spread:l,isGis:h}),this._viewer.render()}removeGlowEffectById(e){if(i.send(t,"removeGlowEffectById"),null==e||0==e.length)return void console.warn("没有发光效果被删除。");this._viewer.getViewer().removeGlowEffectById(this.modelId,e),this._viewer.render()}clearGlowEffect(){i.send(t,"clearGlowEffect"),this._viewer.getViewer().removeGlowEffectById(this.modelId),this._viewer.render()}getAnimations(e){return this._manager.getAnimations(e)}play(e,t){if(!this.isAnimatable(e))return void console.warn("there is no animation in the mesh");if(!c.assertType(t,"obj")){t={index:t||0}}const i=!1===t.loop?THREE.LoopOnce:THREE.LoopRepeat;this._manager.play(e,{...t,loop:i})}pause(e){this._manager.pause(e)}stop(e){this._manager.stop(e)}isAnimatable(e){return this._manager.isAnimation(e)}getObjectByName(e){const t=this.getAllObjects(),i=this.getObjectIdByName(e);return t.find((e=>e.name===i))}removeByName(e){let t=this.getObjectIdByName(e);this.removeById(t)}getAllObjects(){return this._manager.getAllMeshes()}setObjectData(e,t){if(Array.isArray(t)){let i={};t.forEach((e=>{i=Object.assign({},i,e)})),this._manager.setObjectData(e,i)}else this._manager.setObjectData(e,t)}getObjectData(e){return this._manager.getObjectData(e)}_getCloneOriginUrlById(e){for(const t in this.urlMap)if(this.urlMap[t].originId===e)return t}toLocalPosition(e,t){if(3===arguments.length){console.warn("[BIMFACE WARN]: ExternalObjectManager.toLocalPosition(id, worldPosition, worldVector) is obsolete, please use ExternalObjectManager.toLocalPosition(id, option) instead.");const t=arguments[1]&&this._viewer.globalUnitUtil.translate(arguments[1],["x","y","z"]),i=arguments[2]&&this._viewer.globalUnitUtil.translate(arguments[2],["x","y","z"]);if(!this._manager._hasObjectId(e))return;const n=this._manager.getTransform(e),o=(new THREE.Matrix4).compose(n.position,n.rotate,n.scale).clone().invert();let s,r;if(t){s=new THREE.Vector3(t.x,t.y,t.z).applyMatrix4(o).toArray()}if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(o),r=r.normalize().toArray()}return{localPosition:s,localVector:r}}let{worldPosition:i,worldVector:n}=t;if(i&&(i=this._viewer.globalUnitUtil.translate(i,["x","y","z"])),n&&(n=this._viewer.globalUnitUtil.translate(n,["x","y","z"])),!this._manager._hasObjectId(e))return;const o=this._manager.getTransform(e),s=(new THREE.Matrix4).compose(o.position,o.rotate,o.scale).clone().invert();let r,a;if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(s),r={x:r.x,y:r.y,z:r.z}}if(n){a=new THREE.Vector4(n.x,n.y,n.z,0).applyMatrix4(s),a.normalize(),a={x:a.x,y:a.y,z:a.z}}return{localPosition:r,localVector:a}}toWorldPosition(e,t){if(3===arguments.length){console.warn("[BIMFACE WARN]: ExternalObjectManager.toWorldPosition(id, localPosition, localVector) is obsolete, please use ExternalObjectManager.toWorldPosition(id, option) instead.");const t=arguments[1],i=arguments[2];if(!this._manager._hasObjectId(e))return;const n=this._manager.getTransform(e),o=(new THREE.Matrix4).compose(n.position,n.rotate,n.scale);let s,r;if(t){const e=new THREE.Vector3(t.x,t.y,t.z);s=this._viewer.globalUnitUtil.revertTranslate(e.applyMatrix4(o).toArray())}if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(o),r=r.normalize().toArray()}return{worldPosition:s,worldVector:r}}const{localPosition:i,localVector:n}=t;if(!this._manager._hasObjectId(e))return;const o=this._manager.getTransform(e),s=(new THREE.Matrix4).compose(o.position,o.rotate,o.scale);let r,a;if(i){r=new THREE.Vector3(i.x,i.y,i.z).applyMatrix4(s),r=this._viewer.globalUnitUtil.revertTranslate({x:r.x,y:r.y,z:r.z},["x","y","z"])}if(n){a=new THREE.Vector4(n.x,n.y,n.z,0).applyMatrix4(s),a.normalize(),a={x:a.x,y:a.y,z:a.z}}return{worldPosition:r,worldVector:a}}setHierarchy(e){return this.temporaryMap=new Map,this.isCorrectRelationships=!0,this.getTemporaryMap(null,e.id,e.children),this.isCorrectRelationships?this.relationshipsMap?this.checkLegal()?(this.combineMap(),!0):(this.console.warn("The hierarchical structure was wrong due to the duplication of objects in different hierarchies."),!1):(this.relationshipsMap=this.temporaryMap,!0):(this.console.warn("The hierarchical structure was wrong due to the duplication of objects in different hierarchies."),!1)}getTemporaryMap(e,t,i){if(!this.isCorrectRelationships)return;let n=[];for(let e=0;e<i.length;e++)if(n.push(i[e].id),i[e].children&&i[e].children.length>0)this.getTemporaryMap(t,i[e].id,i[e].children);else{if(this.temporaryMap.has(i[e].id))return void(this.isCorrectRelationships=!1);this.temporaryMap.set(i[e].id,{father:t,children:[]})}this.temporaryMap.has(t)?this.isCorrectRelationships=!1:this.temporaryMap.set(t,{father:e,children:n})}checkLegal(){let e=!0,t={};return this.relationshipsMap.forEach(((e,i)=>{t[i]=this.getAncestors(i)})),this.temporaryMap.forEach(((i,n)=>{let o=i.children;for(let i=0;i<o.length;i++)if(t[n]&&t[n].indexOf(o[i])>-1)return void(e=!1)})),e}getAncestors(e){let t=[],i=this.relationshipsMap.get(e).father;return i&&(t.push(i),t=[...t,...this.getAncestors(i)]),t}combineMap(){this.relationshipsMap&&this.temporaryMap&&this.temporaryMap.forEach(((e,t)=>{if(this.relationshipsMap.has(t)){let i=e.children;for(let e=0;e<i.length;e++)if(this.relationshipsMap.has(i[e]))if(this.relationshipsMap.get(t).children.indexOf(i[e])>-1);else{if(this.relationshipsMap.get(i[e]).father!==t){if(this.relationshipsMap.get(i[e]).father){let t=this.relationshipsMap.get(this.relationshipsMap.get(i[e]).father).children.indexOf(i[e]);this.relationshipsMap.get(this.relationshipsMap.get(i[e]).father).children.splice(t,1)}this.relationshipsMap.get(i[e]).father=t}this.relationshipsMap.get(t).children.push(i[e])}else this.relationshipsMap.get(t).children.push(i[e])}else{this.relationshipsMap.set(t,e);let i=e.children;for(let e=0;e<i.length;e++)if(this.relationshipsMap.has(i[e])&&this.relationshipsMap.get(i[e]).father!==t){if(this.relationshipsMap.get(i[e]).father){let t=this.relationshipsMap.get(this.relationshipsMap.get(i[e]).father).children.indexOf(i[e]);this.relationshipsMap.get(this.relationshipsMap.get(i[e]).father).children.splice(t,1)}this.relationshipsMap.get(i[e]).father=t}}}))}getAllChildrenId(e){if(!this.relationshipsMap)return[];let t=[];if(this.relationshipsMap.has(e)){let i=this.relationshipsMap.get(e).children;t=[...t,...i];for(let e=0;e<i.length;e++)this.relationshipsMap.get(i[e])&&this.relationshipsMap.get(i[e]).children.length>0&&(t=[...t,...this.getAllChildrenId(i[e])])}return t}clearAllHierarchy(){this.relationshipsMap.clear()}clearHierarchy(e,t){let i=this.relationshipsMap.get(e).children,n=new Set,o=new Set;t.forEach((e=>{-1===i.indexOf(e)?o.add(e):n.add(e)})),o.size>0&&this.console.warn(`The relationships associated with childrenIds "${[...o].join("、")}" were not cleared because the parent-child relationships were not established.`),[...n].forEach((t=>this.clearCurrentIdToAncestorRelationship(e,t)))}clearCurrentIdToAncestorRelationship(e,t){let i=this.relationshipsMap.get(t).father;if(i){let n=this.relationshipsMap.get(i).children.indexOf(t);this.relationshipsMap.get(i).children.splice(n,1),i!=e?this.clearCurrentIdToAncestorRelationship(e,i):0===this.relationshipsMap.get(i).children.length&&null===this.relationshipsMap.get(i).father&&this.relationshipsMap.delete(i)}this.relationshipsMap.get(t).father=null,0===this.relationshipsMap.get(t).children.length&&this.relationshipsMap.delete(t)}clearRelationshipById(e){if(!this.relationshipsMap)return;if(!this.relationshipsMap.has(e))return;let t=this.relationshipsMap.get(e).father;t&&this.clearHierarchy(t,[e]);let i=this.relationshipsMap.get(e).children;i&&i.length>0&&this.clearHierarchy(e,i)}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer");t.ExternalObjectManager=class{constructor(t){return new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(t)}}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=Object.freeze({Endpoint:"endpoint",Midpoint:"midpoint",Intersection:"intersection",Line:"line",Face:"face"});t.SnapObject=i}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer");t.SnapMode=class{constructor(){this.snapList={},this.snapConditions=[],this.snapCondition={}}setSnap2DList(e){this.snapList=e}getSnap2DList(){return this.snapList}setSnap3DList(e){this.snapList=e}getSnap3DList(){return this.snapList}setSnapConditions(e){this.snapConditions=e,this.snapCondition.objectData=e}getSnapConditions(){return this.snapConditions}setSnapList(e){this.snapList=e}setSnapCondition(e){this.snapCondition=e}getSnapCondition(){return this.snapCondition}}}();class z{constructor(e){this.viewer=e,this.console=e.console,this._cloudViewer=e.getViewer(),this._cloudCamera=this._cloudViewer.camera,this.globalUnitUtil=e.globalUnitUtil,P(this),this._editorConfig={NoZoom:CLOUD.EditorConfig.NoZoom,NoPan:CLOUD.EditorConfig.NoPan,NoRotate:CLOUD.EditorConfig.NoRotate}}destroy(){this._cloudCamera=null,this._cloudViewer=null,this.console=null,this.viewer=null,this._editorConfig=null}getStatus(){const e=this._cloudViewer.getCamera();let t=JSON.parse(e);return t=this.globalUnitUtil.revertTranslate(t,["far","near"]),t.position=this.viewer.globalUnitUtil.revertVector(t.position),t.target=this.viewer.globalUnitUtil.revertVector(t.target),t.coordinateSystem="world",t}setStatus(e,t){"object"==typeof e&&(e=JSON.stringify(e)),(e=this.globalUnitUtil.translate(JSON.parse(e),["far","near"])).position=this.globalUnitUtil.translateVector(e.position),e.target=this.globalUnitUtil.translateVector(e.target),this._cloudViewer.setCamera(e,!1,t),this._cloudViewer.render()}setCameraType(e,t){const i=this._cloudViewer;if("PerspectiveCamera"==e)null==t?t=45:t<10?t=10:t>120&&(t=120),this._cloudCamera.setFov(t),i.switchToCamera("persp");else if("OrthographicCamera"==e){if(CLOUD.GlobalData.EnableGisMap)return void this.console.warn("Can not use OrthographicCamera when EnableLogarithmicDepthBuffer is true");i.switchToCamera("orth")}this._cloudViewer.render()}getCurrentRange(){return this._cloudViewer.cameraControl.getCurrentRangeofCamera()}lockAxis(e,t){"Z"==e?t&&(t[0]>t[1]&&(t=[t[1],t[0]]),t[0]<0||t[1]>Math.PI)?this.console.warn("The value range of 'range' is [0, Math.PI]"):(this._cloudViewer.lockAxisZ(!0,t),this._cloudViewer.render()):this.console.warn("The API supports AxisOption.Z only for now.")}unlockAxis(e){"Z"===e?(this._cloudViewer.lockAxisZ(!1),this._cloudViewer.render()):this.console.warn("The API supports AxisOption.Z only for now.")}setMaximalRange(e){const t=this._cloudViewer.cameraControl;void 0!==e?"number"==typeof e?e<0?this.console.warn("The parameter must be greater than 0."):(t.setMaximalRangeofCamera(e),t.cameraWithinMaximumRange()||(this.console.info("The previous position of camera was beyond the CameraRange, so we reset it."),t.resetCameraToMaximumRange()),this._cloudViewer.render()):this.console.warn("The parameter is not a number."):this.console.warn("The parameter is undefined.")}setObjectOffset(e){if(!CLOUD.Utils.isDefined(e))return void this.console.warn("The parameter offset is undefined.");if("number"!=typeof e)return void this.console.warn("The parameter offset is not a number.");let t=e/1e3;this._cloudViewer.cameraControl.setObjectOffset(t),this._cloudViewer.render()}getObjectOffset(){return 1e3*this._cloudViewer.cameraControl.getObjectOffset()}setZoomSpeed(e){CLOUD.Utils.isDefined(e)?"number"==typeof e?(this._cloudViewer.setZoomSpeed(e),this._cloudViewer.render()):this.console.warn("The parameter zoomSpeed is not a number."):this.console.warn("The parameter zoomSpeed is undefined.")}getZoomSpeed(){return this._cloudViewer.getZoomSpeed()}setRotateSensitivity(e){CLOUD.Utils.isDefined(e)?"number"==typeof e?(this._cloudViewer.setRotateSpeed(e),this._cloudViewer.render()):this.console.warn("The parameter ratio is not a number."):this.console.warn("The parameter ratio is undefined.")}getRotateSensitivity(){return this._cloudViewer.getRotateSpeed()}enableRotate(e=!0){CLOUD.EditorConfig.NoRotate=!e,this._cloudViewer.render()}enablePan(e=!0){CLOUD.EditorConfig.NoPan=!e,this._cloudViewer.render()}enablePitch(e=!0){const t=!e;this._cloudViewer.lockAxisZ(t),this._cloudViewer.render()}enableZoom(e=!0){CLOUD.EditorConfig.NoZoom=!e,this._cloudViewer.render()}setCameraAnimation(t){if(this._animationOption&&this.clearCameraAnimation(),this._animationOption=t,!t.pathAnimation instanceof e.Bimface.Plugins.Animation.PathAnimation)return void this.console.warn("The parameter option.pathAnimation is not type of Glodon.Bimface.Plugins.Animation.PathAnimation.");let i=null==t.distance?5e3:t.distance,n=null==t.angle?0:t.angle;this._animationOption.distance=i,this._animationOption.angle=n,t.pathAnimation._setCameraAnimation(this._cloudCamera,this.viewer.globalUnitUtil.translate(i),n),this._editorConfig.NoZoom=CLOUD.EditorConfig.NoZoom,this._editorConfig.NoPan=CLOUD.EditorConfig.NoPan,this._editorConfig.NoRotate=CLOUD.EditorConfig.NoRotate,CLOUD.EditorConfig.NoZoom=!0,CLOUD.EditorConfig.NoPan=!0,CLOUD.EditorConfig.NoRotate=!0}getCameraAnimation(){return this._animationOption}clearCameraAnimation(){this._animationOption&&(this._animationOption.pathAnimation.camera=null,this._animationOption=null,CLOUD.EditorConfig.NoZoom=this._editorConfig.NoZoom,CLOUD.EditorConfig.NoPan=this._editorConfig.NoPan,CLOUD.EditorConfig.NoRotate=this._editorConfig.NoRotate)}zoomToBoundingBox(e,t,i,n){let o;if(arguments[0]&&arguments[0].boundingBox){if(!(e=arguments[0].boundingBox)||!e.min||!e.max)return;i=arguments[0].margin,n=arguments[0].duration,o=arguments[0].direction,void 0===i&&(i=.5),void 0===n&&(n=1e3),arguments[1]&&(t=arguments[1]);var s=[[e.min.x,e.min.y,e.min.z],[e.max.x,e.max.y,e.max.z]];this.viewer.viewerAdapter.zoomToBBox(CLOUD.Utils.computeBBox(s),i,void 0,"[object Function]"===Object.prototype.toString.call(t)?t:void 0,n,o)}else{if(1===arguments.length)e=arguments[0];else if(2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],arguments[1]>100?(i=1,n=arguments[1]):(i=arguments[1],n=1e3);else if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],t=arguments[1],i=1,n=1e3;else if(3===arguments.length){for(let e=0;e<arguments.length;e++){const o=arguments[e];"[object Function]"===Object.prototype.toString.call(o)?t=o:"[object Number]"===Object.prototype.toString.call(o)&&(o>100?n=o:i=o)}e=arguments[0],void 0===n&&(n=1e3),void 0===i&&(i=.5)}if(e&&e.min&&e.max){s=[[e.min.x,e.min.y,e.min.z],[e.max.x,e.max.y,e.max.z]];this.viewer.viewerAdapter.zoomToBBox(CLOUD.Utils.computeBBox(s),i,void 0,"[object Function]"===Object.prototype.toString.call(t)?t:void 0,n)}}}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Camera").Camera3D=z;class F{static getExternalObjectManager(e,t){return this.managerTypeMap.has(t)||this.managerTypeMap.set(t,new CLOUD.EffectComponentManager(e.getViewer(),t)),this.managerTypeMap.get(t)}static removeExternalObjectManager(e){if(!this.managerTypeMap.has(e))return;const t=this.managerTypeMap.get(e).getAllNodes();0===Object.keys(t).length&&this.managerTypeMap.delete(e)}static destroy(){for(const e of this.managerTypeMap.values())e.destroy();this.managerTypeMap.clear()}}var W;F.managerTypeMap=new Map,function(e){if("undefined"!=typeof module&&module.exports)return function(e){module.exports=e()};if("function"==typeof define&&define.amd)return define;if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")}()((function(){function e(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function t(e,t){var i,n,o=e.length;if(!o||!t)return!1;for(i=t.toLowerCase(),n=0;n<o;++n)if(i===e[n].toLowerCase())return!0;return!1}function i(e){for(var t in e)r.call(e,t)&&(e[t]=new RegExp(e[t],"i"))}function n(e,t){this.ua=function(e){return(e||"").substr(0,500)}(e),this._cache={},this.maxPhoneWidth=t||600}var o,s={mobileDetectRules:{phones:{iPhone:"\\biPhone\\b|\\biPod\\b",BlackBerry:"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+",HTC:"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel",Nexus:"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6",Dell:"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b",Motorola:"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052",Samsung:"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F",LG:"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710",Sony:"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533",Asus:"Asus.*Galaxy|PadFone.*Mobile",NokiaLumia:"Lumia [0-9]{3,4}",Micromax:"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b",Palm:"PalmSource|Palm",Vertu:"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature",Pantech:"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790",Fly:"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250",Wiko:"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM",iMobile:"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)",SimValley:"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b",Wolfgang:"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q",Alcatel:"Alcatel",Nintendo:"Nintendo (3DS|Switch)",Amoi:"Amoi",INQ:"INQ",OnePlus:"ONEPLUS",GenericPhone:"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},tablets:{iPad:"iPad|iPad.*Mobile",NexusTablet:"Android.*Nexus[\\s]+(7|9|10)",GoogleTablet:"Android.*Pixel C",SamsungTablet:"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V",Kindle:"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)",SurfaceTablet:"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)",HPTablet:"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10",AsusTablet:"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b",BlackBerryTablet:"PlayBook|RIM Tablet",HTCtablet:"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410",MotorolaTablet:"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617",NookTablet:"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2",AcerTablet:"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30",ToshibaTablet:"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO",LGTablet:"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b",FujitsuTablet:"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b",PrestigioTablet:"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002",LenovoTablet:"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X",DellTablet:"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7",YarvikTablet:"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b",MedionTablet:"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB",ArnovaTablet:"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2",IntensoTablet:"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004",IRUTablet:"M702pro",MegafonTablet:"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b",EbodaTablet:"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)",AllViewTablet:"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)",ArchosTablet:"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b",AinolTablet:"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark",NokiaLumiaTablet:"Lumia 2520",SonyTablet:"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712",PhilipsTablet:"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b",CubeTablet:"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT",CobyTablet:"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010",MIDTablet:"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10",MSITablet:"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b",SMiTTablet:"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)",RockChipTablet:"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A",FlyTablet:"IQ310|Fly Vision",bqTablet:"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus",HuaweiTablet:"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19",NecTablet:"\\bN-06D|\\bN-08D",PantechTablet:"Pantech.*P4100",BronchoTablet:"Broncho.*(N701|N708|N802|a710)",VersusTablet:"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b",ZyncTablet:"z1000|Z99 2G|z930|z990|z909|Z919|z900",PositivoTablet:"TB07STA|TB10STA|TB07FTA|TB10FTA",NabiTablet:"Android.*\\bNabi",KoboTablet:"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build",DanewTablet:"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b",TexetTablet:"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE",PlaystationTablet:"Playstation.*(Portable|Vita)",TrekstorTablet:"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab",PyleAudioTablet:"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b",AdvanTablet:"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ",DanyTechTablet:"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1",GalapadTablet:"Android.*\\bG1\\b(?!\\))",MicromaxTablet:"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b",KarbonnTablet:"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b",AllFineTablet:"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide",PROSCANTablet:"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b",YONESTablet:"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026",ChangJiaTablet:"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503",GUTablet:"TX-A1301|TX-M9002|Q702|kf026",PointOfViewTablet:"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10",OvermaxTablet:"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027",HCLTablet:"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync",DPSTablet:"DPS Dream 9|DPS Dual 7",VistureTablet:"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10",CrestaTablet:"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989",MediatekTablet:"\\bMT8125|MT8389|MT8135|MT8377\\b",ConcordeTablet:"Concorde([ ]+)?Tab|ConCorde ReadMan",GoCleverTablet:"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042",ModecomTablet:"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003",VoninoTablet:"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b",ECSTablet:"V07OT2|TM105A|S10OT1|TR10CS1",StorexTablet:"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab",VodafoneTablet:"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400",EssentielBTablet:"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2",RossMoorTablet:"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711",iMobileTablet:"i-mobile i-note",TolinoTablet:"tolino tab [0-9.]+|tolino shine",AudioSonicTablet:"\\bC-22Q|T7-QC|T-17B|T-17P\\b",AMPETablet:"Android.* A78 ",SkkTablet:"Android.* (SKYPAD|PHOENIX|CYCLOPS)",TecnoTablet:"TECNO P9|TECNO DP8D",JXDTablet:"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b",iJoyTablet:"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)",FX2Tablet:"FX2 PAD7|FX2 PAD10",XoroTablet:"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151",ViewsonicTablet:"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a",VerizonTablet:"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1",OdysTablet:"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10",CaptivaTablet:"CAPTIVA PAD",IconbitTablet:"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S",TeclastTablet:"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi",OndaTablet:"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b",JaytechTablet:"TPC-PA762",BlaupunktTablet:"Endeavour 800NG|Endeavour 1010",DigmaTablet:"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b",EvolioTablet:"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b",LavaTablet:"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b",AocTablet:"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712",MpmanTablet:"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010",CelkonTablet:"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b",WolderTablet:"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b",MediacomTablet:"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA",MiTablet:"\\bMI PAD\\b|\\bHM NOTE 1W\\b",NibiruTablet:"Nibiru M1|Nibiru Jupiter One",NexoTablet:"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI",LeaderTablet:"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100",UbislateTablet:"UbiSlate[\\s]?7C",PocketBookTablet:"Pocketbook",KocasoTablet:"\\b(TB-1207)\\b",HisenseTablet:"\\b(F5281|E2371)\\b",Hudl:"Hudl HT7S3|Hudl 2",TelstraTablet:"T-Hub2",GenericTablet:"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},oss:{AndroidOS:"Android",BlackBerryOS:"blackberry|\\bBB10\\b|rim tablet os",PalmOS:"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino",SymbianOS:"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b",WindowsMobileOS:"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;",WindowsPhoneOS:"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;",iOS:"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia",iPadOS:"CPU OS 13",MeeGoOS:"MeeGo",MaemoOS:"Maemo",JavaOS:"J2ME/|\\bMIDP\\b|\\bCLDC\\b",webOS:"webOS|hpwOS",badaOS:"\\bBada\\b",BREWOS:"BREW"},uas:{Chrome:"\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?",Dolfin:"\\bDolfin\\b",Opera:"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+",Skyfire:"Skyfire",Edge:"Mobile Safari/[.0-9]* Edge",IE:"IEMobile|MSIEMobile",Firefox:"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS",Bolt:"bolt",TeaShark:"teashark",Blazer:"Blazer",Safari:"Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari",WeChat:"\\bMicroMessenger\\b",UCBrowser:"UC.*Browser|UCWEB",baiduboxapp:"baiduboxapp",baidubrowser:"baidubrowser",DiigoBrowser:"DiigoBrowser",Mercury:"\\bMercury\\b",ObigoBrowser:"Obigo",NetFront:"NF-Browser",GenericBrowser:"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger",PaleMoon:"Android.*PaleMoon|Mobile.*PaleMoon"},props:{Mobile:"Mobile/[VER]",Build:"Build/[VER]",Version:"Version/[VER]",VendorID:"VendorID/[VER]",iPad:"iPad.*CPU[a-z ]+[VER]",iPhone:"iPhone.*CPU[a-z ]+[VER]",iPod:"iPod.*CPU[a-z ]+[VER]",Kindle:"Kindle/[VER]",Chrome:["Chrome/[VER]","CriOS/[VER]","CrMo/[VER]"],Coast:["Coast/[VER]"],Dolfin:"Dolfin/[VER]",Firefox:["Firefox/[VER]","FxiOS/[VER]"],Fennec:"Fennec/[VER]",Edge:"Edge/[VER]",IE:["IEMobile/[VER];","IEMobile [VER]","MSIE [VER];","Trident/[0-9.]+;.*rv:[VER]"],NetFront:"NetFront/[VER]",NokiaBrowser:"NokiaBrowser/[VER]",Opera:[" OPR/[VER]","Opera Mini/[VER]","Version/[VER]"],"Opera Mini":"Opera Mini/[VER]","Opera Mobi":"Version/[VER]",UCBrowser:["UCWEB[VER]","UC.*Browser/[VER]"],MQQBrowser:"MQQBrowser/[VER]",MicroMessenger:"MicroMessenger/[VER]",baiduboxapp:"baiduboxapp/[VER]",baidubrowser:"baidubrowser/[VER]",SamsungBrowser:"SamsungBrowser/[VER]",Iron:"Iron/[VER]",Safari:["Version/[VER]","Safari/[VER]"],Skyfire:"Skyfire/[VER]",Tizen:"Tizen/[VER]",Webkit:"webkit[ /][VER]",PaleMoon:"PaleMoon/[VER]",Gecko:"Gecko/[VER]",Trident:"Trident/[VER]",Presto:"Presto/[VER]",Goanna:"Goanna/[VER]",iOS:" \\bi?OS\\b [VER][ ;]{1}",Android:"Android [VER]",BlackBerry:["BlackBerry[\\w]+/[VER]","BlackBerry.*Version/[VER]","Version/[VER]"],BREW:"BREW [VER]",Java:"Java/[VER]","Windows Phone OS":["Windows Phone OS [VER]","Windows Phone [VER]"],"Windows Phone":"Windows Phone [VER]","Windows CE":"Windows CE/[VER]","Windows NT":"Windows NT [VER]",Symbian:["SymbianOS/[VER]","Symbian/[VER]"],webOS:["webOS/[VER]","hpwOS/[VER];"]},utils:{Bot:"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp",MobileBot:"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2",DesktopMode:"WPDesktop",TV:"SonyDTV|HbbTV",WebKit:"(webkit)[ /]([\\w.]+)",Console:"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b",Watch:"SM-V700"}},detectMobileBrowsers:{fullPattern:/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,shortPattern:/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,tabletPattern:/android|ipad|playbook|silk/i}},r=Object.prototype.hasOwnProperty;return s.FALLBACK_PHONE="UnknownPhone",s.FALLBACK_TABLET="UnknownTablet",s.FALLBACK_MOBILE="UnknownMobile",o="isArray"in Array?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},function(){var e,t,n,a,l,h,d=s.mobileDetectRules;for(e in d.props)if(r.call(d.props,e)){for(t=d.props[e],o(t)||(t=[t]),l=t.length,a=0;a<l;++a)(h=(n=t[a]).indexOf("[VER]"))>=0&&(n=n.substring(0,h)+"([\\w._\\+]+)"+n.substring(h+5)),t[a]=new RegExp(n,"i");d.props[e]=t}i(d.oss),i(d.phones),i(d.tablets),i(d.uas),i(d.utils),d.oss0={WindowsPhoneOS:d.oss.WindowsPhoneOS,WindowsMobileOS:d.oss.WindowsMobileOS}}(),s.findMatch=function(e,t){for(var i in e)if(r.call(e,i)&&e[i].test(t))return i;return null},s.findMatches=function(e,t){var i=[];for(var n in e)r.call(e,n)&&e[n].test(t)&&i.push(n);return i},s.getVersionStr=function(e,t){var i,n,o,a,l=s.mobileDetectRules.props;if(r.call(l,e))for(o=(i=l[e]).length,n=0;n<o;++n)if(null!==(a=i[n].exec(t)))return a[1];return null},s.getVersion=function(e,t){var i=s.getVersionStr(e,t);return i?s.prepareVersionNo(i):NaN},s.prepareVersionNo=function(e){var t;return 1===(t=e.split(/[a-z._ \/\-]/i)).length&&(e=t[0]),t.length>1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},s.isMobileFallback=function(e){return s.detectMobileBrowsers.fullPattern.test(e)||s.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},s.isTabletFallback=function(e){return s.detectMobileBrowsers.tabletPattern.test(e)},s.prepareDetectionCache=function(e,t,i){var o,r,a;if(e.mobile===W)return(r=s.findMatch(s.mobileDetectRules.tablets,t))?(e.mobile=e.tablet=r,void(e.phone=null)):(o=s.findMatch(s.mobileDetectRules.phones,t))?(e.mobile=e.phone=o,void(e.tablet=null)):void(s.isMobileFallback(t)?(a=n.isPhoneSized(i),a===W?(e.mobile=s.FALLBACK_MOBILE,e.tablet=e.phone=null):a?(e.mobile=e.phone=s.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=s.FALLBACK_TABLET,e.phone=null)):s.isTabletFallback(t)?(e.mobile=e.tablet=s.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null)},s.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},s.detectOS=function(e){return s.findMatch(s.mobileDetectRules.oss0,e)||s.findMatch(s.mobileDetectRules.oss,e)},s.getDeviceSmallerSide=function(){return window.screen.width<window.screen.height?window.screen.width:window.screen.height},n.prototype={constructor:n,mobile:function(){return s.prepareDetectionCache(this._cache,this.ua,this.maxPhoneWidth),this._cache.mobile},phone:function(){return s.prepareDetectionCache(this._cache,this.ua,this.maxPhoneWidth),this._cache.phone},tablet:function(){return s.prepareDetectionCache(this._cache,this.ua,this.maxPhoneWidth),this._cache.tablet},userAgent:function(){return this._cache.userAgent===W&&(this._cache.userAgent=s.findMatch(s.mobileDetectRules.uas,this.ua)),this._cache.userAgent},userAgents:function(){return this._cache.userAgents===W&&(this._cache.userAgents=s.findMatches(s.mobileDetectRules.uas,this.ua)),this._cache.userAgents},os:function(){return this._cache.os===W&&(this._cache.os=s.detectOS(this.ua)),this._cache.os},version:function(e){return s.getVersion(e,this.ua)},versionStr:function(e){return s.getVersionStr(e,this.ua)},is:function(i){return t(this.userAgents(),i)||e(i,this.os())||e(i,this.phone())||e(i,this.tablet())||t(s.findMatches(s.mobileDetectRules.utils,this.ua),i)},match:function(e){return e instanceof RegExp||(e=new RegExp(e,"i")),e.test(this.ua)},isPhoneSized:function(e){return n.isPhoneSized(e||this.maxPhoneWidth)},mobileGrade:function(){return this._cache.grade===W&&(this._cache.grade=s.mobileGrade(this)),this._cache.grade}},"undefined"!=typeof window&&window.screen?n.isPhoneSized=function(e){return e<0?W:s.getDeviceSmallerSide()<=e}:n.isPhoneSized=function(){},n._impl=s,n.version="1.4.4 2019-09-21",n}));class ${}$.loadThirdPartyByName=function(e,t){const i=Glodon.Web.Lang.Utility.HttpRequest,n=window.BimfaceLoaderConfig.fullStaticHost,o=$.libraryConfig(),s=[],r=o[e]&&o[e].loaderFiles;void 0!==r?(r.map((e=>{s.push(`${n}/lib/${e}`)})),i.getScripts(s,(()=>{t&&t()}))):console.warn("The thirdParty not found")},$.libraryConfig=function(){return{Video:{loaderName:"Video",loaderFiles:["video.min.js"]},clipper:{loaderName:"clipper",loaderFiles:["clipper.js"]},interactions:{loaderName:"interactions",loaderFiles:["interactions.js"]},html2canvas:{loaderName:"html2canvas",loaderFiles:["html2canvas.min.js"]}}};let X=new THREE.Vector3;!function(){var t="Glodon.Bimface.Viewer.Viewer3D",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),r=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),"Please call enableSectionBox before using this method."),a=e.Web.Lang.Utility.ClientHelper.isWebGLAvailable();const l=e.Web.Lang.Utility.DataUtil;let h=function(o){n.Viewer.call(this);let r=e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(this.viewerType="Viewer3D",this.emptyModelButtons=["Home","RectangleSelect","Setting","Information","FullScreen"],this.trackObj={},e.Bimface.Viewer.loadApp3DNum?e.Bimface.Viewer.loadApp3DNum++:e.Bimface.Viewer.loadApp3DNum=1,(e.Bimface.Viewer.loadAppGISNum||0)+e.Bimface.Viewer.loadApp3DNum>=2&&i.send("bf_userBehavior","loadMultApps"),a){this.initModeParams(o),this.visualization.active||(y.GlobalData.EnableForceForwardRendering=!0),r||(y.GlobalData.MOBILE_DEFAULT_MAX_LOD_BIM=void 0);let n=this;o.APIHost=o.APIHost.replace(/\/$/,""),o.resourceHost=o.resourceHost.replace(/\/$/,""),o.unit&&i.send(t,"bf_c_unit_new"),o.globalUnit&&i.send(t,"bf_c_globalUnit_new"),o.enableSSAO&&i.send("Glodon.Bimface.Viewer","Viewer3DConfig.enableSSAO"),!1===o.enableSSAO&&i.send("Glodon.Bimface.Viewer","Viewer3DConfig.enableSSAO_false"),o.enableCSMShadow&&i.send("Glodon.Bimface.Viewer","Viewer3DConfig.enableCSMShadow"),o.unit=o.globalUnit?o.globalUnit:o.unit,this.globalUnitUtil=new G(this),this._beforeInitialize(o),this._opt=o,this._opt.skyBoxType="CloudySky",this._opt.floorExplosion=!1,this._opt.enableBorderLine=!0===o.enableWireframe?o.enableBorderLine:o.enableWireframe,this._colorOverridedMap={},this._colorOverridedList=[],this._models={},this._manifest={},this._lastModelIndex=0,this._defaultModelType=void 0,this._defaultUnit=void 0,this._renderingMode=0,this.console=new e.Web.Common.Console,this._plugins={},this.enableStorage=o.enableStorage,this.enableStorage&&(this.storageManager=new y.Storage.StorageManager);const a={setupEarth:o.enableEarth,staticResourcesHost:o.staticResourcesHost,initialGeoCoordinates:o.initialGeoCoordinates,gisMode:!1,enableStorage:o.enableStorage,maxMemoryUsage:o.memoryThreshold};let p=new y.Viewer(a);switch(this.viewerAdapter=new j(this,p),p.globalUnitUtil=this.globalUnitUtil,p.viewerAdapter=this.viewerAdapter,this.customedHomeview=null,this.defaultHomeview=null,this.bViewHouseIsLoaded=o.enableViewHouse,this.bIsViewHouseVisible=!1,this.bIsCursorEnabled=!0,o.renderMode){case"fullVolume":this._renderingMode=1;break;case"incremental":this._renderingMode=2;break;default:this._renderingMode=0}let m=y.GlobalData;m.EnableLoadOnDemand=!0===o.loadOnDemand,m.Instance=!o.enableReplaceMaterial,m.EnableSplitComponent=o.enableSplitComponent,m.EnableExplosion=o.enableExplosion,m.EnableLogarithmicDepthBuffer=o.enableLogarithmicDepthBuffer,m.ConstraintZoom=o.enableConstraintZoom,m.BorderLineDelayLoaded=!1===o.enableBorderLine||!1===o.enableWireframe,m.PickingEffect=!1!==o.pickingEffect,m.Renderer=this._renderingMode,m.EnableLodDemDom=!0===o.enableLodDemDom,m.SceneUnit=o.unit,void 0!==o.enableInstanceSharedMesh&&(m.InstanceSharedMeshEnabled=o.enableInstanceSharedMesh),void 0!==o.instanceSharedMeshThreshold&&(m.InstanceSharedMeshThreshold=o.instanceSharedMeshThreshold),void 0!==o.instanceAsyncProcessing&&(m.InstanceAsyncProcessing=o.instanceAsyncProcessing),void 0!==o.instanceAsyncProcessingStep&&(m.InstanceAsyncProcessingStep=o.instanceAsyncProcessingStep),void 0!==o.BatchAsyncProcessingFrequency&&(m.BatchAsyncProcessingFrequency=o.BatchAsyncProcessingFrequency),e.Web.Lang.Utility.ClientHelper.getIsMac()&&e.Web.Lang.Utility.ClientHelper.getIsChrome()&&(m.ForcedUseWebgl1=!0),y.EditorConfig.NoRotate=!o.enableOrbit,this.enableShortcutKey(o.enableShortcutKey);var l=s.create("div","bf-view");o.domElement.appendChild(l),p.init(l,!1),this.view={},this.snap=null,this.bIsBringAxisGridsToFront=!1,this.bIsActiveAxisGridManager=!1,this.bIsEnableSelectionChanged=!0,this.mapCustomizedRoom={},this._effectMode=o.effectMode?o.effectMode:"performance",p.setDeviceMobile&&p.setDeviceMobile(!r),null!=p&&(p.cameraControl.enableLimitWorldScalar(!1),this.maximalRangeofCamera=p.cameraControl.getMaximalRangeofCamera()),this.getViewer=function(){return p},this.getDomElement=function(){return l},this.hookContextMenu(l),this.hookCloudViewerEvents(),this._config(o),this.setBackgroundColors(o.backgroundColor),this.camera3D=new z(this),this.resizeWindow=function(){n.resize()},window.addEventListener("resize",this.resizeWindow),this.getLightManager=function(){return this.lightManager},this.setNavigationMode(e.Bimface.Viewer.NavigationMode3D.PickWithRect),this.thirdPersonAvatar=e.Bimface.Viewer.AvatarOption[n._opt.avatar]||e.Bimface.Viewer.AvatarOption.OfficeMale,this.avatarHeight=n._opt.avatarHeight||1.9,this.isThirdPersonRun=!1,r?(console.log("client: desktop"),this.mouseRotating=new U(this)):console.log("client: mobile"),n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewAdded,(function(){n.setOrbitButton(n._opt.orbitButton);var o=new e.Bimface.Light.LightManagerConfig;if(o.viewer=n,n.lightManager=new e.Bimface.Light.LightManager(o),y.GlobalData.EnableShadowMap||n._opt.enableCSMShadow){const t=n.getLightManager().getCSMLight();t.setLightPreset(!0),t.enableShadow(!0);let i=n.getModels()[0];(i&&!i.isBimtilesModel()||e.Web.Lang.Utility.ClientHelper.getIsMac())&&(t.setLightPreset(!1),t.enableShadow(!1)),i&&i.isShadowDafault()&&t.enableAvoidShadowPlaneCutting(!0)}n._opt.enableSSAO;var s=n.getViewer(),r=s.getNumOfElements(),a=s.getNumOfTriangles();let l,h=n._data.modelType;l="singleMode"==h?"model":h,i.send(t,"ViewAdded"),window.bimfaceSdkVersion&&(i.send(t,"sdkVersion"),delete window.bimfaceSdkVersion);let d=n.getModels()[0];if(n.trackObj.eventId="加载",n.trackObj.loadModel="expert",n.trackObj.type=l,n.trackObj.elements=r,n.trackObj.triangles=a,n.trackObj.modelId=d._data.modelId,n.trackObj.fileSuffix=d._manifest.Metadata.FileType,"bimtiles"===n._defaultModelType&&"compareModel"!=d._data.modelType){let e=0,o=!1,s=!1,r="",a="",l=0,h=!0,d=[],c=()=>{h?(r=(new Date).getTime(),l=0,h=!1):++l,a=(new Date).getTime(),s?h=!0:requestAnimationFrame(c)};n.getViewer().registerEventListener(y.EVENTS.ON_EDITOR_BEGIN,(()=>{e>=3||(s=!1,o=!1,c())})),n.getViewer().registerEventListener(y.EVENTS.ON_EDITOR_ROTATING,(()=>{e>=3||(o=!0)})),n.getViewer().registerEventListener(y.EVENTS.ON_EDITOR_END,(()=>{if(!(e>=3)&&(s=!0,o)){let o=Math.round(l/(a-r)*1e3);d.push(o),e++,3==e&&(n.trackObj.averageFPS=Math.round((d[0]+d[1]+d[2])/3),n.trackObj.minimumFPS=Math.min(...d),i.send(t,"ViewAdded",n.trackObj),i.intervalAction())}}))}if(n.getModel().isBimtilesModel()&&!e.Web.Lang.Utility.ClientHelper.getIsMac()&&n.visualization.active){switch(n.visualization.mode){case e.Bimface.Viewer.VisualizaionMode.Render:n.setRenderMode();break;case e.Bimface.Viewer.VisualizaionMode.Performance:n.setPerformanceMode();break;case e.Bimface.Viewer.VisualizaionMode.White:n.setWhiteMode();break;default:n.setRenderMode()}n.enableWireframe(n.visualization.option.enableWireframe),n.enableSSAOEffect(n.visualization.option.enableSSAO),n.setExposureShift(n.visualization.option.exposure);let t=n.getLightManager().getCSMLight();if(t.setLightPreset(n.visualization.option.enableCSMShadow),t.enableShadow(n.visualization.option.enableCSMShadow),n.getViewer().IBLManager.enableIBL(!1),n.visualization.option.enableEnvMap&&n.visualization.option.envMapStyle){let t=new e.Bimface.Plugins.EnvMap.EnvMapManagerConfig;t.viewer=n,t.style=n.visualization.option.envMapStyle,n._envMapManager=new e.Bimface.Plugins.EnvMap.EnvMapManager(t)}n.setAutoExposure(n.visualization.option.enableAutoExposure,n.visualization.mode)}}));let f=(new Date).getTime();n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.Initialized,(()=>{n.trackObj.firstFrameLoadTime=(new Date).getTime()-this.loadTime||f}));let w=!0;n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewLoaded,(()=>{w&&(w=!1,n.trackObj.primaryViewLoadTime=(new Date).getTime()-this.loadTime||f,"bimtiles"===n._defaultModelType&&"compareModel"!=n.getModels()[0]._data.modelType&&(i.send(t,"ViewAdded",n.trackObj),i.intervalAction()))}));let v=window.performance||window.msPerformance||window.webkitPerformance;if(n.trackObj.id=e.Web.Lang.Utility.UUID.createUUID(),n.trackObj.createTime=e.Web.Lang.Utility.ClientHelper.formatTime(),n.trackObj.memoryFootprint=v.memory?v.memory.usedJSHeapSize:0,n.trackObj.browserVersion=e.Web.Lang.Utility.ClientHelper.getBrowserVersion(),n.trackObj.browserType=e.Web.Lang.Utility.ClientHelper.getBrowserType(),n.trackObj.deviceType=e.Web.Lang.Utility.ClientHelper.getDeviceType(),r)n.trackObj.systemVersion=e.Web.Lang.Utility.ClientHelper.getDesktopType().name,n.trackObj.systemType=e.Web.Lang.Utility.ClientHelper.getDesktopType().type;else{n.trackObj.screenWidth=window.screen.width+"px",n.trackObj.screenHeight=window.screen.height+"px";var h=navigator.userAgent,d=new MobileDetect(h),c=d.os(),u="";if("iOS"==c)c+=d.version(d.mobile()),u=d.mobile();else if("AndroidOS"==c){c=d.os()+d.version("Android");var g=h.split(";");for(let e=0;e<g.length;e++)if(g[e].indexOf("Build/")>=0){u=g[e].substring(0,g[e].indexOf("Build/"));break}}n.trackObj.osVersion=c,n.trackObj.modelName=u}}else this._loadNotSuportPromptPage(o.domElement);this.enableDoubleClickZoom(o.enableDoubleClickZoom)};o.Type.inheritPrototype(h,n.Viewer),h.prototype=Object.assign({},n.Viewer.prototype,{getIsMobileNew:function(){return this.isMobileNew},hookContextMenu:function(t){var i,n,o,s=this,r=!0;this.onTouchstart=function(a){let l=a.touches[0];r=!1,i=[l.pageX,l.pageY],o&&clearTimeout(o),o=setTimeout((function(){if(!r){n=n||i;var o=t.getBoundingClientRect(),a={clientPosition:{x:n[0]-o.left,y:n[1]-o.top},containerBox:{width:o.width,height:o.height}};Math.abs(i[0]-n[0])<5&&Math.abs(i[1]-n[1])<5&&(s.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.LongTap,a),s._opt.enableToggleContextMenuDisplay&&s.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ContextMenu,a)),r=!0}}),1e3)},this.onTouchmove=function(e){let t=e.touches[0];n=[t.pageX,t.pageY]},this.onTouchend=function(){n=null,r=!0},t.addEventListener("touchstart",this.onTouchstart),t.addEventListener("touchend",this.onTouchend),t.addEventListener("touchmove",this.onTouchmove)},destroy:function(){i.send(t,"destroy"),this.mouseRotating&&(this.mouseRotating.destroy(),this.mouseRotating=null),this.lightManager&&(this.lightManager.destroy(),this.lightManager=null),this.globalUnitUtil=null,this.camera3D.destroy(),this.camera3D=null,this.getModels().forEach((e=>{e.destroy()})),this.getViewer().removeAllCallbacks(),this._viewHouse&&(this._viewHouse.destroy(),this._viewHouse=null),F.destroy(),this.getViewer().destroy(),window.removeEventListener("resize",this.resizeWindow),this.resizeWindow=null;var o=this.getDomElement();o&&(o.removeEventListener("mousedown",this.onMouseDown),o.removeEventListener("mouseup",this.onMouseUp),o.removeEventListener("touchstart",this.onTouchstart),o.removeEventListener("touchend",this.onTouchend),o.removeEventListener("touchmove",this.onTouchmove),this.removeMouseMotionEventListeners&&(this.removeMouseMotionEventListeners(),this.removeMouseMotionEventListeners=null),this.onMouseDown=null,this.onMouseUp=null,this.onTouchstart=null,this.onTouchend=null,this.onTouchmove=null),o.parentNode&&o.parentNode.removeChild(o),this.getDomElement=null,this.getLightManager=null,this.getViewer=null,this._opt=null,this._colorOverridedMap=null,this._colorOverridedList=null,this._data=null,this._models=null,this._defaultModel=null,this.customedHomeview=null,this.defaultHomeview=null,this.view=null,this.snap=null,this._manifest=null,this._plugins=null,this.console=null,this.storageManager=null,e.Bimface.Viewer.loadApp3DNum&&e.Bimface.Viewer.loadApp3DNum>0&&e.Bimface.Viewer.loadApp3DNum--,n.Viewer.prototype.destroy.call(this)},hookCloudViewerEvents:function(){let t=this,i=t._opt,n=this.getViewer(),o=this.getEventManager(),r=e.Bimface.Viewer.Viewer3DEvent,a=s.create("div","bf-loading"),l=s.create("div","bf-loading-gif"),h=s.create("div","bf-loading-progress"),d=!1,c=0,u=s.create("div","bf-rect-selcetion"),p=null;i.useCustomResources&&(l.style.backgroundImage=`url(${g.staticHost}/resources/custom/loading.gif)`);const m=2;let f=function(e){let t;const i="Component",n="ExternalComponent",o="Room",s="Map";switch(e){case y.PICKABLETYPE.ExternalComponent:t=n;break;case y.PICKABLETYPE.Room:t=o;break;case y.PICKABLETYPE.Map:t=s;break;default:t=i}return t};y.GlobalData.EnableDemolishByDClick=!0,h.innerText="0%",a.appendChild(l),a.appendChild(h),n.registerEventListener(y.EVENTS.ON_LOAD_START_NO_PROGRESS,(()=>{this._opt.loading&&(c++,a.parentElement||this._opt.domElement.appendChild(a),h.style.display="none")})),n.registerEventListener(y.EVENTS.ON_LOAD_START,(function(){i.loading&&(c++,i.domElement.appendChild(a))})),n.registerEventListener(y.EVENTS.ON_AXIS_GRID_HOVER,(function(e){o.fireEvent(r.AxisGridHover,e)})),n.registerEventListener(y.EVENTS.ON_EXPLOSION,(function(e){o.fireEvent(r.ModelExplosion,e)})),n.registerEventListener(y.EVENTS.ON_FLOOR_EXPLOSION,(function(e){if(void 0===t.floorData&&(t.floorData={}),t.floorData[e.modelId]=e.floorInfos,e.floorInfos&&e.floorInfos.length){let i=JSON.parse(JSON.stringify(e.floorInfos));i.map((e=>{e.boundingBox=t.globalUnitUtil.revertTranslate(e.boundingBox,["x","y","z"]),e.elevation=t.globalUnitUtil.revertTranslate(e.elevation),e.explodedHeight=t.globalUnitUtil.revertTranslate(e.explodedHeight),e.preExplodedHeight=t.globalUnitUtil.revertTranslate(e.preExplodedHeight)})),e.floorInfos=i}o.fireEvent(r.FloorExplosion,e)}));var w={Home:0,Top:1,Bottom:2,North:3,South:4,West:5,East:6,SouthEast:7,SouthWest:8,NorthEast:9,NorthWest:10};let v=!1;n.registerEventListener(y.EVENTS.ON_LOAD_COMPLETE,(function(o){var s=t._opt;i.enableViewHouse&&(t.showViewHouse(),i.enableCoordinateSystem&&t.enableCoordinateSystem(!0)),c--,i.loading&&0==c&&(h.innerText="0%",i.domElement.removeChild(a));var r=t.getInformation(),l=t.getModel()._manifest;let d=e.Web.Lang.Utility.ClientHelper.getIsDesktop();l.Metadata.Content&&"V3"==l.Metadata.Content.BimtilesVersion?t.enableWireframe(i.enableBorderLine):(!0===i.enableBorderLine||void 0===i.enableBorderLine?r.elements>8e4&&r.triangles>2e7?(t.enableWireframe(!1),t.setMinimumFPS(30)):(t.enableWireframe(!0),t.setMinimumFPS(8)):t.enableWireframe(i.enableBorderLine),d&&!y.GlobalData.IncrementRender||t.enableWireframe(!1)),t.setExposureShift(i.exposure),!d&&r.triangles>5e6&&(y.GlobalData.maxObjectNumInPool=2e3),!0===s.cancelHomeView||v||(n.setInitialView(w[s.initialViewOption]),n.setHomeView(w[s.homeViewOption])),v=!0,t.defaultHomeview=t.getCameraStatus();let u=t.getModel().isBimtilesModel()&&!e.Web.Lang.Utility.ClientHelper.getIsMac()&&t.visualization.active&&t.visualization.option.enableEnvMap;s.enableIBLBackground&&s.loadIBLScene.IBLSceneOption&&!u&&t.loadIBLScene(s.loadIBLScene.IBLSceneOption,s.loadIBLScene.withBackground),n.enableTextureMapping(!0),t.removeMouseMotionEventListeners=e.Web.Lang.Utility.MouseMotion.setCursor(t)})),n.registerEventListener(y.EVENTS.ON_LOAD_PROGRESS,(function(e){var t=e.progress,i=Math.round(t.loaded/t.total*100);t.progress=i,h.innerText=i+"%",o.fireEvent(r.ViewLoading,t)})),n.registerEventListener(y.EVENTS.ON_LOAD_EMPTY_SCENE,(function(){"bimtiles"==t._defaultModelType&&c--,i.loading&&0==c&&a.parentElement&&i.domElement.removeChild(a),o.fireEvent(r.Error,{code:"EmptyData",message:"this view is empty."})})),n.registerEventListener(y.EVENTS.ON_DEMAND_LOAD_START,(function(){i.loading&&(c++,i.domElement.appendChild(a)),o.fireEvent(r.DemandLoadStart)})),n.registerEventListener(y.EVENTS.ON_DEMAND_LOAD_PROGRESS,(function(e){var t=e.progress,i=Math.round(t.loaded/t.total*100);t.progress=i,h.innerText=i+"%",o.fireEvent(r.DemandLoading,t)})),n.registerEventListener(y.EVENTS.ON_DEMAND_LOAD_COMPLETE,(function(e){c--,i.loading&&0==c&&(h.innerText="0%",i.domElement.removeChild(a)),n.setInitialView(w[i.initialViewOption]),n.setHomeView(w[i.homeViewOption]),o.fireEvent(r.DemandLoaded,e.data)})),n.registerEventListener(y.EVENTS.ON_EDITOR_UPDATEUI,(function(e){!function(e,t){e.visible?("pickByRect"===t?e.dir?u.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px solid rgba(0,130,94,1)"}):u.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px dashed rgba(0,130,94,1)"}):u.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(136,136,136,0.2)",border:"solid #888888 1px"}),i.domElement.firstElementChild.appendChild(u),d=!0):(d&&(i.domElement.firstElementChild.removeChild(u),d=!1,o.fireEvent(r.RectSelection,{end:!0})),o.fireEvent(r.RectSelection,e))}(e.data,e.editor)})),n.registerEventListener(y.EVENTS.ON_CLICK_PICK,(function(i){i.intersectInfo&&(i.intersectInfo.worldBoundingBox=t.globalUnitUtil.revertBBox(i.intersectInfo.worldBoundingBox),i.intersectInfo.worldPosition=t.globalUnitUtil.revertVector(i.intersectInfo.worldPosition),i.intersectInfo.point=t.globalUnitUtil.revertVector(i.intersectInfo.point)),function(e){if(!(0==t.bIsEnableSelectionChanged||e.intersectInfo&&e.intersectInfo.objectType==y.PICKABLETYPE.Marker3d)){var i=null,n=null,s=e.doubleClick?2:1;if(n=e.event.button==m?"RightClick":e.doubleClick?"DoubleClick":"Click",e.intersectInfo){if(i={objectId:e.intersectInfo.selectedObjectId,modelId:e.intersectInfo.modelId,fileId:e.intersectInfo.fileId,elementId:e.intersectInfo.selectedObjectId,boundingBox:e.intersectInfo.worldBoundingBox,click:s,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:e.intersectInfo.worldPosition,clientPosition:e.canvasPos,eventType:n,objectType:f(e.intersectInfo.objectType)},e.intersectInfo.objectType==y.PICKABLETYPE.Room&&(i.boundaryPoints=e.intersectInfo.boundaryPoints),e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var a=e.intersectInfo.selectedObjectId.split(".");a.length>1&&(i.elementId=a[1],i.integrateId=i.fileId,i.fileId=a[0])}}else i={click:s,screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:n,objectType:""};if(e.event.altKey&&console.log(i),e.doubleClick)o.fireEvent(r.MouseDoubleClicked,i),o.fireEvent(r.ComponentsSelectionChanged,i);else{if(e.event.button===THREE.MOUSE.LEFT&&(o.fireEvent(r.ComponentsSelectionChanged,i),null!=t.snap)){const e=t.snap.context;let n=t.globalUnitUtil.revertVector(e.pickPoint),o=e.hoverPosition,s="Panel"===e.hoverObjectType?"Plane":e.hoverObjectType,r=o?{type:s,worldPosition:n,clientPosition:{x:o.x,y:o.y}}:{type:s,worldPosition:n};i.snapPoint=r}i.normal=e.intersectInfo?e.intersectInfo.normal:null,t.isMobileNew&&o.fireEvent(r.Tap,i),o.fireEvent(r.MouseClicked,i)}}}(i),function(i){if(t._opt.enableToggleContextMenuDisplay&&t.bIsEnableSelectionChanged){var n={};if(i.event.button==m){var o=t.getDomElement().getBoundingClientRect(),s={x:i.event.clientX-o.left,y:i.event.clientY-o.top},r={width:o.width,height:o.height};n.clientPosition=s,n.containerBox=r,n.objectType=i.intersectInfo?f(i.intersectInfo.objectType):"",t.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ContextMenu,n)}}}(i)})),n.registerEventListener(y.EVENTS.ON_HOVER_PICK,(function(e){e.intersectInfo&&(e.intersectInfo.worldBoundingBox=t.globalUnitUtil.revertBBox(e.intersectInfo.worldBoundingBox),e.intersectInfo.worldPosition=t.globalUnitUtil.revertVector(e.intersectInfo.worldPosition),e.intersectInfo.point=t.globalUnitUtil.revertVector(e.intersectInfo.point)),function(e){var t=null,i="Hover";if(e.intersectInfo){if(t={objectId:e.intersectInfo.selectedObjectId,modelId:e.intersectInfo.modelId,fileId:e.intersectInfo.fileId,elementId:e.intersectInfo.selectedObjectId,boundingBox:e.intersectInfo.worldBoundingBox,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:e.intersectInfo.worldPosition,clientPosition:e.canvasPos,eventType:i,objectType:f(e.intersectInfo.objectType)},e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var n=e.intersectInfo.selectedObjectId.split(".");n.length>1&&(t.elementId=n[1],t.integrateId=t.fileId,t.fileId=n[0])}}else p=null,t={screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:i};o.fireEvent(r.ComponentsHoverChanged,t),t.objectId&&p!=t.objectId&&(o.fireEvent(r.Hover,t),p=t.objectId)}(e)})),n.registerEventListener(y.EVENTS.ON_MOUSE_MOVE_PICK,(e=>{e.intersectInfo&&(e.intersectInfo.worldBoundingBox=t.globalUnitUtil.revertBBox(e.intersectInfo.worldBoundingBox),e.intersectInfo.worldPosition=t.globalUnitUtil.revertVector(e.intersectInfo.worldPosition),e.intersectInfo.point=t.globalUnitUtil.revertVector(e.intersectInfo.point)),function(e){if(!e.intersectInfo)return;const t=e.intersectInfo;var i={};if(void 0!==t.selectedObjectId&&(i.objectId=t.selectedObjectId),void 0!==t.modelId&&(i.modelId=t.modelId),void 0!==t.selectedObjectId&&(i.elementId=t.selectedObjectId),void 0!==t.worldBoundingBox&&(i.boundingBox=t.worldBoundingBox),void 0!==t.worldPosition&&(i.worldPosition=t.worldPosition),void 0!==t.objectType&&(i.objectType=f(e.intersectInfo.objectType)),void 0!==t.fileId&&(i.fileId=t.fileId),i.eventType="MouseMove",i.screenPosition={x:e.event.clientX,y:e.event.clientY},i.clientPosition=e.canvasPos,t.selectedObjectId&&"string"==typeof t.selectedObjectId){var n=t.selectedObjectId.split(".");n.length>1&&(i.elementId=n[1],i.integrateId=i.fileId,i.fileId=n[0])}o.fireEvent(r.MouseMove,i)}(e)})),n.registerEventListener(y.EVENTS.ON_EDITOR_ZOOM_END,(()=>{o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.ZoomEnd)})),n.registerEventListener(y.EVENTS.ON_SELECTION_CHANGED,(function(i){let s=[];for(let e in i.selectionList)s=s.concat(i.selectionList[e]);o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.SelectionChanged,s),n._componentTreeSelect||o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.SelectionChangedInModel,i.selectionList,t._opt.domElement,t),requestAnimationFrame((()=>{delete n._componentTreeSelect}))})),n.addCallbacks("render",(function(){o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.Rendered)})),n.registerEventListener(y.EVENTS.ON_MOUSE_DRAGGED,(function(t){o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.MouseDragged,t)})),n.registerEventListener(y.EVENTS.ON_HOVER_SNAP,(function(e){t.snap.snapByPoint(e)})),t.addEventListener(r.ButtonOnToolbarClicked,(function(e){"Measure"==e.id&&e.isChecked&&null!=t.snap&&t.enableSnap(!1)})),t.addEventListener(r.MouseDoubleClicked,(function(e){t.getViewer().isEnabledDoubleClick&&t.zoomToSelectedComponents()})),n.registerEventListener(y.EVENTS.ON_CAMERA_CHANGED,(function(i){o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.PureRender,i),o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,t.getCameraStatus())})),n.registerEventListener(y.EVENTS.ON_TILES_LOAD_INITIAL,(function(t){o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.Initialized,t)}));let b=0,E=0;n.registerEventListener(y.EVENTS.ON_TILES_LOAD_PROGRESS,(function(t){const i=t.data.numAttemptedRequests+t.data.numPendingRequests+t.data.numTilesProcessing;if(E>0&&0===i)return b=0,E=0,void o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.CurrentViewLoading,100);0!==i&&(b<i&&(b=i),E=100*(b-i)/b,o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.CurrentViewLoading,Number(E.toFixed(1))))})),n.registerEventListener(y.EVENTS.ON_TILES_LOAD_COMPLETE,(function(t){o.fireEvent(e.Bimface.Viewer.Viewer3DEvent.ViewLoaded,t)}))},_enableSelectionChanged(e){this.bIsEnableSelectionChanged=e},_viewerMethodToModelMethod(e,n,o){return i.send(t,e),!1!==o&&this.getModelCount()>1&&this.console.obsolete("Viewer3D."+e,"Viewer3D.getModel(modelId)."+e),this.getDefaultModel()[e](...n)},_viewerMethodWithIdsToModelMethod(e,n){i.send(t,e);const o=n[0];if("[object Array]"===Object.prototype.toString.call(o)){const t=this.getViewer().modelManager.modelCollection.getById("ExtrudeBodyManager"),i=this.getViewer().modelManager.modelCollection.getById("ExternalComponent");let s=[],r=[],a=[];if(o.forEach((e=>{t&&t._hasObjectId(e)?s.push(e):i&&i._hasObjectId(e)?r.push(e):a.push(e)})),s.length>0){const t=this._getExtrudeBodyModel();t&&(n[0]=s,t[e](...n))}if(r.length>0){const t=this._getExternalComponentModel();t&&(n[0]=r,t[e](...n))}a.length>0&&(n[0]=a,this._viewerMethodToModelMethod(e,n))}},_getExtrudeBodyModel(){if(!this._extrudeBodyModel){if(this.getViewer().modelManager.modelCollection.getById("ExtrudeBodyManager")){const t={modelId:"ExtrudeBodyManager",isVirtualModel:!0};this._extrudeBodyModel=new e.Bimface.Model.Model(this,t)}}return this._extrudeBodyModel},_getExternalComponentModel(){if(!this._externalComponentModel){if(this.getViewer().modelManager.modelCollection.getById("ExternalComponent")){const t={modelId:"ExternalComponent",isVirtualModel:!0};this._externalComponentModel=new e.Bimface.Model.Model(this,t)}}return this._externalComponentModel},_viewerMethodToVirtualModelMethod(e,t){const i=this._getExtrudeBodyModel();i&&i[e](...t);const n=this._getExternalComponentModel();n&&n[e](...t)},isolateComponentsById:function(e,t){return this._viewerMethodWithIdsToModelMethod("isolateComponentsById",arguments)},isolateComponentsByObjectData:function(e,t){return this._viewerMethodToModelMethod("isolateComponentsByObjectData",arguments)},isolateByBox:function(e,t){return this._viewerMethodToModelMethod("isolateByBox",arguments)},isolateModel:function(e,t){l.assertType(e,"arr")&&this.getModels().forEach((i=>{i.clearIsolation(),e.indexOf(i.modelId)<0&&e.indexOf(i.modelId.toString())<0&&i.isolateComponentsById([void 0],t)}))},clearModelIsolation:function(){this.getModels().forEach((e=>{e.clearIsolation()}))},clearIsolation:function(){return this._viewerMethodToVirtualModelMethod("clearIsolation",arguments),this._viewerMethodToModelMethod("clearIsolation",arguments,!1)},showComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("showComponentsById",arguments)},setShellVisibility:function(e,n){i.send(t,"setShellVisibility"),this.getModels().some((t=>{if(t.viewToken===e)return t.setShellVisibility(n),!0}))},showComponents:function(e){this.showComponentsById(e)},showComponentsByObjectData:function(e){return this._showExternalComponentByObjDate(e),this._viewerMethodToModelMethod("showComponentsByObjectData",arguments)},_showExternalComponentByObjDate(e){if(!y.Utils.isDefined(e))return;Array.isArray(e)||(e=[e]);const t=this._getExternalComponentModel();if(y.Utils.isDefined(t)){let i=t.getMatchIds(e);if(!y.Utils.isDefined(i))return;t.showComponentsById(i)}},hideComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("hideComponentsById",arguments)},hideComponents:function(e){this.hideComponentsById(e)},hideComponentsByObjectData:function(e){return this._hideExternalComponentByObjDate(e),this._viewerMethodToModelMethod("hideComponentsByObjectData",arguments)},_hideExternalComponentByObjDate(e){if(!y.Utils.isDefined(e))return;Array.isArray(e)||(e=[e]);const t=this._getExternalComponentModel();if(y.Utils.isDefined(t)){let i=t.getMatchIds(e);if(!y.Utils.isDefined(i))return;t.hideComponentsById(i)}},showAllComponents:function(e,t){return this._viewerMethodToVirtualModelMethod("showAllComponents",arguments),this._viewerMethodToModelMethod("showAllComponents",arguments,!1)},hideAllComponents:function(){return this._viewerMethodToVirtualModelMethod("hideAllComponents",arguments),this._viewerMethodToModelMethod("hideAllComponents",arguments,!1)},showExclusiveComponentsByObjectData:function(e,t,i){return this._viewerMethodToModelMethod("showExclusiveComponentsByObjectData",arguments)},transparentComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("transparentComponentsById",arguments)},transparentComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("transparentComponentsByObjectData",arguments)},transparentAllComponents:function(){return this._viewerMethodToVirtualModelMethod("transparentAllComponents",arguments),this._viewerMethodToModelMethod("transparentAllComponents",arguments,!1)},opaqueComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("opaqueComponentsById",arguments)},opaqueComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("opaqueComponentsByObjectData",arguments)},opaqueAllComponents:function(){return this._viewerMethodToVirtualModelMethod("opaqueAllComponents",arguments),this._viewerMethodToModelMethod("opaqueAllComponents",arguments,!1)},setIsolatedComponentColor:function(e){return this._viewerMethodToModelMethod("setIsolatedComponentColor",arguments)},restoreIsolatedComponentColor:function(){return this._viewerMethodToModelMethod("restoreIsolatedComponentColor",arguments)},getIsolatedComponentColor:function(){return this._viewerMethodToModelMethod("getIsolatedComponentColor",arguments)},setComponentsOpacity:function(e,t){return this._viewerMethodWithIdsToModelMethod("setComponentsOpacity",arguments)},addSelectedComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("addSelectedComponentsById",arguments)},setSelectedComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("setSelectedComponentsById",arguments)},addSelectedComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("addSelectedComponentsByObjectData",arguments)},setSelectedComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("setSelectedComponentsByObjectData",arguments)},getObjectDataById:function(e){return this._viewerMethodToModelMethod("getObjectDataById",arguments)},getSelectedComponents:function(){let e=new Set,t=this._getExternalComponentModel(),i=this.getModels(),n={},o=i.length>1,s=this._getExtrudeBodyModel(),r=[];const a=(t,i)=>{if(t){const s=t.getSelectedComponents();let a=[];if(s.forEach((t=>{if(o)if("external"===i){if(t.indexOf("-")>-1){let e=this.getExternalObjectManager().getAssociatedInfo(t);e&&(!n[e.modelId]&&(n[e.modelId]=[t])||n[e.modelId].push(t))}}else if("room"===i){const e=this.getViewer();let i=y.ExtrudeBodyManager.getInstance(e).getBindedModelId(t);i?!n[i]&&(n[i]=[t])||n[i].push(t):r.push(t)}else a.push(t);else e.add(t)})),o){if(t.modelId){a=n[t.modelId]&&a.concat(n[t.modelId])||a;let i={ModelId:t.modelId,Ids:a};a.length&&e.add(i)}"room"===i&&r.length>0&&e.add({ids:r})}}};return a(t,"external"),a(s,"room"),i.forEach((e=>{a(e)})),[...e]},removeSelectedId:function(e){return this._viewerMethodWithIdsToModelMethod("removeSelectedId",arguments)},setCollisionByCondition:function(e){this.getViewer().cameraControl.collisionManager.setCondition(e)},getCollisionByCondition:function(){return this.getViewer().cameraControl.collisionManager.getCondition()},clearSelectedComponents:function(){return this._viewerMethodToVirtualModelMethod("clearSelectedComponents",arguments),this._viewerMethodToModelMethod("clearSelectedComponents",arguments,!1)},enableBlinkComponents:function(e){this.getViewer().enableBlinkComponents(e)},addBlinkComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("addBlinkComponentsById",arguments)},setBlinkComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("setBlinkComponentsById",arguments)},getBlinkComponents:function(){let e=new Set;const t=t=>{if(t){t.getBlinkComponents().forEach((t=>{e.add(t)}))}};return t(this._getExtrudeBodyModel()),t(this._getExternalComponentModel()),t(this.getDefaultModel()),[...e]},clearBlinkComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("clearBlinkComponentsById",arguments)},clearAllBlinkComponents:function(){return this._viewerMethodToVirtualModelMethod("clearAllBlinkComponents",arguments),this._viewerMethodToModelMethod("clearAllBlinkComponents",arguments,!1)},setBlinkColor:function(e){return this._viewerMethodToVirtualModelMethod("setBlinkColor",arguments),this._viewerMethodToModelMethod("setBlinkColor",arguments,!1)},setBlinkIntervalTime:function(e){return this._viewerMethodToVirtualModelMethod("setBlinkIntervalTime",arguments),this._viewerMethodToModelMethod("setBlinkIntervalTime",arguments,!1)},overrideComponentsColorById:function(e,t){return this._viewerMethodWithIdsToModelMethod("overrideComponentsColorById",arguments)},applyMaterialOverrideSet(e,t,i,n,o){return this._viewerMethodToModelMethod("applyMaterialOverrideSet",arguments,!1)},overrideComponentsColorByObjectData:function(e,t){return this._viewerMethodToModelMethod("overrideComponentsColorByObjectData",arguments)},restoreComponentsColorById:function(e){return this._viewerMethodWithIdsToModelMethod("restoreComponentsColorById",arguments)},restoreComponentsColorByObjectData:function(e){return this._viewerMethodToModelMethod("restoreComponentsColorByObjectData",arguments)},overrideComponentsOpacityById:function(e,t){return this._viewerMethodWithIdsToModelMethod("overrideComponentsOpacityById",arguments)},overrideComponentsOpacityByObjectData:function(e,t){return this._viewerMethodToModelMethod("overrideComponentsOpacityByObjectData",arguments)},restoreComponentsOpacityById:function(e){return this._viewerMethodWithIdsToModelMethod("restoreComponentsOpacityById",arguments)},restoreComponentsOpacityByObjectData:function(e){return this._viewerMethodWithIdsToModelMethod("restoreComponentsOpacityByObjectData",arguments)},clearOverrideColorComponents:function(){return this._viewerMethodToVirtualModelMethod("clearOverrideColorComponents",arguments),this._viewerMethodToModelMethod("clearOverrideColorComponents",arguments,!1)},restoreDefault:function(){return this._viewerMethodToVirtualModelMethod("restoreDefault",arguments),this._viewerMethodToModelMethod("restoreDefault",arguments,!1)},restoreAllDefault:function(){return this._viewerMethodToVirtualModelMethod("restoreAllDefault",arguments),this._viewerMethodToModelMethod("restoreAllDefault",arguments,!1)},zoomIn:function(){this.getViewer().zoomIn()},recordCustomHomeview:function(e){this.customedHomeview=e},recordCustomedHomeview:function(e){this.console.obsolete("Viewer3D.recordCustomedHomeview","Viewer3D.recordCustomHomeview"),this.recordCustomHomeview(e)},getCustomHomeview:function(){return this.customedHomeview},getCustomedHomeview:function(){return this.console.obsolete("Viewer3D.getCustomedHomeview","Viewer3D.getCustomHomeview"),this.getCustomHomeview()},getDefaultHomeview:function(){if(this._opt.floorExplosion){var e=this.getViewer(),t=this.getCameraStatus(),i=this.getCameraAnimation();e.setHomeView(e.getHomeView()),this.defaultHomeview=this.getCameraStatus(),this.setCameraAnimation(!1),this.setCameraStatus(t),this.setCameraAnimation(i)}return this.defaultHomeview},getViewHouseIsLoaded:function(){return this.bViewHouseIsLoaded},zoomOut:function(){this.getViewer().zoomOut()},setCameraAnimation:function(e){i.send(t,"setCameraAnimation"),this.getViewer().setTransitionAnimationState(e)},getCameraAnimation:function(){return this.getViewer().getTransitionAnimationState()},toggleContextMenuDisplay:function(e){i.send(t,"toggleContextMenuDisplay"),this._opt.enableToggleContextMenuDisplay=void 0!==e?e:!this._opt.enableToggleContextMenuDisplay},render:function(){var e=this.getViewer();e.modelManager&&e.modelManager.setRenderStateChanged(!0),e.render()},enableTranslate:function(e){i.send(t,"enableTranslate"),y.EditorConfig.NoPan=null!=e&&!e},isEnableTranslate:function(){return i.send(t,"isEnableTranslate"),!1===y.EditorConfig.NoPan},enableScale:function(e){i.send(t,"enableScale"),y.EditorConfig.NoZoom=null!=e&&!e},isEnableScale:function(){return i.send(t,"isEnableScale"),!1===y.EditorConfig.NoZoom},enableOrbit:function(e){i.send(t,"enableOrbit"),y.EditorConfig.NoRotate=null!=e&&!e},isEnableOrbit:function(){return i.send(t,"isEnableOrbit"),!1===y.EditorConfig.NoRotate},setMinimumFPS:function(e){if(i.send(t,"setMinimumFPS"),"number"!=typeof e)return!1;e=e>60?60:e<4?4:e,this.getViewer().limitFrameRate(e)},getMinimumFPS:function(){return i.send(t,"getMinimumFPS"),this.getViewer().minimumFPS},setEffectMode(e){switch(this.console.obsolete("Viewer3D.setEffectMode","Viewer3D.setMinimumFPS"),e){case"performance":this.setMinimumFPS(8),this.enableWireframe(!0);break;case"fluency":this.setMinimumFPS(30),this.enableWireframe(!1);break;default:e="performance"}this._effectMode=e,this.render()},getEffectMode(){return this.console.obsolete("Viewer3D.getEffectMode","Viewer3D.getMinimumFPS"),this._effectMode},setFlySpeedRate:function(e){if(i.send(t,"setFlySpeedRate"),null==e&&(e=1),"number"!=typeof e)return!1;e=e>25?25:e<=0?0:e;!0===this.getViewer().modelManager.isMeterUnit()&&(e*=.001),this.getViewer().setWalkSpeedRate(2*e)},enableGravity:function(e){i.send(t,"enableGravity"),y.GlobalData.WalkingWithGravity=!!e},setRotationCenter:function(e){i.send(t,"setRotationCenter");let n=this.getViewer();null==e&&(e=n.getBoundingBoxWorld().getCenter(X)),n.setRotationCenter(this.worldToScene(e))},clearRotationCenter:function(){i.send(t,"clearRotationCenter"),this.getViewer().clearRotationCenter()},enableHitDetection:function(e){i.send(t,"enableHitDetection"),this.getViewer().enableHitDetection(e)},exitWalk:function(){i.send(t,"exitWalk");var e=document.querySelector(".gld-bf-firstperson.bf-checked");e&&e.click()},setView:function(e,n){i.send(t,"setView");var o=y.EnumStandardView,s={Home:o.ISO,Top:o.Top,Bottom:o.Bottom,North:o.Back,South:o.Front,West:o.Left,East:o.Right,SouthEast:o.SouthEast,SouthWest:o.SouthWest,NorthEast:o.NorthEast,NorthWest:o.NorthWest,NorthEastIsometricTop:o.RoofNorthEast,NorthWestIsometricTop:o.RoofNorthWest,SouthEastIsometricTop:o.RoofSouthEast,SouthWestIsometricTop:o.RoofSouthWest,NorthEastIsometricBottom:o.BottomNorthEast,NorthWestIsometricBottom:o.BottomNorthWest,SouthEastIsometricBottom:o.BottomSouthEast,SouthWestIsometricBottom:o.BottomSouthWest,NorthTop:o.RoofBack,SouthTop:o.RoofFront,WestTop:o.RoofLeft,EastTop:o.RoofRight,NorthBottom:o.BottomBack,SouthBottom:o.BottomFront,WestBottom:o.BottomLeft,EastBottom:o.BottomRight};this.exitWalk(),this.getViewer().setStandardView(s[e],null,null,n)},zoomToSelectedComponents:function(e,n,o){i.send(t,"zoomToSelectedComponents"),1===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[0])?(e=1,n=arguments[0]):2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1])?(e=arguments[0],o=arguments[1]):2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1])?(e=arguments[0],n=arguments[1]):e=e||1,void 0===o&&(o=1e3),this.getViewer().zoomToSelection(e,void 0,"[object Function]"===Object.prototype.toString.call(n)?n:void 0,void 0,o)},zoomToBoundingBox:function(e,n,o,s){if(i.send(t,"zoomToBoundingBox"),1===arguments.length)e=arguments[0];else if(2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],arguments[1]>100?(o=1,s=arguments[1]):(o=arguments[1],s=1e3);else if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],n=arguments[1],o=1,s=1e3;else if(3===arguments.length){for(let e=0;e<arguments.length;e++){const t=arguments[e];"[object Function]"===Object.prototype.toString.call(t)?n=t:"[object Number]"===Object.prototype.toString.call(t)&&(t>100?s=t:o=t)}e=arguments[0],void 0===s&&(s=1e3),void 0===o&&(o=.5)}if(e&&e.min&&e.max){var r=[[e.min.x,e.min.y,e.min.z],[e.max.x,e.max.y,e.max.z]];this.viewerAdapter.zoomToBBox(y.Utils.computeBBox(r),o,void 0,"[object Function]"===Object.prototype.toString.call(n)?n:void 0,s)}},setNavigationMode:function(e,n){i.send(t,"setNavigationMode");var o=this.getViewer();switch(this.enableZoomRect(!1),this.enablePickRect(!1),e){case"Fly":o.setEditorMode(y.EditorMode.FLY);break;case"Orbit":o.setEditorMode(y.EditorMode.ORBIT);break;case"Zoom":o.setEditorMode(y.EditorMode.ZOOM);break;case"OrbitWithModelCenter":o.setEditorMode(y.EditorMode.PICK),o.setPointRotateMode(y.RotatePivotMode.CENTER);break;case"Select":o.setPointRotateMode(y.RotatePivotMode.SELECTION),o.setEditorMode(y.EditorMode.PICK);break;case"PickWithRect":o.setPointRotateMode(y.RotatePivotMode.SELECTION),o.setEditorMode(y.EditorMode.PICK),this.enablePickRect(!0),this.enableZoomRect(!1);break;case"ZoomWithRect":this.enableZoomRect(!0),this.enablePickRect(!1);break;case"Walk":o.setEditorMode(y.EditorMode.WALK);let e=n&&null!=n.walkRotationSpeed?n.walkRotationSpeed:this._opt.walkRotationSpeed;y.GlobalData.WalkRotationSpeed=Math.max(Math.min(e,5),.2),this.enablePickRect(!1),this.enableZoomRect(!1),o.getRenderer().domElement.focus();break;case"ThirdPerson":o.getCurrentEditorName()==y.EditorMode.THIRDPERSONWALK&&(o.getCurrentEditor().onExit(),o.editorManager.editor=null),o.setEditorMode(y.EditorMode.THIRDPERSONWALK),this.isThirdPersonRun=!1,this._prepareThirdPerson(o.getCurrentEditor(),!1,n&&n.position),this.setFlySpeedRate(2),o.getRenderer().domElement.focus();break;case"ThirdPersonRun":o.getCurrentEditorName()==y.EditorMode.THIRDPERSONWALK&&(o.getCurrentEditor().onExit(),o.editorManager.editor=null),o.setEditorMode(y.EditorMode.THIRDPERSONWALK),this.isThirdPersonRun=!0,this._prepareThirdPerson(o.getCurrentEditor(),!0,n&&n.position),this.setFlySpeedRate(8),o.getRenderer().domElement.focus()}},setAvatar:function(t){e.Bimface.Viewer.AvatarOption[t]&&(this.thirdPersonAvatar=t)},getAvatar:function(){return this.thirdPersonAvatar},setAvatarHeight:function(e){if(Number.isNaN(e)||!Number.isFinite(e))return;this.avatarHeight=e;if(this.getViewer().getCurrentEditorName()==y.EditorMode.THIRDPERSONWALK){this.getViewer().getCurrentEditor().setThirdPersonHeight(e)}},getAvatarHeight:function(){return this.avatarHeight},_prepareThirdPerson:function(t,i,n){n=this.globalUnitUtil.translate(n,["x","y","z"])||this.getViewer().getCurrentEditor().getObjectPosition();let o=e.Bimface.Viewer.AvatarOption.personTypeMap[this.thirdPersonAvatar]||0,s=this.avatarHeight;if(t.objectInfoMap&&t.objectInfoMap[o])return void t.prepare(i,n,s,o);let r=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this);var a=this._data,l=a.dataEnvType==_.Local?a.sdkPath:g.staticHost;let h=`${l}/resources/ExternalObject/ThirdPerson/Avatar/Standard.FBX`,d={walk:[0,30],run:[141,200],stand:[65,66]};switch(o){case y.ThirdPersonType.ConstructionWorker:h=`${l}/resources/ExternalObject/ThirdPerson/constructionWorker/Standard.fbx`,d={walk:[0,35],run:[127,149],stand:[38,39]};case y.ThirdPersonType.OfficeMale:}const c=`thirdPerson_${o}`,u=this;r.loadObject({name:c,url:{objectUrl:h}},(function(){const e=r.getObjectIdByName(c);let a=u.getExternalComponentManager().getNodeById(e);const l={objectId:e,externalObjectManager:r._manager,isRunMode:i,initialPosition:n,personType:o,personHeight:s,animationClip:d};a.personType=o,t.setThirdPerson(a,l)}))},getBoundingBoxById:function(e){const t=this.getViewer().modelManager.modelCollection.getById("ExtrudeBodyManager"),i=this.getViewer().modelManager.modelCollection.getById("ExternalComponent");if(t&&t._hasObjectId(e)){const t=this._getExtrudeBodyModel();if(t)return t.getBoundingBoxById(e)}else if(i&&i._hasObjectId(e)){const t=this._getExternalComponentModel();if(t)return t.getBoundingBoxById(e)}return this._viewerMethodToModelMethod("getBoundingBoxById",arguments)},enableZoomRect:function(e){i.send(t,"enableZoomRect");var n=this.getViewer();this._opt.enableZoomRect=e,e?n.editorManager.enableTool(n,y.EditToolMode.ZOOM_BY_RECT):n.editorManager.disableTool(y.EditToolMode.ZOOM_BY_RECT)},enablePickRect:function(e,t){var i=this.getViewer();if(e){let e=!y.Utils.isDefined(t)||t,n=i.editorManager.enableTool(i,y.EditToolMode.PICK_BY_RECT);n&&n.triggerByCtrlKey(e)}else i.editorManager.disableTool(y.EditToolMode.PICK_BY_RECT)},setOrbitButton:function(e){i.send(t,"setOrbitButton");this._opt.orbitButton=e,this._opt.leftHandedMouseSetup="Left"==e,this.getViewer().setOrbitButton({Left:"left",Right:"right"}[e])},setUseLeftHandedInput:function(e){i.send(t,"setUseLeftHandedInput"),this._opt.leftHandedMouseSetup=e,this.getViewer().setOrbitButton(e?"left":"right")},getUseLeftHandedInput:function(){return void 0===this._opt.leftHandedMouseSetup||this._opt.leftHandedMouseSetup},setReverseWheelDirection:function(e){i.send(t,"setReverseWheelDirection"),this.getViewer().setReverseWheelDirection(e)},enableHover:function(e){i.send(t,"enableHover"),this._opt.enableHover=e,this.getViewer().enableHover(e)},setDampingFactor:function(e){i.send(t,"setDampingFactor"),this.getViewer().setDampingFactor(e)},enableDamping:function(e){i.send(t,"enableDamping"),this.getViewer().enableDamping(e)},enableMouseMovePick:function(e){i.send(t,"enableMouseMovePick"),this._opt.enableMouseMovePick=e,this.getViewer().enableMouseMovePick(e)},getCameraStatus:function(){return this.camera3D.getStatus()},setCameraStatus:function(e,n){i.send(t,"setCameraStatus"),this.camera3D.setStatus(e,n)},setCameraType:function(e,n){i.send(t,"setCameraType"),this.camera3D.setCameraType(e,n)},highlightComponentsById:function(e,t,i){return this._viewerMethodToModelMethod("highlightComponentsById",arguments)},highlightComponentsByObjectData:function(e,t){return this._viewerMethodToModelMethod("highlightComponentsByObjectData",arguments)},loadViewCore:function(t,i,n){if(t&&t.renderVersion!=t.renderVersion)return console.log("this model can not be added."),!1;n&&n.enableComponentCut&&(t.previousDatabagId=t.databagId,t.databagId=t.componentSegmentDataBagId,t.enableComponentCut=!0);new e.Bimface.Model.BimModel(this,t,i,n);var o=e.Bimface.Data.StatisticsDataManager.getInstance();o.modelType=t.modelType,o.modelId=t.modelId;const s=this._opt;s.enableSkyBox&&this.setSkyBoxType(s.skyBoxType),n&&!1===n.zoomAll&&(s.cancelHomeView=!0),this.fireEvent(e.Bimface.Viewer.Viewer3DEvent.AddView,this.getModelCount())},fireEvent(e,t){this.getEventManager&&this.getEventManager().fireEvent(e,t)},getModels(){return Object.values(this._models)},getAllModels(){let e=[];return this.getModels().forEach((t=>{let i=t.getMetaData();e.push({modelId:t.modelId,modelName:i.name})})),e},getModel(e){return e?this._models?this._models[e]:void 0:this.getDefaultModel()},getDefaultModel(){return this._defaultModel},getModelCount(){return this.getModels().length},loadMaterialOverrideSet:function(e,t,i,n,o){return this._viewerMethodToModelMethod("loadMaterialOverrideSet",arguments,!1)},changeMaterialOverrideSetMode:function(e){return this._viewerMethodToModelMethod("changeMaterialOverrideSetMode",arguments,!1)},loadModel:function(e){i.send(t,"loadModel"),e.componentsFrame&&(void 0===e.componentsFrame.isVisible&&(e.componentsFrame.isVisible=!0),void 0===e.componentsFrame.condition&&(e.componentsFrame.condition={all:!0})),e.viewToken?this.addView(e.viewToken,this.viewerType,{modelId:e.modelId,componentsFrame:e.componentsFrame,enableComponentCut:e.enableComponentCut}):e.viewMetaData&&this.addModel(e.viewMetaData,this.viewerType,{modelId:e.modelId,componentsFrame:e.componentsFrame,enableComponentCut:e.enableComponentCut})},addModel:function(t,i,n){const o=this.getDefaultModel()?this.getDefaultModel().getMetaData():void 0;if(!a||o&&o.renderVersion!=t.renderVersion)return console.log("this model can not be added."),!1;n&&n.enableComponentCut&&(t.previousDatabagId=t.databagId,t.databagId=t.componentSegmentDataBagId,t.enableComponentCut=!0);new e.Bimface.Model.BimModel(this,t,i,n);this.fireEvent(e.Bimface.Viewer.Viewer3DEvent.AddView,this.getModelCount())},removeView:function(e){let n;i.send(t,"removeView"),this.getModels().some((t=>{if(t.getMetaData().viewToken===e)return n=t,!0})),n&&n.destroy()},removeModel:function(e){i.send(t,"removeModel");let n=this.getModel(e);n&&n.destroy()},showView:function(e){i.send(t,"showView"),this.setModelVisible(e,!0)},hideView:function(e){i.send(t,"hideView"),this.setModelVisible(e,!1)},setModelVisible(t,i){this.getModels().some((n=>{if(n.viewToken===t)return n.setVisible(i),this.fireEvent(e.Bimface.Viewer.Viewer3DEvent.ModelVisibleChanged,i),!0}))},worldToScene:function(e){return this.viewerAdapter.worldToDrawing(e)},sceneToWorld:function(e){return this.viewerAdapter.drawingToWorld(e)},resize:function(t,i){if(this._opt){var n=this._opt.domElement,o=t||n.clientWidth,s=i||n.clientHeight;this.getViewer().resize(o,s),this.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.Resized)}},setBackgroundColor:function(n,o){if(i.send(t,"setBackgroundColor"),o){const e=[{color:n,stop:"0%"},{color:o,stop:"100%"}];this.setBackgroundColors(e,"180deg"),this._opt.backgroundColor=e,this._opt.backgroundColorDirection=Math.PI}else{let t=e.Web.Graphics.Color,i={Black:new t(0,0,0,1),Blue:new t(0,0,189,1),Green:new t(0,255,0,1),Red:new t(255,0,0,1),Yellow:new t(250,189,5,1)},o=this._opt.domElement;"string"==typeof n&&(n=i[n]),this.getViewer().rendererManager.renderer&&this.getViewer().IBLManager.removeSkyBox(),this._opt.backgroundColor=[n],this._opt.backgroundColorDirection=Math.PI,o.style.background=n.getRGBA(),this._setBackground(o,n)}},setBackgroundColors:function(e,t){var i=this._opt.domElement,n=(t=t||"0deg",[]);if(e&&e.length>0){if(this.backgroundColor=e,1==e.length)this.setBackgroundColor(e[0].color||e[0]);else{for(var o=0;o<e.length;o++){var s=e[o].color.getRGBA()+" "+e[o].stop;n.push(s)}this.getViewer().rendererManager.renderer&&this.getViewer().IBLManager.removeSkyBox();var r=`${t}, ${n.join(",")}`;i.style.background=`linear-gradient(${r})`,this._setBackground(i)}this._opt.backgroundColorDirection=parseInt(t)}},_setBackground:function(e,t){},getCurrentState:function(){var e,t,i,n=this.getViewer().getFilter().saveState(),o=this.getCameraStatus(),s=this.getDefaultModel().getSelectedComponents(),r=this.getDefaultModel().getCurrentAxisGridsState();this.getModelCount()>1&&(e={},this.getModels().forEach((t=>{e[t.modelId]={};let i=e[t.modelId];i.selection=t.getSelectedComponents(),i.axisGrid=t.getCurrentAxisGridsState()}))),this._sectionBox&&(t=this._sectionBox.getState()),this._sectionPlane&&(i=this._sectionPlane.getState());const a={state:JSON.parse(n),camera:o,selection:s,axisGrid:r,sectionBoxState:t,sectionPlaneState:i};return e&&(a.models=e),a},setState:function(n,o){i.send(t,"setState"),"string"==typeof n&&(n=JSON.parse(n)),this._viewerMethodToVirtualModelMethod("_restoreAllDefaultFilter",arguments),this._viewerMethodToModelMethod("_restoreAllDefaultFilter",arguments,!1);var s=this.getViewer();if(n.models)for(let e in n.models){const t=n.models[e],i=this.getModel(e);if(i&&(t.selection&&t.selection.length>0?i.setSelectedComponentsById(t.selection):i.clearSelectedComponents(),t.axisGrid)){Object.keys(t.axisGrid).length>0&&i.setAxisGridsState(t.axisGrid)}}else if(n.selection&&n.selection.length>0?this.getDefaultModel().setSelectedComponentsById(n.selection):this.getDefaultModel().clearSelectedComponents(),n.axisGrid){Object.keys(n.axisGrid).length>0&&this.getDefaultModel().setAxisGridsState(n.axisGrid)}if(s.getFilter().loadState(JSON.stringify(n.state)),n.sectionBoxState){var r;if(this._sectionBox)r=this._sectionBox;else(l=new e.Bimface.Plugins.Section.SectionBoxConfig).viewer=this,l.id="SectionBox",r=new e.Bimface.Plugins.Section.SectionBox(l);r.setState(n.sectionBoxState),n.sectionBoxState.rotate&&(r.rotateByAxis("XAxis",n.sectionBoxState.rotate[0]*(180/Math.PI)),r.rotateByAxis("YAxis",n.sectionBoxState.rotate[1]*(180/Math.PI)),r.rotateByAxis("ZAxis",n.sectionBoxState.rotate[2]*(180/Math.PI)))}else this._sectionBox&&(this._sectionBox.reset(),this._sectionBox.hideBox());if(n.sectionPlaneState){var a,l;if(this._sectionPlane)a=this._sectionPlane;else(l=new e.Bimface.Plugins.Section.SectionPlaneConfig).viewer=this,l.id="SectionPlane",a=new e.Bimface.Plugins.Section.SectionPlane(l);a.setState(n.sectionPlaneState)}else this._sectionPlane&&(this._sectionPlane.setProgress(0),this._sectionPlane.hidePlane());var h=this;this.setCameraStatus(n.camera,(function(){o&&o(),0==h.getCameraAnimation()&&h.render()}))},createSnapshot:function(e){return console.warn("This function is deprecated. Please use createSnapshotAsync instead."),this.getViewer().canvas2image(e)},createSnapshotAsync:function(e,n){i.send(t,"createSnapshotAsync");var o=this,s=o.getViewer(),r=e.backgroundColor?e.backgroundColor:e;if(e.enableMarks||!1){const e=s.domElement;e.querySelector(".bf-measure-conext")||e.querySelector(".bf-drawable-context")||e.parentElement.querySelector("#markup")?$.loadThirdPartyByName("html2canvas",(()=>{html2canvas(e,{backgroundColor:null,ignoreElements:function(e){return"cloud-main-canvas"==e.id}}).then((t=>{let i=document.createElement("canvas");t.getContext("2d").getImageData(0,0,t.width,t.height);i.width=t.width,i.height=t.height,s.getRenderBufferScreenShot(r.getRGBA(),(function(s){if(s){const r=new Image;r.onload=function(){if(i.getContext("2d").drawImage(r,0,0),i.getContext("2d").drawImage(t,0,0),e.parentElement.querySelector("#markup")){const t=e.parentElement.querySelector("#markup");i.getContext("2d").drawImage(t,0,0)}n&&n(i.toDataURL("image/png")),o.render(),i.getContext("2d").clearRect(0,0,i.width,i.height),i=null},r.src=s}}))}))})):s.getRenderBufferScreenShot(r.getRGBA(),(function(e){n&&n(e),o.render()}))}else s.getRenderBufferScreenShot(r.getRGBA(),(function(e){n&&n(e),o.render()}))},section:function(){console.log("This function is deprecated. Please use enableSectionBox instead.")},enableSectionBox:function(){var e=this,t=this.getViewer();t.editorManager.enableTool(t,y.EditToolMode.CLIP_BY_BOX),e._sectionTool=new y.ClipPlaneService(t),e._sectionTool.toggle(!0,!0),e._sectionTool.setVisible(!0),e._isSection=!0,this.render()},disableSectionBox:function(){this.getViewer().editorManager.disableTool(y.EditToolMode.CLIP_BY_BOX),this._isSection=!1,this.render()},resetSectionBox:function(){this._isSection?(this.showSectionBox(),this.setSectionBoxMode(),this._sectionTool.reset("Rotate")):console.log(r)},setSectionBoxMode:function(e){this._isSection?"Rotate"==e?this._sectionTool.setRotatable(!0):this._sectionTool.setRotatable(!1):console.log(r)},showSectionBox:function(){this._isSection?(this._sectionTool.setVisible(!0),this.render()):console.log(r)},hideSectionBox:function(){this._isSection?(this._sectionTool.setVisible(!1),this.render()):console.log(r)},setSectionBox:function(e){var t=y.ClipPlaneManager.getInstance(viewer.getScene()),i=this.viewerAdapter.worldToDrawing(e.min),n=this.viewerAdapter.worldToDrawing(e.max);this.enableSectionBox(),t.setSectionBox(i,n),this.hideSectionBox()},getSectionBoxState:function(){if(this._isSection)return this._sectionTool.saveState();console.log(r)},setSectionBoxState:function(e){this._isSection?this._sectionTool.loadState(e):console.log(r)},getFamilyTypes:function(e){return this._viewerMethodToModelMethod("getFamilyTypes",arguments)},showFamilyTypeById:function(e){return this._viewerMethodToModelMethod("showFamilyTypeById",arguments)},getModelTree:function(e){return this._viewerMethodToModelMethod("getModelTree",arguments)},getScheduleList:function(e){return this._viewerMethodToModelMethod("getScheduleList",arguments)},getScheduleById:function(e,t){return this._viewerMethodToModelMethod("getScheduleById",arguments)},getElementByConditions:function(e,t,i){return this.console.obsolete("Viewer3D.getElementByConditions","Viewer3D.getModel(modelId).getComponentsByConditions"),this._viewerMethodToModelMethod("getElementByConditions",arguments)},getModeTree:function(e){return this.console.warn("Viewer3D.getModeTree() is deprecated. Please use Viewer3D.getModel(modelId).getModelTree() instead."),this._viewerMethodToModelMethod("getModelTree",arguments,!1)},getFloors:function(e){return this._viewerMethodToModelMethod("getFloors",arguments)},createAreaInfo:function(e,t){return this.console.obsolete("Viewer3D.createAreaInfo","Viewer3D.createBoundary"),this.createBoundary(t)},createBoundary:function(e,n){i.send(t,"createBoundary");var o=this.getViewer();return 1===arguments.length?o.createAreaInfo("",arguments[0]):arguments.length>1?o.createAreaInfoWithHoles("",arguments[0],arguments[1]):void 0},getAreas:function(e,t){return this._viewerMethodToModelMethod("getAreas",arguments)},getComponentProperty:function(e,t,i){return this._viewerMethodToModelMethod("getComponentProperty",arguments)},getComponentOverriddenProperty:function(e,t,i){return this._viewerMethodToModelMethod("getComponentOverriddenProperty",arguments)},getModelGroup:function(e,t){this.console.obsolete("Viewer3D.getModelGroup","Viewer3D.getModel(modelId).getModelSet"),this.getDefaultModel().getModelSet(e,t)},getModelSet:function(e,t){return this._viewerMethodToModelMethod("getModelSet",arguments)},getSetByComponentId:function(e,t){return this._viewerMethodToModelMethod("getSetByComponentId",arguments)},getComponentsBySetId(e,t){return this._viewerMethodToModelMethod("getComponentsBySetId",arguments)},getAreaProperty:function(e,t){return this._viewerMethodToModelMethod("getAreaProperty",arguments)},getMaterialProperty:function(e,t,i){return this._viewerMethodToModelMethod("getMaterialProperty",arguments)},getRoomProperty:function(e,t){return this._viewerMethodToModelMethod("getRoomProperty",arguments)},getFiles:function(e){return this._viewerMethodToModelMethod("getFiles",arguments)},getLinkGraph:function(e){return this._viewerMethodToModelMethod("getLinkGraph",arguments)},getDrawingsheets:function(e,t){return this._viewerMethodToModelMethod("getDrawingsheets",arguments)},getAllDrawingsheets:function(e){return this._viewerMethodToModelMethod("getAllDrawingsheets",arguments)},getLinksJson:function(e){return this._viewerMethodToModelMethod("getLinksJson",arguments)},getMapInfo:function(e){return this._viewerMethodToModelMethod("getMapInfo",arguments)},showViewHouse:function(){i.send(t,"showViewHouse");var n=this;if(n._viewHouse)n._viewHouse.enableViewHouse(!0);else{this.bViewHouseIsLoaded=!0;var o=n._opt,s=e.Bimface.Plugins.ViewHouseConfig();s.domElement=o.domElement,s.viewer=n,n._viewHouse=new e.Bimface.Plugins.ViewHouse(s)}this.bIsViewHouseVisible=!0},hideViewHouse:function(){i.send(t,"hideViewHouse"),this._viewHouse&&(this._viewHouse.enableViewHouse(!1),this.bIsViewHouseVisible=!1)},enableCoordinateSystem(e){this._opt.enableCoordinateSystem=e,this._viewHouse.enableCoordinateSystem(e)},isEnableCoordinateSystem(){return this._opt.enableCoordinateSystem},_getViewHouseVisibility:function(){return this.bIsViewHouseVisible},_getIsCursorEnabled:function(){return this.bIsCursorEnabled},_enableCursor:function(e){this.bIsCursorEnabled=e},startAutoRotate:function(e,n){i.send(t,"startAutoRotate");let o=this.getCameraStatus();o.up={x:0,y:0,z:1},this.setCameraStatus(o);var s=this,r=this.getViewer();if(0==e)return void s.stopAutoRotate();s._animationFrameHandle&&s.stopAutoRotate();let a=r.getRotationCenter(),l=r.cameraControl.calculatePivot(y.RotatePivotMode.CENTER,null);void 0!==n?l=this.worldToScene(n):a&&(l=a),function t(){y.Utils.isDefined(n)||y.Utils.isDefined(a)||(l=r.cameraControl.calculatePivot(y.RotatePivotMode.CENTER,null));r.rotateByAxis(e,"x",l),r.render(),s._animationFrameHandle=requestAnimationFrame(t)}()},stopAutoRotate:function(){i.send(t,"stopAutoRotate"),this._animationFrameHandle&&cancelAnimationFrame(this._animationFrameHandle)},_getModelGroup(e,t){let i="Model|"+t,n=e.getScene().getObjectGroup(i),o="BimTilesGroup|"+t,s=e.getScene().getObjectGroup(o);return n||s},setModelTranslation:function(e,n){const o=this.getModel(e);if(o){const e="setModelTranslation";return i.send(t,e),this.getModelCount()>1&&this.console.obsolete("Viewer3D."+e,"Viewer3D.getModel(modelId)."+e),o[e](n)}},setModelRotationZ:function(e,n,o){const s=this.getModel(e);if(s){const e="setModelRotationZ";return i.send(t,e),this.getModelCount()>1&&this.console.obsolete("Viewer3D."+e,"Viewer3D.getModel(modelId)."+e),s[e](n,o)}},setModelScale:function(e,n,o){const s=this.getModel(e);if(s){const e="setModelScale";return i.send(t,e),this.getModelCount()>1&&this.console.obsolete("Viewer3D."+e,"Viewer3D.getModel(modelId)."+e),s[e](n,o)}},getModelTransformation:function(e){if(!e)return void console.log("Parameter modelId is required.");let t=this.getViewer().modelManager.getModel(e).getRawTransformMatrix().clone(),i=new THREE.Vector3,n=new THREE.Quaternion,o=new THREE.Vector3;return t.decompose(i,n,o),i=this.globalUnitUtil.revertVector(i),t.compose(i,n,o),t.elements},_getModelTransformation:function(e){if(!e)return void console.log("Parameter modelId is required.");let t=this.getViewer().modelManager.getModel(e).getRawTransformMatrix();return l.limitTransformationDecimal(t.elements)},getModelTransformationAdaptedUnit:function(e){if(!e)return void console.log("Parameter modelId is required.");let t=this.getViewer().modelManager.getModel(e).getTransformMatrix();return l.limitTransformationDecimal(t.elements)},setModelTransformation:function(e,t){if(!e||!t)return void console.log("Parameter modelId and modelTransformation is required.");if(["[object Float32Array]","[object Array]"].indexOf(Object.prototype.toString.call(t))<0)return void console.log("Parameter modelTransformation should be a array.");let i=this.getViewer(),n=this._getModelGroup(i,e);if(!n)return;let o=(new THREE.Matrix4).fromArray(t),s=new THREE.Vector3,r=new THREE.Quaternion,a=new THREE.Vector3;o.decompose(s,r,a),s=this.globalUnitUtil.translateVector(s),o.compose(s,r,a),i.modelManager.getModel(e).setTransformMatrix(o),n.transformMatrix=o,i.modelManager.updateScene(),i.rendererManager.getPickingEffecter().apply(!0),this.render()},getModelBoundaryPoints:function(e){if(!e)return console.log("Parameter modelId is required."),null;let t=this.getViewer().getModelManager().getModel(e);return this.globalUnitUtil.revertTranslate(t.getBoundaryPoints(),["x","y","z"])},disableComponentsSelectionById:function(e){console.log("the method deprecated.")},enableComponentsSelectionById:function(e){console.log("the method deprecated.")},isIsolate:function(){return this._viewerMethodToModelMethod("isIsolate",arguments)},isFiltering:function(){return this._viewerMethodToModelMethod("isFiltering",arguments)},worldToClient:function(e){return this.viewerAdapter.worldToCanvas(e)},clientToWorld:function(e){return this.viewerAdapter.canvasToWorld(e)},pickByPoint:function(e){var t=this.viewerAdapter.pickByPoint(e);if(t)return{objectId:t.meshId,boundingBox:t.worldBoundingBox,worldPosition:t.worldPosition,clientPosition:t.clientPosition}},hitTest:function(e){return console.warn("This function is deprecated. Please use pickByPoint instead."),this.pickByPoint(e)},isInViewFrustum:function(e){return this.viewerAdapter.isInViewFrustum(e)},lockAxis:function(e,t){this.camera3D.lockAxis(e,t)},unlockAxis:function(e){this.camera3D.unlockAxis(e)},enableMouseHoverHighlight:function(){this.getViewer().enableHover(!0)},disableMouseHoverHighlight:function(){this.getViewer().enableHover(!1)},setOverallLightIntensity:function(e){this.getViewer().setLightIntensityFactor(e)},getOverallLightIntensity:function(e){return y.GlobalData.LightIntensityFactor},moveTo:function(e){var t=y.MoveDirection;t={Up:y.MoveDirection.UP,Down:y.MoveDirection.DOWN,Left:y.MoveDirection.LEFT,Right:y.MoveDirection.RIGHT,Forward:y.MoveDirection.FORWARD,Back:y.MoveDirection.BACK};this.getViewer().moveTo(t[e])},getInformation:function(){i.send(t,"getInformation");var e=this.getViewer();return{elements:e.getNumOfElements(),renderables:e.getNumOfRenderables(),triangles:e.getNumOfTriangles(),vertices:e.getNumOfVertices()}},getComponentsByClientCoordinates:function(e){var t=this.getViewer().getObjectsByClientCoordinates(e);t.sort((function(e,t){return e.distance-t.distance}));var i=[];for(let e=0;e<t.length;e++){const o=t[e];var n=o.userId||o.object.name;-1==i.indexOf(n)&&i.push(n)}return i},setBorderLineEnabled:function(e){this.console.obsolete("Viewer3D.setBorderLineEnabled","Viewer3D.enableWireframe"),this.enableWireframe(e)},setLightingMode:function(n){i.send(t,"setLightingMode");var o=this.getViewer().IBLManager;n==e.Bimface.Viewer.LightingMode.IBL?this._opt.enableIBLBackground=!0:(this._opt.enableIBLBackground=!1,o.enableIBL(!1))},getLightingMode:function(){return this._opt.enableIBLBackground&&e.Bimface.Viewer.LightingMode.IBL||e.Bimface.Viewer.LightingMode.Phong},loadIBLScene:function(e,n){i.send(t,"loadIBLScene");var o=this,s=this.getViewer().IBLManager,r=this._data,a=r.dataEnvType==_.Local?r.sdkPath:g.staticHost;this._opt.enableIBLBackground&&(s.enableIBL(!0),this._getIBLConfig((function(t){var i=t;i[e]&&(o._opt.loadIBLScene=e,i[e].url=i[e].url.replace(g.staticHost,""),s.loadIBLMaps(`${a}/${i[e].url}`,i[e].isHDR,n,i[e].uniforms),n&&s.setSkyBoxType(e))})))},enableIBLBackground:function(e){i.send(t,"enableIBLBackground");var n=this.getViewer().IBLManager;if(e&&this._opt.enableIBLBackground){var o=this._opt.loadIBLScene;if(o==n.getSkyBoxType())n.addSkyBox(!0);else{var s="resources/IBL/Pics/"+this._opt.loadIBLScene,r=this._data,a=r.dataEnvType==_.Local?r.sdkPath:g.staticHost;n.loadSkyBox(`${a}/${s}`,!0),n.setSkyBoxType(o)}this._opt.IBLSkyBox=!0}else this._opt.IBLSkyBox=!1,n.removeSkyBox()},enableSkyBox:function(e){if(this.console.obsolete("Viewer3D.enableSkyBox","Glodon.Bimface.Plugins.SkyBox.SkyBoxManager.enableSkyBox"),this._opt.enableSkyBox=e,!this._opt.IBLSkyBox){var t=this.getViewer().IBLManager;e?this.setSkyBoxType(this._opt.skyBoxType):this._opt.skyBoxType==t.getSkyBoxType()&&t.removeSkyBox()}},addSkyBox(e){const t=JSON.parse(e),i=t.right,n=t.left,o=t.top,s=t.buttom,r=t.front,a=t.back;i&&n&&o&&s&&r&&a?this._opt.skyBoxUrls=[i,n,o,s,r,a]:this.console.warn('the input url is invalid,should be \'{"front": "front.jpg", "back":"back.jpg", "left":"left.jpg", "right":"right.jpg", "top":"top.jpg", "buttom":"bottom.jpg"}\'')},setSkyBoxType:function(e){if(this.console.obsolete("Viewer3D.setSkyBoxType","Glodon.Bimface.Plugins.SkyBox.SkyBoxManager.setStyle"),!this._opt.enableSkyBox)return;if("CloudySky"!==e&&!this._opt.skyBoxUrls)return void this.console.warn("Customized skyBox must addSkyBox first");this._opt.skyBoxType=e;const t=this.getViewer().IBLManager;let i=[];const n=this._data;if("CloudySky"===e){let e="resources/SkyBox/Pics/"+this._opt.skyBoxType;const t=n.dataEnvType==_.Local?n.sdkPath:g.staticHost,s=["posx.jpg","negx.jpg","posy.jpg","negy.jpg","posz.jpg","negz.jpg"];for(var o=0;o<6;++o)i.push(`${t}/${e}/EnvMap_${s[o]}`)}else i=this._opt.skyBoxUrls;t.loadSkyBox(i,!1),t.setSkyBoxType(this._opt.skyBoxType)},getSkyBoxType:function(){return this.console.obsolete("Viewer3D.getSkyBoxType","Glodon.Bimface.Plugins.SkyBox.SkyBoxManager.getStyle"),this._opt.skyBoxType},getViewToken:function(e,t){this._getFileManager().getViewToken(e,t)},resizePool:function(e){this.getViewer().resizePool(e)},_getMetaDataManager:function(){return this.getDefaultModel()._getMetaDataManager()},_getFileManager:function(){if(this._FileManager)return this._FileManager;var t=new e.Bimface.Data.FileManagerConfig,i=this._data;return t.APIHost=this._opt.APIHost,t.viewToken=i.viewToken,t.databagId=i.databagId,t.modelId=i.modelId,t.modelType=i.modelType,t.dataEnvType=i.dataEnvType,this._FileManager=new e.Bimface.Data.FileManager(t),this._FileManager},setArea:function(e,n,o){i.send(t,"setArea"),this.clearAllRooms(),this.createRoom(e,n,o)},createRoomByOffset:function(e,n,o,s,r,a=!1){if(i.send(t,"createRoomByOffset"),n&&n.length>=2)var l=n[0],h=n[1]-n[0];var d=(e="string"==typeof e?e=JSON.parse(e):e).clone?e.clone():JSON.parse(JSON.stringify(e));if(d.loops&&d.loops.length>0)for(var c=d.loops[0],u=c.length,g=0;g<u;++g)for(var p=c[g].length,m=0;m<p;++m)c[g][m].z+=l;else d.offsetZ+=l;a?this.createRoom(this.globalUnitUtil.revertTranslate(d,["z","x","y","offsetZ"]),this.globalUnitUtil.revertTranslate(h),o,s,r):this.createRoom(d,h,o,s,r)},clearArea:function(){this.console.obsolete("Viewer3D.clearArea","Viewer3D.clearAllRooms"),this.clearAllRooms()},clearAllRooms:function(){i.send(t,"clearAllRooms");var e=this.getViewer();y.ExtrudeBodyManager.getInstance(e).clearNodes(),this.mapCustomizedRoom={}},addArea:function(e,t,i,n,o){return this.console.obsolete("Viewer3D.addArea","Viewer3D.createRoom"),this.createRoom(e,t,i,n,o)},getCustomizedRoom:function(){return this.mapCustomizedRoom},createRoom:function(n,o,s,r,a){i.send(t,"createRoom");const l=Object.prototype.toString.call(n).slice(8,-1);"String"===l?(n=JSON.parse(n),n=this.globalUnitUtil.translate(n,["offsetZ","x","y","z"]),n=JSON.stringify(n)):"Array"===l?n=this.globalUnitUtil.translate(n):"Object"===l&&(n=this.globalUnitUtil.translate(n,["offsetZ","x","y","z"])),o=this.globalUnitUtil.translate(o);s=s||e.Web.Lang.Utility.UUID.createUUID(),r=r||new e.Web.Graphics.Color(50,138,240,.4),a=a||new e.Web.Graphics.Color(50,138,240,1);var h=this.getViewer(),d=y.ExtrudeBodyManager.getInstance(h),c=d.createMaterial({color:parseInt(r.getHEX(),16),transparent:!0,opacity:r.getAlpha()}),u=d.createMaterial({color:parseInt(a.getHEX(),16),opacity:a.getAlpha()});let g,p;if("string"==typeof n&&(n=JSON.parse(n)),n instanceof Array){if(n.length>1)g=(n=this.createBoundary(n[0],n[1]))[1];else{if(!(n.length>0))return;n=this.createBoundary(n[0])}if(p=n[0],!n)return void console.warn("The custom room data is not standard")}return d.addNode(s,n,o,c,u),this.mapCustomizedRoom[s]={boundary:n,offset:[n.offsetZ||0,(n.offsetZ||0)+o],height:o,innerBoundary:g,outerBoundary:p,faceColor:r,frameColor:a},d.bindModel(s,this.getDefaultModel().modelId),this.getViewer().modelManager.updateSceneBoundingBox(),this.updateSceneBoundingBox(!1),s},showAreasById:function(e){this.console.obsolete("Viewer3D.showAreasById","Viewer3D.showRoomsById"),this.showRoomsById(e)},showRoomsById:function(e){i.send(t,"showRoomsById");var n=this.getViewer(),o=y.ExtrudeBodyManager.getInstance(n);if(e&&e.length>0)for(var s=0;s<e.length;s++)o.setNodeVisibleById(e[s],!0)},hideAreasById:function(e){this.console.obsolete("Viewer3D.hideAreasById","Viewer3D.hideRoomsById"),this.hideRoomsById(e)},hideRoomsById:function(e){i.send(t,"hideRoomsById");var n=this.getViewer(),o=y.ExtrudeBodyManager.getInstance(n);if(e&&e.length>0)for(var s=0;s<e.length;s++)o.setNodeVisibleById(e[s],!1)},showAllAreas:function(){this.console.obsolete("Viewer3D.showAllAreas","Viewer3D.showAllRooms"),this.showAllRooms()},showAllRooms:function(){i.send(t,"showAllRooms");var e=this.getViewer();y.ExtrudeBodyManager.getInstance(e).showAllNodes()},hideAllAreas:function(){this.console.obsolete("Viewer3D.hideAllAreas","Viewer3D.hideAllRooms"),this.hideAllRooms()},hideAllRooms:function(){i.send(t,"hideAllRooms");var e=this.getViewer();y.ExtrudeBodyManager.getInstance(e).hideAllNodes()},setAreasColorById:function(e,t){this.console.obsolete("Viewer3D.setAreasColorById","Viewer3D.setRoomsColorById"),this.setRoomsColorById(e,t)},setRoomsColorById:function(e,n){i.send(t,"setRoomsColorById");var o=this.getViewer(),s=this.getCustomizedRoom(),r=y.ExtrudeBodyManager.getInstance(o);if(e&&e.length>0)for(var a=0;a<e.length;a++){if(r.setNodeColorById(e[a],n),e[a]in s)s[e[a]].faceColor=n}},getAreaColorById:function(e){return this.console.obsolete("Viewer3D.getAreaColorById","Viewer3D.getRoomColorById"),this.getRoomColorById(e)},getRoomColorById:function(t){var i=this.getViewer(),n=y.ExtrudeBodyManager.getInstance(i).getNodeColorById(t);return new e.Web.Graphics.Color(n.red,n.green,n.blue,n.alpha)},setAreasFrameColorById:function(e,t){this.console.obsolete("Viewer3D.setAreasFrameColorById","Viewer3D.setRoomsFrameColorById"),this.setRoomsFrameColorById(e,t)},setRoomsFrameColorById:function(e,n){i.send(t,"setRoomsFrameColorById");var o=this.getViewer(),s=this.getCustomizedRoom(),r=y.ExtrudeBodyManager.getInstance(o);if(e&&e.length>0)for(var a=0;a<e.length;a++){if(r.setWireframeColorById(e[a],n),e[a]in s)s[e[a]].frameColor=n}},getAreaFrameColorById:function(e){return this.console.obsolete("Viewer3D.getAreaFrameColorById","Viewer3D.getRoomFrameColorById"),this.getRoomFrameColorById(e)},getRoomFrameColorById:function(t){var i=this.getViewer(),n=y.ExtrudeBodyManager.getInstance(i).getWireframeColorById(t);return new e.Web.Graphics.Color(n.red,n.green,n.blue,n.alpha)},clearAreasById:function(e){this.console.obsolete("Viewer3D.clearAreasById","Viewer3D.clearRoomsById"),this.clearRoomsById(e)},clearRoomsById:function(e){i.send(t,"clearRoomsById");var n=this.getViewer(),o=y.ExtrudeBodyManager.getInstance(n);if(e&&e.length>0)for(var s=0;s<e.length;s++)o.removeNodeById(e[s]),delete this.mapCustomizedRoom[e[s]]},bindRoomByModelId:function(e,n){if(i.send(t,"associateRoomByModelId"),!n||!this.getModel(n))return void this.console.warn(`Invalid modelId [${n}]`);const o=this.getViewer(),s=y.ExtrudeBodyManager.getInstance(o);if(!s.getNode(e))return void this.console.warn(`Invalid roomId [${e}]`);let r=s.getBindedModelId(e);r&&s.unbindModel(e,r),s.bindModel(e,n)},deactivateComponentsById:function(e){return this._viewerMethodWithIdsToModelMethod("deactivateComponentsById",arguments)},deactivateComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("deactivateComponentsByObjectData",arguments)},activateComponentsByObjectData:function(e){return this._viewerMethodToModelMethod("activateComponentsByObjectData",arguments)},activateAllComponents:function(){return this._viewerMethodToVirtualModelMethod("activateAllComponents",arguments),this._viewerMethodToModelMethod("activateAllComponents",arguments,!1)},getLineSelectRange:function(){return this.getViewer().getLineSelectRange()},setLineSelectRange:function(e){this.getViewer().setLineSelectRange(e)},getExternalComponentManager:function(){return this.externalComponentManager&&!this.externalComponentManager.isDestroyed()||(this.externalComponentManager=new y.ExternalComponentManager(this.getViewer()),this.externalComponentManager._objects={}),this.externalComponentManager},getExternalObjectManager:function(){return this.externalObjectManager||(this.externalObjectManager=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this)),this.externalObjectManager},addExternalObject(n,o,s,r){function a(t){return t instanceof e.Bimface.Plugins.Geometry.SplineCurve||t instanceof e.Bimface.Plugins.Geometry.SpatialPlane||t instanceof e.Bimface.Plugins.Geometry.Plane||t instanceof e.Bimface.Plugins.Geometry.Pipe||t instanceof e.Bimface.Plugins.Geometry.Band}i.send(t,"addExternalObject");n=n||e.Web.Lang.Utility.UUID.createUUID();var l=this.getExternalComponentManager();if(l._objects[n])console.warn(`[Viewer3D.addExternalObject] 已有名为 "${n}" 的ExternalObject,请更换名称后再执行Viewer3D.addExternalObject()`);else{if(l._objects[n]=n,a(o)&&(o=o._rebuild?o._rebuild(this):o),l.addNode(n,o,s,r),!a(o)&&!1!==o._externalNeedScale){let e=this.globalUnitUtil.unitMap[this.globalUnitUtil.isBimtilesAsset()?"m":this.globalUnitUtil.getDefaultUnit()],t=this.globalUnitUtil.unitMap[this.globalUnitUtil.getGlobalUnit()],i=this.globalUnitUtil.unitTransMultiplyingMap[`${t}-${e}`];if(1!=i){const[e]=l.meshes[n];if(e){const t=e.matrix.clone();t.multiply((new THREE.Matrix4).makeScale(i,i,i)),t.elements[12]*=i,t.elements[13]*=i,t.elements[14]*=i,l.applyTransformMatrix(n,t,!0)}o.setScale&&o.setScale(i)}}this.getViewer().render()}},addExternalObjects(n,o,s){i.send(t,"addExternalObjects");for(var r=this.getExternalComponentManager(),a=0;a<n.length;a++){var l=e.Web.Lang.Utility.UUID.createUUID();r._objects[l]=l,r.addNode(l,n[a],o,s)}this.getViewer().render()},removeExternalObjectByName(e){i.send(t,"removeExternalObjectByName");var n=this.getExternalComponentManager();delete n._objects[e],n.removeNodeById(e),this.getViewer().render()},clearExternalObjects(){i.send(t,"clearExternalObjects");var e=this.getExternalComponentManager();e._objects={},e.clearNodes(),this.getViewer().render()},getExternalObjectByName(e){return i.send(t,"getExternalObjectByName"),this.getExternalComponentManager().getNodeById(e)},getAllExternalObjects(){return i.send(t,"getAllExternalObjects"),Object.values(this.getExternalComponentManager().getAllNodes())},getDrawingListbyId:function(e,t,i){return this._viewerMethodToModelMethod("getDrawingListbyId",arguments)},getWireframeColor:function(){var t=this.getViewer().getWireframeColor();return new e.Web.Graphics.Color(255*t.r,255*t.g,255*t.b,t.opacity)},setWireframeColor:function(e){return i.send(t,"setWireframeColor"),this.getViewer().setWireframeColor(e)},restoreWireframeColor:function(){i.send(t,"restoreWireframeColor"),this.getViewer().restoreWireframeColor()},setExposureShift:function(e){i.send(t,"setExposureShift");var n=this.getViewer();e>1&&(e=1),e<-1&&(e=-1),this._opt.exposure=e,n.setExposureShift(e)},isSupportSSAO:function(){return this.getViewer().isSupportSSAO()},enableSSAO:function(e){return i.send(t,"enableSSAO"),this.getViewer().enableSSAO(e)},_getIBLConfig:function(t){var i=this,n=i._data;if(i._IBLConfig)t&&t(i._IBLConfig);else{var o=new e.Bimface.Data.IBLManagerConfig;n.dataEnvType==_.Local&&(o.resourceHost=n.sdkPath),new e.Bimface.Data.IBLManager(o).getIBLConfig((function(e){i._IBLConfig=e,t&&t(e)}))}},_beforeInitialize:function(e){y.GlobalData.LimitFrameTime=1e3/e.minimumFPS,y.GlobalData.EnableDemolishByDClick=!1,y.GlobalData.DisableRotation=e.rotation,y.GlobalData.UseMpkWorker=!1,y.GlobalData.ZipResourcePostfix=e.suffix,y.GlobalData.LightIntensityFactor=1.2,y.GlobalData.Hover=e.enableHover,y.GlobalData.MouseMovePick=e.enableMouseMovePick,y.GlobalData.MaxMemeorySizeToFullRender=e.MaxMemeorySizeToFullRender},_config:function(e){this.getViewer().setOrbitButton({Left:"left",Right:"right"}[e.orbitButton])},setRvtBorderLine:function(){this.getViewer().getFilter().setConditions(y.EnumConditionType.BORDERLINE,[{categoryId:I}],modelId)},setBorderLine:function(e){this.getViewer().getFilter().setConditions(y.EnumConditionType.BORDERLINE,e,modelId)},getWorldBox:function(e,t){var i=this.getViewer().getScene().getBoundingBoxWorld();return e&&(i.min.z=e),t&&(i.max.z=t),this.globalUnitUtil.revertBBox(i)},getFloorsbyFileId:function(e,t){return this._viewerMethodToModelMethod("getFloorsbyFileId",arguments)},showAllAxisGrids:function(){return this._viewerMethodToModelMethod("showAllAxisGrids",arguments)},getNearestAxisGrids:function(e,t,i){return this._viewerMethodToModelMethod("getNearestAxisGrids",arguments)},showAxisGridsByFloor:function(e,t,i){return this._viewerMethodToModelMethod("showAxisGridsByFloor",arguments)},showAxisGridsByElevation:function(e,t,i){return this._viewerMethodToModelMethod("showAxisGridsByElevation",arguments)},bringAxisGridsToFront:function(e){return this._viewerMethodToModelMethod("bringAxisGridsToFront",arguments)},removeAxisGridsByFloor:function(e,t,i){return this._viewerMethodToModelMethod("removeAxisGridsByFloor",arguments)},removeAxisGridsByElevation:function(e,t){return this._viewerMethodToModelMethod("removeAxisGridsByElevation",arguments)},getCurrentAxisGridsState:function(){return this._viewerMethodToModelMethod("getCurrentAxisGridsState",arguments)},setGridBubblesColor:function(e){return this._viewerMethodToModelMethod("setGridBubblesColor",arguments)},getGridBubblesColor:function(){return this._viewerMethodToModelMethod("getGridBubblesColor",arguments)},setGridLinesColor:function(e){return this._viewerMethodToModelMethod("setGridLinesColor",arguments)},getGridLinesColor:function(){return this._viewerMethodToModelMethod("getGridLinesColor",arguments)},enableAxisGridsHover:function(e){const t=this.getViewer().getScene();y.AxisGridManager.setEnableHover(t,e)},setAxisGridsState:function(e){return this._viewerMethodToModelMethod("setAxisGridsState",arguments)},_activeAxisGridManager:function(){if(!this.bIsActiveAxisGridManager){var t=new e.Bimface.Plugins.AxisGrid.AxisGridManagerConfig;t.viewer=this;new e.Bimface.Plugins.AxisGrid.AxisGridManager(t);this.bIsActiveAxisGridManager=!0}},showAxisGrid:function(e,t,i){return this._viewerMethodToModelMethod("showAxisGrid",arguments)},removeAxisGrid:function(e,t,i){return this._viewerMethodToModelMethod("removeAxisGrid",arguments)},removeAllAxisGrids:function(){return this._viewerMethodToModelMethod("removeAllAxisGrids",arguments)},addPlane:function(e,n,o,s){i.send(t,"addPlane");var r=this.getViewer();let a=this.globalUnitUtil.translateVector(e),l=this.globalUnitUtil.translateVector(n);r.addPlane.call(r,a,l,o,s)},clearPlane:function(){this.getViewer().clearPlane()},getFloorBoundingBoxById:function(e,t){return this._viewerMethodToModelMethod("getFloorBoundingBoxById",arguments)},getComponentStatus:function(e){return this._viewerMethodToModelMethod("getComponentStatus",arguments)},getMinimumDistanceByIds:function(e,n){return i.send(t,"getMinimumDistanceByIds"),this.console.obsolete("Viewer3D.getMinimumDistanceByIds","Viewer3D.getMinimumComponentDistanceById"),this.getMinimumComponentDistanceById(e,n)},getMinimumComponentDistanceById:function(e,n){return i.send(t,"getMinimumComponentDistanceById"),this.viewerAdapter.calculateMinDistance(e,n)},isEnableToggleContextMenuDisplay:function(){return this._opt.enableToggleContextMenuDisplay},isEnableHover:function(){return this._opt.enableHover},isEnableMouseMovePick:function(){return this._opt.enableMouseMovePick},isEnableBorderLine:function(){return this.console.obsolete("Viewer3D.isEnableBorderLine","Viewer3D.isWireframeEnabled"),this.isWireframeEnabled()},getExposureShift:function(){return this._opt.exposure},getBackgroundColor:function(){return this._opt.backgroundColor},isEnableIBLBackground:function(){return this._opt.enableIBLBackground},getLoadIBLScene:function(){return this._opt.loadIBLScene},getCategoryVisibility:function(e,t){return this._viewerMethodToModelMethod("getCategoryVisibility",arguments)},getSegmentGroups:function(e,t){return this._viewerMethodToModelMethod("getSegmentGroups",arguments,!1)},getSegmentFromGroups:function(e,t,i){return this._viewerMethodToModelMethod("getSegmentFromGroups",arguments,!1)},getSegmentTree:function(e,t){return this._viewerMethodToModelMethod("getSegmentTree",arguments,!1)},getSegmentById:function(e,t,i){return this._viewerMethodToModelMethod("getSegmentById",arguments,!1)},getSegmentElementIds:function(e,t,i){return this._viewerMethodToModelMethod("getSegmentElementIds",arguments,!1)},getPartialElementsMetadata:function(e,t,i){return this._viewerMethodToModelMethod("getPartialElementsMetadata",arguments,!1)},getPartialElementsMetadataFile:function(e){return this._viewerMethodToModelMethod("getPartialElementsMetadataFile",arguments,!1)},getDatabagResource:function(e){return this._viewerMethodToModelMethod("getDatabagResource",arguments,!1)},getSegmentManager:function(){return this.segmentManager||(this.getDefaultModel().isBimtilesModel()?this.segmentManager=new y.BimtilesSegmentManager(this.getViewer()):this.segmentManager=new y.SegmentManager(this.getViewer())),this.segmentManager},getExternalObjectConverter:function(){return this.externalObjectConverter||(this.externalObjectConverter=new y.ExternalObjectConverter(this.getViewer())),this.externalObjectConverter},convertToExternalObject(e,n,o){return i.send(t,"convertToExternalObject"),this.getExternalObjectConverter().convertToExternalObject(e,n,o)},splitComponentByPlane(e,t){return this._viewerMethodToModelMethod("splitComponentByPlane",arguments)},splitComponentByStretchedPlane(e,t){return this._viewerMethodToModelMethod("splitComponentByPlane",arguments)},getExplosionExtent(){return this._viewerMethodToModelMethod("getExplosionExtent",arguments,!1)},loadFloorsForExplosion(){return this._viewerMethodToModelMethod("loadFloorsForExplosion",arguments,!1)},setExplosionExtent(e){return this._viewerMethodToModelMethod("setExplosionExtent",arguments,!1)},setFloorExplosion(e,t,i){return this._viewerMethodToModelMethod("setFloorExplosion",arguments,!1)},getFloorExplosionExtent(){return this._viewerMethodToModelMethod("getFloorExplosionExtent",arguments,!1)},getFloorExplosionDirection(){return this._viewerMethodToModelMethod("getFloorExplosionDirection",arguments,!1)},getFloorExplosionList(){return this._viewerMethodToModelMethod("getFloorExplosionList",arguments,!1)},clearFloorExplosion(){return this._viewerMethodToModelMethod("clearFloorExplosion",arguments,!1)},enableShadow(e){this.console.obsolete("Viewer3D.enableShadow","Glodon.Bimface.Light.DirectionalLight.enableShadow"),this.getViewer().enableShadow(e)},updateShadow(){this.console.obsolete("Viewer3D.updateShadow","Glodon.Bimface.Light.DirectionalLight.update"),this.getViewer().updateShadowMap()},setSnapMode(e){i.send(t,"setSnapMode"),this.snapMode=e},enableSnap(n){if(i.send(t,"enableSnap"),this.getViewer().enableSnap(n),!1===n&&null!=this.snap)this.snap.destroy(),this.snap=null;else if(!0===n&&null==this.snap){var o=new e.Bimface.Plugins.Snap.SnapConfig;o.viewer=this,o.snapMode=this.snapMode,this.snap=new e.Bimface.Plugins.Snap.Snap(o)}},getOutlinerInfo:function(e){return this._viewerMethodToModelMethod("getOutlinerInfo",arguments)},getMepSystem:function(e,t,i){return this._viewerMethodToModelMethod("getMepSystem",arguments)},setBorderLineWithFilter:function(e){return this._viewerMethodToModelMethod("setBorderLineWithFilter",arguments)},_updateManifest(){const e=["HasComponentProperty","HasMaterialProperty","HasMiniMap","HasComponentStructure","HasFileList","HasRoom","HasArea","HasDrawing","HasMEPSystem","HasGroup","HasAssemble","HasLinkRelation","HasFamilyTypeList","HasLayout","HasSplitDrawing"];let t={};this.getModels().forEach((i=>{const n=i._manifest;!i.isEmptyModel&&n&&e.forEach((e=>{t[e]||(t[e]=n.Features[e])}))})),this.getModelCount()>1&&(t.HasFileList=!0),this._manifest.Features=t},setMaximalRangeofCamera:function(e){this.camera3D.setMaximalRange(e)},getCurrentRangeofCamera:function(){return this.camera3D.getCurrentRange()},updateSceneBoundingBox:function(e=!0){const t=y.ExtrudeBodyManager.getInstance(this.getViewer()).getBoundingBox(),i=this.getExternalComponentManager(),n=this.getViewer(),o=n.getScene(),s=i.meshes;var r=n.modelManager.boundingBox.clone();for(var a in t.isEmpty()||(r.expandByPoint(t.min),r.expandByPoint(t.max)),s)for(var l=0;l<s[a].length;l++){var h=s[a][l].box;r.min.x=Math.min(r.min.x,h.min.x),r.min.y=Math.min(r.min.y,h.min.y),r.min.z=Math.min(r.min.z,h.min.z),r.max.x=Math.max(r.max.x,h.max.x),r.max.y=Math.max(r.max.y,h.max.y),r.max.z=Math.max(r.max.z,h.max.z)}o.setBoundingBoxWorld(r),n.getModelManager().updateSceneBoundingBox(),e&&this.getViewer().zoomToBBox(r,.5,void 0,void 0,1e3)},enableShortcutKey:function(e){y.EditorConfig.NoKey=!e},overrideComponentsFrameColorById:function(e,t){return this.console.obsolete("Viewer3D.overrideComponentsFrameColorById","Viewer3D.getModel(modelId).overrideComponentsFrameColor"),this._viewerMethodWithIdsToModelMethod("overrideComponentsFrameColorById",arguments)},restoreComponentsFrameColorById:function(e){return this.console.obsolete("Viewer3D.restoreComponentsFrameColorById","Viewer3D.getModel(modelId).restoreComponentsFrameColor"),this._viewerMethodWithIdsToModelMethod("restoreComponentsFrameColorById",arguments)},overrideComponentsFrameColorByObjectData:function(e,t){return this.console.obsolete("Viewer3D.overrideComponentsFrameColorByObjectData","Viewer3D.getModel(modelId).overrideComponentsFrameColor"),this._viewerMethodToModelMethod("overrideComponentsFrameColorByObjectData",arguments)},restoreComponentsFrameColorByObjectData:function(e){return this.console.obsolete("Viewer3D.restoreComponentsFrameColorByObjectData","Viewer3D.getModel(modelId).restoreComponentsFrameColor"),this._viewerMethodToModelMethod("restoreComponentsFrameColorByObjectData",arguments)},getNestedComponents:function(e){return this._viewerMethodToModelMethod("getNestedComponents",arguments)},getAxisGridsIntersection:function(e,t,i){return this._viewerMethodToModelMethod("getAxisGridsIntersection",arguments)},createRoomByAxisGrids:function(e,t,i,n,o,s){return this._viewerMethodToModelMethod("createRoomByAxisGrids",arguments)},enableGlowEffect:function(e){i.send(t,"enableGlowEffect"),y.GlobalData.EnableGlow=e,this.render()},setGlowEffectById:function(e,t){this._viewerMethodWithIdsToModelMethod("setGlowEffectById",arguments)},removeGlowEffectById:function(e){this._viewerMethodWithIdsToModelMethod("removeGlowEffectById",arguments)},clearGlowEffect:function(){this._viewerMethodToModelMethod("clearGlowEffect",arguments);const e=this._getExternalComponentModel();e&&e.clearGlowEffect()},enableSSAOEffect:function(e){i.send(t,"enableSSAOEffect"),!1===e&&i.send(t,"enableSSAOEffect_false"),y.GlobalData.GTAO=e,this.render()},enableSnowEffect:function(e){i.send(t,"enableSnowEffect"),y.GlobalData.EnableSnowPass=e,this.render()},setSnowEffectOpts:function(e){i.send(t,"setSnowEffectOpts"),this.getViewer().snowOpt(e)},getSnowEffectOpts:function(){return i.send(t,"getSnowEffectOpts"),this.getViewer().snowOpt()},enableFogEffect:function(e){i.send(t,"enableFogEffect"),y.GlobalData.EnableFogPass=e,this.render()},setFogEffectOpts:function(n){i.send(t,"setFogEffectOpts");var o=this.getViewer(),s={darkness:n.darkness,lightAttenuation:n.lightAttenuation,visualSceneDistance:n.visualSceneDistance,visibleSceneDistance:n.visibleSceneDistance,visibleDistanceSet:n.visibleDistanceSet,startSceneDistance:n.startSceneDistance,fogHeight:n.fogHeight};null!=n&&null!=n.fogColor&&(n.fogColor instanceof e.Web.Graphics.Color?s.fogColor=new THREE.Color(n.fogColor.red/255,n.fogColor.green/255,n.fogColor.blue/255):s.fogColor=new THREE.Color(n.fogColor)),o.fogOpt(s),this.render()},getFogEffectOpts:function(){return i.send(t,"getFogEffectOpts"),this.getViewer().fogOpt()},get3DViewStates:function(e){return this._viewerMethodToModelMethod("get3DViewStates",arguments)},getProjectInfo:function(e,n,o){this.console.obsolete("Viewer3D.getProjectInfo","Viewer3D.getModel(modelId).getProjectInfo"),i.send(t,"getProjectInfo"),this._getMetaDataManager(o).getProjectInfo(e,n)},getComponentsByRaycaster(e,t,i){return i||(i=[]),this.viewerAdapter.getComponentsByRaycaster(e,t,i)},enableFullScreen(e){n.Viewer.prototype.enableFullScreen.call(this,e)},closeBimfaceConsole(){this.console.close()},openBimfaceConsole(){this.console.open()},getObjectPosition(){let e=this.getViewer().getCurrentEditor();return this.globalUnitUtil.revertTranslate(e.getObjectPosition?e.getObjectPosition():null,["x","y","z"])},_storeData(t){return new Promise(((i,n)=>{if(!(t instanceof Array))return void n();let o=(t=t.filter((e=>-1===e.indexOf("resource/v3/model")))).map((t=>e.Web.Lang.Utility.HttpRequest.promiseJSONRequest(`${this._opt.resourceHost}/${/\/\/.*?\/(.+?)(\?.+)?$/.exec(t)[1]}`,"noCode",!0)));Promise.allSettled(o).then(i)}))},enableContactShadow(e){if(!0===e)return y.ContactShadow.createInstance(this.getViewer()),void this.render();y.ContactShadow.destroyInstance(),this.render()},isContactShadowEnabled:()=>null!==y.ContactShadow.getInstance(),enableDoubleClickZoom(e){this.getViewer().isEnabledDoubleClick=e},setContactShadow(e){if(!this.isContactShadowEnabled())return void this.console.warn("enableContactShadow before");const t=y.ContactShadow.getInstance();if(e&&e.color){const i=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255);t.setColor(i)}if(e&&void 0!==e.blur&&t.setBlur(e.blur),e&&void 0!==e.height){let i=this.globalUnitUtil.translate(e.height);t.setHeight(i)}this.render()},getContactShadow(){if(!this.isContactShadowEnabled())return void this.console.warn("enableContactShadow before");const t=y.ContactShadow.getInstance(),i=t.getColor();return{color:new e.Web.Graphics.Color(parseInt(255*i.r),parseInt(255*i.g),parseInt(255*i.b),1),blur:t.getBlur(),height:this.globalUnitUtil.revertTranslate(t.getHeight())}},updateContactShadow(){this.isContactShadowEnabled()?(y.ContactShadow.getInstance().update(),this.render()):this.console.warn("enableContactShadow before")},enableWireframe(e){i.send(t,"enableWireframe");var n=this.getViewer();this._opt.enableBorderLine=e,e?n.setDrawingStyle(y.DrawingStyle.SHADINGWITHLINE):n.setDrawingStyle(y.DrawingStyle.SHADING)},isWireframeEnabled:function(){return this._opt.enableBorderLine},getCamera(){return this.camera3D},getUnit(){return"m"===this._defaultUnit?e.Bimface.Common.Units.LengthUnits.Meter:e.Bimface.Common.Units.LengthUnits.Millimeter},getGlobalUnit(){return this.globalUnitUtil.getGlobalUnit()},getDefaultUnit(){return this.globalUnitUtil.getDefaultUnit()},getRoomManager(){if(!this.roomManager){let t=new e.Bimface.Plugins.Rooms.RoomManagerConfig;t.viewer=this,this.roomManager=new e.Bimface.Plugins.Rooms.RoomManager(t)}return this.roomManager},getColorTemperature(){let t=null;if(this.getModel().isBimtilesModel()&&!e.Web.Lang.Utility.ClientHelper.getIsMac()&&this.visualization&&this.visualization.active)switch(this._currentVisualizationMode){case e.Bimface.Viewer.VisualizaionMode.Render:t=[3600,.5];break;case e.Bimface.Viewer.VisualizaionMode.Performance:t=[3800,.5];break;case e.Bimface.Viewer.VisualizaionMode.White:t=[6e3,.5]}return t},setRenderMode(){const t=this.getViewer();t.enableGlobalDiffuseColor(!1),t.setColorSaturation(.9),t.setColorTemperature(3600,.5),t.setColorContrast(0),t.setRenderMode(),this._currentVisualizationMode=e.Bimface.Viewer.VisualizaionMode.Render},setPerformanceMode(){const t=this.getViewer();t.enableGlobalDiffuseColor(!1),t.setColorSaturation(.9),t.setColorTemperature(3800,.5),t.setColorContrast(0),t.setPerformanceMode(),this._currentVisualizationMode=e.Bimface.Viewer.VisualizaionMode.Performance},setWhiteMode(){const t=this.getViewer();t.enableGlobalDiffuseColor(!0),t.setColorSaturation(.4),t.setColorTemperature(6e3,.5),t.setColorContrast(.1),t.setWhiteMode(),this._currentVisualizationMode=e.Bimface.Viewer.VisualizaionMode.White},setAutoExposure(e,t){if(e){let e={Render:{averageLuminance:.7,hdrIncreaseRate:1.5},Performance:{averageLuminance:.5,hdrIncreaseRate:3.5},White:{averageLuminance:.7,hdrIncreaseRate:1.5}},i=e[t]||e.Render;this.getViewer().enableAutoExposure(!0),this.getViewer().rendererManager.renderer.renderEffectOverlay.luminancePostProcesses.defaultLum=i.averageLuminance,this.getViewer().rendererManager.renderer.renderEffectOverlay.luminancePostProcesses.hdrIncreaseRate=i.hdrIncreaseRate}else this.getViewer().enableAutoExposure(!1)},initModeParams(t){this.visualization={};let i={Render:{enableWireframe:!1,enableCSMShadow:!0,exposure:0,enableSSAO:!0,enableEnvMap:!0,envMapStyle:e.Bimface.Plugins.EnvMap.EnvMapStyle.CloudPuresky,enableAutoExposure:!0},Performance:{enableWireframe:!1,enableCSMShadow:!1,exposure:0,enableSSAO:!0,enableEnvMap:!0,envMapStyle:e.Bimface.Plugins.EnvMap.EnvMapStyle.CloudPuresky,enableAutoExposure:!0},White:{enableWireframe:!1,enableCSMShadow:!0,exposure:0,enableSSAO:!0,enableEnvMap:!1,envMapStyle:null,enableAutoExposure:!0}};if(t&&t.visualization){if(this.visualization.active=t.visualization.active,void 0===t.visualization.active&&(this.visualization.active=!0),!e.Web.Lang.Utility.ClientHelper.getIsDesktop())return this.visualization.mode=e.Bimface.Viewer.VisualizaionMode.Performance,void(void 0===t.visualization.mode||t.visualization.mode==e.Bimface.Viewer.VisualizaionMode.Performance?this.visualization.option={...i[this.visualization.mode],..."object"==typeof t.visualization.option?t.visualization.option:{}}:this.visualization.option=i[this.visualization.mode]);t.visualization.mode!==e.Bimface.Viewer.VisualizaionMode.Render&&t.visualization.mode!==e.Bimface.Viewer.VisualizaionMode.Performance&&t.visualization.mode!==e.Bimface.Viewer.VisualizaionMode.White?this.visualization.mode=e.Bimface.Viewer.VisualizaionMode.Render:this.visualization.mode=t.visualization.mode,"object"!=typeof t.visualization.option&&(t.visualization.option={}),this.visualization.option={...i[this.visualization.mode],...t.visualization.option}}else this.visualization.active=!1}}),n.Viewer3D=h}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerGISConfig=class{constructor(){let t=e.Bimface.Viewer.OrbitButton,i="Local"==BimfaceLoaderConfig.dataEnvType?`${BimfaceLoaderConfig.staticHost}Glodon/bimface/resources`:`${BimfaceLoaderConfig.staticHost}/../resources`;const n={domElement:null,resourceHost:g.resourceHost,staticHost:g.staticHost+"/api/Glodon",APIHost:g.APIHost,staticResourcesHost:i,securityApi:g.securityApi,useCustomResources:g.useCustomResources,sdkUrl:null,staticPath:"/api/Glodon",basePoint:null,homeView:null,orbitButton:t.Left,loading:!1,backgroundColor:{direction:Math.PI,colors:[{color:new e.Web.Graphics.Color(88,103,133,1),stop:"0%"},{color:new e.Web.Graphics.Color(229,234,242,1),stop:"100%"}]},enableExplosion:!1,enableLogarithmicDepthBuffer:!0,enableCompassControl:!0,enableScaleBar:!0,enableInfoBar:!0,enableCreditBar:!0,enableStorage:!0,loadIBLScene:{IBLSceneOption:"",withBackground:!1},memoryThreshold:void 0,enableWireframe:null,wireframeColor:null,enableAutoRaiseCamera:!0,enableSSAO:!1,enableCSMShadow:!0,disableMapOcclusion:!1};for(let e in n)this[e]=n[e]}},function(){let t=Object.freeze({Rendered:"Rendered",CameraPositionChanged:"CameraPositionChanged",SceneAdded:"SceneAdded",SceneLoading:"SceneLoading",Error:"Error",ModelAdded:"ModelAdded",ModelRemoved:"ModelRemoved",LayerAdded:"LayerAdded",ViewChanged:"ViewChanged",MouseClicked:"MouseClicked",MouseClickedWithoutMap:"MouseClickedWithoutMap",MouseHover:"MouseHover",MouseMove:"MouseMove",EarthAnimationCompleted:"EarthAnimationCompleted",MouseDraged:"MouseDraged",MouseDoubleClicked:"MouseDoubleClicked",ContextMenu:"ContextMenu",SelectedObjectsChanged:"SelectedObjectsChanged",SelectionChanged:"SelectionChanged",ComponentsHoverChanged:"ComponentsHoverChanged",ComponentsSelectionChanged:"ComponentsSelectionChanged",RectSelection:"RectSelection",ModelTransformed:"ModelTransformed",FloorExplosion:"FloorExplosion",ModelAddFailed:"ModelAddFailed",ModelInitedWithoutLoad:"ModelInitedWithoutLoad",AllModelInited:"AllModelInited",ZoomEnd:"ZoomEnd",Initialized:"Initialized",CurrentViewLoading:"CurrentViewLoading",ViewLoaded:"ViewLoaded",LayerVisibleChanged:"LayerVisibleChanged"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer").ViewerGISEvent=t}();class Y{constructor(e){this._root=e}query(e){return e=this.parseCondition(e),this.getObjectsByCondition(e)}execute(e,t,i){this.query(e).forEach((e=>{"[object Function]"===Object.prototype.toString.call(e[t])&&(i?e[t](...i):e[t]())}))}getObjectsByCondition(e){if(!e)return;let t=[];const i=n=>{let o;for(let t in e){let i,s,r=e[t];switch(t){case"id":case"name":case"typeName":i=t,s=!0;case"noId":case"noName":case"noTypeName":i=i||{noId:"id",noName:"name",noTypeName:"typeName"}[t],s=s||!1,o=n[i]===r?s:!s;break;case"ids":case"names":case"typeNames":i=/(.*)s/.exec(t)[1],s=!0;case"noIds":case"noNames":case"noTypeNames":if(i=i||{noIds:"id",noNames:"name",noTypeNames:"typeName"}[t],s=s||!1,"[object Array]"!==Object.prototype.toString.call(r))return;o=r.indexOf(n[i])>=0?s:!s}if(!o)break}o&&t.push(n),n.children&&n.children.length>0&&n.children.forEach((e=>{i(e)}))};return i(this._root),t}parseCondition(e){let t;return"[object String]"===Object.prototype.toString.call(e)?t=this.codeTocondition(e):"[object Array]"===Object.prototype.toString.call(e)?t=this.codeTocondition(e.join(" ")):"[object Object]"===Object.prototype.toString.call(e)&&(t=e),t}codeTocondition(e){let t={};if("[object String]"===Object.prototype.toString.call(e)){e.split(" ").forEach((e=>{if(0===e.length)return;const i={id:"noId",typeName:"noTypeName",name:"noName",property:"noProperty",userData:"noUserData",ids:"noIds",typeNames:"noTypeNames",names:"noNames",properties:"noProperties"};let n={id:"id",typeName:"typeName",name:"name",property:"property",userData:"userData",ids:"ids",typeNames:"typeNames",names:"names",properties:"properties"};"!"===e[0]&&(e=/!(.*)/.exec(e)[1],n=i),(e=>{const i=(e,i)=>{const o=n[e],s=n["property"===e?"properties":e+"s"];if(t[s])t[s].push(i);else if(t[o]){let e=[t[o],i];delete t[o],t[s]=e}else t[o]=i};switch(e[0]){case"#":i("id",/#(.*)/.exec(e)[1]);break;case".":i("typeName",/\.(.*)/.exec(e)[1]);break;case"(":let t=/\((.*?)\)(.*)/.exec(e);if(t){const[e,n,o]=t;i(n,o)}default:i("name",e)}})(e)}))}return t}}class Z{constructor(t){const i=e.Web.Lang.Utility.DataUtil;this._getDataUtil=()=>i,this.id=i.assertType(t.id,"str")||i.assertType(t.id,"num")?t.id.toString():e.Web.Lang.Utility.UUID.createUUID(),this.name=t.name,this.typeName=t.typeName,this.userData=t.userData,this.isVisible=!1!==t.isVisible,t.viewer&&(this.getViewer=()=>t.viewer),this.children=[];const n=new Y(this);this.getOperationManager=()=>n,P(this)}getId(){return this.id}getName(){return this.name}setName(e){this.name=e}getParent(){return this.parent}getContents(){return this.children}show(e){this.getOperationManager().execute(e,"show")}hide(e){this.getOperationManager().execute(e,"hide")}query(e){return this.getOperationManager().query(e)}add(e,t){this.children.push(e),e.parent=this,this.isVisible||(e.isVisible=this.isVisible),e.getViewer||(e.getViewer=()=>this.getViewer()),e.init&&e.init()}remove(e){if(e instanceof Z){const t=e;t.destroy&&t.destroy();const i=this.children.indexOf(t);i>=0&&this.children.splice(i,1)}else this.getOperationManager().execute(e,"remove")}}class q extends Z{constructor(e){super(e)}updateParentsVisible(){const e=t=>{let i=!1;t.children.some((e=>i=e.isVisible)),t.isVisible=i,t.parent&&e(t.parent)};this.parent&&e(this.parent)}show(){this.isVisible=!0,this.updateParentsVisible(),setTimeout((()=>this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.LayerVisibleChanged,!0)),0)}hide(){this.isVisible=!1,this.updateParentsVisible(),this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.LayerVisibleChanged,!1)}}var K=e.Bimface.Data.StatisticsDataManager.getInstance();class Q extends q{constructor(e){K.send("Glodon.Bimface.Layer.GroupLayer","bf_c_groupLayer_new"),e.typeName="GroupLayer",super(e)}show(){this.children.forEach((e=>{e.show()})),super.show()}hide(){this.children.forEach((e=>{e.hide()})),super.hide()}destroy(){let e=[];this.children.forEach((t=>e.push(t))),e.forEach((e=>{e.destroy()}))}addLayer(e){this.add(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").GroupLayer=Q;class J extends q{constructor(e){e.children=null,super(e),this.priority=e.priority,this.elementManager={}}}class ee{static getTileSource(e){e.provider=ee.parseProvider(e);const{credit:t,url:i,text:n,link:o,copyright:s,provider:r,key:a,parameters:l}=e;if(t===Glodon.Bimface.Common.Credit.Custom)return{credit:t,url:i,text:n,link:o,copyright:s,provider:r,key:a,parameters:l};{let e=this.TileSources[t]||this.TileSources[Glodon.Bimface.Common.Credit.None];return e=Object.assign({},e,{url:i,provider:r,key:a,parameters:l}),e}}static parseProviderByMapUrl(e){return void 0===e||e.indexOf("is.autonavi.com/appmaptile")>-1||e.indexOf("google.cn/vt")>-1||e.indexOf("google.com/vt")>-1||e.indexOf("microsoft.com")>-1||e.indexOf("microsoft.cn")>-1||e.indexOf("tile.openstreetmap.org")>-1||e.indexOf("map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile")>-1?"UrlTemplate":!0===/tianditu.gov.cn.*wmts/.test(e)?"WebMapTileServiceTDU":e.indexOf("tiles.virtualearth.net")>-1?"TileMapBingMapService":e.indexOf("map.gtimg.com/sateTiles")>-1?"TileMapTencentMapService":e.indexOf("bdimg.com")>-1?"BdMapService":"SpecificMapService"}static parseProvider(e){let t;const i=e.mapUrl||e.url;t=void 0===e.provider?ee.parseProviderByMapUrl(i):ee.parseProviderByProtocol(e.provider);const n=ee.fixRequestByProvider(i,t,e.parameters);return e.mapUrl=n,e.url=n,t}static parseProviderByProtocol(e){if(["TileMapBingMapService","WebMapTileServiceTDU","TileMapService","TileMapTencentMapService","WebMapService","WebMapTileService","BdMapService","UrlTemplate"].indexOf(e)>=0)return e;switch(e){case"BingMap":return"TileMapBingMapService";case"Tianditu":return"WebMapTileServiceTDU";case"TMS":return"TileMapService";case"Tencent":return"TileMapTencentMapService";case"WMS":return"WebMapService";case"WMTS":return"WebMapTileService";case"BaiDu":return"BdMapService";default:return"UrlTemplate"}}static fixRequestByProvider(e,t,i){let n=e;switch(t){case"WebMapTileServiceTDU":if(!/tianditu.gov.cn.*wmts.*{x}/.test(e)){const t=e.indexOf("wmts?"),i=t+5,o=t-6,s=e.slice(o,o+3);n=e.slice(0,i)+"SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w"+`&LAYER=${s}&FORMAT=tiles&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}&`+e.slice(i)}break;case"TileMapBingMapService":e.indexOf("tiles.virtualearth.net")>-1&&(n="https://ecn.t0.tiles.virtualearth.net/tiles/a{x}.jpeg?n=z&g=9791");break;case"TileMapTencentMapService":e.indexOf("map.gtimg.com/sateTiles")>-1&&(n="https://p0.map.gtimg.com/sateTiles/{z}/{sx}/{sy}/{x}_{y}.jpg?version=400");break;case"WebMapService":n=e+"?service=WMS&request=GetMap&width=256&height=256&srs=EPSG%3A4326"+`&transparent=${i.transparent}`+`&format=${i.format}`+`&version=${i.version}`+`&styles=${i.styles}`+`&layers=${i.layers}`;break;case"WebMapTileService":(-1===e.indexOf("{x}")||-1===e.indexOf("{y}")&&-1===e.indexOf("{z}"))&&i&&(n=e+"?service=WMTS&request=GetTile"+`&format=${i.format}`+`&tilematrixset=${i.tileMatrixSet}`+`&version=${i.version}`+`&style=${i.style}`+`&layer=${i.layer}&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}`)}return n}static verifyKey(e){return new Promise(((t,i)=>{const n={TileMapTencentMapService:{url:"https://apikey.map.qq.com/mkey/index.php/mkey/check?key={key}&pid=127.0.0.1&channel=0",mkeycb:e=>{e.info&&0===e.info.error&&t(),i(),window.mkeycb=void 0}},TileMapBingMapService:{url:"https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?jsonp=callbackFunction&key={key}&uriScheme=http",callbackFunction:e=>{"ValidCredentials"===e.authenticationResultCode&&t(),i(),window.callbackFunction=void 0}},BdMapService:{url:"http://api.map.baidu.com/?qt=verify&v=3.0&type=webgl&ak={key}&callback=mkeycb",mkeycb:e=>{e&&0===e.error&&t(),i(),window.mkeycb=void 0}}},o=e.provider;let s=n[o]&&n[o].url;if(s)if(e.key){let t=Glodon.Web.Lang.Utility.HttpRequest;s=s.replace("{key}",e.key),window.callbackFunction=n[o].callbackFunction,window.mkeycb=n[o].mkeycb,t.getScript(s)}else i();else t()}))}}function te(e="google",t){e=e.toLowerCase();const i={google:22,openstreetmap:18,arcgis:19,autonavi:19,virtualearth:21};let n;if(Object.keys(i).some((t=>{if(e.indexOf(t)>=0)return n=i[t],!0})),n&&n<t){(new Glodon.Web.Common.Console).warn("The value set is out of the range supported by the map service.")}}ee.TileSources=Object.freeze({Tianditu:{credit:Glodon.Bimface.Common.Credit.Tianditu,text:"服务条款",link:"http://www.tianditu.gov.cn/about/contact.html?type=2",copyright:"天地图"},None:{credit:Glodon.Bimface.Common.Credit.None,text:"",link:"",copyright:""}});var ie=e.Bimface.Data.StatisticsDataManager.getInstance();class ne extends J{constructor(e){ie.send("Glodon.Bimface.Layer.TileLayer","bf_c_tileLayer_new"),e.typeName="TileLayer",e.priority=e.priority||1,e.castShadow=!!y.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!y.Utils.isDefined(e.receiveShadow)||e.receiveShadow,"https:"===window.location.protocol&&(e.url=e.url.replace("http:","https:")),super(e),this._config=e,this.mapStyle={},this.lastValidMapStyle={},this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.clippingManager=null}init(){const t=this._config;let i=this.getViewer().getLayerManager().baseMap;if(i&&i.tileManager){this._isBaseMap=!1,this.tileManager=i.tileManager,this.tileManager=this.getViewer().getLayerManager().baseMap.tileManager;let e={url:t.url,provider:t.layerConfig&&t.layerConfig.customResource&&t.layerConfig.customResource.provider};return e.imageryProviderType=ee.parseProvider(e),this.tileSource=ee.getTileSource({credit:t.credit,url:t.url,provider:t.layerConfig&&t.layerConfig.customResource?t.layerConfig.customResource.provider:void 0}),void(this._imageryId=this.tileManager.addImageryLayer(e))}this._isBaseMap=!0,this.getViewer().getLayerManager().baseMap=this;const n=this.getViewer().getViewer();this.loadMap(),this.getViewer()._camera&&this.getViewer()._camera.init(),this.tileSource=ee.getTileSource({credit:t.credit,url:t.url,provider:t.layerConfig&&t.layerConfig.customResource?t.layerConfig.customResource.provider:void 0});const o=()=>{this.isVisible||this.hide(),this.initSetting(),this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.SceneAdded),n.unregisterEventListener(y.EVENTS.ON_MAP_LOAD_ALL,o)};n.registerEventListener(y.EVENTS.ON_MAP_LOAD_ALL,o)}initSetting(){let e=this._config.style,t=this._config.shadow;e&&y.Utils.isDefined(e.opacity)&&this.setOpacity(e.opacity),t&&y.Utils.isDefined(t.receiveShadow)&&this.enableReceiveShadow(t.receiveShadow)}loadMap(){const t=this._config;t.baseLatLon=t.baseLatLon||this.getViewer()._config.baseLatLon;var i=new e.Bimface.Plugins.TileMap.MapConfig;t.url&&(i.mapUrl=t.url),i.viewer=this.getViewer(),i.modelAltitude=0,i.basePoint={x:0,y:0},i.useTerrain=t.useTerrain||!1,i.provider=t.provider,i.terrainOnlineConfig=t.terrainOnlineConfig,i.maxTerrainLevel=14,i.sectionable=t.sectionable,i.maxLevel=t.maxLevel,t.terrainPath&&(i.terrainPath=t.terrainPath),i.modelRotationZ=0*Math.PI/180,i.modelPosition=[t.baseLatLon.lon,t.baseLatLon.lat],i.mapUrl||(i.mapUrl="https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}&tk=9fe0f60cd462f38c726d9a12565e4524"),t.layerConfig&&t.layerConfig.customResource&&(i.provider=t.layerConfig.customResource.provider),i.imageryProviderType=ee.parseProvider(i);let n={};n.loadConfig=i,n.loadConfig.castShadow=this.castShadow,n.loadConfig.receiveShadow=this.receiveShadow;const o=this.getViewer().getViewer();this.model=o.modelManager.createDemModel(n,!0),this.tileManager=this.model.tileManager,this._imageryId=this.tileManager.getBaseLayerId()}destroy(){this._isBaseMap||(this.tileManager&&this.tileManager.removeImageryLayer(this._imageryId),this.tileManager=null)}show(){this.tileManager.show(this._imageryId),super.show()}hide(){this.tileManager.hide(this._imageryId),super.hide()}useTerrain(e){this.tileManager.applyTerrain(e)}isUseTerrain(){return this.tileManager.isUseTerrain()}setTerrain(e,t){return this.tileManager.setTerrain(e,t)}getTerrain(){return{url:this.tileManager.getTerrain()}}setOpacity(e){e=y.Utils.isDefined(e)?e:1,"[object Number]"===Object.prototype.toString.call(e)&&this.tileManager.setOpacity(e>1?1:e<0?0:e,this._imageryId)}getSource(){return this.tileSource}setSource(e){const t=this.getViewer();this.tileSource=ee.getTileSource(e),this.id===t.firstTileLayerId&&t._creditWidget.update(this.tileSource),this._imageryId=this.tileManager.updateImageryLayer(this._imageryId,{mapUrl:this.tileSource.url,imageryProviderType:this.tileSource.provider}),null==this._imageryId&&(this._imageryId=this.tileManager.addImageryLayer({mapUrl:this.tileSource.url,imageryProviderType:this.tileSource.provider}));t.getViewer().holesManager.updateImageryId(this.id,this._imageryId),t.render()}updateCredit(e){const t=this.getViewer(),i=ee.TileSources[e];t._creditWidget.update(i)}getStyle(){return this.mapStyle}getLastValidMapStyle(){return this.lastValidMapStyle}setLastValidMapStyle(e){this.lastValidMapStyle=Object.assign({},e)}setStyle(t){if(t=t||{},this.mapStyle=Object.assign({},t),"{}"!==JSON.stringify(t)&&(this.lastValidMapStyle=Object.assign({},t)),t.template)switch(t.template){case e.Bimface.Common.ImageStyle.DarkBlue:t.color=new THREE.Vector4(2/255,30/255,88/255,1);break;case e.Bimface.Common.ImageStyle.DarkGreen:t.color=new THREE.Vector4(3/255,63/255,44/255,1);break;case e.Bimface.Common.ImageStyle.CustomColor:if(!t.color)return void console.warn("color is needed when template == Glodon.Bimface.Common.ImageStyle.CustomColor.");t.color=new THREE.Vector4(t.color.red/255,t.color.green/255,t.color.blue/255,t.color.alpha)}if(y.Utils.isDefined(t.brightness)&&(t.brightness+=1,t.brightness=Math.min(Math.max(t.brightness,0),2)),y.Utils.isDefined(t.contrast)){var i=t.contrast+=1;i=Math.min(Math.max(i,0),2),t.contrast=i>1?1+Math.pow(i-1,2):i}y.Utils.isDefined(t.saturation)&&(t.saturation+=1,t.saturation=Math.min(Math.max(t.saturation,0),2)),this.tileManager.setStyle(t,this._imageryId),this.getViewer().render()}restoreStyle(){this.mapStyle={},this.tileManager.setStyle(this.mapStyle,this._imageryId),this.getViewer().render()}setMaxLevel(e){e&&this._getDataUtil().assertType(e,"num")&&(te(this._config.url,e),this.tileManager&&this.tileManager.setMaxLevel(e,this._imageryId))}getMaxLevel(){return this.tileManager.getMaxLevel(this._imageryId)}enableCastShadow(e){e!=this.castShadow&&this.model&&(this.model.setCastShadow(e),this.castShadow=e)}isCastShadowEnabled(){return this.castShadow}enableReceiveShadow(e){this.model&&(this.model.setReceiveShadow(e),this.receiveShadow=e)}isReceiveShadowEnabled(){return this.receiveShadow}getId(){return super.getId()}getModelId(){return y.ObjectGroupType.TILEGROUP}getSenceType(){return e.Bimface.Common.Type.EffectType.MapStyle}getClippingManager(){if(!this.clippingManager){let t=new e.Bimface.Plugins.Clipping.ClippingManagerConfig;t.viewer=this.getViewer(),this.clippingManager=new e.Bimface.Plugins.Clipping.ClippingManager(t)}return this.clippingManager}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").TileLayer=ne;var oe=e.Bimface.Data.StatisticsDataManager.getInstance();class se extends J{constructor(e){oe.send("Glodon.Bimface.Layer.TerrainLayer","bf_c_terrainLayer_new"),e.typeName="TerrainLayer",e.priority=e.priority||1,super(e),this.baseMap=e.baseMap,this.flatManager=null}show(){this.baseMap.useTerrain(!0),super.show(),this.getViewer()._autoRaiseCamera()}hide(){this.baseMap.useTerrain(!1),super.hide()}getId(){return super.getId()}setSource(e,t){if(this.baseMap.isUseTerrain())return this.source=e,this.baseMap.setTerrain(e,t);console.warn("open the terrain firstly")}getSource(){return void 0===this.source?this.baseMap.getTerrain():this.source}getWorldPosition(e,t){if(null==t)return;const i=this.getViewer().getLayerManager().baseMap;if(i&&i.tileManager)if(e.hasOwnProperty("lat")&&e.hasOwnProperty("lon")){let n=i.tileManager.lngLatToWorldPositionWithoutOpenTerrain([e.lon,e.lat],(function(e){Object.is(e.x,NaN)||Object.is(e.y,NaN)?console.warn("[BIMFACE WARNING]:The latitude and longitude are out of the data range."):t(e)}));n&&(Object.is(n.x,NaN)||Object.is(n.y,NaN)?console.warn("[BIMFACE WARNING]:The latitude and longitude are out of the data range."):t(n))}else console.warn("[BIMFACE WARNING]:latLon must contain property lat and lon.")}getFlatManager(){if(!this.flatManager){let t=new e.Bimface.Plugins.Flats.FlatManagerConfig;t.viewer=this.getViewer(),this.flatManager=new e.Bimface.Plugins.Flats.FlatManager(t)}return this.flatManager}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").TerrainLayer=se,function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Model"),i=e.Web.Lang.Utility.DataUtil;class n extends e.Bimface.Model.Model{constructor(t,i,n,o,s){super(t,i,n,o,s),this._container={};let r=new e.Bimface.Plugins.Marker3D.Marker3DContainerConfig;r.viewer=this.getViewer(),r.type="ShpPoint",r.layerId=this._layer.id,this._container.marker3DContainer=new e.Bimface.Plugins.Marker3D.Marker3DContainer(r),this.getCloudViewer().registerEventListener(CLOUD.EVENTS.ON_LOAD_COMPLETE,(e=>{e.modelId&&this.modelId&&e.modelId.toString()===this.modelId.toString()&&(this.cloudModel=this.getCloudViewer().getModelManager().getModel(this.modelId),this.cloudModel.getAllFeature&&(this.points=this.cloudModel.getAllFeature(),this.setStyleByFeatureStyle()))}))}setStyleById(t,n){if(this.points)if(i.assertType(t,"arr"))t.forEach((e=>this.setStyleById(e,n)));else{this._container.marker3DContainer.removeItemById(t);let i,o,s=this.getPositionById(t);if(!s)return;if("dot"===(n=n||{type:"dot",color:new e.Web.Graphics.Color(50,211,166,1),pixelSize:8,outlineColor:new e.Web.Graphics.Color(255,255,255,1),outlineWidth:2}).type){let e=document.createElement("canvas"),t=2;o=t*(n.pixelSize+n.outlineWidth);let s=o/2;e.width=o,e.height=o;let r=e.getContext("2d");r.beginPath(),r.arc(s,s,s,0,2*Math.PI),r.fillStyle=`#${n.outlineColor.getHEX()}`,r.fill(),r.beginPath(),r.arc(s,s,t*n.pixelSize/2,0,2*Math.PI),r.fillStyle=`#${n.color.getHEX()}`,r.fill(),i=e.toDataURL(),o/=t}else{if("img"!==n.type)return;i=n.src,o=n.size}let r={id:t,worldPosition:s,src:i,size:o};this._addMarker3D(r)}}setStyleByObjectData(e,t){i.assertType(e,"arr")&&(e.length>0?this.setStyleById(this.getMatchIds(e),t):this.setStyleById(this.points.map((e=>e.id)),t))}setStyleByFeatureStyle(){if(!this.points)return;this._container.marker3DContainer.clear();this._getMetaDataManager().getFeatureStyle((e=>{let t;if(e&&e.data&&e.data.length>0&&e.data.some((e=>{if("point"===e.type)return t=e.style,!0})),!t)return;let i=t.symbol,n=i.items,o=t.label.field;const s="https://static-test.bimface.com/resources/Icon/FuZhouProject/PointIcon/",r=(e,t,i)=>{e.forEach((e=>{let n=this.getPositionById(e.id),s={id:e.id,worldPosition:n,src:t,size:i};if(o){let t=e.properties&&e.properties[o];t&&(s.tooltip=t)}this._addMarker3D(s)}))};if(i.field)n.forEach((e=>{let t=`${s}${e.iconType}.png`,n=e.iconSize||24,o=this.getPointsByProperty(i.field,e.value);r(o,t,n)}));else{let[e]=n;if(e){let t=`${s}${e.iconType}.png`,i=e.iconSize||24;r(this.points,t,i)}}}))}destroy(){this.cloudModel&&this.cloudModel.destroy(),this.points=null,this._container=null}_addMarker3D(t){let i=new e.Bimface.Plugins.Marker3D.Marker3DConfig;i.tooltipStyle={color:"#fff",backgroundColor:"#20262f",padding:"8px",opacity:.8};for(let e in t)i[e]=t[e];let n=new e.Bimface.Plugins.Marker3D.Marker3D(i);this._container.marker3DContainer.addItem(n)}containerCall(e,...t){for(let i in this._container)this._container[i][e](...t)}getPointsByProperty(e,t){return this.cloudModel.select({key:e,value:t})}setVisible(e){e?this.containerCall("showAllItems"):this.containerCall("hideAllItems"),this.cloudModel.setVisible&&this.cloudModel.setVisible(e)}hideAllComponents(){this.setVisible(!1)}showAllComponents(){this.setVisible(!0)}showComponentsById(e){i.assertType(e,"arr")&&this.containerCall("showItemsById",e)}hideComponentsById(e){i.assertType(e,"arr")&&this.containerCall("hideItemsById",e)}getMatchIds(e){const t=e=>{if(i.assertType(e,"obj"))return this.points.filter((t=>{for(let i in e)if(t.properties[i]!==e[i])return!1;return!0}))};if(i.assertType(e,"arr")){let i=[];return e.forEach((e=>{t(e).forEach((e=>{i.indexOf(e.id)<0&&i.push(e.id)}))})),i}}getObjectData(){if(this.points&&this.points.length>0)return Object.keys(this.points[0].properties)}showComponentsByObjectData(e){i.assertType(e,"arr")&&(e.length>0?this.showComponentsById(this.getMatchIds(e)):this.setVisible(!0))}hideComponentsByObjectData(e){i.assertType(e,"arr")&&(e.length>0?this.hideComponentsById(this.getMatchIds(e)):this.setVisible(!1))}getPositionById(e){let[t]=this.points.filter((t=>t.id===e));if(t){let{x:e,y:i}=t.geometry;return this.getViewer().latLonToWorld({latLon:{lat:i,lon:e}})}}getPropertiesById(e){let[t]=this.points.filter((t=>t.id===e));return t?t.properties:void 0}_executeMarkers(e){i.assertType(e,"func")&&this._container.marker3DContainer.getAllItems().forEach((t=>e(t)))}onClick(e){this._executeMarkers((t=>{t.onClick((()=>e({id:t.getId(),layerId:this._layer.id})))}))}onHover(e){this._executeMarkers((t=>{t.onHover((()=>e({id:t.getId(),layerId:this._layer.id})))}))}onDoubleClick(e){this._executeMarkers((t=>{t.onDoubleClick((()=>e({id:t.getId(),layerId:this._layer.id})))}))}onRightClick(e){this._executeMarkers((t=>{t.onRightClick((()=>e({id:t.getId(),layerId:this._layer.id})))}))}}t.PointModel=n}();class re{}re.xmlns="http://www.w3.org/2000/svg",re.makeCircle=function(e){var t=document.createElementNS(re.xmlns,"circle");return t.style.fill=e.color,t.setAttribute("r",e.radius+""),t.setAttribute("stroke","#FFFFFF"),t.setAttribute("stroke-width",e.strokeWidth),t.setAttribute("transform","translate("+e.position.x+","+e.position.y+")"),t},re.makeConcentricCircle=function(e){var t=document.createElementNS(re.xmlns,"g"),i=document.createElementNS(re.xmlns,"circle");i.style.fill=e.color,i.setAttribute("r",e.innerRadius+""),i.setAttribute("stroke","#FFFFFF"),i.setAttribute("stroke-width",e.innerStrokeWidth),i.setAttribute("transform","translate("+e.position.x+","+e.position.y+")");var n=i.cloneNode();return n.setAttribute("r",e.outerRadius+""),n.setAttribute("stroke-width",e.outerStrokeWidth||0),t.appendChild(n),t.appendChild(i),t},re.makeLine=function(e){var t=document.createElementNS(re.xmlns,"line");return t.setAttribute("stroke",e.color),t.setAttribute("stroke-width",e.lineWidth),t.setAttribute("x1",e.start.x+""),t.setAttribute("y1",e.start.y+""),t.setAttribute("x2",e.end.x+""),t.setAttribute("y2",e.end.y+""),t},re.makeDashLine=function(e){let t=re.makeLine(e);return t.setAttribute("stroke-dasharray",e.dashArray||"10 8"),t},re.makePath=function(e){var t=document.createElementNS(re.xmlns,"path");let i=e.info;return t.setAttribute("d",`M ${i.pointA.x} ${i.pointA.y} A ${e.arcRadius} ${e.arcRadius} 0 0 ${i.direction} ${i.pointB.x} ${i.pointB.y}`),t.setAttribute("fill","rgba(0,0,0,0)"),t.setAttribute("stroke",e.color),t.setAttribute("stroke-width",e.lineWidth),t},re.makePolyline=function(e){var t=document.createElementNS(re.xmlns,"polyline");return t.setAttribute("stroke",e.color),t.setAttribute("stroke-width",e.width),t.style.fill=e.fillColor||"none",t.style.opacity=e.opacity||1,t.setAttribute("points",e.points),t},re.makePolygon=function(e){var t=document.createElementNS(re.xmlns,"polygon");return t.setAttribute("stroke",e.color),t.setAttribute("stroke-width",e.width),t.style.fill=e.fillColor||"none",t.setAttribute("points",e.points),t},re.calcPolylinePoints=function(e){for(var t="",i=0;i<e.length;i++)t+=e[i].x+","+e[i].y+" ";return t},re.makeRectangle=function(e){var t=document.createElementNS(re.xmlns,"rect");return t.setAttribute("stroke-width",2),t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.setAttribute("width",e.width),t.setAttribute("height",e.height),t.setAttribute("rx",e.radius),t.style.fill=e.fillColor||"none",t.setAttribute("fill-opacity",e.fillOpacity||1),t.setAttribute("stroke",e.strokeColor||"none"),t},re.makeMarker=function(e){var t=document.createElementNS(this.xmlns,"marker");t.setAttribute("id",e.id),t.setAttribute("viewBox","0 0 10 10"),t.setAttribute("refX","5"),t.setAttribute("refY","5"),t.setAttribute("markerWidth",e.markerWidth||"6"),t.setAttribute("markerHeight",e.markerHeight||"6"),t.setAttribute("orient","auto-start-reverse");var i=document.createElementNS(this.xmlns,"path");i.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),i.style.fill=e.color,t.appendChild(i);let n=re.makeDefs();return n.appendChild(t),n},re.makeText=function(e){var t=document.createElementNS(re.xmlns,"text");t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.setAttribute("fill",e.color||"#000"),t.setAttribute("font-size",e.fontsize);var i=e.content?e.content.split("\n"):[""];if(i.length>1)for(let o=0;o<i.length;o++){var n=document.createElementNS(re.xmlns,"tspan");n.setAttribute("x",e.x),n.setAttribute("y",e.y+30*o),n.textContent=i[o],t.appendChild(n)}else t.textContent=i[0];return t},re.makeDefs=function(){return document.createElementNS(this.xmlns,"defs")},re.measureText=function(e,t='14px "Microsoft YaHei'){var i=document.createElement("canvas").getContext("2d");return i.font=t,i.measureText(e).width},re.distanceToSegment=function(e,t,i){var o=t.distanceToSquared(i);if(0==o)return e.distanceTo(t);var s=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/o;s=Math.max(0,Math.min(1,s));let r=new n;return r.x=t.x+s*(i.x-t.x),r.y=t.y+s*(i.y-t.y),e.distanceTo(r)},re.isPointInPolygon=function(e,t){let i=0,n=t.length;for(let o=0;o<n;o++){let s=t[o],r=t[(o+1)%n];s.y!=r.y&&(e.y<Math.min(s.y,r.y)||e.y>=Math.max(s.y,r.y)||(e.y-s.y)*(r.x-s.x)/(r.y-s.y)+s.x>e.x&&i++)}return i%2==1},re.isPointInTriangle=function(e,t){const{a:i,b:n,c:o}=t;let s=n.clone().sub(i),r=o.clone().sub(i),a=e.clone().sub(i),l=s.clone().cross(r),h=s.clone().cross(a);return l.dot(h)>=0},re.calcSpatialArea=function(e){if(e.length<3)return 0;let t=0,i=re.getAllTriangle(e);for(let e=0;e<i.length;e++){t+=(new THREE.Triangle).set(i[e][0],i[e][1],i[e][2]).getArea()}return t},re.getAllTriangle=function(e){let t,i,n,o,s,r,a,l,h=[];return t=function(e){if(e.length<3)return;if(3==e.length)return void l(e[0],e[1],e[2]);let o=[e[0],e[1],e[2]],r=[e[0],e[1],e[2]],a=(new THREE.Plane).setFromCoplanarPoints(new THREE.Vector3(e[0].x,e[0].y,e[0].z),new THREE.Vector3(e[1].x,e[1].y,e[1].z),new THREE.Vector3(e[2].x,e[2].y,e[2].z));for(let t=3;t<e.length;t++){if(!i([e[0],e[1],e[2]],e[t]))break;{let i=new THREE.Vector3;if(a.projectPoint(new THREE.Vector3(e[t].x,e[t].y,e[t].z),i),!n([...r,i,r[0]]))break;o.push(e[t]),r.push(i)}}if(o.length>3){s(o);let i=JSON.parse(JSON.stringify(e));if(i.splice(1,o.length-2),2===i.length)return;t(i)}else{l(e[0],e[1],e[2]);let i=JSON.parse(JSON.stringify(e));i.splice(1,1),t(i)}},i=function(e,t){let i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Triangle;o.set(e[0],e[1],e[2]);let s=new THREE.Triangle;s.set(e[0],e[2],t);let r=o.getNormal(i),a=s.getNormal(n),l=r.angleTo(a);return Math.abs(l-3.1415)<2e-4||Math.abs(l)<2e-4},n=function(e){for(let t=0;t<e.length-1;t++)for(let i=t+2;i<e.length-1;i++)if((0!=t||i!=e.length-2)&&o(new THREE.Vector3(e[t].x,e[t].y,e[t].z),new THREE.Vector3(e[t+1].x,e[t+1].y,e[t+1].z),new THREE.Vector3(e[i].x,e[i].y,e[i].z),new THREE.Vector3(e[i+1].x,e[i+1].y,e[i+1].z)))return!1;return!0},o=function(e,t,i,n){const o=1e-5;function s(e,t,i){return!!(CLOUD.Math.lessThanOrEquals(i.x,Math.max(e.x,t.x),o)&&CLOUD.Math.lessThanOrEquals(Math.min(e.x,t.x),i.x,o)&&CLOUD.Math.lessThanOrEquals(i.y,Math.max(e.y,t.y),o)&&CLOUD.Math.lessThanOrEquals(Math.min(e.y,t.y),i.y,o)&&CLOUD.Math.lessThanOrEquals(i.z,Math.max(e.z,t.z),o)&&CLOUD.Math.lessThanOrEquals(Math.min(e.z,t.z),i.z,o))}var r=(new THREE.Vector3).subVectors(t,e),a=(new THREE.Vector3).subVectors(n,i);if(CLOUD.Math.equalsEpsilon(r.dot(a),o))return!1;var l=(new THREE.Vector3).subVectors(i,e),h=(new THREE.Vector3).crossVectors(r,a),d=(new THREE.Vector3).crossVectors(l,a),c=l.dot(h);if(!CLOUD.Math.equalsEpsilon(h.lengthSq(),o)){var u=d.dot(h)/h.lengthSq();if(!CLOUD.Math.lessThan(1,u,o)&&!CLOUD.Math.lessThan(c,0,o)){var g=e.clone().add(new THREE.Vector3(r.x*u,r.y*u,r.z*u));return s(e,t,g)&&s(i,n,g)?g:void 0}}},s=function(e){if(3!==e.length)for(let t=2;t<e.length;t++){let i=[e[t-2],e[t-1],e[t]],n=!1;for(let o=t+1;o<e.length;o++){if(r(i,e[o])){n=!0;break}}let o=new THREE.Vector3;new THREE.Triangle(e[t-2],e[t-1],e[t]).getMidpoint(o);let h=a(e,o);if(!n&&h){l(i[0],i[1],i[2]);let n=JSON.parse(JSON.stringify(e));return n.splice(t-1,1),s(n)}}else l(e[0],e[1],e[2])},r=function(e,t){let i=new THREE.Vector3(e[0].x,e[0].y,e[0].z).sub(new THREE.Vector3(t.x,t.y,t.z)),n=new THREE.Vector3(e[1].x,e[1].y,e[1].z).sub(new THREE.Vector3(t.x,t.y,t.z)),o=new THREE.Vector3(e[2].x,e[2].y,e[2].z).sub(new THREE.Vector3(t.x,t.y,t.z)),s=i.angleTo(n),r=i.angleTo(o),a=n.angleTo(o);return Math.abs(s+r+a-2*Math.PI)<1e-5},a=function(e,t){let i=0,n=(new THREE.Plane).setFromCoplanarPoints(new THREE.Vector3(e[0].x,e[0].y,e[0].z),new THREE.Vector3(e[1].x,e[1].y,e[1].z),new THREE.Vector3(e[2].x,e[2].y,e[2].z));for(let o=0;o<e.length;o++){let s,r=new THREE.Vector3(e[o].x,e[o].y,e[o].z).sub(new THREE.Vector3(t.x,t.y,t.z));s=o===e.length-1?new THREE.Vector3(e[0].x,e[0].y,e[0].z).sub(new THREE.Vector3(t.x,t.y,t.z)):new THREE.Vector3(e[o+1].x,e[o+1].y,e[o+1].z).sub(new THREE.Vector3(t.x,t.y,t.z));let a=r.angleTo(s);!(r.clone().cross(s.clone()).angleTo(n.normal)<Math.PI/2)&&(a*=-1),i+=a}return Math.abs(Math.abs(i)-2*Math.PI)<1e-5},l=function(e,t,i){h.push([e,t,i])},t(e),h},re.calcProjectedArea=function(e){let t=[];return e.forEach((e=>{let i=e.clone();i.z=0,t.push(i)})),this.calcSpatialArea(t)},re.cutFillAnalysis=null,re.calcSurfaceArea=function(e,t,i){let n=0;if(e.length<3||!t)return this.console.warn("Parameter points or viewer is invalid."),n;let o=t.getViewer(),s=e.map((e=>o.worldToDrawing(e))),r=null;if("TilesetLayer"===i){let e=t.getLayerManager().getLayerByType("TilesetLayer");r=[],e.map((e=>r.push(e.id)))}return re.cutFillAnalysis?re.cutFillAnalysis.effectOpt({boundary:s,layerIds:r}):re.cutFillAnalysis=new CLOUD.CutFillMeasure({boundary:s,viewer:t,layerIds:r}),n=re.cutFillAnalysis.getTotalSuperficialArea(),n},re.cutFillAnalysisEarth=null,re.calcSurfaceAreaEarth=function(e,t,i){let n=0;if(e.length<3||!t)return this.console.warn("Parameter points or viewer is invalid."),n;let o=t.getViewer(),s=e.map((e=>o.worldToDrawing(e))),r=null;if("TilesetLayer"===i){let e=t.getLayerManager().getLayerByType("TilesetLayer");r=[],e.map((e=>r.push(e.id)))}return re.cutFillAnalysisEarth?re.cutFillAnalysisEarth.effectOpt({boundary:s,layerIds:r}):re.cutFillAnalysisEarth=new CLOUD.SphereCutFillMeasure({boundary:s,viewer:t,layerIds:r}),n=re.cutFillAnalysisEarth.getTotalSuperficialArea(),n},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Model"),i=e.Web.Lang.Utility.DataUtil;t.LineModel=class{constructor(e,t,i){this.modelId=`${t.modelId}-line`,this.viewer=e,this.cloudViewer=e.getViewer(),this.cloudModel=null,this.dataManager=t.model._getMetaDataManager().dataManager,this.types={polygon:!0},this.loaded=!1,this.lineHeight=i.lineHeight,this.managerVisible=!1,this.cloudViewer.getModelManager().createLineModel({databagId:t.databagId,serverUrl:t.model._opt.resourceHost,rootPath:"metadata/Points.json.gz",modelId:this.modelId,loadConfig:i}),this.cloudViewer.registerEventListener(CLOUD.EVENTS.ON_LOAD_COMPLETE,(e=>{e.modelId&&this.modelId&&e.modelId.toString()===this.modelId.toString()&&(this.cloudModel=this.cloudViewer.getModelManager().getModel(this.modelId),this.features=this.cloudModel.getAllFeature(),this.setStyleByFeatureStyle(),this.viewer.render())}))}destroy(){const e=this.modelId;this.features=null,this.cloudViewer.unload(e)}setVisible(e){this.cloudModel&&this.cloudModel.setVisible(e)}setOutlineVisible(e){this.managerVisible=e,this.cloudModel&&this.cloudModel.setVisible(e)}getOutlineVisible(){return this.managerVisible}setStyleByFeatureStyle(){this.features&&this.dataManager.getFeatureStyle((e=>{if(e&&e.data){if(0===e.data.length){const e={color:new THREE.Color(0,0,0),opacity:1,lineWidth:1,useLineWidth:!1};let t={};for(const e in this.features){this.features[e].geometry.map((i=>{let n=[];i.map((e=>{const t=this.viewer.latLonToWorld({latLon:{lon:e.x,lat:e.y}});n.push(t.x,t.y,this.lineHeight)})),t[e]=n}))}return this.cloudModel.createLineMesh(t,e),this.loaded=!0,this.setVisible(!1),void this.viewer.render()}e.data.some((e=>{if(void 0===this.types[e.type])return;const t=this.features;e.style.items.map((e=>{const i=e.outlineColor,n=this._getLineMaterialColor(i),o=i[3],s=e.outlineWidth,r={color:n,opacity:o,lineWidth:s,useLineWidth:!1},a=e.ids;if(!a)return;let l={};a.map((e=>{const n=t[e];this.features[e].originLineWidth=s,this.features[e].originOutlineColor=i,n.lineWidth=s,n.outlineColor=i;n.geometry.map((t=>{let i=[];t.map((e=>{const t=this.viewer.latLonToWorld({latLon:{lon:e.x,lat:e.y}});i.push(t.x,t.y,this.lineHeight)})),l[e]=i})),n.geometry.length=0})),this.cloudModel.createLineMesh(l,r)}))})),this.loaded=!0,this.setVisible(!1),this.viewer.render()}}),(e=>{console.log(e)}))}_getLineMaterialColor(e){return new THREE.Color(e[0]/255,e[1]/255,e[2]/255)}_classifyIdsByStyle(e,t){let i={};e.map((e=>{let n=this.features[e];if(!n)return;t&&t.color&&(n.outlineColor=[t.color.red,t.color.green,t.color.blue,t.color.alpha]),t&&t.width&&(n.lineWidth=t.width);const o=void 0===t?n.originOutlineColor.toString():n.outlineColor.toString(),s=n.originLineWidth.toString();void 0===i[o]&&(i[o]={}),void 0===i[o][s]?i[o][s]=[e]:i[o][s].push(e)}));let n=[];for(const e in i)for(const o in i[e]){const s=i[e][o];n.push({ids:s,color:void 0===t?this.features[s[0]].originOutlineColor:this.features[s[0]].outlineColor,width:void 0===t?this.features[s[0]].originLineWidth:this.features[s[0]].lineWidth})}return this.styleIdMap=null,n}setStyleByIds(e,t){if(!this.features)return;if(!t.color&&!t.width)return void console.warn("color or lineWidth must in style");let i=this._classifyIdsByStyle(e,t);i.map((e=>{const t=e.ids,i=e.color,n=e.width,o={color:this._getLineMaterialColor(i),opacity:i[3],lineWidth:n};this.cloudModel.updateMaterialByFeatureIds(t,o)})),i.length=0,this.viewer.render()}getMatchIds(e){const t=e=>{if(i.assertType(e,"obj"))return Object.values(this.features).filter((t=>{for(let i in e)if(t.properties[i]!==e[i])return!1;return!0}))};let n=[];return e.forEach((e=>{t(e).forEach((e=>{n.indexOf(e.id)<0&&n.push(e.id)}))})),n}getObjectData(){if(this.features&&this.features.length>0)return Object.keys(this.features[0].properties)}setStyleByObjectData(e,t){if(i.assertType(e,"arr"))if(e.length>0)this.setStyleByIds(this.getMatchIds(e),t);else{const e=Object.keys(this.features);this.setStyleByIds(e,t)}else console.warn("conditions must be array")}restoreStyleByIds(e){if(!this.features)return;let t=this._classifyIdsByStyle(e);t.map((e=>{const t=e.ids,i=e.color,n=e.width,o={color:this._getLineMaterialColor(i),opacity:i[3],lineWidth:n};this.cloudModel.updateMaterialByFeatureIds(t,o),t.map((e=>{let t=this.features[e];t.outlineColor=t.originOutlineColor,t.lineWidth=t.originLineWidth}))})),t.length=0,this.viewer.render()}restoreStyleByObjectData(e){if(i.assertType(e,"arr"))if(e.length>0)this.restoreStyleByIds(this.getMatchIds(e));else{const e=Object.keys(this.features);this.restoreStyleByIds(e)}else console.warn("conditions must be array")}getAreaById(e){if(void 0===e||!this.features)return;let t=this.features[e],i=0;return t._meshList.forEach((e=>{if(e.geometry&&e.geometry.attributes&&e.geometry.attributes.position){let t=e.geometry.attributes.position,n=[];for(let e=0;e<t.count;e++)n.push((new THREE.Vector3).fromBufferAttribute(t,e));i+=re.calcSpatialArea(n)}})),i}}}();class ae extends J{constructor(e){e.typeName=e.typeName,e.id=c.assertType(e.id,"str")||c.assertType(e.id,"num")?e.id:e.modelId,e.priority=e.priority||3,e.isVisible=null==e.isVisible||e.isVisible,e.enableBorderLine=!!e.enableBorderLine||!(!e.style||!0!==e.style.wireframe),e.maxDetailLevel=c.assertType(e.maxDetailLevel,"num")?e.maxDetailLevel:void 0,e.visualRange=e.visualRange,e.disableUserData=!0===e.disableUserData,e.metaData=e.metaData,e.coordinateSystem=e.coordinateSystem,e.castShadow=!!e.castShadow,e.receiveShadow=!!e.receiveShadow,!0===e.enableBorderLine&&(e.wireFrameVisibilityOption=!0),super(e),this._config=e,this.modelId=e.modelId,this.customId=e.customId,this.loaded=!1!==e.isVisible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.presetWireFrameVisible=e.enableBorderLine}init(){const t=this._config;if(!t.viewToken&&!t.modelId&&!t.databagId)return(new e.Web.Common.Console).warn("Invalid Layer Config"),void this.getParent().remove(this);this.loadStatus="inited",!1!==this.loaded?this.loadModel(t):this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,this.layerId)}destroy(t=!0){if("destroyed"!==this.loadStatus&&(this.loadStatus="destroyed",this._modelAddedCallback&&this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,this._modelAddedCallback),this.model&&this.model.destroy(),this.model=void 0,t&&this.getParent())){let e=[],t=this.getParent();for(;t;)e.push(t.id),t=t.getParent();e.reverse().splice(0,2);let i=this.getViewer()._config.resources;if(e.length>0)for(;e.length>0;){let[t]=i.filter((t=>t.id===e[0]));if(!t||!t.children){i=void 0;break}i=t.children,e.splice(0,1)}if(i){let[e]=i.filter((e=>e.id===this.id));if(e){let t=i.indexOf(e);i.splice(t,1)}}this.getParent()&&this.getParent().remove(this)}}getMetaDataByViewToken(t,i,n){const o=this.getViewer();let s=e.Bimface.Authentication.AuthenticationManager,r=new e.Bimface.Authentication.AuthenticationConfig;r.viewToken=t,r.APIHost=o._opt.APIHost,new s(r).authenticate(i,n)}initSetting(){const e=this._config,t=e.shadow,i=e.style,n=e.maxDetailLevel;e.visualRange;t&&CLOUD.Utils.isDefined(t.castShadow)&&this.enableCastShadow(t.castShadow),t&&CLOUD.Utils.isDefined(t.receiveShadow)&&this.enableReceiveShadow(t.receiveShadow),i&&CLOUD.Utils.isDefined(i.opacity)&&this.setOpacity(i.opacity),n&&CLOUD.Utils.isDefined(n)&&this.setMaxDetailLevel(n),i&&i.enableVisualRange&&CLOUD.Utils.isDefined(i.visualRange)&&this.setVisualRange(i.visualRange)}_onLayerLoaded(){this.loadStatus="loaded",this.getViewer()._getLayerLoadedHandlerList().forEach((e=>"loaded"===e.status&&e.handler&&e.handler(this))),this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.LayerAdded,{layerId:this.id,layerName:this.name,layerType:this.typeName,modelId:this.modelId});let t=this.getViewer()._data,i=t.dataEnvType==_.Local?t.sdkPath:hostConfig.staticHost;this.getViewer().getViewer().loadEquirectangularMap(`${i}/resources/EnvMap/MonoCloudPuresky.exr`,!0),this.getViewer().getViewer().setEnvMapIntensity(.3)}loadModel(t){const i="bimTiles",n=this._getModelLoadConfig(t.transformation);null!=t.layerVersion&&(this.layerVersion=t.layerVersion),this.loadStatus="loading";const o=t=>{this.databagId=t.databagId,this.modelId=t.modelId,this.modelType=t.modelType,this.isVisible=null==t.isVisible||t.isVisible,"point"!==this._config.featureType?(t.customId&&(n.modelId=t.customId),this.model=new e.Bimface.Model.BimModel(this.getViewer(),t,i,n,this),this._modelAddedCallback=t=>{if(this.getId()===t){if(this.model.setVisible(this.isVisible),this.initSetting(),this.loadStatus="rendered","shp"===this.model.getModelContent()){let t={lineHeight:0,transformMatrix:new THREE.Matrix4};const i=this.getTransformation();if(t.lineHeight=i[14],1===i[0]&&1===i[5]&&1===i[10]){const e=Math.cos(THREE.Math.degToRad(this.getViewer().getBasePoint().lat)),n=(new THREE.Matrix4).makeScale(e,e,e);t.transformMatrix.fromArray(i).multiply(n),this.setTransformation(t.transformMatrix.elements)}this.lineModel=new e.Bimface.Model.LineModel(this.getViewer(),this,t)}this.getViewer()._getLayerLoadedHandlerList().forEach((e=>"rendered"===e.status&&e.handler&&e.handler(this))),this._config.disableUserData||this._onLayerLoaded()}},this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,this._modelAddedCallback)):this.model=new e.Bimface.Model.PointModel(this.getViewer(),t,i,n,this)},s=e=>(t.customId?this.customId=e.customId=t.customId:this.getViewer().getModels().map((e=>e.modelId.toString())).indexOf(e.modelId.toString())>=0?this.customId=e.customId=this.id:this.customId=void 0,e);if(this.viewToken=t.viewToken,t.databagId){const e={databagId:t.databagId,metaData:this.getViewer()._opt.disableConfigCache?void 0:t.config&&t.config.metadata,coordinateSystem:this.getViewer()._opt.disableConfigCache?void 0:t.config&&t.coordinateSystem,modelId:t.modelId,modelType:t.modelType,viewToken:t.viewToken||this.getViewer()._data.viewToken,isVisible:this.isVisible||t.isVisible,name:t.name,renderType:"3DView",renderVersion:"3.0",count:t.config&&t.config.count};s(e),t.config&&t.config.metadata&&"point"===t.config.metadata.FeatureType&&(this._config.featureType=t.config.metadata.FeatureType),o(e)}else t.viewToken&&this.getMetaDataByViewToken(this.viewToken,(e=>{s(e),e=Object.assign({},e,{isVisible:this.isVisible||t.isVisible}),o(e)}),(t=>{this.getViewer().getEventManager().fireEvent(e.Bimface.Viewer.ViewerGISEvent.Error,t),console.log(t)}))}_getModelLoadConfig(e){let t={zoomAll:!1,enableBorderLine:!!this._config.enableBorderLine||!(!this._config.style||!0!==this._config.style.wireframe),maxDetailLevel:this._config.maxDetailLevel,visualRange:this._config.visualRange,onDemand:this._config.onDemand,condition:this._config.condition,wireFrameVisibilityOption:this._config.componentsFrame,disableUserData:this._config.disableUserData,castShadow:!!this._config.castShadow,receiveShadow:!!this._config.receiveShadow};return e&&16===e.length&&(t.transformMatrix=(new THREE.Matrix4).fromArray(e)),t}debugShowGeometricError(e){let t=this.getViewer().getViewer().getModelManager().getModel(this.modelId);t&&t.debugShowGeometricError(e)}getRootGeoErrDistance(){return this.model&&this.model.getRootGeoErrDistance()}getCoordinateSystem(e){this.model._getMetaDataManager().getModelInfo((t=>{t.coordinateSystem&&e(t.coordinateSystem),t.coordinateSystems&&e(t.coordinateSystems)}),(t=>{e(t)}))}getManifest(e){this.model._getMetaDataManager().getManifest((t=>{e(t)}),(t=>{e(t)}))}getCurrentVersion(){return this.layerVersion}update(e){this.destroy(!1);let t={transformation:null,isVisible:!0};e.viewToken||e.databagId?Object.assign(t,e):Object.assign(t,this._config,e),this._config=t,this.loadModel(t)}getBoundingBox(){return this._getModel().getBoundingBoxWorld()}show(){super.show(),"loading"!==this.loadStatus&&(this.lineModel&&!0===this.lineModel.loaded&&this.lineModel.getOutlineVisible()&&this.lineModel.setVisible(this.isVisible),!0!==this.loaded?(this.loaded=!0,this.init()):this.model.setVisible(this.isVisible))}hide(){this.model&&this.model.setVisible(!1),this.lineModel&&this.lineModel.setVisible(!1),super.hide()}getTransformation(){return this.model.getModelTransformationAdaptedUnit()}setTransformation(e){this.model.setModelTransformation(e)}setTranslation(e){this.model.setModelTranslation(e)}setRotationZ(e,t){this.model.setModelRotationZ(e,t)}setScale(e,t){this.model.setModelScale(e,t)}getBoundaryPoints(){return this._getModel().getBoundaryPoints()}setOpacity(e){e=CLOUD.Utils.isDefined(e)?e:1;let t=Math.min(e,1);t=Math.max(t,0),this._config.opacity=t;let i=this._getModel();i&&i.materialManager&&i.materialManager.setMaterialsOpacity(t)}setExposureCompensation(e){if(isNaN(e))return void console.warn("the exposure compensation input is not a number");if(e<-1||e>1)return void console.warn("the exposure compensation must in [-1, 1]");let t=this._getModel();t&&t.materialManager&&t.setExposureShift(e)}getExposureCompensation(){let e=this._getModel();if(e&&e.materialManager)return e.getExposureShift()}getCategory(){return this._config.category}setCategory(e){this._config.category=Object.assign({},this._config.category,e)}enableCastShadow(e){let t=this._getModel();t&&(t.setCastShadow(e),this.castShadow=e)}isCastShadowEnabled(){return this.castShadow}enableReceiveShadow(e){let t=this._getModel();t&&(t.setReceiveShadow(e),this.receiveShadow=e)}isReceiveShadowEnabled(){return this.receiveShadow}loadBusinessResources(e){if(this._businessResourcesLoaded||!this._config.disableUserData)return;this._businessResourcesLoaded=!0;const t=()=>{this._onLayerLoaded(),e&&e()};requestAnimationFrame((()=>{let e=this._getModel();e&&e.loadBusinessResources&&e.loadBusinessResources(t)}))}getObjectData(){return this.model.getObjectData()}getMaxDetailLevel(){return this.model?this.model.getMaxDetailLevel():this._config.maxDetailLevel}setMaxDetailLevel(e){this._config.maxDetailLevel=e,"point"!==this._config.featureType&&this.model&&this.model.setMaxDetailLevel(e)}setVisualRange(e){this._config.visualRange=e,this.model&&this.model.setVisualRange(e)}getVisualRange(){return this._config.visualRange}setGeometryErrorRatio(e){null!=this.model&&this.model.setDetailRatio(e)}getGeometryErrorRatio(){if(null!=this.model)return this.model.getDetailRatio()}getOpacity(){return this._config.opacity}getId(){return super.getId()}setLocation(e){if(c.assertType(e,"obj")){const{latLon:t,worldPosition:i}=e;let n={},o=!1;if(c.assertType(t,"obj")&&c.assertParamsType(t.lat,t.lon,"num")){const e=this.getViewer().latLonToWorld({latLon:t});n.x=e.x,n.y=e.y,n.z=c.assertType(t.alt,"num")?t.alt:e.z||0,o=!0}else c.assertType(i,"obj")&&c.assertParamsType(i.x,i.y,i.z,"num")&&(n=i,o=!0);if(o){const e=[...this.getTransformation()];e[12]=n.x,e[13]=n.y,e[14]=n.z,this.setTransformation(e)}}}getLocation(){const e=this.getTransformation(),t={x:e[12],y:e[13],z:e[14]},{lat:i,lon:n}=this.getViewer().worldToLatLon(t);return{latLon:{lat:Number(i.toFixed(9)),lon:Number(n.toFixed(9)),alt:Number(e[14].toFixed(3))},worldPosition:t}}getExplosionExtent(){return 0}getModelId(){return this.customId||this.modelId}_getModel(){return this.getViewer().getViewer().getModelManager().getModel(this.getModelId())}}class le extends Z{constructor(e,t){super({id:e,name:e,typeName:e,userData:e}),this._layer=t}}class he extends le{constructor(e){super("RoomManager",e)}}class de extends le{constructor(e,t){super(e,t)}_executeByCondition(e,t){if(!e)return;const i=this._getDataUtil();(e=this._parseCondition(e)).all?i.assertType(t.all,"func")&&t.all():(e.objectData&&e.objectData.length>0&&i.assertType(t.objectData,"func")&&t.objectData(e.objectData),e.ids&&e.ids.length>0&&i.assertType(t.ids,"func")&&t.ids(e.ids),e.noObjectData&&e.noObjectData.length>0&&i.assertType(t.noObjectData,"func")&&t.noObjectData(e.noObjectData),e.noIds&&e.noIds.length>0&&i.assertType(t.noIds,"func")&&t.noIds(e.noIds))}_parseCondition(e){let t;const i=this._getDataUtil();if(i.assertType(e,"str"))t=this._codeToCondition(e);else if(i.assertType(e,"arr")){let n=[],o=[];e.forEach((e=>{i.assertType(e,"obj")?o.push(e):n.push(e)})),t={ids:n,objectData:o}}else i.assertType(e,"obj")&&(t=e);return t}_codeToCondition(e){let t=[],i=[],n=[],o=[];if(this._getDataUtil().assertType(e,"str")){e.split(" ").forEach((e=>{if(0===e.length)return;const s={ids:i,objectData:o};let r={ids:t,objectData:n};"!"===e[0]&&(e=/!(.*)/.exec(e)[1],r=s),(e=>{switch(e[0]){case"#":const t=/#(.*)/.exec(e)[1];r.ids.push(t);break;case"(":let i=/\((.*?)\)(.*)/.exec(e);if(i){const[e,t,n]=i;let o={};o[t]=n,r.objectData.push(o)}}})(e)}))}return{ids:t,noIds:i,objectData:n,noObjectData:o}}getBoundingBox(e){const t=this._layer.model;let i,n=[],o=!1;const s={all:()=>{o=!0},objectData:e=>{n=n.concat(t.getMatchIds(e))},ids:e=>{n=n.concat(e)}};return this._executeByCondition(e,s),i=o?this._layer.getBoundingBox():t.getBoundingBoxByIds(n),i}show(e){const t=this._layer.model,i={all:()=>t.showAllComponents(),objectData:e=>t.showComponentsByObjectData(e),ids:e=>t.showComponentsById(e),noObjectData:e=>t.hideComponentsByObjectData(e),noIds:e=>t.hideComponentsById(e)};this._executeByCondition(e,i)}hide(e){const t=this._layer.model,i={all:()=>t.hideAllComponents(),objectData:e=>t.hideComponentsByObjectData(e),ids:e=>t.hideComponentsById(e),noObjectData:e=>t.showComponentsByObjectData(e),noIds:e=>t.showComponentsById(e)};this._executeByCondition(e,i)}select(e){const t=this._layer.model,i={all:()=>t.addSelectedComponentsByObjectData([]),objectData:e=>t.addSelectedComponentsByObjectData(e),ids:e=>t.addSelectedComponentsById(e),noObjectData:e=>{},noIds:e=>t.removeSelectedId(e)};this._executeByCondition(e,i)}clearSelection(){this._layer.model.clearSelectedComponents()}clearSelected(){this.clearSelection()}overrideColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsColorByObjectData([],t),objectData:e=>i.overrideComponentsColorByObjectData(e,t),ids:e=>i.overrideComponentsColorById(e,t),noObjectData:e=>i.restoreComponentsColorByObjectData(e),noIds:e=>i.restoreComponentsColorById(e)};this._executeByCondition(e,n)}restoreColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsColorByObjectData([]),objectData:e=>t.restoreComponentsColorByObjectData(e),ids:e=>t.restoreComponentsColorById(e)};this._executeByCondition(e,i)}overrideFrameColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsFrameColorByObjectData([],t),objectData:e=>i.overrideComponentsFrameColorByObjectData(e,t),ids:e=>i.overrideComponentsFrameColorById(e,t),noObjectData:e=>i.restoreComponentsFrameColorByObjectData(e),noIds:e=>i.restoreComponentsFrameColorById(e)};this._executeByCondition(e,n)}restoreFrameColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsFrameColorByObjectData([]),objectData:e=>t.restoreComponentsFrameColorByObjectData(e),ids:e=>t.restoreComponentsFrameColorById(e)};this._executeByCondition(e,i)}blink(e,t,i,n){const o=this._layer.model;o.getCloudViewer().enableBlinkComponents(!0);const s={ids:e=>o.addBlinkComponentsById(e,{color:t,interval:i,times:n}),objectData:e=>o.addBlinkComponentsByObjectData(e,{color:t,interval:i,times:n})};this._executeByCondition(e,s)}clearAllBlinkComponents(){this._layer.model.clearAllBlinkComponents()}clearBlinkComponents(e){const t=this._layer.model,i={ids:e=>t.clearBlinkComponentsById(e),objectData:e=>t.clearBlinkComponentsByObjectData(e)};this._executeByCondition(e,i)}isolate(e){const t=this._layer.model,i={objectData:e=>t.isolateComponentsByObjectData(e),ids:e=>t.isolateComponentsById(e)};this._executeByCondition(e,i)}clearIsolation(){this._layer.model.clearIsolation()}setGlowEffectById(e,t){this._layer.model.setGlowEffectById(e,t)}removeGlowEffectById(e){this._layer.model.removeGlowEffectById(e)}clearGlowEffect(){this._layer.model.clearGlowEffect()}setStyle(e,t){const i=this._layer.model;let n=[];const o={all:()=>{n=n.concat(i.getMatchIds([]))},objectData:e=>{n=n.concat(i.getMatchIds(e))},ids:e=>{n=n.concat(e)}};this._executeByCondition(e,o);let s={color:parseInt(t.color.getHEX(),16)};const r=((e,t)=>{const n=i.getCloudViewer().domElement;e.viewportSize=new THREE.Vector2(n.offsetWidth,n.offsetHeight);let o=null;switch(t.fillType){default:case"color":o="fullFill";break;case"grid":switch(t.direction){default:case 0:case 2:o="orthogonalCrossLine";break;case 1:case 3:o="skewCrossLine"}break;case"stripe":switch(t.direction){default:case 0:o="horizontalLine";break;case 1:o="rightDiagonalLine";break;case 2:o="verticalLine";break;case 3:o="leftDiagonalLine"}}return o})(s,t);s.fillMap=CLOUD.MaterialUtil.loadFillMap(r,2);const a=CLOUD.MaterialUtil.createStandardMaterial(s,!1);a.name=`${t.color.getRGB()}${t.fillType}${t.direction}${t.width}`,i.overrideComponentsMaterialById(n,a)}restoreStyle(e){const t=this._layer.model;let i=[];const n={all:()=>{i=i.concat(t.getMatchIds([]))},objectData:e=>{i=i.concat(t.getMatchIds(e))},ids:e=>{i=i.concat(e)}};this._executeByCondition(e,n),t.restoreComponentsMaterialById(i)}getObjectDataById(e){if(this._layer&&"loaded"===this._layer.loadStatus)return this._layer.model.getObjectDataById(e)}}class ce extends de{constructor(e){super("ComponentManager",e)}isolate(e,t){const i=this._layer.model,n={ids:this._getDataUtil().assertType(e.ids,"arr")?[...e.ids]:[],objectData:this._getDataUtil().assertType(e.objectData,"arr")&&e.objectData.length>0?[...e.objectData]:void 0,all:e.all};n.objectData&&(n.ids=n.ids.concat(i.getMatchIds(n.objectData)));const o={all:()=>i.clearIsolation(),ids:e=>i.isolateComponentsById(e,t)};this._executeByCondition(n,o)}clearIsolation(){this.isolate({all:!0})}overrideOpacity(e,t){const i=this._layer.model,n={all:()=>i._overrideAllComponentsOpacityByObjectData([],t),objectData:e=>i.overrideComponentsOpacityByObjectData(e,t),ids:e=>i.overrideComponentsOpacityById(e,t),noObjectData:e=>i.overrideComponentsOpacityByObjectData(e,1),noIds:e=>i.overrideComponentsOpacityById(e,1)};this._executeByCondition(e,n)}restoreOpacity(e){const t=this._layer.model,i={all:()=>t._restoreAllComponentsOpacityByObjectData([]),objectData:e=>t.restoreComponentsOpacityByObjectData(e),ids:e=>t.restoreComponentsOpacityById(e)};this._executeByCondition(e,i)}transparent(e){const t=this._layer.model;t.opaqueAllComponents();const i={all:()=>t.transparentComponentsByObjectData([]),objectData:e=>t.transparentComponentsByObjectData(e),ids:e=>t.transparentComponentsById(e),noObjectData:e=>t.opaqueComponentsByObjectData(e),noIds:e=>t.opaqueComponentsById(e)};this._executeByCondition(e,i)}deactivate(e){const t=this._layer.model;t.activateAllComponents();const i={all:()=>t.deactivateComponentsByObjectData([]),ids:e=>t.deactivateComponentsById(e),objectData:e=>t.deactivateComponentsByObjectData(e)};this._executeByCondition(e,i)}setFrameVisibility(e){this.wireFrameVisibilityOption=e}getFrameVisibility(){return this.wireFrameVisibilityOption}getComponentsBySetId(e,t){this._layer.model.getComponentsBySetId(e,t)}getSetByComponentId(e,t){this._layer.model.getSetByComponentId(e,t)}overrideFrameColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsFrameColorByObjectData([],t),objectData:e=>i.overrideComponentsFrameColorByObjectData(e,t),ids:e=>i.overrideComponentsFrameColorById(e,t),noObjectData:e=>i.restoreComponentsFrameColorByObjectData(e),noIds:e=>i.restoreComponentsFrameColorById(e)};this._executeByCondition(e,n)}restoreFrameColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsFrameColorByObjectData([]),objectData:e=>t.restoreComponentsFrameColorByObjectData(e),ids:e=>t.restoreComponentsFrameColorById(e)};this._executeByCondition(e,i)}splitComponentByStretchedPlane(e,t){return this._layer.model.splitComponentByStretchedPlane(e,t)}splitComponentByPlane(e,t){return this._layer.model.splitComponentByPlane(e,t)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager").ComponentManager=ce;class ue{constructor(e){this.model=e.model,this.metaDataManager=this.model&&this.model._getMetaDataManager()}getCoordinateSystem(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getModelInfo((t=>{t.coordinateSystem&&e(t.coordinateSystem),t.coordinateSystems&&e(t.coordinateSystems)}),(t=>{e(t)}))}getManifest(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getManifest((t=>{e(t)}),(t=>{e(t)}))}getFloors(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getFloors((t=>{e(t)}),(t=>{e(t)}))}getModelTree(e){this.model&&this.model.getModelTree(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface").DataManager=ue;const ge=e.Bimface.Data.StatisticsDataManager.getInstance();class pe extends ae{constructor(e){ge.send("Glodon.Bimface.Layer.BIMLayer","bf_c_bimLayer_new"),e.typeName="BIMLayer",e.castShadow=!!CLOUD.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!CLOUD.Utils.isDefined(e.receiveShadow)||e.receiveShadow,super(e)}init(){super.init(),this.elementManager.componentManager=new ce(this),this.elementManager.roomManager=new he(this),this.getComponentManager=()=>this.elementManager.componentManager,this.getRoomManager=()=>this.elementManager.roomManager,this.dataManager=new ue(this),this.getDataManager=()=>this.dataManager}getFloors(e){this.getDataManager().getFloors(e)}getFloorExplosionList(){return this.getViewer().getViewer().getFloorExplosionList(this.modelId)}getFloorExplosionDirection(){return this.getViewer().getViewer().getFloorExplosionDirection(this.modelId)}getFloorExplosionExtent(){return this.getViewer().getViewer().getFloorExplosionExtent(this.modelId)}setFloorExplosion(e,t,i){this.model&&this.model.setFloorExplosion(e,t,i)}clearFloorExplosion(){this.model&&this.model.clearFloorExplosion()}setWireframeVisible(e){this.presetWireFrameVisible=e,this._setWireframeVisibleByViewer(e)}_setWireframeVisibleByViewer(e){let t=this.getViewer().getViewer().getModelManager().getModel(this.modelId);t&&t.materialManager&&t.setBorderLineVisible(e)}isWireframeVisible(){let e=this.getViewer().getViewer().getModelManager().getModel(this.modelId);if(e&&e.materialManager)return e.isBorderLineVisible()}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").BIMLayer=pe;class me extends de{constructor(e,t){super(e,t)}getFeatureTypeName(){return this.typeName}getObjectDataById(e){return super.getObjectDataById(e)}setGlowEffectById(e,t){super.setGlowEffectById(e,t)}removeGlowEffectById(e){super.removeGlowEffectById(e)}clearGlowEffect(){super.clearGlowEffect()}}class fe extends me{constructor(e){super("PolygonFeatureManager",e)}setOutlineStyle(e,t){const i=this._layer.lineModel;if(!i||!i.loaded)return void console.warn("No outline or not loaded");const n={all:()=>i.setStyleByObjectData([],t),objectData:e=>i.setStyleByObjectData(e,t),ids:e=>i.setStyleByIds(e,t)};this._executeByCondition(e,n)}restoreOutlineStyle(e){const t=this._layer.lineModel;if(!t||!t.loaded)return void console.warn("No outline");const i={all:()=>t.restoreStyleByObjectData([]),objectData:e=>t.restoreStyleByObjectData(e),ids:e=>t.restoreStyleByIds(e)};this._executeByCondition(e,i)}getArea(e){if(void 0===e)return;const t=this._layer.lineModel;if(t&&t.loaded)return t.getAreaById(e);console.warn("No outline or not loaded")}setStyle(e,t){super.setStyle(e,t)}restoreStyle(e){super.restoreStyle(e)}setOutlineVisible(e){const t=this._layer.lineModel;t&&t.loaded&&t.setOutlineVisible(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager").PolygonFeatureManager=fe;class we extends me{constructor(e){super("LineFeatureManager",e)}show(e){return super.show(e)}hide(e){return super.hide(e)}overrideColor(e,t){return super.overrideColor(e,t)}restoreColor(e){return super.restoreColor(e)}overrideFrameColor(e,t){return super.overrideFrameColor(e,t)}restoreFrameColor(e){return super.restoreFrameColor(e)}blink(e,t,i,n){super.blink(e,t,i,n)}clearAllBlinkComponents(){super.clearAllBlinkComponents()}clearBlinkComponents(e){super.clearBlinkComponents(e)}getBoundingBox(e){return super.getBoundingBox(e)}select(e){return super.select(e)}clearSelectedFeatures(){return super.clearSelected()}}class ye extends me{constructor(e){super("PointFeatureManager",e)}show(e){return super.show(e)}hide(e){return super.hide(e)}getIds(e){const t=this._layer.model;if(!t)return;let i=[];const n={all:()=>i=t.points.map((e=>e.id)),objectData:e=>i=t.getMatchIds(e)};return this._executeByCondition(e,n),i}getPosition(e){return this._layer.model.getPositionById(e)}getProperty(e){return this._layer.model.getPropertiesById(e)}setStyle(e,t){const i=this._layer.model,n={all:()=>i.setStyleByObjectData([],t),objectData:e=>i.setStyleByObjectData(e,t),ids:e=>i.setStyleById(e,t)};this._executeByCondition(e,n)}}var ve=e.Bimface.Data.StatisticsDataManager.getInstance();class be extends ae{constructor(e){ve.send("Glodon.Bimface.Layer.FeatureLayer","bf_c_featureLayer_new"),e.typeName="FeatureLayer",e.castShadow=!!CLOUD.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!CLOUD.Utils.isDefined(e.receiveShadow)||e.receiveShadow,super(e)}init(){super.init(),this.elementManager.polygonFeatureManager=new fe(this),this.getPolygonFeatureManager=()=>this.elementManager.polygonFeatureManager,this.elementManager.lineFeatureManager=new we(this),this.getLineFeatureManager=()=>this.elementManager.lineFeatureManager,this.elementManager.pointFeatureManager=new ye(this),this.getPointFeatureManager=()=>this.elementManager.pointFeatureManager,this.dataManager=new ue(this),this.getDataManager=()=>this.dataManager}getLegend(e,t){if(!this.model)return;this.model._getMetaDataManager().getFeatureStyle(e,t)}initSetting(){super.initSetting();const t=this._config.style;if(t&&CLOUD.Utils.isDefined(t.color)){let i=new e.Web.Graphics.Color(t.color);CLOUD.Utils.isDefined(t.opacity)&&(i.alpha=t.opacity),this.getPolygonFeatureManager().overrideColor({all:!0},i)}}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").FeatureLayer=be;class Ee extends ae{constructor(t){e.Bimface.Data.StatisticsDataManager.getInstance().send("Glodon.Bimface.Layer.TilesetLayer","bf_c_tilesetLayer_new"),t.typeName="TilesetLayer",t.castShadow=!!CLOUD.Utils.isDefined(t.castShadow)&&t.castShadow,t.receiveShadow=!CLOUD.Utils.isDefined(t.receiveShadow)||t.receiveShadow,super(t),this.flatManager=null,this.clippingManager=null}init(){super.init(),this.dataManager=new ue(this),this.getDataManager=()=>this.dataManager}isVisible(){return this.isVisible}getOpacity(){return this._config.opacity}getFlatManager(){if(!this.flatManager){let t=new e.Bimface.Plugins.Flats.FlatManagerConfig;t.viewer=this.getViewer(),this.flatManager=new e.Bimface.Plugins.Flats.FlatManager(t)}return this.flatManager}getClippingManager(){if(!this.clippingManager){let t=new e.Bimface.Plugins.Clipping.ClippingManagerConfig;t.viewer=this.getViewer(),this.clippingManager=new e.Bimface.Plugins.Clipping.ClippingManager(t)}return this.clippingManager}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").TilesetLayer=Ee;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").ExternalObjectLayer=class extends J{constructor(t={}){e.Bimface.Data.StatisticsDataManager.getInstance().send("Bimface.Layer.ExternalObjectLayer","bf_c_extObjLayer_new"),t.name=t.name||"外部构件",t.typeName="ExternalObjectLayer",t.priority=t.priority||5,null==t.isVisible&&(t.isVisible=!0),super(t)}_createExternalObjectManager(){var t=this;t._externalObjectManager=new e.Bimface.ElementManager.ExternalObjectManager(t.getViewer(),t.getId())}_hasObjectId(e){return null!=this._externalObjectManager&&-1!==this._externalObjectManager.getAllObjectIds().indexOf(e)}getModelId(){return"ExternalComponent"}getId(){return this.id}getExternalObjectManager(){var e=this;return null==e._externalObjectManager&&null!=e.getViewer()&&(e._createExternalObjectManager(),e.isVisible?e.show():e.hide()),e._externalObjectManager}hide(){const e={ids:this.getExternalObjectManager().getAllObjectIds()};this.getExternalObjectManager().hide(e)}show(){const e={ids:this.getExternalObjectManager().getAllObjectIds()};this.getExternalObjectManager().show(e)}};class Me{constructor(t,i,n){this.viewer3D=t,this.worldPosition=!0===n?null:i,this.clientPosition=!0===n?i:null,this.svgElement=null,this.xmlns="http://www.w3.org/2000/svg",this.glodonColor="#11DAB7",this.gridHighlightColor="#FF7F00",this.observer=function(){},this.entityType="EntityPreviewPoint",this.id=e.Web.Lang.Utility.UUID.createUUID(),this.state="Finished",this.index=0,this.attachLine=null,this.worldHeight=this.worldPosition.z,this.initialize()}initialize(){this.worldPosition?this.clientPosition=this.viewer3D.worldToClient(this.worldPosition):this.worldPosition=this.viewer3D.clientToWorld(this.clientPosition);let e=document.createElementNS(this.xmlns,"circle");e.setAttribute("r",5),e.setAttribute("style","stroke: "+this.glodonColor+"; stroke-width: 1; fill: #ffffff"),e.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")"),this.svgElement=e,this.originPosition=this.clientPosition,this.originWorldPosition=this.worldPosition,this.lastWorldPosition=this.worldPosition}setObserver(e){this.observer=e}setAttachLine(e,t){this.attachLine=e,this.index=t}cancled(){this.state="Finished",this.clientPosition=this.originPosition,this.worldPosition=this.originWorldPosition,this.unSelected(),this.update(!0)}finished(e){this.state="Finished",this.originPosition=this.clientPosition,this.unSelected()}processing(t,i){if(this.state="Processing",i)this.worldPosition=t;else{let i=this.viewer3D.getViewer().pickToPoint(t,5);null!=i?"Line"===i.type&&(i.pickLine instanceof e.Bimface.Plugins.Geometry.SplineCurve||i.pickLine instanceof e.Bimface.Plugins.Entity.PreviewLine)?(this.worldPosition=i.pickPoint,this.worldPosition.z=this.worldHeight):(this.worldPosition=this.viewer3D.sceneToWorld(i.pickPoint),this.worldPosition.z=this.worldHeight):(this.worldPosition=this.viewer3D.sceneToWorld(t),this.worldPosition.z=this.worldHeight)}this.update(!0)}hightlight(){this.svgElement.style.stroke=this.gridHighlightColor}cancelHightlight(){this.svgElement.style.stroke=this.glodonColor}show(){this.svgElement.style.display="block"}hide(){this.svgElement.style.display="none"}selected(){this.svgElement.setAttribute("r",10),this.cancelHightlight()}unSelected(){this.svgElement.setAttribute("r",5)}distanceTo(e){let t=e.x-this.clientPosition.x,i=e.y-this.clientPosition.y;return Math.sqrt(t*t+i*i)}detach(){this.svgElement.parentNode.removeChild(this.svgElement)}update(e){this.clientPosition=this.viewer3D.worldToClient(this.worldPosition),this.svgElement.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")"),this.attachLine.updatePoint(this)}isEqualWith(e){return e.id==this.id}getWorldPosition(){let e=this.worldPosition;return[e.x,e.y,e.z]}getClientPosition(){return new THREE.Vector2(this.clientPosition.x,this.clientPosition.y)}setClientPosition(e){this.clientPosition.x=e.x,this.clientPosition.y=e.y}getSvgElement(){return this.svgElement}clear(){this.detach()}delete(){this.attachLine.deletePoint(this),this.detach()}}class Ce extends y.MeshLine{constructor(t,i,n,o,s){super(),this.entityType="EntityPreviewLine",this.points=void 0!==t?t:[],this.color=void 0!==i?i:new e.Web.Graphics.Color("#32D3A6"),this.width=void 0!==n?n:1,this.style=void 0!==o?o:{lineType:"Continuous",lineStyle:null},this.curveType=void 0!==s?s:"spline",this.divisions=100,this.curve=null,this.points.length>2&&(this.createCurve(),this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1]),this.material.linewidth=this.width,this.material.resolution=new THREE.Vector2(window.innerWidth,window.innerHeight),this.previewPoints=new Map,this.highlightColor="#FF7F00",this._viewer=null}createFromEntity(e){e&&(this.points=e.getPoints(),this.color=e.color,this.width=e.width,this.curveType=e.type,this.id,e.id,this.createCurve(),this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1],this.material.linewidth=this.width,this._viewer=e.viewer)}setColor(t){!t instanceof e.Web.Graphics.Color?console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color"):(this.color=t,this.material.color.setRGB(t.red/255,t.green/255,t.blue/255),this.material.opacity=t.alpha,t.alpha<1||this.material.map?this.material.transparent=!0:this.material.transparent=!1,this.renderOrder=y.GlobalData.IncrementRender?100:-1)}hightlight(){let t=new e.Web.Graphics.Color(this.highlightColor,1);this.material.color.setRGB(t.red/255,t.green/255,t.blue/255)}cancelHightlight(){this.material.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255)}setPreviewPoint(e){null!=e.index&&null!=e.id&&this.previewPoints.set(e.id,e.index)}finished(e){}cancled(){}processing(e){}deletePoint(e){let t=this.previewPoints.get(e.id);this.points.splice(t,1),this.previewPoints.delete(e.id),this.updateIndexInPreviewPoints(t,!0)}addPoint(e){if(this._viewer){let t=new Me(this._viewer,e),i=this.insertPointIndex(e);return i>=0?(this.updateIndexInPreviewPoints(i,!1),t.setAttachLine(this,i),t):null}return null}insertPointIndex(e){let t=this.positionPoints.length,i=new THREE.Box2,n=new THREE.Vector2(e.x,e.y),o=-1;for(let s=0;s<t-1;s++){let t=new THREE.Vector2(this.positionPoints[s].x,this.positionPoints[s].y),r=new THREE.Vector2(this.positionPoints[s+1].x,this.positionPoints[s+1].y);if("polyline"===this.curveType){if(this.pointOnSegment(n,t,r)){for(let t=0;t<this.ctlPointIndexInPosition.length;t++){let i=this.ctlPointIndexInPosition[t];if(s<=i.pos){this.points.splice(i.index,0,e),o=i.index;break}}break}}else if(i.makeEmpty(),i.expandByPoint(t),i.expandByPoint(r),i.containsPoint(n)){for(let t=0;t<this.ctlPointIndexInPosition.length;t++){let i=this.ctlPointIndexInPosition[t];if(s<=i.pos){this.points.splice(i.index,0,e),o=i.index;break}}break}}return i=null,o}pointOnSegment(e,t,i){return!!(y.Math.equalsEpsilon((e.x-t.x)*(i.y-t.y),(i.x-t.x)*(e.y-t.y),.1)&&y.Math.lessThanOrEquals(Math.min(t.x,i.x),e.x,.1)&&y.Math.lessThanOrEquals(e.x,Math.max(t.x,i.x),.1)&&y.Math.lessThanOrEquals(Math.min(t.y,i.y),e.y,.1)&&y.Math.lessThanOrEquals(e.y,Math.max(t.y,i.y),.1))}checkPointContains(e,t,i){return!!(y.Math.lessThanOrEquals(Math.min(t.x,i.x),e.x,.1)&&y.Math.lessThanOrEquals(e.x,Math.max(t.x,i.x),.1)&&y.Math.lessThanOrEquals(Math.min(t.y,i.y),e.y,.1)&&y.Math.lessThanOrEquals(e.y,Math.max(t.y,i.y),.1))}updateIndexInPreviewPoints(e,t){this.previewPoints.forEach(((i,n)=>{i>=e&&(t?(i-=1)<=0&&(i=0):i+=1)}))}updatePoint(e){this.points[e.index]=e.worldPosition,this.updateGeo()}createCurve(){var e=this.points;if(e.length<2)return;for(var t=[],i=0,n=e.length;i<n;i++)t.push(new THREE.Vector3(e[i].x,e[i].y,e[i].z));this.curve=new THREE.CatmullRomCurve3(t),this.curve.tension="polyline"==this.curveType?0:.5,this.curve.curveType="catmullrom";let o=10*e.length,s=[];this.positionPoints=[],this.ctlPointIndexInPosition=[];let r=new Map,a=new THREE.Box2,l=this.curve.getPoints(o),h=-1;for(let e=0;e<this.points.length-1;e++){let t=new THREE.Vector2(this.points[e].x,this.points[e].y),i=new THREE.Vector2(this.points[e+1].x,this.points[e+1].y);h=-1,a.makeEmpty(),a.expandByPoint(t),a.expandByPoint(i);for(let n=0;n<l.length;n++){if(0===e&&(s.push(l[n].x,l[n].y,l[n].z),this.positionPoints.push(l[n])),null!=r.get(n))continue;let o=new THREE.Vector2(l[n].x,l[n].y);"polyline"===this.curveType?this.checkPointContains(o,t,i)&&(r.set(n,""),h=n):a.containsPoint(o)&&(r.set(n,""),h=n)}-1!=h&&this.ctlPointIndexInPosition.push({pos:h,index:e+1})}a=null,r=null,this.geometry.setPositions(s),this.material.totalSize=this.geometry.totalSize,this.setColor(this.color)}updateGeo(){this.geometry.dispose(),this.material.dispose(),this.curve=null,this.createCurve()}dispose(){this.geometry.dispose(),this.material.dispose(),this.points=[],this.curve=null,this.geometry=null,this.material=null,this.color=null,this.width=null,this.style=null,this.startPoint=null,this.endPoint=null}clear(){this.dispose()}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Entity").PreviewLine=Ce;var xe=function(e,t,i){void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document);let n=e,o=i.getViewer().getScene();this.sceneMatrix=(new THREE.Matrix4).getInverse(o.getMatrixGlobal()),this.viewer=i,THREE.Object3D.call(this),this.visible=!1,this.domElement=t;var s=new Te;this.add(s);var r=new Pe;this.add(r);var a=this;z("camera",n),z("object",void 0),z("enabled",!0),z("axis",null),z("mode","translate"),z("translationSnap",null),z("rotationSnap",null),z("scaleSnap",null),z("space","world"),z("size",1),z("dragging",!1),z("showX",!0),z("showY",!0),z("showZ",!0);var l={type:"change"},h={type:"mouseDown"},d={type:"mouseUp",mode:a.mode},c={type:"objectChange"},u=new THREE.Raycaster;function g(e,t,i){for(var n=t.intersectObject(e,!0),o=0;o<n.length;o++)if(n[o].object.visible||i)return n[o];return!1}var p=new THREE.Vector3,m=new THREE.Vector3,f=new THREE.Quaternion,w={X:new THREE.Vector3(1,0,0),Y:new THREE.Vector3(0,1,0),Z:new THREE.Vector3(0,0,1)},y=new THREE.Vector3,v=new THREE.Vector3,b=new THREE.Vector3,E=new THREE.Vector3,M=new THREE.Vector3,C=new THREE.Vector3,x=0,T=new THREE.Vector3,P=new THREE.Quaternion,I=new THREE.Vector3,S=new THREE.Vector3,B=new THREE.Quaternion,_=new THREE.Quaternion,L=new THREE.Vector3,D=new THREE.Vector3,A=new THREE.Quaternion,V=new THREE.Vector3,R=new THREE.Vector3,O=new THREE.Quaternion,k=new THREE.Quaternion,H=new THREE.Vector3,U=new THREE.Vector3,N=new THREE.Vector3,G=new THREE.Quaternion,j=new THREE.Vector3;function z(e,t){var i=t;Object.defineProperty(a,e,{get:function(){return void 0!==i?i:t},set:function(t){i!==t&&(i=t,r[e]=t,s[e]=t,a.dispatchEvent({type:e+"-changed",value:t}),a.dispatchEvent(l))}}),a[e]=t,r[e]=t,s[e]=t}function F(e){if(a.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};var i=e.changedTouches?e.changedTouches[0]:e,n=t.getBoundingClientRect();return{x:(i.clientX-n.left)/n.width*2-1,y:-(i.clientY-n.top)/n.height*2+1,button:e.button}}function W(e){if(a.enabled)switch(e.pointerType){case"mouse":case"pen":a.pointerHover(F(e))}}function $(e){a.enabled&&(a.domElement.style.touchAction="none",a.domElement.ownerDocument.addEventListener("pointermove",X),a.pointerHover(F(e)),a.pointerDown(F(e)))}function X(e){a.enabled&&a.pointerMove(F(e))}function Y(e){a.enabled&&(a.domElement.style.touchAction="",a.domElement.ownerDocument.removeEventListener("pointermove",X),a.pointerUp(F(e)))}z("worldPosition",R),z("worldPositionStart",D),z("worldQuaternion",O),z("worldQuaternionStart",A),z("cameraPosition",T),z("cameraQuaternion",P),z("pointStart",y),z("pointEnd",v),z("rotationAxis",E),z("rotationAngle",x),z("eye",U),t.addEventListener("pointerdown",$),t.addEventListener("pointermove",W),a.domElement.ownerDocument.addEventListener("pointerup",Y),this.dispose=function(){t.removeEventListener("pointerdown",$),t.removeEventListener("pointermove",W),a.domElement.ownerDocument.removeEventListener("pointermove",X),a.domElement.ownerDocument.removeEventListener("pointerup",Y),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))},this.attach=function(e){return this.object=e,this.visible=!1,this.updateMatrixWorld(),this},this.detach=function(){return this.object=void 0,this.visible=!1,this.axis=null,this},this.updateMatrixWorld=function(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrix.decompose(S,B,L),this.object.matrix.decompose(R,O,H),_.copy(B).inverse(),k.copy(O).inverse()),this.camera.matrixWorld.multiply(this.sceneMatrix),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(T,P,I),U.copy(T).sub(R).normalize(),THREE.Object3D.prototype.updateMatrixWorld.call(this)},this.pointerHover=function(e){void 0!==this.object&&!0!==this.dragging&&(this.axis="XYZ")},this.setRay=function(e,t){t instanceof CLOUD.CombinedCamera?t.isPerspective?(u.ray.origin.copy(t.position),u.ray.direction.set(e.x,e.y,.5).unproject(t).sub(t.position).normalize()):(u.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),u.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld)):t instanceof THREE.PerspectiveCamera?(u.ray.origin.copy(t.position),u.ray.direction.set(e.x,e.y,.5).unproject(t).sub(t.position).normalize()):t instanceof THREE.OrthographicCamera?(u.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),u.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld)):console.error("CLOUD.Raycaster: Unsupported camera type.")},this.pointerDown=function(e){if(void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis){this.setRay(e,this.camera);var t=g(r,u,!0);if(t){var i=this.space;if("scale"===this.mode?i="local":"E"!==this.axis&&"XYZE"!==this.axis&&"XYZ"!==this.axis||(i="world"),"local"===i&&"rotate"===this.mode){var n=this.rotationSnap;"X"===this.axis&&n&&(this.object.rotation.x=Math.round(this.object.rotation.x/n)*n),"Y"===this.axis&&n&&(this.object.rotation.y=Math.round(this.object.rotation.y/n)*n),"Z"===this.axis&&n&&(this.object.rotation.z=Math.round(this.object.rotation.z/n)*n)}this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),N.copy(this.object.position),G.copy(this.object.quaternion),j.copy(this.object.scale),this.object.matrix.decompose(D,A,V),y.copy(t.point).sub(D)}this.dragging=!0,h.mode=this.mode,this.dispatchEvent(h)}},this.pointerMove=function(e){var t=this.axis,i=this.mode,n=this.object,o=this.space;if("scale"===i?o="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(o="world"),void 0!==n&&null!==t&&!1!==this.dragging&&-1===e.button){this.setRay(e,this.camera);var s=g(r,u,!0);if(s){if(v.copy(s.point).sub(D),"translate"===i)b.copy(v).sub(y),"local"===o&&"XYZ"!==t&&b.applyQuaternion(k),-1===t.indexOf("X")&&(b.x=0),-1===t.indexOf("Y")&&(b.y=0),-1===t.indexOf("Z")&&(b.z=0),"local"===o&&"XYZ"!==t?b.applyQuaternion(G).divide(L):b.applyQuaternion(_).divide(L),n.position.copy(b).add(N),this.translationSnap&&("local"===o&&(n.position.applyQuaternion(f.copy(G).inverse()),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(G)),"world"===o&&(n.parent&&n.position.add(p.setFromMatrixPosition(n.parent.matrixWorld)),-1!==t.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(p.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==t.search("XYZ")){var a=v.length()/y.length();v.dot(y)<0&&(a*=-1),m.set(a,a,a)}else p.copy(y),m.copy(v),p.applyQuaternion(k),m.applyQuaternion(k),m.divide(p),-1===t.search("X")&&(m.x=1),-1===t.search("Y")&&(m.y=1),-1===t.search("Z")&&(m.z=1);n.scale.copy(j).multiply(m),this.scaleSnap&&(-1!==t.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){b.copy(v).sub(y);var h=20/R.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));"E"===t?(E.copy(U),x=v.angleTo(y),M.copy(y).normalize(),C.copy(v).normalize(),x*=C.cross(M).dot(U)<0?1:-1):"XYZE"===t?(E.copy(b).cross(U).normalize(),x=b.dot(p.copy(E).cross(this.eye))*h):"X"!==t&&"Y"!==t&&"Z"!==t||(E.copy(w[t]),p.copy(w[t]),"local"===o&&p.applyQuaternion(O),x=b.dot(p.cross(U).normalize())*h),this.rotationSnap&&(x=Math.round(x/this.rotationSnap)*this.rotationSnap),this.rotationAngle=x,"local"===o&&"E"!==t&&"XYZE"!==t?(n.quaternion.copy(G),n.quaternion.multiply(f.setFromAxisAngle(E,x)).normalize()):(E.applyQuaternion(_),n.quaternion.copy(f.setFromAxisAngle(E,x)),n.quaternion.multiply(G).normalize())}this.dispatchEvent(l),this.dispatchEvent(c)}}},this.pointerUp=function(e){0===e.button&&(this.dragging&&null!==this.axis&&(d.mode=this.mode,this.dispatchEvent(d)),this.dragging=!1,this.axis=null)},this.getMode=function(){return a.mode},this.setMode=function(e){a.mode=e},this.setTranslationSnap=function(e){a.translationSnap=e},this.setRotationSnap=function(e){a.rotationSnap=e},this.setScaleSnap=function(e){a.scaleSnap=e},this.setSize=function(e){a.size=e},this.setSpace=function(e){a.space=e},this.update=function(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}};xe.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:xe,isTransformControls:!0});var Te=function(){THREE.Object3D.call(this),this.type="TransformControlsGizmo";var e=new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:THREE.DoubleSide,fog:!1,toneMapped:!1}),t=new THREE.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),i=e.clone();i.opacity=.15;var n=e.clone();n.opacity=.33;var o=e.clone();o.color.set(16711680);var s=e.clone();s.color.set(65280);var r=e.clone();r.color.set(255);var a=e.clone();a.opacity=.25;var l=a.clone();l.color.set(16776960);var h=a.clone();h.color.set(65535);var d=a.clone();d.color.set(16711935),e.clone().color.set(16776960);var c=t.clone();c.color.set(16711680);var u=t.clone();u.color.set(65280);var g=t.clone();g.color.set(255);var p=t.clone();p.color.set(65535);var m=t.clone();m.color.set(16711935);var f=t.clone();f.color.set(16776960);var w=t.clone();w.color.set(7895160);var y=f.clone();y.opacity=.25;var v=new THREE.CylinderGeometry(0,.05,.2,12,1,!1),b=new THREE.BoxGeometry(.125,.125,.125),E=new THREE.BufferGeometry;E.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,0,0],3));var M,C=function(e,t){for(var i=new THREE.BufferGeometry,n=[],o=0;o<=64*t;++o)n.push(0,Math.cos(o/32*Math.PI)*e,Math.sin(o/32*Math.PI)*e);return i.addAttribute("position",new THREE.Float32BufferAttribute(n,3)),i},x={X:[[new THREE.Mesh(v,o),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new THREE.Mesh(v,o),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new THREE.Line(E,c)]],Y:[[new THREE.Mesh(v,s),[0,1,0],null,null,"fwd"],[new THREE.Mesh(v,s),[0,1,0],[Math.PI,0,0],null,"bwd"],[new THREE.Line(E,u),null,[0,0,Math.PI/2]]],Z:[[new THREE.Mesh(v,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new THREE.Mesh(v,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new THREE.Line(E,g),null,[0,-Math.PI/2,0]]],XYZ:[[new THREE.Mesh(new THREE.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new THREE.Mesh(new THREE.PlaneGeometry(.295,.295),l.clone()),[.15,.15,0]],[new THREE.Line(E,f),[.18,.3,0],null,[.125,1,1]],[new THREE.Line(E,f),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new THREE.Mesh(new THREE.PlaneGeometry(.295,.295),h.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new THREE.Line(E,p),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new THREE.Line(E,p),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new THREE.Mesh(new THREE.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new THREE.Line(E,m),[.18,0,.3],null,[.125,1,1]],[new THREE.Line(E,m),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},T={X:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),i),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),i),[0,.6,0]]],Z:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,1,4,1,!1),i),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new THREE.Mesh(new THREE.OctahedronGeometry(.2,0),i)]],XY:[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),i),[.2,.2,0]]],YZ:[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),i),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new THREE.Mesh(new THREE.PlaneGeometry(.4,.4),i),[.2,0,.2],[-Math.PI/2,0,0]]]},P={START:[[new THREE.Mesh(new THREE.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new THREE.Mesh(new THREE.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new THREE.Line((M=new THREE.BufferGeometry,M.addAttribute("position",new THREE.Float32BufferAttribute([0,0,0,1,1,1],3)),M),n),null,null,null,"helper"]],X:[[new THREE.Line(E,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new THREE.Line(E,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new THREE.Line(E,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},I={X:[[new THREE.Line(C(1,.5),c)],[new THREE.Mesh(new THREE.OctahedronGeometry(.04,0),o),[0,0,.99],null,[1,3,1]]],Y:[[new THREE.Line(C(1,.5),u),null,[0,0,-Math.PI/2]],[new THREE.Mesh(new THREE.OctahedronGeometry(.04,0),s),[0,0,.99],null,[3,1,1]]],Z:[[new THREE.Line(C(1,.5),g),null,[0,Math.PI/2,0]],[new THREE.Mesh(new THREE.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new THREE.Line(C(1.25,1),y),null,[0,Math.PI/2,0]],[new THREE.Mesh(new THREE.CylinderGeometry(.03,0,.15,4,1,!1),y),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new THREE.Mesh(new THREE.CylinderGeometry(.03,0,.15,4,1,!1),y),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new THREE.Mesh(new THREE.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new THREE.Mesh(new THREE.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new THREE.Line(C(1,1),w),null,[0,Math.PI/2,0]]]},S={AXIS:[[new THREE.Line(E,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},B={X:[[new THREE.Mesh(new THREE.TorusGeometry(1,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.TorusGeometry(1,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new THREE.Mesh(new THREE.TorusGeometry(1,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new THREE.Mesh(new THREE.TorusGeometry(1.25,.1,2,24),i)]],XYZE:[[new THREE.Mesh(new THREE.SphereGeometry(.7,10,8),i)]]},_={X:[[new THREE.Mesh(b,o),[.8,0,0],[0,0,-Math.PI/2]],[new THREE.Line(E,c),null,null,[.8,1,1]]],Y:[[new THREE.Mesh(b,s),[0,.8,0]],[new THREE.Line(E,u),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new THREE.Mesh(b,r),[0,0,.8],[Math.PI/2,0,0]],[new THREE.Line(E,g),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new THREE.Mesh(b,l),[.85,.85,0],null,[2,2,.2]],[new THREE.Line(E,f),[.855,.98,0],null,[.125,1,1]],[new THREE.Line(E,f),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new THREE.Mesh(b,h),[0,.85,.85],null,[.2,2,2]],[new THREE.Line(E,p),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new THREE.Line(E,p),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new THREE.Mesh(b,d),[.85,0,.85],null,[2,.2,2]],[new THREE.Line(E,m),[.855,0,.98],null,[.125,1,1]],[new THREE.Line(E,m),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new THREE.Mesh(new THREE.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new THREE.Mesh(new THREE.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new THREE.Mesh(new THREE.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},L={X:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,.8,4,1,!1),i),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,.8,4,1,!1),i),[0,.5,0]]],Z:[[new THREE.Mesh(new THREE.CylinderGeometry(.2,0,.8,4,1,!1),i),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new THREE.Mesh(b,i),[.85,.85,0],null,[3,3,.2]]],YZ:[[new THREE.Mesh(b,i),[0,.85,.85],null,[.2,3,3]]],XZ:[[new THREE.Mesh(b,i),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new THREE.Mesh(new THREE.BoxGeometry(.2,.2,.2),i),[1.1,0,0]]],XYZY:[[new THREE.Mesh(new THREE.BoxGeometry(.2,.2,.2),i),[0,1.1,0]]],XYZZ:[[new THREE.Mesh(new THREE.BoxGeometry(.2,.2,.2),i),[0,0,1.1]]]},D={X:[[new THREE.Line(E,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new THREE.Line(E,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new THREE.Line(E,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},A=function(e){var t=new THREE.Object3D;for(var i in e)for(var n=e[i].length;n--;){var o=e[i][n][0].clone(),s=e[i][n][1],r=e[i][n][2],a=e[i][n][3],l=e[i][n][4];o.name=i,o.tag=l,s&&o.position.set(s[0],s[1],s[2]),r&&o.rotation.set(r[0],r[1],r[2]),a&&o.scale.set(a[0],a[1],a[2]),o.updateMatrix();var h=o.geometry.clone();h.applyMatrix(o.matrix),o.geometry=h,o.renderOrder=1/0,o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),t.add(o)}return t},V=new THREE.Vector3(0,0,0),R=new THREE.Euler,O=new THREE.Vector3(0,1,0),k=new THREE.Vector3(0,0,0),H=new THREE.Matrix4,U=new THREE.Quaternion,N=new THREE.Quaternion,G=new THREE.Quaternion,j=new THREE.Vector3(1,0,0),z=new THREE.Vector3(0,1,0),F=new THREE.Vector3(0,0,1);this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(x)),this.add(this.gizmo.rotate=A(I)),this.add(this.gizmo.scale=A(_)),this.add(this.picker.translate=A(T)),this.add(this.picker.rotate=A(B)),this.add(this.picker.scale=A(L)),this.add(this.helper.translate=A(P)),this.add(this.helper.rotate=A(S)),this.add(this.helper.scale=A(D)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1,this.updateMatrixWorld=function(){var e=this.space;"scale"===this.mode&&(e="local");var t="local"===e?this.worldQuaternion:G;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;var i=[];i=(i=(i=i.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(var n=0;n<i.length;n++){var o,s=i[n];if(s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition),o=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),s.scale.set(1,1,1).multiplyScalar(o*this.size/7),"helper"!==s.tag){if(s.quaternion.copy(t),"translate"===this.mode||"scale"===this.mode){var r=.99;"X"!==s.name&&"XYZX"!==s.name||Math.abs(O.copy(j).applyQuaternion(t).dot(this.eye))>r&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Y"!==s.name&&"XYZY"!==s.name||Math.abs(O.copy(z).applyQuaternion(t).dot(this.eye))>r&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Z"!==s.name&&"XYZZ"!==s.name||Math.abs(O.copy(F).applyQuaternion(t).dot(this.eye))>r&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XY"===s.name&&Math.abs(O.copy(F).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"YZ"===s.name&&Math.abs(O.copy(j).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XZ"===s.name&&Math.abs(O.copy(z).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),-1!==s.name.search("X")&&(O.copy(j).applyQuaternion(t).dot(this.eye)<0?"fwd"===s.tag?s.visible=!1:s.scale.x*=-1:"bwd"===s.tag&&(s.visible=!1)),-1!==s.name.search("Y")&&(O.copy(z).applyQuaternion(t).dot(this.eye)<0?"fwd"===s.tag?s.visible=!1:s.scale.y*=-1:"bwd"===s.tag&&(s.visible=!1)),-1!==s.name.search("Z")&&(O.copy(F).applyQuaternion(t).dot(this.eye)<0?"fwd"===s.tag?s.visible=!1:s.scale.z*=-1:"bwd"===s.tag&&(s.visible=!1))}else"rotate"===this.mode&&(N.copy(t),O.copy(this.eye).applyQuaternion(U.copy(t).inverse()),-1!==s.name.search("E")&&s.quaternion.setFromRotationMatrix(H.lookAt(this.eye,k,z)),"X"===s.name&&(U.setFromAxisAngle(j,Math.atan2(-O.y,O.z)),U.multiplyQuaternions(N,U),s.quaternion.copy(U)),"Y"===s.name&&(U.setFromAxisAngle(z,Math.atan2(O.x,O.z)),U.multiplyQuaternions(N,U),s.quaternion.copy(U)),"Z"===s.name&&(U.setFromAxisAngle(F,Math.atan2(O.y,O.x)),U.multiplyQuaternions(N,U),s.quaternion.copy(U)));s.visible=s.visible&&(-1===s.name.indexOf("X")||this.showX),s.visible=s.visible&&(-1===s.name.indexOf("Y")||this.showY),s.visible=s.visible&&(-1===s.name.indexOf("Z")||this.showZ),s.visible=s.visible&&(-1===s.name.indexOf("E")||this.showX&&this.showY&&this.showZ),s.material._opacity=s.material._opacity||s.material.opacity,s.material._color=s.material._color||s.material.color.clone(),s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled?this.axis&&(s.name===this.axis||this.axis.split("").some((function(e){return s.name===e}))?(s.material.opacity=1,s.material.color.lerp(new THREE.Color(1,1,1),.5)):(s.material.opacity*=.25,s.material.color.lerp(new THREE.Color(1,1,1),.5))):(s.material.opacity*=.5,s.material.color.lerp(new THREE.Color(1,1,1),.5))}else s.visible=!1,"AXIS"===s.name?(s.position.copy(this.worldPositionStart),s.visible=!!this.axis,"X"===this.axis&&(U.setFromEuler(R.set(0,0,0)),s.quaternion.copy(t).multiply(U),Math.abs(O.copy(j).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"Y"===this.axis&&(U.setFromEuler(R.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(U),Math.abs(O.copy(z).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"Z"===this.axis&&(U.setFromEuler(R.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(U),Math.abs(O.copy(F).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"XYZE"===this.axis&&(U.setFromEuler(R.set(0,Math.PI/2,0)),O.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(H.lookAt(k,O,z)),s.quaternion.multiply(U),s.visible=this.dragging),"E"===this.axis&&(s.visible=!1)):"START"===s.name?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):"END"===s.name?(s.position.copy(this.worldPosition),s.visible=this.dragging):"DELTA"===s.name?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),V.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),V.applyQuaternion(this.worldQuaternionStart.clone().inverse()),s.scale.copy(V),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=-1!==this.axis.search(s.name)))}THREE.Object3D.prototype.updateMatrixWorld.call(this)}};Te.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:Te,isTransformControlsGizmo:!0});var Pe=function(){THREE.Mesh.call(this,new THREE.PlaneGeometry(1e5,1e5,2,2),new THREE.MeshBasicMaterial({visible:!1,wireframe:!0,side:THREE.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane";var e=new THREE.Vector3(1,0,0),t=new THREE.Vector3(0,1,0),i=new THREE.Vector3(0,0,1),n=new THREE.Vector3,o=new THREE.Vector3,s=new THREE.Vector3,r=new THREE.Matrix4,a=new THREE.Quaternion;this.updateMatrixWorld=function(){var l=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(l="local"),e.set(1,0,0).applyQuaternion("local"===l?this.worldQuaternion:a),t.set(0,1,0).applyQuaternion("local"===l?this.worldQuaternion:a),i.set(0,0,1).applyQuaternion("local"===l?this.worldQuaternion:a),s.copy(t),this.mode){case"translate":case"scale":switch(this.axis){case"X":s.copy(this.eye).cross(e),o.copy(e).cross(s);break;case"Y":s.copy(this.eye).cross(t),o.copy(t).cross(s);break;case"Z":s.copy(this.eye).cross(i),o.copy(i).cross(s);break;case"XY":o.copy(i);break;case"YZ":o.copy(e);break;case"XZ":s.copy(i),o.copy(t);break;case"XYZ":case"E":o.set(0,0,0)}break;default:o.set(0,0,0)}0===o.length()?this.quaternion.copy(this.cameraQuaternion):(r.lookAt(n.set(0,0,0),o,s),this.quaternion.setFromRotationMatrix(r)),THREE.Object3D.prototype.updateMatrixWorld.call(this)}};Pe.prototype=Object.assign(Object.create(THREE.Mesh.prototype),{constructor:Pe,isTransformControlsPlane:!0}),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Entity"),n="point",o="line",s="plane";i.EntityEditor=class{constructor(t){void 0!==t.viewer?(this.viewer=t.viewer,this.entityInfo=t.entity,this.currentLayerId=this.entityInfo?this.entityInfo.layerId:null,this.currentEntityId=this.entityInfo?this.entityInfo.entityId:null,this.currentEntity=null,this.currentLayer=null,this.points=new Map,this.lines=new Map,this.planes=new Map,this.externalObjectManager=new e.Bimface.Viewer.ExternalObjectManager(this.viewer),this.customEntityLayer=new e.Bimface.Layer.EntityLayer({name:"CustomEntity"}),this.SNAPTOLERANCE=5,this.deleteMode=!1,this.tmpGeometry=new THREE.BoxGeometry(1,1,1),this.visualPoints=new Map,this.viewer.getViewer().camera&&(this.camera=this.viewer.getViewer().camera)):console.warn("Need param:viewer In Constructing EntityEditor")}getCurrentEntity(){this.currentLayerId&&this.currentEntityId&&(this.currentLayer=this.viewer.getLayerManager().getLayer(this.currentLayerId),this.currentEntity=this.currentLayer.getEntityById(this.currentEntityId),this._drawPreviewLine(this.currentEntity))}edit(){this._init(),this.getCurrentEntity()}exit(){this.externalObjectManager.removeByName("TransformControls"),this.transformControl.dispose(),this.transformControl=null,this.domContainer&&(this.domContainer.style.cursor=""),this.saveCurrentEntity(),this.removeDomEventListeners(),this.destroySvgContainer(),this.entityInfo=null,this.currentLayerId=null,this.currentEntityId=null,this.currentEntity=null,this.currentLayer=null}setEntity(e){this.saveCurrentEntity(),this.entityInfo=e,this.currentLayerId=this.entityInfo.layerId,this.currentEntityId=this.entityInfo.entityId,this.getCurrentEntity()}saveCurrentEntity(){this.currentEntity&&this.currentEntity.updateGeo(this.lines.values().next().value.points),this.clearPreview()}clearPreview(){for(const e of this.points.values())e.clear();this.points.clear();for(const e of this.lines.values()){e.clear();let t=this.externalObjectManager.getObjectIdByName(`${e.id}`);this.externalObjectManager.removeById(t)}this.lines.clear();for(const e of this.planes.values())e.clear();this.planes.clear();for(const e of this.visualPoints){let t=this.externalObjectManager.getObjectIdByName(`${e[0]}`);this.externalObjectManager.removeById(t)}this.visualPoints.clear()}getEntity(){return this.entityInfo}_init(){this.domContainer=t.create("div","bf-EditorEditor-conext"),this.domContainer.style.position="absolute",this.domContainer.style.left=0,this.domContainer.style.top=0,this.domContainer.style.width="100%",this.domContainer.style.height="100%",this.svgContainer=t.createNS("svg","bf-EditorEditor-svg"),this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.domContainer.appendChild(this.svgContainer),this.viewer.getDomElement().appendChild(this.domContainer),this.addDomEventListeners(),this.transformControl=new xe(this.camera,this.viewer.getDomElement(),this.viewer),this.externalObjectManager._addObject("TransformControls",this.transformControl)}_makePreview(){this._drawAllPreviewEntities()}_drawAllPreviewEntities(){this.viewer.getLayerManager().getLayerByType("EntityLayer").forEach((e=>{e.getAllEntities().forEach(((e,t)=>{switch(e.type){case"polyline":case"spline":this._drawPreviewLine(e);break;case"polygon":this._drawPreviewPlane(e)}}))}))}_drawPreviewLine(e){let t=e.getPoints(),i=new Ce;i.createFromEntity(e);let n=0;t.forEach((e=>{let t=new Me(this.viewer,e);this.svgContainer.appendChild(t.getSvgElement()),t.setAttachLine(i,n),this.points.set(t.id,t),this.addVisualPoint(t.id,t.worldPosition),i.setPreviewPoint({index:n,id:t.id}),n++})),this.lines.set(e.id,i),this.externalObjectManager._addObject(`${i.id}`,i),e.destroyGeo()}_drawPreviewPoint(e){}_drawPreviewPlane(e){}addDomEventListeners(){this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseDoubleClickBinded=this.onMouseDoubleClick.bind(this),this.onWindowResizeBinded=this.onWindowResize.bind(this),this.update=this.update.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this);let e=this.svgContainer;e.addEventListener("mousemove",this.onMouseMoveBinded,!1),e.addEventListener("mousedown",this.onMouseDownBinded,!1),document.addEventListener("mouseup",this.onMouseUpBinded,!1),e.addEventListener("dblclick",this.onMouseDoubleClickBinded,!1),window.addEventListener("resize",this.onWindowResizeBinded,!1),this.viewer.addEventListener("Rendered",this.update,!1),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp)}removeDomEventListeners(){let e=this.svgContainer;e.removeEventListener("mousemove",this.onMouseMoveBinded),e.removeEventListener("mousedown",this.onMouseDownBinded),document.removeEventListener("mouseup",this.onMouseUpBinded),e.removeEventListener("dblclick",this.onMouseDoubleClickBinded),window.removeEventListener("resize",this.onWindowResizeBinded),this.viewer.removeEventListener("Rendered",this.update),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp)}destroySvgContainer(){this.domContainer.removeChild(this.svgContainer),this.svgContainer=null,this.viewer.getDomElement().removeChild(this.domContainer),this.domContainer=null}onKeyDown(e){if(46===e.keyCode)this.deleteMode=!0}onKeyUp(e){if(46===e.keyCode)this.deleteMode=!1}onMouseDown(t){if(t.button===THREE.MOUSE.LEFT){let i={x:t.clientX,y:t.clientY};if(this.currentSnap);else{let t=this.getSnap(i);if(t)switch(this._tmpSnap=null,t.type){case n:this.deleteMode?(t.snap.delete(),this.points.delete(t.snap.id),this.removeVisualPoint(t.snap.id),this.points.size<2?(this.clearPreview(),this.currentLayer.removeEntity(this.currentEntity.id),this.currentEntity=null):(this.updateIndexInPreviewPoints(t.snap.index,!0),this.saveCurrentEntity(),this._drawPreviewLine(this.currentEntity)),this.deleteMode=!1):(t.snap.selected(),t.state="Processing",this.currentSnap=t,this.viewer.enableOrbit(!1));break;case o:if(t.snap instanceof e.Bimface.Plugins.Geometry.SplineCurve)this.setEntity({layerId:t.snap.layerId,entityId:t.snap.entityId});else{this.currentSnap=t;let e=t.snap.addPoint(t.snapPoint);e&&(this.svgContainer.appendChild(e.getSvgElement()),this.points.set(e.id,e),this.addVisualPoint(e.id,e.worldPosition),t.snap.setPreviewPoint({index:e.index,id:e.id}),t.snap.updateGeo(),this.saveCurrentEntity(),this._drawPreviewLine(this.currentEntity)),this.viewer.enableOrbit(!1)}}this.viewer.render()}}}onMouseMove(e){let t={x:e.clientX,y:e.clientY};if(this.currentSnap&&"Processing"===this.currentSnap.state){let e=this.getCurrentVisualPointPosition(this.currentSnap.snap.id);e?this.currentSnap.snap.processing(e,!0):this.currentSnap.snap.processing(t,!1)}else{this._tmpSnap&&(this._tmpSnap.cancelHightlight(),this._tmpSnap=null),this.transformControl.detach();let e=this.getSnap(t);if(e){switch(e.type){case n:this.domContainer.style.cursor="",this.attachVisualPoint(e.snap.id);break;case o:this.domContainer.style.cursor=`url(${l})10 10,auto`}this._tmpSnap=e.snap,this._tmpSnap.hightlight()}else this.domContainer.style.cursor=`url(${l})10 10,auto`}this.viewer.render()}onMouseUp(e){if(e.button===THREE.MOUSE.LEFT){let t={x:e.clientX,y:e.clientY};this.currentSnap&&(this.currentSnap.snap.finished(t),this.viewer.enableOrbit(!0),this.currentSnap=null,this.transformControl.detach())}else e.button===THREE.MOUSE.RIGHT&&this.currentSnap&&this.currentSnap.snap.cancled()}onMouseDoubleClick(e){e.preventDefault(),e.stopPropagation()}onWindowResize(){this.update()}update(){this.points.forEach(((e,t)=>{e.update()}))}clear(){this.points.forEach(((e,t)=>{e.clear()}))}getSnap(e){let t=null;return t=this.snapPoint(e),t?{type:n,snap:t}:(t=this.snapLine(e),t?{type:o,snap:t.line,snapPoint:t.snapPoint}:(t=this.snapPlane(e),t?{type:s,snap:t}:t))}snapPoint(e){let t=null;for(const i of this.points.values())i.distanceTo(e)<=this.SNAPTOLERANCE&&(t=i);return t}snapLine(t){let i=null,n=this.viewer.getViewer().pickToPoint(t,50);return null!=n&&n.pickLine&&(n.pickLine instanceof e.Bimface.Plugins.Geometry.SplineCurve||n.pickLine instanceof Ce)&&(i={line:n.pickLine,snapPoint:n.pickPoint}),i}snapPlane(e){}distanceTo(e,t){let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}updateIndexInPreviewPoints(e,t){this.points.forEach(((i,n)=>{i.index>=e&&(t?(i.index-=1,i.index<=0&&(i.index=0)):i.index+=1)}))}addVisualPoint(e,t){let i=new THREE.MeshBasicMaterial({color:65280,visible:!1,opacity:.1}),n=new THREE.Mesh(this.tmpGeometry,i);this.visualPoints.set(e,n),n.position.copy(t),this.externalObjectManager._addObject(`${e}`,n)}removeVisualPoint(e){this.transformControl.detach(),this.visualPoints.delete(e);let t=this.externalObjectManager.getObjectIdByName(`${e}`);this.externalObjectManager.removeById(t)}attachVisualPoint(e){let t=this.visualPoints.get(e);t!=this.transformControl.object&&t&&this.transformControl.attach(t)}getCurrentVisualPointPosition(e){return this.transformControl.object?this.transformControl.object.position:null}}}();class Ie{constructor(t){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.color=new e.Web.Graphics.Color("#32D3A6"),this.type="",this.attributes={},this.viewer=t,this.externalObjectManager=new e.Bimface.Viewer.ExternalObjectManager(this.viewer),this.layerId=""}getId(){return this.id}show(){}hide(){}genGeometry(){}updateGeometry(){}destroy(){}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class n extends CLOUD.MeshLine{constructor(i,n,o,s,r){super(),t.send("Bimface.Plugins.Geometry.SplineCurve","bf_c_geometry_newSpline");let a={};i instanceof Array?(a.points=i,a.color=n,a.width=o,a.style=s,a.type=r):a=i,null==i||i&&i.length<2?console.log("ERROR::points must be not empty or only one"):(P(this),this.viewer=a.viewer,this.points=void 0!==a.points?a.points:[],this.color=void 0!==a.color?a.color:new e.Web.Graphics.Color("#32D3A6"),this.width=void 0!==a.width?a.width:1,this.style=void 0!==a.style?a.style:{lineType:"Continuous",lineStyle:null},this.curveType=void 0!==a.type?a.type:"spline",this.divisions=100,this._clampMode="Space",this.curve=null,this.createCurve(),this.createGroundCurve({points:this.points,color:this.color,width:this.width,style:this.style,type:this.curveType,divisions:this.divisions}),this.groundCurve.visible=!1,this.groundCurveVisible=this.groundCurve.visible,this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1],this.material.linewidth=this.width,this.material.resolution=new THREE.Vector2(window.innerWidth,window.innerHeight),this.setColor(this.color),this.setStyle(this.style),this.highlightColor="#FF7F00",this.addEventListener("removed",(function(){this.groundCurve.onRemoved()})),this.addEventListener("added",(function(){this.groundCurve.onAdded()})),this._widthType="DisplayWidth",this._adjustGlobalUnit=!1,this.mapOption=void 0,this.disPickable=!0)}createCurve(){for(var e=this.points,t=[],i=0,n=e.length;i<n;i++)t.push(new THREE.Vector3(e[i].x,e[i].y,e[i].z));this.curve=new THREE.CatmullRomCurve3(t),this.curve.tension=0,this.curve.curveType="polyline"==this.curveType?"catmullrom":"centripetal",this.length=this.curve.getLength();var o=Math.ceil(this.length/1e3);this.divisions=o<this.divisions?this.divisions:o;var s=[];if("polyline"===this.curveType)s=this.getPolylinePositions();else{i=0;for(var r=this.divisions;i<=r;i++){var a=this.curve.getPointAt(i/r);s.push(a.x,a.y,a.z)}}this.geometry.setPositions(s),this.material.totalSize=this.geometry.totalSize,this.curvePositions=s}_rebuild(e){if(this._adjustGlobalUnit)return this;this.viewer||(this.viewer=e),this.points=this.viewer.globalUnitUtil.translate(this.points,["x","y","z"]);let t={};return this.style&&"Continuous"==this.style.lineType&&(t.lineType="Continuous",t.lineStyle=null),this.style&&"Dashed"==this.style.lineType&&(t.lineType="Dashed",t.lineStyle={},t.lineStyle.dashLength=this.viewer.globalUnitUtil.translate(this.style.lineStyle.dashLength),t.lineStyle.gapLength=this.viewer.globalUnitUtil.translate(this.style.lineStyle.gapLength)),this.createCurve(),this.createGroundCurve({points:this.points,color:this.color,width:this.width,style:this.style,type:this.curveType,divisions:this.divisions}),this.groundCurve.visible=this.groundCurveVisible,this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1],this.material.linewidth=this.width,this.material.resolution=new THREE.Vector2(window.innerWidth,window.innerHeight),this.setColor(this.color),this.setStyle(t),this._isStretch&&this.stretch(this.intensty,this.parameter),this._adjustGlobalUnit=!0,this}clone(){var t=this.points.copyWithin(0),i=new e.Web.Graphics.Color(this.color.red,this.color.green,this.color.blue,this.color.alpha),n=this.width,o="Continuous"==this.style.lineType?{lineType:this.style.lineType,lineStyle:this.lineStyle}:{lineType:this.style.lineType,lineStyle:{dashLength:this.style.lineStyle.dashLength,gapLength:this.style.lineStyle.gapLength}};this._adjustGlobalUnit&&(t=this.viewer.globalUnitUtil.revertTranslate(t,["x","y","z"]));var s=new this.constructor(t,i,n,o);return this.material&&(s.material=this.material.clone()),s}dispose(){this.geometry.dispose(),this.material.dispose(),this.points=[],this.curve=null,this.geometry=null,this.material=null,this.color=null,this.width=null,this.style=null,this.startPoint=null,this.endPoint=null,this.groundCurve.dispose()}getPointByLength(e){if(this._adjustGlobalUnit&&(e=this.viewer.globalUnitUtil.translate(e)),e<0||e>this.length||!this.curve)return null;var t=e/this.length,i=this.curve.getPointAt(t);return this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate({x:i.x,y:i.y,z:i.z},["x","y","z"]):{x:i.x,y:i.y,z:i.z}}getPointByParameter(e){if(e<0||e>1||!this.curve)return null;var t=this.curve.getPointAt(e);return this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate({x:t.x,y:t.y,z:t.z},["x","y","z"]):{x:t.x,y:t.y,z:t.z}}getTangentByLength(e){if(this._adjustGlobalUnit&&(e=this.viewer.globalUnitUtil.translate(e)),e<0||e>this.length||!this.curve)return null;var t=e/this.length,i=this.curve.getTangentAt(t);return{x:i.x,y:i.y,z:i.z}}getTangentByParameter(e){if(length<0||length>1||!this.curve)return null;var t=this.curve.getTangentAt(e);return{x:t.x,y:t.y,z:t.z}}setColor(t){!t instanceof e.Web.Graphics.Color?console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color"):(this.color=t,this.material.color.setRGB(t.red/255,t.green/255,t.blue/255),this.material.opacity=t.alpha,t.alpha<1||this.material.map?this.material.transparent=!0:this.material.transparent=!1,this.renderOrder=CLOUD.GlobalData.IncrementRender?100:-1,this.groundCurve.setColor(t))}getColor(){return this.color}setWidth(e){this.width=e,this.material.linewidth=e,this.groundCurve.setWidth(e)}getWidth(){return this.width}setStyle(e){if(this.style=e,"Continuous"==e.lineType)this.material.dashArray=0,this.material.dashRatio=0;else{var t=e.lineStyle.dashLength,i=e.lineStyle.gapLength;this._adjustGlobalUnit&&(t=this.viewer.globalUnitUtil.translate(t),i=this.viewer.globalUnitUtil.translate(i)),this.material.dashArray=(t+i)/this.material.totalSize,this.material.dashRatio=t/(t+i)}this.material.needsUpdate=!0,this.groundCurve.setStyle(e)}getStyle(){return this.style}setType(e){if(this.curveType!=e&&("polyline"==e||"spline"==e)){this.curveType=e,this.curve.curveType="polyline"==e?"catmullrom":"centripetal",this.length=this.curve.getLength();var t=this.divisions,i=[];if("polyline"===e)i=this.getPolylinePositions();else for(var n=0,o=t;n<=o;n++){var s=this.curve.getPointAt(n/o);i.push(s.x,s.y,s.z)}this.geometry.setPositions(i),this.curvePositions=i,this.groundCurve.setType(e)}}getType(){return this.curveType}getPoints(){let e=this.points;return this._adjustGlobalUnit&&(e=this.viewer.globalUnitUtil.revertTranslate(this.points,["x","y","z"])),e}setPoints(e){if(e.length<2)return;this._adjustGlobalUnit&&(e=this.viewer.globalUnitUtil.translate(e,["x","y","z"])),this.points=e;let t=[];for(let i=0,n=e.length;i<n;i++)t.push(new THREE.Vector3(e[i].x,e[i].y,e[i].z));this.curve.points=t,this.length=this.curve.getLength();const i=Math.ceil(this.length/1e3);this.divisions=i<this.divisions?this.divisions:i;let n=[];for(let e=0,t=this.divisions;e<=t;e++){const i=this.curve.getPointAt(e/t);n.push(i.x,i.y,i.z)}this.geometry.setPositions(n),this.material.totalSize=this.geometry.totalSize,this.curvePositions=n,this.groundCurve.geometry.updateGeometry({points:e})}projectToGround(e){this.visible=!e,this.groundCurve.visible=e,this.groundCurveVisible=e,e?(this._clampMode="Both",this._updateClampMode(0)):this._clampMode="Space"}clampMode(e){if(!e)return;var t=CLOUD.Utils.isDefined(e.mode)?e.mode:"Space",i="Space"!=t;switch(this.visible=!i,this.groundCurve.visible=i,this.groundCurveVisible=i,this._clampMode=t,this._clampMode){case"Both":this._updateClampMode(0);break;case"Ground":this._updateClampMode(1);break;case"Model":this._updateClampMode(2)}const n=e.layerIds;this._setVisibleLayerIds(n)}_setVisibleLayerIds(e){let t={};if(!(e instanceof Array)||0===e.length)return void CLOUD.GroundPrimitiveManager.getInstance().setInVisibleModelIdMapAboutGroundCurve(null);if(!this.viewer||"ViewerGIS"!==this.viewer.viewerType)return console.warn("option.layerIds only support ViewerGIS"),t={all:!1},void CLOUD.GroundPrimitiveManager.getInstance().setInVisibleModelIdMapAboutGroundCurve(null);this.viewer.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((i=>{if(e.indexOf(i.id)>-1)return;const n=i.getModelId();t[n]=!0})),this.groundCurve.inVisibleModelIdMap=t}_updateClampMode(e){this.groundCurve.setClampMode(e)}setMap(e,t){if(e.src){var i=null==e.offset?[0,0]:[0,e.offset],n=null==e.scale?[1,1]:[1,e.scale];if(this.mapOption=e,this.src!=e.src){this.src=e.src;var o=new THREE.Texture,s=this;(new TEST.CryptoResourceLoader).loadURL(e.src,(r=>{var a=new Blob([r],{type:"jpeg"});let l=new Image;l.onload=function(){o.image=CLOUD.MaterialUtil.ensurePowerOfTwo(l),o.needsUpdate=!0,o.offset.fromArray(i),o.repeat.fromArray(n),o.wrapS=THREE.RepeatWrapping,o.wrapT=THREE.RepeatWrapping,s.material.enableColorOverride=null!=e.enableColorOverride&&e.enableColorOverride,s.material.transparent=!0,s.material.depthWrite=!1,s.material.map=o,s.material.needsUpdate=!0,s.groundCurve.setMap(o,s.material.enableColorOverride),t&&t(o)},l.onerror=e=>{console.log(e),onError&&onError(e)},l.src=URL.createObjectURL(a)}),null,(e=>{console.log(e),onError&&onError(e)}))}else{var r=this.material.map;r&&(r.offset.fromArray(i),r.repeat.fromArray(n),this.material.map=r,this.material.enableColorOverride=null!=e.enableColorOverride&&e.enableColorOverride,this.material.needsUpdate=!0,this.groundCurve.material.enableColorOverride=this.material.enableColorOverride,this.groundCurve.material.needsUpdate=!0,t&&t(r))}}}getMap(){return this.mapOption}stretch(e,t){function i(e,t,i,n){const o=i-e,s=n-t,r=o*o+s*s;return Math.sqrt(r)}this.intensty=e,this.parameter=t;const n=null==e?.5:e,o=null==t?.5:t,s=this.points;var r=[],a=0;for(let e=1;e<s.length;e++){let t=s[e-1],w=s[e];var l=t.x+(w.x-t.x)*o,h=t.y+(w.y-t.y)*o,d=i(t.x,t.y,w.x,w.y),c=t.z+d*n,u=new THREE.Vector3(l,h,c),g=new THREE.QuadraticBezierCurve3(t,u,w),p=10*Math.floor(Math.log(d)/Math.LN10)+10;a+=p;for(var m=0;m<p;m++){var f=m/p;r.push(g.getPointAt(f))}r.push(g.getPointAt(1))}this.curve=new THREE.CatmullRomCurve3(r),this.length=this.curve.getLength(),this.divisions=a;for(var w=[],y=0,v=a;y<v;y++){var b=this.curve.getPointAt(y/v);w.push(b.x,b.y,b.z)}this.geometry.setPositions(w),this.curvePositions=w,this._isStretch=!0}setEntityId(e,t){this.entityId=t,this.layerId=e}hightlight(){let t=new e.Web.Graphics.Color(this.highlightColor,1);this.material.color.setRGB(t.red/255,t.green/255,t.blue/255)}cancelHightlight(){this.material.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255)}setWidthType(e){this._widthType==e||"DisplayWidth"!=e&&"ActualWidth"!=e||(this._widthType=e,this.groundCurve.setWidthType(this._widthType),this.material.sizeAttenuation="DisplayWidth"!=e,this.material.needsUpdate=!0)}getWidthType(){return this._widthType}show(){"Space"===this._clampMode?this.visible=!0:(this.groundCurve.visible=!0,this.groundCurveVisible=!0)}hide(){"Space"===this._clampMode?this.visible=!1:(this.groundCurve.visible=!1,this.groundCurveVisible=!1)}getBox(){let e=this.geometry.boundingBox;return e||(this.geometry.computeBoundingBox(),e=this.geometry.boundingBox),e}getParams(){let e=this.points,t=this.style;return this._adjustGlobalUnit&&(e=this.viewer.globalUnitUtil.revertTranslate(e,["x","y","z"]),"Dashed"==t.lineType&&(t.lineStyle.dashLength=this.viewer.globalUnitUtil.revertTranslate(t.lineStyle.dashLength),t.lineStyle.gapLength=this.viewer.globalUnitUtil.revertTranslate(t.lineStyle.gapLength))),{points:e,color:this.color,width:this.width,style:t,type:this.curveType,widthType:this._widthType,url:this.src,enableColorOverride:this.material.enableColorOverride,intensty:this.intensty,parameter:this.parameter}}getPolylinePositions(){const e=[],t=this.length,i=this.divisions,n=new THREE.Vector3,o=new THREE.Vector3;for(let s=1;s<this.points.length;s++){n.set(this.points[s-1].x,this.points[s-1].y,this.points[s-1].z),o.set(this.points[s].x,this.points[s].y,this.points[s].z);const r=new THREE.CatmullRomCurve3([n,o]);r.tension=0,r.curveType="catmullrom";const a=r.getLength(),l=Math.ceil(i*a/t);for(let t=1===s?0:1;t<=l;t++){const i=r.getPoint(t/l);e.push(i.x,i.y,i.z)}}return e}}i.SplineCurve=n}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Entity");t.CurveEntity=class extends Ie{constructor(e){super(e),this.lineType="solid",this._points=[],this._curve=null,this._name="Spline_"+this.id,this.width=2}getBox(){if(this._curve)return this._curve.getBox()}show(){this._curve&&this._curve.show(),this.viewer.render()}hide(){this._curve&&this._curve.hide(),this.viewer.render()}projectToGround(e){this._curve&&(this._curve.projectToGround(e),this.viewer.render())}setLayerId(e){this.layerId=e,this._curve&&this._curve.setEntityId(this.layerId,this.id)}getPoints(){return this._points}genGeometry(t){!t||!t.points||t.points.length<2?console.log("ERROR::CurveEntity points must be not empty or only one"):(this._points=t.points,this.type=t.type.toLowerCase(),this._curve=new e.Bimface.Plugins.Geometry.SplineCurve({points:this._points,type:t.type}),this.setLineType(t.lineType),this.setColor(t.color),this.setWidth(t.width),this.setAttributes(t.attributes),this.externalObjectManager&&this.externalObjectManager._addObject(this._name,this._curve))}setType(e){this.type=e.toLowerCase(),this._curve&&(this._curve.setType(this.type),this.viewer.render())}setLineType(e){if(this._curve){let t;switch(e){case"solid":default:t={lineType:"Continuous",lineStyle:null};break;case"dash":t={lineType:"Dashed",lineStyle:{dashLength:10,gapLength:10}}}this.lineType=e,this._curve.setStyle(t),this.viewer.render()}}setAttributes(e){this.attributes=e}getAttributes(){return this.attributes}setColor(t){if(this._curve){if("string"==typeof t||!t instanceof e.Web.Graphics.Color){let i=new e.Web.Graphics.Color(t,1);this._curve.setColor(i),this.color=i}else this._curve.setColor(t),this.color=t;this.viewer.render()}}setWidth(e){this._curve&&(this._curve.setWidth(e),this.width=e,this.viewer.render())}updateGeo(t){this._points=t,this._curve=new e.Bimface.Plugins.Geometry.SplineCurve({points:this._points,type:this.type}),this.setLineType(this.lineType),this.setColor(this.color),this.setWidth(this.width),this.setAttributes(this.attributes),this.externalObjectManager&&this.externalObjectManager._addObject(this._name,this._curve),this._curve&&this._curve.setEntityId(this.layerId,this.id)}destroy(){this.points=[],this._curve&&this._curve.dispose(),this._curve=null;let e=this.externalObjectManager.getObjectIdByName(this._name);this.externalObjectManager.removeById(e)}destroyGeo(){this._curve&&this._curve.dispose(),this._curve=null;let e=this.externalObjectManager.getObjectIdByName(this._name);this.externalObjectManager.removeById(e)}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class i extends THREE.BufferGeometry{constructor(e){super(),this.points=e,this.handlePoints=[],this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.invalid=!1,this._createPlaneGeometry()}_createPlaneGeometry(){var e=this;e.points.length;if(e._RemoveDuplicatePoints(e.points))this.invalid=!0;else{if(e.handlePoints.length<3)return console.warn("Failed to create plane, the number of the points must be more than three."),void(this.invalid=!0);if(3==e.handlePoints.length&&0==i.area(e.handlePoints[0],e.handlePoints[1],e.handlePoints[2]))return console.warn("Failed to create plane, points are collinear."),void(this.invalid=!0);if(i.checkIntersect(e.handlePoints))return console.warn("Failed to create plane, the plane border is self-intersecting."),void(this.invalid=!0);e.handlePoints.push(new THREE.Vector2(e.points[0].x,e.points[0].y));var t=new THREE.Shape(e.handlePoints),n=new THREE.ShapeGeometry(t),o=new Float32Array(e._updateUv(n));n.setAttribute("uv",new THREE.BufferAttribute(o,2)),this.attributes=n.attributes,this.groups=n.groups,this.index=n.index}}_updateUv(e){for(var t=this,i=[],n=e.attributes.position.array,o=0;o<n.length;o+=3){var s=n[o],r=n[o+1],a=(s-t.minX)/(t.maxX-t.minX),l=(r-t.minY)/(t.maxY-t.minY);i.push(a),i.push(l)}return i}_RemoveDuplicatePoints(e){var t=this,i=new THREE.Vector2(e[0].x,e[0].y);t.handlePoints.push(i),t.minX=i.x,t.maxX=i.x,t.minY=i.y,t.maxY=i.y;for(var n=1;n<e.length;n++){var o=!1;if(null==e[n].x||null==e[n].y||null==e[n].z)return console.log("Failed to create plane, the format of plane is not right, please follow [{x:,y:,z:},...]"),!0;for(var s=0;s<t.handlePoints.length;s++)if(e[n].x==t.handlePoints[s].x&&e[n].y==t.handlePoints[s].y){o=!0;break}if(!1===o){i=new THREE.Vector2(e[n].x,e[n].y);t.handlePoints.push(i),t.minX>i.x&&(t.minX=i.x),t.minY>i.y&&(t.minY=i.y),t.maxX<i.x&&(t.maxX=i.x),t.maxY<i.y&&(t.maxY=i.y)}}return!1}static checkIntersect(e){for(var t,n,o,s,r=e.length,a=0;a<r;a++){t=e[a],n=e[a==r-1?0:a+1];for(var l=a+2;l<r;l++)if((0!=a||l!=r-1)&&(o=e[l],s=e[l==r-1?0:l+1],i.intersectSegments(t,n,o,s)))return!0}return!1}static area(e,t,i){return(t.x-e.x)*(i.y-e.y)-(i.x-e.x)*(t.y-e.y)}static collinearIntersectCheck(e,t,i,n){return!(Math.min(e.x,t.x)<=i.x&&i.x<=Math.max(e.x,t.x)&&Math.min(e.y,t.y)<=i.y&&i.y<=Math.max(e.y,t.y))&&!(Math.min(e.x,t.x)<=n.x&&n.x<=Math.max(e.x,t.x)&&Math.min(e.y,t.y)<=n.y&&n.y<=Math.max(e.y,t.y))}static intersectSegments(e,t,n,o){var s=i.area(e,t,n)*i.area(e,t,o),r=i.area(n,o,e)*i.area(n,o,t);return!(s>0)&&(!(r>0)&&(0!=s||0!=r||!i.collinearIntersectCheck(e,t,n,o)))}}t.PlaneBufferGeometry=i}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class n extends THREE.Group{constructor(i){if(t.send("Bimface.Plugins.Geometry.Plane","bf_c_plane_newPlane"),super(),i){if(this.isEntityPlane=null!=i.isEntityPlane&&i.isEntityPlane,this.points=null,this.height=0,P(this),2==arguments.length){var n=arguments[0],o=arguments[1];this.points=[],this.height=(n.z+o.z)/2,this.points.push(new THREE.Vector3(n.x,n.y)),this.points.push(new THREE.Vector3(o.x,n.y)),this.points.push(new THREE.Vector3(o.x,o.y)),this.points.push(new THREE.Vector3(n.x,o.y))}else if(i instanceof Array){var s=i;if(s.length<3)return void console.log("Glodon.Bimface.Plugins.Geometry.Plane points.length must >= 3.");this.points=s,this.height=s[0].z}else if("rectangle"==i.type){if(2!=i.points.length)return void console.log("Glodon.Bimface.Plugins.Geometry.Plane rectangle points.length must be 2.");n=i.points[0],o=i.points[1];this.points=[],this.height=(n.z+o.z)/2,this.points.push(new THREE.Vector3(n.x,n.y)),this.points.push(new THREE.Vector3(o.x,n.y)),this.points.push(new THREE.Vector3(o.x,o.y)),this.points.push(new THREE.Vector3(n.x,o.y))}else if("polygon"==i.type){if(i.points.length<3)return void console.log("Glodon.Bimface.Plugins.Geometry.Plane polygon points.length must >= 3.");this.points=i.points,this.height=i.points[0].z}else{if("circle"!=i.type)return void console.log("Glodon.Bimface.Plugins.Geometry.Plane opt type must be rectangle or polygon or circle.");if(!i.center||!i.radius)return void console.log("Glodon.Bimface.Plugins.Geometry.Plane circle need center and radius.");var r=new THREE.Vector3(i.center.x,i.center.y,i.center.z);this.points=[],this.height=r.z;for(var a=new THREE.Vector3,l=new THREE.Vector3(0,0,1),h=0;h<36;h++){a.set(1,0,0),a.applyAxisAngle(l,h*Math.PI*2/36);var d=new THREE.Vector3;d.copy(r),d.addScaledVector(a,i.radius),this.points.push(d)}}this._opt=i,this.mapUrl=null,this.color=new e.Web.Graphics.Color(50,138,240,.5),this.enableLightEffect=!0,this.borderColor=new e.Web.Graphics.Color(50,138,240,1),this.borderWidth=2,this.useBorder=!0,this.groundPlane=null,this.groundBorderLine=null,this._adjustGlobalUnit=!1,this.mapTransparent=!1,this.handlePoints=[],this._createPlane()||(this.type="invalidPlane"),this.addEventListener("removed",(function(){this.groundPlane&&this.groundPlane.onRemoved(),this.groundBorderLine&&this.groundBorderLine.onRemoved()})),this.addEventListener("added",(function(){this.groundPlane&&this.groundPlane.onAdded(),this.groundBorderLine&&this.groundBorderLine.onAdded()}))}}_createPlane(){var t=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(this.points);if(t.invalid)return!1;this.handlePoints=t.handlePoints;var i=this._createMeshMaterial(),n=new THREE.Mesh(t,i);return n.position.copy(new THREE.Vector3(0,0,this.height)),this.isEntityPlane&&(n.renderOrder=1),this.add(n),this._opt.onlyPlane||(this.groundPlane=CLOUD.GroundPrimitiveManager.getInstance().createGroundPolygon({color:this.color,points:this.handlePoints}),this.groundPlane.visible=!1),1==this.useBorder&&(this.add(this._createBorderLine()),this._opt.onlyPlane||(this.groundBorderLine=CLOUD.GroundPrimitiveManager.getInstance().createGroundCurve({points:this.handlePoints,color:this.borderColor,width:2,style:"Continuous",type:"polyline"}),this.groundBorderLine.visible=!1)),!0}_rebuild(e){return this._adjustGlobalUnit||(this.viewer||(this.viewer=e),this.points&&(this.points=this.viewer.globalUnitUtil.translate(this.points,["x","y","z"])),this.height&&(this.height=this.viewer.globalUnitUtil.translate(this.height)),this.children.length>0&&(this.children.length=0),this._createPlane()||(this.type="invalidPlane"),this.color&&this.setColor(this.color,this.enableLightEffect),this.borderColor&&this.setBorderColor(this.borderColor),this.borderWidth&&this.setBorderWidth(this.borderWidth),this.mapUrl&&this.setMap(this.mapUrl,null,this._opacity||null),this.useBorder||this.clearBorder(),this._adjustGlobalUnit=!0),this}clone(){var t=new e.Web.Graphics.Color(this.color.red,this.color.green,this.color.blue,this.color.alpha),i=new e.Web.Graphics.Color(this.borderColor.red,this.borderColor.green,this.borderColor.blue,this.borderColor.alpha),n=this.mapUrl,o=this.useBorder,s=new this.constructor(this._opt);return s.setColor(t),s.setBorderColor(i),s.setBorderWidth(this.borderWidth),null!=n&&s.setMap(n),s.useBorder=o,0==o&&s.clearBorder(),s}setBorderColor(t){if(!t instanceof e.Web.Graphics.Color)console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color");else{this.borderColor=t;var i=this.children[1];null!=i&&i.material.color.setRGB(this.borderColor.red/255,this.borderColor.green/255,this.borderColor.blue/255,THREE.SRGBColorSpace),this.groundBorderLine&&this.groundBorderLine.setColor(this.borderColor)}}getBorderColor(){return this.borderColor}setBorderWidth(e){if(Number(e)){this.borderWidth=Number(e);var t=this.children[1];null!=t&&(t.material.linewidth=this.borderWidth),this.groundBorderLine&&this.groundBorderLine.setWidth(this.borderWidth)}else console.warn("Parameter width is invalid.")}getBorderWidth(){return this.borderWidth}setColor(t,i){if(!t instanceof e.Web.Graphics.Color)console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color");else{this.color=t,i=null==i||i,this.enableLightEffect=i;var n=this.children[0];null!=n&&(n.material.map=null,n.material.alphaMap=null,n.material.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255,THREE.SRGBColorSpace),n.material.opacity=this.color.alpha,n.material.transparent=this.color.alpha<1,delete n.material.defines.USE_COLORWITHOUTLIGHT,!1===i&&(n.material.defines.USE_COLORWITHOUTLIGHT=""),n.material.needsUpdate=!0),this.groundPlane&&this.groundPlane.setColor(this.color)}}getColor(){return this.color}setMap(e,t,i){this._opacity=i;let n=!0;void 0===n&&"[object Boolean]"===Object.prototype.toString.call(i)&&(n=i,i=void 0);const o=()=>{var n=this;n.mapUrl=e;var o=n.children[0];if(null!=o){var s=new THREE.TextureLoader;s.setCrossOrigin("anonymous"),s.load(n.mapUrl,(e=>{e.colorSpace=THREE.SRGBColorSpace,o.material.map=e,!0===this.mapTransparent&&(o.material.alphaMap=e),this.setOpacity(i),o.material.needsUpdate=!0,t&&t(o)}))}};if(!1===n){let t=new Image;t.src=e,t.onload=()=>{const e=t.width,i=t.height,n=e/i,s=Math.abs(this.points[1].x-this.points[0].x),r=Math.abs(this.points[2].y-this.points[0].y),a=s/r;let l=0,h=0,d=0;this.points.forEach((e=>{l+=e.x,h+=e.y,d+=e.z})),l*=1/this.points.length,h*=1/this.points.length,d*=1/this.points.length;const c=new THREE.Vector3(l,h,d);if(n>a){const t=i*s/e/r;this.children.forEach((e=>{e.scale.setY(t),e.position.sub(c).multiply(new THREE.Vector3(1,t,1)).add(c),e.updateMatrixWorld()}))}else if(n<a){const t=e*r/i/s;this.children.forEach((e=>{e.scale.setX(t),e.position.sub(c).multiply(new THREE.Vector3(t,1,1)).add(c),e.updateMatrixWorld()}))}o()}}else o()}enableTransparent(e){this.mapTransparent=e}setOpacity(e){if(void 0===e&&(e=1),"[object Number]"===Object.prototype.toString.call(e)){e>1&&(e=1),e<0&&(e=0);var t=this.children[0];null!=t&&(t.material.needsUpdate=!0,t.material.opacity=e,t.material.transparent=!!this.mapTransparent||!(Math.abs(e-1)<.001)),this.groundPlane&&this.groundPlane.setOpacity(e)}}setBorderOpacity(e){if(void 0===e&&(e=1),"[object Number]"===Object.prototype.toString.call(e)){e>=1&&(e=this.isEntityPlane?.99:1),e<0&&(e=0);var t=this.children[1];null!=t&&(t.material.needsUpdate=!0,t.material.opacity=e,t.material.transparent=!!this.mapTransparent||!(Math.abs(e-1)<.001)),this.groundBorderLine&&this.groundBorderLine.setOpacity(e)}}clearBorder(){this.useBorder=!1;var e=this.children[1];this.remove(e),this.groundBorderLine&&(this.groundBorderLine.visible=!1)}clearPlane(){var e=this.children[0];this.remove(e),this.groundPlane&&(this.groundPlane.visible=!1)}projectToGround(e){var t=this.children[0];this.groundPlane&&t&&(t.visible=!e,this.groundPlane.visible=e);var i=this.children[1];this.groundBorderLine&&i&&this.useBorder&&(i.visible=!e,this.groundBorderLine.visible=e)}clampMode(e){var t=this.children[0],i=this.children[1];if("Ground"===e.mode||"Model"===e.mode||"Both"===e.mode){if(t.visible=!1,i&&(i.visible=!1),this.groundPlane.visible=!0,this.groundBorderLine.visible=!0,"Ground"===e.mode)this.groundPlane.setClampMode(1),this.groundBorderLine.setClampMode(1);else if("Model"===e.mode){this.groundPlane.setClampMode(2),this.groundBorderLine.setClampMode(2),"layerIdsNotExit"==this.handleLayerIds(e.layerIds)&&(this.groundPlane.visible=!1,this.groundBorderLine.visible=!1)}else if("Both"===e.mode){this.groundPlane.setClampMode(0),this.groundBorderLine.setClampMode(0),"layerIdsNotExit"==this.handleLayerIds(e.layerIds)&&(this.groundPlane.setClampMode(1),this.groundBorderLine.setClampMode(1))}}else t.visible=!0,i&&(i.visible=!0),this.groundPlane.visible=!1,this.groundBorderLine.visible=!1}handleLayerIds(e){if(this.viewer&&"ViewerGIS"===this.viewer.getViewerType())if(e&&e.length>0){let t=[];for(let i=0;i<e.length;i++){let n=this.viewer.getLayerManager().getLayer(e[i]);n&&n.model&&("TilesetLayer"===n.typeName||"BIMLayer"===n.typeName)&&t.push(n.model.modelId)}if(!(t.length>0))return"layerIdsNotExit";this.groundPlane.setVisibleModelIdMap(t),this.groundBorderLine.setVisibleModelIdMap(t)}else{let e=[...this.viewer.getLayerManager().getLayerByType("BIMLayer"),...this.viewer.getLayerManager().getLayerByType("TilesetLayer")],t=[];for(let i=0;i<e.length;i++)e[i].model&&t.push(e[i].model.modelId);if(!(t.length>0))return"layerIdsNotExit";this.groundPlane.setVisibleModelIdMap(t),this.groundBorderLine.setVisibleModelIdMap(t)}}dispose(){this.points=null,this.min=null,this.max=null,this.points=null,this.height=null,this.mapUrl=null,this.color=null,this.borderColor=null,this.useBorder=null,this.handlePoints=null;var e=this.children[0],t=this.children[1];e&&this.remove(e),t&&this.remove(t),this.groundPlane&&this.groundPlane.dispose(),this.groundBorderLine&&this.groundBorderLine.dispose()}updateGroundPlane(){if(this.groundPlane&&this.groundPlane.geometry.updateGeometry({points:this.points}),this.groundBorderLine){let t=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(this.points);t.invalid||(this.handlePoints=t.handlePoints,this.groundBorderLine.geometry.updateGeometry({points:this.handlePoints}))}}_createMeshMaterial(){var e=this,t=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255).convertSRGBToLinear(),i=new CLOUD.CloudStandardMaterial({color:t,side:THREE.DoubleSide,depthWrite:!this.isEntityPlane});return i.opacity=e.color.alpha,i.transparent=e.color.alpha<1,i}_createBorderLine(){var e,t=this;if(t.isEntityPlane){var i=new THREE.LineGeometry;let r=[];for(var n=0;n<t.handlePoints.length;n++){var o=new THREE.Vector3(t.handlePoints[n].x,t.handlePoints[n].y,t.height);r.push(o.x),r.push(o.y),r.push(o.z)}i.setPositions(r);var s=t._createLineMaterial();(e=new THREE.Line2(i,s)).renderOrder=10}else{const i=new THREE.BufferGeometry;let o=[];for(n=0;n<t.handlePoints.length;n++)o.push(t.handlePoints[n].x,t.handlePoints[n].y,t.height);i.setAttribute("position",new THREE.Float32BufferAttribute(o,3));const s=t._createLineMaterial2();e=new THREE.Line(i,s)}return e}_createLineMaterial(){var e=this,t=new THREE.Color(e.borderColor.red/255,e.borderColor.green/255,e.borderColor.blue/255),i=new THREE.LineMaterial({color:t,linewidth:2,dashed:!1,depthWrite:!this.isEntityPlane});return i.resolution.set(window.innerWidth,window.innerHeight),i.opacity=null==e.borderColor?1:e.borderColor.alpha,i.transparent=null!=e.borderColor&&e.borderColor.alpha<1,i}_createLineMaterial2(){var e=this,t=new THREE.Color(e.borderColor.red/255,e.borderColor.green/255,e.borderColor.blue/255),i=CLOUD.MaterialUtil.createStandardMaterial({color:t,linewidth:2,dashed:!1,depthWrite:!this.isEntityPlane});return i.setUnLight(!0),i.opacity=null==e.borderColor?1:e.borderColor.alpha,i.transparent=null!=e.borderColor&&e.borderColor.alpha<1,i}show(){this.children.forEach((e=>{e.material.visible=!0}))}hide(){this.children.forEach((e=>{e.material.visible=!1}))}getBox(){let e,t=this.children[0],i=null;return t&&(i=t.geometry),i&&(e=i.boundingBox,e||(i.computeBoundingBox(),e=i.boundingBox)),this.viewer.globalUnitUtil.revertBBox(e)}setEntityId(e,t){this.entityId=t,this.layerId=e}}i.Plane=n}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Entity");t.PolygonEntity=class extends Ie{constructor(e){super(e),this.lineType="solid",this._points=[],this._polygon=null,this._name="Polygon_"+this.id}setLayerId(e){this.layerId=e,this._polygon&&this._polygon.setEntityId(this.layerId,this.id)}getBox(){if(this._polygon)return this._polygon.getBox()}show(){this._polygon&&this._polygon.show(),this.viewer.render()}hide(){this._polygon&&this._polygon.hide(),this.viewer.render()}setBorderColor(t){if(this._polygon){if("string"==typeof t||!t instanceof e.Web.Graphics.Color){let i=new e.Web.Graphics.Color(t,1);this._polygon.setBorderColor(i)}else this._polygon.setBorderColor(t);this.viewer.render()}}getBorderColor(){if(this._polygon)return this._polygon.getBorderColor()}setBorderWidth(e){this._polygon&&(this._polygon.setBorderWidth(e),this.viewer.render())}getBorderWidth(){this._polygon&&this._polygon.getBorderWidth()}setOpacity(e){this._polygon&&(this._polygon.setOpacity(e),this.viewer.render())}setBorderOpacity(e){this._polygon&&(this._polygon.setBorderOpacity(e),this.viewer.render())}clearBorder(){this._polygon&&(this._polygon.clearBorder(),this.viewer.render())}clearPlane(){this._polygon&&(this._polygon.clearPlane(),this.viewer.render())}projectToGround(e){this._polygon&&(this._polygon.projectToGround(e),this.viewer.render())}getPoints(){return this._points}genGeometry(t){if(!t||!t.points||t.points.length<2)return void console.log("ERROR::CurveEntity points must be not empty or only one");this._points=t.points,this.type=t.type.toLowerCase();let i={type:"polygon",points:this._points,isEntityPlane:!0};this._polygon=new e.Bimface.Plugins.Geometry.Plane(i),this._polygon&&(t.outline?(t.outlineWidth&&this._polygon.setBorderWidth(t.outlineWidth),t.outlineColor&&this.setBorderColor(t.outlineColor),t.outlineOpacity&&this.setBorderOpacity(t.outlineOpacity)):this.clearBorder(),t.fill?(t.color&&this.setColor(t.color),t.opacity&&this._polygon.setOpacity(t.opacity)):this.clearPlane(),this.setAttributes(t.attributes),this.externalObjectManager&&this.externalObjectManager._addObject(this._name,this._polygon))}setAttributes(e){this.attributes=e}setColor(t){if(this._polygon){if("string"==typeof t||!t instanceof e.Web.Graphics.Color){let i=new e.Web.Graphics.Color(t,1);this._polygon.setColor(i)}else this._polygon.setColor(t);this.viewer.render()}}getColor(){if(this._polygon)return this._polygon.getColor()}destroy(){this.points=[],this._polygon&&this._polygon.dispose(),this._polygon=null;let e=this.externalObjectManager.getObjectIdByName(this._name);this.externalObjectManager.removeById(e)}}}();var Se=e.Bimface.Data.StatisticsDataManager.getInstance();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").EntityLayer=class extends q{constructor(e){Se.send("Glodon.Bimface.Layer.EntityLayer","bf_c_entityLayer_new"),e.name=e.name?e.name:"EntityLayer_Default",e.typeName="EntityLayer",e.priority=e.priority||5,super(e),this._entities=new Map,this.viewer=null,this.range=null,this.adjustCamera=this.adjustCamera.bind(this)}init(){this.viewer=this.getViewer(),this.addEvent()}addEvent(){this.viewer&&this.viewer.getEventManager().addEvent(e.Bimface.Viewer.ViewerGISEvent.CameraPositionChanged,this.adjustCamera)}removeEvent(){this.viewer&&this.viewer.getEventManager().removeEvent(e.Bimface.Viewer.ViewerGISEvent.CameraPositionChanged,this.adjustCamera)}adjustCamera(e){this.range&&this._entities.forEach((t=>{let i=t.getBox();if(i){let n=new THREE.Vector3(e.position.x,e.position.y,e.position.z);this.checkVisiable(i,n)?t.show():t.hide()}}))}checkVisiable(e,t){let i=Math.abs(e.distanceToPoint(t));return i<=this.range.max&&i>=this.range.min}setVisualRange(e){e&&(this.range=e)}getVisualRange(){return this.range}getId(){return this.id}show(){this._entities.forEach((e=>{e.show()}))}hide(){this._entities.forEach((e=>{e.hide()}))}addEntity(e){e&&(this._entities.set(e.id,e),e.setLayerId(this.id))}removeEntity(e){let t=this.getEntityById(e);t&&t.destroy(),this._entities.delete(e)}getEntityById(e){return this._entities.get(e)}getAllEntities(){return this._entities}destroy(){this._entities.forEach((e=>{e.destroy()})),this._entities.clear(),this.removeEvent()}parseGeoJson(e){let t=JSON.parse(e);if(!t||void 0===t.properties.type)return void console.log("Input geojson should be not empty!");if(!this.getViewer)return void console.warn("Please add EntityLayer into LayerManager first!");this.viewer=this.getViewer();let i=null;switch(t.properties.type){case"Polyline":case"Spline":i=this._createCurveEntity(t);break;case"polygon":i=this._createPolygonEntity(t)}i&&this.addEntity(i)}_createCurveEntity(t){let i=t.properties.style&&t.properties.style.color?t.properties.style.color:"#32D3A6",n=t.properties.style&&t.properties.style.width?t.properties.style.width:1,o=t.properties.style&&t.properties.style.lineType?t.properties.style.lineType:"solid",s=t.properties.attributes,r=[];if(t.geometry&&t.geometry.coordinates)for(let e=0;e<t.geometry.coordinates.length;e++){let i,n=t.geometry.coordinates[e];n.length<=1||(2===n.length?i={x:n[0],y:n[1]}:n.length>=3&&(i={x:n[0],y:n[1],z:n[2]}),r.push(i))}let a=null;a={type:t.properties.type.toLowerCase(),lineType:o,color:i,width:n,points:r,attributes:s};let l=new e.Bimface.Plugins.Entity.CurveEntity(this.viewer);return l.genGeometry(a),l}_createPolygonEntity(t){let i=t.properties.style&&t.properties.style.color?t.properties.style.color:"#32D3A6",n=t.properties.style&&t.properties.style.opacity?t.properties.style.opacity:1,o=!t.properties.style||!t.properties.style.outline||t.properties.style.outline,s=t.properties.style&&t.properties.style.outlineWidth?t.properties.style.outlineWidth:1,r=!t.properties.style||!t.properties.style.fill||t.properties.style.fill,a=t.properties.style&&t.properties.style.fillType?t.properties.style.fillType:"color",l=t.properties.style&&t.properties.style.outlineColor?t.properties.style.outlineColor:"#ffffff",h=t.properties.style&&t.properties.style.outlineOpacity?t.properties.style.outlineOpacity:1,d=t.properties.attributes;if(!o&&!r)return null;let c=[],u=[];if(t.geometry&&t.geometry.coordinates){let e,i=t.geometry.coordinates.length;if(!(i>0))return null;e=t.geometry.coordinates[0];for(let t=0;t<e.length;t++){let i,n=e[t];n.length<=1||(2===n.length?i={x:n[0],y:n[1]}:n.length>=3&&(i={x:n[0],y:n[1],z:n[2]}),c.push(i))}if(i>1)for(let e=1;e<t.geometry.coordinates.length;e++){let i=t.geometry.coordinates[e],n=[];for(let e=0;e<i.length;e++){let t,o=i[e];o.length<=1||(2===o.length?t={x:o[0],y:o[1]}:o.length>=3&&(t={x:o[0],y:o[1],z:o[2]}),n.push(t))}n.length>0&&u.push(n)}}let g=new e.Bimface.Plugins.Entity.PolygonEntity(this.viewer),p=null;return p={type:t.properties.type,opacity:n,color:i,outline:o,outlineWidth:s,fill:r,fillType:a,outlineColor:l,outlineOpacity:h,points:c,innerPoints:u,attributes:d},g.genGeometry(p),g}};const Be=e.Bimface.Data.StatisticsDataManager.getInstance();class _e extends ae{constructor(e){Be.send("Glodon.Bimface.Layer.DrawingLayer","bf_c_drawingLayer_new"),e.typeName="DrawingLayer",super(e),void 0===this._config.opacity&&(this._config.opacity=1)}init(){super.init()}destroy(e=!0){this.groundId&&(CLOUD.GroundDrawingManager.getInstance().deleteGroundDrawingById(this.groundId),this.groundId=null),super.destroy(e)}getId(){return super.getId()}show(){super.show()}hide(){super.hide()}getOpacity(){return super.getOpacity()}setOpacity(e){super.setOpacity(e)}getTransformation(){return super.getTransformation()}setTransformation(e){super.setTransformation(e)}setTranslation(e){super.setTranslation(e)}setRotationZ(e,t){super.setRotationZ(e,t)}setScale(e,t){super.setScale(e,t)}clampMode(e){let t=this.getViewer().getViewer().modelManager.modelCollection._layers;this.dwgLayer||t.map((e=>{e.fileId==this.modelId&&(this.dwgLayer=e)}));let i=[],n=!1;if(e.layerIds&&e.layerIds.map((e=>{let t=this.getViewer().getLayerManager().getLayer(e);t&&("TilesetLayer"==t.typeName&&i.push(t.model.modelId.toString()),"TileLayer"==t.typeName&&(n=!0))})),this.groundId&&(CLOUD.GroundDrawingManager.getInstance().deleteGroundDrawingById(this.groundId),this.groundId=null),e.mode){let o=[];"Ground"==e.mode?(t.map((e=>{e.isDemLayer&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)):"Model"==e.mode?(t.map((e=>{i.length>0?e.isObliquePhotography&&i.indexOf(e.id)>-1&&o.push(e):e.isObliquePhotography&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)):"Both"==e.mode&&(i.length>0||n?t.map((e=>{n&&e.isDemLayer&&o.push(e),e.isObliquePhotography&&i.indexOf(e.id)>-1&&o.push(e)})):t.map((e=>{(e.isObliquePhotography||e.isDemLayer)&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)),this.getViewer().render()}}projectToGround(e){}isProjectedToGround(){}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").DrawingLayer=_e;class Le{constructor(e){this.getLayerManager=()=>e,this.getViewer=e.getViewer,this._allModelInited=!1}buildLayers(t){let i,n,o={},s=[],r=[],a=this.getViewer();const l=t=>{switch(t.typeName){case"GroupLayer":const h=new Q(t);t.parent.add(h),t.children&&t.children.length>0&&t.children.forEach((e=>{e.parent=h,l(e)}));break;case"TileLayer":let d={};d.id=t.id,d.provider=t.provider,d.name=t.name,d.credit=t.credit,d.style=t.style,d.shadow=t.shadow,d.maxLevel=t.maxLevel,d.isVisible=!1!==t.isVisible,d.sectionable=!0===t.sectionable,d.tileLayerParent=t.parent,t.layerConfig&&(d.layerConfig=t.layerConfig),this._isValidUrl(t.url)&&(d.url=t.url),s.push(d);break;case"TerrainLayer":this._isValidUrl(t.url)?(o.useTerrain=!1!==t.isVisible,o.terrainPath=t.url,o.terrainViewToken=t.viewToken,o.modelId=t.modelId,o.databagId=t.databagId,o.terrainViewToken=t.viewToken,i=t.parent,n={id:t.id,name:t.name,isVisible:t.isVisible}):(o.useTerrain=!1!==t.isVisible,o.terrainPath=e.Bimface.Plugins.TileMap.Tile.getTerrainRootPath(this.getViewer()._opt.resourceHost),i=t.parent,n={id:t.id,name:t.name,isVisible:t.isVisible});break;case"BIMLayer":case"DrawingLayer":case"FeatureLayer":(t.viewToken||t.modelId&&t.databagId)&&(t.style&&t.style.color?t.disableUserData=!1:t.isVisible&&(t.disableUserData=CLOUD.Utils.isDefined(t.disableUserData)?t.disableUserData:a.disableUserData),r.push(t));break;case"TilesetLayer":(t.viewToken||t.modelId&&t.databagId)&&r.push(t)}};if("[object Array]"===Object.prototype.toString.call(t)){t={id:"root",name:"root",typeName:"GroupLayer",children:t}}t.parent=this.getLayerManager(),l(t);for(let e=0;e<s.length;e++)s[e].useTerrain=o.useTerrain,s[e].terrainPath=o.terrainPath,s[e].terrainViewToken=o.terrainViewToken,s[e].modelId=o.modelId,s[e].databagId=o.databagId,s[e].terrainViewToken=o.terrainViewToken;if(o.databagId)this.loadTerrainConfig(o.databagId,s,(()=>{this.startLoad(s,n,i,r)}));else if(o.terrainViewToken){const t=this.getViewer();let a=e.Bimface.Authentication.AuthenticationManager,l=new e.Bimface.Authentication.AuthenticationConfig;l.viewToken=o.terrainViewToken,l.APIHost=t._opt.APIHost,(this.authenticate=new a(l)).authenticate((e=>{this.loadTerrainConfig(e.databagId,s,(()=>{this.startLoad(s,n,i,r)}))}),(e=>{console.log("the invalid terrain viewtoken"),s.map((e=>e.useTerrain=!1)),this.startLoad(s,void 0,i,r)}))}else this.startLoad(s,n,i,r)}loadTerrainConfig(e,t,i){const n=this.getViewer(),o=`${n._opt.resourceHost}/${e}/resource/v3/model/config.json`;t.map((t=>t.terrainPath=`${n._opt.resourceHost}/${e}/resource/v3/model/terrain/`));let s=new THREE.FileLoader;s.setResponseType("json"),s.load(o,(e=>{t.map((t=>t.terrainOnlineConfig=e.metadata)),i&&i()}))}startLoad(t,i,n,o){for(let e=t.length-1;e>=0;e--)if(t[e].tileLayerParent){let i=new ne(t[e]);t[e].tileLayerParent.add(i)}this.getViewer().firstTileLayerId=t[0].id,i&&(i.baseMap=this.getLayerManager().baseMap,this.getLayerManager().terrainLayer=new se(i),n.add(this.getLayerManager().terrainLayer)),this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.SceneAdded,(()=>{this.getViewer().initModelSync?this._loadModelSync(o):this._loadModelAsyn(o)}))}_loadModelSync(t){if(t.length>0){let i;const n=()=>{if(t.length>0){let e=this.getViewer().getViewer().getCamera();e!==i&&this.sortModel(t),i=e;const[n]=t.splice(0,1);let o=null;switch(n.typeName){case"BIMLayer":default:o=new pe(n);break;case"FeatureLayer":o=new be(n);break;case"TilesetLayer":o=new Ee(n);break;case"DrawingLayer":o=new _e(n)}n.parent.add(o)}else this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer .DrawingLayer").forEach((e=>e.isVisible&&e.loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.removeEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),this._allModelInited=!0,this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.AllModelInited)};this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.addEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),n()}}_loadModelAsyn(t){this.sortModel(t);let i=t.length;const n=()=>{--i,0===i&&(this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer .DrawingLayer").forEach((e=>e.isVisible&&e.loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.removeEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),this._allModelInited=!0,this.getViewer().fireEvent(e.Bimface.Viewer.ViewerGISEvent.AllModelInited))};for(this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.addEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n);t.length>0;){const[e]=t.splice(0,1);let i=null;switch(e.typeName){case"BIMLayer":default:i=new pe(e);break;case"FeatureLayer":i=new be(e);break;case"TilesetLayer":i=new Ee(e);break;case"DrawingLayer":i=new _e(e)}e.parent.add(i)}}sortModel(e,t){t=t||{},e.forEach((e=>{if(!e.box3&&e.boundingBox&&e.boundingBox.min&&e.boundingBox.max){let{x:t,y:i,z:n}=this.getViewer().worldToScene(e.boundingBox.min),{x:o,y:s,z:r}=this.getViewer().worldToScene(e.boundingBox.max);e.box3=new THREE.Box3(new THREE.Vector3(t,i,n),new THREE.Vector3(o,s,r))}})),e.sort(((e,i)=>{let n=e.isVisible,o=i.isVisible;if(!1!==t.visible&&n!==o)return n?-1:1;if(!1===t.visible||n){if(!1!==t.priority){let t=e.priority||3,n=i.priority||3;if(t!==n)return t-n}if(!1!==t.boundingBox){if(!i.box3)return-1;if(!e.box3)return 1;let t=this.getViewer().getViewer().camera.frustum;if(!t.intersectsBox(i.box3))return-1;if(!t.intersectsBox(e.box3))return 1;let n=this.getViewer().getViewer().camera.position.clone();return e.box3.distanceToPoint(n)-i.box3.distanceToPoint(n)}}}))}loadLayer(t,i=!1){if(this._allModelInited){if(t instanceof Array){let n=[];if(t.forEach((e=>{let t=this.getLayerManager().getLayer(e);t&&(t.loaded?i&&t.show():(t._config.disableUserData=!0,n.push(t._config)))})),n.length>0){this.sortModel(n,{visible:!1});let t=n.length,o=0,s=n.map((e=>e.id));const r=a=>{s.includes(a)&&(o++,i||this.getLayerManager().getLayer(a).hide()),o===t&&(n.forEach((e=>this.getLayerManager().getLayer(e.id).loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,r))};this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,r),n.forEach((e=>this.getLayerManager().getLayer(e.id).show()))}}}else this.getViewer().addEventListener(e.Bimface.Viewer.ViewerGISEvent.AllModelInited,(()=>this.loadLayer(t)))}showLayers(e){this.loadLayer(e,!0)}_isValidUrl(e){return!!e&&/(https?):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/.test(e)}}class De extends Z{constructor(e){super({id:"LayerManager",name:"LayerManager",typeName:"LayerManager",userData:"LayerManager",viewer:e});let t=new Le(this);this.getLoadManager=()=>t}getLayerConfigsObject(){let e=[],t=this.getViewer()._config.resources;if(t){let i=this.getRootLayer(),n={id:i.id,name:i.name,typeName:i.typeName,isVisible:i.isVisible,children:t};e.push(n)}const i=(e,t)=>{const{id:n,name:o,typeName:s,isVisible:r}=e;let a={id:n,name:o,typeName:s,isVisible:r,parentId:e.parent?e.parent.id:""};if("GroupLayer"!=s&&(a.priority=e.priority),"BIMLayer"===s||"FeatureLayer"===s||"TilesetLayer"===s||"DrawingLayer"===s){if("destroyed"===e.loadStatus)return;if(a.modelId=e.modelId,a.modelType=e.modelType,e.viewToken&&(a.viewToken=e.viewToken),e.databagId&&(a.databagId=e.databagId),e.model){let t=e.model.getModelTransformationAdaptedUnit();a.transformation=t?[...t]:void 0}}if(t instanceof Array){let[e]=t.filter((e=>e.id===a.id));if(e){for(let t in a)a.hasOwnProperty(t)&&void 0!==a[t]&&(e[t]=a[t]);a=e}else t.push(a)}e.children.length>0&&(a.children=a.children||[],e.children.forEach((e=>{i(e,a.children)})))};return i(this.getRootLayer(),e),1===e.length?e[0]:e.length>1?e:void 0}buildLayers(e){return this.getLoadManager().buildLayers(e)}showLayers(e){return this.getLoadManager().showLayers(e)}getRootLayer(){if(0===this.children.length){const e=new Q({id:"root",name:"root"});this.add(e)}return this.children[0]}getLayer(e){const[t]=this.query(`#${e}`);return t}getLayerByType(e){return this.query({typeName:e})}addLayer(e,t){(this.getLayer(t)||this.getRootLayer()).add(e)}removeLayer(e){const t=this.getLayer(e);if(t&&t.parent.remove(t),"GroupLayer"===t.typeName&&"root"!==e&&t.getParent()){let i=[],n=t.getParent();for(;n;)i.push(n.id),n=n.getParent();i.reverse().splice(0,2);let o=this.getViewer()._config.resources;if(i.length>0)for(;i.length>0;){let[e]=o.filter((e=>e.id===i[0]));if(!e||!e.children){o=void 0;break}o=e.children,i.splice(0,1)}if(o){let[t]=o.filter((t=>t.id===e));if(t){let e=o.indexOf(t);o.splice(e,1)}}}}removeLayerByCondition(e){this.query(e).forEach((e=>{e.parent.remove(e)}))}moveLayer(e,t){const i=this.getLayer(e),n=this.getLayer(t);i&&n&&(i.parent.children.splice(i.parent.children.indexOf(i),1),n.children.push(i),i.parent=n)}zoomToLayer(e,t){const i=this.getLayer(e);if(i&&i.model){let e=i.model.modelId,n=this.getViewer().getViewer().getModelManager().modelCollection.getById(e).getBoundingBoxWorld(),o={};o.boundingBox=n,o.margin=.5,o.duration=1e3,this.getViewer().zoomToBoundingBox(o,this._getDataUtil().assertType(t,"func")?t:void 0)}if(i&&"ExternalObjectLayer"===i.typeName){let e=i.getExternalObjectManager().getBoundingBoxWorld();if(e.isEmpty())return;let n={};n.boundingBox=e,n.margin=.5,n.duration=1e3,this.getViewer().zoomToBoundingBox(n,this._getDataUtil().assertType(t,"func")?t:void 0)}}setLayerPriority(e,t){let i=this.getLayer(e);i&&(i.priority=t)}getLayerPriority(e){let t=this.getLayer(e);if(t)return t.priority}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").LayerManager=De;class Ae{constructor(t){this._viewer=t;const i=e.Web.Lang.Utility.DataUtil;this.dataUtil=i,this._panFactor=5}init(){if(!this._viewer.getLayerManager().baseMap)return;const e=this.getCloudViewer().cameraControl;e.maxPitch=Math.PI/2,e.minPitch=-Math.PI/2;const t=this._viewer._config,i=t.homeView.position;let n=this._viewer.getLayerManager().baseMap?this._viewer.getLayerManager().baseMap.tileManager.lonLat2Mercator(i.lon,i.lat):{x:0,y:-1113.1366825229488};n.z=i.alt;const o=t.homeView.orientation,s=o.yaw;let r=o.pitch;r>=Math.PI/2&&(r=Math.PI/2-Math.PI/1e3),r<=-Math.PI/2&&(r=Math.PI/1e3-Math.PI/2),this.setCameraFromYawPitch({position:n,yaw:s,pitch:r},!0),this.defaultHomeview=this.getCameraStatus()}setCameraFromYawPitch(e,t){const i=this.getCameraStatus();let n=e.yaw;n>2*Math.PI&&(n-=2*Math.PI);let o=e.pitch;o>Math.PI&&(o-=2*Math.PI),o<-Math.PI&&(o+=2*Math.PI);let s=e.position;if(null!=this.cameraMinimumElevation&&e.isDownDirection&&i.position.z<this.cameraMinimumElevation)return;let r=e.target;const a=new THREE.Vector2(0,1).rotateAround(new THREE.Vector2(0,0),n),l=Math.tan(o),h=new THREE.Vector3(a.x,a.y,l);h.normalize();const d=e.distance||1e3,c=h.clone().multiplyScalar(d);if(s)!0===s&&(s=new THREE.Vector3(i.position.x,i.position.y,i.position.z)),i.position=s,i.target=s.clone().add(c);else if(r){!0===r&&(r=new THREE.Vector3(i.target.x,i.target.y,i.target.z)),s=new THREE.Vector3(i.position.x,i.position.y,i.position.z);const e=new THREE.Line3(s,r),t=e.distance();if(i.position.z>0&&r.z<0||i.position.z<0&&r.z>0){const n=new THREE.Plane(new THREE.Vector3(0,0,1),0),o=new THREE.Vector3;n.intersectLine(e,o);const r=o.clone().sub(s).length()/t,a=1-r;i.target=o.clone().add(h.clone().multiplyScalar(a*t)),i.position=o.clone().sub(h.clone().multiplyScalar(r*t))}else i.position=r.clone().sub(h.clone().multiplyScalar(t)),i.target=r}i.up={x:0,y:0,z:1},this.setCameraStatus(i,void 0,t)}getYawPitch(){const e=this.getCameraStatus(),t=new THREE.Vector3(e.target.x,e.target.y,e.target.z),i=new THREE.Vector3(e.position.x,e.position.y,e.position.z),n=t.clone().sub(i),o=this.getCloudViewer().camera.realUp.y>0?1:-1,s=new THREE.Vector2(n.x*o,n.y*o),r=new THREE.Vector2(0,1);let a=s.angle()-r.angle();a<0&&(a+=2*Math.PI);let l=new THREE.Vector2(Math.sqrt(n.x*n.x+n.y*n.y)*o,n.z).angle();return l>Math.PI&&(l-=2*Math.PI),{yaw:a,pitch:l}}panInDirection(e){const t=this.getCameraStatus(),i=new THREE.Vector3(t.target.x,t.target.y,t.target.z),n=new THREE.Vector3(t.position.x,t.position.y,t.position.z),o=i.clone().sub(n);o.z=0,o.normalize();let s=e?this._panFactor:-1*this._panFactor;o.multiplyScalar(s),i.add(o),n.add(o),t.target=i,t.position=n,t.up={x:0,y:0,z:1},this.setCameraStatus(t,void 0,!0)}panInHorizontal(e){const t=this.getCameraStatus(),i=new THREE.Vector3(t.target.x,t.target.y,t.target.z),n=new THREE.Vector3(t.position.x,t.position.y,t.position.z),o=i.clone().sub(n);o.z=0,o.applyAxisAngle(new THREE.Vector3(0,0,1),Math.PI/2),o.normalize();let s=e?this._panFactor:-1*this._panFactor;o.multiplyScalar(s),i.add(o),n.add(o),t.target=i,t.position=n,t.up={x:0,y:0,z:1},this.setCameraStatus(t,void 0,!0)}panInLat(e){const t=this.getCameraStatus(),i=new THREE.Vector3(t.target.x,t.target.y,t.target.z),n=new THREE.Vector3(t.position.x,t.position.y,t.position.z),o=new THREE.Vector3(1,0,0);let s=e?this._panFactor:-1*this._panFactor;o.multiplyScalar(s),i.add(o),n.add(o),t.target=i,t.position=n,t.up={x:0,y:0,z:1},this.setCameraStatus(t,void 0,!0)}getCloudViewer(){return this._viewer.getViewer()}getCameraStatus(){const e=JSON.parse(this.getCloudViewer().getCamera());return e.coordinateSystem="world",e}setCameraStatus(e,t,i){"object"==typeof e&&(e=JSON.stringify(e)),this.getCloudViewer().setCamera(e,!1,t,i)}recordCustomHomeview(e){this.customedHomeview=e}getCustomHomeview(){return this.customedHomeview}getDefaultHomeview(){return this.defaultHomeview}getHomeView(){return this.getCustomHomeview()||this.getDefaultHomeview()}setHomeView(e){this.recordCustomHomeview(e)}startAutoRotate(e,t){const i=this.getCloudViewer();if(0==e)return void this.stopAutoRotate();this._animationFrameHandle&&this.stopAutoRotate();let n=i.getRotationCenter(),o=i.cameraControl.calculatePivot(y.RotatePivotMode.CENTER,null);void 0!==t?o=this._viewer.worldToScene(t):n&&(o=n);const s=()=>{i.rotateByAxis(e,"x",o),i.render(),this._animationFrameHandle=requestAnimationFrame(s)};s()}stopAutoRotate(){this._animationFrameHandle&&cancelAnimationFrame(this._animationFrameHandle)}zoomIn(){this.getCloudViewer().zoomIn(.01)}zoomOut(){this.getCloudViewer().zoomOut(.01)}zoomToBoundingBox(e,t){let i=e.boundingBox,n=null!=e.margin?e.margin:.5,o=null!=e.duration?e.duration:1e3;if(!i||!i.min||!i.max)return;const s=[[i.min.x,i.min.y,i.min.z],[i.max.x,i.max.y,i.max.z]];this.getCloudViewer().zoomToBBox(y.Utils.computeBBox(s),n,void 0,"[object Function]"===Object.prototype.toString.call(t)?t:void 0,o,e.direction)}setCameraMinimumElevation(e){this.getCloudViewer().setCameraMinimumElevation(e),this.cameraMinimumElevation=e}enableRotate(e=!0){y.EditorConfig.NoRotate=!e,this.getCloudViewer().render()}enablePan(e=!0){y.EditorConfig.NoPan=!e,this.getCloudViewer().render()}enablePitch(e=!0){const t=!e;this.getCloudViewer().lockAxisZ(t),this.getCloudViewer().render()}enableZoom(e=!0){y.EditorConfig.NoZoom=!e,this.getCloudViewer().render()}}class Ve{constructor(e){this.viewer=e,this.globalUnitUtil=e.globalUnitUtil,this._camera=new Ae(e),this.console=e.console,P(this),this._editorConfig={NoZoom:CLOUD.EditorConfig.NoZoom,NoPan:CLOUD.EditorConfig.NoPan,NoRotate:CLOUD.EditorConfig.NoRotate}}convertStatus(e,t){if(!(e&&t&&c.assertType(e,"obj")&&c.assertType(t,"str")))return void this.console.warn("invalid params in convertStatus(status, mode)");const{aspect:i,near:n,far:o,zoom:s,version:r}=e,a={aspect:i,near:n,far:o,zoom:s,version:r};if("LatLon"===t){if(!c.hasProperties(e.position,"x","y","z")||!c.hasProperties(e.target,"x","y","z"))return void this.console.warn("invalid params in convertStatus(status, mode)");const t=new THREE.Vector3(e.target.x,e.target.y,e.target.z),i=new THREE.Vector3(e.position.x,e.position.y,e.position.z),n=t.clone().sub(i),o=e.up.y>0?1:-1,s=new THREE.Vector2(n.x*o,n.y*o),r=new THREE.Vector2(0,1);let l=s.angle()-r.angle();l<0&&(l+=2*Math.PI);let h=new THREE.Vector2(Math.sqrt(n.x*n.x+n.y*n.y)*o,n.z).angle();h>Math.PI&&(h-=2*Math.PI),a.orientation={pitch:h,yaw:l,roll:0};const{lat:d,lon:u}=this.viewer.worldToLatLon(i);a.position={lat:d,lon:u,alt:i.z},a.coordinateSystem="CGCS-2000"}else if("World"===t){if(!c.hasProperties(e.position,"lat","lon","alt")||!c.hasProperties(e.orientation,"pitch","yaw","roll"))return void this.console.warn("invalid params in convertStatus(status, mode)");const{lat:t,lon:i,alt:n}=e.position;a.position=this.viewer.latLonToWorld({latLon:{lat:t,lon:i}}),a.position.z=n;const o=new THREE.Vector3(a.position.x,a.position.y,a.position.z);let{yaw:s,pitch:r}=e.orientation;s>2*Math.PI&&(s-=2*Math.PI),r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI);const l=new THREE.Vector2(0,1).rotateAround(new THREE.Vector2(0,0),s),h=Math.tan(r),d=new THREE.Vector3(l.x,l.y,h);d.normalize();const u=o.clone().add(d.clone().multiplyScalar(1e3));a.target={x:u.x,y:u.y,z:u.z},a.up={x:0,y:0,z:1},a.coordinateSystem="world"}return a}getStatus(){return this._camera.getCameraStatus()}getStatusWorld(e){let t=Object.assign({},e);if("CGCS-2000"===e.coordinateSystem&&(t=this.convertStatus(e,"World")),"world"===t.coordinateSystem)return t}setStatus(e,t){let i=this.getStatusWorld(e);i&&this._camera.setCameraStatus(i,t)}getHomeView(){return this._camera.getHomeView()}setHomeView(e){let t=this.getStatusWorld(e);t&&this._camera.setHomeView(t)}restoreHomeView(){this.setHomeView(this._camera.getDefaultHomeview())}home(){this.setStatus(this.getHomeView())}getMinimumElevation(){return this._camera.cameraMinimumElevation}setMinimumElevation(e){this._camera.setCameraMinimumElevation(e)}startAutoRotate(e,t){this._camera.startAutoRotate(e,t)}stopAutoRotate(){this._camera.stopAutoRotate()}zoomIn(){this._camera.zoomIn()}zoomOut(){this._camera.zoomOut()}zoomToBoundingBox(e,t,i,n){let o,s=new Object;if(arguments[0]&&arguments[0].boundingBox){if(!(e=arguments[0].boundingBox)||!e.min||!e.max)return;return i=arguments[0].margin,n=arguments[0].duration,o=arguments[0].direction,void 0===i&&(i=.5),void 0===n&&(n=1e3),arguments[1]&&(t=arguments[1]),s.boundingBox=e,s.margin=i,s.duration=n,s.direction=o,void this._camera.zoomToBoundingBox(s,t)}if(1===arguments.length)e=arguments[0];else if(2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],arguments[1]>100?(i=.5,n=arguments[1]):(i=arguments[1],n=1e3),t=void 0;else if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],t=arguments[1],i=.5,n=1e3;else if(3===arguments.length){for(let e=0;e<arguments.length;e++){const o=arguments[e];"[object Function]"===Object.prototype.toString.call(o)?t=o:"[object Number]"===Object.prototype.toString.call(o)&&(o>100?n=o:i=o)}e=arguments[0],"[object Function]"!==Object.prototype.toString.call(t)&&(t=void 0),void 0===n&&(n=1e3),void 0===i&&(i=.5)}s.boundingBox=e,s.margin=i,s.duration=n,this._camera.zoomToBoundingBox(s,t)}enableRotate(e=!0){this._camera.enableRotate(e)}enablePan(e=!0){this._camera.enablePan(e)}enablePitch(e=!0){this._camera.enablePitch(e)}enableZoom(e=!0){this._camera.enableZoom(e)}setCameraAnimation(t){if(this._animationOption&&this.clearCameraAnimation(),this._animationOption=t,!t.pathAnimation instanceof e.Bimface.Plugins.Animation.PathAnimation)return void this.console.warn("The parameter option.pathAnimation is not type of Glodon.Bimface.Plugins.Animation.PathAnimation.");let i=null==t.distance?5:t.distance,n=null==t.angle?0:t.angle;this._animationOption.distance=i,this._animationOption.angle=n;let o=this.viewer.getViewer().camera;t.pathAnimation._setCameraAnimation(o,i,n),this._editorConfig.NoZoom=CLOUD.EditorConfig.NoZoom,this._editorConfig.NoPan=CLOUD.EditorConfig.NoPan,this._editorConfig.NoRotate=CLOUD.EditorConfig.NoRotate,CLOUD.EditorConfig.NoZoom=!0,CLOUD.EditorConfig.NoPan=!0,CLOUD.EditorConfig.NoRotate=!0}getCameraAnimation(){return this._animationOption}clearCameraAnimation(){this._animationOption&&(this._animationOption.pathAnimation.camera=null,this._animationOption=null,CLOUD.EditorConfig.NoZoom=this._editorConfig.NoZoom,CLOUD.EditorConfig.NoPan=this._editorConfig.NoPan,CLOUD.EditorConfig.NoRotate=this._editorConfig.NoRotate)}}var Re,Oe,ke;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Camera").CameraGIS=Ve,function(){var t="Bimface.ElementManager.EffectManager",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager");const o="effectGroup";n.EffectManager=class{constructor(t){this.viewer=t,this.fileIds=[],this.effectAndFileObject={id:"root",isVisible:!0,type:o,children:[]},this.effectTypeExtObjMng=[e.Bimface.Common.Type.EffectType.PrismPoint,e.Bimface.Common.Type.EffectType.CurveAnimation],this.effectType=[e.Bimface.Common.Type.EffectType.PrismPoint,e.Bimface.Common.Type.EffectType.CurveAnimation,e.Bimface.Common.Type.EffectType.FanScan,e.Bimface.Common.Type.EffectType.WaterEffect,e.Bimface.Common.Type.EffectType.RingScan,e.Bimface.Common.Type.EffectType.SkyBoxManager,e.Bimface.Common.Type.EffectType.MapStyle,e.Bimface.Common.Type.EffectType.Rain,e.Bimface.Common.Type.EffectType.FireEffect,e.Bimface.Common.Type.EffectType.WallEffect],this.isAddSkyBoxManager=!1,this.isAddMapStyle=!1,this.isAddRain=!1,this._createExternalObjectManager(),P(this)}_createExternalObjectManager(){this._externalObjectManager=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this.viewer)}addEffect(n,o){let s=n&&n.getSenceType&&n.getSenceType();if(this.effectType.indexOf(s)<0)return;if(!o||!o.id||!o.name)return;i.send(t,"addEffect");let r={[e.Bimface.Common.Type.EffectType.PrismPoint]:"addEffect_effectType_prismPoint",[e.Bimface.Common.Type.EffectType.CurveAnimation]:"addEffect_effectType_curveAnimation",[e.Bimface.Common.Type.EffectType.FanScan]:"addEffect_effectType_fanScan",[e.Bimface.Common.Type.EffectType.RingScan]:"addEffect_effectType_ringScan",[e.Bimface.Common.Type.EffectType.WaterEffect]:"addEffect_effectType_waterEffect",[e.Bimface.Common.Type.EffectType.SkyBoxManager]:"addEffect_effectType_skyBoxManager",[e.Bimface.Common.Type.EffectType.MapStyle]:"addEffect_effectType_mapStyle",[e.Bimface.Common.Type.EffectType.Rain]:"addEffect_effectType_rain",[e.Bimface.Common.Type.EffectType.FireEffect]:"addEffect_effectType_fireEffect",[e.Bimface.Common.Type.EffectType.WallEffect]:"addEffect_effectType_wallEffect"};i.send(t,r[s]);let a=[];if(s===e.Bimface.Common.Type.EffectType.CurveAnimation){let t=n.getCurves();for(let i=0;i<t.length;i++){let n="curve"+e.Web.Lang.Utility.UUID.createUUID(),o=this._externalObjectManager.loadObject({name:n,object:t[i]});a.push(o)}}else if(s===e.Bimface.Common.Type.EffectType.PrismPoint){let e;n.initSizeByViewer(this.viewer),n.objectId&&this._externalObjectManager.getAllObjectIds().indexOf(n.objectId)>=0?e=n.objectId:(e=this._externalObjectManager._addObject(n.getId(),n.getPointIns()),n.objectId=e),a=[e]}else{if(s===e.Bimface.Common.Type.EffectType.SkyBoxManager){if(this.isAddSkyBoxManager)return;this.isAddSkyBoxManager=!0}if(s===e.Bimface.Common.Type.EffectType.MapStyle){if(this.isAddMapStyle)return;this.isAddMapStyle=!0}if(s===e.Bimface.Common.Type.EffectType.Rain){if(this.isAddRain)return;this.isAddRain=!0}}this.fileIds.indexOf(o.parentId)<0&&(o.parentId="root");let l={...o,isVisible:!0,type:n.getSenceType(),extObjMngIds:a,parentId:o.parentId||"root",effect:n};this.addEffectOrFile(this.effectAndFileObject,l),this.showEffect(l)}addGroup(e){if(!e||!e.id||!e.name)return;this.fileIds.push(e.id),this.fileIds.indexOf(e.parentId)<0&&(e.parentId="root");let t={...e,isVisible:!0,type:o,parentId:e.parentId||"root",children:[]};this.addEffectOrFile(this.effectAndFileObject,t)}addEffectOrFile(e,t){if(e.id===t.parentId||"root"===e.id&&!t.parentId)return e.children.unshift(t),this.handleParentVisibleShow(t.parentId),!0;for(let i=0;i<e.children.length;i++)if(e.children[i].type===o){if(this.addEffectOrFile(e.children[i],t))return!0}}getEffect(e){let t=this.getEffectObjById(this.effectAndFileObject,e);return t&&t.effect?t.effect:t}getEffectObj(e){return this.getEffectObjById(this.effectAndFileObject,e)}getEffects(e){let t=[];if(e&&(e.ids||e.type)){let i=e.ids;if(e.ids)for(let e=0;e<i.length;e++){let n=this.getEffectObjById(this.effectAndFileObject,i[e]);n&&t.push(n.effect)}else{if(this.effectType.indexOf(e.type)<0)return[];let i=this.getEffectObjByType(this.effectAndFileObject,e.type);for(let e=0;e<i.length;e++)t.push(i[e].effect)}}return t}getEffectObjById(e,t){if(e.id===t&&this.effectType.indexOf(e.type)>=0)return e;if(e.type===o)for(let i=0;i<e.children.length;i++){let n=this.getEffectObjById(e.children[i],t);if(n)return n}}getFileObjById(e,t){if(e.id===t&&e.type===o)return e;if(e.type===o)for(let i=0;i<e.children.length;i++)if(e.children[i].type===o){let n=this.getFileObjById(e.children[i],t);if(n)return n}}getEffectObjByType(e,t){let i=[];if(e.type===t&&i.push(e),e.type===o)for(let n=0;n<e.children.length;n++){let o=this.getEffectObjByType(e.children[n],t);i=[...i,...o]}return i}hide(e){if("object"==typeof e)if(!0===e.all)this.hideAll();else if(e.ids&&e.ids.length>0){let t=e.ids;for(let e=0;e<t.length;e++)if(this.fileIds.indexOf(t[e])>=0){let i=this.getFileObjById(this.effectAndFileObject,t[e]);i&&this.hideEffectAndFile(i),i&&this.handleParentVisibleHide(i.parentId)}else{let i=this.getEffectObjById(this.effectAndFileObject,t[e]);i&&this.hideEffect(i)}}else if(e.type){if(this.effectType.indexOf(e.type)<0)return;this.hideEffectByType(this.effectAndFileObject,e.type)}}hideAll(){this.hideEffectAndFile(this.effectAndFileObject)}hideEffectAndFile(e){if(e.isVisible=!1,e.type===o)for(let t=0;t<e.children.length;t++)this.hideEffectAndFile(e.children[t]);else this.hideEffect(e)}hideEffectByType(e,t){if(e.type===o)for(let i=0;i<e.children.length;i++)this.hideEffectByType(e.children[i],t);else e.type===t&&this.hideEffect(e)}hideEffect(t){t.isVisible=!1,this.handleParentVisibleHide(t.parentId),t.type===e.Bimface.Common.Type.EffectType.MapStyle?(t.effect.setStyle({}),this.viewer.getLayerManager().getLayerByType("TileLayer").map((e=>e.setStyle({})))):t.type===e.Bimface.Common.Type.EffectType.Rain?t.effect.enableEffect(!1):this.effectTypeExtObjMng.indexOf(t.type)<0?t.effect.hide():t.type===e.Bimface.Common.Type.EffectType.CurveAnimation?t.effect.curves.map((e=>{e.hide()})):this._externalObjectManager.hide({ids:t.extObjMngIds})}handleParentVisibleHide(e){if(!e)return;let t=this.getFileObjById(this.effectAndFileObject,e),i=!1;t.children.forEach((e=>{!0===e.isVisible&&(i=!0)})),i||(t.isVisible=!1,this.handleParentVisibleHide(t.parentId))}show(e){if("object"==typeof e)if(!0===e.all)this.showAll();else if(e.ids&&e.ids.length>0){let t=e.ids;for(let e=0;e<t.length;e++)if(this.fileIds.indexOf(t[e])>=0){let i=this.getFileObjById(this.effectAndFileObject,t[e]);i&&this.showEffectAndFile(i),i&&this.handleParentVisibleShow(i.parentId)}else{let i=this.getEffectObjById(this.effectAndFileObject,t[e]);i&&this.showEffect(i)}}else if(e.type){if(this.effectType.indexOf(e.type)<0)return;this.showEffectByType(this.effectAndFileObject,e.type)}}showAll(){this.showEffectAndFile(this.effectAndFileObject)}showEffectAndFile(e){if(e.isVisible=!0,e.type===o)for(let t=0;t<e.children.length;t++)this.showEffectAndFile(e.children[t]);else this.showEffect(e)}showEffectByType(e,t){if(e.type===o)for(let i=0;i<e.children.length;i++)this.showEffectByType(e.children[i],t);else e.type===t&&this.showEffect(e)}showEffect(t){t.isVisible=!0,this.handleParentVisibleShow(t.parentId),t.type===e.Bimface.Common.Type.EffectType.MapStyle?(t.effect.setStyle(JSON.parse(JSON.stringify(t.effect.getLastValidMapStyle()))),this.viewer.getLayerManager().getLayerByType("TileLayer").map((e=>e.setStyle(JSON.parse(JSON.stringify(t.effect.getLastValidMapStyle())))))):t.type===e.Bimface.Common.Type.EffectType.Rain?t.effect.enableEffect(!0):this.effectTypeExtObjMng.indexOf(t.type)<0?t.effect.show():t.type===e.Bimface.Common.Type.EffectType.CurveAnimation?t.effect.curves.map((e=>{e.show()})):this._externalObjectManager.show({ids:t.extObjMngIds})}handleParentVisibleShow(e){if(!e)return;let t=this.getFileObjById(this.effectAndFileObject,e);t.isVisible||(t.isVisible=!0,this.handleParentVisibleShow(t.parentId))}remove(e,t=!1){if("object"==typeof e)if(!0===e.all)this.removeAll(t);else if(e.ids&&e.ids.length>0){let i=e.ids;for(let e=0;e<i.length;e++)this.fileIds.indexOf(i[e])>=0?this.removeFileById(this.effectAndFileObject,i[e],t):this.removeEffectById(this.effectAndFileObject,i[e],t)}else e.type&&this.removeEffectByType(this.effectAndFileObject,e.type,t)}removeAll(e){this.removeEffectAndFile(this.effectAndFileObject,e),this.effectAndFileObject.children=[],this.isAddSkyBoxManager=!1,this.isAddMapStyle=!1,this.isAddRain=!1}removeEffectAndFile(e,t){if(e.type===o){for(let i=0;i<e.children.length;i++)this.removeEffectAndFile(e.children[i],t);let i=this.fileIds.indexOf(e.id);this.fileIds.splice(i,1)}else this.removeEffect(e,t)}removeFileById(e,t,i){for(let n=0;n<e.children.length;n++)if(e.children[n].type===o){if(e.children[n].id===t)return this.removeEffectAndFile(e.children[n],i),e.children.splice(n,1),this.handleParentVisibleHide(e.id),!0;if(this.removeFileById(e.children[n],t,i))return}}removeEffectById(e,t,i){for(let n=0;n<e.children.length;n++)if(e.children[n].type===o){if(this.removeEffectById(e.children[n],t,i))return}else if(e.children[n].id===t)return this.removeEffect(e.children[n],i),e.children.splice(n,1),this.handleParentVisibleHide(e.id),!0}removeEffectByType(e,t,i){if(e.type===o)for(let n=0;n<e.children.length;n++)e.children[n].type===o?this.removeEffectByType(e.children[n],t,i):e.children[n].type===t&&(this.removeEffect(e.children[n],i),e.children.splice(n--,1),this.handleParentVisibleHide(e.id))}removeEffect(t,i){if(t.type===e.Bimface.Common.Type.EffectType.MapStyle)this.isAddMapStyle=!1,t.effect.setStyle({}),this.viewer.getLayerManager().getLayerByType("TileLayer").map((e=>e.setStyle({})));else if(t.type===e.Bimface.Common.Type.EffectType.Rain)this.isAddRain=!1,t.effect.enableEffect(!1);else if(t.type===e.Bimface.Common.Type.EffectType.SkyBoxManager)this.isAddSkyBoxManager=!1,t.effect.hide(),i&&t.effect.destroy();else{if(this.effectTypeExtObjMng.indexOf(t.type)>=0)for(let e=0;e<t.extObjMngIds.length;e++)this._externalObjectManager.removeById(t.extObjMngIds[e]);else t.effect.hide();i&&t.effect.destroy&&t.effect.destroy()}}update(){this.updateEffect(this.effectAndFileObject)}updateEffect(e){if(e.type?e.type===o:e.typeName===o)for(let t=0;t<e.children.length;t++)this.updateEffect(e.children[t]);else e.effect.update&&e.effect.update()}getEffectsObject(){return this.getFileParams(this.effectAndFileObject)}getObjectsInsideFoler(e){return this.getFileObjById(this.effectAndFileObject,e)}getFileParams(e){let t=[];for(let i=0;i<e.children.length;i++)if(e.children[i].type?e.children[i].type===o:e.children[i].typeName===o){let n=this.getFileParams(e.children[i]);t.push({id:e.children[i].id,type:e.children[i].type,name:e.children[i].name,isVisible:e.children[i].isVisible,children:n,parentId:e.children[i].parentId})}else t.push(this.getEffectParams(e.children[i]));return t}getEffectParams(t){return{id:t.id,type:t.type,name:t.name,isVisible:t.isVisible,parentId:t.parentId,params:t.type===e.Bimface.Common.Type.EffectType.MapStyle?t.effect.getLastValidMapStyle():t.effect.getParams()}}init(e){e&&(this.effectAndFileObject.children=e,this.initFile(this.effectAndFileObject))}initFile(e){for(let t=0;t<e.children.length;t++)e.children[t].type===o?(this.fileIds.push(e.children[t].id),this.initFile(e.children[t])):this.initEffect(e.children[t])}initEffect(t,i=!0){if(t.type===e.Bimface.Common.Type.EffectType.PrismPoint){let n=new e.Bimface.Plugins.Anchor.PrismPointConfig;n.position=t.params.position,n.duration=t.params.duration,n.size=t.params.size,n.color=new e.Web.Graphics.Color(t.params.color.red,t.params.color.green,t.params.color.blue,t.params.color.alpha),n.wireframeColor=new e.Web.Graphics.Color(t.params.wireframeColor.red,t.params.wireframeColor.green,t.params.wireframeColor.blue,t.params.wireframeColor.alpha);let o=new e.Bimface.Plugins.Anchor.PrismPoint(n);if(o.initSizeByViewer(this.viewer),i){let e=this._externalObjectManager._addObject(o.getId(),o.getPointIns());o.objectId=e,t.effect=o,t.extObjMngIds=[e]}if(!i)return o.parentId=t.parentId,o}else if(t.type===e.Bimface.Common.Type.EffectType.FireEffect){let i=new e.Bimface.Plugins.ParticleSystem.FireEffectConfig;i.position=t.params.position,i.scale=t.params.scale,i.fireType=t.params.fireType,i.color=t.params.color,i.smokeConcentration=t.params.smokeConcentration,i.viewer=this.viewer;let n=new e.Bimface.Plugins.ParticleSystem.FireEffect(i);t.effect=n}else if(t.type===e.Bimface.Common.Type.EffectType.CurveAnimation){let i=this,n=[],o=t.params.path,s=[],r=0,a=t.isVisible;for(let l=0;l<o.length;l++){let h=new e.Web.Graphics.Color(o[l].color.red,o[l].color.green,o[l].color.blue,o[l].color.alpha),d=new e.Bimface.Plugins.Geometry.SplineCurve(o[l].points,h,o[l].width,o[l].style,o[l].type);n.push(d),(o[l].intensty||o[l].parameter)&&d.stretch(o[l].intensty,o[l].parameter),d.setWidthType(o[l].widthType),d.setMap({src:o[l].url,enableColorOverride:o[l].enableColorOverride},(function(){let e=t.id+"_curve_"+r,o=i._externalObjectManager.loadObject({name:e,object:n[r]});a||d.hide(),s.push(o),r++}))}let l=new e.Bimface.Plugins.Animation.CurveAnimationConfig;l.viewer=this.viewer,l.curves=n,l.time=t.params.time,l.loop=t.params.loop,l.speed=t.params.speed,l.type=t.params.type;let h=new e.Bimface.Plugins.Animation.CurveAnimation(l);h.play(),t.effect=h,t.extObjMngIds=s}else if(t.type===e.Bimface.Common.Type.EffectType.WallEffect){let i=new e.Bimface.Plugins.Animation.WallEffectConfig;i.viewer=this.viewer,i.direction={type:t.params.direction.type,reverse:t.params.direction.reverse},i.stretch=!0,i.duration=t.params.duration,i.height=t.params.height,i.path=t.params.path,i.color=new e.Web.Graphics.Color(t.params.color.red,t.params.color.green,t.params.color.blue,t.params.color.alpha);const n=new e.Bimface.Plugins.Animation.WallEffect(i);t.effect=n}else if(t.type===e.Bimface.Common.Type.EffectType.FanScan){let i=new e.Bimface.Plugins.Animation.FanScanEffectConfig;i.viewer=this.viewer,i.backgroundColor=new e.Web.Graphics.Color(t.params.backgroundColor.red,t.params.backgroundColor.green,t.params.backgroundColor.blue,t.params.backgroundColor.alpha),i.color=new e.Web.Graphics.Color(t.params.color.red,t.params.color.green,t.params.color.blue,t.params.color.alpha),i.duration=t.params.duration,i.fanAngle=t.params.fanAngle,i.originPosition=t.params.originPosition,i.radius=t.params.radius,i.enableComponentsScanned=t.params.enableComponentsScanned;let n=new e.Bimface.Plugins.Animation.FanScanEffect(i);t.effect=n}else if(t.type===e.Bimface.Common.Type.EffectType.WaterEffect){let i=new e.Bimface.Plugins.Animation.WaterEffectConfig;i.boundary=t.params.boundary,i.viewer=this.viewer,i.flow=t.params.flow,i.color=new e.Web.Graphics.Color(t.params.color.red,t.params.color.green,t.params.color.blue,t.params.color.alpha),i.scale=t.params.scale,i.shadow=t.params.shadow,i.offset=!!t.params.offset,i.xDirection=t.params.xDirection,i.yDirection=t.params.yDirection;let n=new e.Bimface.Plugins.Animation.WaterEffect(i);t.effect=n}else if(t.type===e.Bimface.Common.Type.EffectType.SkyBoxManager){let n=new e.Bimface.Plugins.SkyBox.SkyBoxManagerConfig;n.viewer=this.viewer,n.customizedImage=t.params.customizedImage,n.style=e.Bimface.Plugins.SkyBox.SkyBoxStyle[t.params.style],n.initializeVisible=t.isVisible;let o=new e.Bimface.Plugins.SkyBox.SkyBoxManager(n);if(t.effect=o,i&&(this.isAddSkyBoxManager=!0),!i)return o.id=t.id,o.parentId=t.parentId,o}else if(t.type===e.Bimface.Common.Type.EffectType.MapStyle){let e=this.viewer.getLayerManager().baseMap;e.setStyle(JSON.parse(JSON.stringify(t.params))),t.effect=e,this.viewer.getLayerManager().getLayerByType("TileLayer").map((e=>e.setStyle(JSON.parse(JSON.stringify(t.params))))),this.isAddMapStyle=!0}else if(t.type===e.Bimface.Common.Type.EffectType.RingScan){let n=new e.Bimface.Plugins.Animation.RingScanEffectConfig;n.originPosition=t.params.originPosition,n.radius=t.params.radius,n.color=new e.Web.Graphics.Color(t.params.color.red,t.params.color.green,t.params.color.blue,t.params.color.alpha),n.enableComponentsScanned=t.params.isEnableComponentsScanned,n.duration=t.params.duration,n.viewer=this.viewer;let o=new e.Bimface.Plugins.Animation.RingScanEffect(n);if(t.effect=o,!i)return o}else if(t.type===e.Bimface.Common.Type.EffectType.Rain){let i=new e.Bimface.Plugins.WeatherEffect.RainConfig;i.viewer=this.viewer,i.darkness=t.params.darkness,i.density=t.params.density;let n=new e.Bimface.Plugins.WeatherEffect.Rain(i);t.isVisible&&n.enableEffect(!0),t.effect=n,this.isAddRain=!0}t.isVisible||this.hideEffect(t)}moveEffectOrFile(e,t){if(this.fileIds.indexOf(t)<0)return;let i=this.spliceEffectOrFile(this.effectAndFileObject,e);i.parentId=t,this.addEffectOrFileToFile(this.effectAndFileObject,t,i)}spliceEffectOrFile(e,t){for(let i=0;i<e.children.length;i++){if(e.children[i].id===t)return e.children.splice(i,1)[0];if(e.children[i].type===o){let n=this.spliceEffectOrFile(e.children[i],t);if(n)return n}}}addEffectOrFileToFile(e,t,i){if(e.id===t)return e.children.push(i),!0;for(let n=0;n<e.children.length;n++)if(e.children[n].type===o){let o=this.addEffectOrFileToFile(e.children[n],t,i);if(o)return o}}getNameMaxNumByType(e){let t=this.getEffectObjByType(this.effectAndFileObject,e),i=[];return t.forEach((e=>{let t=e.name.match(/[0-9]+$/g);t&&i.push(+t[0])})),i.length>0?Math.max(...i):0}hideAllEffect(t=[]){const i=n=>{if(n.type===o)for(let e=0;e<n.children.length;e++)i(n.children[e]);else{if(t.indexOf(n.type)>=0)return;n.type===e.Bimface.Common.Type.EffectType.MapStyle?(n.effect.setStyle({}),this.viewer.getLayerManager().getLayerByType("TileLayer").map((e=>e.setStyle({})))):n.type===e.Bimface.Common.Type.EffectType.Rain?n.effect.enableEffect(!1):this.effectTypeExtObjMng.indexOf(n.type)<0?n.effect.hide():n.type===e.Bimface.Common.Type.EffectType.CurveAnimation?n.effect.curves.map((e=>{e.hide()})):this._externalObjectManager.hide({ids:n.extObjMngIds})}};i(this.effectAndFileObject)}restoreEffectVisible(){const e=t=>{if(t.type===o)for(let i=0;i<t.children.length;i++)e(t.children[i]);else t.isVisible&&this.showEffect(t)};e(this.effectAndFileObject)}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n="Glodon.Bimface.Viewer.ViewerGIS",o=e.Bimface.Data.StatisticsDataManager.getInstance(),s=e.Web.Lang.Utility.DataUtil;class r extends t.Viewer{constructor(t){e.Bimface.Viewer.loadAppGISNum?e.Bimface.Viewer.loadAppGISNum++:e.Bimface.Viewer.loadAppGISNum=1,e.Bimface.Viewer.loadAppGISNum+(e.Bimface.Viewer.loadApp3DNum||0)>=2&&o.send("bf_userBehavior","loadMultApps"),o.send(n,"bf_c_viewerGIS_new"),window.bimfaceSdkVersion&&(o.send(n,"sdkVersion"),delete window.bimfaceSdkVersion),t.enableSSAO&&o.send("Glodon.Bimface.Viewer","ViewerGISConfig.enableSSAO"),super(),this.viewerType="ViewerGIS",this._opt=t,this._data={},this._beforeInitialize(t),this.console=new e.Web.Common.Console,this._models={},this._defaultModelType="bimtiles",this._defaultUnit="m",this._plugins={},this._layerLoadedHandlerList=[],this.enableStorage=t.enableStorage,this.bIsEnableSelectionChanged=!0,this.globalUnitUtil=new G(this),this.disableUserData=!y.Utils.isDefined(t.disableUserData)||t.disableUserData,this.initModelSync=!!y.Utils.isDefined(t.initModelSync)&&t.initModelSync;const s={setupEarth:t.enableEarth,staticResourcesHost:t.staticResourcesHost,initialGeoCoordinates:t.initialGeoCoordinates,enableStorage:t.enableStorage,maxMemoryUsage:t.memoryThreshold,disableMapOcclusion:t.disableMapOcclusion,gisMode:!0},r=new y.Viewer(s);this.viewerAdapter=new j(this,r),r.globalUnitUtil=this.globalUnitUtil,r.viewerAdapter=this.viewerAdapter;const a=i.create("div","bf-view");t.domElement.appendChild(a),r.init(a,!0),this.getViewer=()=>r,this.setOrbitButton(t.orbitButton),this.setBackgroundColors(t.backgroundColor),t.enableSkyBox&&this.setSkyBoxType(t.skyBoxType);const l=new De(this),h=e.Web.Lang.Utility.ClientHelper.getIsDesktop();r.setDeviceMobile&&r.setDeviceMobile(!h),t.enableIBLBackground&&t.loadIBLScene.IBLSceneOption&&this.loadIBLScene(t.loadIBLScene.IBLSceneOption,t.loadIBLScene.withBackground);const d=new e.Bimface.ElementManager.EffectManager(this);this.getEffectManager=()=>d,this.getLayerManager=()=>l,this.getDomElement=()=>a,this.resizeWindow=()=>{this.resize()},window.addEventListener("resize",this.resizeWindow),this.mouseRotating=new U(this),this.hookContextMenu(a),this.hookCloudViewerEvents();const c=()=>{o.modelType="scene",o.modelId=this._config.id,this._config.baseLatLon=this._opt.basePoint||this._config.baseLatLon||{lat:30.94136274453108,lon:120.77426794742208},this.enuMatrix=this._getEnuMatrix(),this._config.homeView=this._opt.homeView||this._config.homeView||{position:{lon:120.77426794742208,lat:30.93136274453108,alt:1e3},orientation:{yaw:0,pitch:-Math.PI/2,roll:0}},this._config.renderingSettings=this._config.renderingSettings||{};let t=this._config.resources=this._config.resources||[];if(this.enableStorage){let e=[];const i=t=>{t.forEach((t=>{t.databagId&&e.push(t.databagId),t.children&&i(t.children)}))};i(t),this.storageManager=new y.Storage.SceneStorageManager({sceneId:this._data.modelId,databagIdList:e})}l.buildLayers(t),this.initLayerEffect(),this.addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,(e=>this.initLayerEffect(e)));const i=new Ve(this);this.getCamera=()=>i,this._camera=i._camera,this._opt.enableEarth&&!this.getViewer().isEarthComplete()?this.getViewer().registerEventListener(y.EVENTS.ON_EARTH_ANIMATION_COMPLETE,(()=>{this._camera.init()})):this._camera.init()};this.initLayerEffect=t=>{let i={children:this._config.resources};const n=i=>{i.children&&i.children.forEach((i=>{if((t?i.id===t&&"TilesetLayer"===i.typeName:["TileLayer","TerrainLayer"].indexOf(i.typeName)>=0)&&i.layerConfig&&i.layerConfig.edits&&i.layerConfig.edits.length>0){let t=l.getLayer(i.id);i.layerConfig.edits.forEach((i=>{if("flat"===i.type){let n=new e.Bimface.Plugins.Flats.FlatConfig;n.elevation=i.params.elevation,n.boundary=i.params.boundary,n.layerIds=[i.params.layerId];let o=new e.Bimface.Plugins.Flats.Flat(n);i.effectId=o.id,t.getFlatManager().addItem(o),!i.isVisible&&t.getFlatManager().hideItems([o.id])}else if("clipping"===i.type){let n=new e.Bimface.Plugins.Clipping.ClippingConfig;n.boundary=i.params.boundary,n.layerIds=[i.params.layerId];let o=new e.Bimface.Plugins.Clipping.Clipping(n);i.effectId=o.id,t.getClippingManager().addItem(o),!i.isVisible&&t.getClippingManager().hideItems([o.id])}}))}"GroupLayer"===i.typeName&&n(i)}))};n(i)},this.addModel=this.loadViewCore=(e,t,i)=>{this._data=e,this._config=e.sceneJsonInfo,this._config.sceneSetting&&(this._config.baseLatLon=this._config.sceneSetting.baseLatLon,this._config.homeView=this._config.sceneSetting.homeView),c(),this._config.effects&&this.getEffectManager().init(this._config.effects)},this.addScene=i=>{if(this.fireEvent(e.Bimface.Viewer.ViewerGISEvent.SceneLoading),t.configUrl){const e=new THREE.FileLoader;e.setResponseType("json"),e.load(t.configUrl,(e=>{this._config=e,c()}),void 0,(e=>{console.error(`Load ${url} failed, ${e}`)}))}else t.config?(this._config=t.config,c()):i?this.addView(i):(this._config={},c());this.getLightManager=function(){return this.lightManager},this.addEventListener(e.Bimface.Viewer.ViewerGISEvent.SceneAdded,(()=>{var t=new e.Bimface.Light.LightManagerConfig;t.viewer=this,this.lightManager=new e.Bimface.Light.LightManager(t);let i=this.lightManager.getCSMLight();if(i.setLightPreset(!0),i.enableShadow(!0),i.setDirectionByCondition({lat:31,lon:120},new Date("2021-03-23T10:00:00+08:00")),!1===this._opt.enableCSMShadow&&(i.setLightPreset(!1),i.enableShadow(!1)),this._opt.enableSSAO&&this.enableSSAOEffect(!0),this._opt.enableCompassControl){const t=new e.Bimface.Plugins.NorthArrowConfig;t.domElement=this.getDomElement(),t.viewer=this,this._northArrow=new e.Bimface.Plugins.NorthArrow(t)}if(this._opt.enableScaleBar){const t=new e.Bimface.Plugins.ScaleBarConfig;t.domElement=this.getDomElement(),t.viewer=this,this._opt.enableInfoBar&&(t.bottom=45),this._scaleWidget=new e.Bimface.Plugins.ScaleBar(t),this.getScaleBar=()=>this._scaleWidget}if(this._opt.enableInfoBar){const t=new e.Bimface.Plugins.InfoBarConfig;t.domElement=this.getDomElement(),t.viewer=this,this._infobarWidget=new e.Bimface.Plugins.InfoBar(t),this.getInfoBar=()=>this._infobarWidget}if(this._opt.enableCreditBar){const t=new e.Bimface.Plugins.CreditConfig;t.domElement=this.getDomElement(),t.viewer=this,this._creditWidget=new e.Bimface.Plugins.Credit(t);const i=Object.assign({},e.Bimface.Common.Credit,{OSM:"openstreetmap",Amap:"appmaptile",BingMap:"virtualearth"});let n=this.getLayerManager().getLayer(this.firstTileLayerId),o=n.getSource(),s=o.url.toLowerCase();if(n._config.layerConfig&&n._config.layerConfig.customResource)o.credit=e.Bimface.Common.Credit.None,n.setSource(o);else for(let e in i)s.indexOf(i[e].toLowerCase())>-1&&(o.credit=e,n.setSource(o))}this.getLayerManager().getLayerByType("TileLayer").map((e=>!e.isVisible&&e.hide()))}))}}setOrbitButton(e){const t=this.getViewer();this._opt.orbitButton=e,t.setOrbitButton({Left:"left",Right:"right"}[e])}hookContextMenu(t){let i,n,o,s=!0;this.onTouchstart=r=>{let a=r.touches[0];s=!1,i=[a.pageX,a.pageY],o&&clearTimeout(o),o=setTimeout((()=>{if(s)return;n=n||i;let o=t.getBoundingClientRect(),r={clientPosition:{x:n[0]-o.left,y:n[1]-o.top},containerBox:{width:o.width,height:o.height}};Math.abs(i[0]-n[0])<5&&Math.abs(i[1]-n[1])<5&&this._opt.enableToggleContextMenuDisplay&&this.getEventManager().fireEvent(e.Bimface.Viewer.Viewer3DEvent.ContextMenu,r),s=!0}),1e3)},this.onTouchmove=e=>{let t=e.touches[0];n=[t.pageX,t.pageY]},this.onTouchend=()=>{n=null,s=!0},t.addEventListener("touchstart",this.onTouchstart),t.addEventListener("touchend",this.onTouchend),t.addEventListener("touchmove",this.onTouchmove)}hookCloudViewerEvents(){const t=this.getViewer(),n=this.getEventManager(),o=e.Bimface.Viewer.ViewerGISEvent;let s=i.create("div","bf-loading"),r=i.create("div","bf-loading-gif"),a=i.create("div","bf-loading-progress"),l=!1,h=0,d=i.create("div","bf-rect-selcetion"),c=null;this._opt.useCustomResources&&(r.style.backgroundImage=`url(${g.staticHost}/resources/custom/loading.gif)`);const u=2,p=e=>{if(0==this.bIsEnableSelectionChanged||e.intersectInfo&&e.intersectInfo.objectType==y.PICKABLETYPE.Marker3d)return;let t=null,i=null,s=null,r=e.doubleClick?2:1;if(s=e.event.button==u?"RightClick":e.doubleClick?"DoubleClick":"Click",e.intersectInfo){const n=t=>({objectId:t.selectedObjectId,modelId:t.modelId,fileId:null,elementId:t.selectedObjectId,boundingBox:t.worldBoundingBox,click:r,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:t.worldPosition,clientPosition:e.canvasPos,eventType:s,objectType:m(t.objectType)});if(t=n(e.intersectInfo),e.intersectInfo.objectType==y.PICKABLETYPE.Room&&(t.boundaryPoints=e.intersectInfo.boundaryPoints),e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var a=e.intersectInfo.selectedObjectId.split(".");a.length>1&&(t.elementId=a[1],t.fileId=a[0])}if("Map"===t.objectType){const e=this.getLayerManager().baseMap;t.layerType=e.typeName;let i=0,n=e.getId();this.getLayerManager().query(".TileLayer").forEach((e=>{if(e.isVisible){const t=e.tileManager.getImageryLayerIndex(e._imageryId);t>i&&(i=t,n=e.getId())}})),t.layerId=n}else if("Component"===t.objectType&&t.modelId){const e=this._models[t.modelId]._layer;t.layerId=e.getId(),t.modelId=e.modelId,t.layerType=e.typeName}else if("ExternalComponent"===t.objectType){const e=this.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i<e.length;i++){const n=e[i];if(n._hasObjectId(t.elementId)){t.layerId=n.getId(),t.layerType=n.typeName;break}}}if(e.intersectInfoWithoutMap){if(i=n(e.intersectInfoWithoutMap),i&&"Component"===i.objectType&&i.modelId){const e=this._models[i.modelId]._layer;i.layerId=e.getId(),i.modelId=e.modelId,i.layerType=e.typeName}}else i="Map"!==t.objectType?t:null}else t={click:r,screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:s,objectType:""};if(e.event.altKey&&console.log(t),e.doubleClick)this.zoomToSelectedComponents(),n.fireEvent(o.MouseDoubleClicked,t),n.fireEvent(o.ComponentsSelectionChanged,t);else{if(e.event.button===THREE.MOUSE.LEFT){n.fireEvent(o.ComponentsSelectionChanged,t);let e=this.getViewer().pickToPoint(t.clientPosition,5);if(null!=this.snap&&null!=e){let i=this.sceneToWorld(e.pickPoint),n=this.worldToClient(i),o={type:null,worldPosition:i,clientPosition:{x:n.x,y:n.y}};t.snapPoint=o}}t.normal=e.intersectInfo?e.intersectInfo.normal:null,n.fireEvent(o.MouseClicked,t),i&&n.fireEvent(o.MouseClickedWithoutMap,i)}},m=e=>{let t;const i="Component",n="ExternalComponent",o="Room",s="Map";switch(e){case y.PICKABLETYPE.ExternalComponent:t=n;break;case y.PICKABLETYPE.Room:t=o;break;case y.PICKABLETYPE.Map:t=s;break;default:t=i}return t},f=t=>{if(this.bIsEnableSelectionChanged){var i={};if(t.event.button==u){var n=this.getDomElement().getBoundingClientRect(),o={x:t.event.clientX-n.left,y:t.event.clientY-n.top},s={width:n.width,height:n.height};i.clientPosition=o,i.containerBox=s,i.objectType=t.intersectInfo?m(t.intersectInfo.objectType):"",this.getEventManager().fireEvent(e.Bimface.Viewer.ViewerGISEvent.ContextMenu,i)}}},w=(e,t)=>{e.visible?("pickByRect"===t?e.dir?d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px solid rgba(0,130,94,1)"}):d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px dashed rgba(0,130,94,1)"}):d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(136,136,136,0.2)",border:"solid #888888 1px"}),this._opt.domElement.firstElementChild.appendChild(d),l=!0):(l&&(this._opt.domElement.firstElementChild.removeChild(d),l=!1,n.fireEvent(o.RectSelection,{end:!0})),n.fireEvent(o.RectSelection,e))};y.GlobalData.EnableDemolishByDClick=!0,a.innerText="0%",s.appendChild(r),s.appendChild(a),this._opt.loading&&this._opt.domElement.appendChild(s),this._opt.enableEarth&&!t.isEarthComplete()&&this.getViewer().registerEventListener(y.EVENTS.ON_EARTH_ANIMATION_COMPLETE,(()=>{n.fireEvent(o.EarthAnimationCompleted)})),t.registerEventListener(y.EVENTS.ON_MAP_LOAD_ALL,(()=>{s.parentElement&&0===h&&this._opt.domElement.removeChild(s)})),t.registerEventListener(y.EVENTS.ON_LOAD_START_NO_PROGRESS,(()=>{this._opt.loading&&(h++,s.parentElement||this._opt.domElement.appendChild(s),a.style.display="none")})),t.registerEventListener(y.EVENTS.ON_LOAD_START,(()=>{this._opt.loading&&(h++,s.parentElement||this._opt.domElement.appendChild(s))})),t.registerEventListener(y.EVENTS.ON_LOAD_PROGRESS,(e=>{let t=e.progress,i=Math.round(t.loaded/t.total*100);t.progress=i,a.innerText=i+"%",n.fireEvent(o.SceneLoading,t)})),t.registerEventListener(y.EVENTS.ON_LOAD_EMPTY_SCENE,(()=>{this._opt.loading&&0==h&&s.parentElement&&this._opt.domElement.removeChild(s),n.fireEvent(o.Error,{code:"EmptyData",message:"this view is empty."})})),t.registerEventListener(y.EVENTS.ON_LOAD_COMPLETE,(i=>{h--,this._opt.loading&&0==h&&s.parentElement&&i.modelId&&(a.innerText="0%",this._opt.domElement.removeChild(s)),t.enableTextureMapping(!0),this.removeMouseMotionEventListeners=e.Web.Lang.Utility.MouseMotion.setCursor(this)})),t.addCallbacks("render",(()=>{n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.Rendered)})),t.registerEventListener(y.EVENTS.ON_EDITOR_UPDATEUI,(e=>{w(e.data,e.editor)})),t.registerEventListener(y.EVENTS.ON_CLICK_PICK,(e=>{p(e),f(e)})),t.registerEventListener(y.EVENTS.ON_HOVER_PICK,(e=>{(e=>{let t=null,i="Hover";if(e.intersectInfo){if(t={objectId:e.intersectInfo.selectedObjectId,modelId:e.intersectInfo.modelId,fileId:null,elementId:e.intersectInfo.selectedObjectId,boundingBox:e.intersectInfo.worldBoundingBox,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:e.intersectInfo.worldPosition,clientPosition:e.canvasPos,eventType:i,objectType:m(e.intersectInfo.objectType)},e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var s=e.intersectInfo.selectedObjectId.split(".");s.length>1&&(t.elementId=s[1],t.fileId=s[0])}}else c=null,t={screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:i};n.fireEvent(o.ComponentsHoverChanged,t),t.objectId&&c!=t.objectId&&(n.fireEvent(o.MouseHover,t),c=t.objectId)})(e)})),t.registerEventListener(y.EVENTS.ON_MOUSE_MOVE_PICK,(e=>{(e=>{if(!e.intersectInfo)return;const t=e.intersectInfo;var i={};if(void 0!==t.selectedObjectId&&(i.objectId=t.selectedObjectId),void 0!==t.modelId&&(i.modelId=t.modelId),void 0!==t.selectedObjectId&&(i.elementId=t.selectedObjectId),void 0!==t.worldBoundingBox&&(i.boundingBox=t.worldBoundingBox),void 0!==t.worldPosition&&(i.worldPosition=t.worldPosition),void 0!==t.objectType&&(i.objectType=m(e.intersectInfo.objectType)),i.eventType="MouseMove",i.screenPosition={x:e.event.clientX,y:e.event.clientY},i.clientPosition=e.canvasPos,t.selectedObjectId&&"string"==typeof t.selectedObjectId){var s=t.selectedObjectId.split(".");s.length>1&&(i.elementId=s[1],i.fileId=s[0])}n.fireEvent(o.MouseMove,i)})(e)})),t.registerEventListener(y.EVENTS.ON_SELECTION_CHANGED,(t=>{n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.SelectionChanged,t.selectionList);const i=[],o={};Object.entries(t.selectionList).forEach((([e,t])=>{if(t&&t.length>0&&"TileGroup"!==e)if("ExternalComponent"===e){const e=this.getLayerManager().query(".ExternalObjectLayer");t.forEach((t=>{e.some((e=>!(!e._hasObjectId||!e._hasObjectId(t))&&(o[e.id]||(o[e.id]=[]),o[e.id].push(t),!0)))}))}else{const n=this.getModel(e);if(n&&n._layer){const n=this.getModel(e)._layer.id;i.push({layerId:n,objectIds:t})}}})),Object.entries(o).forEach((([e,t])=>i.push({layerId:e,objectIds:t}))),n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.SelectedObjectsChanged,i)})),t.registerEventListener(y.EVENTS.ON_MOUSE_DRAGGED,(t=>{n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.MouseDragged,t)})),t.registerEventListener(y.EVENTS.ON_EDITOR_ZOOM_END,(()=>{n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.ZoomEnd)})),t.registerEventListener(y.EVENTS.ON_FLOOR_EXPLOSION,(function(t){void 0===this.floorData&&(this.floorData={}),this.floorData[t.modelId]=t.floorInfos,n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.FloorExplosion,t)})),t.registerEventListener(y.EVENTS.ON_CAMERA_CHANGED,(t=>{n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.CameraPositionChanged,this.getCameraStatus())})),t.registerEventListener(y.EVENTS.ON_TILES_LOAD_INITIAL,(function(t){n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.Initialized,t)}));let v=0,b=0;t.registerEventListener(y.EVENTS.ON_TILES_LOAD_PROGRESS,(function(t){const i=t.data.numAttemptedRequests+t.data.numPendingRequests+t.data.numTilesProcessing;if(b>0&&0===i)return v=0,b=0,void n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.CurrentViewLoading,100);0!==i&&(v<i&&(v=i),b=100*(v-i)/v,n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.CurrentViewLoading,Number(b.toFixed(1))))})),t.registerEventListener(y.EVENTS.ON_TILES_LOAD_COMPLETE,(function(t){n.fireEvent(e.Bimface.Viewer.ViewerGISEvent.ViewLoaded,t)})),t.registerEventListener(y.EVENTS.ON_HOVER_SNAP,(e=>{this.snap&&this.snap.snapByPoint(e)})),this._opt.wireframeColor&&this.setWireframeColor(this._opt.wireframeColor)}setSnapMode(e){this.snapMode=e}enableSnap(t){if(t?(this.getViewer().editorManager.enableTool(this.getViewer(),y.EditToolMode.PICK_BY_RECT),this.getViewer().enableSnap(t)):this.getViewer().editorManager.disableTool(y.EditToolMode.PICK_BY_RECT),!1===t&&null!=this.snap)this.snap.destroy(),this.snap=null;else if(!0===t&&null==this.snap){var i=new e.Bimface.Plugins.Snap.SnapConfig;i.viewer=this,i.snapMode=this.snapMode,this.snap=new e.Bimface.Plugins.Snap.Snap(i)}}getModel(e){if(e)return this._models[e]}getModels(){return Object.values(this._models)}destroy(){o.send(n,"destroy"),this._northArrow&&this._northArrow.destroy(),this._scaleWidget&&this._scaleWidget.destroy(),this._creditWidget&&this._creditWidget.destroy(),this._infobarWidget&&this._infobarWidget.destroy(),this.mouseRotating&&(this.mouseRotating.destroy(),this.mouseRotating=null),this.lightManager&&(this.lightManager.destroy(),this.lightManager=null),this._isDestroyed=!0,F.destroy(),this.getViewer().destroy(),window.removeEventListener("resize",this.resizeWindow);var i=this.getDomElement();i&&this.removeMouseMotionEventListeners&&(this.removeMouseMotionEventListeners(),this.removeMouseMotionEventListeners=null),i.parentNode&&i.parentNode.removeChild(i),y.GlobalData.EnableRainPass=!1,e.Bimface.Viewer.loadAppGISNum&&e.Bimface.Viewer.loadAppGISNum>0&&e.Bimface.Viewer.loadAppGISNum--,t.Viewer.prototype.destroy.call(this)}resize(e,t){var i=this._opt.domElement,n=e||i.clientWidth,o=t||i.clientHeight;this.getViewer().resize(n,o)}fireEvent(e,t){this.getEventManager().fireEvent(e,t)}_beforeInitialize(e){y.GlobalData.LimitFrameTime=1e3/e.minimumFPS,y.GlobalData.EnableDemolishByDClick=!1,y.GlobalData.DisableRotation=e.rotation,y.GlobalData.UseMpkWorker=!1,y.GlobalData.ZipResourcePostfix=e.suffix,y.GlobalData.LightIntensityFactor=1.2,y.GlobalData.Hover=e.enableHover,y.GlobalData.MouseMovePick=e.enableMouseMovePick,y.GlobalData.MaxMemeorySizeToFullRender=e.MaxMemeorySizeToFullRender,y.GlobalData.EnableLoadOnDemand=!0===e.loadOnDemand,y.GlobalData.Instance=!e.enableReplaceMaterial,y.GlobalData.EnableSplitComponent=e.enableSplitComponent,y.GlobalData.EnableExplosion=e.enableExplosion,y.GlobalData.EnableLogarithmicDepthBuffer=e.enableLogarithmicDepthBuffer,y.GlobalData.ConstraintZoom=e.enableConstraintZoom,y.GlobalData.BorderLineDelayLoaded=!1===e.enableBorderLine,y.GlobalData.PickingEffect=!1!==e.pickingEffect}render(){const e=this.getViewer();e.modelManager.setRenderStateChanged(!0),e.render()}getBasePoint(){if(this._config&&this._config.baseLatLon)return this._config.baseLatLon}getSelectedElements(){function e(e,t){return{layerId:e,objectIds:t}}let t=this.getViewer().getModelManager().getModelIds(!0),i=new Array;for(let n=0;n<t.length;n++){let o=this.getViewer().getSelection(t[n]);if("ExternalComponent"!==this.getViewer().getModelManager().getModel(t[n]).getId()){if(this._models[t[n]]&&o.length>0){let s=e(this._models[t[n]]._layer.getId(),o);i.push(s)}}else{const t=this.getLayerManager().getLayerByType("ExternalObjectLayer");for(let n=0;n<t.length;n++){const s=t[n];let r=new Array;for(let e=0;e<o.length;e++)s._hasObjectId(o[e])&&r.push(o[e]);if(r.length>0){let t=e(s.getId(),r);i.push(t)}}}}return i}getCameraStatus(){return this._camera.getCameraStatus()}setCameraStatus(e,t){this._camera.setCameraStatus(e,t)}setCameraMinimumElevation(e){this._camera.setCameraMinimumElevation(e),null!=e?this._northArrow.setLimitPitch(0,null):this._northArrow.setLimitPitch(null,null)}setBackgroundColors(e){const t=this._opt.domElement,i=e.colors,n=void 0===e.direction?"180deg":e.direction*(180/Math.PI)+"deg";void 0===e.direction&&(e.direction=Math.PI);const o=[];if(i)if(1==i.length){const e=i[0].color;t.style.background=e.getRGBA(),this._setBackground(t,e)}else{i[0].stop=i[0].stop||"0%",i[1].stop=i[1].stop||"100%";for(let e=0;e<i.length;e++){const t=i[e].color.getRGBA()+" "+i[e].stop;o.push(t)}const e=`${n}, ${o.join(",")}`;t.style.background=`linear-gradient(${e})`,this._setBackground(t)}this._opt.backgroundColor=e}_setBackground(e,t){this.getViewer().setBackground(e,t)}getBackgroundColors(){return this._opt.backgroundColor}getHomeView(){return this._camera.getCustomHomeview()||this._camera.getDefaultHomeview()}setHomeView(e){this._camera.setHomeView(e)}worldToScene(e){return this.getViewer().worldToDrawing(e)}sceneToWorld(e){return this.getViewer().drawingToWorld(e)}worldToClient(e){return this.getViewer().worldToCanvas(e)}clientToWorld(e){return this.getViewer().clientToWorld(e)}zoomIn(){this.getViewer().zoomIn()}zoomOut(){this.getViewer().zoomOut()}createSnapshot(e){o.send(n,"createSnapshot"),this.getViewer().getRenderBufferScreenShot(void 0,(t=>{"[object Function]"==Object.prototype.toString.call(e)&&e(t),this.render()}))}startAutoRotate(e,t){this._camera.startAutoRotate(e,t)}stopAutoRotate(){this._camera.stopAutoRotate()}zoomToBoundingBox(e,t){this._camera.zoomToBoundingBox(e,t)}enableZoomRect(e){const t=this.getViewer();this._opt.enableZoomRect=e,e?t.editorManager.enableTool(t,y.EditToolMode.ZOOM_BY_RECT):t.editorManager.disableTool(y.EditToolMode.ZOOM_BY_RECT)}enablePickRect(e,t=!1){const i=this.getViewer();if(e){let e=!y.Utils.isDefined(t)||t;i.editorManager.enableTool(i,y.EditToolMode.PICK_BY_RECT).triggerByCtrlKey(e)}else i.editorManager.disableTool(y.EditToolMode.PICK_BY_RECT)}enableMouseMovePick(e){o.send(n,"enableMouseMovePick"),this._opt.enableMouseMovePick=e,this.getViewer().enableMouseMovePick(e)}zoomToSelectedComponents(){}worldToLatLon(e){if(s.assertType(e,"obj")&&s.assertParamsType(e.x,e.y,e.z,"num")&&this.getLayerManager().baseMap&&this.getLayerManager().baseMap.tileManager){const t=this.getLayerManager().baseMap.tileManager.worldPositionToLngLat(e);return{lat:t.y,lon:t.x}}}latLonToWorld(e){if(!s.assertType(e,"obj")||!s.assertType(e.latLon,"obj")||!s.assertParamsType(e.latLon.lat,e.latLon.lon,"num"))return;const t=e.latLon,i=this.getLayerManager().baseMap;if(!i||!i.tileManager)return;const n=i.tileManager.lngLatToWorldPosition([t.lon,t.lat]),o=void 0===e.layerId||e.layerId===this.getLayerManager().baseMap.id||e.layerId===this.getLayerManager().terrainLayer.id;if(void 0===n.z&&(n.z=0,!0===o&&console.log("The latitude and longitude input is out of the loading range.")),!0===o)return n;const r=this.getLayerManager().getLayer(e.layerId);if(!r)return void console.warn("The layerId is invalid");const a=r.model&&r.model.rayCastVertical(n);return void 0===a&&console.warn("[BIMFACE WARNING]:The latitude and longitude are out of the data range."),a}enableGlowEffect(e){o.send(n,"enableGlowEffect"),y.GlobalData.EnableGlow=e,this.render()}showNorthArrow(){this._northArrow&&this._northArrow.show()}hideNorthArrow(){this._northArrow&&this._northArrow.hide()}isInViewFrustum(e){return this.getViewer().insideCamera(e)}setDampingFactor(e){this.getViewer().setDampingFactor(e)}enableDamping(e){this.getViewer().enableDamping(e)}isolateLayerByIds(e,t){s.assertType(e,"arr")&&this.getLayerManager()&&(this._executeDirectlyOrLayerLoaded((i=>{e.indexOf(i.id)<0&&e.indexOf(i.id.toString())<0&&i.model.isolateComponentsById([void 0],t),this.render()}),"isolateLayerByIds","loaded"),this.render())}clearIsolation(){let e=this.getLayerManager().query(".BIMLayer .FeatureLayer");for(let t=0;t<e.length;t++){const i=e[t];if(i){let e=i.model;null!=e&&e.clearIsolation()}}this.render()}cloneModel(e,t){return this.getViewer().cloneModel(e,t)}enableFullScreen(e){super.enableFullScreen(e)}setLightingMode(t){var i=this.getViewer().IBLManager;t==e.Bimface.Viewer.LightingMode.IBL?this._opt.enableIBLBackground=!0:(this._opt.enableIBLBackground=!1,i.enableIBL(!1))}getLightingMode(){return this._opt.enableIBLBackground&&e.Bimface.Viewer.LightingMode.IBL||e.Bimface.Viewer.LightingMode.Phong}loadIBLScene(e,t){var i=this,n=this.getViewer().IBLManager,o=this._data,s=o.dataEnvType==_.Local?o.sdkPath:g.staticHost;this._opt.enableIBLBackground&&(n.enableIBL(!0),this._getIBLConfig((function(o){var r=o;r[e]&&(i._opt.loadIBLScene=e,r[e].url=r[e].url.replace(g.staticHost,""),n.loadIBLMaps(`${s}/${r[e].url}`,r[e].isHDR,t,r[e].uniforms),t&&n.setSkyBoxType(e))})))}_getIBLConfig(t){var i=this,n=i._data;if(i._IBLConfig)t&&t(i._IBLConfig);else{var o=new e.Bimface.Data.IBLManagerConfig;n.dataEnvType==_.Local&&(o.resourceHost=n.sdkPath),new e.Bimface.Data.IBLManager(o).getIBLConfig((function(e){i._IBLConfig=e,t&&t(e)}))}}enableIBLBackground(e){var t=this.getViewer().IBLManager;if(e&&this._opt.enableIBLBackground){var i=this._opt.loadIBLScene;if(i==t.getSkyBoxType())t.addSkyBox(!0);else{var n="resources/IBL/Pics/"+this._opt.loadIBLScene,o=this._data,s=o.dataEnvType==_.Local?o.sdkPath:g.staticHost;t.loadSkyBox(`${s}/${n}`,!0),t.setSkyBoxType(i)}this._opt.IBLSkyBox=!0}else this._opt.IBLSkyBox=!1,t.removeSkyBox()}enableOrbit(e){y.EditorConfig.NoRotate=null!=e&&!e}_addLayerLoadedHandler(e,t,i="loaded"){s.assertType(e,"func")&&s.assertType(t,"str")&&(this._removeLayerLoadedHandler(t),this._layerLoadedHandlerList.push({handler:e,name:t,status:i}))}_removeLayerLoadedHandler(e){for(let t=0;t<this._layerLoadedHandlerList.length;t++){if(this._layerLoadedHandlerList[t].name===e)return void this._layerLoadedHandlerList.splice(t,1)}}_getLayerLoadedHandlerList(){return this._layerLoadedHandlerList}_executeDirectlyOrLayerLoaded(e,t,i){this._addLayerLoadedHandler(e,t,i),this.getLayerManager()&&this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((t=>{("rendered"===i&&["rendered","loaded"].includes(t.loadStatus)||"loaded"===i&&t.loadStatus===i)&&e(t)}))}setExposureCompensation(e){s.assertType(e,"num")&&(e>1&&(e=1),e<-1&&(e=-1),this._executeDirectlyOrLayerLoaded((t=>{t.setExposureCompensation(e)}),"setExposureCompensation","rendered"))}getExposureCompensation(){let e=[];if(this.getLayerManager()){const t=this.getLayerManager().getRootLayer().children;t.length>0&&t.forEach((t=>{t.getExposureCompensation&&e.push({id:t.id,exposureCompensation:t.getExposureCompensation()})}),"getExposureCompensation","rendered")}return e}enableWireframe(e){o.send(n,"enableWireframe"),this._opt.enableWireframe=e;this.getLayerManager().query(".BIMLayer").forEach((t=>{t.presetWireFrameVisible&&t._setWireframeVisibleByViewer(e)}))}isWireframeEnabled(){return this._opt.enableWireframe}setWireframeColor(e){return this.getViewer().setWireframeColor(e)}getWireframeColor(){const t=this.getViewer().getWireframeColor();return new e.Web.Graphics.Color(255*t.r,255*t.g,255*t.b,t.opacity)}restoreWireframeColor(){this.getViewer().restoreWireframeColor()}_autoRaiseCamera(){if(this._opt.enableAutoRaiseCamera){let e,t=this.getCamera(),i=t.getStatus();const n=i.position.z;if("world"===i.coordinateSystem){const t=new THREE.Vector3(i.position.x,i.position.y,i.position.z);e=this.worldToLatLon(t)}else"CGCS-2000"===i.coordinateSystem&&(e={lat:i.position.x,lon:i.position.y});const o=this.getLayerManager().baseMap;if(!o||!o.tileManager)return;o.tileManager.lngLatToWorldPosition([e.lon,e.lat],(function(e){const o=e.z;n<o&&(i.position.z=o+(i.position.z>0?i.position.z:10),t.setStatus(i))}))}}getExternalComponentManager(){return this.externalComponentManager&&!this.externalComponentManager.isDestroyed()||(this.externalComponentManager=new y.ExternalComponentManager(this.getViewer()),this.externalComponentManager._objects={}),this.externalComponentManager}getExternalObjectManager(){return this.externalObjectManager||(this.externalObjectManager=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this)),this.externalObjectManager}getExternalObjectConverter(){return this.externalObjectConverter||(this.externalObjectConverter=new y.ExternalObjectConverter(this.getViewer())),this.externalObjectConverter}getComponentsByRaycaster(e,t,i){i||(i=[]);let n={};this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((e=>{const t=e.getModelId();n[t]=e.id}));let o=!1;const s=this.getLayerManager().terrainLayer.id;0===i.length&&(o=!0);let r=[];for(const e of i){if(!e.layerId)continue;if(e.layerId===s){1===Object.keys(e).length&&(o=!0);continue}let t={};const i=this.getLayerManager().getLayer(e.layerId);if(!i||!0===i._isBaseMap)continue;const n=i.getModelId().toString();t.modelId=n,e.objectIds?t.userId=e.objectIds:e.objectData&&(t.objectData=e.objectData),r.push(t)}let a=!1;0===r.length&&0!==i.length&&(a=!0);const l=this.getViewer().getComponentsByRaycasterConditions(e,t,r);let h=[];return l.map((e=>{if(e.modelId&&(e.layerId=n[e.modelId],delete e.modelId),!0===e.isMap){if(!1===o)return;e.layerId=s,delete e.id,delete e.isMap,delete e.modelId}e.id&&(e.objectId=e.id,delete e.id),!0===a&&e.layerId!==s||h.push(e)})),h}enableSSAOEffect(e){o.send(n,"enableSSAOEffect"),y.GlobalData.GTAO=e,this.render()}_getEnuMatrix(){let{baseLatLon:e}=this._config,t=y.Tile.TileMath.fromDegrees(e.lon,e.lat,0),i=y.GIS.Transforms.eastNorthUpToFixedFrame(t);return i.invert(),i}updateSceneBoundingBox(){}}t.ViewerGIS=r}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").MiniMapConfig=function(){return{name:"defaultMap",domElement:null,width:240,height:240,viewer:null,axis:!1,host:g.resourceHost,onCameraChanged:null,inMoveOnAxisGrid:null}},Re=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),Oe=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),(ke=function(e){var t=this,i=e;if(t._opt=i,!i.domElement)return console.log("domElement must not be empty."),!1;if(!i.viewer)return console.log("viewer is not defined."),!1;var n=i.viewer.getViewer();t._helper=new y.Extensions.MiniMapHelper(i.viewer.getViewer()),n.addCallbacks("render",(function(){t._helper.renderMiniMap()})),t.init()}).prototype={init:function(){var e=this,t=e._opt,i={},n=[];e._helper,Oe.ajax({url:`${t.host}/${t.viewer._data.databagId}/metadata/grids.json`,async:!1,success:function(e){for(var t=JSON.parse(e),n=[],o=0,s=t.grids.length;o<s;o++){var r=t.grids[o];r.start.X=r.start.x,r.start.Y=r.start.y,r.start.Z=r.start.z,r.end.X=r.end.x,r.end.Y=r.end.y,r.end.Z=r.end.z,n.push(r)}i.Grids=n}}),Oe.ajax({async:!1,url:`${t.host}/${t.viewer._data.databagId}/metadata/levels.json`,success:function(e){i.Levels=JSON.parse(e).levels}}),Oe.ajax({async:!1,url:`${t.host}/${t.viewer._data.databagId}/resource/model/maps/output.json`,dataType:"text",success:function(e){var i=JSON.parse(e);for(var o in i){var s=i[o];null==s.id&&(s.id=o),s.path=`${t.host}/${t.viewer._data.databagId}/resource/model/maps/${s.id}.png`,s.name=o,n.push(s)}}}),e._floors=n,e.createMap(i,n)},createMap:function(e,t){var i=this._helper,n=this._opt;i.createMiniMap(n.name,n.domElement,n.width,n.height,{left:0,bottom:0,outling:"none",position:"relative"},n.onCameraChanged,n.inMoveOnAxisGrid),e.Grids&&e.Levels&&i.setAxisGridData(n.name,e),t.length>0&&(i.setAllFloorPlaneData(n.name,t),i.setFloorPlaneId(n.name,t[0].name)),i.generateAxisGrid(n.name),i.generateFloorPlane(n.name,!1),i.showAxisGrid(n.name,n.axis),i.getMiniMap(n.name).setMapClickCallback((function(){}))},getFloors:function(){return this._floors},showAxisGrid:function(){this._helper.showAxisGrid(this._opt.name,!0)},hideAxisGrid:function(){this._helper.showAxisGrid(this._opt.name,!1)},showFloorById:function(e){var t=this,i=t._opt.name;t._helper.setFloorPlaneData(i,e),t._helper.generateFloorPlane(i,!0)},resize:function(e,t){this._helper.resize(this._opt.name,e,t)},onClick:function(e,t){var i=this._opt,n=(e=e||"default",this._helper.getMiniMap(i.name));n.setMapClickMode(e),n.setMapClickCallback((function(e){t&&"function"==typeof t&&t(e)}))},toLocation:function(e,t){var i=this._opt;this._helper.getMiniMap(i.name).toLocation(e,t)},imageCoord2WordCoord:function(e,t){var i=this._opt;return this._helper.getMiniMap(i.name).imageCoord2WordCoord({x:e,x:t})}},Re.MiniMap=ke,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map").MapConfig=function(){return{id:"defaultMap",name:"defaultMap",domElement:null,viewer:null,width:240,height:240,isShowGrid:!1,navigationMode:"Default",resourceHost:g.resourceHost,loadAsync:!1}},function(){let t=Object.freeze({ViewerCameraChanged:"ViewerCameraChanged",MouseClicked:"MouseClicked",MouseHoveredGrid:"MouseHoveredGrid",SelectionChanged:"SelectionChanged",SelectionMoved:"SelectionMoved",SelectionEditor:"SelectionEditor",FloorPlaneChanged:"FloorPlaneChanged",Zoom:"Zoom"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map").MapEvents=t}(),function(){let t=Object.freeze({Default:"Default",Static:"Static"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map").MapNavigationMode=t}();var He=function(e,t){return He=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},He(e,t)};function Ue(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}He(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var Ne,Ge=function(){function e(){this.xmlns="http://www.w3.org/2000/svg",this.material=null,this.svgNode=null,this.children=[],this.glodonColor="#11DAB7",this.position=new THREE.Vector2}return e.prototype.add=function(e){this.children.push(e)},e.prototype.getSvgNode=function(){return this.svgNode},e.prototype.abtainRenderables=function(e){e.appendChild(this.svgNode)},e.prototype.isMatch=function(e){return this.name==e},e.prototype.highlight=function(){this.svgNode.setAttribute("style","stroke:"+this.glodonColor)},e.prototype.cancelHighlight=function(){this.svgNode.setAttribute("style","stroke:"+this.material.color.getStyle())},e.prototype.locate=function(e,t){this.position.set(e,t),this.move(0,0)},e.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t;this.svgNode.setAttribute("transform","translate("+i+","+n+")")},e}(),je=function(){function e(){this._boxSize=new THREE.Vector2,this._boxCenter=new THREE.Vector2,this._intersect=new THREE.Vector3}return e.prototype.cross=function(e,t,i,n){return(t.x-e.x)*(n.y-i.y)-(t.y-e.y)*(n.x-i.x)},e.prototype.getArea=function(e,t,i){return this.cross(e,t,e,i)},e.prototype.getAbsArea=function(e,t,i){return Math.abs(this.getArea(e,t,i))},e.prototype.getInterPoint=function(e,t,i,n){var o=this.getAbsArea(e,t,i),s=this.getAbsArea(e,t,n);return new THREE.Vector2((n.x*o+i.x*s)/(o+s),(n.y*o+i.y*s)/(o+s))},e.prototype.isAngleGreaterThanPi=function(e,t,i){var n=new THREE.Vector3;return n.crossVectors(e,t),!(n.dot(i)>=0)},e.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},e.prototype.screenToNormalizedPoint=function(e,t){e.x=e.x/t.width,e.y=-e.y/t.height},e.prototype.normalizedPointToWorld=function(e,t){t.getSize(this._boxSize),e.x=.5*(e.x+1)*this._boxSize.x+t.min.x,e.y=.5*(e.y+1)*this._boxSize.y+t.min.y},e.prototype.worldToNormalizedPoint=function(e,t){t.getSize(this._boxSize),e.x=(e.x-t.min.x)/this._boxSize.x*2-1,e.y=(e.y-t.min.y)/this._boxSize.y*2-1},e.prototype.toWorldPoint=function(e,t,i,n){e.x<0&&(e.x=0),e.x>t&&(e.x=t),e.y<0&&(e.y=0),e.y>i&&(e.y=i),e.x=e.x/t*2-1,e.y=-e.y/i*2+1,this.normalizedPointToWorld(e,n)},e.prototype.getCuttingBoxOnCanvas=function(e,t,i,n){var o=new THREE.Box3,s=new THREE.Vector2(e.x,e.y),r=new THREE.Vector2(t.x,t.y);this.toWorldPoint(s,i[0],i[1],n),this.toWorldPoint(r,i[0],i[1],n);var a=[];return a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,s.y)),a.push(new THREE.Vector3(r.x,s.y)),o.setFromPoints(a),{min:{x:o.min.x,y:o.min.y,z:0},max:{x:o.max.x,y:o.max.y,z:0}}},e.prototype.canvasPointToClient=function(e,t){var i=t.mapContainer;if(!i||!t.floorPlaneBox)return null;var n=this.getContainerOffsetToClient(i);if(0===n.width||0===n.height)return null;var o=new THREE.Vector2;return o.x=e.x+n.left,o.y=e.y+n.top,o},e.prototype.getMainSceneMatrix=function(e){return e.getScene().getMatrixGlobal()},e.prototype.transformWorldPoint=function(e,t){var i=this.getMainSceneMatrix(e);e.miniMapTransform&&t.applyMatrix4((new THREE.Matrix4).fromArray(e.miniMapTransform)),t.applyMatrix4(i)},e.prototype.expandBbox=function(e,t){var i=e.getCenter(this._boxCenter);e.getSize(this._boxSize);var n=new THREE.Vector2,o=t,s=this._boxSize.x/this._boxSize.y,r=this._boxSize.x,a=this._boxSize.y;s>o?a=r/o:s<o&&(r=a*o),n.set(r,a),e.setFromCenterAndSize(i,n)},e.prototype.containsPointInMainScene=function(e,t){var i=e.getScene().getBoundingBoxWorld();return!!i&&i.containsPoint(t)},e.prototype.isMouseOverCanvas=function(e,t,i){if(e){var n=this.getContainerOffsetToClient(e),o=new THREE.Vector2;if(o.x=i.x-n.left,o.y=i.y-n.top,0===n.width||0===n.height)return!1;var s={width:t[0],height:t[0]};if(o.x>0&&o.x<s.width&&o.y>0&&o.y<s.height)return!0}return!1},e.prototype.normalizePoint=function(e,t,i){var n=new THREE.Vector2;if(e){var o=this.getContainerOffsetToClient(e),s=new THREE.Vector2;s.x=i.x-o.left,s.y=i.y-o.top;var r={width:t[0],height:t[1]};if(s.x>0&&s.x<r.width&&s.y>0&&s.y<r.height)return n.x=s.x/r.width*2-1,n.y=-s.y/r.height*2+1,new THREE.Vector2(n.x,n.y)}return null},e.getIntersectionByPoint=function(e,t,i){void 0===i&&(i=3);for(var n=null,o=i*i,s=0,r=e.length;s<r;s++){var a=e[s].intersectionPoint;if(a)if(a.distanceToSquared(t)<o){n=e[s];break}}return n},e.prototype.flyToPointWithParallelEye=function(e,t){e.cameraControl.flyToPointWithParallelEye(t)},e.prototype.getIntersectionToMinDistance=function(e,t){if(e.length<1)return null;for(var i=0,n=0,o=0,s=e.length;o<s;o++){var r=e[o];if(r.intersectionPoint){var a=new THREE.Vector2(r.intersectionPoint.x,r.intersectionPoint.y).distanceToSquared(t);0==i?i=a:i>a&&(i=a,n=o)}}return e[n]},e.prototype.getAxisGridInfoByNormalizedPoint=function(e,t){var i=t.clone(),n=e.naviData.getAxisGridBox2D();this.normalizedPointToWorld(i,n);var o=t.clone(),s={width:e.svgHalfWidth,height:e.svgHalfHeight};this.normalizedPointToScreen(o,s);var r=this.getIntersectionToMinDistance(e.naviData.getAxisGridIntersectionPoints(),o);if(r&&r.intersectionPoint){var a=new THREE.Vector2(r.intersectionPoint.x,r.intersectionPoint.y);this.screenToNormalizedPoint(a,s),this.normalizedPointToWorld(a,n);var l=Math.round(i.x-a.x),h=Math.round(i.y-a.y);return{position:i,abcName:r.abcName,numeralName:r.numeralName,offsetX:l,offsetY:h}}return{position:new THREE.Vector3,abcName:"",numeralName:"",offsetX:"",offsetY:""}},e.prototype.getAxisGridInfoByPoint=function(e,t){var i=this.getMainSceneMatrix(e.viewer),n=new THREE.Matrix4;n.copy(i).invert();var o=t.clone();o.applyMatrix4(n);var s=o.clone(),r={width:e.svgHalfWidth,height:e.svgHalfHeight},a=e.naviData.getAxisGridBox2D();this.worldToNormalizedPoint(s,a),this.normalizedPointToScreen(s,r);var l=this.getIntersectionToMinDistance(e.naviData.getAxisGridIntersectionPoints(),s);if(l&&l.intersectionPoint){var h=new THREE.Vector2(l.intersectionPoint.x,l.intersectionPoint.y);this.screenToNormalizedPoint(h,r),this.normalizedPointToWorld(h,a);var d=Math.round(o.x-h.x),c=Math.round(o.y-h.y);return{position:o,abcName:l.abcName,numeralName:l.numeralName,offsetX:d,offsetY:c}}return{position:new THREE.Vector3,abcName:"",numeralName:"",offsetX:"",offsetY:""}},e.prototype.calculateEdgePositionCameraOutBounds=function(e,t,i){var n=function(e,t){for(var i=!1,n=0,o=e.length;n<o;n++)if(this.isEqualBetweenPoints(t,e[n],this.epsilon)){i=!0;break}return i},o=i.clone();if(o.min.x-=.5,o.min.y-=.5,o.max.x+=.5,o.max.y+=.5,!o.containsPoint(e)){var s=[],r=new THREE.Vector3(e.x,e.y,0),a=new THREE.Ray(r,t),l=new THREE.Vector3(i.min.x,i.min.y,0),h=new THREE.Vector3(-1,0,0),d=new THREE.Plane;if(d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&s.push(this._intersect),l.set(i.max.x,i.max.y,0),h.set(-1,0,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&s.push(this._intersect),l.set(i.min.x,i.min.y,0),h.set(0,1,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),l.set(i.max.x,i.max.y,0),h.set(0,1,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),2!=s.length)return null;var c=s[0],u=s[1].clone().sub(c).normalize();return this.isEqualBetweenPoints(u,t,1e-5)?s[0]:s[1]}return null},e.prototype.getContainerOffsetToClient=function(e){var t,i;if(e!=document){var n=(i=e).getBoundingClientRect?function(e){var t=e.getBoundingClientRect(),i=document.body,n=document.documentElement,o=n.clientTop||i.clientTop,s=n.clientLeft||i.clientLeft,r=t.top-o,a=t.left-s;return{top:Math.round(r),left:Math.round(a)}}(i):function(e){for(var t=0,i=0;e;)t+=e.offsetTop,i+=e.offsetLeft,e=e.offsetParent;var n=document.body,o=document.documentElement;return{top:t-=window.pageYOffset||o.scrollTop||n.scrollTop,left:i-=window.pageXOffset||o.scrollLeft||n.scrollLeft}}(i);t={width:e.offsetWidth,height:e.offsetHeight,left:n.left,top:n.top}}else t={width:window.innerWidth,height:window.innerHeight,left:0,top:0};return t},e.prototype.isEqualBetweenPoints=function(e,t,i){i=i||1e-4;var n=e.x-t.x,o=e.y-t.y;return!(Math.sqrt(n*n+o*o)>i)},e}(),ze=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.start=t,s.end=i,s.material=n,s.name=o,s.build(),s}return Ue(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"line");e.setAttribute("x1",this.start.x),e.setAttribute("y1",this.start.y),e.setAttribute("x2",this.end.x),e.setAttribute("y2",this.end.y);var t=this.material;t instanceof THREE.LineBasicMaterial&&e.setAttribute("style","fill: none; stroke: "+t.color.getStyle()+"; stroke-width: "+t.linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.linecap+"; stroke-linejoin: "+t.linejoin),this.svgNode=e},t}(Ge),Fe=function(e){function t(t,i,n){var o=e.call(this)||this;return o.arcPoints=t,o.material=i,o.name=n,o.build(),o}return Ue(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"polyline");e.setAttribute("points",this.arcPoints.map((function(e){return e.x+","+e.y})).join(" "));var t=this.material;t instanceof THREE.LineBasicMaterial&&e.setAttribute("style","fill: none; stroke: "+t.color.getStyle()+"; stroke-width: "+t.linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.linecap+"; stroke-linejoin: "+t.linejoin),this.svgNode=e},t}(Ge),We=function(e){function t(t,i){var n=e.call(this)||this;return n.center=t,n.literal=i,n.fontSize=8,n.textColor=new THREE.Color(.6,.6,.6),n.build(),n}return Ue(t,e),t.prototype.build=function(){var e=this.center.x,t=this.center.y;if("NaN"!=e.toString()&&"NaN"!=t.toString()){var i=document.createElementNS(this.xmlns,"text");i.setAttribute("style","font-size:"+this.fontSize+"px; fill: none; stroke: "+this.textColor.getStyle()+"; stroke-width: 1"),i.innerHTML=this.literal,i.textContent=this.literal,i.getBoundingClientRect();var n=e-3.5,o=t+2.8;this.svgNode=i,this.locate(n,o)}},t}(Ge),$e=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return Ue(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new We(t,e.name))}))},t.prototype.abtainRenderables=function(e){for(var t=0;t<this.children.length;t++){this.children[t].abtainRenderables(e)}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(Ge),Xe=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.intersections=[],s.lineElements=[],s.horizLineElements=[],s.verticalLineElements=[],s.width=i[0],s.height=i[1],s.bIsShowAxisGrid=n,s.multiplyZoomFactor=o,s.algorithm=new je,s.materialGrid=new THREE.LineBasicMaterial({color:10066329,linewidth:.5}),s.children=[],s.resourceGrids=t,s.boundingBox=new THREE.Box2,s.realBoundingBox=new THREE.Box2,s.clipBox2D=new THREE.Box2(new THREE.Vector2(-s.width/2,-s.height/2),new THREE.Vector2(s.width/2,s.height/2)),s.axisGridNumberInterval=3,s.scratchVector=new THREE.Vector3,s.boxSize=new THREE.Vector2,s.isValid()&&s.build(),s}return Ue(t,e),t.prototype.build=function(){var e=this,t=this.getAxisGridBox(),i={width:this.width/2,height:this.height/2},n=function(n){var o=new THREE.Vector2(n.x,n.y);return e.algorithm.worldToNormalizedPoint(o,t),e.algorithm.normalizedPointToScreen(o,i),o},o=this.materialGrid;this.resourceGrids.forEach((function(t){var i=t.name,s=t.geometry,r=t.label;s.forEach((function(t){if("Line"===t.lineType){var s=t.startPoint,r=t.endPoint,a=n(s),l=n(r),h=l.clone().sub(a).normalize();e.add(new ze(a,l,o,i)),Math.abs(h.x)>=Math.abs(h.y)?e.horizLineElements.push({name:i,v1:a,v2:l,material:o}):e.verticalLineElements.push({name:i,v1:a,v2:l,material:o})}else if("Arc"===t.lineType){var d=t.points.map(n);e.add(new Fe(d,o,i))}}));var a=r.positions.map(n);e.add(new $e(a,i))})),this.lineElements.push(this.horizLineElements),this.lineElements.push(this.verticalLineElements),this.calculateIntersections()},t.prototype.calculateAxisGridBox=function(e,t,i){var n=this;this.boundingBox.makeEmpty(),this.resourceGrids.forEach((function(e){e.geometry.forEach((function(e){if("Line"===e.lineType){var t=e.startPoint,i=e.endPoint,o=new THREE.Vector2(t.x,t.y),s=new THREE.Vector2(i.x,i.y);e.points=[o,s]}else if("Arc"===e.lineType){var r=window.CLOUD.AxisGridManager.getArcGridPoints(e);e.points=r}e.points.forEach((function(e){return n.boundingBox.expandByPoint(e)}))}))})),this.realBoundingBox=this.boundingBox.clone();var o=this.boundingBox.getCenter(this.scratchVector);this.boundingBox.getSize(this.boxSize);var s=new THREE.Vector2,r=e/t,a=this.boxSize.x/this.boxSize.y,l=this.boxSize.x,h=this.boxSize.y,d=4*(i+4)*this.multiplyZoomFactor;a>r?(this.bIsShowAxisGrid&&(l=this.boxSize.x*e/(e-d)),h=l/r):a<r&&(this.bIsShowAxisGrid&&(h=this.boxSize.y*t/(t-d)),l=h*r),s.set(l,h),this.boundingBox.setFromCenterAndSize(o,s)},t.prototype.getAxisGridBox=function(e){return this.isValid()&&this.calculateAxisGridBox(this.width,this.height,10),e?this.realBoundingBox:this.boundingBox},t.prototype.isEmpty=function(){return this.boundingBox.getSize(this.boxSize),0==this.boxSize.length()},t.prototype.isValid=function(){return!!this.resourceGrids},t.prototype.calculateIntersections=function(){for(var e,t,i,n,o,s,r,a,l=this.horizLineElements.length,h=this.verticalLineElements.length,d=0;d<l;d++){n=(e=this.horizLineElements[d]).name,o=e.v1.clone(),s=e.v2.clone();for(var c=0;c<h;c++){i=(t=this.verticalLineElements[c]).name,r=t.v1.clone(),a=t.v2.clone();var u=!1;r.x<=Math.max(o.x,s.x)&&r.x>=Math.min(o.x,s.x)&&o.y<=Math.max(r.y,a.y)&&o.y>=Math.min(r.y,a.y)&&(u=!0);var g=null;u&&(g=this.algorithm.getInterPoint(o,s,r,a)),this.intersections.push({intersectionPoint:g,horizLine:[o.clone(),s.clone()],verticalLine:[r.clone(),a.clone()],abcName:n,numeralName:i})}}},t.prototype.getIntersections=function(){return this.intersections},t.prototype.abtainRenderables=function(e){for(var t=0;t<this.children.length;t++){this.children[t].abtainRenderables(e)}},t.prototype.getGridLineByName=function(e){for(var t=this.children,i=0;i<t.length;i++){var n=t[i];if(n instanceof ze&&n.isMatch(e))return n}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(Ge),Ye=function(e){function t(t,i,n){var o=e.call(this)||this;return o.imageUrl=t,o.width=i[0],o.height=i[1],o.offsetX=i[2],o.offsetY=i[3],o.isFlip=n,o.build(),o}return Ue(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"image");e.href.baseVal=this.imageUrl,e.setAttribute("herf",this.imageUrl),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("width",this.width+""),e.setAttribute("height",this.height+""),e.setAttribute("x",-.5*this.width+""),e.setAttribute("y",-.5*this.height+""),this.isFlip&&e.setAttribute("transform","scale(-1,1)"),this.svgNode=e,this.locate(this.offsetX,this.offsetY)},t.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t;return this.isFlip?this.svgNode.setAttribute("transform","translate("+i+", "+n+")\n scale("+"-1,1)"):this.svgNode.setAttribute("transform","translate("+i+","+n+")"),{x:i,y:n}},t}(Ge);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(Ne||(Ne={}));var Ze,qe,Ke=function(){function e(){this.bIsMouseDown=!1,this.name=Ne.Default}return e.prototype.onMouseDown=function(e){},e.prototype.onMouseMove=function(e){},e.prototype.onMouseUp=function(e){},e.prototype.onMouseWheel=function(e){},e.prototype.getName=function(){return this.name},e}();!function(e){e[e.RECTPICK_MOUSE_DOWN=1e3]="RECTPICK_MOUSE_DOWN",e[e.RECTPICK_MOUSE_MOVE=1001]="RECTPICK_MOUSE_MOVE",e[e.RECTPICK_MOUSE_UP=1002]="RECTPICK_MOUSE_UP",e[e.PICK_MOUSE_DOWN=2e3]="PICK_MOUSE_DOWN",e[e.PICK_MOUSE_MOVE=2001]="PICK_MOUSE_MOVE",e[e.PICK_MOUSE_UP=2002]="PICK_MOUSE_UP",e[e.Floor_Plane_Changed=3e3]="Floor_Plane_Changed",e[e.Floor_Plane_Changed_For_Panel=3001]="Floor_Plane_Changed_For_Panel",e[e.Resize=4e3]="Resize",e[e.Camera_Height_Changed=5e3]="Camera_Height_Changed",e[e.ZOOM_MOUSE_WHEEL=6e3]="ZOOM_MOUSE_WHEEL",e[e.PAN_MOUSE_MOVE=7e3]="PAN_MOUSE_MOVE",e[e.Minimap_Rect_Changed=8e3]="Minimap_Rect_Changed",e[e.Minimap_Rect_Destroyed=8001]="Minimap_Rect_Destroyed"}(Ze||(Ze={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(qe||(qe={}));var Qe,Je=function(){function e(){this.eventDispatcher=new THREE.EventDispatcher}return e.prototype.addEventListener=function(e,t){this.eventDispatcher.addEventListener(e,t)},e.prototype.hasEventListener=function(e){this.eventDispatcher.hasEventListener(e)},e.prototype.removeEventListener=function(e,t){this.eventDispatcher.removeEventListener(e,t)},e.prototype.dispatchEvent=function(e){this.eventDispatcher.dispatchEvent(e)},e}();!function(e){e.Min="Min",e.Max="Max"}(Qe||(Qe={}));var et=function(e){function t(t,i){var n=e.call(this)||this;return n.totalZoomFactors=[],n.zoomFactors=[],n.lastZoomFactor=1,n.currentIdx=0,n.name=Ne.Zoom_Editor,n.eventManager=i,n.vfData=t.getData(),n.vfViewer=t,n}return Ue(t,e),t.prototype.onMouseWheel=function(e){var t=(e.deltaY||-e.wheelDelta||e.detail)<0,i=-1;if(t?this.currentIdx<this.zoomFactors.length-1&&(this.currentIdx++,i=this.zoomFactors[this.currentIdx]):this.currentIdx>0&&(this.currentIdx--,i=this.zoomFactors[this.currentIdx]),!(i<0||this.lastZoomFactor==i)){this.lastZoomFactor=i,1==i&&tt.clear();var n=this.vfData.getOriginSize(),o=new THREE.Vector2(e.offsetX-n[0]/2,e.offsetY-n[1]/2),s=this.zoomFactors[this.currentIdx],r=0,a=0;if(t){var l=s/(u=this.zoomFactors[this.currentIdx-1]),h=[],d=this.vfData.getCorner("Virtual","LB");d[0]-=o.x,d[1]-=o.y,h.push(d[0]*l+o.x),h.push(d[1]*l+o.y),this.vfData.setZoomFactor(s);var c=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(u),r=h[0]-c[0],a=h[1]-c[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}tt.panOffsetX+=r,tt.panOffsetY+=a,tt.panOffsetXForCamera+=r,tt.panOffsetYForCamera+=a,this.vfData.setZoomFactor(i),this.vfViewer.destroy(),this.vfData.destroy(),this.vfData.build(),this.vfViewer.update(),this.vfData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:Ze.ZOOM_MOUSE_WHEEL,data:{offsetX:tt.panOffsetX,offsetY:tt.panOffsetY,zoomFactor:i}})}},t.prototype.boundsChecking=function(e,t,i){var n=e/t,o=this.vfData.getCorner("Virtual","LB"),s=this.vfData.getCorner("Virtual","LT"),r=this.vfData.getCorner("Virtual","RT"),a=this.vfData.getCorner("Virtual","RB"),l=[0,0],h=(o[0]-i.x)*n+i.x,d=(o[1]-i.y)*n+i.y;this.vfData.setZoomFactor(e);var c=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(t),l[0]=h-c[0],l[1]=d-c[1];var u=0,g=0,p=this.vfData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),d<p[1]&&(l[1]+=p[1]-d,g++),h=(s[0]-i.x)*n+i.x,d=(s[1]-i.y)*n+i.y;var m=this.vfData.getCorner("Origin","LT");h>m[0]&&0==u&&(l[0]+=m[0]-h,u++),d>m[1]&&0==g&&(l[1]+=m[1]-d,g++),h=(r[0]-i.x)*n+i.x,d=(r[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","RT");h<f[0]&&0==u&&(l[0]+=f[0]-h,u++),d>f[1]&&0==g&&(l[1]+=f[1]-d,g++),h=(a[0]-i.x)*n+i.x,d=(a[1]-i.y)*n+i.y;var w=this.vfData.getCorner("Origin","RB");return h<w[0]&&0==u&&(l[0]+=w[0]-h,u++),d<w[1]&&0==g&&(l[1]+=w[1]-d,g++),l},t.prototype.enableMode=function(e){if(e==Qe.Min)this.zoomFactors=this.totalZoomFactors;else if(e==Qe.Max){this.zoomFactors=this.totalZoomFactors.slice(1,this.totalZoomFactors.length);for(var t=1;t<this.zoomFactors.length;t++)this.zoomFactors[t]/=this.zoomFactors[0];this.zoomFactors[0]=1}this.currentIdx=0},t.prototype.setZoomFactors=function(e){this.totalZoomFactors=e,this.zoomFactors=e},t.prototype.setZoonIndex=function(e){this.currentIdx=e},t.prototype.getZoonIndex=function(){return this.currentIdx},t.prototype.updateZoomAndPan=function(){var e=this.vfData.getCorner("Origin","LT"),i=this.vfData.getCorner("Virtual","LT");t.offsetXForZoomAndPan=e[0]-i[0],t.offsetYForZoomAndPan=e[1]-i[1]},t.clear=function(){t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0},t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0,t}(Ke),tt=function(e){function t(i,n){var o=e.call(this)||this;return o.name=Ne.PAN_Editor,o.eventManager=n,o.vfData=i.getData(),o.bIsMouseDown=!1,o.mouseDownPos=new THREE.Vector2,t.panOffsetX=0,t.panOffsetY=0,o}return Ue(t,e),t.prototype.onMouseDown=function(e){this.bIsMouseDown=!0,this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)},t.prototype.onMouseMove=function(e){if(0!=this.bIsMouseDown&&1!=this.vfData.getZoomFactor()){var i=e.clientX-this.mouseDownPos.x,n=e.clientY-this.mouseDownPos.y,o=this.boundsChecking(i,n);i=o[0],n=o[1],t.panOffsetX+=i,t.panOffsetY+=n,t.panOffsetXForCamera+=i,t.panOffsetYForCamera+=n,this.vfData.updateMovement(),this.updateZoomAndPan(),this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)}},t.prototype.onMouseUp=function(e){if(0!=this.bIsMouseDown&&1!=this.vfData.getZoomFactor()){var i=e.clientX-this.mouseDownPos.x,n=e.clientY-this.mouseDownPos.y,o=this.boundsChecking(i,n);i=o[0],n=o[1],t.panOffsetX+=i,t.panOffsetY+=n,t.panOffsetXForCamera+=i,t.panOffsetYForCamera+=n,this.vfData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:Ze.PAN_MOUSE_MOVE,data:{offsetX:t.panOffsetX,offsetY:t.panOffsetY,zoomFactor:this.vfData.getZoomFactor()}}),this.bIsMouseDown=!1}},t.prototype.boundsChecking=function(e,t){var i=this.vfData.getCorner("Origin","LB"),n=this.vfData.getCorner("Virtual","LB"),o=this.vfData.getCorner("Origin","RT"),s=this.vfData.getCorner("Virtual","RT");if(e>0)(r=i[0]-n[0])<=e&&(e=r);else if(e<0){var r;(r=o[0]-s[0])>=e&&(e=r)}if(t<0)(a=i[1]-n[1])>=t&&(t=a);else if(t>0){var a;(a=o[1]-s[1])<=t&&(t=a)}return[e,t]},t.prototype.updateZoomAndPan=function(){var e=this.vfData.getCorner("Origin","LT"),t=this.vfData.getCorner("Virtual","LT");et.offsetXForZoomAndPan=e[0]-t[0],et.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(Ke),it=function(e){function t(){var t=e.call(this)||this;return t.cameraCircleNode=null,t.cameraArrowNode=null,t.rotateAngle=0,t.panelSize=[298,198],t.cameraPositionToTarget=2e3,t.build(),t}return Ue(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"g");e.setAttribute("fill","none"),e.setAttribute("fill-rule","evenodd"),e.setAttribute("stroke-width","1");var t=document.createElementNS(this.xmlns,"circle");t.setAttribute("r","4.5"),t.setAttribute("stroke","#FFFFFF"),t.setAttribute("fill","#32D3A6"),this.cameraCircleNode=t;var i=document.createElementNS(this.xmlns,"path");i.setAttribute("d","M5.94925387,0 C18.4132389,0 28.6581001,9.50119823 29.8362478,21.6560048 L5.94925387,25 Z"),i.setAttribute("fill","url(#radialGradient-1)"),i.setAttribute("transform","translate(13,-21)rotate(50)"),this.cameraArrowNode=i;var n=document.createElementNS(this.xmlns,"defs"),o=document.createElementNS(this.xmlns,"radialGradient"),s=document.createElementNS(this.xmlns,"stop"),r=document.createElementNS(this.xmlns,"stop");o.setAttribute("cx","0%"),o.setAttribute("cy","100%"),o.setAttribute("fx","0%"),o.setAttribute("fy","100%"),o.setAttribute("r","104.321936%"),o.setAttribute("id","radialGradient-1"),s.setAttribute("stop-color","#36D4A8"),s.setAttribute("offset","0%"),r.setAttribute("stop-color","#36D4A8"),r.setAttribute("offset","100%"),r.setAttribute("stop-opacity","0"),n.append(o),o.append(s),o.append(r),e.appendChild(n),e.appendChild(t),e.appendChild(i),this.svgNode=e},t.prototype.setCircleAttribute=function(e,t){this.cameraCircleNode.setAttribute(e,t)},t.prototype.setArrowAttribute=function(e,t){this.cameraArrowNode.setAttribute(e,t)},t.prototype.rotate=function(e){e&&(this.rotateAngle=e);var t=this.svgNode.getAttribute("transform");t+="rotate("+this.rotateAngle+")",this.svgNode.setAttribute("transform",t)},t.prototype.setOffsetAndRotate=function(e,t,i){var n=this.setOffsetBoundary(e,t);this.locate(n.X,n.Y),this.rotate(i),tt.panOffsetXForCamera=0,tt.panOffsetYForCamera=0},t.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t,o=this.setOffsetBoundary(i,n);this.svgNode.setAttribute("transform","translate("+o.X+","+o.Y+")")},t.prototype.setOpacity=function(e){this.svgNode.setAttribute("opacity",e)},t.prototype.setCameraArrowOpacity=function(e){this.cameraArrowNode.setAttribute("opacity",e)},t.prototype.setCameraCircleOpacity=function(e){this.cameraCircleNode.setAttribute("opacity",e)},t.prototype.setBigCamera=function(){this.cameraCircleNode.setAttribute("r","4.5"),this.cameraArrowNode.setAttribute("transform","translate(13,-21)rotate(50)")},t.prototype.setSmallCamera=function(){this.cameraCircleNode.setAttribute("r","2"),this.cameraArrowNode.setAttribute("transform","translate(20,-21)rotate(50)")},t.prototype.setPanelSize=function(e){this.panelSize=e},t.prototype.setOffsetBoundary=function(e,t){var i=this.panelSize[0]/2-6,n=-this.panelSize[0]/2+6,o=this.panelSize[1]/2-6,s=-this.panelSize[1]/2+6;return e>=i||e<=n||t>=o||t<=s?this.setSmallCamera():this.setBigCamera(),e>i&&(e=i),e<n&&(e=n),t>o&&(t=o),t<s&&(t=s),{X:e,Y:t}},t}(Ge),nt=function(){function e(e){this.resourceGrids=e,this.floorPlaneBox=new THREE.Box2}return e.prototype.get=function(){return this.resourceGrids},e}(),ot=function(){function e(e){this.resourceLevels=e,this.elevations=[],this.offsetForPlane=235,this.createElevationsInOrder()}return e.prototype.createElevationsInOrder=function(){var e=this.resourceLevels;for(var t in e)null!=e[t].elevation&&this.elevations.push(e[t].elevation);this.elevations.sort((function(e,t){return e-t})),this.elevations[this.elevations.length-1]-this.elevations[0]<this.offsetForPlane&&(this.offsetForPlane/=1e3)},e.prototype.getMinMaxElevations=function(e){var t=[0,0],i=this.resourceLevels;for(var n in i)if(i[n].name==e){t[0]=i[n].elevation-this.offsetForPlane,t[1]=i[n].elevation;break}for(var o=0;o<this.elevations.length;o++)if(this.elevations[o]-t[0]-this.offsetForPlane>1e-6){t[1]=this.elevations[o],t[1]-=this.offsetForPlane;break}return t},e.prototype.getElevation=function(e,t){for(var i=this.resourceLevels,n=0;n<i.length;n++){var o=i[n];if(o.id==e&&(!t||o.modelId==t))return o.elevation}},e.prototype.getElevationsInOrder=function(){return this.elevations},e.prototype.getLevelIdByElevation=function(e){for(var t=this.resourceLevels,i=0;i<t.length;i++){var n=t[i];if(n.elevation==e)return n.id}},e}(),st=function(){function e(e){this.resourcePlanes=e}return e.prototype.find=function(e,t){for(var i=0;i<this.resourcePlanes.length;i++){var n=this.resourcePlanes[i];if(t){if(n.modelId==t&&n.id==e)return n}else if(n.id==e)return n}},e.prototype.getFloorPlaneBox=function(e,t){var i=this.find(e,t);return i?i.boundingBox||i.BoundingBox:void 0},e.prototype.getUrl=function(e,t){var i=this.find(e,t);return i?i.path||i.Path:void 0},e.prototype.getElevation=function(e,t){var i=this.find(e,t);return i?i.Elevation:void 0},e.prototype.getName=function(e,t){var i=this.find(e,t);return i?i.name||i.Name:void 0},e}(),rt=function(e){function t(t,i){var n=e.call(this)||this;return n.radius=t,n.material=i,n.build(),n}return Ue(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"circle");e.setAttribute("r",this.radius+""),e.setAttribute("fill",this.glodonColor),e.setAttribute("style","fill: none; stroke: "+this.glodonColor),e.setAttribute("opacity","0"),this.svgNode=e},t.prototype.highlight=function(){this.svgNode.setAttribute("style","stroke:"+this.glodonColor),this.svgNode.setAttribute("opacity","1")},t.prototype.cancelHighlight=function(){this.svgNode.setAttribute("style","stroke:rgb(153,153,153)"),this.svgNode.setAttribute("opacity","0")},t.prototype.setOffset=function(e,t){this.svgNode.setAttribute("transform","translate("+e+","+t+")")},t}(Ge),at=function(e){function t(){var t=e.call(this)||this;return t.tipNodeBackgroundColor="#fff",t.tipNodeColor="#000",t.initialize(),t.build(),t}return Ue(t,e),t.prototype.initialize=function(){var e=".cloud-tip:after { box-sizing: border-box;display: inline;font-size: 10px;width: 100%;line-height: 1;color: "+this.tipNodeBackgroundColor+";content: '\\25BC';position: absolute;text-align: center;margin: -4px 0 0 0;top: 100%;left: 0;}";this.loadStyleString(e)},t.prototype.loadStyleString=function(e){var t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t)},t.prototype.build=function(){var e=document.createElement("div");e.className="cloud-tip",e.style.position="absolute",e.style.opacity="0",e.style.background=this.tipNodeBackgroundColor,e.style.color=this.tipNodeColor,e.style.padding="0 8px 0 8px",e.style.borderRadius="2px",e.style.fontSize="8px",e.style.zIndex="10",this.svgNode=e},t.prototype.show=function(){this.svgNode.style.opacity=1,this.svgNode.className="cloud-tip"},t.prototype.hide=function(){this.svgNode.style.opacity=0,this.svgNode.className=""},t.prototype.setContent=function(e){this.svgNode.innerHTML=e},t.prototype.setOffset=function(e,t){var i=this.svgNode.getBoundingClientRect();this.svgNode.style.left=e[0]/2+t[0]-.5*i.width+"px",this.svgNode.style.top=e[1]/2+t[1]-i.height-12+"px"},t}(Ge),lt=function(){function e(){this.zoomFactor=1,this.bboxLengthStages=[15e4,3e5],this.zoomFactors1=[1,7/4,2.5,10/3],this.zoomFactors2=[1,7/4,2.5,14/3,65/12,20/3],this.zoomFactors3=[1,7/4,2.5,10/3,14/3,65/12,20/3,49/6,10],this.needFlip=!1,this.floorPlaneId=null,this.drawableItems=[],this.width=298,this.height=198,this.bIsShowAxisGrid=!1,this.bIsShowCameraNode=!0,this.bIsShowFloorPlane=!0,this.floorPlaneBox=new THREE.Box3,this.axisGridNode=null,this.cameraNode=null,this.floorPlaneNode=null,this.algorithm=new je,this.glodonColor="#11DAB7",this.scratchVector=new THREE.Vector2,this.scratchVector_2=new THREE.Vector2,this.scratchVector_3=new THREE.Vector2,this.scratchVector_4=new THREE.Vector2,this.axisGridBoxSize=new THREE.Vector2,this.floorPlaneBox2DSize=new THREE.Vector2}return e.prototype.setAxisGrids=function(e){this.dataAxisGrid=new nt(e.Grids),this.dataLevels=new ot(e.Levels)},e.prototype.setPlanes=function(e){this.dataFloorPlanes=new st(e)},e.prototype.setFloorPlaneId=function(e,t){this.floorPlaneId=e,this.modelId=t,this.build()},e.prototype.setFlip=function(e){this.needFlip=e},e.prototype.getFloorPlaneId=function(){return this.floorPlaneId},e.prototype.getFloorPlaneBox=function(){var e=this.dataFloorPlanes.getFloorPlaneBox(this.floorPlaneId,this.modelId),t=this.dataFloorPlanes.getName(this.floorPlaneId,this.modelId),i=this.dataLevels.getMinMaxElevations(t);return e&&(this.floorPlaneBox.min=new THREE.Vector3(e.Min.X||e.Min.x,e.Min.Y||e.Min.y,i[0]),this.floorPlaneBox.max=new THREE.Vector3(e.Max.X||e.Max.x,e.Max.Y||e.Max.y,i[1])),this.floorPlaneBox},e.prototype.setSize=function(e,t){this.width=e,this.height=t},e.prototype.getSize=function(){return[this.width*this.zoomFactor,this.height*this.zoomFactor]},e.prototype.getOriginSize=function(){return[this.width,this.height]},e.prototype.getGlodonColor=function(){return this.glodonColor},e.prototype.build=function(){var e=!!this.dataAxisGrid&&this.dataAxisGrid.get();if(this.axisGridNode=new Xe(e,this.getSize(),this.bIsShowAxisGrid,this.getZoomFactor()),this.axisGridNode.isEmpty()&&(this.bIsShowAxisGrid=!1),this.bIsShowAxisGrid&&this.drawableItems.push(this.axisGridNode),this.buildFloorPlane(),this.bIsShowCameraNode){this.cameraNode=new it;var t=this.getOriginSize();this.cameraNode.setPanelSize(t),this.drawableItems.push(this.cameraNode)}this.intersectPoint=new rt(3),this.drawableItems.push(this.intersectPoint),this.tipNode=new at,this.drawableItems.push(this.tipNode)},e.prototype.buildFloorPlane=function(){if(this.bIsShowFloorPlane){var e=this.getFloorPlaneBox();this.getAxisGridBox2D().containsBox(e)||console.warn("the bounding-box of axis-grid is not contains the bounding-box of floor-plane!");var t=this.getFloorPlaneParams();this.floorPlaneNode=new Ye(this.dataFloorPlanes.getUrl(this.floorPlaneId,this.modelId),t,this.needFlip),this.drawableItems.push(this.floorPlaneNode)}},e.prototype.getFloorPlaneParams=function(){var e=this.getFloorPlaneBox(),t=this.getAxisGridBox2D(),i=new THREE.Box2(new THREE.Vector2(e.min.x,e.min.y),new THREE.Vector2(e.max.x,e.max.y)),n=this.getSize()[0],o=n/this.getSize()[1];t.getSize(this.axisGridBoxSize),this.axisGridBoxSize.x/this.axisGridBoxSize.y!=o&&(this.algorithm.expandBbox(t,o),t.getSize(this.axisGridBoxSize));var s=[],r=n/this.axisGridBoxSize.x;i.getSize(this.floorPlaneBox2DSize);var a=this.floorPlaneBox2DSize.x*r,l=this.floorPlaneBox2DSize.y*r;s.push(a,l);var h=i.getCenter(this.scratchVector).clone().sub(t.getCenter(this.scratchVector_2));return h.x*=r,h.y*=-r,s.push(h.x,h.y),s},e.prototype.updateFloorPlane=function(e){for(var t=this.dataLevels.getElevationsInOrder(),i=this.getElevationById(),n=void 0,o=void 0,s=0;s<t.length;s++){if((r=t[s])>e){o=r;break}}for(s=t.length-1;s>=0;s--){var r;if((r=t[s])<e){n=r;break}}if(null==n){var a=this.dataLevels.getLevelIdByElevation(o);return this.floorPlaneId=a,!0}if(null==o){a=this.dataLevels.getLevelIdByElevation(n);return this.floorPlaneId=a,!0}if(i>=n&&i<o)return!1;a=this.dataLevels.getLevelIdByElevation(n);return this.floorPlaneId=a,!0},e.prototype.getDataFloorPlanes=function(){return this.dataFloorPlanes},e.prototype.getAxisGridBox2D=function(e){var t=this.axisGridNode.getAxisGridBox(e);if(0==t.getSize(this.axisGridBoxSize).length()){var i=this.getFloorPlaneBox();if(e)return i;var n=(new THREE.Box2).set(new THREE.Vector2(i.min.x,i.min.y),new THREE.Vector2(i.max.x,i.max.y)),o=n.getCenter(this.scratchVector);n.getSize(this.scratchVector_4);var s=new THREE.Vector2,r=this.width/this.height,a=this.scratchVector_4.x/this.scratchVector_4.y,l=this.scratchVector_4.x,h=this.scratchVector_4.y;return a>r?h=l/r:a<r&&(l=h*r),s.set(l,h),n.setFromCenterAndSize(o,s),n}return t},e.prototype.getDrawableItems=function(){return this.drawableItems},e.prototype.destroy=function(){this.drawableItems=[]},e.prototype.setIsShowAxisGrid=function(e){this.bIsShowAxisGrid=e},e.prototype.getCameraNode=function(){for(var e=this.drawableItems,t=0;t<e.length;t++){var i=e[t];if(i instanceof it)return i}},e.prototype.getElevationById=function(){return this.dataLevels.getElevation(this.floorPlaneId,this.modelId)},e.prototype.updateMovement=function(){this.getFloorPlaneNode().move(tt.panOffsetX,tt.panOffsetY);var e=this.getAxisGridNode();e&&e.move(tt.panOffsetX,tt.panOffsetY);var t=this.getCameraNode();t.move(tt.panOffsetXForCamera,tt.panOffsetYForCamera),t.rotate()},e.prototype.getCorner=function(e,t){var i=[],n=[];"Origin"==e?(i=[0,0],n=this.getOriginSize()):"Virtual"==e&&(i=[tt.panOffsetX,tt.panOffsetY],n=this.getSize());var o=0,s=0;switch(t){case"LB":o=i[0]-n[0]/2,s=i[1]+n[1]/2;break;case"LT":o=i[0]-n[0]/2,s=i[1]-n[1]/2;break;case"RT":o=i[0]+n[0]/2,s=i[1]-n[1]/2;break;case"RB":o=i[0]+n[0]/2,s=i[1]+n[1]/2;break;default:console.log("CornerName is wrong.")}return[o,s]},e.prototype.getIntersections=function(){return this.axisGridNode.getIntersections()},e.prototype.getGridLineByName=function(e){return this.axisGridNode.getGridLineByName(e)},e.prototype.getTipNode=function(){return this.tipNode},e.prototype.getFloorPlaneNode=function(){return this.floorPlaneNode},e.prototype.getAxisGridNode=function(){return 0==this.bIsShowAxisGrid?null:this.axisGridNode},e.prototype.getIntersectPoint=function(){return this.intersectPoint},e.prototype.setZoomFactor=function(e){this.zoomFactor=e},e.prototype.getZoomFactor=function(){return this.zoomFactor},e.prototype.getProperZoomFactors=function(){this.getAxisGridBox2D(!0).getSize(this.scratchVector_3);var e=Math.max(this.scratchVector_3.x,this.scratchVector_3.y);return e<=this.bboxLengthStages[0]?this.zoomFactors1:e<=this.bboxLengthStages[1]?this.zoomFactors2:this.zoomFactors3},e}(),ht=function(){function e(e,t,i){this.viewer=e,this.domContainer=t,this.viewerFloorData=i,this.width=298,this.height=198,this.manHeight=e._manHeight,this.algorithm=new je,this.eventManager=null,this.currentFloorName=null,this.bBoxCenter=new THREE.Vector2,this.projectedCameraPosition=new THREE.Vector3,this.projectedTargetPosition=new THREE.Vector3,this.sceneMatrixInverse=new THREE.Matrix4,this.initialize()}return e.prototype.initialize=function(){var e="http://www.w3.org/2000/svg";this.drawableContainer=document.createElementNS(e,"svg"),this.drawableContainer.setAttribute("width",this.width+""),this.drawableContainer.setAttribute("height",this.height+""),this.drawableContainer.setAttribute("viewBox",-this.width/2+" "+-this.height/2+" "+this.width+" "+this.height),this.drawableContainer.style.position="absolute",this.auxContainer=document.createElementNS(e,"svg"),this.auxContainer.setAttribute("width",this.width+""),this.auxContainer.setAttribute("height",this.height+""),this.auxContainer.setAttribute("viewBox",-this.width/2+" "+-this.height/2+" "+this.width+" "+this.height),this.auxContainer.style.position="absolute",this.mapContainer=document.createElement("div"),this.mapContainer.style.left="0px",this.mapContainer.style.bottom="0px",this.mapContainer.style.position="relative",this.mapContainer.outling="none",this.mapContainer.appendChild(this.drawableContainer),this.mapContainer.appendChild(this.auxContainer),this.domContainer.appendChild(this.mapContainer),this.cameraHeightChangedCallbackBinded=this.cameraHeightChangedCallback.bind(this)},e.prototype.cameraHeightChangedCallback=function(e){var t=e.cameraPosition,i=this.viewer.getScene().getMatrixGlobal();this.sceneMatrixInverse.copy(i).invert();var n=t.clone().applyMatrix4(this.sceneMatrixInverse);if(this.viewerFloorData.getAxisGridBox2D().containsPoint(new THREE.Vector2(n.x,n.y))&&this.viewerFloorData.updateFloorPlane(n.z)){var o=this.viewerFloorData.getDataFloorPlanes().getName(this.viewerFloorData.getFloorPlaneId());o&&this.currentFloorName!=o&&(this.currentFloorName=o,this.eventManager.dispatchEvent({type:Ze.Camera_Height_Changed,id:this.viewerFloorData.getFloorPlaneId()}),console.log("Current floor plane is "+o))}},e.prototype.getMapContainer=function(){return this.drawableContainer},e.prototype.getDomContainer=function(){return this.mapContainer},e.prototype.getAuxContainer=function(){return this.auxContainer},e.prototype.getViewer=function(){return this.viewer},e.prototype.getData=function(){return this.viewerFloorData},e.prototype.setSize=function(e,t){this.mapContainer.style.width=e+"px",this.mapContainer.style.height=t+"px",this.drawableContainer.setAttribute("width",e+""),this.drawableContainer.setAttribute("height",t+""),this.drawableContainer.setAttribute("viewBox",-e/2+" "+-t/2+" "+e+" "+t),this.auxContainer.setAttribute("width",e+""),this.auxContainer.setAttribute("height",t+""),this.auxContainer.setAttribute("viewBox",-e/2+" "+-t/2+" "+e+" "+t),this.destroy(),this.viewerFloorData.destroy(),this.viewerFloorData.build(),this.update(),this.eventManager.dispatchEvent({type:Ze.Resize,size:{width:e,height:t}})},e.prototype.destroy=function(){for(var e=this.drawableContainer;e.children.length>0;){var t=e.children[0];e.removeChild(t)}this.mapContainer.removeChild(e);var i=this.getData().getTipNode();i&&null!=i.getSvgNode().parentNode&&this.mapContainer.removeChild(i.getSvgNode())},e.prototype.updateCameraNode=function(e){var t=this.viewer,i=t.camera,n=t.cameraControl;if(i&&n){var o=i.position,s=i.target,r=this.algorithm.getMainSceneMatrix(t),a=new THREE.Matrix4;a.copy(r).invert();var l=this.viewerFloorData.getFloorPlaneBox();l.getCenter(this.bBoxCenter);var h=new THREE.Vector3(l.min.x,l.min.y,this.bBoxCenter.z).applyMatrix4(r),d=new THREE.Vector3(l.min.x,l.max.y,this.bBoxCenter.z).applyMatrix4(r),c=new THREE.Vector3(l.max.x,l.min.y,this.bBoxCenter.z).applyMatrix4(r),u=new THREE.Plane;u.setFromCoplanarPoints(h,d,c),u.projectPoint(o,this.projectedCameraPosition),this.projectedCameraPosition.applyMatrix4(a),t.miniMapTransform&&this.projectedCameraPosition.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert()),u.projectPoint(s,this.projectedTargetPosition),this.projectedTargetPosition.applyMatrix4(a),t.miniMapTransform&&this.projectedTargetPosition.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert());var g=this.projectedTargetPosition.clone().sub(this.projectedCameraPosition);g.z=0,g.normalize();var p=o.clone();p.applyMatrix4(a),t.miniMapTransform&&p.applyMatrix4((new THREE.Matrix4).fromArray(t.miniMapTransform).invert()),e&&(p=e.globalUnitUtil.revertVector(p));var m=p.clone(),f=this.viewerFloorData.getSize(),w={width:f[0]/2,height:f[1]/2},y=this.viewerFloorData.getAxisGridBox2D();this.algorithm.worldToNormalizedPoint(m,y),this.algorithm.normalizedPointToScreen(m,w);var v=this.viewerFloorData.getCameraNode();if(v.setOpacity("1.0"),g.length()<1e-5)v.setCameraArrowOpacity("0.0"),v.setOffsetAndRotate(m.x+tt.panOffsetX,m.y+tt.panOffsetY,0);else{var b=new THREE.Vector3(0,0,1),E=new THREE.Vector3(1,0,0),M=this.algorithm.isAngleGreaterThanPi(E,g,b),C=THREE.Math.radToDeg(E.angleTo(g));M||(C*=-1),v.setBigCamera(),v.setOffsetAndRotate(m.x+tt.panOffsetX,m.y+tt.panOffsetY,C),v.setCameraArrowOpacity("1.0")}}},e.prototype.update=function(e){for(var t=this.viewerFloorData.getDrawableItems(),i=0;i<t.length;i++){var n=t[i];n instanceof at?this.mapContainer.appendChild(n.getSvgNode()):n.abtainRenderables(this.drawableContainer)}this.updateCameraNode();var o=this.mapContainer.firstChild;o?this.mapContainer.insertBefore(this.drawableContainer,o):this.mapContainer.appendChild(this.drawableContainer)},e.prototype.setEventManager=function(e){this.eventManager=e},e.prototype.getEventManager=function(){return this.eventManager},e.prototype.registerCameraHeightChanged=function(e){this.viewer.registerEventListener(e,this.cameraHeightChangedCallbackBinded)},e.prototype.getManHeight=function(){return this.manHeight},e}(),dt=function(){function e(e){this.viewerFloorData=e}return e.prototype.hightlight=function(e,t,i){var n=this.viewerFloorData.getOriginSize();this.intersectPoint=this.viewerFloorData.getIntersectPoint();var o=[e.intersectionPoint.x+t,e.intersectionPoint.y+i];this.intersectPoint.setOffset(o[0],o[1]),this.abcGridLine=this.viewerFloorData.getGridLineByName(e.abcName),this.numeralGridLine=this.viewerFloorData.getGridLineByName(e.numeralName),this.intersectPoint.highlight(),this.abcGridLine.highlight(),this.numeralGridLine.highlight(),this.tipNode=this.viewerFloorData.getTipNode(),this.tipNode.setContent(e.numeralName+"-"+e.abcName),this.tipNode.setOffset(n,o),this.tipNode.show()},e.prototype.cancelHightlight=function(){this.intersectPoint&&(this.intersectPoint.cancelHighlight(),this.abcGridLine.cancelHighlight(),this.numeralGridLine.cancelHighlight(),this.tipNode.hide(),this.intersectPoint=null,this.abcGridLine=null,this.numeralGridLine=null,this.tipNode=null)},e}(),ct=function(e){function t(t,i){var n=e.call(this)||this;return n.name=Ne.PICK_Editor,n.vfViewer=t,n.vfData=t.getData(),n.algorithm=new je,n.highlightControl=new dt(n.vfData),n.cameraProjectedPosZ=t.getManHeight(),n.mapClickMode="default",n.lastMousePoint=new THREE.Vector2,n.eventManager=i,n.bIsEnableHover=!0,n}return Ue(t,e),t.prototype.onMouseDown=function(e){this.bIsMouseDown=!0,this.lastMousePoint.setX(e.clientX),this.lastMousePoint.setY(e.clientY)},t.prototype.onMouseMove=function(e){if(0!=this.bIsEnableHover||!this.bIsMouseDown){var t=new THREE.Vector2(e.clientX,e.clientY);t.x+=et.offsetXForZoomAndPan,t.y+=+et.offsetYForZoomAndPan;var i=this.vfViewer.getMapContainer(),n=this.vfData.getSize();if(this.algorithm.isMouseOverCanvas(i,n,t)){var o=this.algorithm.normalizePoint(i,n,t),s=new THREE.Vector2(o.x,o.y),r=null;this.bIsAllowNear?(this.algorithm.normalizedPointToScreen(s,{width:n[0]/2,height:n[1]/2}),r=this.algorithm.getIntersectionToMinDistance(this.vfData.getIntersections(),s)):r=this.getIntersectionByNormalizedPoint(s),this.highlightControl.cancelHightlight(),r&&this.highlightControl.hightlight(r,tt.panOffsetX,tt.panOffsetY)}}},t.prototype.onMouseUp=function(e){this.bIsMouseDown=!1,this.lastMousePoint.x===e.clientX&&this.lastMousePoint.y===e.clientY&&this.locateByClientPoint(e.clientX+et.offsetXForZoomAndPan,e.clientY+et.offsetYForZoomAndPan)},t.prototype.setIsAllowNear=function(e){this.bIsAllowNear=e},t.prototype.getIntersectionByNormalizedPoint=function(e){for(var t=null,i=this.vfData.getIntersections(),n=0,o=i.length;n<o;n++){var s=i[n].intersectionPoint;if(s){var r=new THREE.Vector2(e.x,e.y),a=this.vfData.getSize();if(this.algorithm.normalizedPointToScreen(r,{width:a[0]/2,height:a[1]/2}),s.distanceToSquared(r)<9){t=i[n];break}}}return t},t.prototype.locateByClientPoint=function(e,t){var i=new THREE.Vector2(e,t),n=new THREE.Vector3,o=this.vfViewer.getMapContainer(),s=this.vfData.getSize(),r=this.algorithm.normalizePoint(o,s,i);if(null!=r){var a=this.vfData.getAxisGridBox2D();this.algorithm.normalizedPointToWorld(r,a);var l=this.algorithm.normalizePoint(o,s,i);this.algorithm.normalizedPointToScreen(l,{width:s[0]/2,height:s[1]/2});var h=this.algorithm.getIntersectionToMinDistance(this.vfData.getIntersections(),l);if(h&&h.intersectionPoint){var d=new THREE.Vector2(h.intersectionPoint.x,h.intersectionPoint.y);if(l.sub(d).lengthSq()<9){var c=d.clone(),u={width:s[0]/2,height:s[1]/2};this.algorithm.screenToNormalizedPoint(c,u),this.algorithm.normalizedPointToWorld(c,a),n.set(c.x,c.y,this.cameraProjectedPosZ)}else n.set(r.x,r.y,this.cameraProjectedPosZ)}else n.set(r.x,r.y,this.cameraProjectedPosZ);var g=n.clone(),p=this.vfData.getElevationById();return"string"==typeof p&&(p=parseFloat(p)),g.z+=p,"default"==this.mapClickMode?(this.eventManager.dispatchEvent({type:Ze.PICK_MOUSE_UP,data:g}),this.algorithm.transformWorldPoint(this.vfViewer.getViewer(),g),this.algorithm.flyToPointWithParallelEye(this.vfViewer.getViewer(),g)):"static"==this.mapClickMode&&this.eventManager.dispatchEvent({type:Ze.PICK_MOUSE_UP,data:g}),!0}console.warn("Click point out of boundary.")},t.prototype.setClickMode=function(e){this.mapClickMode=e},t}(Ke),ut=function(){function e(e){this.vfViewer=e,this.vfData=e.getData(),this.svgRect=null,this.rectForMinimapId="RectForMinimap",this.bEditMode=!1,this.bPanMode=!1,this.bMouseDown=!1,this.rectangle=[],this.currentGripId=-1,this.lastHighlightGripId=-1,this.bFirstMouseClick=!0,this.lastMousePoint=new THREE.Vector2,this.lastMousePointToRectMin=new THREE.Vector2,this.lastMousePointToRectMax=new THREE.Vector2,this.pointOnBorder=[],this.eventManager=e.getEventManager(),this.panOffset=[0,0],this.zoomFactor=1;var t=this;this.eventManager.addEventListener(Ze.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})),this.eventManager.addEventListener(Ze.PAN_MOUSE_MOVE,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)}))}return e.prototype.getMouseClickState=function(){return this.bFirstMouseClick},e.prototype.setMouseClickState=function(e){this.bFirstMouseClick=!!e},e.prototype.getCurrentGripId=function(){return this.currentGripId},e.prototype.setCurrentGripId=function(e){this.currentGripId=e},e.prototype.getRectangleInfo=function(){var e=Math.abs(this.rectangle[2]-this.rectangle[0]),t=Math.abs(this.rectangle[3]-this.rectangle[1]);return{x:this.rectangle[0],y:this.rectangle[1],width:e,height:t}},e.prototype.setLastMousePoint=function(e,t){this.lastMousePoint.x=e,this.lastMousePoint.y=t},e.prototype.equalWithLastPoint=function(e,t){return this.lastMousePoint.x===e&&this.lastMousePoint.y===t},e.prototype.getRectangle=function(){return this.rectangle},e.prototype.addPointToRectangle=function(e,t){"number"==typeof e&&this.rectangle.push(e),"number"==typeof t&&this.rectangle.push(t)},e.prototype.pointsCount=function(){return this.rectangle.length/2},e.prototype.pointValidation=function(e,t){var i=this.vfViewer.getDomContainer().getBoundingClientRect();(e<0||t<0||e>i.width||t>i.height)&&(e=this.pointOnBorder[0],t=this.pointOnBorder[1]),e<this.rectangle[0]?(this.rectangle.push(this.rectangle[0]),this.rectangle[0]=e):this.rectangle.push(e),t<this.rectangle[1]?(this.rectangle.push(this.rectangle[1]),this.rectangle[1]=t):this.rectangle.push(t)},e.prototype.getMouseState=function(){return this.bMouseDown},e.prototype.setMouseState=function(e){this.bMouseDown=!!e},e.prototype.getEditMode=function(){return this.bEditMode},e.prototype.setEditMode=function(e){this.bEditMode=!!e},e.prototype.getPanMode=function(){return this.bPanMode},e.prototype.setPanMode=function(e){this.bPanMode=!!e},e.prototype.createSvgElement=function(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e);return t.setAttribute("pointer-events","inherit"),t},e.prototype.createSvgRect=function(e){this.svgRect||(this.svgRect=this.createSvgElement("rect"),this.svgRect.setAttribute("id",this.rectForMinimapId),this.svgRect.setAttribute("stroke-width",2),this.svgRect.style.position="absolute",this.svgRect.style.fillOpacity="0.4",this.svgRect.style.fill=this.vfData.getGlodonColor(),this.svgRect.style.display="block",this.svgRect.style.stroke=this.vfData.getGlodonColor(),this.svgRect.style.strokeWidth="2");var t=Math.abs(e.x-this.rectangle[0]),i=Math.abs(e.y-this.rectangle[1]),n=this.vfViewer.getAuxContainer(),o=n.clientWidth,s=n.clientHeight,r=["translate(",e.x-o/2,",",e.y-s/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",r),this.svgRect.setAttribute("width",t+""),this.svgRect.setAttribute("height",i+""),n.appendChild(this.svgRect)},e.prototype.updateSvgRect=function(e){this.pointOnBorder=[],this.pointOnBorder.push(e.x,e.y);var t=Math.abs(e.x-this.rectangle[0]),i=Math.abs(e.y-this.rectangle[1]),n={x:this.rectangle[0],y:this.rectangle[1]};if(e.x<n.x||e.y<n.y){e.x<n.x&&(n.x=e.x),e.y<n.y&&(n.y=e.y);var o=this.vfData.getOriginSize(),s=["translate(",n.x-o[0]/2,",",n.y-o[1]/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",s)}this.svgRect.setAttribute("width",t+""),this.svgRect.setAttribute("height",i+"")},e.prototype.resetSvgRect=function(){var e=Math.abs(this.rectangle[0]-this.rectangle[2]),t=Math.abs(this.rectangle[1]-this.rectangle[3]);this.svgRect.setAttribute("width",e+""),this.svgRect.setAttribute("height",t+"");var i=this.vfViewer.getAuxContainer(),n=i.clientWidth,o=i.clientHeight,s=["translate(",this.rectangle[0]-n/2,",",this.rectangle[1]-o/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",s),this.eventManager.dispatchEvent({type:Ze.Minimap_Rect_Changed,rectInfo:this.getRectangleInfo()})},e.prototype.clearRectangle=function(){this.rectangle=[]},e.prototype.adjustRectangle=function(e,t,i){if(t[0]>=i[0])switch(e){case 0:case 1:case 2:t[0]=i[0];break;case 4:case 5:case 6:i[0]=t[0]}if(t[1]>=i[1])switch(e){case 2:case 3:case 4:i[1]=t[1];break;case 6:case 7:case 0:t[1]=i[1]}return t.concat(i)},e.prototype.gripDragging=function(e,t){var i=this.rectangle,n=t.x-e.x,o=t.y-e.y,s=[i[0],i[1]],r=[i[2],i[3]];switch(this.currentGripId){case 0:s[0]+=n,s[1]+=o;break;case 1:s[0]+=n;break;case 2:s[0]+=n,r[1]+=o;break;case 3:r[1]+=o;break;case 4:r[0]+=n,r[1]+=o;break;case 5:r[0]+=n;break;case 6:s[1]+=o,r[0]+=n;break;case 7:s[1]+=o;break;default:console.log("default grip id."+this.currentGripId)}var a=this.vfData.getOriginSize();r[0]=r[0]>a[0]?a[0]:r[0],r[1]=r[1]>a[1]?a[1]:r[1],this.rectangle=this.adjustRectangle(this.currentGripId,s,r)},e.prototype.hightlightGrip=function(e){var t={x:e.offsetX,y:e.offsetY},i=this.hitGrips(t);i!=this.lastHighlightGripId&&(this.currentGripId<0&&this.lastHighlightGripId>=0&&(document.getElementById(this.rectForMinimapId+"-"+this.lastHighlightGripId).style.stroke=this.vfData.getGlodonColor()));(this.currentGripId>=0||i>=0)&&(this.currentGripId>=0&&(i=this.currentGripId),document.getElementById(this.rectForMinimapId+"-"+i).style.stroke="#f5a623",this.currentGripId<0&&(this.lastHighlightGripId=i))},e.prototype.drawGrips=function(){for(var e=this.getGrips(),t=0;t<e.length;t+=2){if(!((t/2-1)%2)){var i=this.createSegmentGrip(t/2,this.vfData.getGlodonColor());this.currentGripId==t/2&&(i=this.createSegmentGrip(t/2,"#FF9D0B")),this.vfViewer.getAuxContainer().appendChild(i)}}for(t=0;t<e.length;t+=2){if(!!((t/2-1)%2)){i=this.createGrip(t/2,this.vfData.getGlodonColor());this.currentGripId==t/2&&(i=this.createGrip(t/2,"#FF9D0B")),this.vfViewer.getAuxContainer().appendChild(i)}}},e.prototype.createSegmentGrip=function(e,t){var i=this.getGrips(),n=this.rectForMinimapId+"-"+e,o=document.getElementById(n);o&&o.parentNode.removeChild(o);var s=this.createSvgElement("line"),r=this.vfViewer.getAuxContainer().clientWidth,a=this.vfViewer.getAuxContainer().clientHeight,l=(e-1)%(i.length/2),h=(e+1)%(i.length/2),d=String(i[2*l]-r/2),c=String(i[2*l+1]-a/2),u=String(i[2*h]-r/2),g=String(i[2*h+1]-a/2);return s.setAttribute("id",n),s.setAttribute("x1",d),s.setAttribute("y1",c),s.setAttribute("x2",u),s.setAttribute("y2",g),s.setAttribute("style","fill: none; stroke: "+(t||"#4784cb")+"; stroke-width: 2; fill: #ffffff; display: block; position: absolute"),s},e.prototype.createGrip=function(e,t){var i=this.getGrips(),n=this.rectForMinimapId+"-"+e,o=document.getElementById(n);o&&o.parentNode.removeChild(o);var s=this.createSvgElement("circle"),r=this.vfViewer.getAuxContainer().clientWidth,a=this.vfViewer.getAuxContainer().clientHeight,l=["translate(",i[2*e]-r/2,",",i[2*e+1]-a/2,") ","rotate(",0,") "].join("");return s.setAttribute("id",n),s.setAttribute("transform",l),s.setAttribute("r","3"),s.setAttribute("style","fill: none; stroke: "+(t||"#4784cb")+"; stroke-width: 1; fill: #ffffff; display: block; position: absolute"),s},e.prototype.removeGrips=function(){for(var e=0;e<8;e++){var t=document.getElementById(this.rectForMinimapId+"-"+e);t&&t.parentNode.removeChild(t)}},e.prototype.removeSvgRect=function(){var e=document.getElementById(this.rectForMinimapId);e&&e.parentNode.removeChild(e)},e.prototype.destroyAll=function(){this.removeGrips(),this.removeSvgRect(),this.clearRectangle(),this.eventManager.dispatchEvent({type:Ze.Minimap_Rect_Destroyed})},e.prototype.getGrips=function(){var e={x:this.rectangle[0],y:this.rectangle[1]},t={x:this.rectangle[2],y:this.rectangle[3]},i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},n=[];return n.push(e.x,e.y),n.push(e.x,i.y),n.push(e.x,t.y),n.push(i.x,t.y),n.push(t.x,t.y),n.push(t.x,i.y),n.push(t.x,e.y),n.push(i.x,e.y),n},e.prototype.hitGrips=function(e){for(var t=this.getGrips(),i=0;i<t.length;i+=2){var n=!1;if(!((i/2-1)%2)){var o=(i/2-1)%(t.length/2),s=(i/2+1)%(t.length/2),r=t[2*o],a=t[2*o+1],l=t[2*s],h=t[2*s+1];n=this.isPointInSegment(e.x,e.y,r,a,l,h,3)}else{var d=[t[i],t[i+1]];n=this.isPointInCircle(e,d,6)}if(n)return i/2}return-1},e.prototype.isPointInCircle=function(e,t,i){var n=e.x-t[0],o=e.y-t[1];return Math.sqrt(n*n+o*o)<=i},e.prototype.isPointInSegment=function(e,t,i,n,o,s,r){r=r||0;var a=(o-i)*(e-i)+(s-n)*(t-n);if(a<=0)return Math.sqrt((e-i)*(e-i)+(t-n)*(t-n))<=r;var l=(o-i)*(o-i)+(s-n)*(s-n);if(a>=l)return Math.sqrt((e-o)*(e-o)+(t-s)*(t-s))<=r;var h=a/l,d=i+(o-i)*h,c=n+(s-n)*h;return Math.sqrt((e-d)*(e-d)+(c-t)*(c-t))<=r},e.prototype.isPointInRectangle=function(e,t){if(this.pointsCount()<2)return!1;var i=this.rectangle,n=i[0]<i[2]?[i[0],i[2]]:[i[2],i[0]],o=n[0],s=n[1],r=(i[1],i[3],[i[1],i[3]]);return o<e&&e<s&&r[0]<t&&t<r[1]},e.prototype.panRectangle=function(e,t){var i=this.rectangle,n=this.vfViewer.getDomContainer().getBoundingClientRect();this.lastMousePointToRectMin.x+e<0?e=-this.lastMousePointToRectMin.x:this.lastMousePointToRectMax.x+e>n.width&&(e=n.width-this.lastMousePointToRectMax.x),this.lastMousePointToRectMin.y+t<0?t=-this.lastMousePointToRectMin.y:this.lastMousePointToRectMax.y+t>n.height&&(t=n.height-this.lastMousePointToRectMax.y),i[0]=this.lastMousePointToRectMin.x+e,i[1]=this.lastMousePointToRectMin.y+t,i[2]=this.lastMousePointToRectMax.x+e,i[3]=this.lastMousePointToRectMax.y+t,this.resetSvgRect(),this.drawGrips()},e.prototype.updateLastMousePointToRect=function(){this.lastMousePointToRectMin.x=this.rectangle[0]-this.lastMousePoint.x,this.lastMousePointToRectMin.y=this.rectangle[1]-this.lastMousePoint.y,this.lastMousePointToRectMax.x=this.rectangle[2]-this.lastMousePoint.x,this.lastMousePointToRectMax.y=this.rectangle[3]-this.lastMousePoint.y},e.prototype.zoomAndPan=function(e,t,i){if(this.pointsCount()<2)return this.panOffset=[e,t],void(this.zoomFactor=i);for(var n=this.vfViewer.getDomContainer().getBoundingClientRect(),o=n.width,s=n.height,r=new THREE.Vector2(.5*o,.5*s),a=0;a<=this.rectangle.length/2;a+=2){var l=new THREE.Vector2(this.rectangle[a]-this.panOffset[0],this.rectangle[a+1]-this.panOffset[1]).clone().sub(r);l.divideScalar(this.zoomFactor),this.rectangle[a]=l.x+r.x,this.rectangle[a+1]=l.y+r.y;var h=new THREE.Vector2(this.rectangle[a],this.rectangle[a+1]).clone().sub(r);h.multiplyScalar(i),this.rectangle[a]=r.x+h.x+e,this.rectangle[a+1]=r.y+h.y+t}this.panOffset=[e,t],this.zoomFactor=i,this.resetSvgRect(),this.drawGrips()},e}(),gt=function(e){function t(t,i){var n=e.call(this)||this;return n.name=Ne.RECTPICK_Editor,n.eventManager=i,n.viewerFloorData=t.getData(),n.naviAction=new ut(t),n.vfViewer=t,n.algorithm=new je,n}return Ue(t,e),t.prototype.onMouseDown=function(e){this.naviAction.setMouseState(!0);var t=this.adjustEvent(e);if(this.naviAction.setLastMousePoint(t.clientX,t.clientY),0==this.naviAction.pointsCount()){var i={x:t.offsetX,y:t.offsetY};this.naviAction.addPointToRectangle(i.x,i.y),this.naviAction.createSvgRect(i)}if(2==this.naviAction.pointsCount()){var n={x:e.offsetX,y:e.offsetY},o=this.naviAction.hitGrips(n),s=this.naviAction.isPointInRectangle(n.x,n.y);o>=0?this.naviAction.setEditMode(!0):s&&(this.naviAction.updateLastMousePointToRect(),this.naviAction.setPanMode(!0))}this.eventManager.dispatchEvent({type:Ze.RECTPICK_MOUSE_DOWN})},t.prototype.onMouseMove=function(e){if(2==this.naviAction.pointsCount()&&this.naviAction.hightlightGrip(e),this.naviAction.getMouseState()){var t=this.vfViewer.getDomContainer().getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;if(this.naviAction.pointsCount()<2&&this.naviAction.updateSvgRect({x:i,y:n}),this.naviAction.getEditMode()){var o={x:i,y:n},s=this.naviAction.hitGrips(o);if(this.naviAction.getMouseClickState())return this.firstPos=o,this.naviAction.setMouseClickState(!1),void(s>=0&&this.naviAction.setCurrentGripId(s));var r=o;this.naviAction.getCurrentGripId()>=0&&(this.naviAction.gripDragging(this.firstPos,r),this.naviAction.resetSvgRect(),this.naviAction.removeGrips(),this.naviAction.drawGrips()),this.firstPos=r}this.naviAction.getPanMode()&&this.naviAction.panRectangle(e.clientX,e.clientY)}},t.prototype.onMouseUp=function(e){if(this.naviAction.setMouseState(!1),this.naviAction.setMouseClickState(!0),this.naviAction.setCurrentGripId(-1),this.naviAction.setPanMode(!1),this.naviAction.equalWithLastPoint(e.clientX,e.clientY))1==this.naviAction.pointsCount()&&this.naviAction.clearRectangle();else{if(1==this.naviAction.pointsCount()){var t=this.adjustEvent(e),i=this.vfViewer.getDomContainer().getBoundingClientRect(),n=t.clientX-i.left,o=t.clientY-i.top;this.naviAction.pointValidation(n,o),this.naviAction.resetSvgRect(),this.naviAction.drawGrips()}this.naviAction.setEditMode(!1)}},t.prototype.clear=function(){this.naviAction.destroyAll()},t.prototype.getBoundingBoxIsolate=function(){var e=this.naviAction.getRectangle(),t={x:e[0]+et.offsetXForZoomAndPan,y:e[1]+et.offsetYForZoomAndPan},i={x:e[2]+et.offsetXForZoomAndPan,y:e[3]+et.offsetYForZoomAndPan},n=this.algorithm.getCuttingBoxOnCanvas(t,i,this.viewerFloorData.getSize(),this.viewerFloorData.getAxisGridBox2D()),o=this.viewerFloorData.getFloorPlaneBox();if(n.min.z=o.min.z,n.max.z=o.max.z,this.vfViewer.getViewer().miniMapTransform){var s=new THREE.Vector3(n.max.x,n.max.y,n.max.z);s.applyMatrix4((new THREE.Matrix4).fromArray(this.vfViewer.getViewer().miniMapTransform));var r=new THREE.Vector3(n.min.x,n.min.y,n.min.z);r.applyMatrix4((new THREE.Matrix4).fromArray(this.vfViewer.getViewer().miniMapTransform)),n.max=s,n.min=r}return n},t.prototype.getIntersectionByNormalizedPoint=function(e,t){var i=this.vfViewer.getData().getIntersections(),n=new THREE.Vector2(e.x,e.y);return this.algorithm.normalizedPointToScreen(n,{width:t[0]/2,height:t[1]/2}),je.getIntersectionByPoint(i,n)},t.prototype.adjustEvent=function(e){var t={offsetX:e.offsetX,offsetY:e.offsetY,clientX:e.clientX,clientY:e.clientY},i=new THREE.Vector2(t.clientX,t.clientY);i.x+=et.offsetXForZoomAndPan,i.y+=et.offsetYForZoomAndPan;var n=this.vfViewer.getMapContainer(),o=this.vfViewer.getData().getSize(),s=this.algorithm.normalizePoint(n,o,i),r=this.getIntersectionByNormalizedPoint(s,o);if(r){var a=this.vfViewer.getDomContainer().getBoundingClientRect();t.clientX=r.intersectionPoint.x-et.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+a.left,t.clientY=r.intersectionPoint.y-et.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+a.top}return t},t}(Ke),pt=function(){function e(e,t,i){this.eventManager=new Je,this.mapContainer=e,this.viewerFloorData=t,this.vfViewer=i,this.vfViewer.setEventManager(this.eventManager),this.activeEditors=[],this.bIsEnablePickHover=!1,this.initialize()}return e.prototype.initialize=function(){this.onContextmenuBinded=this.onContextmenu.bind(this),this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this),this.onMouseWheelBinded=this.onMouseWheel.bind(this),this.addDomEventListeners(),this.enableEditor(Ne.PICK_Editor),this.enableEditor(Ne.PAN_Editor),this.enableEditor(Ne.Zoom_Editor)},e.prototype.addDomEventListeners=function(){var e=this.mapContainer;e.addEventListener("contextmenu",this.onContextmenuBinded,!1),e.addEventListener("mousemove",this.onMouseMoveBinded,!1),e.addEventListener("mousedown",this.onMouseDownBinded,!1),e.addEventListener("mousewheel",this.onMouseWheelBinded,!1),document.addEventListener("mouseup",this.onMouseUpBinded,!1)},e.prototype.removeDomEventListeners=function(){var e=this.mapContainer;e.removeEventListener("contextmenu",this.onContextmenuBinded,!1),e.removeEventListener("mousemove",this.onMouseMoveBinded,!1),e.removeEventListener("mousedown",this.onMouseDownBinded,!1),document.removeEventListener("mouseup",this.onMouseUpBinded,!1)},e.prototype.onMouseDown=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Ne.PICK_Editor&&e.button!=qe.Left||(n.getName()==Ne.RECTPICK_Editor&&e.button!=qe.Left||n.getName()==Ne.PAN_Editor&&e.button==qe.Left||n.onMouseDown(e))}},e.prototype.onMouseMove=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Ne.PICK_Editor&&0==this.bIsEnablePickHover||n.onMouseMove(e)}},e.prototype.onMouseUp=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Ne.PICK_Editor&&e.button!=qe.Left||(n.getName()==Ne.RECTPICK_Editor&&e.button!=qe.Left||n.getName()==Ne.PAN_Editor&&e.button==qe.Left||n.onMouseUp(e))}},e.prototype.onMouseWheel=function(e){var t=this.find(Ne.Zoom_Editor);t&&t.onMouseWheel(e)},e.prototype.onContextmenu=function(e){e.preventDefault()},e.prototype.addEventListener=function(e,t){this.eventManager.addEventListener(e,t)},e.prototype.clearRectPick=function(){var e=this.find(Ne.RECTPICK_Editor);e instanceof gt&&e.clear()},e.prototype.clearZoomAndPan=function(){tt.clear(),et.clear(),this.viewerFloorData.setZoomFactor(1);var e=this.find(Ne.Zoom_Editor);e instanceof et&&e.setZoonIndex(0)},e.prototype.getBoundingBoxIsolate=function(){var e=this.find(Ne.RECTPICK_Editor);if(e instanceof gt)return e.getBoundingBoxIsolate()},e.prototype.setMapClickMode=function(e){var t=this.find(Ne.PICK_Editor);t instanceof ct&&t.setClickMode(e)},e.prototype.find=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++)if(t[i].getName()===e)return t[i]},e.prototype.enableEditor=function(e){if(!this.find(e)){var t=this.activeEditors;switch(e){case Ne.PICK_Editor:t.push(new ct(this.vfViewer,this.eventManager));break;case Ne.RECTPICK_Editor:t.push(new gt(this.vfViewer,this.eventManager));break;case Ne.PAN_Editor:t.push(new tt(this.vfViewer,this.eventManager));break;case Ne.Zoom_Editor:t.push(new et(this.vfViewer,this.eventManager))}}},e.prototype.getEventManager=function(){return this.eventManager},e.prototype.disableEditor=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++)t[i].getName()===e&&t.splice(i,1)},e.prototype.enablePickHover=function(e){this.bIsEnablePickHover=e},e.prototype.setZoomMode=function(e){var t=this.find(Ne.Zoom_Editor);t instanceof et&&t.enableMode(e)},e.prototype.setZoomFactors=function(e){var t=this.find(Ne.Zoom_Editor);t instanceof et&&t.setZoomFactors(e)},e}(),mt=function(){function e(e,t){this.viewer=e,this.vfData=new lt,this.vfView=new ht(e,t,this.vfData),this.bIsEnableFloorPlaneChangedEvent=!0;var i=this.getMapContainer();this.vfEditor=new pt(i,this.vfData,this.vfView),THREE.vf=this}return e.prototype.setAxisGridData=function(e){this.vfData.setAxisGrids(e)},e.prototype.setPlanes=function(e){this.vfData.setPlanes(e)},e.prototype.setFloorPlaneId=function(e,t){this.vfData.setFloorPlaneId(e,t);var i=this.vfData.getProperZoomFactors();this.vfEditor.setZoomFactors(i),tt.clear(),this.bIsEnableFloorPlaneChangedEvent&&this.vfEditor.getEventManager().dispatchEvent({type:Ze.Floor_Plane_Changed,elevation:t&&this.viewer.getModelManager().getModel(t)?this.viewer.globalUnitUtil.revertTranslate(new THREE.Vector3(0,0,this.viewer.globalUnitUtil.translate(this.vfData.getElevationById())).applyMatrix4(this.viewer.getModelManager().getModel(t).transformMatrix.clone()).z):this.vfData.getElevationById()}),this.vfEditor.getEventManager().dispatchEvent({type:Ze.Floor_Plane_Changed_For_Panel,name:this.getFloorPlaneName()})},e.prototype.getEventManager=function(){return this.vfEditor.getEventManager()},e.prototype.enableFloorPlaneChangedEvent=function(e){this.bIsEnableFloorPlaneChangedEvent=e},e.prototype.setSize=function(e,t){this.vfData.setSize(e,t)},e.prototype.setFlip=function(e){this.vfData.setFlip(e)},e.prototype.resize=function(e,t,i){this.vfEditor.clearZoomAndPan(),this.vfData.setIsShowAxisGrid(i),this.vfData.setSize(e,t),this.vfView.setSize(e,t),i?(this.vfEditor.setZoomMode(Qe.Max),this.vfEditor.enableEditor(Ne.RECTPICK_Editor),this.vfEditor.enablePickHover(!0)):(this.clearRectPick(),this.vfEditor.setZoomMode(Qe.Min),this.vfEditor.disableEditor(Ne.RECTPICK_Editor),this.vfEditor.enablePickHover(!1)),this.vfData.getTipNode().hide()},e.prototype.destroy=function(){this.vfView.destroy(),this.vfData.destroy(),this.clearRectPick()},e.prototype.rebuildData=function(){this.vfData.build()},e.prototype.renderCameraNode=function(e){this.vfView.updateCameraNode(e)},e.prototype.addEventListener=function(e,t){this.vfEditor.addEventListener(e,t)},e.prototype.clearRectPick=function(){this.vfEditor.clearRectPick()},e.prototype.clearZoomAndPan=function(){this.vfEditor.clearZoomAndPan(),this.vfView.destroy(),this.vfData.destroy(),this.vfData.build(),this.vfView.update()},e.prototype.getBoundingBoxIsolate=function(){return this.vfEditor.getBoundingBoxIsolate()},e.prototype.getFloorPlaneName=function(){return this.vfData.getDataFloorPlanes().getName(this.vfData.getFloorPlaneId(),this.vfData.modelId)},e.prototype.getAxisGridBox2D=function(){return this.vfData.getAxisGridBox2D()},e.prototype.setMapClickMode=function(e){this.vfEditor.setMapClickMode(e)},e.prototype.getMapContainer=function(){return this.vfView.getDomContainer()},e.prototype.render=function(){this.vfView.update()},e.prototype.getPanOffset=function(){return{x:tt.panOffsetX,y:tt.panOffsetY}},e.prototype.registerCameraHeightChanged=function(e){this.vfView.registerCameraHeightChanged(e)},e}();!function(){var t="Bimface.Plugins.Section.SectionPlane",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=this,n=t;if(this.defaultFloorPlane="F01",i._opt=n,i.id=t.id,!n.domElement)return console.log("domElement must not be empty."),!1;if(!n.viewer)return console.log("viewer is not defined."),!1;P(this);let o=new e.Web.Lang.EventManager;this.getEventManager=function(){return o},this.EventType={RECTPICK_MOUSE_MOVE:1001,RECTPICK_MOUSE_UP:1002,PICK_MOUSE_UP:2002,Floor_Plane_Changed:3e3,Floor_Plane_Changed_For_Panel:3001,Camera_Height_Changed:5e3,ZOOM_MOUSE_WHEEL:6e3,Minimap_Rect_Changed:8e3,Minimap_Rect_Destroyed:8001},i._floors=[],i._axisGrids={},i._hasFloor=void 0===n.hasFloor||n.hasFloor,i._mapHeader=n.mapHeader,i._mapEvents=e.Bimface.Plugins.Map.MapEvents;var s=n.viewer.getViewer();const r=s.getBoundingBoxWorld(),a=r.max.z-r.min.z,l=n.viewer.getUnit()===e.Bimface.Common.Units.LengthUnits.Meter;i._manHeight=i._hasFloor?l?1.75:1750:Math.min(l?1:1e3,a/20),i._refreshHeight=Math.min(l?3:3e3,a/10),s._manHeight=i._manHeight,i.viewerFloor=new mt(s,n.domElement),i.viewerFloor.registerCameraHeightChanged(y.EVENTS.ON_CAMERA_HEIGHT_CHANGED),i._helper=this,i._useEngineMap=n.viewer._opt.enableRealisticMiniMap,i.renderCB=function(){i._inited&&i.viewerFloor.renderCameraNode(i._opt.viewer)},s.addCallbacks("render",i.renderCB),i.init()};s.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},init:function(){i.send(t,"init");const n=this._opt.viewer;let s=[],r=[],a=[];if(this._hasFloor){const t=()=>{this._axisGrids={Grids:r,Levels:a},this._floors=s,(this._axisGrids.Grids||this._axisGrids.Levels)&&this.viewerFloor.setAxisGridData(this._axisGrids),this.viewerFloor.setPlanes(this._floors);var t=new e.Bimface.UI.Select.SelectConfig;t.className="bf-select bf-select-map";var i=this.getDefaultFloorPlane(),n=this._floors.getObjectByAttribute("name",i);0!=n&&(t.default=n.id),t.options=this._floors,t.element=this._mapHeader,t.prefix=BimfaceLanguage.bf_panel_map_level;var o=this,l=new e.Bimface.UI.Select.Select(t);l.addEventListener("Change",(function(e){o.showFloorById(e.id,e.modelId)})),this.addEventListener(this._mapEvents.FloorPlaneChanged,(function(e){l._currentElement.innerText=BimfaceLanguage.bf_panel_map_level+e})),this.createMap()};let i=0;const o=n.getModels().length;n.getModels().forEach((e=>{e["getMapInfo"+(this._opt.loadAsync?"Async":"")]((n=>{n.floors.map((t=>t.modelId=e.modelId)),s=[...n.floors,...s],r=n.axisGrid.Grids?[...n.axisGrid.Grids,...r]:r,n.axisGrid.Levels&&n.axisGrid.Levels.map((t=>t.modelId=e.modelId)),a=n.axisGrid.Levels?[...n.axisGrid.Levels,...a]:a,i++,i===o&&t()}),(()=>{i++,i===o&&t()}))}))}else{var l=o.create("div","bf-map-header-title");this._mapHeader.appendChild(l),this.addEventListener(this._mapEvents.FloorPlaneChanged,(function(t){void 0===t&&(t=0),n.getUnit()===e.Bimface.Common.Units.LengthUnits.Millimeter&&(t/=1e3),l.innerHTML=BimfaceLanguage.bf_panel_map_height+t+"m"})),this.createMap()}},createMap:function(){i.send(t,"createMap");var n=(h=this).getEventManager(),o=e.Bimface.Plugins.Map.MapEvents,s=h._opt;let r=this.EventType;!h._modelId&&h._floors[0]&&(h._modelId=h._floors[0].modelId);const a=h._opt.viewer.getModel(h._modelId)._getModelTransformation();if(h._opt.viewer.getViewer().miniMapTransform=a,this.viewerFloor.addEventListener(r.PICK_MOUSE_UP,(function(e){!h._modelId&&h._floors[0]&&(h._modelId=h._floors[0].modelId);const t=h._opt.viewer.getModel(h._modelId)._getModelTransformation();h._opt.viewer.getViewer().miniMapTransform=t,h._opt.viewer.globalUnitUtil.translate(e,["x","y","z"],!1),n.fireEvent(o.MouseClicked,e.data,t),window.requestAnimationFrame((()=>h._opt.viewer.fireEvent("MiniMapOperate")))})),this.viewerFloor.setMapClickMode(s.navigationMode.toLocaleLowerCase()),this.viewerFloor.addEventListener(r.Minimap_Rect_Changed,(function(e){n.fireEvent("MinimapRectChanged",e.rectInfo)})),this.viewerFloor.addEventListener(r.Minimap_Rect_Destroyed,(function(e){n.fireEvent("MinimapRectDestroyed",e)})),this.viewerFloor.addEventListener(r.Camera_Height_Changed,(function(e){h.viewerFloor.enableFloorPlaneChangedEvent(!1),h.showFloorById(e.id),h.viewerFloor.enableFloorPlaneChangedEvent(!0)})),this.viewerFloor.addEventListener(r.Floor_Plane_Changed_For_Panel,(function(e){n.fireEvent("FloorPlaneChanged",e.name)})),this.viewerFloor.addEventListener(r.ZOOM_MOUSE_WHEEL,(function(e){n.fireEvent(o.Zoom,e.data)})),this.viewerFloor.addEventListener(r.Floor_Plane_Changed,(function(e){if(null!=e.elevation){"string"==typeof e.elevation&&(e.elevation=parseFloat(e.elevation));var t=s.viewer.getViewer(),i=t.camera,n=e.elevation;window.requestAnimationFrame((()=>{var e=s.viewer.sceneToWorld(i.position.clone()),o=new THREE.Vector3(e.x,e.y,n+h._manHeight);const r=t.getBoundingBoxWorld();o.z=Math.min(o.z,s.viewer.globalUnitUtil.revertTranslate(r.max.z));var a=s.viewer.worldToScene(o);t.cameraControl.flyToPointWithParallelEye(new THREE.Vector3(a.x,a.y,a.z)),window.requestAnimationFrame((()=>h._opt.viewer.fireEvent("MiniMapOperate")))}))}})),h.viewerFloor.enableFloorPlaneChangedEvent(!1),h._hasFloor)if(this._useEngineMap){let t=this;t.viewerFloor.setFlip(!0);let i=s.viewer.getViewer();t.mapManager=new e.Bimface.Plugins.Map.MapManager({viewer:s.viewer});const n=this._axisGrids,o=this._floors;let r={};r.maxPixel=t._opt.maxPixel,r.height=[],r.boundingbox=[],r.useBorder=!1;const a=n.Levels;for(let e=0;e<o.length;e++){const n=a.find((({id:t})=>t==o[e].id));if(n){const a=t.viewerFloor.vfData.getDataFloorPlanes().getFloorPlaneBox(o[e].id);let l=s.viewer.globalUnitUtil.translateBBox(new THREE.Box3(new THREE.Vector3(a.Min.X,a.Min.Y,a.Min.Z),new THREE.Vector3(a.Max.X,a.Max.Y,a.Max.Z)));l.applyMatrix4((new THREE.Matrix4).fromArray(t._opt.viewer.getModel(o[e].modelId)._getModelTransformation())),l.applyMatrix4(i.getScene().getMatrixGlobal()),r.boundingbox.push(l);let h=new THREE.Vector3(0,0,n.elevation);h.applyMatrix4((new THREE.Matrix4).fromArray(t._opt.viewer.getModel(o[e].modelId)._getModelTransformation())),r.height.push(s.viewer.globalUnitUtil.translate(h.z))}}let l=e=>{for(let t=0;t<e.length;t++)o[t].path=e[t];if(o.length>0){var i=o.getObjectByAttribute("name",this.defaultFloorPlane);0==i?this.showFloorById(o[0].id):this.showFloorById(i.id)}t.viewerFloor.enableFloorPlaneChangedEvent(!0),t._inited=!0};r.successCallback=l,t.mapManager.removeCreateMapEvent(),t.mapManager.createMapByHeight(r)}else{const e=this._floors;if(e.length>0){var l=e.getObjectByAttribute("name",this.defaultFloorPlane);0==l?this.showFloorById(e[0].id):this.showFloorById(l.id)}h.viewerFloor.enableFloorPlaneChangedEvent(!0),h._inited=!0}else{var h;(h=this).viewerFloor.setFlip(!0);const t=s.viewer,i=t.globalUnitUtil.revertBBox(t.getViewer().getBoundingBoxWorld()),n={Min:i.min,Max:i.max};h.mapManager=new e.Bimface.Plugins.Map.MapManager({viewer:t});let o=t.getCamera().getStatus().position.z;o=Math.floor(Math.min(Math.max(o,i.min.z),i.max.z));let r=e=>{let o=t.getCamera().getStatus().position.z;o=Math.floor(Math.min(Math.max(o,i.min.z),i.max.z));let s=[];s.push({id:o,name:"top",elevation:o}),s.push({id:i.min.z,name:o.toString(),elevation:i.min.z});let r={Grids:[],Levels:s};h.viewerFloor.setAxisGridData(r);let a=[];a.push({id:o,name:o,path:e,BoundingBox:n}),h._floors=a,h.viewerFloor.setPlanes(a),h.showFloorById(o),h._inited=!0},a={};a.maxPixel=h._opt.maxPixel,a.spacing=h._refreshHeight,a.successCallback=r,h.mapManager.removeCreateMapEvent(),h.mapManager.createMapByCamera(a),t.getViewer().getModelManager().dispatchEvent({type:y.EVENTS.ON_CAMERA_CHANGED_AND_RENDERED})}},setDefaultFloorPlane:function(e){for(var t=this._floors,i=0;i<t.length;i++)if(t[i].name==e){this.viewerFloor;this.getEventManager().fireEvent("FloorPlaneChanged",e);var n=t.getObjectByAttribute("name",e);return helpershowFloorById(n.id),!0}return!1},getFloorList:function(){return this._floors},getDefaultFloorPlane:function(){return this.defaultFloorPlane},getBoundingBox:function(){return this.viewerFloor.getBoundingBoxIsolate()},showFloorById:function(e,t){this.viewerFloor.setFloorPlaneId(e,t),this.viewerFloor.destroy(),this.viewerFloor.rebuildData(),this.viewerFloor.render(),t&&(this._modelId=t)},resize:function(e,t,i){var n=this._opt.domElement;n.style.width=e+"px",n.style.height=t+"px",this.viewerFloor.resize(e,t,i),this.getEventManager().fireEvent("Resize",{width:e,height:t})},setPlaneChangedCallback:function(e){this.addEventListener("FloorPlaneChanged",(function(t){e&&e(t)}))},setMinimapResizeCallback:function(e){this.addEventListener("Resize",(function(t){e&&e(t)}))},setNavigationMode:function(e){var t=this._opt,i=this.viewerFloor;t.navigationMode=e,i.setMapClickMode(t.navigationMode.toLocaleLowerCase())},clear:function(){this.viewerFloor.clearRectPick()},clearZoomAndPan:function(){this.viewerFloor.clearZoomAndPan();let e=this.EventType;this.viewerFloor.getEventManager().dispatchEvent({type:e.ZOOM_MOUSE_WHEEL,data:{offsetX:0,offsetY:0,zoomFactor:1}})},getMapContainer:function(){return this.viewerFloor.getMapContainer()},getFloorPlaneName:function(){return this.viewerFloor.getFloorPlaneName()},getAxisGridBox2D:function(){return this.viewerFloor.getAxisGridBox2D()},exit:function(){var e=this;e._opt.viewer.getViewer().removeCallbacks("render",e.renderCB),e.clear(),e.mapManager&&e.mapManager.destroy()}},n.Map=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap").NavigationMapConfig=function(){return{viewer:null,domElement:null,successCallback:null,failureCallback:null,type:"Relevance",mapAnchors:null,modelAnchors:null,url:null,PDFId:void 0,drawingId:void 0,height:0}},function(){let t=Object.freeze({MouseClicked:"MouseClicked",MapChanged:"MapChanged"});var i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap");i.NavigationMapEvent=t,i.MapViewerEvent=t}();var ft=function(e,t){return ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},ft(e,t)};function wt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}ft(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var yt,vt=function(){function e(){this.xmlns="http://www.w3.org/2000/svg",this.material=null,this.svgNode=null,this.children=[],this.glodonColor="#11DAB7",this.position=new THREE.Vector2}return e.prototype.add=function(e){this.children.push(e)},e.prototype.getSvgNode=function(){return this.svgNode},e.prototype.abtainRenderables=function(e){e.appendChild(this.svgNode)},e.prototype.isMatch=function(e){return this.name==e},e.prototype.highlight=function(){this.svgNode.setAttribute("style","stroke:"+this.glodonColor)},e.prototype.cancelHighlight=function(){this.svgNode.setAttribute("style","stroke:"+this.material.color.getStyle())},e.prototype.locate=function(e,t){this.position.set(e,t),this.move(0,0)},e.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t;this.svgNode.setAttribute("transform","translate("+i+","+n+")")},e}(),bt=function(){function e(){this._boxSize=new THREE.Vector2,this._boxCenter=new THREE.Vector2,this._intersect=new THREE.Vector3}return e.prototype.cross=function(e,t,i,n){return(t.x-e.x)*(n.y-i.y)-(t.y-e.y)*(n.x-i.x)},e.prototype.getArea=function(e,t,i){return this.cross(e,t,e,i)},e.prototype.getAbsArea=function(e,t,i){return Math.abs(this.getArea(e,t,i))},e.prototype.getInterPoint=function(e,t,i,n){var o=this.getAbsArea(e,t,i),s=this.getAbsArea(e,t,n);return new THREE.Vector2((n.x*o+i.x*s)/(o+s),(n.y*o+i.y*s)/(o+s))},e.prototype.isAngleGreaterThanPi=function(e,t,i){var n=new THREE.Vector3;return n.crossVectors(e,t),!(n.dot(i)>=0)},e.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},e.prototype.screenToNormalizedPoint=function(e,t){e.x=e.x/t.width,e.y=-e.y/t.height},e.prototype.normalizedPointToWorld=function(e,t){t.getSize(this._boxSize),e.x=.5*(e.x+1)*this._boxSize.x+t.min.x,e.y=.5*(e.y+1)*this._boxSize.y+t.min.y},e.prototype.worldToNormalizedPoint=function(e,t){t.getSize(this._boxSize),e.x=(e.x-t.min.x)/this._boxSize.x*2-1,e.y=(e.y-t.min.y)/this._boxSize.y*2-1},e.prototype.toWorldPoint=function(e,t,i,n){e.x<0&&(e.x=0),e.x>t&&(e.x=t),e.y<0&&(e.y=0),e.y>i&&(e.y=i),e.x=e.x/t*2-1,e.y=-e.y/i*2+1,this.normalizedPointToWorld(e,n)},e.prototype.getCuttingBoxOnCanvas=function(e,t,i,n){var o=new THREE.Box3,s=new THREE.Vector2(e.x,e.y),r=new THREE.Vector2(t.x,t.y);this.toWorldPoint(s,i[0],i[1],n),this.toWorldPoint(r,i[0],i[1],n);var a=[];return a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,s.y)),a.push(new THREE.Vector3(r.x,s.y)),o.setFromPoints(a),{min:{x:o.min.x,y:o.min.y,z:0},max:{x:o.max.x,y:o.max.y,z:0}}},e.prototype.canvasPointToClient=function(e,t){var i=t.mapContainer;if(!i||!t.floorPlaneBox)return null;var n=this.getContainerOffsetToClient(i);if(0===n.width||0===n.height)return null;var o=new THREE.Vector2;return o.x=e.x+n.left,o.y=e.y+n.top,o},e.prototype.getMainSceneMatrix=function(e){return e.getScene().getMatrixGlobal()},e.prototype.transformWorldPoint=function(e,t){var i=this.getMainSceneMatrix(e);e.miniMapTransform&&t.applyMatrix4((new THREE.Matrix4).fromArray(e.miniMapTransform)),t.applyMatrix4(i)},e.prototype.expandBbox=function(e,t){var i=e.getCenter(this._boxCenter);e.getSize(this._boxSize);var n=new THREE.Vector2,o=t,s=this._boxSize.x/this._boxSize.y,r=this._boxSize.x,a=this._boxSize.y;s>o?a=r/o:s<o&&(r=a*o),n.set(r,a),e.setFromCenterAndSize(i,n)},e.prototype.containsPointInMainScene=function(e,t){var i=e.getScene().getBoundingBoxWorld();return!!i&&i.containsPoint(t)},e.prototype.isMouseOverCanvas=function(e,t,i){if(e){var n=this.getContainerOffsetToClient(e),o=new THREE.Vector2;if(o.x=i.x-n.left,o.y=i.y-n.top,0===n.width||0===n.height)return!1;var s={width:t[0],height:t[0]};if(o.x>0&&o.x<s.width&&o.y>0&&o.y<s.height)return!0}return!1},e.prototype.normalizePoint=function(e,t,i){var n=new THREE.Vector2;if(e){var o=this.getContainerOffsetToClient(e),s=new THREE.Vector2;s.x=i.x-o.left,s.y=i.y-o.top;var r={width:t[0],height:t[1]};if(s.x>0&&s.x<r.width&&s.y>0&&s.y<r.height)return n.x=s.x/r.width*2-1,n.y=-s.y/r.height*2+1,new THREE.Vector2(n.x,n.y)}return null},e.getIntersectionByPoint=function(e,t,i){void 0===i&&(i=3);for(var n=null,o=i*i,s=0,r=e.length;s<r;s++){var a=e[s].intersectionPoint;if(a)if(a.distanceToSquared(t)<o){n=e[s];break}}return n},e.prototype.flyToPointWithParallelEye=function(e,t){e.cameraControl.flyToPointWithParallelEye(t)},e.prototype.getIntersectionToMinDistance=function(e,t){if(e.length<1)return null;for(var i=0,n=0,o=0,s=e.length;o<s;o++){var r=e[o];if(r.intersectionPoint){var a=new THREE.Vector2(r.intersectionPoint.x,r.intersectionPoint.y).distanceToSquared(t);0==i?i=a:i>a&&(i=a,n=o)}}return e[n]},e.prototype.getAxisGridInfoByNormalizedPoint=function(e,t){var i=t.clone(),n=e.naviData.getAxisGridBox2D();this.normalizedPointToWorld(i,n);var o=t.clone(),s={width:e.svgHalfWidth,height:e.svgHalfHeight};this.normalizedPointToScreen(o,s);var r=this.getIntersectionToMinDistance(e.naviData.getAxisGridIntersectionPoints(),o);if(r&&r.intersectionPoint){var a=new THREE.Vector2(r.intersectionPoint.x,r.intersectionPoint.y);this.screenToNormalizedPoint(a,s),this.normalizedPointToWorld(a,n);var l=Math.round(i.x-a.x),h=Math.round(i.y-a.y);return{position:i,abcName:r.abcName,numeralName:r.numeralName,offsetX:l,offsetY:h}}return{position:new THREE.Vector3,abcName:"",numeralName:"",offsetX:"",offsetY:""}},e.prototype.getAxisGridInfoByPoint=function(e,t){var i=this.getMainSceneMatrix(e.viewer),n=new THREE.Matrix4;n.copy(i).invert();var o=t.clone();o.applyMatrix4(n);var s=o.clone(),r={width:e.svgHalfWidth,height:e.svgHalfHeight},a=e.naviData.getAxisGridBox2D();this.worldToNormalizedPoint(s,a),this.normalizedPointToScreen(s,r);var l=this.getIntersectionToMinDistance(e.naviData.getAxisGridIntersectionPoints(),s);if(l&&l.intersectionPoint){var h=new THREE.Vector2(l.intersectionPoint.x,l.intersectionPoint.y);this.screenToNormalizedPoint(h,r),this.normalizedPointToWorld(h,a);var d=Math.round(o.x-h.x),c=Math.round(o.y-h.y);return{position:o,abcName:l.abcName,numeralName:l.numeralName,offsetX:d,offsetY:c}}return{position:new THREE.Vector3,abcName:"",numeralName:"",offsetX:"",offsetY:""}},e.prototype.calculateEdgePositionCameraOutBounds=function(e,t,i){var n=function(e,t){for(var i=!1,n=0,o=e.length;n<o;n++)if(this.isEqualBetweenPoints(t,e[n],this.epsilon)){i=!0;break}return i},o=i.clone();if(o.min.x-=.5,o.min.y-=.5,o.max.x+=.5,o.max.y+=.5,!o.containsPoint(e)){var s=[],r=new THREE.Vector3(e.x,e.y,0),a=new THREE.Ray(r,t),l=new THREE.Vector3(i.min.x,i.min.y,0),h=new THREE.Vector3(-1,0,0),d=new THREE.Plane;if(d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&s.push(this._intersect),l.set(i.max.x,i.max.y,0),h.set(-1,0,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&s.push(this._intersect),l.set(i.min.x,i.min.y,0),h.set(0,1,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),l.set(i.max.x,i.max.y,0),h.set(0,1,0),d.setFromNormalAndCoplanarPoint(h,l),a.intersectPlane(d,this._intersect),this._intersect&&o.containsPoint(this._intersect)&&(n(this._intersect,s)||s.push(this._intersect)),2!=s.length)return null;var c=s[0],u=s[1].clone().sub(c).normalize();return this.isEqualBetweenPoints(u,t,1e-5)?s[0]:s[1]}return null},e.prototype.getContainerOffsetToClient=function(e){var t,i;if(e!=document){var n=(i=e).getBoundingClientRect?function(e){var t=e.getBoundingClientRect(),i=document.body,n=document.documentElement,o=n.clientTop||i.clientTop,s=n.clientLeft||i.clientLeft,r=t.top-o,a=t.left-s;return{top:Math.round(r),left:Math.round(a)}}(i):function(e){for(var t=0,i=0;e;)t+=e.offsetTop,i+=e.offsetLeft,e=e.offsetParent;var n=document.body,o=document.documentElement;return{top:t-=window.pageYOffset||o.scrollTop||n.scrollTop,left:i-=window.pageXOffset||o.scrollLeft||n.scrollLeft}}(i);t={width:e.offsetWidth,height:e.offsetHeight,left:n.left,top:n.top}}else t={width:window.innerWidth,height:window.innerHeight,left:0,top:0};return t},e.prototype.isEqualBetweenPoints=function(e,t,i){i=i||1e-4;var n=e.x-t.x,o=e.y-t.y;return!(Math.sqrt(n*n+o*o)>i)},e}(),Et=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.start=t,s.end=i,s.material=n,s.name=o,s.build(),s}return wt(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"line");e.setAttribute("x1",this.start.x),e.setAttribute("y1",this.start.y),e.setAttribute("x2",this.end.x),e.setAttribute("y2",this.end.y);var t=this.material;t instanceof THREE.LineBasicMaterial&&e.setAttribute("style","fill: none; stroke: "+t.color.getStyle()+"; stroke-width: "+t.linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.linecap+"; stroke-linejoin: "+t.linejoin),this.svgNode=e},t}(vt),Mt=function(e){function t(t,i,n){var o=e.call(this)||this;return o.arcPoints=t,o.material=i,o.name=n,o.build(),o}return wt(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"polyline");e.setAttribute("points",this.arcPoints.map((function(e){return e.x+","+e.y})).join(" "));var t=this.material;t instanceof THREE.LineBasicMaterial&&e.setAttribute("style","fill: none; stroke: "+t.color.getStyle()+"; stroke-width: "+t.linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.linecap+"; stroke-linejoin: "+t.linejoin),this.svgNode=e},t}(vt),Ct=function(e){function t(t,i){var n=e.call(this)||this;return n.center=t,n.literal=i,n.fontSize=8,n.textColor=new THREE.Color(.6,.6,.6),n.build(),n}return wt(t,e),t.prototype.build=function(){var e=this.center.x,t=this.center.y;if("NaN"!=e.toString()&&"NaN"!=t.toString()){var i=document.createElementNS(this.xmlns,"text");i.setAttribute("style","font-size:"+this.fontSize+"px; fill: none; stroke: "+this.textColor.getStyle()+"; stroke-width: 1"),i.innerHTML=this.literal,i.textContent=this.literal,i.getBoundingClientRect();var n=e-3.5,o=t+2.8;this.svgNode=i,this.locate(n,o)}},t}(vt),xt=function(e){function t(t,i){var n=e.call(this)||this;return n.name=i,n.labelPoints=t,n.build(),n}return wt(t,e),t.prototype.build=function(){var e=this;this.labelPoints.forEach((function(t){e.add(new Ct(t,e.name))}))},t.prototype.abtainRenderables=function(e){for(var t=0;t<this.children.length;t++){this.children[t].abtainRenderables(e)}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(vt),Tt=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.intersections=[],s.lineElements=[],s.horizLineElements=[],s.verticalLineElements=[],s.width=i[0],s.height=i[1],s.bIsShowAxisGrid=n,s.multiplyZoomFactor=o,s.algorithm=new bt,s.materialGrid=new THREE.LineBasicMaterial({color:10066329,linewidth:.5}),s.children=[],s.resourceGrids=t,s.boundingBox=new THREE.Box2,s.realBoundingBox=new THREE.Box2,s.clipBox2D=new THREE.Box2(new THREE.Vector2(-s.width/2,-s.height/2),new THREE.Vector2(s.width/2,s.height/2)),s.axisGridNumberInterval=3,s.scratchVector=new THREE.Vector3,s.boxSize=new THREE.Vector2,s.isValid()&&s.build(),s}return wt(t,e),t.prototype.build=function(){var e=this,t=this.getAxisGridBox(),i={width:this.width/2,height:this.height/2},n=function(n){var o=new THREE.Vector2(n.x,n.y);return e.algorithm.worldToNormalizedPoint(o,t),e.algorithm.normalizedPointToScreen(o,i),o},o=this.materialGrid;this.resourceGrids.forEach((function(t){var i=t.name,s=t.geometry,r=t.label;s.forEach((function(t){if("Line"===t.lineType){var s=t.startPoint,r=t.endPoint,a=n(s),l=n(r),h=l.clone().sub(a).normalize();e.add(new Et(a,l,o,i)),Math.abs(h.x)>=Math.abs(h.y)?e.horizLineElements.push({name:i,v1:a,v2:l,material:o}):e.verticalLineElements.push({name:i,v1:a,v2:l,material:o})}else if("Arc"===t.lineType){var d=t.points.map(n);e.add(new Mt(d,o,i))}}));var a=r.positions.map(n);e.add(new xt(a,i))})),this.lineElements.push(this.horizLineElements),this.lineElements.push(this.verticalLineElements),this.calculateIntersections()},t.prototype.calculateAxisGridBox=function(e,t,i){var n=this;this.boundingBox.makeEmpty(),this.resourceGrids.forEach((function(e){e.geometry.forEach((function(e){if("Line"===e.lineType){var t=e.startPoint,i=e.endPoint,o=new THREE.Vector2(t.x,t.y),s=new THREE.Vector2(i.x,i.y);e.points=[o,s]}else if("Arc"===e.lineType){var r=window.CLOUD.AxisGridManager.getArcGridPoints(e);e.points=r}e.points.forEach((function(e){return n.boundingBox.expandByPoint(e)}))}))})),this.realBoundingBox=this.boundingBox.clone();var o=this.boundingBox.getCenter(this.scratchVector);this.boundingBox.getSize(this.boxSize);var s=new THREE.Vector2,r=e/t,a=this.boxSize.x/this.boxSize.y,l=this.boxSize.x,h=this.boxSize.y,d=4*(i+4)*this.multiplyZoomFactor;a>r?(this.bIsShowAxisGrid&&(l=this.boxSize.x*e/(e-d)),h=l/r):a<r&&(this.bIsShowAxisGrid&&(h=this.boxSize.y*t/(t-d)),l=h*r),s.set(l,h),this.boundingBox.setFromCenterAndSize(o,s)},t.prototype.getAxisGridBox=function(e){return this.isValid()&&this.calculateAxisGridBox(this.width,this.height,10),e?this.realBoundingBox:this.boundingBox},t.prototype.isEmpty=function(){return this.boundingBox.getSize(this.boxSize),0==this.boxSize.length()},t.prototype.isValid=function(){return!!this.resourceGrids},t.prototype.calculateIntersections=function(){for(var e,t,i,n,o,s,r,a,l=this.horizLineElements.length,h=this.verticalLineElements.length,d=0;d<l;d++){n=(e=this.horizLineElements[d]).name,o=e.v1.clone(),s=e.v2.clone();for(var c=0;c<h;c++){i=(t=this.verticalLineElements[c]).name,r=t.v1.clone(),a=t.v2.clone();var u=!1;r.x<=Math.max(o.x,s.x)&&r.x>=Math.min(o.x,s.x)&&o.y<=Math.max(r.y,a.y)&&o.y>=Math.min(r.y,a.y)&&(u=!0);var g=null;u&&(g=this.algorithm.getInterPoint(o,s,r,a)),this.intersections.push({intersectionPoint:g,horizLine:[o.clone(),s.clone()],verticalLine:[r.clone(),a.clone()],abcName:n,numeralName:i})}}},t.prototype.getIntersections=function(){return this.intersections},t.prototype.abtainRenderables=function(e){for(var t=0;t<this.children.length;t++){this.children[t].abtainRenderables(e)}},t.prototype.getGridLineByName=function(e){for(var t=this.children,i=0;i<t.length;i++){var n=t[i];if(n instanceof Et&&n.isMatch(e))return n}},t.prototype.move=function(e,t){this.children.forEach((function(i){i.move(e,t)}))},t}(vt),Pt=function(e){function t(t,i,n){var o=e.call(this)||this;return o.imageUrl=t,o.width=i[0],o.height=i[1],o.offsetX=i[2],o.offsetY=i[3],o.isFlip=n,o.build(),o}return wt(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"image");e.href.baseVal=this.imageUrl,e.setAttribute("herf",this.imageUrl),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("width",this.width+""),e.setAttribute("height",this.height+""),e.setAttribute("x",-.5*this.width+""),e.setAttribute("y",-.5*this.height+""),this.isFlip&&e.setAttribute("transform","scale(-1,1)"),this.svgNode=e,this.locate(this.offsetX,this.offsetY)},t.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t;return this.isFlip?this.svgNode.setAttribute("transform","translate("+i+", "+n+")\n scale("+"-1,1)"):this.svgNode.setAttribute("transform","translate("+i+","+n+")"),{x:i,y:n}},t}(vt);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(yt||(yt={}));var It,St,Bt,_t=function(){function e(){this.bIsMouseDown=!1,this.name=yt.Default}return e.prototype.onMouseDown=function(e){},e.prototype.onMouseMove=function(e){},e.prototype.onMouseUp=function(e){},e.prototype.onMouseWheel=function(e){},e.prototype.getName=function(){return this.name},e}();!function(e){e[e.RECTPICK_MOUSE_DOWN=1e3]="RECTPICK_MOUSE_DOWN",e[e.RECTPICK_MOUSE_MOVE=1001]="RECTPICK_MOUSE_MOVE",e[e.RECTPICK_MOUSE_UP=1002]="RECTPICK_MOUSE_UP",e[e.PICK_MOUSE_DOWN=2e3]="PICK_MOUSE_DOWN",e[e.PICK_MOUSE_MOVE=2001]="PICK_MOUSE_MOVE",e[e.PICK_MOUSE_UP=2002]="PICK_MOUSE_UP",e[e.Floor_Plane_Changed=3e3]="Floor_Plane_Changed",e[e.Floor_Plane_Changed_For_Panel=3001]="Floor_Plane_Changed_For_Panel",e[e.Resize=4e3]="Resize",e[e.Camera_Height_Changed=5e3]="Camera_Height_Changed",e[e.ZOOM_MOUSE_WHEEL=6e3]="ZOOM_MOUSE_WHEEL",e[e.PAN_MOUSE_MOVE=7e3]="PAN_MOUSE_MOVE",e[e.Minimap_Rect_Changed=8e3]="Minimap_Rect_Changed",e[e.Minimap_Rect_Destroyed=8001]="Minimap_Rect_Destroyed"}(It||(It={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(St||(St={})),function(e){e.Min="Min",e.Max="Max"}(Bt||(Bt={}));var Lt,Dt=function(e){function t(t,i){var n=e.call(this)||this;return n.totalZoomFactors=[],n.zoomFactors=[],n.lastZoomFactor=1,n.currentIdx=0,n.name=yt.Zoom_Editor,n.eventManager=i,n.vfData=t.getData(),n.vfViewer=t,n}return wt(t,e),t.prototype.onMouseWheel=function(e){var t=(e.deltaY||-e.wheelDelta||e.detail)<0,i=-1;if(t?this.currentIdx<this.zoomFactors.length-1&&(this.currentIdx++,i=this.zoomFactors[this.currentIdx]):this.currentIdx>0&&(this.currentIdx--,i=this.zoomFactors[this.currentIdx]),!(i<0||this.lastZoomFactor==i)){this.lastZoomFactor=i,1==i&&At.clear();var n=this.vfData.getOriginSize(),o=new THREE.Vector2(e.offsetX-n[0]/2,e.offsetY-n[1]/2),s=this.zoomFactors[this.currentIdx],r=0,a=0;if(t){var l=s/(u=this.zoomFactors[this.currentIdx-1]),h=[],d=this.vfData.getCorner("Virtual","LB");d[0]-=o.x,d[1]-=o.y,h.push(d[0]*l+o.x),h.push(d[1]*l+o.y),this.vfData.setZoomFactor(s);var c=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(u),r=h[0]-c[0],a=h[1]-c[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}At.panOffsetX+=r,At.panOffsetY+=a,At.panOffsetXForCamera+=r,At.panOffsetYForCamera+=a,this.vfData.setZoomFactor(i),this.vfViewer.destroy(),this.vfData.destroy(),this.vfData.build(),this.vfViewer.update(),this.vfData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:It.ZOOM_MOUSE_WHEEL,data:{offsetX:At.panOffsetX,offsetY:At.panOffsetY,zoomFactor:i}})}},t.prototype.boundsChecking=function(e,t,i){var n=e/t,o=this.vfData.getCorner("Virtual","LB"),s=this.vfData.getCorner("Virtual","LT"),r=this.vfData.getCorner("Virtual","RT"),a=this.vfData.getCorner("Virtual","RB"),l=[0,0],h=(o[0]-i.x)*n+i.x,d=(o[1]-i.y)*n+i.y;this.vfData.setZoomFactor(e);var c=this.vfData.getCorner("Virtual","LB");this.vfData.setZoomFactor(t),l[0]=h-c[0],l[1]=d-c[1];var u=0,g=0,p=this.vfData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),d<p[1]&&(l[1]+=p[1]-d,g++),h=(s[0]-i.x)*n+i.x,d=(s[1]-i.y)*n+i.y;var m=this.vfData.getCorner("Origin","LT");h>m[0]&&0==u&&(l[0]+=m[0]-h,u++),d>m[1]&&0==g&&(l[1]+=m[1]-d,g++),h=(r[0]-i.x)*n+i.x,d=(r[1]-i.y)*n+i.y;var f=this.vfData.getCorner("Origin","RT");h<f[0]&&0==u&&(l[0]+=f[0]-h,u++),d>f[1]&&0==g&&(l[1]+=f[1]-d,g++),h=(a[0]-i.x)*n+i.x,d=(a[1]-i.y)*n+i.y;var w=this.vfData.getCorner("Origin","RB");return h<w[0]&&0==u&&(l[0]+=w[0]-h,u++),d<w[1]&&0==g&&(l[1]+=w[1]-d,g++),l},t.prototype.enableMode=function(e){if(e==Bt.Min)this.zoomFactors=this.totalZoomFactors;else if(e==Bt.Max){this.zoomFactors=this.totalZoomFactors.slice(1,this.totalZoomFactors.length);for(var t=1;t<this.zoomFactors.length;t++)this.zoomFactors[t]/=this.zoomFactors[0];this.zoomFactors[0]=1}this.currentIdx=0},t.prototype.setZoomFactors=function(e){this.totalZoomFactors=e,this.zoomFactors=e},t.prototype.setZoonIndex=function(e){this.currentIdx=e},t.prototype.getZoonIndex=function(){return this.currentIdx},t.prototype.updateZoomAndPan=function(){var e=this.vfData.getCorner("Origin","LT"),i=this.vfData.getCorner("Virtual","LT");t.offsetXForZoomAndPan=e[0]-i[0],t.offsetYForZoomAndPan=e[1]-i[1]},t.clear=function(){t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0},t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0,t}(_t),At=function(e){function t(i,n){var o=e.call(this)||this;return o.name=yt.PAN_Editor,o.eventManager=n,o.vfData=i.getData(),o.bIsMouseDown=!1,o.mouseDownPos=new THREE.Vector2,t.panOffsetX=0,t.panOffsetY=0,o}return wt(t,e),t.prototype.onMouseDown=function(e){this.bIsMouseDown=!0,this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)},t.prototype.onMouseMove=function(e){if(0!=this.bIsMouseDown&&1!=this.vfData.getZoomFactor()){var i=e.clientX-this.mouseDownPos.x,n=e.clientY-this.mouseDownPos.y,o=this.boundsChecking(i,n);i=o[0],n=o[1],t.panOffsetX+=i,t.panOffsetY+=n,t.panOffsetXForCamera+=i,t.panOffsetYForCamera+=n,this.vfData.updateMovement(),this.updateZoomAndPan(),this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)}},t.prototype.onMouseUp=function(e){if(0!=this.bIsMouseDown&&1!=this.vfData.getZoomFactor()){var i=e.clientX-this.mouseDownPos.x,n=e.clientY-this.mouseDownPos.y,o=this.boundsChecking(i,n);i=o[0],n=o[1],t.panOffsetX+=i,t.panOffsetY+=n,t.panOffsetXForCamera+=i,t.panOffsetYForCamera+=n,this.vfData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:It.PAN_MOUSE_MOVE,data:{offsetX:t.panOffsetX,offsetY:t.panOffsetY,zoomFactor:this.vfData.getZoomFactor()}}),this.bIsMouseDown=!1}},t.prototype.boundsChecking=function(e,t){var i=this.vfData.getCorner("Origin","LB"),n=this.vfData.getCorner("Virtual","LB"),o=this.vfData.getCorner("Origin","RT"),s=this.vfData.getCorner("Virtual","RT");if(e>0)(r=i[0]-n[0])<=e&&(e=r);else if(e<0){var r;(r=o[0]-s[0])>=e&&(e=r)}if(t<0)(a=i[1]-n[1])>=t&&(t=a);else if(t>0){var a;(a=o[1]-s[1])<=t&&(t=a)}return[e,t]},t.prototype.updateZoomAndPan=function(){var e=this.vfData.getCorner("Origin","LT"),t=this.vfData.getCorner("Virtual","LT");Dt.offsetXForZoomAndPan=e[0]-t[0],Dt.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(_t),Vt=function(e){function t(){var t=e.call(this)||this;return t.cameraCircleNode=null,t.cameraArrowNode=null,t.rotateAngle=0,t.panelSize=[298,198],t.cameraPositionToTarget=2e3,t.build(),t}return wt(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"g");e.setAttribute("fill","none"),e.setAttribute("fill-rule","evenodd"),e.setAttribute("stroke-width","1");var t=document.createElementNS(this.xmlns,"circle");t.setAttribute("r","4.5"),t.setAttribute("stroke","#FFFFFF"),t.setAttribute("fill","#32D3A6"),this.cameraCircleNode=t;var i=document.createElementNS(this.xmlns,"path");i.setAttribute("d","M5.94925387,0 C18.4132389,0 28.6581001,9.50119823 29.8362478,21.6560048 L5.94925387,25 Z"),i.setAttribute("fill","url(#radialGradient-1)"),i.setAttribute("transform","translate(13,-21)rotate(50)"),this.cameraArrowNode=i;var n=document.createElementNS(this.xmlns,"defs"),o=document.createElementNS(this.xmlns,"radialGradient"),s=document.createElementNS(this.xmlns,"stop"),r=document.createElementNS(this.xmlns,"stop");o.setAttribute("cx","0%"),o.setAttribute("cy","100%"),o.setAttribute("fx","0%"),o.setAttribute("fy","100%"),o.setAttribute("r","104.321936%"),o.setAttribute("id","radialGradient-1"),s.setAttribute("stop-color","#36D4A8"),s.setAttribute("offset","0%"),r.setAttribute("stop-color","#36D4A8"),r.setAttribute("offset","100%"),r.setAttribute("stop-opacity","0"),n.append(o),o.append(s),o.append(r),e.appendChild(n),e.appendChild(t),e.appendChild(i),this.svgNode=e},t.prototype.setCircleAttribute=function(e,t){this.cameraCircleNode.setAttribute(e,t)},t.prototype.setArrowAttribute=function(e,t){this.cameraArrowNode.setAttribute(e,t)},t.prototype.rotate=function(e){e&&(this.rotateAngle=e);var t=this.svgNode.getAttribute("transform");t+="rotate("+this.rotateAngle+")",this.svgNode.setAttribute("transform",t)},t.prototype.setOffsetAndRotate=function(e,t,i){var n=this.setOffsetBoundary(e,t);this.locate(n.X,n.Y),this.rotate(i),At.panOffsetXForCamera=0,At.panOffsetYForCamera=0},t.prototype.move=function(e,t){var i=this.position.x+e,n=this.position.y+t,o=this.setOffsetBoundary(i,n);this.svgNode.setAttribute("transform","translate("+o.X+","+o.Y+")")},t.prototype.setOpacity=function(e){this.svgNode.setAttribute("opacity",e)},t.prototype.setCameraArrowOpacity=function(e){this.cameraArrowNode.setAttribute("opacity",e)},t.prototype.setCameraCircleOpacity=function(e){this.cameraCircleNode.setAttribute("opacity",e)},t.prototype.setBigCamera=function(){this.cameraCircleNode.setAttribute("r","4.5"),this.cameraArrowNode.setAttribute("transform","translate(13,-21)rotate(50)")},t.prototype.setSmallCamera=function(){this.cameraCircleNode.setAttribute("r","2"),this.cameraArrowNode.setAttribute("transform","translate(20,-21)rotate(50)")},t.prototype.setPanelSize=function(e){this.panelSize=e},t.prototype.setOffsetBoundary=function(e,t){var i=this.panelSize[0]/2-6,n=-this.panelSize[0]/2+6,o=this.panelSize[1]/2-6,s=-this.panelSize[1]/2+6;return e>=i||e<=n||t>=o||t<=s?this.setSmallCamera():this.setBigCamera(),e>i&&(e=i),e<n&&(e=n),t>o&&(t=o),t<s&&(t=s),{X:e,Y:t}},t}(vt),Rt=function(){function e(e){this.resourcePlanes=e}return e.prototype.find=function(e,t){for(var i=0;i<this.resourcePlanes.length;i++){var n=this.resourcePlanes[i];if(t){if(n.modelId==t&&n.id==e)return n}else if(n.id==e)return n}},e.prototype.getFloorPlaneBox=function(e,t){var i=this.find(e,t);return i?i.boundingBox||i.BoundingBox:void 0},e.prototype.getUrl=function(e,t){var i=this.find(e,t);return i?i.path||i.Path:void 0},e.prototype.getElevation=function(e,t){var i=this.find(e,t);return i?i.Elevation:void 0},e.prototype.getName=function(e,t){var i=this.find(e,t);return i?i.name||i.Name:void 0},e}(),Ot=function(e){function t(){return e.call(this)||this}return wt(t,e),t.prototype.getCuttingBoxOnCanvas=function(e,t,i,n){var o=new THREE.Box3,s=new THREE.Vector2(e.x,e.y),r=new THREE.Vector2(t.x,t.y);this.toWorldPoint(s,i[0],i[1],n),this.toWorldPoint(r,i[0],i[1],n);var a=[];return a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,s.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(s.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,r.y)),a.push(new THREE.Vector3(r.x,s.y)),a.push(new THREE.Vector3(r.x,s.y)),o.setFromPoints(a),{min:{x:o.min.x,y:o.min.y,z:0},max:{x:o.max.x,y:o.max.y,z:0}}},t.prototype.toWorldPoint=function(e,t,i,n){e.x<0&&(e.x=0),e.x>t&&(e.x=t),e.y<0&&(e.y=0),e.y>i&&(e.y=i),e.x=e.x/t*2-1,e.y=-e.y/i*2+1,n.normalizedPointToWorld(e)},t.prototype.normalizePointByZoomFactor=function(e,t,i,n){var o=new THREE.Vector2;if(e){var s=this.getContainerOffsetToClient(e),r=new THREE.Vector2;r.x=i.x-s.left-(e.clientWidth*n-t[0])/2,r.y=i.y-s.top-(e.clientHeight*n-t[1])/2;var a={width:t[0],height:t[1]};if(r.x>0&&r.x<a.width&&r.y>0&&r.y<a.height)return o.x=r.x/a.width*2-1,o.y=-r.y/a.height*2+1,new THREE.Vector2(o.x,o.y)}return null},t}(bt),kt=function(){function e(e,t){this.point2D=new THREE.Vector2;var i=e[0],n=e[1],o=t[0],s=t[1];i.x,o.x,i.y,o.y;var r=n.clone().sub(i).length()/s.clone().sub(o).length();i.x!==n.x?Math.atan((n.y-i.y)/(n.x-i.x)):i.x==n.x&&(n.y,i.y),o.x!==s.x?Math.atan((o.y-s.y)/(s.x-o.x)):o.x==s.x&&(s.y,o.y),this.rotateAngle=this.calculateRotateAngle(s.x-o.x,o.y-s.y,n.x-i.x,n.y-i.y);var a=(new THREE.Matrix3).translate(-o.x,o.y),l=(new THREE.Matrix3).translate(i.x,i.y),h=(new THREE.Matrix3).rotate(-this.rotateAngle),d=(new THREE.Matrix3).scale(r,r);this.mapToModelMatrix=l.clone().multiply(d).multiply(h).multiply(a);var c=(new THREE.Matrix3).translate(o.x,-o.y),u=(new THREE.Matrix3).translate(-i.x,-i.y),g=(new THREE.Matrix3).rotate(this.rotateAngle),p=(new THREE.Matrix3).scale(1/r,1/r);this.modelToMapMatrix=c.clone().multiply(g).multiply(p).multiply(u)}return e.prototype.calculateRotateAngle=function(e,t,i,n){var o=1e-6,s=Math.acos(-1),r=Math.sqrt(e*e+t*t);t/=r;var a=0,l=(e/=r)*(i/=r=Math.sqrt(i*i+n*n))+t*(n/=r);if(Math.abs(l-1)<=o)a=0;else if(Math.abs(l+1)<=o)a=s;else{a=Math.acos(l),e*n-i*t<0&&(a=2*s-a)}return a},e.prototype.getRotateAngle=function(){return this.rotateAngle},e.prototype.mapToModel=function(e){return new THREE.Vector2(e.x,-e.y).applyMatrix3(this.mapToModelMatrix)},e.prototype.modelToMap=function(e){this.point2D.set(e.x,e.y);var t=this.point2D.clone().applyMatrix3(this.modelToMapMatrix);return t.y=-t.y,t},e}(),Ht=function(e){function t(t,i){var n=e.call(this)||this;return n.radius=t,n.material=i,n.build(),n}return wt(t,e),t.prototype.build=function(){var e=document.createElementNS(this.xmlns,"circle");e.setAttribute("r",this.radius+""),e.setAttribute("fill",this.glodonColor),e.setAttribute("style","fill: none; stroke: "+this.glodonColor),e.setAttribute("opacity","0"),this.svgNode=e},t.prototype.highlight=function(){this.svgNode.setAttribute("style","stroke:"+this.glodonColor),this.svgNode.setAttribute("opacity","1")},t.prototype.cancelHighlight=function(){this.svgNode.setAttribute("style","stroke:rgb(153,153,153)"),this.svgNode.setAttribute("opacity","0")},t.prototype.setOffset=function(e,t){this.svgNode.setAttribute("transform","translate("+e+","+t+")")},t}(vt);!function(e){e.Default="Editor",e.PICK_Editor="Pick",e.RECTPICK_Editor="RectPick",e.PAN_Editor="Pan",e.Zoom_Editor="Zoom"}(Lt||(Lt={}));var Ut,Nt,Gt=function(){function e(){this.bIsMouseDown=!1,this.name=Lt.Default}return e.prototype.onMouseDown=function(e){},e.prototype.onMouseMove=function(e){},e.prototype.onMouseUp=function(e){},e.prototype.onMouseWheel=function(e){},e.prototype.getName=function(){return this.name},e.prototype.scale=function(e,t,i){},e}();!function(e){e[e.RECTPICK_MOUSE_DOWN=1e3]="RECTPICK_MOUSE_DOWN",e[e.RECTPICK_MOUSE_MOVE=1001]="RECTPICK_MOUSE_MOVE",e[e.RECTPICK_MOUSE_UP=1002]="RECTPICK_MOUSE_UP",e[e.PICK_MOUSE_DOWN=2e3]="PICK_MOUSE_DOWN",e[e.PICK_MOUSE_MOVE=2001]="PICK_MOUSE_MOVE",e[e.PICK_MOUSE_UP=2002]="PICK_MOUSE_UP",e[e.Floor_Plane_Changed=3e3]="Floor_Plane_Changed",e[e.Floor_Plane_Changed_For_Panel=3001]="Floor_Plane_Changed_For_Panel",e[e.Resize=4e3]="Resize",e[e.Camera_Height_Changed=5e3]="Camera_Height_Changed",e[e.ZOOM_MOUSE_WHEEL=6e3]="ZOOM_MOUSE_WHEEL",e[e.PAN_MOUSE_MOVE=7e3]="PAN_MOUSE_MOVE",e[e.NavigationMapRectChanged=8e3]="NavigationMapRectChanged",e[e.NavigationMapRectDestroyed=8001]="NavigationMapRectDestroyed"}(Ut||(Ut={})),function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(Nt||(Nt={}));var jt,zt=function(){function e(){this.eventDispatcher=new THREE.EventDispatcher}return e.prototype.addEventListener=function(e,t){this.eventDispatcher.addEventListener(e,t)},e.prototype.hasEventListener=function(e){this.eventDispatcher.hasEventListener(e)},e.prototype.removeEventListener=function(e,t){this.eventDispatcher.removeEventListener(e,t)},e.prototype.dispatchEvent=function(e){this.eventDispatcher.dispatchEvent(e)},e}();!function(e){e.Min="Min",e.Max="Max"}(jt||(jt={}));var Ft=function(e){function t(t,i){var n=e.call(this)||this;return n.totalZoomFactors=[],n.zoomFactors=[],n.lastZoomFactor=1,n.currentIdx=0,n.name=Lt.Zoom_Editor,n.eventManager=i,n.nmData=t.getData(),n.nmViewer=t,n}return wt(t,e),t.prototype.scale=function(e,t,i){var n=t>e,o=-1;if(n?this.currentIdx<this.zoomFactors.length-1&&(this.currentIdx++,o=this.zoomFactors[this.currentIdx]):this.currentIdx>0&&(this.currentIdx--,o=this.zoomFactors[this.currentIdx]),!(o<0||this.lastZoomFactor==o)){this.lastZoomFactor=o,1==o&&Wt.clear();var s=this.nmData.getOriginSize(),r=new THREE.Vector2(i[0]-s[0]/2,i[1]-s[1]/2),a=this.zoomFactors[this.currentIdx],l=0,h=0;if(n){var d=a/(p=this.zoomFactors[this.currentIdx-1]),c=[],u=this.nmData.getCorner("Virtual","LB");u[0]-=r.x,u[1]-=r.y,c.push(u[0]*d+r.x),c.push(u[1]*d+r.y),this.nmData.setZoomFactor(a);var g=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(p),l=c[0]-g[0],h=c[1]-g[1]}else{var p=this.zoomFactors[this.currentIdx+1],m=this.boundsChecking(a,p,r);l=m[0],h+=m[1]}Wt.panOffsetX+=l,Wt.panOffsetY+=h,Wt.panOffsetXForCamera+=l,Wt.panOffsetYForCamera+=h,this.nmData.setZoomFactor(o),this.nmViewer.destroy(),this.nmData.destroy(),this.nmData.build(),this.nmViewer.update(),this.nmData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:Ut.ZOOM_MOUSE_WHEEL,data:{offsetX:Wt.panOffsetX,offsetY:Wt.panOffsetY,zoomFactor:o}})}},t.prototype.onMouseWheel=function(e){var t=(e.deltaY||-e.wheelDelta||e.detail)<0,i=-1;if(t?this.currentIdx<this.zoomFactors.length-1&&(this.currentIdx++,i=this.zoomFactors[this.currentIdx]):this.currentIdx>0&&(this.currentIdx--,i=this.zoomFactors[this.currentIdx]),!(i<0||this.lastZoomFactor==i)){this.lastZoomFactor=i,1==i&&Wt.clear();var n=this.nmData.getOriginSize(),o=new THREE.Vector2(e.offsetX-n[0]/2,e.offsetY-n[1]/2),s=this.zoomFactors[this.currentIdx],r=0,a=0;if(this.nmData.isZooming=!0,t){var l=s/(u=this.zoomFactors[this.currentIdx-1]),h=[],d=this.nmData.getCorner("Virtual","LB");d[0]-=o.x,d[1]-=o.y,h.push(d[0]*l+o.x),h.push(d[1]*l+o.y),this.nmData.setZoomFactor(s);var c=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(u),r=h[0]-c[0],a=h[1]-c[1]}else{var u=this.zoomFactors[this.currentIdx+1],g=this.boundsChecking(s,u,o);r=g[0],a+=g[1]}Wt.panOffsetX+=r,Wt.panOffsetY+=a,Wt.panOffsetXForCamera+=r,Wt.panOffsetYForCamera+=a,this.nmData.setZoomFactor(i),this.nmViewer.destroy(),this.nmData.destroy(),this.nmData.build(),this.nmViewer.update(),this.nmData.updateMovement(),this.updateZoomAndPan();var p=this;1==s&&requestAnimationFrame((function(){delete p.nmData.isZooming})),this.eventManager.dispatchEvent({type:Ut.ZOOM_MOUSE_WHEEL,data:{offsetX:Wt.panOffsetX,offsetY:Wt.panOffsetY,zoomFactor:i}})}},t.prototype.boundsChecking=function(e,t,i){var n=e/t,o=this.nmData.getCorner("Virtual","LB"),s=this.nmData.getCorner("Virtual","LT"),r=this.nmData.getCorner("Virtual","RT"),a=this.nmData.getCorner("Virtual","RB"),l=[0,0],h=(o[0]-i.x)*n+i.x,d=(o[1]-i.y)*n+i.y;this.nmData.setZoomFactor(e);var c=this.nmData.getCorner("Virtual","LB");this.nmData.setZoomFactor(t),l[0]=h-c[0],l[1]=d-c[1];var u=0,g=0,p=this.nmData.getCorner("Origin","LB");h>p[0]&&(l[0]+=p[0]-h,u++),d<p[1]&&(l[1]+=p[1]-d,g++),h=(s[0]-i.x)*n+i.x,d=(s[1]-i.y)*n+i.y;var m=this.nmData.getCorner("Origin","LT");h>m[0]&&0==u&&(l[0]+=m[0]-h,u++),d>m[1]&&0==g&&(l[1]+=m[1]-d,g++),h=(r[0]-i.x)*n+i.x,d=(r[1]-i.y)*n+i.y;var f=this.nmData.getCorner("Origin","RT");h<f[0]&&0==u&&(l[0]+=f[0]-h,u++),d>f[1]&&0==g&&(l[1]+=f[1]-d,g++),h=(a[0]-i.x)*n+i.x,d=(a[1]-i.y)*n+i.y;var w=this.nmData.getCorner("Origin","RB");return h<w[0]&&0==u&&(l[0]+=w[0]-h,u++),d<w[1]&&0==g&&(l[1]+=w[1]-d,g++),l},t.prototype.enableMode=function(e){if(e==jt.Min)this.zoomFactors=this.totalZoomFactors;else if(e==jt.Max){this.zoomFactors=this.totalZoomFactors.slice(1,this.totalZoomFactors.length);for(var t=1;t<this.zoomFactors.length;t++)this.zoomFactors[t]/=this.zoomFactors[0];this.zoomFactors[0]=1}this.currentIdx=0},t.prototype.setZoomFactors=function(e){this.totalZoomFactors=e,this.zoomFactors=e},t.prototype.setZoonIndex=function(e){this.currentIdx=e},t.prototype.getZoonIndex=function(){return this.currentIdx},t.prototype.updateZoomAndPan=function(){var e=this.nmData.getCorner("Origin","LT"),i=this.nmData.getCorner("Virtual","LT");t.offsetXForZoomAndPan=e[0]-i[0],t.offsetYForZoomAndPan=e[1]-i[1]},t.clear=function(){t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0},t.offsetXForZoomAndPan=0,t.offsetYForZoomAndPan=0,t}(Gt),Wt=function(e){function t(i,n){var o=e.call(this)||this;return o.name=Lt.PAN_Editor,o.eventManager=n,o.nmData=i.getData(),o.bIsMouseDown=!1,o.mouseDownPos=new THREE.Vector2,t.panOffsetX=0,t.panOffsetY=0,o}return wt(t,e),t.prototype.onMouseDown=function(e){this.bIsMouseDown=!0,this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)},t.prototype.onMouseMove=function(e){if(0!=this.bIsMouseDown&&1!=this.nmData.getZoomFactor()){var i=e.clientX-this.mouseDownPos.x,n=e.clientY-this.mouseDownPos.y;if(0!==i||0!==n){var o=this.boundsChecking(i,n);i=o[0],n=o[1],t.panOffsetX+=i,t.panOffsetY+=n,t.panOffsetXForCamera+=i,t.panOffsetYForCamera+=n,this.nmData.updateMovement(),this.updateZoomAndPan(),this.eventManager.dispatchEvent({type:Ut.PAN_MOUSE_MOVE,data:{offsetX:t.panOffsetX,offsetY:t.panOffsetY,zoomFactor:this.nmData.getZoomFactor()}}),this.mouseDownPos.setX(e.clientX),this.mouseDownPos.setY(e.clientY)}}},t.prototype.onMouseUp=function(e){0!=this.bIsMouseDown&&(this.bIsMouseDown=!1)},t.prototype.boundsChecking=function(e,t){var i=this.nmData.getCorner("Origin","LB"),n=this.nmData.getCorner("Virtual","LB"),o=this.nmData.getCorner("Origin","RT"),s=this.nmData.getCorner("Virtual","RT");if(e>0)(r=i[0]-n[0])<=e&&(e=r);else if(e<0){var r;(r=o[0]-s[0])>=e&&(e=r)}if(t<0)(a=i[1]-n[1])>=t&&(t=a);else if(t>0){var a;(a=o[1]-s[1])<=t&&(t=a)}return[e,t]},t.prototype.updateZoomAndPan=function(){var e=this.nmData.getCorner("Origin","LT"),t=this.nmData.getCorner("Virtual","LT");Ft.offsetXForZoomAndPan=e[0]-t[0],Ft.offsetYForZoomAndPan=e[1]-t[1]},t.clear=function(){t.panOffsetX=0,t.panOffsetY=0,t.panOffsetXForCamera=0,t.panOffsetYForCamera=0},t}(Gt),$t=function(){function e(){this.zoomFactor=1,this.imageScale=1,this.imageOriginScale=1,this.bboxLengthStages=[15e4,3e5],this.zoomFactors1=[1,7/4,2.5,10/3],this.zoomFactors2=[1,7/4,2.5,14/3,65/12,20/3],this.zoomFactors3=[1,7/4,2.5,10/3,14/3,65/12,20/3,49/6,10],this.url=null,this.drawableItems=[],this.bIsShowAxisGrid=!1,this.bIsShowCameraNode=!0,this.bIsShowFloorPlane=!0,this.floorPlaneBox=new THREE.Box3,this.axisGridNode=null,this.cameraNode=null,this.floorPlaneNode=null,this.algorithm=new Ot,this.glodonColor="#11DAB7",this.axisGridBoxSize=new THREE.Vector2,this.boxCenter=new THREE.Vector2,this.boxSize=new THREE.Vector2,this.boxCenter2=new THREE.Vector2}return e.prototype.setPlanes=function(e){this.dataFloorPlanes=new Rt(e)},e.prototype.setUrl=function(e,t){this.url=e,this.isProfile=t,this.build()},e.prototype.setAnchor=function(e){var t=e.modelAnchor,i=e.mapAnchor,n=e.zHeight,o=e.maxHeight;this.modelAnchor=t,this.mapAnchor=i,this.zHeight=n,this.maxHeight=o,this.coordinateTransform=new kt(t,i)},e.prototype.getRotateAngle=function(){return this.coordinateTransform.getRotateAngle()},e.prototype.mapToModel=function(e){var t=this.coordinateTransform.mapToModel(e);return new THREE.Vector3(t.x,t.y,this.zHeight)},e.prototype.modelToMap=function(e){return this.coordinateTransform.modelToMap(e)},e.prototype.worldToNormalizedPoint=function(e){var t=this.modelToMap(e);return e.x=t.x/this.imgSize.width*2-1,e.y=2*(1-t.y/this.imgSize.height)-1,e},e.prototype.normalizedPointToWorld=function(e){var t=new THREE.Vector2;t.x=.5*(e.x+1)*this.imgSize.width,t.y=(1-.5*(e.y+1))*this.imgSize.height;var i=this.mapToModel(t);e.x=i.x,e.y=i.y},e.prototype.clientToModel=function(e){var t=e.x/this.getSize()[0]*this.imgSize.width,i=e.y/this.getSize()[1]*this.imgSize.height,n=new THREE.Vector2(t,i);return this.mapToModel(n)},e.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},e.prototype.getUrl=function(){return this.url},e.prototype.getFloorPlaneBox=function(){var e=this.modelAnchor[0],t=this.modelAnchor[1];return e.z=this.zHeight,t.z=this.maxHeight,this.floorPlaneBox.makeEmpty(),this.floorPlaneBox.expandByPoint(e),this.floorPlaneBox.expandByPoint(t),this.floorPlaneBox},e.prototype.setSize=function(e,t){this.width=e,this.height=t},e.prototype.getSize=function(){return[this.width*this.zoomFactor,this.height*this.zoomFactor]},e.prototype.getImageSize=function(){return[this.imgSize.width*this.imageScale*this.zoomFactor,this.imgSize.height*this.imageScale*this.zoomFactor]},e.prototype.saveImageSize=function(e){var t=this.width,i=this.height,n=e.width,o=e.height,s=i/t,r=o/n;this.imageOriginScale=s>=r?t/n:i/o,this.imgSize=e},e.prototype.getOriginSize=function(){return[this.width,this.height]},e.prototype.getGlodonColor=function(){return this.glodonColor},e.prototype.build=function(){if(this.axisGridNode=new Tt(!1,this.getSize(),this.bIsShowAxisGrid,this.getZoomFactor()),this.buildFloorPlane(),this.bIsShowCameraNode){this.cameraNode=new Vt;var e=this.getOriginSize();this.cameraNode.setPanelSize(e),this.drawableItems.push(this.cameraNode)}this.intersectPoint=new Ht(3),this.drawableItems.push(this.intersectPoint)},e.prototype.buildFloorPlane=function(){var e=this.getUrl();if(this.bIsShowFloorPlane){var t=this.getFloorPlaneBox();this.getAxisGridBox2D().containsBox(t)||console.warn("the bounding-box of axis-grid is not contains the bounding-box of floor-plane!");var i=this.getFloorPlaneParams2();this.floorPlaneNode=new Pt(e,i,this.isProfile),this.drawableItems.push(this.floorPlaneNode)}},e.prototype.getFloorPlaneParams2=function(){var e=this.getSize()[0],t=this.getSize()[1],i=this.imgSize.width,n=this.imgSize.height,o=t/e,s=n/i;this.imageScale=o>=s?e/(i*this.zoomFactor):t/(n*this.zoomFactor);var r=i*this.imageScale*this.zoomFactor,a=n*this.imageScale*this.zoomFactor,l=[];return l.push(r,a),l.push(0,0),l},e.prototype.getFloorPlaneParams=function(){var e=this.getFloorPlaneBox(),t=this.getAxisGridBox2D(),i=new THREE.Box2(new THREE.Vector2(e.min.x,e.min.y),new THREE.Vector2(e.max.x,e.max.y)),n=this.getSize()[0],o=n/this.getSize()[1];t.getSize(this.axisGridBoxSize),this.axisGridBoxSize.x/this.axisGridBoxSize.y!=o&&(this.algorithm.expandBbox(t,o),t.getSize(this.axisGridBoxSize));var s=[],r=n/this.axisGridBoxSize.x;i.getSize(this.boxSize);var a=this.boxSize.x*r,l=this.boxSize.y*r;s.push(a,l),i.getCenter(this.boxCenter),t.getCenter(this.boxCenter2);var h=this.boxCenter.clone().sub(this.boxCenter2);return h.x*=r,h.y*=-r,s.push(h.x,h.y),s},e.prototype.getDataFloorPlanes=function(){return this.dataFloorPlanes},e.prototype.getAxisGridBox2D=function(e){var t=this.axisGridNode.getAxisGridBox(e);if(t.getSize(this.axisGridBoxSize),0==this.axisGridBoxSize.length()){var i=this.getFloorPlaneBox();if(e)return i;var n=(new THREE.Box2).set(new THREE.Vector2(i.min.x,i.min.y),new THREE.Vector2(i.max.x,i.max.y));n.getCenter(this.boxCenter),n.getSize(this.boxSize);var o=new THREE.Vector2,s=this.width/this.height,r=this.boxSize.x/this.boxSize.y,a=this.boxSize.x,l=this.boxSize.y;return r>s?l=a/s:r<s&&(a=l*s),o.set(a,l),n.setFromCenterAndSize(this.boxCenter,o),n}return t},e.prototype.getDrawableItems=function(){return this.drawableItems},e.prototype.destroy=function(){this.drawableItems=[]},e.prototype.setIsShowAxisGrid=function(e){this.bIsShowAxisGrid=e},e.prototype.getCameraNode=function(){for(var e=this.drawableItems,t=0;t<e.length;t++){var i=e[t];if(i instanceof Vt)return i}},e.prototype.updateMovement=function(){var e=this.getFloorPlaneNode();this.imgPosition=e.move(Wt.panOffsetX,Wt.panOffsetY);var t=this.getAxisGridNode();t&&t.move(Wt.panOffsetX,Wt.panOffsetY);var i=this.getCameraNode();i.move(Wt.panOffsetXForCamera,Wt.panOffsetYForCamera),i.rotate()},e.prototype.getPicPosition=function(e){var t=this.getFloorPlaneNode(),i=e.x-this.imgPosition.x,n=e.y-this.imgPosition.y;return{x:(i-.5*this.width- -.5*t.width)/t.width*this.imgSize.width,y:(n-.5*this.height- -.5*t.height)/t.height*this.imgSize.height}},e.prototype.getCorner=function(e,t){var i=[],n=[];"Origin"==e?(i=[0,0],n=this.getOriginSize()):"Virtual"==e&&(i=[Wt.panOffsetX,Wt.panOffsetY],n=this.getSize());var o=0,s=0;switch(t){case"LB":o=i[0]-n[0]/2,s=i[1]+n[1]/2;break;case"LT":o=i[0]-n[0]/2,s=i[1]-n[1]/2;break;case"RT":o=i[0]+n[0]/2,s=i[1]-n[1]/2;break;case"RB":o=i[0]+n[0]/2,s=i[1]+n[1]/2;break;default:console.log("CornerName is wrong.")}return[o,s]},e.prototype.getHeight=function(){return this.zHeight},e.prototype.getIntersections=function(){return this.axisGridNode.getIntersections()},e.prototype.getGridLineByName=function(e){return this.axisGridNode.getGridLineByName(e)},e.prototype.getFloorPlaneNode=function(){return this.floorPlaneNode},e.prototype.getAxisGridNode=function(){return 0==this.bIsShowAxisGrid?null:this.axisGridNode},e.prototype.getIntersectPoint=function(){return this.intersectPoint},e.prototype.setZoomFactor=function(e){this.zoomFactor=e},e.prototype.getZoomFactor=function(){return this.zoomFactor},e.prototype.getProperZoomFactors=function(){this.getAxisGridBox2D(!0).getSize(this.boxSize);var e=Math.max(this.boxSize.x,this.boxSize.y);return e<=this.bboxLengthStages[0]?this.zoomFactors1:e<=this.bboxLengthStages[1]?this.zoomFactors2:this.zoomFactors3},e}(),Xt=function(){function e(e,t,i){this.viewer=e,this.domContainer=t,this.navigationMapData=i,this.width=t.offsetWidth,this.height=t.offsetHeight,this.offsetLeft=t.offsetLeft,this.offsetTop=t.offsetTop,this.algorithm=new Ot,this.eventManager=null,this.bBoxCenter=new THREE.Vector3,this.inverseMatrix=new THREE.Matrix4,this.rotateMatrix=new THREE.Matrix3,this.projectedCameraPosition=new THREE.Vector3,this.projectedTargetPosition=new THREE.Vector3,this.initialize()}return e.prototype.initialize=function(){var e="http://www.w3.org/2000/svg";this.drawableContainer=document.createElementNS(e,"svg"),this.drawableContainer.setAttribute("width",this.width+""),this.drawableContainer.setAttribute("height",this.height+""),this.drawableContainer.setAttribute("viewBox",-this.width/2+" "+-this.height/2+" "+this.width+" "+this.height),this.drawableContainer.style.position="absolute",this.auxContainer=document.createElementNS(e,"svg"),this.auxContainer.setAttribute("width",this.width+""),this.auxContainer.setAttribute("height",this.height+""),this.auxContainer.setAttribute("viewBox",-this.width/2+" "+-this.height/2+" "+this.width+" "+this.height),this.auxContainer.style.position="absolute",this.mapContainer=document.createElement("div"),this.mapContainer.style.left="0px",this.mapContainer.style.bottom="0px",this.mapContainer.style.position="relative",this.mapContainer.outling="none",this.mapContainer.appendChild(this.drawableContainer),this.mapContainer.appendChild(this.auxContainer),this.domContainer.appendChild(this.mapContainer),this.cameraHeightChangedCallbackBinded=this.cameraHeightChangedCallback.bind(this)},e.prototype.cameraHeightChangedCallback=function(e){var t=e.cameraPosition;this.viewer.getScene().getMatrixGlobal();var i=this.viewer.getScene().getInverseMatrixGlobal(),n=t.clone().applyMatrix4(i);this.navigationMapData.getAxisGridBox2D().containsPoint(new THREE.Vector2(n.x,n.y))},e.prototype.getMapContainer=function(){return this.drawableContainer},e.prototype.getDomContainer=function(){return this.domContainer},e.prototype.getAuxContainer=function(){return this.auxContainer},e.prototype.getViewer=function(){return this.viewer},e.prototype.getData=function(){return this.navigationMapData},e.prototype.setSize=function(e,t){this.mapContainer.style.width=e+"px",this.mapContainer.style.height=t+"px",this.drawableContainer.setAttribute("width",e+""),this.drawableContainer.setAttribute("height",t+""),this.drawableContainer.setAttribute("viewBox",-e/2+" "+-t/2+" "+e+" "+t),this.auxContainer.setAttribute("width",e+""),this.auxContainer.setAttribute("height",t+""),this.auxContainer.setAttribute("viewBox",-e/2+" "+-t/2+" "+e+" "+t),this.destroy(),this.navigationMapData.destroy(),this.navigationMapData.build(),this.update(),this.eventManager.dispatchEvent({type:Ut.Resize,size:{width:e,height:t}})},e.prototype.destroy=function(){for(var e=this.drawableContainer;e.children.length>0;){var t=e.children[0];e.removeChild(t)}this.mapContainer.removeChild(e)},e.prototype.updateCameraNode=function(){var e=this.viewer,t=e.camera,i=e.cameraControl;if(t&&i){var n=t.position,o=t.target,s=this.algorithm.getMainSceneMatrix(e);this.inverseMatrix.copy(s).invert();var r=this.navigationMapData.getFloorPlaneBox();if(isNaN(r.min.z)){var a=n.clone();a.applyMatrix4(this.inverseMatrix),r.min.z=a.z,r.max.z=this.navigationMapData.maxHeight}r.getCenter(this.bBoxCenter);var l=new THREE.Vector3(r.min.x,r.min.y,this.bBoxCenter.z).applyMatrix4(s),h=new THREE.Vector3(r.min.x,r.max.y,this.bBoxCenter.z).applyMatrix4(s),d=new THREE.Vector3(r.max.x,r.min.y,this.bBoxCenter.z).applyMatrix4(s),c=new THREE.Plane;c.setFromCoplanarPoints(l,h,d),c.projectPoint(n,this.projectedCameraPosition),this.projectedCameraPosition.applyMatrix4(this.inverseMatrix),c.projectPoint(o,this.projectedTargetPosition),this.projectedTargetPosition.applyMatrix4(this.inverseMatrix);var u=this.projectedTargetPosition.clone().sub(this.projectedCameraPosition);u.z=0,u.normalize();var g=n.clone();g.applyMatrix4(this.inverseMatrix);var p=g.clone(),m=this.navigationMapData.getCameraNode();if(m){var f=this.navigationMapData.getImageSize(),w={width:f[0]/2,height:f[1]/2};if(this.navigationMapData.getAxisGridBox2D(),this.getData().worldToNormalizedPoint(p),this.algorithm.normalizedPointToScreen(p,w),m.setOpacity("1.0"),u.length()<1e-5)m.setCameraArrowOpacity("0.0"),m.setOffsetAndRotate(p.x+Wt.panOffsetX,p.y+Wt.panOffsetY,0);else{var y=new THREE.Vector3(0,0,1),v=new THREE.Vector3(1,0,0);this.rotateMatrix.identity(),this.rotateMatrix.rotate(this.navigationMapData.getRotateAngle()),u.applyMatrix3(this.rotateMatrix);var b=this.algorithm.isAngleGreaterThanPi(v,u,y),E=THREE.Math.radToDeg(v.angleTo(u));b||(E*=-1),m.setBigCamera(),m.setOffsetAndRotate(p.x+Wt.panOffsetX,p.y+Wt.panOffsetY,E),m.setCameraArrowOpacity("1.0")}}}},e.prototype.update=function(e){for(var t=this.navigationMapData.getDrawableItems(),i=0;i<t.length;i++){t[i].abtainRenderables(this.drawableContainer)}this.updateCameraNode();var n=this.mapContainer.firstChild;n?this.mapContainer.insertBefore(this.drawableContainer,n):this.mapContainer.appendChild(this.drawableContainer)},e.prototype.setEventManager=function(e){this.eventManager=e},e.prototype.getEventManager=function(){return this.eventManager},e.prototype.registerCameraHeightChanged=function(e){this.viewer.registerEventListener(e,this.cameraHeightChangedCallbackBinded)},e}(),Yt=function(e){function t(t,i){var n=e.call(this)||this;return n.name=Lt.PICK_Editor,n.nmViewer=t,n.nmData=t.getData(),n.algorithm=new Ot,n.cameraProjectedPosZ=1750,n.nmViewer.getViewer().modelManager.isMeterUnit()&&(n.cameraProjectedPosZ=n.cameraProjectedPosZ/1e3),n.mapClickMode="default",n.lastMousePoint=new THREE.Vector2,n.eventManager=i,n}return wt(t,e),t.prototype.onMouseDown=function(e){this.bIsMouseDown=!0,this.lastMousePoint.setX(e.clientX),this.lastMousePoint.setY(e.clientY)},t.prototype.onMouseMove=function(e){},t.prototype.onMouseUp=function(e){this.bIsMouseDown=!1,this.lastMousePoint.x===e.clientX&&this.lastMousePoint.y===e.clientY&&this.locateByClientPoint(e.clientX+Ft.offsetXForZoomAndPan,e.clientY+Ft.offsetYForZoomAndPan,e)},t.prototype.flyToPointWithParallelEye=function(e){var t=this.nmData.clientToModel(e),i=this.nmViewer.getViewer(),n=i.worldToDrawing(t);i.cameraControl.flyToPointWithParallelEye(new THREE.Vector3(n.x,n.y,n.z))},t.prototype.locateByClientPoint=function(e,t,i){var n=new THREE.Vector2(e,t),o=new THREE.Vector3,s=this.nmViewer.getMapContainer(),r=this.nmData.getImageSize(),a=this.nmData.getZoomFactor(),l=this.algorithm.normalizePointByZoomFactor(s,r,n,a);if(null!=l){var h=this.nmData.getAxisGridBox2D();this.nmData.normalizedPointToWorld(l);var d=this.algorithm.normalizePointByZoomFactor(s,r,n,a);this.algorithm.normalizedPointToScreen(d,{width:r[0]/2,height:r[1]/2});var c=this.algorithm.getIntersectionToMinDistance(this.nmData.getIntersections(),d);if(c&&c.intersectionPoint){var u=new THREE.Vector2(c.intersectionPoint.x,c.intersectionPoint.y);if(d.sub(u).lengthSq()<9){var g=u.clone(),p={width:r[0]/2,height:r[1]/2};this.algorithm.screenToNormalizedPoint(g,p),this.algorithm.normalizedPointToWorld(g,h),o.set(g.x,g.y,this.cameraProjectedPosZ)}else o.set(l.x,l.y,this.cameraProjectedPosZ)}else o.set(l.x,l.y,this.cameraProjectedPosZ);var m=o.clone(),f=this.nmData.getHeight();isNaN(f)||(m.z=f),this.nmData.updateMovement();var w=this.algorithm.getContainerOffsetToClient(s),y={x:i.clientX-w.left,y:i.clientY-w.top},v=this.nmData.getPicPosition(y);return this.eventManager.dispatchEvent({type:Ut.PICK_MOUSE_UP,data:{worldPosition:m.clone(),picPosition:v,clientPosition:y,screenPosition:{x:i.clientX,y:i.clientY}}}),this.algorithm.transformWorldPoint(this.nmViewer.getViewer(),m),this.algorithm.flyToPointWithParallelEye(this.nmViewer.getViewer(),m),!0}console.warn("Click point out of boundary.")},t}(Gt),Zt=function(){function e(e){this.nmViewer=e,this.nmData=e.getData(),this.svgRect=null,this.rectForMinimapId="RectForMinimap",this.bEditMode=!1,this.bPanMode=!1,this.bMouseDown=!1,this.rectangle=[],this.currentGripId=-1,this.lastHighlightGripId=-1,this.bFirstMouseClick=!0,this.lastMousePoint=new THREE.Vector2,this.lastMousePointToRectMin=new THREE.Vector2,this.lastMousePointToRectMax=new THREE.Vector2,this.pointOnBorder=[],this.eventManager=e.getEventManager(),this.panOffset=[0,0],this.zoomFactor=1;var t=this;this.eventManager.addEventListener(Ut.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor),t.nmViewer.updateCameraNode()})),this.eventManager.addEventListener(Ut.PAN_MOUSE_MOVE,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor),t.nmViewer.updateCameraNode()}))}return e.prototype.getMouseClickState=function(){return this.bFirstMouseClick},e.prototype.setMouseClickState=function(e){this.bFirstMouseClick=!!e},e.prototype.getCurrentGripId=function(){return this.currentGripId},e.prototype.setCurrentGripId=function(e){this.currentGripId=e},e.prototype.getRectangleInfo=function(){var e=Math.abs(this.rectangle[2]-this.rectangle[0]),t=Math.abs(this.rectangle[3]-this.rectangle[1]);return{x:this.rectangle[0],y:this.rectangle[1],width:e,height:t}},e.prototype.setLastMousePoint=function(e,t){this.lastMousePoint.x=e,this.lastMousePoint.y=t},e.prototype.equalWithLastPoint=function(e,t){return this.lastMousePoint.x===e&&this.lastMousePoint.y===t},e.prototype.getRectangle=function(){return this.rectangle},e.prototype.addPointToRectangle=function(e,t){"number"==typeof e&&this.rectangle.push(e),"number"==typeof t&&this.rectangle.push(t)},e.prototype.pointsCount=function(){return this.rectangle.length/2},e.prototype.pointValidation=function(e,t){var i=this.nmViewer.getDomContainer().getBoundingClientRect();(e<0||t<0||e>i.width||t>i.height)&&(e=this.pointOnBorder[0],t=this.pointOnBorder[1]),e<this.rectangle[0]?(this.rectangle.push(this.rectangle[0]),this.rectangle[0]=e):this.rectangle.push(e),t<this.rectangle[1]?(this.rectangle.push(this.rectangle[1]),this.rectangle[1]=t):this.rectangle.push(t)},e.prototype.getMouseState=function(){return this.bMouseDown},e.prototype.setMouseState=function(e){this.bMouseDown=!!e},e.prototype.getEditMode=function(){return this.bEditMode},e.prototype.setEditMode=function(e){this.bEditMode=!!e},e.prototype.getPanMode=function(){return this.bPanMode},e.prototype.setPanMode=function(e){this.bPanMode=!!e},e.prototype.createSvgElement=function(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e);return t.setAttribute("pointer-events","inherit"),t},e.prototype.createSvgRect=function(e){this.svgRect||(this.svgRect=this.createSvgElement("rect"),this.svgRect.setAttribute("id",this.rectForMinimapId),this.svgRect.setAttribute("stroke-width",2),this.svgRect.style.position="absolute",this.svgRect.style.fillOpacity="0.4",this.svgRect.style.fill=this.nmData.getGlodonColor(),this.svgRect.style.display="block",this.svgRect.style.stroke=this.nmData.getGlodonColor(),this.svgRect.style.strokeWidth="2");var t=Math.abs(e.x-this.rectangle[0]),i=Math.abs(e.y-this.rectangle[1]),n=this.nmViewer.getAuxContainer(),o=n.clientWidth,s=n.clientHeight,r=["translate(",e.x-o/2,",",e.y-s/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",r),this.svgRect.setAttribute("width",t+""),this.svgRect.setAttribute("height",i+""),n.appendChild(this.svgRect)},e.prototype.updateSvgRect=function(e){this.pointOnBorder=[],this.pointOnBorder.push(e.x,e.y);var t=Math.abs(e.x-this.rectangle[0]),i=Math.abs(e.y-this.rectangle[1]),n={x:this.rectangle[0],y:this.rectangle[1]};if(e.x<n.x||e.y<n.y){e.x<n.x&&(n.x=e.x),e.y<n.y&&(n.y=e.y);var o=this.nmData.getOriginSize(),s=["translate(",n.x-o[0]/2,",",n.y-o[1]/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",s)}this.svgRect.setAttribute("width",t+""),this.svgRect.setAttribute("height",i+"")},e.prototype.resetSvgRect=function(){var e=Math.abs(this.rectangle[0]-this.rectangle[2]),t=Math.abs(this.rectangle[1]-this.rectangle[3]);this.svgRect.setAttribute("width",e+""),this.svgRect.setAttribute("height",t+"");var i=this.nmViewer.getAuxContainer(),n=i.clientWidth,o=i.clientHeight,s=["translate(",this.rectangle[0]-n/2,",",this.rectangle[1]-o/2,") ","rotate(",0,") "].join("");this.svgRect.setAttribute("transform",s),this.eventManager.dispatchEvent({type:Ut.NavigationMapRectChanged,rectInfo:this.getRectangleInfo()})},e.prototype.clearRectangle=function(){this.rectangle=[]},e.prototype.adjustRectangle=function(e,t,i){if(t[0]>=i[0])switch(e){case 0:case 1:case 2:t[0]=i[0];break;case 4:case 5:case 6:i[0]=t[0]}if(t[1]>=i[1])switch(e){case 2:case 3:case 4:i[1]=t[1];break;case 6:case 7:case 0:t[1]=i[1]}return t.concat(i)},e.prototype.gripDragging=function(e,t){var i=this.rectangle,n=t.x-e.x,o=t.y-e.y,s=[i[0],i[1]],r=[i[2],i[3]];switch(this.currentGripId){case 0:s[0]+=n,s[1]+=o;break;case 1:s[0]+=n;break;case 2:s[0]+=n,r[1]+=o;break;case 3:r[1]+=o;break;case 4:r[0]+=n,r[1]+=o;break;case 5:r[0]+=n;break;case 6:s[1]+=o,r[0]+=n;break;case 7:s[1]+=o;break;default:console.log("default grip id."+this.currentGripId)}var a=this.nmData.getOriginSize();r[0]=r[0]>a[0]?a[0]:r[0],r[1]=r[1]>a[1]?a[1]:r[1],this.rectangle=this.adjustRectangle(this.currentGripId,s,r)},e.prototype.hightlightGrip=function(e){var t={x:e.offsetX,y:e.offsetY},i=this.hitGrips(t);i!=this.lastHighlightGripId&&(this.currentGripId<0&&this.lastHighlightGripId>=0&&(document.getElementById(this.rectForMinimapId+"-"+this.lastHighlightGripId).style.stroke=this.nmData.getGlodonColor()));(this.currentGripId>=0||i>=0)&&(this.currentGripId>=0&&(i=this.currentGripId),document.getElementById(this.rectForMinimapId+"-"+i).style.stroke="#f5a623",this.currentGripId<0&&(this.lastHighlightGripId=i))},e.prototype.drawGrips=function(){for(var e=this.getGrips(),t=0;t<e.length;t+=2){if(!((t/2-1)%2)){var i=this.createSegmentGrip(t/2,this.nmData.getGlodonColor());this.currentGripId==t/2&&(i=this.createSegmentGrip(t/2,"#FF9D0B")),this.nmViewer.getAuxContainer().appendChild(i)}}for(t=0;t<e.length;t+=2){if(!!((t/2-1)%2)){i=this.createGrip(t/2,this.nmData.getGlodonColor());this.currentGripId==t/2&&(i=this.createGrip(t/2,"#FF9D0B")),this.nmViewer.getAuxContainer().appendChild(i)}}},e.prototype.createSegmentGrip=function(e,t){var i=this.getGrips(),n=this.rectForMinimapId+"-"+e,o=document.getElementById(n);o&&o.parentNode.removeChild(o);var s=this.createSvgElement("line"),r=this.nmViewer.getAuxContainer().clientWidth,a=this.nmViewer.getAuxContainer().clientHeight,l=(e-1)%(i.length/2),h=(e+1)%(i.length/2),d=String(i[2*l]-r/2),c=String(i[2*l+1]-a/2),u=String(i[2*h]-r/2),g=String(i[2*h+1]-a/2);return s.setAttribute("id",n),s.setAttribute("x1",d),s.setAttribute("y1",c),s.setAttribute("x2",u),s.setAttribute("y2",g),s.setAttribute("style","fill: none; stroke: "+(t||"#4784cb")+"; stroke-width: 2; fill: #ffffff; display: block; position: absolute"),s},e.prototype.createGrip=function(e,t){var i=this.getGrips(),n=this.rectForMinimapId+"-"+e,o=document.getElementById(n);o&&o.parentNode.removeChild(o);var s=this.createSvgElement("circle"),r=this.nmViewer.getAuxContainer().clientWidth,a=this.nmViewer.getAuxContainer().clientHeight,l=["translate(",i[2*e]-r/2,",",i[2*e+1]-a/2,") ","rotate(",0,") "].join("");return s.setAttribute("id",n),s.setAttribute("transform",l),s.setAttribute("r","3"),s.setAttribute("style","fill: none; stroke: "+(t||"#4784cb")+"; stroke-width: 1; fill: #ffffff; display: block; position: absolute"),s},e.prototype.removeGrips=function(){for(var e=0;e<8;e++){var t=document.getElementById(this.rectForMinimapId+"-"+e);t&&t.parentNode.removeChild(t)}},e.prototype.removeSvgRect=function(){var e=document.getElementById(this.rectForMinimapId);e&&e.parentNode.removeChild(e)},e.prototype.destroyAll=function(){this.removeGrips(),this.removeSvgRect(),this.clearRectangle(),this.eventManager.dispatchEvent({type:Ut.NavigationMapRectDestroyed})},e.prototype.getGrips=function(){var e={x:this.rectangle[0],y:this.rectangle[1]},t={x:this.rectangle[2],y:this.rectangle[3]},i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},n=[];return n.push(e.x,e.y),n.push(e.x,i.y),n.push(e.x,t.y),n.push(i.x,t.y),n.push(t.x,t.y),n.push(t.x,i.y),n.push(t.x,e.y),n.push(i.x,e.y),n},e.prototype.hitGrips=function(e){for(var t=this.getGrips(),i=0;i<t.length;i+=2){var n=!1;if(!((i/2-1)%2)){var o=(i/2-1)%(t.length/2),s=(i/2+1)%(t.length/2),r=t[2*o],a=t[2*o+1],l=t[2*s],h=t[2*s+1];n=this.isPointInSegment(e.x,e.y,r,a,l,h,3)}else{var d=[t[i],t[i+1]];n=this.isPointInCircle(e,d,6)}if(n)return i/2}return-1},e.prototype.isPointInCircle=function(e,t,i){var n=e.x-t[0],o=e.y-t[1];return Math.sqrt(n*n+o*o)<=i},e.prototype.isPointInSegment=function(e,t,i,n,o,s,r){r=r||0;var a=(o-i)*(e-i)+(s-n)*(t-n);if(a<=0)return Math.sqrt((e-i)*(e-i)+(t-n)*(t-n))<=r;var l=(o-i)*(o-i)+(s-n)*(s-n);if(a>=l)return Math.sqrt((e-o)*(e-o)+(t-s)*(t-s))<=r;var h=a/l,d=i+(o-i)*h,c=n+(s-n)*h;return Math.sqrt((e-d)*(e-d)+(c-t)*(c-t))<=r},e.prototype.isPointInRectangle=function(e,t){if(this.pointsCount()<2)return!1;var i=this.rectangle,n=i[0]<i[2]?[i[0],i[2]]:[i[2],i[0]],o=n[0],s=n[1],r=(i[1],i[3],[i[1],i[3]]);return o<e&&e<s&&r[0]<t&&t<r[1]},e.prototype.panRectangle=function(e,t){var i=this.rectangle,n=this.nmViewer.getDomContainer().getBoundingClientRect();this.lastMousePointToRectMin.x+e<0?e=-this.lastMousePointToRectMin.x:this.lastMousePointToRectMax.x+e>n.width&&(e=n.width-this.lastMousePointToRectMax.x),this.lastMousePointToRectMin.y+t<0?t=-this.lastMousePointToRectMin.y:this.lastMousePointToRectMax.y+t>n.height&&(t=n.height-this.lastMousePointToRectMax.y),i[0]=this.lastMousePointToRectMin.x+e,i[1]=this.lastMousePointToRectMin.y+t,i[2]=this.lastMousePointToRectMax.x+e,i[3]=this.lastMousePointToRectMax.y+t,this.resetSvgRect(),this.drawGrips()},e.prototype.updateLastMousePointToRect=function(){this.lastMousePointToRectMin.x=this.rectangle[0]-this.lastMousePoint.x,this.lastMousePointToRectMin.y=this.rectangle[1]-this.lastMousePoint.y,this.lastMousePointToRectMax.x=this.rectangle[2]-this.lastMousePoint.x,this.lastMousePointToRectMax.y=this.rectangle[3]-this.lastMousePoint.y},e.prototype.zoomAndPan=function(e,t,i){if(this.pointsCount()<2)return this.panOffset=[e,t],void(this.zoomFactor=i);for(var n=this.nmViewer.getDomContainer().getBoundingClientRect(),o=n.width,s=n.height,r=new THREE.Vector2(.5*o,.5*s),a=0;a<=this.rectangle.length/2;a+=2){var l=new THREE.Vector2(this.rectangle[a]-this.panOffset[0],this.rectangle[a+1]-this.panOffset[1]).clone().sub(r);l.divideScalar(this.zoomFactor),this.rectangle[a]=l.x+r.x,this.rectangle[a+1]=l.y+r.y;var h=new THREE.Vector2(this.rectangle[a],this.rectangle[a+1]).clone().sub(r);h.multiplyScalar(i),this.rectangle[a]=r.x+h.x+e,this.rectangle[a+1]=r.y+h.y+t}this.panOffset=[e,t],this.zoomFactor=i,this.resetSvgRect(),this.drawGrips()},e}(),qt=function(e){function t(t,i){var n=e.call(this)||this;return n.name=Lt.RECTPICK_Editor,n.eventManager=i,n.nmData=t.getData(),n.naviAction=new Zt(t),n.nmViewer=t,n.algorithm=new Ot,n}return wt(t,e),t.prototype.onMouseDown=function(e){this.naviAction.setMouseState(!0);var t=this.adjustEvent(e);if(this.naviAction.setLastMousePoint(t.clientX,t.clientY),0==this.naviAction.pointsCount()){var i={x:t.offsetX,y:t.offsetY};this.naviAction.addPointToRectangle(i.x,i.y),this.naviAction.createSvgRect(i)}if(2==this.naviAction.pointsCount()){var n={x:e.offsetX,y:e.offsetY},o=this.naviAction.hitGrips(n),s=this.naviAction.isPointInRectangle(n.x,n.y);o>=0?this.naviAction.setEditMode(!0):s&&(this.naviAction.updateLastMousePointToRect(),this.naviAction.setPanMode(!0))}this.eventManager.dispatchEvent({type:Ut.RECTPICK_MOUSE_DOWN})},t.prototype.onMouseMove=function(e){if(2==this.naviAction.pointsCount()&&this.naviAction.hightlightGrip(e),this.naviAction.getMouseState()){var t=this.nmViewer.getDomContainer().getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top;if(this.naviAction.pointsCount()<2&&this.naviAction.updateSvgRect({x:i,y:n}),this.naviAction.getEditMode()){var o={x:i,y:n},s=this.naviAction.hitGrips(o);if(this.naviAction.getMouseClickState())return this.firstPos=o,this.naviAction.setMouseClickState(!1),void(s>=0&&this.naviAction.setCurrentGripId(s));var r=o;this.naviAction.getCurrentGripId()>=0&&(this.naviAction.gripDragging(this.firstPos,r),this.naviAction.resetSvgRect(),this.naviAction.removeGrips(),this.naviAction.drawGrips()),this.firstPos=r}this.naviAction.getPanMode()&&this.naviAction.panRectangle(e.clientX,e.clientY)}},t.prototype.onMouseUp=function(e){if(this.naviAction.setMouseState(!1),this.naviAction.setMouseClickState(!0),this.naviAction.setCurrentGripId(-1),this.naviAction.setPanMode(!1),this.naviAction.equalWithLastPoint(e.clientX,e.clientY))1==this.naviAction.pointsCount()&&this.naviAction.clearRectangle();else{if(1==this.naviAction.pointsCount()){var t=this.adjustEvent(e),i=this.nmViewer.getDomContainer().getBoundingClientRect(),n=t.clientX-i.left,o=t.clientY-i.top;this.naviAction.pointValidation(n,o),this.naviAction.resetSvgRect(),this.naviAction.drawGrips()}this.naviAction.setEditMode(!1)}},t.prototype.clear=function(){this.naviAction.destroyAll()},t.prototype.getBoundingBoxIsolate=function(){var e=this.naviAction.getRectangle(),t={x:e[0]+Ft.offsetXForZoomAndPan,y:e[1]+Ft.offsetYForZoomAndPan},i={x:e[2]+Ft.offsetXForZoomAndPan,y:e[3]+Ft.offsetYForZoomAndPan},n=this.algorithm.getCuttingBoxOnCanvas(t,i,this.nmData.getSize(),this.nmData),o=this.nmData.getFloorPlaneBox();if(isNaN(o.min.z)){var s=this.nmViewer.getViewer().camera.position,r=this.nmViewer.getViewer().getScene().getInverseMatrixGlobal(),a=s.clone();a.applyMatrix4(r),o.min.z=a.z,o.max.z=this.nmData.maxHeight}return n.min.z=o.min.z,n.max.z=o.max.z,n},t.prototype.getIntersectionByNormalizedPoint=function(e,t){var i=this.nmViewer.getData().getIntersections(),n=new THREE.Vector2(e.x,e.y);return this.algorithm.normalizedPointToScreen(n,{width:t[0]/2,height:t[1]/2}),Ot.getIntersectionByPoint(i,n)},t.prototype.adjustEvent=function(e){var t={offsetX:e.offsetX,offsetY:e.offsetY,clientX:e.clientX,clientY:e.clientY},i=new THREE.Vector2(t.clientX,t.clientY);i.x+=Ft.offsetXForZoomAndPan,i.y+=Ft.offsetYForZoomAndPan;var n=this.nmViewer.getMapContainer(),o=this.nmViewer.getData().getSize(),s=this.nmData.getZoomFactor(),r=this.algorithm.normalizePointByZoomFactor(n,o,i,s),a=this.getIntersectionByNormalizedPoint(r,o);if(a){var l=this.nmViewer.getDomContainer().getBoundingClientRect();t.clientX=a.intersectionPoint.x-Ft.offsetXForZoomAndPan,t.offsetX=t.clientX+o[0]/2,t.clientX=t.offsetX+l.left,t.clientY=a.intersectionPoint.y-Ft.offsetYForZoomAndPan,t.offsetY=t.clientY+o[1]/2,t.clientY=t.offsetY+l.top}return t},t}(Gt),Kt=function(){function e(e,t,i){this.eventManager=new zt,this.mapContainer=e,this.navigationMapData=t,this.nmViewer=i,this.touches=[],this.nmViewer.setEventManager(this.eventManager),this.offset=e.getBoundingClientRect(),this.activeEditors=[],this.bIsEnablePickHover=!1,this.initialize()}return e.prototype.initialize=function(){this.onContextmenuBinded=this.onContextmenu.bind(this),this.onTouchStartBinded=this.onTouchStart.bind(this),this.onTouchEndBinded=this.onTouchEnd.bind(this),this.onTouchMoveBinded=this.onTouchMove.bind(this),this.onMouseWheelBinded=this.onMouseWheel.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this),this.addDomEventListeners(),this.enableEditor(Lt.PICK_Editor),this.enableEditor(Lt.Zoom_Editor),this.enableEditor(Lt.PAN_Editor),this.enableEditor(Lt.RECTPICK_Editor),this.enablePickHover(!0)},e.prototype.addDomEventListeners=function(){var e=this.mapContainer;e.addEventListener("contextmenu",this.onContextmenuBinded,!1),e.addEventListener("touchmove",this.onTouchMoveBinded,!1),e.addEventListener("touchstart",this.onTouchStartBinded,!1),e.addEventListener("touchend",this.onTouchEndBinded,!1),e.addEventListener("mousewheel",this.onMouseWheelBinded,!1),e.addEventListener("mousedown",this.onMouseDownBinded,!1),e.addEventListener("mousemove",this.onMouseMoveBinded,!1),document.addEventListener("mouseup",this.onMouseUpBinded,!1)},e.prototype.removeDomEventListeners=function(){var e=this.mapContainer;e.removeEventListener("contextmenu",this.onContextmenuBinded,!1),e.removeEventListener("touchmove",this.onTouchMoveBinded,!1),e.removeEventListener("touchstart",this.onTouchStartBinded,!1),e.removeEventListener("touchend",this.onTouchEndBinded,!1),e.removeEventListener("mousewheel",this.onMouseWheelBinded,!1),e.removeEventListener("mousedown",this.onMouseDownBinded,!1),e.removeEventListener("mousemove",this.onMouseMoveBinded,!1),document.removeEventListener("mouseup",this.onMouseUpBinded,!1)},e.prototype.destroy=function(){this.removeDomEventListeners()},e.prototype.enablePickHover=function(e){this.bIsEnablePickHover=e},e.prototype.onTouchStart=function(e){this.touches=this.originTouches=e.touches;var t=this.activeEditors;if(!(this.touches.length>1))for(var i=0;i<t.length;i++){t[i].onMouseDown(this.formatPoint(e.touches[0]))}},e.prototype.onTouchMove=function(e){var t,i,n,o=e.touches;this.activeEditors,1==o.length?this.touches=o:2==o.length&&(t=Math.sqrt(Math.pow(this.touches[0].pageX-this.touches[1].pageX,2)+Math.pow(this.touches[0].pageY-this.touches[1].pageY,2)),i=Math.sqrt(Math.pow(o[0].pageX-o[1].pageX,2)+Math.pow(o[0].pageY-o[1].pageY,2)),n=[(this.originTouches[0].pageX+this.originTouches[1].pageX)/2-this.offset.left,(this.originTouches[0].pageY+this.originTouches[1].pageY)/2-this.offset.top],Math.abs(t-i)>8&&(this.onScale(t,i,n),this.touches=o))},e.prototype.onTouchEnd=function(e){for(var t=e.changedTouches[0],i=[],n=0;n<this.touches.length;n++){var o=this.touches[n];o.clientX==t.clientX&&o.clientY==t.clientY||i.push(o)}this.touches=i;var s=this.activeEditors;if(1==this.touches.length);else if(0==this.touches.length)for(n=0;n<s.length;n++){s[n].onMouseUp(this.formatPoint(t))}},e.prototype.onScale=function(e,t,i){var n=this.find(Lt.Zoom_Editor);n&&n.scale(e,t,i)},e.prototype.onMouseWheel=function(e){var t=this.find(Lt.Zoom_Editor);t&&t.onMouseWheel(e)},e.prototype.onContextmenu=function(e){e.preventDefault()},e.prototype.clearRectPick=function(){var e=this.find(Lt.RECTPICK_Editor);e instanceof qt&&e.clear()},e.prototype.getBoundingBoxIsolate=function(){var e=this.find(Lt.RECTPICK_Editor);if(e instanceof qt)return e.getBoundingBoxIsolate()},e.prototype.onMouseUp=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Lt.PICK_Editor&&e.button!=Nt.Left||(n.getName()==Lt.RECTPICK_Editor&&e.button!=Nt.Left||n.getName()==Lt.PAN_Editor&&e.button==Nt.Left||n.onMouseUp(e))}},e.prototype.onMouseDown=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Lt.PICK_Editor&&e.button!=Nt.Left||(n.getName()==Lt.RECTPICK_Editor&&e.button!=Nt.Left||n.getName()==Lt.PAN_Editor&&e.button==Nt.Left||n.onMouseDown(e))}},e.prototype.onMouseMove=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++){var n=t[i];n.getName()==Lt.PICK_Editor&&0==this.bIsEnablePickHover||n.onMouseMove(e)}},e.prototype.formatPoint=function(e){var t,i={};for(t in e)i[t]=e[t];return i},e.prototype.addEventListener=function(e,t){this.eventManager.addEventListener(e,t)},e.prototype.clearZoomAndPan=function(){Wt.clear(),Ft.clear(),this.navigationMapData.setZoomFactor(1);var e=this.find(Lt.Zoom_Editor);e instanceof Ft&&e.setZoonIndex(0)},e.prototype.find=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++)if(t[i].getName()===e)return t[i]},e.prototype.enableEditor=function(e){if(!this.find(e)){var t=this.activeEditors;switch(e){case Lt.PICK_Editor:t.push(new Yt(this.nmViewer,this.eventManager));break;case Lt.RECTPICK_Editor:t.push(new qt(this.nmViewer,this.eventManager));break;case Lt.PAN_Editor:t.push(new Wt(this.nmViewer,this.eventManager));break;case Lt.Zoom_Editor:t.push(new Ft(this.nmViewer,this.eventManager))}}},e.prototype.getEventManager=function(){return this.eventManager},e.prototype.disableEditor=function(e){for(var t=this.activeEditors,i=0;i<t.length;i++)t[i].getName()===e&&t.splice(i,1)},e.prototype.setZoomMode=function(e){var t=this.find(Lt.Zoom_Editor);t instanceof Ft&&t.enableMode(e)},e.prototype.setZoomFactors=function(e){var t=this.find(Lt.Zoom_Editor);t instanceof Ft&&t.setZoomFactors(e)},e}(),Qt=function(){function e(e,t,i){this.nmData=new $t,this.nmData.setSize(t.offsetWidth,t.offsetHeight),this.nmView=new Xt(e,t,this.nmData),this.setAnchor(i);var n=this.getMapContainer();this.nmEditor=new Kt(n,this.nmData,this.nmView)}return e.prototype.setAnchor=function(e){this.nmData.setAnchor(e)},e.prototype.saveImageSize=function(e){this.nmData.saveImageSize(e)},e.prototype.setPlanes=function(e){this.nmData.setPlanes(e)},e.prototype.updateUrl=function(e,t){this.nmData.setUrl(e,t);var i=this.nmData.getProperZoomFactors();this.nmEditor.setZoomFactors(i),Wt.clear()},e.prototype.getEventManager=function(){return this.nmEditor.getEventManager()},e.prototype.setSize=function(e,t){this.nmData.setSize(e,t)},e.prototype.resize=function(e,t){this.nmEditor.clearZoomAndPan(),this.nmData.setSize(e,t),this.nmView.setSize(e,t),this.nmEditor.setZoomMode(jt.Min)},e.prototype.destroy=function(){this.nmEditor.clearZoomAndPan(),this.nmView.destroy(),this.nmData.destroy(),this.clearRectPick()},e.prototype.destroyEditor=function(){this.nmEditor.destroy()},e.prototype.rebuildData=function(){this.nmData.build()},e.prototype.renderCameraNode=function(){this.nmView.updateCameraNode()},e.prototype.addEventListener=function(e,t){this.nmEditor.addEventListener(e,t)},e.prototype.getBoundingBox=function(){return this.nmEditor.getBoundingBoxIsolate()},e.prototype.clearRectPick=function(){this.nmEditor.clearRectPick()},e.prototype.clearZoomAndPan=function(){this.nmEditor.clearZoomAndPan(),this.nmView.destroy(),this.nmData.destroy(),this.nmData.build(),this.nmView.update()},e.prototype.getAxisGridBox2D=function(){return this.nmData.getAxisGridBox2D()},e.prototype.getMapContainer=function(){return this.nmView.getDomContainer()},e.prototype.render=function(){this.nmView.update()},e.prototype.getPanOffset=function(){return{x:Wt.panOffsetX,y:Wt.panOffsetY}},e.prototype.registerCameraHeightChanged=function(e){this.nmView.registerCameraHeightChanged(e)},e}();!function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap");i.NavigationMap=class{constructor(t){if(!t.viewer)return console.log("viewer is not defined."),!1;P(this),!t.domElement&&t.mapViewer&&(t.domElement=t.mapViewer.domElement),this._opt=t,this.id=t.id,this.eventManager=new e.Web.Lang.EventManager,this.EventType={PICK_MOUSE_UP:2002,Camera_Height_Changed:5e3,ZOOM_MOUSE_WHEEL:6e3,PAN_MOUSE_MOVE:7e3,NavigationMap_Rect_Changed:8e3,NavigationMap_Rect_Destroyed:80001};var i=t.viewer.getViewer();switch(this._viewer=t.viewer,this.viewer=i,this.renderCB=()=>{this._initialized&&this.navigationMap.renderCameraNode()},i.addCallbacks("render",this.renderCB),this.maxHeight=i.getBoundingBoxWorld().max.z,this.onClickCallback=t.onClickCallback,this.initConfig=null,this.cloudMapManager=new e.Bimface.Plugins.Map.MapManager({viewer:t.viewer}),t.type){case"Relevance":default:this.associateModel(t);break;case"SetProfile":t.isProfile=!0,this.initConfig=t,this.setProfileHeight(t);break;case"AutoProfile":t.isProfile=!0,this.setProfileAutoHeight(t)}}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}init(){t.send("Bimface.Plugins.NavigationMap.NavigationMap","init");const i=this.getEventManager(),n=e.Bimface.Plugins.NavigationMap.NavigationMapEvent;let o=this.EventType;this.navigationMap.addEventListener(o.PICK_MOUSE_UP,(e=>{const t=e.data;this.onClickCallback&&this.onClickCallback(e.data),i.fireEvent(n.MouseClicked,t)})),this._initialized=!0,this._opt.successCallback&&this._opt.successCallback(),this.navigationMap.setSize(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight),this.initConfig&&(this.setProfileHeight(this.initConfig),this.initConfig=null),this.navigationMap.addEventListener(this.EventType.NavigationMap_Rect_Changed,(e=>{this.getEventManager().fireEvent("NavigationMapRectChanged",e.rectInfo)})),this.navigationMap.addEventListener(this.EventType.NavigationMap_Rect_Destroyed,(e=>{this.getEventManager().fireEvent("NavigationMapRectDestroyed",e)})),this.addEventListener("NavigationMapRectChanged",(e=>{this._updateToolBarByMinmapRect(e)})),this.addEventListener("NavigationMapRectDestroyed",(e=>{this.toolbar&&this.toolbar.hide()}))}associateModel(e){let{mapAnchors:t,modelAnchors:i,url:n,domElement:o}=e;o&&(this.mapContainer=o),i.point1=this._viewer.globalUnitUtil.translateVector(i.point1),i.point2=this._viewer.globalUnitUtil.translateVector(i.point2);const s=Math.min(i.point1.z,i.point2.z);this.getImageSize(n,(o=>{const r=[new THREE.Vector2(i.point1.x,i.point1.y),new THREE.Vector2(i.point2.x,i.point2.y)],a=[new THREE.Vector2(t.point1.x,t.point1.y),new THREE.Vector2(t.point2.x,t.point2.y)],l=this.maxHeight,h={modelAnchor:r,mapAnchor:a,zHeight:s,maxHeight:l};this._initialized?(this.navigationMap.clearZoomAndPan(),this.navigationMap.setAnchor(h)):(this.navigationMap=new Qt(this.viewer,this.mapContainer,h),this.navigationMap.registerCameraHeightChanged(y.EVENTS.ON_CAMERA_HEIGHT_CHANGED),this.init()),this.navigationMap.saveImageSize(o),this.update(n,e.isProfile)}))}setProfileHeight(e,t,i){let n={maxPixel:800};n.height=void 0===e.height?0:e.height,void 0===e.isProfile&&(e.isProfile=!0);let o=i=>{const o=this._viewer.globalUnitUtil.revertBBox(this.viewer.getBoundingBoxWorld());let s=o.min,r=o.max;s.z=r.z=n.height;const a={point1:s,point2:r};let l=new THREE.Vector3;o.getSize(l);const h=l.x/l.y;let d=n.maxPixel,c=n.maxPixel;const u=e.domElement||this._opt.domElement,g=e.isProfile,p=u&&u.getBoundingClientRect();if(p&&p.width&&p.height){const e=p.width/p.height,n=new Image;return n.onload=()=>{const i=n.width/n.height,o=document.createElement("canvas");let l=o.getContext("2d");if(e>i){o.height=n.height,o.width=n.height*e;const t=(o.width-n.width)/2,i=t*(r.x-s.x)/n.width;a.point1.x-=i,a.point2.x+=i,l.drawImage(n,t,0,n.width,n.height)}else{o.width=n.width,o.height=n.width/e;const t=(o.height-n.height)/2,i=t*(r.y-s.y)/n.height;a.point1.y-=i,a.point2.y+=i,l.drawImage(n,0,t,n.width,n.height)}const h=o.toDataURL("image/png");let d=new THREE.Vector2(0,o.height),c=new THREE.Vector2(o.width,0);const p={modelAnchors:a,mapAnchors:{point1:d,point2:c},url:h,domElement:u,isProfile:g};this.associateModel(p),t&&t()},void(n.src=i)}h>1?c/=h:d*=h;let m=new THREE.Vector2(0,c),f=new THREE.Vector2(d,0);const w={modelAnchors:a,mapAnchors:{point1:m,point2:f},url:i,domElement:u,isProfile:g};this.associateModel(w),t&&t()};n.successCallback=o,this.cloudMapManager.removeCreateMapEvent();let s=JSON.parse(JSON.stringify(n));s.height=this._viewer.globalUnitUtil.translate(s.height),s.successCallback=o,this.cloudMapManager.createMapByHeight(s)}setProfileAutoHeight(e,t,i){let n={maxPixel:800};n.height=void 0===e.height?0:e.height;let o=i=>{const o=this._viewer.globalUnitUtil.revertBBox(this.viewer.getBoundingBoxWorld());let s=o.min,r=o.max;s.z=r.z=n.height;const a={point1:s,point2:r};let l=new THREE.Vector3;o.getSize(l);const h=l.x/l.y;let d=n.maxPixel,c=n.maxPixel;h>1?c/=h:d/=h;const u={modelAnchors:a,mapAnchors:{point1:new THREE.Vector2(0,c),point2:new THREE.Vector2(d,0)},url:i,domElement:e.domElement,isProfile:e.isProfile};this.associateModel(u),t&&t()};n.successCallback=o;let s=JSON.parse(JSON.stringify(n));s.height=this._viewer.globalUnitUtil.translate(s.height),s.successCallback=o,this.cloudMapManager.createMapByCamera(n),this.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CAMERA_CHANGED_AND_RENDERED})}getImageSize(e,t){let i=document.createElement("img");i.onload=()=>{t({width:i.width,height:i.height})},i.onerror=()=>{this._opt.failureCallback&&this._opt.failureCallback()},i.src=e}update(e,t){this.navigationMap.updateUrl(e,t),this.navigationMap.destroy(),this.navigationMap.rebuildData(),this.navigationMap.render()}destroy(){this._opt.viewer.getViewer().removeCallbacks("render",this.renderCB),this.cloudMapManager.destroy(),this.navigationMap.destroy(),this.navigationMap.destroyEditor(),this.mapContainer.innerHTML=""}resize(e,t){var i=this._opt.domElement;i.style.width=e+"px",i.style.height=t+"px",this.navigationMap.resize(e,t),this.getEventManager().fireEvent("Resize",{width:e,height:t})}_clearState(){let e=this._opt.viewer,t=e._sectionBox;t&&t.exit(),e.restoreDefault()}_clearSectionBox(){let e=this._opt.viewer._sectionBox;e&&e.reset()}_updateSectionBox(t){let i=this._opt.viewer,n=i._sectionBox;if(!n){let t=new e.Bimface.Plugins.Section.SectionBoxConfig;t.viewer=i,t.id="SectionBox",n=new e.Bimface.Plugins.Section.SectionBox(t)}n.setBox(t),i.zoomToBoundingBox(t),i.render()}_updateToolBarByMinmapRect(t){const i=this._opt.domElement;let n=this._opt.viewer;if(this.toolbar)this.toolbar.show();else{let t=new e.Bimface.UI.Button.ButtonConfig;t.id="mapIsolate",t.title=BimfaceLanguage.bf_panel_map_isolation,t.className="bf-map-button bf-map-isolate";let o=new e.Bimface.UI.Button.Button(t);o.setHtml(BimfaceLanguage.bf_panel_map_isolation),o.setStyle({cursor:"default"}),o.addEventListener("Click",(()=>{this._clearState();let t=this.navigationMap.getBoundingBox();t=this._viewer.globalUnitUtil.revertBBox(t),n.isolateByBox(t,e.Bimface.Viewer.IsolateOption.HideOthers),n.zoomToBoundingBox(t),this.navigationMap.clearRectPick(),this.toolbar.hide(),n.render()}));let s=new e.Bimface.UI.Button.ButtonConfig;s.id="mapSection",s.title=BimfaceLanguage.bf_panel_map_section,s.className="bf-map-button bf-map-section";let r=new e.Bimface.UI.Button.Button(s);r.setHtml(BimfaceLanguage.bf_panel_map_section),r.setStyle({cursor:"default"}),r.addEventListener("Click",(()=>{this._clearState();let e=this.navigationMap.getBoundingBox();e=this._viewer.globalUnitUtil.revertBBox(e),this._clearSectionBox(),this._updateSectionBox(e),this.navigationMap.clearRectPick(),this.toolbar.hide(),n.render()}));let a=new e.Bimface.UI.Button.ButtonConfig;a.id="mapCancel",a.title=BimfaceLanguage.bf_general_cancel,a.className="bf-map-button bf-map-cancel";let l=new e.Bimface.UI.Button.Button(a);l.setHtml(BimfaceLanguage.bf_general_cancel),l.setStyle({cursor:"default"}),l.addEventListener("Click",(e=>{this.navigationMap.clearRectPick(),this.toolbar.hide()})),l.addEventListener("mousedown",(e=>{e.preventDefault(),e.stopPropagation()}));let h=new e.Bimface.UI.Toolbar.ToolbarConfig;h.className="bf-map-toolbar",this.toolbar=new e.Bimface.UI.Toolbar.Toolbar(h),this.toolbar.addControls([o,r,l]),this.toolbar.element.style.zIndex=11,i.appendChild(this.toolbar.element)}i.offsetWidth;const o=i.offsetHeight,s=this.toolbar.element.offsetWidth,r=this.toolbar.element.offsetHeight;t.x+t.width<s?this.toolbar.element.style.left=t.x+"px":this.toolbar.element.style.left=t.x+t.width-s+"px",o<t.y+t.height+r?this.toolbar.element.style.top=t.y+t.height-r-6+"px":this.toolbar.element.style.top=t.y+t.height+6+"px",(this.toolbar.element.offsetLeft+this.toolbar.element.offsetWidth>this._opt.domElement.offsetWidth||this.toolbar.element.offsetTop+this.toolbar.element.offsetHeight>this._opt.domElement.offsetHeight||this.toolbar.element.offsetLeft<0||this.toolbar.element.offsetTop<0)&&this.toolbar.hide()}}}(),function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap");i.MapViewer=class{constructor(i){t.send("Bimface.Plugins.NavigationMap.MapViewer","bf_c_newMapViewer"),this.domElement=i.domElement,this.eventManager=new e.Web.Lang.EventManager,P(this)}destroy(){}addEventListener(e,t){this.eventManager.addEvent(e,t)}removeEventListener(e,t){this.eventManager.getEventManager().removeEvent(e,t)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.NavigationMap").MapViewerConfig=class{constructor(){this.console=new e.Web.Common.Console,this.console.obsolete("The Class 'Glodon.Bimface.Plugins.NavigationMap.MapViewer'","Glodon.Bimface.Plugins.NavigationMapConfig.domElement",!1),this.map=null,this.domElement=[]}};var Jt=function(e,t){return Jt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},Jt(e,t)};function ei(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}Jt(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var ti,ii,ni=function(){function e(){this.faceDefaultColor=14936556,this.wireframeDefaultColor=13421772,this.faceHighlightColor=12255212,this.wireframeHighlightColor=3330982}return e.prototype.createMesh=function(e){for(var t=new THREE.BufferGeometry,i=e.length-2,n=new Uint32Array(3*i),o=0,s=1;s<=i;s++)n[o++]=0,n[o++]=s,n[o++]=s+1;for(var r=new THREE.MeshBasicMaterial({color:this.faceDefaultColor,side:THREE.DoubleSide}),a=new Float32Array(3*e.length),l=0;l<e.length;l++)a[3*l]=e[l].x,a[3*l+1]=e[l].y,a[3*l+2]=e[l].z;t.setAttribute("position",new THREE.Float32BufferAttribute(a,3)),t.setIndex(new THREE.BufferAttribute(n,1));var h=new THREE.Mesh(t,r);return h.componentId=this.componentId,h},e.prototype.createWireframe=function(e){for(var t=new THREE.LineGeometry,i=[],n=0;n<e.length;n++){var o=e[n];i.push(o.x,o.y,o.z)}t.setPositions(i);var s=new THREE.LineMaterial({color:this.wireframeDefaultColor,linewidth:1});s.resolution.set(160,160);var r=new THREE.Line2(t,s);return r.componentId=this.componentId,r},e.prototype.getMesh=function(){return this.mesh},e.prototype.getWireframe=function(){return this.wireframeMesh},e.prototype.transparent=function(e){e.material&&(e.material.transparent=!0,e.material.opacity=0)},e.prototype.opaque=function(e){e.material&&(e.material.transparent=!1,e.material.opacity=1)},e.prototype.getId=function(){return this.componentId},e}(),oi=function(e){function t(t,i,n){var o=e.call(this)||this;return o.highlightWidth=3,o.width=15,o.vertices=t,o.indices=i,o.componentId=n,o.highlightWireframeMesh=null,o.testWireframe=null,o.build(),o}return ei(t,e),t.prototype.build=function(){var e=this.indices[0],t=this.indices[1],i=this.vertices[e],n=this.vertices[t],o=i.clone().add(n).multiplyScalar(.5).clone().multiplyScalar(-1),s=o.clone().normalize(),r=[],a=n.clone().sub(i).normalize(),l=i.clone().add(a.clone().multiplyScalar(20)),h=i.clone().add(a.clone().multiplyScalar(80)),d=[];if(0!==o.x){var c=o.x>0?this.width:-this.width;d.push((new THREE.Vector3).setX(c).add(s))}if(0!==o.y){var u=o.y>0?this.width:-this.width;d.push((new THREE.Vector3).setY(u).add(s))}if(0!==o.z){var g=o.z>0?this.width:-this.width;d.push((new THREE.Vector3).setZ(g).add(s))}2===d.length&&(r.push(l.clone().add(s)),r.push(l.clone().add(d[0])),r.push(h.clone().add(d[0])),r.push(h.clone().add(s)),r.push(h.clone().add(d[1])),r.push(l.clone().add(d[1]))),this.mesh=this.createMesh(r),this.transparent(this.mesh),this.wireframeMesh=this.createWireframe([l,h]),this.highlightWireframeMesh=this.createHighlightWireframe([l.sub(s),h.sub(s)])},t.prototype.createHighlightWireframe=function(e){for(var t=[],i=0;i<e.length;i++){var n=e[i];t.push(n.x,n.y,n.z)}var o=new THREE.LineGeometry;o.setPositions(t);var s=new THREE.LineMaterial({color:this.wireframeHighlightColor,linewidth:this.highlightWidth,dashed:!1});s.resolution.set(160,160);var r=new THREE.Line2(o,s);return r.computeLineDistances(),r.scale.set(1,1,1),r.visible=!1,r.renderOrder=100,r},t.prototype.getTestWireframe=function(){return this.testWireframe},t.prototype.getHighlightWireframeMesh=function(){return this.highlightWireframeMesh},t.prototype.highlight=function(){this.highlightWireframeMesh.visible=!0,this.highlightWireframeMesh.renderOrder=100},t.prototype.cancelHighlight=function(){this.highlightWireframeMesh.visible=!1},t}(ni),si=function(e){function t(t,i){var n=e.call(this)||this;return n.length=20,n.vertex=t,n.cornerFace=null,n.cornerWireframe=null,n.componentId=i,n.cornerVertices=null,n.build(),n}return ei(t,e),t.prototype.build=function(){var e=[],t=this.vertex.clone(),i=t.clone().multiplyScalar(-1);e.push(t);var n=this.vertex.clone(),o=i.x>0?this.length:-this.length;n.x+=o,e.push(n);var s=this.vertex.clone(),r=i.y>0?this.length:-this.length;s.y+=r,e.push(s);var a=this.vertex.clone(),l=i.z>0?this.length:-this.length;a.z+=l,e.push(a),this.cornerVertices=e,this.mesh=this.createMesh([n,s,a]),this.wireframeMesh=this.createWireframe([n,s,a,n]),this.buildCornerFace(),this.buildCornerWireframe()},t.prototype.highlight=function(){this.wireframeMesh.material.color.setHex(this.wireframeHighlightColor),this.wireframeMesh.renderOrder=100,this.mesh.material.color.setHex(this.faceHighlightColor),this.cornerFace.material.color.setHex(this.faceHighlightColor),this.cornerFace.material.transparent=!0,this.cornerFace.material.opacity=.5,this.cornerWireframe.material.color.setHex(this.wireframeHighlightColor),this.cornerWireframe.visible=!0},t.prototype.cancelHighlight=function(){this.wireframeMesh.material.color.setHex(this.wireframeDefaultColor),this.wireframeMesh.renderOrder=0,this.mesh.material.color.setHex(this.faceDefaultColor),this.transparent(this.cornerFace),this.cornerWireframe.visible=!1},t.prototype.buildCornerFace=function(){if(!this.cornerFace){var e=this.cornerVertices;e.push(e[1]),this.cornerFace=this.createMesh(e),this.transparent(this.cornerFace)}},t.prototype.getCornerFace=function(){return this.cornerFace},t.prototype.getCornerWireframe=function(){return this.cornerWireframe},t.prototype.buildCornerWireframe=function(){if(!this.cornerWireframe){for(var e=[],t=1;t<this.cornerVertices.length;t++){var i=this.cornerVertices[0],n=this.cornerVertices[t];e.push(i,n)}this.cornerWireframe=this.createWireframe(e),this.cornerWireframe.visible=!1}},t}(ni),ri=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.length=60,s.vertices=t,s.indices=i,s.componentId=n,s.vertexUvs=null,s.texture=o,s.highlightMesh=null,s.wireframeMesh=null,s.vertexUvs=[],s.vertexUvs.push(new THREE.Vector2(0,.2)),s.vertexUvs.push(new THREE.Vector2(0,.8)),s.vertexUvs.push(new THREE.Vector2(.2,1)),s.vertexUvs.push(new THREE.Vector2(.8,1)),s.vertexUvs.push(new THREE.Vector2(1,.8)),s.vertexUvs.push(new THREE.Vector2(1,.2)),s.vertexUvs.push(new THREE.Vector2(.8,0)),s.vertexUvs.push(new THREE.Vector2(.2,0)),s.build(),s}return ei(t,e),t.prototype.build=function(){for(var e=[],t=null,i=null,n=0,o=this.indices.length;n<o;n++){var s=this.indices[n],r=this.indices[n+1];t=this.vertices[s],i=this.vertices[r],n===o-1&&(i=this.vertices[this.indices[0]]);var a=i.clone().sub(t).normalize(),l=t.clone().add(i).multiplyScalar(.5);e.push(l.clone().sub(a.clone().multiplyScalar(this.length/2))),e.push(l.clone().add(a.clone().multiplyScalar(this.length/2)))}this.createTexturedMesh(e);for(var h=new THREE.Box3,d=0;d<this.indices.length;d++){var c=this.indices[d];h.expandByPoint(this.vertices[c])}for(var u=h.getCenter(new THREE.Vector3).normalize(),g=[],p=0;p<e.length;p++){var m=e[p];g.push(m.clone().add(u))}this.highlightMesh=this.createMesh(g),this.highlightMesh.visible=!1,this.highlightMesh.isHighlightMesh=!0,g.push(g[0]),this.wireframeMesh=this.createWireframe(g)},t.prototype.highlight=function(){this.highlightMesh.visible=!0,this.highlightMesh.material.color.setHex(this.faceHighlightColor),this.highlightMesh.material.transparent=!0,this.highlightMesh.material.opacity=.5,this.wireframeMesh.material.color.setHex(this.wireframeHighlightColor)},t.prototype.cancelHighlight=function(){this.highlightMesh.visible=!1,this.wireframeMesh.material.color.setHex(this.wireframeDefaultColor)},t.prototype.createTexturedMesh=function(e){for(var t=e.length-2,i=new Uint32Array(3*t),n=0,o=1;o<=t;o++)i[n++]=0,i[n++]=o,i[n++]=o+1;for(var s=new THREE.BufferGeometry,r=new Float32Array(3*e.length),a=0;a<e.length;a++)r[3*a]=e[a].x,r[3*a+1]=e[a].y,r[3*a+2]=e[a].z;for(var l=new Float32Array(2*this.vertexUvs.length),h=0;h<this.vertexUvs.length;h++)l[2*h]=this.vertexUvs[h].x,l[2*h+1]=this.vertexUvs[h].y;s.setAttribute("position",new THREE.Float32BufferAttribute(r,3)),s.setAttribute("uv",new THREE.Float32BufferAttribute(l,2)),s.setIndex(new THREE.BufferAttribute(i,1));var d=new THREE.MeshBasicMaterial({map:this.texture,side:THREE.DoubleSide,transparent:!1});this.mesh=new THREE.Mesh(s,d),this.mesh.componentId=this.componentId},t.prototype.getHighlightMesh=function(){return this.highlightMesh},t.prototype.buildVertexUvs=function(e){var t=[],i=(new THREE.Box3).setFromPoints(e),n=i.min,o=new THREE.Vector2;i.getSize(o);for(var s=0==o.x?"x":0==o.y?"y":"z",r=0;r<e.length;r++){var a=e[r],l=(o.x+o.y+o.z)/2,h=a.clone().sub(n).multiplyScalar(1/l),d=new THREE.Vector2(h.x,h.y);"x"==s?d=new THREE.Vector2(h.y,h.z):"y"==s&&(d=new THREE.Vector2(h.x,h.z)),t.push(d)}return t},t}(ni),ai=function(e){function t(t,i,n){var o=e.call(this)||this;switch(n){case"X":o.wireframeDefaultColor=16722181;break;case"Y":o.wireframeDefaultColor=1647355;break;case"Z":o.wireframeDefaultColor=3330982}return o.width=0,o.vertices=t,o.indices=i,o.componentId=n,o.testWireframe=null,o.build(),o}return ei(t,e),t.prototype.build=function(){var e=this.indices[0],t=this.indices[1],i=this.vertices[e],n=this.vertices[t],o=i.clone().add(n).multiplyScalar(.5).clone().multiplyScalar(-1),s=o.clone().normalize(),r=[],a=n.clone().sub(i).normalize(),l=i.clone(),h=i.clone().add(a.clone().multiplyScalar(105)),d=[];if(0!==o.x){var c=o.x>0?this.width:-this.width;d.push((new THREE.Vector3).setX(c).add(s))}if(0!==o.y){var u=o.y>0?this.width:-this.width;d.push((new THREE.Vector3).setY(u).add(s))}if(0!==o.z){var g=o.z>0?this.width:-this.width;d.push((new THREE.Vector3).setZ(g).add(s))}2===d.length&&(r.push(l.clone().add(s)),r.push(l.clone().add(d[0])),r.push(h.clone().add(d[0])),r.push(h.clone().add(s)),r.push(h.clone().add(d[1])),r.push(l.clone().add(d[1]))),this.mesh=this.createMesh(r),this.transparent(this.mesh),this.wireframeMesh=this.createWireframe([l,h]);var p=i.clone().add(a.clone().multiplyScalar("Z"==this.componentId?125:120));this.createTextWireframe(p),this.hide()},t.prototype.createWireframe=function(e){for(var t=new THREE.LineGeometry,i=[],n=0;n<e.length;n++){var o=e[n];i.push(o.x,o.y,o.z)}t.setPositions(i);var s=new THREE.LineMaterial({color:this.wireframeDefaultColor,linewidth:2});s.resolution.set(160,160);var r=new THREE.Line2(t,s);r.componentId=this.componentId;var a=new THREE.LineMaterial({color:this.wireframeDefaultColor,linewidth:2,depthTest:!0,transparent:!0,opacity:.3,depthFunc:THREE.GreaterDepth});a.resolution.set(160,160);var l=new THREE.Line2(t,a);return this.wireframeMeshBack=l,r},t.prototype.createTextWireframe=function(e){var t=document.createElement("canvas"),i=t.getContext("2d"),n='32px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",SimSun, sans-serif';i.font=n;var o=i.measureText(this.componentId.toString()),s=o.width,r=o.actualBoundingBoxAscent;t.width=64,t.height=64,i.font=n,i.fillStyle={X:"#FF2905",Y:"#1922FB",Z:"#32D3A6"}[this.componentId.toString()],i.fillText(this.componentId.toString(),(64-s)/2,(64+r)/2);var a=new THREE.CanvasTexture(t),l=new THREE.SpriteMaterial({map:a}),h=new THREE.Sprite(l);h.position.set(e.x,e.y,e.z),h.scale.set(45,45,45),h.renderOrder=100,this.textMesh=h;var d=new THREE.SpriteMaterial({map:a,transparent:!0,opacity:.3,depthFunc:THREE.GreaterDepth}),c=new THREE.Sprite(d);c.position.set(e.x,e.y,e.z),c.scale.set(45,45,45),c.renderOrder=100,this.textMeshBack=c},t.prototype.show=function(){this.mesh.visible=!0,this.wireframeMesh.visible=!0,this.wireframeMeshBack.visible=!0,this.textMesh.visible=!0,this.textMeshBack.visible=!0},t.prototype.hide=function(){this.mesh.visible=!1,this.wireframeMesh.visible=!1,this.wireframeMeshBack.visible=!1,this.textMesh.visible=!1,this.textMeshBack.visible=!1},t.prototype.getTestWireframe=function(){return this.testWireframe},t.prototype.getWireframeMeshBack=function(){return this.wireframeMeshBack},t.prototype.getTextMesh=function(){return this.textMesh},t.prototype.getTextMeshBack=function(){return this.textMeshBack},t.prototype.highlight=function(){},t.prototype.cancelHighlight=function(){},t}(ni),li=function(){function e(e,t){this.languageType=e,this.initialize(),this.scene=new THREE.Scene,this.callback=t,this.buildEdges(),this.buildCorners(),this.buildFaces(),this.buildArrows()}return e.prototype.initialize=function(){this.enumViewMode={2673:"Top",4015:"Bottom","0231":"Front",5764:"Back",1375:"Right",4620:"Left",3:"RoofSouthEast",2:"RoofSouthWest",7:"RoofNorthEast",6:"RoofNorthWest",1:"BottomSouthEast",0:"BottomSouthWest",4:"BottomNorthWest",5:"BottomNorthEast",32:"RoofFront",76:"RoofBack",37:"RoofRight",26:"RoofLeft","01":"BottomFront",45:"BottomBack",15:"BottomRight","04":"BottomLeft",13:"SouthEast",20:"SouthWest",57:"NorthEast",64:"NorthWest"},this.length=100,this.vertices=[],this.vertexIds=[],this.edgeIds=[],this.edgeIndices=[],this.faceIds=[],this.faceIndices=[],this.componentList=[],this.texturesLoaded=0;var e=this.length;this.vertices.push(new THREE.Vector3(-e/2,-e/2,e/2)),this.vertices.push(new THREE.Vector3(e/2,-e/2,e/2)),this.vertices.push(new THREE.Vector3(-e/2,e/2,e/2)),this.vertices.push(new THREE.Vector3(e/2,e/2,e/2)),this.vertices.push(new THREE.Vector3(-e/2,-e/2,-e/2)),this.vertices.push(new THREE.Vector3(e/2,-e/2,-e/2)),this.vertices.push(new THREE.Vector3(-e/2,e/2,-e/2)),this.vertices.push(new THREE.Vector3(e/2,e/2,-e/2));for(var t=0;t<8;t++)this.vertexIds.push(t+"");this.edgeIndices.push([0,1],[1,3],[3,2],[2,0]),this.edgeIndices.push([0,4],[1,5],[2,6],[3,7]),this.edgeIndices.push([4,5],[5,7],[7,6],[6,4]);for(t=0;t<12;t++){var i=this.edgeIndices[t];this.edgeIds.push(i[0]+""+i[1])}this.faceIndices.push([0,2,3,1]),this.faceIndices.push([4,0,1,5]),this.faceIndices.push([4,6,2,0]),this.faceIndices.push([2,6,7,3]),this.faceIndices.push([1,3,7,5]),this.faceIndices.push([5,7,6,4]);for(t=0;t<6;t++){var n=this.faceIndices[t];this.faceIds.push(n[0]+""+n[1]+n[2]+n[3])}},e.prototype.buildFaces=function(){for(var e=this.vertices,t=this.faceIndices,i=this.faceIds,n=function(n){var s=window.BimfaceLoaderConfig.fullStaticHost+"/textures/"+o.languageType+"/"+o.enumViewMode[i[n]]+".png",r=new THREE.TextureLoader;r.setCrossOrigin("anonymous");var a=o;r.load(s,(function(o){o.colorSpace=THREE.SRGBColorSpace;var s=new ri(e,t[n],i[n],o);a.componentList.push(s),a.scene.add(s.getMesh()),a.scene.add(s.getWireframe()),a.scene.add(s.getHighlightMesh()),6==++a.texturesLoaded&&a.callback&&a.callback()}))},o=this,s=0;s<6;s++)n(s)},e.prototype.buildEdges=function(){for(var e=this.vertices,t=this.edgeIndices,i=this.edgeIds,n=0;n<12;n++){var o=new oi(e,t[n],i[n]);this.componentList.push(o),this.scene.add(o.getMesh()),this.scene.add(o.getWireframe()),this.scene.add(o.getHighlightWireframeMesh())}},e.prototype.buildCorners=function(){for(var e=this.vertices,t=this.vertexIds,i=0;i<8;i++){var n=new si(e[i],t[i]);this.componentList.push(n),this.scene.add(n.getMesh()),this.scene.add(n.getWireframe()),this.scene.add(n.getCornerFace()),this.scene.add(n.getCornerWireframe())}},e.prototype.buildArrows=function(){var e=[],t=this.length+10;e.push(new THREE.Vector3(-t/2,-t/2,t/2)),e.push(new THREE.Vector3(t/2,-t/2,t/2)),e.push(new THREE.Vector3(-t/2,-t/2,-t/2)),e.push(new THREE.Vector3(-t/2,t/2,t/2));for(var i=[[0,1],[0,2],[0,3]],n=["X","Y","Z"],o=0;o<3;o++){var s=new ai(e,i[o],n[o]);this.componentList.push(s),this.scene.add(s.getMesh()),this.scene.add(s.getWireframe()),this.scene.add(s.getWireframeMeshBack()),this.scene.add(s.getTextMesh()),this.scene.add(s.getTextMeshBack())}},e.prototype.getComponent=function(e){for(var t=0;t<this.componentList.length;t++){var i=this.componentList[t];if(i.getId()==e)return i}return null},e.prototype.transparentCorners=function(){},e.prototype.opaqueCorners=function(){},e.prototype.getScene=function(){return this.scene},e.prototype.getMeshes=function(){for(var e=[],t=this.scene.children,i=0;i<t.length;i++){var n=t[i];"Mesh"===n.type&&!0!==n.isHighlightMesh&&e.push(n)}return e},e.prototype.destroy=function(){this.scene=null,this.vertices=null,this.vertexIds=null,this.edgeIds=null,this.edgeIndices=null,this.faceIds=null,this.faceIndices=null,this.componentList=null,this.enumViewMode=null},e}(),hi=function(){function e(e,t){this.container=e,this.bimCubeData=t,this.activeCamera=new THREE.OrthographicCamera(-120,120,120,-120,.01,500),this.activeCamera.position.set(0,0,200),this.activeScene,this.initialize(),this.cameraTarget=new THREE.Vector3(0,0,0)}return e.prototype.initialize=function(){var e,t;this.renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),this.container.appendChild(this.renderer.domElement),"none"==this.container.style.display?(e=this.container.style.width.replace("px",""),t=this.container.style.height.replace("px","")):(e=this.container.offsetWidth,t=this.container.offsetHeight),this.renderer.setSize(e,t)},e.prototype.switchCameraType=function(e){},e.prototype.getActiveCamera=function(){return this.activeCamera},e.prototype.setActiveScene=function(e){this.activeScene=e},e.prototype.render=function(e){e&&(this.activeCamera.position.copy(new THREE.Vector3(0,0,200).applyQuaternion(e.quaternion)),this.activeCamera.up.copy(e.up),this.activeCamera.lookAt(this.cameraTarget),this.activeCamera.updateMatrixWorld());var t=this.activeScene||this.bimCubeData.getScene();this.renderer.autoClear=!0,this.renderer.render(t,this.activeCamera)},e.prototype.destroy=function(){this.container.removeChild(this.renderer.domElement),this.container=null,this.renderer.dispose(),this.renderer=null,this.activeScene=null,this.bimCubeData=null,this.activeCamera=null},e.enumTypes={PERSPECTIVE:1e3,ORTHOGRAPHIC:1001},e}(),di=function(){function e(){this.eventDispatcher=new THREE.EventDispatcher}return e.prototype.addEventListener=function(e,t){this.eventDispatcher.addEventListener(e,t)},e.prototype.hasEventListener=function(e){this.eventDispatcher.hasEventListener(e)},e.prototype.removeEventListener=function(e,t){this.eventDispatcher.removeEventListener(e,t)},e.prototype.dispatchEvent=function(e){this.eventDispatcher.dispatchEvent(e)},e.enumTypes={ON_COMPONENT_HOVER:1e3,ON_COMPONENT_CLICK:1001},e}(),ci=function(){function e(e,t,i){this.eventManager=new di,this.container=e,this.bimCubeData=t,this.bimCubeView=i,this.initialize()}return e.prototype.initialize=function(){this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this);var e=this.container;e.addEventListener("mousemove",this.onMouseMoveBinded,!1),e.addEventListener("mousedown",this.onMouseDownBinded,!1),this.raycaster=new THREE.Raycaster,this.lastHoverComponentId=null,this.bMouseDown=!1,this.mouseDownPos=null,this.doubleClickFlag=!1},e.prototype.onMouseDown=function(e){this.bMouseDown=!0,this.mouseDownPos=new THREE.Vector2(e.offsetX,e.offsetY),window.addEventListener("mouseup",this.onMouseUpBinded,!1)},e.prototype.onMouseMove=function(e){if(!this.bMouseDown){var t={x:e.offsetX,y:e.offsetY},i=this.canvasToNormalized(t),n=this.hitTest(i),o=this.lastHoverComponentId;if(n){if(n!=this.lastHoverComponentId)this.bimCubeData.getComponent(n).highlight(),this.bimCubeView.render(),this.lastHoverComponentId=n}else this.lastHoverComponentId=null;if(o&&n!=o)this.bimCubeData.getComponent(o).cancelHighlight(),this.bimCubeView.render()}},e.prototype.onMouseUp=function(e){if(window.removeEventListener("mouseup",this.onMouseUpBinded),0!=this.bMouseDown){var t=this;if(0==this.doubleClickFlag){this.doubleClickFlag=!0,setTimeout((function(){t.doubleClickFlag=!1}),1e3),this.bMouseDown=!1;var i=new THREE.Vector2(e.offsetX,e.offsetY);if(i.x==this.mouseDownPos.x&&i.y==this.mouseDownPos.y){var n={x:e.offsetX,y:e.offsetY},o=this.canvasToNormalized(n),s=this.hitTest(o);if(s){if(this.lastHoverComponentId)this.bimCubeData.getComponent(this.lastHoverComponentId).cancelHighlight(),this.lastHoverComponentId=null,this.bimCubeView.render();var r={type:di.enumTypes.ON_COMPONENT_CLICK,componentId:s,viewType:this.bimCubeData.enumViewMode[s]};this.eventManager.dispatchEvent(r)}}}else this.bMouseDown=!1}},e.prototype.canvasToNormalized=function(e){var t=this.container.offsetWidth,i=this.container.offsetHeight,n={x:0,y:0};return n.x=e.x/t*2-1,n.y=-e.y/i*2+1,n},e.prototype.hitTest=function(e){var t=this.bimCubeView.getActiveCamera();this.raycaster.setFromCamera(e,t);var i=this.bimCubeData.getMeshes(),n=this.raycaster.intersectObjects(i,!0);if(0!=n.length){var o=n[0].object.componentId;if(n.length>=2){var s=n[1].object.componentId;4==o.length&&2==s.length&&n[1].distance<n[0].distance+5&&(o=s)}return o}},e.prototype.addEventListener=function(e,t){this.eventManager.addEventListener(e,t)},e.prototype.destroy=function(){window.removeEventListener("mouseup",this.onMouseUpBinded),this.container.removeEventListener("mousemove",this.onMouseMoveBinded),this.container.removeEventListener("mousedown",this.onMouseDownBinded),this.container=null,this.eventManager=null,this.bimCubeData=null,this.bimCubeView=null,this.onMouseDownBinded=null,this.onMouseUpBinded=null,this.onMouseMoveBinded=null,this.raycaster=null,this.lastHoverComponentId=null,this.mouseDownPos=null},e}(),ui=function(){function e(e,t,i){this.callback=i,this.functionsUnexecuted=[];var n=this;this.bimCubeData=new li(t,(function(){n.bimCubeView=new hi(e,n.bimCubeData),n.bimCubeEditor=new ci(e,n.bimCubeData,n.bimCubeView),n.callback&&n.callback(),n.applyFunctionsUnexecuted()}))}return e.prototype.applyFunctionsUnexecuted=function(){for(var e=this.functionsUnexecuted,t=0;t<e.length;t++){switch(e[t]){case"show":this.show();break;case"hide":this.hide();break;case"showCoordinateSystem":this.showCoordinateSystem();break;case"hideCoordinateSystem":this.hideCoordinateSystem()}}this.functionsUnexecuted=[]},e.prototype.switchCameraType=function(e){this.bimCubeView.switchCameraType(e)},e.prototype.addEventListener=function(e,t){this.bimCubeEditor.addEventListener(e,t)},e.prototype.show=function(){if(this.bimCubeView){var e=this.bimCubeData.getScene();this.bimCubeView.setActiveScene(e),this.bimCubeView.render()}else this.functionsUnexecuted.push("show")},e.prototype.hide=function(){if(this.bimCubeView){var e=new THREE.Scene;this.bimCubeView.setActiveScene(e),this.bimCubeView.render()}else this.functionsUnexecuted.push("hide")},e.prototype.showCoordinateSystem=function(){this.bimCubeView?(this.bimCubeData.getComponent("X").show(),this.bimCubeData.getComponent("Y").show(),this.bimCubeData.getComponent("Z").show(),this.bimCubeView.render()):this.functionsUnexecuted.push("showCoordinateSystem")},e.prototype.hideCoordinateSystem=function(){this.bimCubeView?(this.bimCubeData.getComponent("X").hide(),this.bimCubeData.getComponent("Y").hide(),this.bimCubeData.getComponent("Z").hide(),this.bimCubeView.render()):this.functionsUnexecuted.push("hideCoordinateSystem")},e.prototype.update=function(e){this.bimCubeView.render(e)},e.prototype.destroy=function(){this.bimCubeData&&this.bimCubeData.destroy(),this.bimCubeData=null,this.bimCubeEditor&&this.bimCubeEditor.destroy(),this.bimCubeEditor=null,this.bimCubeView&&this.bimCubeView.destroy(),this.bimCubeView=null,this.callback=null,this.functionsUnexecuted=null},e}();!function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");t.ViewHouseNavi=class{constructor(e,t){this.viewer=e.getViewer(),this.enumEventTypes={ON_COMPONENT_HOVER:1e3,ON_COMPONENT_CLICK:1001},this.initialize();var i=this;this.bimcube=new ui(t,BimfaceLanguage.name,(function(){i.hookEvents(),i.bimcube.update(i.viewer.getActiveCameraInfo())}))}initialize(){this.enumViewMode={Home:0,Top:1,Bottom:2,Front:3,Back:4,Right:5,Left:6,SouthEast:7,SouthWest:8,NorthEast:9,NorthWest:10,BottomFront:11,BottomBack:12,BottomRight:13,BottomLeft:14,BottomSouthEast:15,BottomSouthWest:16,BottomNorthEast:17,BottomNorthWest:18,RoofFront:19,RoofBack:20,RoofRight:21,RoofLeft:22,RoofSouthEast:23,RoofSouthWest:24,RoofNorthEast:25,RoofNorthWest:26,TopTurnRight:27,TopTurnBack:28,TopTurnLeft:29,BottomTurnRight:30,BottomTurnBack:31,BottomTurnLeft:32,FrontTurnRight:33,FrontTurnTop:34,FrontTurnLeft:35,RightTurnBack:36,RightTurnTop:37,RightTurnFront:38,BackTurnRight:39,BackTurnTop:40,BackTurnLeft:41,LeftTurnFront:42,LeftTurnTop:43,LeftTurnBack:44}}hookEvents(){var e=this.bimcube,t=this.viewer,i=this.enumViewMode,n=function(){t.render()};e.addEventListener(this.enumEventTypes.ON_COMPONENT_CLICK,(function(e){var o=i[e.viewType];o&&t.setStandardView(o,null,n,n)})),t.addRenderCallback((function(){e.update(t.getActiveCameraInfo())}))}setVisible(e){!0===e?this.bimcube.show():this.bimcube.hide()}setCoordinateSystemVisible(e){!0===e?this.bimcube.showCoordinateSystem():this.bimcube.hideCoordinateSystem()}getImpl(){return this.bimcube}destroy(){this.viewer=null,this.enumEventTypes=null,this.enumViewMode=null,this.bimcube.destroy(),this.bimcube=null}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").ViewHouseConfig=function(){return{width:150,height:150,domElement:null,viewer:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Application.UI.Menu").ViewHouseMenu=function(t){var i=this,n=t.viewer;this.viewer=n;var o=t.domElement,s=e.Bimface.UI.Control.ControlEvent,r=e.Bimface.Viewer.Viewer3DEvent,a=n.getDomElement(),l=new e.Bimface.UI.Menu.MenuConfig;l.element=o,this.menu=new e.Bimface.UI.Menu.Menu(l),this.menu.element.style.backgroundColor="#EBEFF1",this.menu.element.style.border="1px solid #D0D6D6";var h=this.menu,d=new e.Bimface.UI.Menu.MenuItemConfig;d.id="home";var c=new e.Bimface.UI.Menu.MenuItem(d);function u(){i.switchHomeView()}function g(){i.switchHomeView(),i.hide()}c.setText(BimfaceLanguage.bf_viewHouse_home),c.element.addClass("bf-menu-item1"),n.getEventManager().addEvent(r.ToolbarHomeClick,u),c.addEventListener(s.Click,g),this.switchHomeView=function(){var e=n.getCustomHomeview(),t=n.getDefaultHomeview(),i=e||t,o=n.getCameraStatus().name;i.name=o,"orth"==o&&m.setText(BimfaceLanguage.bf_viewHouse_perspective),"persp"==o&&m.setText(BimfaceLanguage.bf_viewHouse_orthographic),n.setCameraStatus(i,(function(){0==n.getCameraAnimation()&&n.render()}))};var p=new e.Bimface.UI.Menu.MenuItemConfig;p.id="orthographic";var m=new e.Bimface.UI.Menu.MenuItem(p);function f(){i.hide(),m.element.textContent==BimfaceLanguage.bf_viewHouse_orthographic?(n.setCameraType("OrthographicCamera"),n.render(),m.setText(BimfaceLanguage.bf_viewHouse_perspective)):(n.setCameraType("PerspectiveCamera"),n.render(),m.setText(BimfaceLanguage.bf_viewHouse_orthographic))}m.setText(BimfaceLanguage.bf_viewHouse_orthographic),m.element.addClass("bf-menu-item1"),m.addEventListener(s.Click,f),this.orthographic=m;var w=new e.Bimface.UI.Menu.MenuItemConfig;w.id="setAsHome";var y=new e.Bimface.UI.Menu.MenuItem(w);function v(){i.hide();var e=n.getCameraStatus();n.recordCustomHomeview(e)}y.setText(BimfaceLanguage.bf_viewHouse_setAsHome),y.element.addClass("bf-menu-item1"),y.addEventListener(s.Click,v);var b=new e.Bimface.UI.Menu.MenuItemConfig;b.id="resetHome";var E=new e.Bimface.UI.Menu.MenuItem(b);function M(){i.hide(),n.recordCustomHomeview(null)}E.setText(BimfaceLanguage.bf_viewHouse_resetHome),E.element.addClass("bf-menu-item1"),E.addEventListener(s.Click,M);var C=new e.Bimface.UI.Menu.Spacer;C.element.style.backgroundColor="#D0D6D6";var x=new e.Bimface.UI.Menu.Spacer;function T(e){h&&i.hide()}x.element.style.backgroundColor="#D0D6D6",this.menu.addControl(c),this.menu.addControl(C),this.menu.addControl(m),this.menu.addControl(x),this.menu.addControl(y),this.menu.addControl(E),this.hide=function(){this.menu.element.style.display="none"},this.show=function(){this.menu.element.style.display=""},this.isHide=function(){return"none"==this.menu.element.style.display},this.update=function(){var e=this.viewer.getCameraStatus().name;"orth"==e&&this.orthographic.setText(BimfaceLanguage.bf_viewHouse_perspective),"persp"==e&&this.orthographic.setText(BimfaceLanguage.bf_viewHouse_orthographic)},this.destroy=function(){n.getEventManager().removeEvent(r.ToolbarHomeClick,u),c.removeEventListener(s.Click,g),m.removeEventListener(s.Click,f),y.removeEventListener(s.Click,v),E.removeEventListener(s.Click,M),a.removeEventListener("mousedown",T),this.viewer=null,this.menu=null,this.orthographic=null},a.addEventListener("mousedown",T)},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(e){var t=e,n=i.create("div","bf-house");n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,t.domElement.appendChild(n),this._domElement=n,this._opt=t,this.viewer=t.viewer,this.init()};n.prototype={init:function(){var t=this;this.viewHouseNavi=new e.Bimface.Plugins.ViewHouseNavi(this._opt.viewer,this._domElement);var n=i.createNS("svg","bf-home-svg");n.setAttribute("viewBox","0 0 20 20");var o=i.createNS("g","");o.setAttribute("fill","none"),o.setAttribute("fill-rule","evenodd");var s=i.createNS("polygon","");s.setAttribute("fill","#E3E9EC"),s.setAttribute("points","1.207 9.5 3.5 9.5 3.5 16.499 7.501 16.499 7.503 12.5 12.5 12.5 12.5 16.499 16.5 16.499 16.5 9.5 18.793 9.5 10 .707"),n.addEventListener("mouseover",(function(){s.setAttribute("fill","#BAFFEC"),r.setAttribute("fill","#32D3A6")})),n.addEventListener("mouseout",(function(){s.setAttribute("fill","#E3E9EC"),r.setAttribute("fill","#BCC0C2")})),n.addEventListener("mousedown",(function(){t.viewHouseMenu.switchHomeView()}));var r=i.createNS("path","");r.setAttribute("fill","#BCC0C2"),r.setAttribute("d","M10,0 L0,10 L3,10 L3,17 L8,17 L8.003,13.001 L12,13.001 L12,17 L17,17 L17,10 L20,10 L10,0 Z M10,1.414 L17.586,9 L17,9 L16,9 L16,10 L16,16 L13,16 L13,13.001 L13,12 L12,12 L8.003,12 L7.004,12 L7.003,12.999 L7.001,16 L4,16 L4,10 L4,9 L3,9 L2.414,9 L10,1.414 Z"),o.appendChild(s),o.appendChild(r),n.appendChild(o),t._domElement.appendChild(n),this.homeSvg=n;var a=i.createNS("svg","bf-menu-svg");a.setAttribute("viewBox","0 0 20 20"),a.style.position="absolute";var l=i.createNS("g","");l.setAttribute("fill","none"),l.setAttribute("fill-rule","evenodd"),l.setAttribute("transform","translate(3 6)");var h=i.createNS("polygon","");h.setAttribute("fill","#E3E9EC"),h.setAttribute("points","1.207 4.5 6.999 10.292 12.793 4.5");var d=i.createNS("path","");d.setAttribute("fill","#BCC0C2"),d.setAttribute("d","M0.0004,3.9998 L6.9994,10.9998 L13.9994,3.9998 L0.0004,3.9998 Z M2.4144,4.9998 L11.5864,4.9998 L6.9994,9.5858 L2.4144,4.9998 Z");var c=i.createNS("polygon","");c.setAttribute("fill","#E3E9EC"),c.setAttribute("points",".5 2.5 13.5 2.5 13.5 .5 .5 .5");var u=i.createNS("path","");u.setAttribute("fill","#BCC0C2"),u.setAttribute("d","M0,3 L14,3 L14,0 L0,0 L0,3 Z M1,2 L13,2 L13,1 L1,1 L1,2 Z"),a.addEventListener("mouseover",(function(){h.setAttribute("fill","#BAFFEC"),d.setAttribute("fill","#32D3A6"),c.setAttribute("fill","#BAFFEC"),u.setAttribute("fill","#32D3A6")})),a.addEventListener("mouseout",(function(){h.setAttribute("fill","#E3E9EC"),d.setAttribute("fill","#BCC0C2"),c.setAttribute("fill","#E3E9EC"),u.setAttribute("fill","#BCC0C2")})),l.appendChild(h),l.appendChild(d),l.appendChild(c),l.appendChild(u),a.appendChild(l),t._domElement.appendChild(a),this.menuSvg=a;var g=new e.Bimface.Application.UI.Menu.ViewHouseMenu(this._opt);this.viewHouseMenu=g,g.hide(),a.addEventListener("click",(function(e){t.viewer.getDomElement().getBoundingClientRect();g.isHide()?(g.update(),g.show()):g.hide()}))},enableViewHouse:function(e){this.viewHouseNavi.setVisible(e),this._domElement.style.display=!0===e?"block":"none"},enableCoordinateSystem:function(e){this.viewHouseNavi.setCoordinateSystemVisible(e)},getDomElement:function(){return this._domElement},destroy:function(){this.viewHouseNavi.destroy(),this.viewHouseNavi=null,this.viewHouseMenu.destroy(),this.viewHouseMenu=null,this._domElement.removeChild(this.menuSvg),this.menuSvg=null,this._domElement.removeChild(this.homeSvg),this.homeSvg=null,this._domElement=null,this.viewer=null,this._opt=null}},t.ViewHouse=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").AnnotationConfig=function(){return{background:null,domElement:null,viewer:null,style:{"stroke-width":3,"stroke-color":"#ff0000","stroke-opacity":1,"fill-color":"#ff0000","fill-opacity":0,"font-family":"Arial","font-size":16,"font-style":"italic","font-weight":"bold"}}},function(){let t=Object.freeze({Arrow:"Arrow",Rectangle:"Rectangle",Circle:"Circle",Cross:"Cross",Cloud:"Cloud",Text:"Text"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").AnnotationTypeOption=t}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(e){this._opt=e,this.init()});i.prototype={init:function(){var e,t=this._opt;if(t.viewer)e=new y.Extensions.AnnotationHelper3D(t.viewer.getViewer());else{if(!t.domElement)return alert("domElement must not be empty."),!1;(e=new y.Extensions.AnnotationHelper2D).setDomContainer(t.domElement)}this._helper=e},begin:function(){var e=this._helper,t=this._opt;e.editAnnotationBegin(t.absBasePoint,t.screenBasePoint,t.zoomFactor)},end:function(){this._helper.editAnnotationEnd()},save:function(){return this._helper.getAnnotationInfoList()},load:function(e){var t=this._helper;this._opt;t.loadAnnotations(e)},createSnapshot:function(e,t){return this._helper.captureAnnotationsScreenSnapshot(e,t)},setType:function(e){this._helper.setAnnotationType({arrow:0,rectangle:1,circle:2,cross:3,cloud:4,text:5}[e.toLocaleLowerCase()])},setStyle:function(e){this._helper.setAnnotationStyle(e)},destroy:function(){this._helper.destroy()}},t.Annotation=i,t.Annotation.Annotation=t.Annotation,t.Annotation.AnnotationConfig=t.AnnotationConfig}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationManagerConfig=function(){return{viewer:null,lineWidth:3,lineColor:new e.Web.Graphics.Color(208,2,27,1),fillColor:new e.Web.Graphics.Color(255,255,255,0),fontFamily:"Arial",fontSize:14,windowAdaption:!1}},function(){let t=Object.freeze({Arrow:"Arrow",Rectangle:"Rectangle",Circle:"Ellips",Ellips:"Ellips",Cross:"Cross",Cloud:"Cloud",CloudRect:"Cloud-rect",Text:"Text",Polyline:"Polyline",Handdrawing:"Handdrawing"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationTypeOption=t}(),ti=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),(ii=function(e){}).prototype={init:function(){var e,t=this._opt;e=new y.Extensions.AnnotationHelper3D(t.viewer.getViewer(),t),this._helper=e},startDrawing:function(){var e=this._helper;this._opt,e.editAnnotationBegin(),this.isShowAnnotation=!0},getAnnotationList:function(){return this._helper.getAnnotationInfoList()},setAnnotationList:function(e){e&&0!=e.length?(this._annotationList=e,this._helper.loadAnnotations(e),this.isShowAnnotation=!0):this.clear()},createSnapshot:function(e){this._opt.viewer,this._helper.captureAnnotationsScreenSnapshot("",e)},setState:function(e){var t=this,i=t._opt.viewer;i.setState(e.state),i.render(),setTimeout((function(){t.setAnnotationList(e.annotationList)}),1e3)},updateSvg:function(){var e=this._annotationList,t=this._opt.viewer.getZoomScale();if(!e||0==e.length)return!1;for(var i=0,n=e.length;i<n;i++)e[i].position=this.getSVGPosition(e[i],t),e[i].size.width=e[i].defaultSize.width*t,e[i].size.height=e[i].defaultSize.height*t;this.isShowAnnotation&&this.setAnnotationList(e)},getSVGPosition:function(e,t){var i=this._opt.viewer,n=i.screenWidth/2,o=i.screenHeight/2,s=i.worldToClient(e.worldPosition);return{x:s.x-n,y:o-s.y}},revoke:function(){}},ti.AnnotationViewer3dManager=ii,function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(t){var i=e.Bimface.Viewer.Viewer2DEvent,n=t.viewer,o=this;n.addEventListener(i.ViewMoving,(function(e){o.updateSvg()})),n.addEventListener(i.ViewZooming,(function(e){o.updateSvg()}))});i.prototype={init:function(){var e,t=this._opt;(e=new y.Extensions.AnnotationHelper2D(t)).setDomContainer(t.viewer.getDomElement()),this._helper=e},startDrawing:function(){var e=this._helper,t=this._opt;e.editAnnotationBegin();t.viewer.getZoomScale();e.editor.svg.addEventListener("mousewheel",(function(e){e.preventDefault(),e.stopPropagation()})),this.isShowAnnotation=!0},getAnnotationList:function(){var e=this._helper.getAnnotationInfoList();if(e&&e.length>0)for(var t=this._opt.viewer.getZoomScale(),i=0,n=e.length;i<n;i++)e[i].worldPosition=this.getWorldPosition(e[i]),e[i].defaultSize={width:e[i].size.width/t,height:e[i].size.height/t};return e},setAnnotationList:function(e){if(e&&0!=e.length){for(var t=this._opt.viewer.getZoomScale(),i=0,n=e.length;i<n;i++)e[i].position=this.getSVGPosition(e[i],t),e[i].size.width=e[i].defaultSize.width*t,e[i].size.height=e[i].defaultSize.height*t;this._annotationList=e,this._helper.loadAnnotations(e),this.isShowAnnotation=!0}else this.clear()},createSnapshot:function(e){var t=this;t._opt.viewer.createSnapshotAsync("",(function(i){t._helper.captureAnnotationsScreenSnapshot(i,e)}))},setState:function(e){this._opt.viewer.setState(e.state),this.setAnnotationList(e.annotationList)},updateSvg:function(){var e=this._annotationList,t=this._opt.viewer.getZoomScale();if(!e||0==e.length)return!1;for(var i=0,n=e.length;i<n;i++)e[i].position=this.getSVGPosition(e[i],t),e[i].size.width=e[i].defaultSize.width*t,e[i].size.height=e[i].defaultSize.height*t;this.isShowAnnotation&&this.setAnnotationList(e)},getSVGPosition:function(e,t){var i=this._opt.viewer,n=i.screenWidth/2,o=i.screenHeight/2,s=i.worldToClient(e.worldPosition);return{x:s.x-n,y:o-s.y}},revoke:function(){}},t.AnnotationViewer2dManager=i}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(e){this._viewer=e,this.drawingViewer=e.getViewer()});i.prototype={init:function(){var e,t=this._opt;e=this.drawingViewer.mouseEditorMgr,this.type="arrow",this.setLineWidth(t.lineWidth),this.setLineColor(t.lineColor),this.setFillColor(t.fillColor),this.setFontFamily(t.fontFamily),this.setFontSize(t.fontSize),this._helper=e},startDrawing:function(){var e,t=this._helper;this._opt;t.activeEditorByName("markup"),(e=t.getEditor()).setMarkupType(this.type),this.annotationToolbar&&(this.setLineColor({red:208,green:2,blue:27,alpha:1}),this.setLineWidth(2)),this.editor=e,this.isShowAnnotation=!0},endDrawing:function(){this.drawingViewer.markupManager.setFillColor("transparent"),this.clear(),this._helper.activeEditorByName("pick"),this.drawingViewer.update(),this.isShowAnnotation=!1},getAnnotationList:function(){return this.drawingViewer.markupManager.markups},setAnnotationList:function(e){this.drawingViewer.markupManager.markups=e,this.drawingViewer.update()},clear:function(){this.drawingViewer.markupManager.clear(),this.drawingViewer.update()},createSnapshot:function(e){var t=this._viewer.getRootElement();e(this.drawingViewer.snapshot(t.style.background))},resize:function(){this._viewer.resize()},setAnnotationType:function(e){this.type={arrow:"arrow",rectangle:"rectangle","cloud-rect":"cloud-rect",circle:"ellips",cross:"cross",cloud:"cloud",text:"text"}[e.toLocaleLowerCase()],this.editor&&this.editor.setMarkupType(this.type)},setLineWidth:function(e){this.drawingViewer.markupManager.setLineWidth(e)},setLineColor:function(e){this.drawingViewer.markupManager.setColor(`rgba(${e.red},${e.green},${e.blue},${e.alpha})`)},setFillColor:function(e){this.drawingViewer.markupManager.setFillColor(`rgba(${e.red},${e.green},${e.blue},${e.alpha})`)},setFontFamily:function(e){this.drawingViewer.markupManager.setFontFamily(e)},setFontSize:function(e){this.drawingViewer.markupManager.setFontSize(e)},getCurrentState:function(){var e=this._opt.viewer,t=this.getAnnotationList();return{annotationList:this.stringifyAnnotationList(t),state:e.getCurrentState()}},stringifyAnnotationList(e){return this.drawingViewer.markupManager.toString(e)},jsonifyAnnotationList(e){return this.drawingViewer.markupManager.fromString(e)},setState:function(e){var t=this._opt.viewer;if("string"==typeof e.annotationList){var i=this.jsonifyAnnotationList(e.annotationList);this.setAnnotationList(i)}else this.setAnnotationList(e.annotationList);t.setState(e.state)},updateSvg:function(){var e=this._annotationList,t=this._opt.viewer.getZoomScale();if(!e||0==e.length)return!1;for(var i=0,n=e.length;i<n;i++)e[i].position=this.getSVGPosition(e[i],t),e[i].size.width=e[i].defaultSize.width*t,e[i].size.height=e[i].defaultSize.height*t;this.isShowAnnotation&&this.setAnnotationList(e)},getWorldPosition:function(e){var t=this._opt.viewer,i=t.screenWidth/2,n=t.screenHeight/2,o={x:i+e.position.x,y:n-e.position.y};return t.clientToWorld(o)},getSVGPosition:function(e,t){var i=this._opt.viewer,n=i.screenWidth/2,o=i.screenHeight/2,s=i.worldToClient(e.worldPosition);return{x:s.x-n,y:o-s.y}},revoke:function(){}},t.AnnotationDrawingManager=i}();var gi=function(e,t){return gi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},gi(e,t)};function pi(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}gi(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var mi,fi=function(){return fi=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},fi.apply(this,arguments)},wi=function(){function e(){}return e.prototype.onDrawing=function(e,t,i,n){this.markup&&(t.strokeStyle=this.markup.strokeStyle,t.lineWidth=this.markup.lineWidth,t.fillStyle=this.markup.fillStyle,this.markup.draw(e,this.markupManager.viewer,t,i,n))},e.prototype.addMarkup=function(e,t){t.drawEnd=!0,this.markupManager.add(t),"function"==typeof this.markupManager.viewer.functions.itemCompleted&&this.markupManager.viewer.functions.itemCompleted(t)},e.prototype.redraw=function(e){},e.prototype.onExit=function(e){},e.prototype.onMouseMove=function(e,t,i,n){},e}(),yi=function(){function e(){}return e.prototype.getCenter=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]);return[(t[0]+i[0])/2,(t[1]+i[1])/2]},e.prototype.getColor=function(){return this.strokeStyle},e.prototype.getHighlightFillColor=function(){return"rgba(61, 204, 147, 0.5)"},e.prototype.getHoverColor=function(e){return(e.markupManager.getHighlightConfig&&e.markupManager.getHighlightConfig()||{}).hoverColor||""},e.prototype.getHighlightColor=function(e){return(e.markupManager.getHighlightConfig&&e.markupManager.getHighlightConfig()||{}).highlightColor||""},e}(),vi=function(e){function t(t,i,n,o,s){var r=e.call(this)||this;return r.rotation=o||0,r.markupType="Ellipse",r.drawPoints=t,r.strokeStyle=i,r.lineWidth=n,r.fillStyle=s,r.bNeedHitByBbox=!0,r}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=.5*Math.abs(a[0]-r[0]),h=.5*Math.abs(a[1]-r[1]),d=this.getCenter(e);i.save(),i.translate(d[0],d[1]),i.rotate(this.rotation),i.beginPath(),i.ellipse(0,0,l,h,0,0,2*Math.PI),i.restore(),i.closePath(),this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var c=this.getHoverColor(t);c&&s?(i.shadowColor=c,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.fillStyle&&i.fill(),i.stroke(),n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth,n.ctx.fillStyle=this.fillStyle,n.drawEllips(r,a,d,this.rotation,o,l,h)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]),o=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=[];return s.push(i[0],i[1]),s.push(i[0],o[1]),s.push(i[0],n[1]),s.push(o[0],n[1]),s.push(n[0],n[1]),s.push(n[0],o[1]),s.push(n[0],i[1]),s.push(o[0],i[1]),s},t}(yi);!function(e){e[e.CONTINUE=0]="CONTINUE",e[e.FINISHED=1]="FINISHED",e[e.LelftButton=1]="LelftButton",e[e.RightButton=2]="RightButton",e[e.MiddleButton=4]="MiddleButton",e[e.MouseMode=1]="MouseMode",e[e.TouchMode=2]="TouchMode"}(mi||(mi={}));var bi=mi,Ei=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new vi([],o,s,0,r)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([this.startX,this.startY]),s=e.clientToWorldPoint([t,i]);this.markup.setPoints([o,s]),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),bi.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),bi.FINISHED)},t}(wi),Mi=function(e){function t(t,i,n,o,s){var r=e.call(this)||this;return r.rotation=o||0,r.markupType="Rectangle",r.drawPoints=t,r.strokeStyle=i,r.lineWidth=n,r.fillStyle=s,r.bNeedHitByBbox=!0,r}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=this.getCenter(e);i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),i.rect(-.5*(a[0]-r[0]),-.5*(a[1]-r[1]),a[0]-r[0],a[1]-r[1]),i.restore(),i.closePath(),this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var h=this.getHoverColor(t);h&&s?(i.shadowColor=h,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.fillStyle&&i.fill(),i.stroke(),n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth,n.ctx.fillStyle=this.fillStyle,n.drawRect(this,r,a,l,this.rotation,o)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]),o=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=[];return s.push(i[0],i[1]),s.push(i[0],o[1]),s.push(i[0],n[1]),s.push(o[0],n[1]),s.push(n[0],n[1]),s.push(n[0],o[1]),s.push(n[0],i[1]),s.push(o[0],i[1]),s},t.prototype.getRotateGrips=function(e){var t=e.worldToClientPoint(this.drawPoints[0]),i=e.worldToClientPoint(this.drawPoints[1]);return[[(t[0]+i[0])/2,(t[1]+i[1])/2][0],t[1]-20]},t}(yi),Ci=mi,xi=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new Mi([],o,s,0,r)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([this.startX,this.startY]),s=e.clientToWorldPoint([t,i]);this.markup.setPoints([o,s]),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),Ci.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),Ci.FINISHED)},t}(wi),Ti=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.rotation=o||0,s.markupType="Arrow",s.drawPoints=t,s.strokeStyle=i,s.lineWidth=n,s.bNeedHitByBbox=!1,s}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=10+this.lineWidth,h=r[0],d=r[1],c=a[0],u=a[1],g=180*Math.atan2(d-u,h-c)/Math.PI,p=(g+30)*Math.PI/180,m=(g-30)*Math.PI/180,f=l*Math.cos(p),w=l*Math.sin(p),y=l*Math.cos(m),v=l*Math.sin(m),b=h-f,E=d-w,M=[(r[0]+a[0])/2,(r[1]+a[1])/2];this.highlightColor?(i.fillStyle=this.highlightColor,i.strokeStyle=this.highlightColor):(i.fillStyle=this.strokeStyle,i.strokeStyle=this.strokeStyle);var C=this.getHoverColor(t);C&&s?(i.shadowColor=C,i.shadowBlur=1):(i.shadowColor="",i.shadowBlur=0),i.beginPath(),b=c+f,E=u+w,i.moveTo(b,E),i.lineTo(c,u),b=c+y,E=u+v,i.lineTo(b,E),i.closePath(),i.fill(),i.beginPath(),i.moveTo(h,d),f=(l-3)*Math.cos(p),w=(l-3)*Math.sin(p);var x=[c+(f+(y=(l-3)*Math.cos(m)))/2,u+(w+(v=(l-3)*Math.sin(m)))/2];i.lineTo(x[0],x[1]),i.stroke(),n.drawArrow(this,h,d,c,u,f,w,y,v,M,this.rotation,o,r,a)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]);return i.concat(n)},t}(yi),Pi=mi,Ii=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth();this.markup=new Ti([],o,s)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([this.startX,this.startY]),s=e.clientToWorldPoint([t,i]);this.markup.setPoints([o,s]),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),Pi.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),Pi.FINISHED)},t}(wi),Si=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.rotation=o||0,s.markupType="Cross",s.drawPoints=t,s.strokeStyle=i,s.lineWidth=n,s.bNeedHitByBbox=!1,s}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=this.getCenter(e);i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),i.moveTo(-.5*(a[0]-r[0]),-.5*(a[1]-r[1])),i.lineTo(.5*(a[0]-r[0]),.5*(a[1]-r[1])),i.moveTo(-.5*(a[0]-r[0]),.5*(a[1]-r[1])),i.lineTo(.5*(a[0]-r[0]),-.5*(a[1]-r[1])),this.highlightColor?i.strokeStyle=this.highlightColor:i.strokeStyle=this.strokeStyle;var h=this.getHoverColor(t);h&&s?(i.shadowColor=h,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),i.stroke(),i.restore(),n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth,n.drawCross(r,a,l,this.rotation,o)}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]),o=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=[];return s.push(i[0],i[1]),s.push(i[0],o[1]),s.push(i[0],n[1]),s.push(o[0],n[1]),s.push(n[0],n[1]),s.push(n[0],o[1]),s.push(n[0],i[1]),s.push(o[0],i[1]),s},t}(yi),Bi=mi,_i=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth();this.markup=new Si([],o,s)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([this.startX,this.startY]),s=e.clientToWorldPoint([t,i]);this.markup.setPoints([o,s]),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),Bi.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),Bi.FINISHED)},t}(wi),Li=function(){function e(){}return e.distance=function(e,t){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.center=function(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}},e.centerByArr=function(e,t){return[(t[0]+e[0])/2,(t[1]+e[1])/2]},e.distanceByArr=function(e,t){var i=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(i*i+n*n)},e.normalize=function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return[e[0]/t,e[1]/t]},e.isPointInBBox=function(e,t,i,n){var o=.5*n[0];if(e<i[0]-o||e>i[0]+o)return!1;var s=.5*n[1];return!(t<i[1]-s||t>i[1]+s)},e.rotateAround=function(e,t,i){var n=[0,0],o=Math.cos(i),s=Math.sin(i),r=e[0]-t[0],a=e[1]-t[1];return n[0]=r*o-a*s+t[0],n[1]=r*s+a*o+t[1],n},e}(),Di=function(e){function t(t,i,n,o,s,r,a){var l=e.call(this)||this;return l.rotation=s||0,l.fillStyle=r||0,l.close=a||!1,l.markupType="Cloud",l.drawPoints=t,l.strokeStyle=i,l.lineWidth=n,l.controlPt=[],l.editPt=null,l.bNeedHitByBbox=!0,l}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=t.markupManager.getMarkupCenter(e,o);r||(r=[0,0]),i.save(),i.translate(r[0],r[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(r[0],r[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath(),n.ctx.strokeStyle="rgba("+(2*o+2)+",60,60,1)",n.ctx.fillStyle="rgba("+(2*o+2)+",60,255,1)",n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth;for(var a=1,l=this.drawPoints.length;a<l;a++){var h=e.worldToClientPoint([this.drawPoints[a-1][0],this.drawPoints[a-1][1],this.drawPoints[a-1][2]]),d=e.worldToClientPoint([this.drawPoints[a][0],this.drawPoints[a][1],this.drawPoints[a][2]]),c=void 0;if(1==a&&(i.moveTo(h[0]-r[0],h[1]-r[1]),n.ctx.moveTo(h[0]-r[0],h[1]-r[1])),this.editPt&&this.editPt[a-1])c=e.worldToClientPoint([this.editPt[a-1][0],this.editPt[a-1][1],this.editPt[a-1][2]]);else if(this.controlPt[a-1]&&a<l-1)c=e.worldToClientPoint([this.controlPt[a-1][0],this.controlPt[a-1][1],this.controlPt[a-1][2]]);else{c=this.getControlPt(h,d);var u=e.clientToWorldPoint(c);u[0]&&u[1]&&(this.controlPt[a-1]=u)}i.quadraticCurveTo(c[0]-r[0],c[1]-r[1],d[0]-r[0],d[1]-r[1]),n.ctx.quadraticCurveTo(c[0]-r[0],c[1]-r[1],d[0]-r[0],d[1]-r[1])}n.ctx.stroke(),this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var g=this.getHoverColor(t);g&&s?(i.shadowColor=g,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.close&&this.fillStyle&&i.fill(),i.stroke(),i.restore(),n.ctx.restore()}},t.prototype.shouldClose=function(e,t,i){if(this.drawPoints.length<3)return!1;var n=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]);return Li.distanceByArr(n,[t,i])<5?(this.close=!0,!0):(this.close=!1,!1)},t.prototype.getControlPt=function(e,t,i){var n=[(e[0]+t[0])/2,(e[1]+t[1])/2],o=.6*Li.distanceByArr(e,t),s=[t[1]-e[1],e[0]-t[0]];return s=Li.normalize(s),[n[0]+s[0]*o,n[1]+s[1]*o]},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.addPoint=function(e){this.drawPoints.push(e)},t.prototype.getStartPoint=function(){return this.drawPoints[0]},t.prototype.popPoint=function(){this.drawPoints.pop()},t.prototype.isEmpty=function(){return 0==this.drawPoints.length},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t,i){if(null==i)return this.drawPoints;var n=t.getMarkupBbox(e,i),o=[n[0],n[1]],s=[n[2],n[3]],r=[(o[0]+s[0])/2,(o[1]+s[1])/2],a=[];return a.push(o[0],o[1]),a.push(o[0],r[1]),a.push(o[0],s[1]),a.push(r[0],s[1]),a.push(s[0],s[1]),a.push(s[0],r[1]),a.push(s[0],o[1]),a.push(r[0],o[1]),a},t}(yi),Ai=mi,Vi=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i.bFirstCloudMarkup=!0,i.uncertainty=!1,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){if(this.bFirstCloudMarkup){if(this.markupManager.hitTest(e,t,i)>-1)return;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new Di([],o,s,null,0,r),this.bFirstCloudMarkup=!1}if(this.markup.shouldClose(e,t,i))this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0;else{var a=e.clientToWorldPoint([t,i]);this.markup.popPoint(),this.markup.addPoint(a)}this.uncertainty=!1},t.prototype.onEditing=function(e,t,i,n){if(!this.bFirstCloudMarkup){var o=void 0;o=this.markup.shouldClose(e,t,i)?this.markup.getStartPoint():e.clientToWorldPoint([t,i]),this.uncertainty&&this.markup.drawPoints.length>1?this.markup.popPoint():this.uncertainty=!0,this.markup.addPoint(o),this.redraw(e)}},t.prototype.onMouseMove=function(e,t,i,n){this.onEditing(e,t,i,n)},t.prototype.end=function(e,t,i,n){if(this.bFirstCloudMarkup)return Ai.FINISHED},t.prototype.onMouseRightClick=function(e,t){this.bFirstCloudMarkup||(this.markup.popPoint(),this.markup.drawPoints.length>1&&this.addMarkup(e,this.markup),this.markup.close=!1,this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0)},t.prototype.onDoubleClick=function(e,t){if(!this.bFirstCloudMarkup){this.markup.popPoint();var i=this.markup.drawPoints.length;i>1&&this.addMarkup(e,this.markup);var n=e.worldToClientPoint([this.markup.drawPoints[i-1][0],this.markup.drawPoints[i-1][1],this.markup.drawPoints[i-1][2]]);Li.distanceByArr(n,[t.x,t.y])<5&&this.markup.popPoint(),this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0}},t.prototype.getIsEndDrawing=function(){return this.bFirstCloudMarkup},t}(wi),Ri=function(e){function t(t,i,n,o,s){var r=e.call(this)||this;return r.rotation=o||0,r.markupType="CloudRect",r.drawPoints=t,r.strokeStyle=i,r.lineWidth=n,r.fillStyle=s,r.baseUnit="30",r.bNeedHitByBbox=!0,r}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),a=e.worldToClientPoint([this.drawPoints[1][0],this.drawPoints[1][1],this.drawPoints[1][2]]),l=this.getCenter(e),h=a[1]-r[1],d=a[0]-r[0],c=Math.abs(d),u=Math.abs(h),g=c/this.baseUnit,p=u/this.baseUnit,m=parseInt(g),f=parseInt(p),w=0==m?c:c/m,y=0==f?u:u/f;i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(l[0],l[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath();var v=[-c/2,-u/2],b=[c/2,u/2];n.ctx.strokeStyle="rgba("+(2*o+2)+",40,40,1)",n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth,i.lineJoin="round",this.drawSide("orientation",w,c,v[0],v[1],i,null,o,n,!0),this.drawSide("portrait",y,u,b[0],v[1],i,null,o,n),this.drawSide("orientation",w,c,b[0],b[1],i,!0,o,n),this.drawSide("portrait",y,u,v[0],b[1],i,!0,o,n),this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var E=this.getHoverColor(t);E&&s?(i.shadowColor=E,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.fillStyle&&i.fill(),i.stroke(),i.restore(),n.ctx.stroke(),n.ctx.restore()}},t.prototype.drawSide=function(e,t,i,n,o,s,r,a,l,h){var d,c=0,u=0,g=i/t,p=n,m=o;"orientation"==e?c=t:u=t;for(var f=0;f<g;f++){h&&0==f&&s.moveTo(n,o),d=r?[n-c,o-u]:[n+c,o+u],c&&Math.abs(d[0]-p)>i?d[0]=r?p-i:p+i:u&&Math.abs(d[1]-m)>i&&(d[1]=r?m-i:m+i);var w=this.getControlPt([n,o],d);s.quadraticCurveTo(w[0],w[1],d[0],d[1]),l.drawCloudRect(n,o,w,d,a),n=d[0],o=d[1]}},t.prototype.getControlPt=function(e,t,i){var n=[(e[0]+t[0])/2,(e[1]+t[1])/2],o=.5*Li.distanceByArr(e,t),s=[t[1]-e[1],e[0]-t[0]];return s=Li.normalize(s),[n[0]+s[0]*o,n[1]+s[1]*o]},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]),n=e.worldToClientPoint(this.drawPoints[1]),o=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=[];return s.push(i[0],i[1]),s.push(i[0],o[1]),s.push(i[0],n[1]),s.push(o[0],n[1]),s.push(n[0],n[1]),s.push(n[0],o[1]),s.push(n[0],i[1]),s.push(o[0],i[1]),s},t}(yi),Oi=mi,ki=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new Ri([],o,s,0,r)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([this.startX,this.startY]),s=e.clientToWorldPoint([t,i]);this.markup.setPoints([o,s]),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),Oi.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),Oi.FINISHED)},t}(wi),Hi=function(e){function t(t,i,n,o,s,r,a,l,h){var d=e.call(this)||this;d.rotation=r||0,d.textAreaId=a||null,d.center=l||null,d.markupType="Text",d.drawPoints=h?t:[t],d.pureText=i,d.userText=i,d.strokeStyle=n,d.fontSize=o,d.fontFamily=s;var c=document.createElement("canvas");return d.virtualCtx=c.getContext("2d"),d.bNeedHitByBbox=!1,d}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){var r=e.worldToClientPoint(this.drawPoints[0]),a=this.getTextBbox(e),l=[(a[2]+a[0])/2,(a[3]+a[1])/2];this.center&&(l=e.worldToClientPoint(this.center)),i.save(),i.translate(l[0],l[1]),i.rotate(this.rotation),i.beginPath(),n.init(l,this.rotation),i.fillStyle=i.strokeStyle,i.font=this.fontSize+"px "+this.fontFamily,i.zIndex=120,n.ctx.font="bold "+this.fontSize+"px "+this.fontFamily,n.ctx.strokeStyle="rgba("+(2*o+2)+",80,80,1)",n.ctx.fillStyle="rgba("+(2*o+2)+",80,80,1)";var h=this.userText.split(/\n/);this.highlightColor?i.fillStyle=this.getHighlightFillColor():i.fillStyle=this.strokeStyle;var d=this.getHoverColor(t);d&&s?(i.shadowColor=d,i.shadowBlur=1):(i.shadowColor="",i.shadowBlur=0);for(var c=0;c<h.length;c++){i.fillText(h[c],r[0]-l[0],r[1]-l[1]+(c+1)*this.fontSize),n.ctx.fillText(h[c],r[0]-l[0],r[1]-l[1]+(c+1)*this.fontSize);var u=h[c].replace(/[a-z]/g,"aa").replace(/[^\u0000-\u00ff]/g,"aaaa").replace(/[A-Z]/g,"aaa").replace(/[0-9]/g,"aa").length;n.ctx.fillRect(r[0]-l[0],r[1]-l[1]+c*this.fontSize,u*this.fontSize*4/14,20)}i.restore(),n.ctx.restore()},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getId=function(){return this.textAreaId},t.prototype.getUserText=function(){return this.userText},t.prototype.getPureText=function(){return this.pureText},t.prototype.setUserText=function(e){this.userText=e},t.prototype.setPureText=function(e){this.pureText=e},t.prototype.show=function(e){var t=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]),i=document.getElementById(this.textAreaId),n=e.wrapDom.getBoundingClientRect();i.style.left=t[0]+n.left+"px",i.style.top=t[1]+n.top+"px",i.style.fontFamily=this.fontFamily,i.style.fontSize=this.fontSize,i.style.border="4px",i.style.resize="none",i.style.zIndex=100,i.style.display="block",i.value=this.userText},t.prototype.resizeText=function(e){this.virtualCtx.font=this.fontSize+"px "+this.fontFamily;var t=(this.pureText||this.userText).split(/\n/),i=e[0];e[1];this.fontSize;for(var n=0;n<t.length;n++){for(var o="",s=t[n].slice(),r="",a=0,l=0;l<s.length;l++){var h=this.virtualCtx.measureText(s[l]).width;a+=h,o+=s[l],a>i&&o.length>1?(r+="\n"+s[l],a=h,o=s[l]):a==i?(t[n]=s.slice(0,l+1)+"\n"+s.slice(l+1),r+=s[l]+"\n",a=0,o=""):r+=s[l]}t[n]=r}this.userText=t.join("\n")},t.prototype.resizeTextarea=function(){var e=document.getElementById(this.textAreaId);e.value=this.userText;var t=this.userText.split(/\n/),i=0;e.rows=t.length;for(var n=0;n<t.length;n++){var o=t[n].replace(/[^\u0000-\u00ff]/g,"aa").replace(/[A-Z]/g,"aa").length;o>i&&(i=o)}e.cols=i},t.prototype.getTextBbox=function(e){var t,i=this.getTextSize(),n=e.worldToClientPoint(this.drawPoints[0]);return t=this.drawPoints[1]?e.worldToClientPoint(this.drawPoints[1]):[n[0]+i[0],n[1]+i[1]],n.concat(t)},t.prototype.getTextSize=function(){var e=0;this.virtualCtx.font=this.fontSize+"px "+this.fontFamily;for(var t,i=this.userText.split(/\n/),n=0;n<i.length;n++)(t=this.virtualCtx.measureText(i[n])).width>e&&(e=t.width);return[e,i.length*this.fontSize]},t.prototype.getEndPt=function(e){var t=this.getTextBbox(e);return[t[2],t[3]]},t.prototype.getGrips=function(e,t){var i=e.worldToClientPoint(this.drawPoints[0]);if(this.drawPoints[1]){s=e.worldToClientPoint(this.drawPoints[1]);var n=[(i[0]+s[0])/2,(i[1]+s[1])/2]}else var o=this.getTextBbox(e),s=(n=[(o[2]+o[0])/2,(o[3]+o[1])/2],[o[2],o[3]]);var r=[];return r.push(i[0],i[1]),r.push(i[0],n[1]),r.push(i[0],s[1]),r.push(n[0],s[1]),r.push(s[0],s[1]),r.push(s[0],n[1]),r.push(s[0],i[1]),r.push(n[0],i[1]),r},t}(yi),Ui=mi,Ni=function(e){function t(t,i,n){var o=e.call(this)||this;return o.editorMode=-1,o.rotation=i,o.worldPoint=[],o.drawPoints=n,o.markupManager=t,o}return pi(t,e),t.prototype.begin=function(e,i,n,o){this.startX=i,this.startY=n,this.textAreaId="";var s=!0;null==this.userText&&(s=this.initDom(e)),s&&""==t.lastTextareaId&&(this.createDiv(t.divId),this.insertTextArea2Dom(e),this.addKeyDownListener(e),this.addInputListener(e))},t.prototype.onEditing=function(e,t,i,n){},t.prototype.end=function(e,t,i,n){return Ui.FINISHED},t.prototype.onExit=function(e){""!=t.lastTextareaId&&(this.removeTextAreaInDom(t.lastTextareaId),t.lastTextareaId="")},t.prototype.initDom=function(e){if(""!=t.lastTextareaId){var i=document.getElementById(t.lastTextareaId),n=i.value.trim();if(""==n)this.removeTextAreaInDom(t.lastTextareaId);else{var o=e.wrapDom.getBoundingClientRect(),s=parseInt(i.style.left.split("px")[0]),r=parseInt(i.style.top.split("px")[0]),a=[s-o.left,r-o.top],l=this.drawPoints&&this.drawPoints[0]||this.worldPoint!==[]&&this.worldPoint||e.clientToWorldPoint(a),h=i.style.color,d=this.markupManager.getFontSize(),c=i.style.fontFamily,u=new Hi(l,n,h,d,c,this.rotation||0,t.lastTextareaId);this.size&&(u.setPureText(n),this.setPureText(n),u.resizeText(this.size)),this.rotation=0,this.hideTextArea(t.lastTextareaId),this.addMarkup(e,u),u=null,this.redraw(e)}return t.lastTextareaId="",!1}return!0},t.prototype.createDiv=function(e){if(null==document.getElementById(e)){console.log("Create div in dom.");var i=document.createElement("div");i.addEventListener("mousedown",(function(e){e.stopImmediatePropagation()})),i.addEventListener("mouseup",(function(e){e.stopImmediatePropagation()})),i.addEventListener("mousemove",(function(e){e.stopImmediatePropagation()})),i.setAttribute("id",t.divId),i.style.position="absolute",i.style.left="0",i.style.top="0",this.markupManager.viewer.wrapDom.appendChild(i);var n=document.createElement("span");n.id="box",n.style.visibility="hidden",i.appendChild(n);var o=document.createElement("span");n.id="boxEdit",n.style.visibility="hidden",n.style.wordBreak="break-all",n.style.display="inline-block",i.appendChild(o)}},t.prototype.setEditBox=function(e){this.size=e},t.prototype.hideTextArea=function(e){var t=document.getElementById(e);t.blur(),t.style.display="none"},t.prototype.showTextArea=function(e){document.getElementById(e).style.display="block"},t.prototype.setUserText=function(e){this.userText=e},t.prototype.setPureText=function(e){this.pureText=e},t.prototype.addKeyDownListener=function(e){var t=this,i=document.getElementById(this.textAreaId);i&&i.addEventListener("keydown",(function(i){return t.keyDownFunction(e,i)}),!0)},t.prototype.addInputListener=function(e){var t=this,i=document.getElementById(this.textAreaId);i&&(i.addEventListener("input",(function(n){t.resize(i,e)})),i.addEventListener("blur",(function(e){})))},t.prototype.resize=function(e,i){var n=e.value.split(/\n/),o=document.querySelectorAll("#"+t.divId+" span")[0];o.innerText=e.value,o.style.fontSize=this.markupManager.getFontSize()+"px",e.style.width=o.offsetWidth+20+"px",e.rows=n.length},t.prototype.keyDownFunction=function(e,t){var i=document.getElementById(this.textAreaId);13==t.keyCode&&(i.rows=i.rows+1,console.log("Key enter pressed."))},t.prototype.addMouseDownListener=function(){var e=document.getElementById(this.textAreaId);e&&e.addEventListener("click",(function(e){console.log("Mouse click textarea now.")}))},t.prototype.createTextArea=function(e){var t=[this.startX,this.startY];this.worldPoint=e.clientToWorldPoint(t);var i=document.createElement("textArea");i.setAttribute("id",this.textAreaId),i.setAttribute("maxlength",999),i.value=null==this.userText?"":this.userText,i.style.color=this.markupManager.getColor(),i.style.position="fixed",i.style.lineHeight="100%",this.editorMode,i.style.width="10px",i.style.paddingLeft="6px",i.style.overflow="hidden",i.style.webkitUserSelect="auto",i.style.webkitAppearance="none",i.style.borderRadius=0,null!=this.userText?this.resize(i,e):i.rows="1";var n=e.wrapDom.getBoundingClientRect();return i.style.left=t[0]+n.left+"px",i.style.top=t[1]+n.top+"px",i.style.fontFamily=this.markupManager.getFontFamily(),i.style.fontSize=this.markupManager.getFontSize()+"px",i.style.border="1px solid red",i.style.background="transparent",i.style.outline="none",i.style.resize="none",i.style.zIndex=100,i.style.display="block",i},t.prototype.insertTextArea2Dom=function(e){var i=document.getElementById(t.divId),n=i.childElementCount+1;this.textAreaId="textArea_"+n;var o=this.createTextArea(e);this.textArea=o,i.appendChild(o),o.focus(),t.lastTextareaId=this.textAreaId},t.prototype.reposition=function(e){var t=e.worldToClientPoint(this.worldPoint),i=e.wrapDom.getBoundingClientRect();this.textArea.style.left=t[0]+i.left+"px",this.textArea.style.top=t[1]+i.top+"px"},t.prototype.removeTextAreaInDom=function(e){var i=document.getElementById(t.divId),n=document.getElementById(e);try{i.removeChild(n)}catch(e){}},t.lastTextareaId="",t.divId="bf-drawing-textEditor",t}(wi),Gi=function(e){function t(t,i,n,o,s,r){var a=e.call(this)||this;return a.rotation=o||0,a.close=r||!1,a.fillStyle=s,a.markupType="Polyline",a.drawPoints=t,a.strokeStyle=i,a.lineWidth=n,a.editPt=null,a.bNeedHitByBbox=!1,a}return pi(t,e),t.prototype.draw=function(e,t,i,n,o,s){if(!(this.drawPoints.length<2)){var r=t.markupManager.getMarkupCenter(e,o);r||(r=[0,0]),i.save(),i.translate(r[0],r[1]),i.rotate(this.rotation),i.beginPath(),i.lineJoin="round",n.init(r,this.rotation),n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth;for(var a=1,l=this.drawPoints.length;a<l;a++){var h=e.worldToClientPoint([this.drawPoints[a-1][0],this.drawPoints[a-1][1],this.drawPoints[a-1][2]]),d=e.worldToClientPoint([this.drawPoints[a][0],this.drawPoints[a][1],this.drawPoints[a][2]]);1==a&&i.moveTo(h[0]-r[0],h[1]-r[1]),i.lineTo(d[0]-r[0],d[1]-r[1]),n.drawPolyline(h,d,r,this.rotation,o)}this.highlightColor?(i.fillStyle=this.getHighlightFillColor(),"rgba(255,255,255,0)"===this.fillStyle&&(i.fillStyle=this.fillStyle),i.strokeStyle=this.highlightColor):(i.fillStyle=this.fillStyle,i.strokeStyle=this.strokeStyle);var c=this.getHoverColor(t);c&&s?(i.shadowColor=c,i.shadowBlur=2):(i.shadowColor="",i.shadowBlur=0),this.close&&this.fillStyle&&(i.fill(),this.bNeedHitByBbox=!0),i.stroke(),i.restore(),n.ctx.restore()}},t.prototype.shouldClose=function(e,t,i){if(this.drawPoints.length<3)return!1;var n=e.worldToClientPoint([this.drawPoints[0][0],this.drawPoints[0][1],this.drawPoints[0][2]]);return Li.distanceByArr(n,[t,i])<5?(this.close=!0,!0):(this.close=!1,!1)},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.addPoint=function(e){this.drawPoints.push(e)},t.prototype.getStartPoint=function(){return this.drawPoints[0]},t.prototype.popPoint=function(){this.drawPoints.pop()},t.prototype.isEmpty=function(){return 0==this.drawPoints.length},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t,i){if(null==i)return this.drawPoints;var n=t.getMarkupBbox(e,i),o=[n[0],n[1]],s=[n[2],n[3]],r=[(o[0]+s[0])/2,(o[1]+s[1])/2],a=[];return a.push(o[0],o[1]),a.push(o[0],r[1]),a.push(o[0],s[1]),a.push(r[0],s[1]),a.push(s[0],s[1]),a.push(s[0],r[1]),a.push(s[0],o[1]),a.push(r[0],o[1]),a},t}(yi),ji=mi,zi=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i.bFirstCloudMarkup=!0,i.uncertainty=!1,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){if(this.bFirstCloudMarkup){if(this.markupManager.hitTest(e,t,i)>-1)return;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth(),r=this.markupManager.getFillStyleState()?this.markupManager.getFillColor():void 0;this.markup=new Gi([],o,s,0,r),this.bFirstCloudMarkup=!1}if(this.markup.shouldClose(e,t,i))this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0;else{var a=e.clientToWorldPoint([t,i]);this.markup.popPoint(),this.markup.addPoint(a)}this.uncertainty=!1},t.prototype.onEditing=function(e,t,i,n){if(!this.bFirstCloudMarkup){var o=void 0;o=this.markup.shouldClose(e,t,i)?this.markup.getStartPoint():e.clientToWorldPoint([t,i]),this.uncertainty&&this.markup.drawPoints.length>1?this.markup.popPoint():this.uncertainty=!0,this.markup.addPoint(o),this.redraw(e)}},t.prototype.onMouseMove=function(e,t,i,n){this.onEditing(e,t,i,n)},t.prototype.end=function(e,t,i,n){if(this.bFirstCloudMarkup)return ji.FINISHED},t.prototype.onMouseRightClick=function(e,t){this.bFirstCloudMarkup||(this.markup.popPoint(),this.markup.drawPoints.length>1&&this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0)},t.prototype.onDoubleClick=function(e,t){this.bFirstCloudMarkup||(this.markup.popPoint(),this.markup.drawPoints.length>1&&this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),this.bFirstCloudMarkup=!0)},t.prototype.getIsEndDrawing=function(){return this.bFirstCloudMarkup},t}(wi),Fi=function(e){function t(t,i,n,o){var s=e.call(this)||this;return s.markupType="Handdrawing",s.drawPoints=t,s.strokeStyle=i,s.lineWidth=n,s.rotation=o||0,s.bNeedHitByBbox=!1,s}return pi(t,e),t.prototype.draw=function(e,t,i,n,o){if(!(this.drawPoints.length<2)){i.lineJoin="round",n.ctx.lineWidth=Ji.isMobile?18:this.lineWidth+n.lineWidth;var s=t.markupManager.getMarkupCenter(e,o);s||(s=[0,0]),i.save(),i.translate(s[0],s[1]),i.rotate(this.rotation),i.beginPath(),n.ctx.save(),n.ctx.translate(s[0],s[1]),n.ctx.rotate(this.rotation),n.ctx.beginPath(),n.ctx.strokeStyle="rgba("+(2*o+2)+",90,90,1)";var r=this.drawPoints.length,a=this.drawPoints;if(r<3)for(var l=1;l<r;l++){var h=e.worldToClientPoint([a[l-1][0],a[l-1][1],a[l-1][2]]),d=e.worldToClientPoint([a[l][0],a[l][1],a[l][2]]);i.moveTo(h[0]-s[0],h[1]-s[1]),i.lineTo(d[0]-s[0],d[1]-s[1]),n.ctx.moveTo(h[0]-s[0],h[1]-s[1]),n.ctx.lineTo(d[0]-s[0],d[1]-s[1])}else for(h=e.worldToClientPoint([a[0][0],a[0][1],a[0][2]]),l=0;l<r-2;l++){var c=e.worldToClientPoint([a[l+1][0],a[l+1][1],a[l+1][2]]),u=e.worldToClientPoint([a[l+2][0],a[l+2][1],a[l+2][2]]);d=Li.centerByArr(c,u);i.moveTo(h[0]-s[0],h[1]-s[1]),i.quadraticCurveTo(c[0]-s[0],c[1]-s[1],d[0]-s[0],d[1]-s[1]),n.drawHanddrawing(h,c,d,s),h=d}this.highlightColor?i.strokeStyle=this.highlightColor:i.strokeStyle=this.strokeStyle,i.stroke(),n.ctx.stroke(),i.restore(),n.ctx.restore()}},t.prototype.setPoints=function(e){this.drawPoints=e},t.prototype.addPoint=function(e){this.drawPoints.push(e)},t.prototype.getPoints=function(){return this.drawPoints},t.prototype.getGrips=function(e,t,i){if(null==i)return this.drawPoints;var n=t.getMarkupBbox(e,i),o=[n[0],n[1]],s=[n[2],n[3]],r=[(o[0]+s[0])/2,(o[1]+s[1])/2],a=[];return a.push(o[0],o[1]),a.push(o[0],r[1]),a.push(o[0],s[1]),a.push(r[0],s[1]),a.push(s[0],s[1]),a.push(s[0],r[1]),a.push(s[0],o[1]),a.push(r[0],o[1]),a},t}(yi),Wi=mi,$i=function(e){function t(t){var i=e.call(this)||this;return i.markupManager=t,i}return pi(t,e),t.prototype.begin=function(e,t,i,n){this.startX=t,this.startY=i;var o=this.markupManager.getColor(),s=this.markupManager.getLineWidth();this.markup=new Fi([],o,s,0)},t.prototype.onEditing=function(e,t,i,n){var o=e.clientToWorldPoint([t,i]);this.markup.addPoint(o),this.redraw(e)},t.prototype.end=function(e,t,i,n){return this.startX==t&&this.startY==i?(console.log("Ignore single point."),Wi.FINISHED):(this.addMarkup(e,this.markup),this.markup=null,this.redraw(e),Wi.FINISHED)},t}(wi),Xi=mi,Yi=function(){function e(e,t,i,n,o){this.canvas=e,this.MarkupVirtualPad=i,this.modelViewer=o,this.ctx=e.getContext("2d"),this.markupManager=t,this.setMarkupType("arrow"),this.curIndex=-1,this.editIndex=-1,this.preEdit=-1,this.inEditMode=!1,this.currentGrip=-1,this.bFirstClick=!0,this.firstPos=[],this.touchPos=[],this.device=n,this.hightLightColor="yellow",this.isEndDrawingForRightClick=!0,new Ni(this.markupManager).createDiv(Ni.divId)}return e.prototype.onDrawing=function(e,t,i){if(this.tool.onDrawing(e,t,this.MarkupVirtualPad,this.curIndex),this.curIndex!=this.highLightId&&this.highLightId>=0&&(this.canvas.style.cursor="",this.highLightId=-1),this.curIndex>=0){if(!(o=this.markupManager.get(this.curIndex)))return;i&&this.markupManager.hitTest(e,i[0],i[1])==this.curIndex&&this.markupManager.viewer.isEnableAnnotationPick&&(this.canvas.style.cursor="pointer",this.highLightId=this.curIndex,this.device.isPc&&(t.lineWidth=o.lineWidth,this.markupManager.viewer.alwaysMode&&o.draw(e,this.markupManager.viewer,t,this.MarkupVirtualPad,this.curIndex,!0)))}if(this.editIndex>=0){if(this.markupManager.viewer.alwaysMode)return;if(0==this.markupManager.markups.length)return this.editIndex,!1;var n=this.markupManager.getMarkupBbox(e,this.editIndex);if(!n)return;var o,s=[n[0],n[1]],r=[n[2],n[3]],a=(o=this.markupManager.get(this.editIndex)).getGrips(e,this.markupManager,this.editIndex),l=this.markupManager.getMarkupCenter(e,this.editIndex);if(!l)return;t.save(),t.translate(l[0],l[1]),"Arrow"!=o.markupType&&t.rotate(o.rotation),t.beginPath(),t.lineWidth="1",t.strokeStyle="red",t.fillStyle="#ffffff";var h=(o.lineWidth||0)/2;4!=a.length&&(this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Move")&&(t.strokeStyle="#999999"),t.strokeRect(-.5*(r[0]-s[0])-h,-.5*(r[1]-s[1])-h,r[0]-s[0]+2*h,r[1]-s[1]+2*h),t.strokeStyle="red",this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Rotate")&&(t.strokeStyle="#ffffff",t.fillStyle="#999999"),t.arc(0,s[1]-l[1]-20,6,0,2*Math.PI,!1),t.fill(),t.stroke(),t.closePath(),t.beginPath(),t.arc(0,s[1]-l[1]-20,3,.5*Math.PI,1.8*Math.PI,!1),t.moveTo(3,s[1]-l[1]-21),t.lineTo(.5,s[1]-l[1]-19.5),t.moveTo(3,s[1]-l[1]-21),t.lineTo(3,s[1]-l[1]-24.5),t.stroke()),t.closePath(),t.strokeStyle="red",t.fillStyle="#ffffff";var d=void 0,c=void 0;if("Arrow"==o.markupType){this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Stretch")&&(t.strokeStyle="#999999");var u=this.markupManager.getMarkupSize(e,this.editIndex),g=Math.sqrt(u[0]*u[0]+u[1]*u[1]),p=u[0]/g*4,m=u[1]/g*4;t.beginPath(),t.arc(a[0]-l[0]+(a[0]<a[2]?-p/2:p/2),a[1]-l[1]+(a[1]<a[3]?-m/2:m/2),4,0,2*Math.PI,!1),t.fill(),t.stroke(),t.closePath(),t.beginPath(),t.arc(a[2]-l[0]+(a[0]<a[2]?p:-p),a[3]-l[1]+(a[1]<a[3]?m:-m),4,0,2*Math.PI,!1),t.fill(),t.stroke(),t.closePath()}else{this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Rotate")&&(t.strokeStyle="#999999"),t.moveTo(0,s[1]-l[1]),t.lineTo(0,s[1]-l[1]-15),t.stroke();for(var f=0;f<a.length;f+=2){t.beginPath(),this.markupManager.viewer.operationTypes&&!this.markupManager.viewer.operationTypes.includes("Stretch")?t.strokeStyle="#999999":t.strokeStyle="red";var w=[a[f],a[f+1]];if("Text"==o.markupType||"Handdrawing"==o.markupType)d=1,c=1;else{var y=e.worldToClientPoint(o.drawPoints[0]),v=e.worldToClientPoint(o.drawPoints[1]);d=y[0]<v[0]?1:-1,c=y[1]<v[1]?1:-1}switch(f){case 0:t.arc(w[0]-l[0]-h*d,w[1]-l[1]-h*c,4,0,2*Math.PI,!1);break;case 2:t.arc(w[0]-l[0]-h*d,w[1]-l[1],4,0,2*Math.PI,!1);break;case 4:t.arc(w[0]-l[0]-h*d,w[1]-l[1]+h*c,4,0,2*Math.PI,!1);break;case 6:t.arc(w[0]-l[0],w[1]-l[1]+h*c,4,0,2*Math.PI,!1);break;case 8:t.arc(w[0]-l[0]+h*d,w[1]-l[1]+h*c,4,0,2*Math.PI,!1);break;case 10:t.arc(w[0]-l[0]+h*d,w[1]-l[1],4,0,2*Math.PI,!1);break;case 12:t.arc(w[0]-l[0]+h*d,w[1]-l[1]-h*c,4,0,2*Math.PI,!1);break;case 14:t.arc(w[0]-l[0],w[1]-l[1]-h*c,4,0,2*Math.PI,!1)}t.fill(),t.stroke(),t.closePath()}}t.restore(),this.MarkupVirtualPad.drawEdit(s,r,l,o,a,this.editIndex,p,m,h,[d,c])}},e.prototype.canCreateMarkup=function(e){if(-1==this.curIndex)return!0;var t=this.markupManager.get(this.curIndex);if(!t)return!0;var i=t.getGrips(e,this.markupManager);return this.editIndex!=this.curIndex&&0!=i.length&&"Text"!=t.markupType},e.prototype.setMarkupType=function(e){if(!Ji.isMobile||"cloud"!==e&&"polyline"!==e){switch(this.tool&&this.tool.onExit(),this.crtMarkupType=e,this.start=!1,e){case"ellips":this.tool=new Ei(this.markupManager);break;case"rectangle":this.tool=new xi(this.markupManager);break;case"arrow":this.tool=new Ii(this.markupManager);break;case"cross":this.tool=new _i(this.markupManager);break;case"cloud":this.tool=new Vi(this.markupManager);break;case"cloud-rect":this.tool=new ki(this.markupManager);break;case"text":this.tool=new Ni(this.markupManager);break;case"polyline":this.tool=new zi(this.markupManager);break;case"handdrawing":this.tool=new $i(this.markupManager);break;default:console.log("Current type is not supported.")}this.tool.redraw=this.redraw.bind(this),this.tool.type=e}},e.prototype.begin=function(e,t,i,n){if(this.modelViewer&&"ViewerDrawing"===this.modelViewer.viewerType&&this.modelViewer.snapIsEnabled){var o=this.modelViewer._drawingViewer.snapToPoint(t,i),s=this.modelViewer._drawingViewer.toScreenPoint([o.GetPoint()[0],o.GetPoint()[1]]);t=s[0],i=s[1]}else this.modelViewer&&"Viewer3D"===this.modelViewer.viewerType&&this.modelViewer.snap&&(t=this.modelViewer.snap.context.hoverPosition.x,i=this.modelViewer.snap.context.hoverPosition.y);this.curIndex=this.markupManager.hitTest(e,t,i,!0);var r=this.MarkupVirtualPad.isEdge(t,i);if(!this.markupManager.viewer.isEnableAnnotationPick||this.curIndex<0&&this.canCreateMarkup(e)&&!r){if(this.editIndex>-1)return this.editIndex=-1,void this.redraw(e);if(n==Xi.LelftButton){if(this.start=!0,this.textMarkupTool)return this.textMarkupTool.initDom(e),this.textMarkupTool=null,void this.redraw(e);this.tool.begin(e,t,i,n)}this.start&&n==Xi.RightButton&&this.tool.begin(e,t,i,n)}this.bFirstClick=!0;var a=this.editIndex;if(this.preEdit=a,this.curIndex>=0){var l=this.markupManager.get(this.curIndex),h=null==l?void 0:l.markupType;if(Ji.isMobile&&("Cloud"===h||"Polyline"===h))return;if(this.markupManager.viewer.hasOwnProperty("isEnableAnnotationPick")&&!this.markupManager.viewer.isEnableAnnotationPick)return;this.editIndex=this.curIndex,this.inEditMode=!0,this.redraw(e)}else this.editIndex=-1,this.redraw(e);this.editIndex!=a&&this.markupManager.viewer.functions.onSelectChange(this.editIndex)},e.prototype.onEditing=function(e,t,i,n){if(this.start?-1!=this.curIndex&&this.editIndex==this.curIndex||this.tool.onEditing(e,t,i,n):this.tool.onMouseMove(e,t,i,n),this.inEditMode){var o=this.markupManager.hitGrip(e,[t,i],this.editIndex);if(this.bFirstClick){this.firstPos=[t,i],this.bFirstClick=!1,this.currentGrip=o>=0?o:-1;var s=this.markupManager.get(this.editIndex);if(!s)return;return s.originPoints=s.getPoints(),s.originRotation=s.rotation,"Text"==s.markupType&&(this.editIndex==this.preEdit&&s.userText&&s.originUserText&&this.currentGrip<9?s.userText=s.originUserText:-1!=this.currentGrip&&this.currentGrip<9&&(s.originUserText=s.userText)),s.controlPt&&(s.originControlPt=s.controlPt),void(s.editPt&&(s.originEditPt=s.editPt))}var r=[t,i];9==this.currentGrip?this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Rotate")&&(this.markupManager.gripRotate(e,this.editIndex,this.firstPos,r),this.redraw(e,r)):this.currentGrip>=0&&this.currentGrip<9?this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Stretch")&&(this.markupManager.gripDragging(e,this.editIndex,this.currentGrip,this.firstPos,r),this.redraw(e,r)):this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Move")&&(this.markupManager.translatePos(e,this.editIndex,this.firstPos,r),this.redraw(e,r))}else this.bFirstClick=!0,this.currentGrip=-1},e.prototype.end=function(e,t,i,n){if(this.modelViewer&&"ViewerDrawing"===this.modelViewer.viewerType&&this.modelViewer.snapIsEnabled){var o=this.modelViewer._drawingViewer.snapToPoint(t,i),s=this.modelViewer._drawingViewer.toScreenPoint([o.GetPoint()[0],o.GetPoint()[1]]);t=s[0],i=s[1]}else this.modelViewer&&"Viewer3D"===this.modelViewer.viewerType&&this.modelViewer.snap&&(t=this.modelViewer.snap.context.hoverPosition.x,i=this.modelViewer.snap.context.hoverPosition.y);this.start&&(-1!=this.curIndex&&this.editIndex==this.curIndex||Xi.FINISHED==this.tool.end(e,t,i,n)&&(this.start=!1)),this.onEditing(e,t,i,n),this.inEditMode&&(this.inEditMode=!1),this.start=!1},e.prototype.onExit=function(e){this.tool.onExit(e)},e.prototype.onMouseWheel=function(e,t){this.start},e.prototype.onKeyDown=function(e,t){this.editIndex>=0&&("Delete"==t.code||"Backspace"==t.code)&&this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Delete")&&(this.markupManager.remove(this.editIndex),this.curIndex=-1,this.editIndex=-1,this.redraw(e))},e.prototype.onClick=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n);if(0==t.button||2==t.button&&this.isEndDrawingForRightClick){var s={click:0==t.button?0:1,clientPosition:{x:t.clientX,y:t.clientY},screenPosition:{x:t.screenX,y:t.screenY},eventType:0==t.button?"Click":"RightClick"};this.markupManager.viewer.functions.onClick(fi(fi({},s),o))}}this.isEndDrawingForRightClick=!0},e.prototype.onTouch=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={click:2,clientPosition:{x:t.touches[0].pageX,y:t.touches[0].pageY},screenPosition:{x:t.touches[0].screenX,y:t.touches[0].screenY},eventType:"touch"};this.markupManager.viewer.functions.onTouch(fi(fi({},s),o))}this.isEndDrawingForRightClick=!0},e.prototype.onLongPress=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={click:2,clientPosition:{x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY},screenPosition:{x:t.changedTouches[0].screenX,y:t.changedTouches[0].screenY},eventType:"longPress"};this.markupManager.viewer.functions.onLongPress(fi(fi({},s),o))}},e.prototype.onDoubleClick=function(e,t){var i=this.formatEventOffset(e,t),n=this.markupManager.hitTest(e,i.x,i.y,!0);if(n>-1){var o=this.markupManager.get(n),s={clientPosition:{x:t.clientX,y:t.clientY},screenPosition:{x:t.screenX,y:t.screenY}};this.markupManager.viewer.functions.onDoubleClick(fi(fi({},s),o))}this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Edit")&&(this.tool.onDoubleClick&&this.tool.onDoubleClick(e,t),this.editText(e))},e.prototype.onDoubleTouch=function(e,t){this.markupManager.viewer.operationTypes&&this.markupManager.viewer.operationTypes.includes("Edit")&&(this.tool.onDoubleTouch&&this.tool.onDoubleTouch(e,t),this.editText(e))},e.prototype.editText=function(e){if(!(this.curIndex<0||null==this.curIndex)){var t=this.markupManager.get(this.curIndex);if(t){var i=t.getPoints();if("Text"==t.markupType){""!=Ni.lastTextareaId&&(this.textMarkupTool?this.textMarkupTool.initDom(e):this.tool.initDom(e));var n=new Ni(this.markupManager,t.rotation,i),o=e.worldToClientPoint([i[0][0],i[0][1],i[0][2]]);n.setUserText(t.getPureText()),this.tool.rotation=t.rotation,n.begin(e,o[0],o[1],Xi.LelftButton),n.setEditBox(t.getTextSize()),this.device.isMobileApple||this.device.isPc||setTimeout((function(){n.reposition(e)}),500),this.markupManager.remove(this.curIndex),this.highLightId=-1,this.curIndex=-1,this.editIndex=-1,this.textMarkupTool=n,this.redraw(e)}}}},e.prototype.onMouseDown=function(e,t){2==t.button?(e.startX=null,e.startY=null,this.isEndDrawingForRightClick=!0,(this.tool instanceof zi||this.tool instanceof Vi)&&(this.isEndDrawingForRightClick=this.tool.getIsEndDrawing()),this.tool.onMouseRightClick&&this.tool.onMouseRightClick(e,t)):this.begin(e,t.offsetX,t.offsetY,t.buttons)},e.prototype.onMouseMove=function(e,t){var i=this.formatEventOffset(e,t);this.onEditing(e,i.x,i.y,t.buttons)},e.prototype.onMouseUp=function(e,t,i){var n=this.formatEventOffset(e,t);this.markupManager.viewer.alwaysMode&&2==t.button&&(this.markupManager.hitTest(e,n.x,n.y,!0)>-1&&(t.preventDefault(),t.stopPropagation()));if(this.curIndex>=0&&this.markupManager.viewer.alwaysMode){if(!this.device.isPc)return;var o=this.markupManager.get(this.curIndex),s=this.markupManager.getHighlightConfig()||{highlightColor:""};o&&(o.highlightColor=o.highlightColor?"":s.highlightColor,this.redraw(e))}return this.end(e,n.x,n.y,t.buttons)},e.prototype.onTouchstart=function(e,t){var i=this.formatEventOffset(e,t);this.touchPos=[i.x,i.y],this.begin(e,i.x,i.y,1)},e.prototype.onTouchmove=function(e,t){var i=this.formatEventOffset(e,t);this.touchPos=[i.x,i.y],this.onEditing(e,i.x,i.y,1)},e.prototype.onTouchend=function(e,t){var i=this.formatEventOffset(e,t);return this.end(e,this.touchPos.length>0?this.touchPos[0]:i.x,this.touchPos.length>0?this.touchPos[1]:i.y,1)},e.prototype.isPanMode=function(e){return e==Xi.MiddleButton||e==Xi.RightButton},e.prototype.formatEventOffset=function(e,t){var i,n,o=this.canvas.getBoundingClientRect();if(Ji.isMobile){var s=t.touches.length>0?t.touches:t.changedTouches;i=s[0].pageX-(o.x||o.left),n=s[0].pageY-(o.y||o.top)}else i=t.clientX-(o.x||o.left),n=t.clientY-(o.y||o.top);return{x:i,y:n}},e.prototype.redraw=function(e,t){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.fillStyle="rgba(0,0,0,0)",this.MarkupVirtualPad.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.markupManager.draw(e,this.ctx),this.onDrawing(e,this.ctx,t),this.markupManager.viewer.redrawOtherMarkups()},e.prototype.setCurIndex=function(e){this.curIndex=e},e.prototype.redrawOnlySelf=function(e,t){this.MarkupVirtualPad.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.MarkupVirtualPad.ctx.fillStyle="rgba(0,0,0,0)",this.MarkupVirtualPad.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.markupManager.draw(e,this.ctx),this.onDrawing(e,this.ctx,t)},e.prototype.getStart=function(){return this.start},e}(),Zi=function(){function e(){}return e.markups2string=function(e){return JSON.stringify(e)},e.string2markups=function(e){var t=JSON.parse(e);return this.transform2markups(t)},e.transform2markups=function(e){for(var t=[],i=0;i<e.length;i++){var n=e[i],o=n.drawPoints,s=n.strokeStyle,r=n.lineWidth,a=n.fillStyle,l=n.close,h=n.userText,d=n.fontSize,c=n.rotation,u=n.fontFamily,g=n.textAreaId,p=n.center,m=n.markupId,f=n.controlPt,w=null;switch(n.markupType){case"Ellipse":w=new vi(o,s,r,c,a);break;case"Rectangle":w=new Mi(o,s,r,c,a);break;case"Arrow":w=new Ti(o,s,r);break;case"Cross":w=new Si(o,s,r,c);break;case"Cloud":w=new Di(o,s,r,f,c,a,l);break;case"CloudRect":w=new Ri(o,s,r,c,a);break;case"Text":if(2==o.length&&"number"==typeof o[0]){if(w=new Hi(o,h,s,d,u,c,g,p,!0),n.pureText){var y=w.getTextSize();w.resizeText(y)}}else w=new Hi(o[0],h,s,d,u,c,g,p);break;case"Polyline":w=new Gi(o,s,r,c,a,l);break;case"Handdrawing":w=new Fi(o,s,r,c);default:console.log("Current type is not supported.")}m&&(w.markupId=m),t.push(w)}return t},e}(),qi=function(){function e(e,t){this.MarkupVirtualPad=e,this.viewer=t,this.markups=[],this.strokeStyle="red",this.lineWidth=3,this.fontSize=14,this.fontFamily="Arial",this.fillStyle="",this.enableFillStyle=!0,this.highlightConfig={hoverColor:"#FFFFFF",highlightColor:"#3DCC93"}}return e.prototype.toString=function(e){return Zi.markups2string(e||this.markups)},e.prototype.fromString=function(e){return Zi.string2markups(e)},e.prototype.add=function(e){e.markupId=Date.now(),this.markups.push(e)},e.prototype.setMarkups=function(e){this.markups=e.slice(),this.viewer.editor.editIndex=-1},e.prototype.clear=function(){this.markups=[],this.viewer.editor.tool.markup&&(this.viewer.editor.tool.markup.setPoints([]),this.viewer.editor.tool.bFirstCloudMarkup=!0)},e.prototype.draw=function(e,t){for(var i=this.markups,n=0,o=i.length;n<o;++n){var s=i[n];t.strokeStyle=s.strokeStyle,t.lineWidth=(Ji.isMobile,s.lineWidth),t.fillStyle=s.fillStyle,t.fontFamily=s.fontFamily,s.highLight&&(t.strokeStyle=s.highLight,s.highLight=null),s.highlightColor&&(t.strokeStyle=s.highlightColor,t.fillStyle=s.highlightColor),s.draw(e,this.viewer,t,this.MarkupVirtualPad,n)}},e.prototype.getColor=function(){return this.strokeStyle},e.prototype.setColor=function(e){this.strokeStyle=e},e.prototype.setHighlightConfig=function(e){this.highlightConfig=e},e.prototype.getHighlightConfig=function(){return this.highlightConfig},e.prototype.getFillColor=function(){return this.fillStyle},e.prototype.setFillColor=function(e){this.enableFillStyle=!0,e.getRGBA&&(e=e.getRGBA()),this.fillStyle=e},e.prototype.setFillStyleState=function(e){this.enableFillStyle=e},e.prototype.getFillStyleState=function(){return this.enableFillStyle},e.prototype.getLineWidth=function(){return this.lineWidth},e.prototype.setLineWidth=function(e){this.lineWidth=e},e.prototype.getFont=function(){return this.font},e.prototype.getFontSize=function(){return this.fontSize},e.prototype.setFont=function(e){this.font=e},e.prototype.get=function(e){return this.markups[e]},e.prototype.remove=function(e){e<0||this.markups.splice(e,1)},e.prototype.hitTest=function(e,t,i,n){var o=this.viewer.isEnableAnnotationPick?this.MarkupVirtualPad.hitTest(t,i):-1;if(null==n||o>=0)return o;o=-1;for(var s=this.markups.length-1;s>=0;s--){var r=this.markups[s];if(0!=r.bNeedHitByBbox&&"rgba(255,255,255,0)"!=r.fillStyle){var a=this.getMarkupBbox(e,s),l=this.getMarkupCenter(e,s),h=Li.rotateAround([t,i],l,-r.rotation);if(1==!(h[0]<a[0]||h[0]>a[2]||h[1]<a[1]||h[1]>a[3])){o=s;break}}}return o},e.prototype.getMarkupBbox=function(e,t){var i=this.markups[t];if(!(t<0)&&i){var n=[Number.MAX_VALUE,Number.MAX_VALUE],o=[-Number.MAX_VALUE,-Number.MAX_VALUE],s=i.getPoints();if("Text"==i.markupType)return i.getTextBbox(e);i.editPt?s=s.concat(i.editPt):i.controlPt&&(s=s.concat(i.controlPt));for(var r=0;r<s.length;r++){var a=e.worldToClientPoint(s[r]);a[0]<n[0]&&(n[0]=a[0]),a[1]<n[1]&&(n[1]=a[1]),a[0]>o[0]&&(o[0]=a[0]),a[1]>o[1]&&(o[1]=a[1])}return n.concat(o)}},e.prototype.getMarkupCenter=function(e,t){var i=this.getMarkupBbox(e,t);if(i)return[(i[0]+i[2])/2,(i[1]+i[3])/2]},e.prototype.setFontSize=function(e){this.fontSize=e},e.prototype.getMarkupSize=function(e,t){var i=this.getMarkupBbox(e,t);return[Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1])]},e.prototype.getFontFamily=function(){return this.fontFamily},e.prototype.setFontFamily=function(e){this.fontFamily=e},e.prototype.translatePos=function(e,t,i,n){var o=this.markups[t];if(o&&(o.setPoints(o.originPoints),o.editPt&&(o.editPt=o.originEditPt),o.controlPt&&(o.controlPt=o.originControlPt),this.getMarkupCenter(e,t))){for(var s=n[0]-i[0],r=n[1]-i[1],a=o.originPoints,l=[],h=[],d=0;d<a.length;d++)h[d]=e.worldToClientPoint(a[d]),h[d][0]+=s,h[d][1]+=r,l[d]=e.clientToWorldPoint(h[d]);if(o.setPoints(l),"Cloud"==o.markupType){var c=(o.editPt&&o.originEditPt||o.controlPt&&o.originControlPt).slice();if(c){var u=[];for(d=0;d<c.length;d++)u[d]=e.worldToClientPoint(c[d]),u[d][0]+=s,u[d][1]+=r,c[d]=e.clientToWorldPoint(u[d]);o.editPt?o.editPt=c:o.controlPt=c}}}},e.prototype.isPointInCircle=function(e,t,i){return Li.distanceByArr(e,t)<=i},e.prototype.hitGrip=function(e,t,i){return this.MarkupVirtualPad.hitGrip(t[0],t[1])},e.prototype.getX=function(e,t,i,n){return(n-t)/i+e},e.prototype.getY=function(e,t,i,n){return(n-e)*i+t},e.prototype.gripRotate=function(e,t,i,n){var o=this.markups[t];o.rotation=o.originRotation;var s=this.getMarkupCenter(e,t),r=Math.sqrt(Math.pow(i[0]-s[0],2)+Math.pow(i[1]-s[1],2)),a=Math.sqrt(Math.pow(n[0]-s[0],2)+Math.pow(n[1]-s[1],2)),l=Math.sqrt(Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)),h=(l*l-r*r-a*a)/(-2*r*a),d=Math.acos(h),c=(i[1]-s[1])/(i[0]-s[0]),u=this.getY(i[0],i[1],c,n[0]),g=this.getX(i[0],i[1],c,n[1]);i[0]>s[0]&&i[1]<s[1]?n[0]<g&&n[1]<u&&(d=2*Math.PI-d):i[0]>s[0]&&i[1]>s[1]?n[0]>g&&n[1]<u&&(d=2*Math.PI-d):i[0]<s[0]&&i[1]>s[1]?n[0]>g&&n[1]>u&&(d=2*Math.PI-d):i[0]<s[0]&&i[1]<s[1]&&n[0]<g&&n[1]>u&&(d=2*Math.PI-d),o.rotation=o.originRotation+d},e.prototype.rotateTransform=function(e,t,i,n,o){i=-(i%=2*Math.PI);var s,r,a=Math.sin(i),l=Math.cos(i),h=(s=n-e)*a+(r=o-t)*l;return[s=s*l-r*a+e,r=h+t]},e.prototype.gripDragging=function(e,t,i,n,o){var s=this.markups[t],r=s.originPoints;s.setPoints(r),s.originUserText&&(s.userText=s.originUserText);var a=s.getGrips(e,this,t),l=this.getMarkupSize(e,t),h=l.slice(),d=this.getMarkupCenter(e,t),c=d.slice();if("Arrow"==s.markupType){var u=o[0]-n[0],g=o[1]-n[1],p=e.worldToClientPoint(r[0]),m=e.worldToClientPoint(r[1]);switch(i){case 0:p[0]+=u,p[1]+=g;break;case 4:m[0]+=u,m[1]+=g;break;default:console.log("default grip id."+i)}return p=e.clientToWorldPoint(p),m=e.clientToWorldPoint(m),void s.setPoints([p,m])}var f=this.rotateTransform(n[0],n[1],s.rotation,o[0],o[1]),w=f[0]-n[0],y=f[1]-n[1];switch(i){case 0:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[1]-=y,h[0]-=w;break;case 1:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),h[0]-=w;break;case 2:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[1]+=y,h[0]-=w;break;case 3:c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[1]+=y;break;case 4:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[0]+=w,h[1]+=y;break;case 5:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),h[0]+=w;break;case 6:c[0]+=.5*w*Math.cos(s.rotation),c[1]+=.5*w*Math.sin(s.rotation),c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[1]-=y,h[0]+=w;break;case 7:c[0]-=.5*y*Math.sin(s.rotation),c[1]+=.5*y*Math.cos(s.rotation),h[1]-=y}if("Cloud"!=s.markupType&&"Polyline"!=s.markupType&&"Handdrawing"!==s.markupType){var v=[c[0]-.5*h[0],c[1]-.5*h[1]],b=[c[0]+.5*h[0],c[1]+.5*h[1]];"Text"==s.markupType&&s.resizeText(h),v=e.clientToWorldPoint(v),b=e.clientToWorldPoint(b),s.setPoints([v,b])}else this.draggingMultipleGrip(e,s,i,n,o,w,y,a,l,h,d,c)},e.prototype.draggingMultipleGrip=function(e,t,i,n,o,s,r,a,l,h,d,c){var u=t.originPoints.slice(),g=d[0]-l[0]/2,p=d[1]-l[1]/2,m=c[0]-h[0]/2,f=c[1]-h[1]/2,w=function(t){for(var i=0;i<t.length;i++){var n=e.worldToClientPoint(t[i]),o=n[0],s=n[1],r=o-g,a=s-p;n[0]=r/l[0]*h[0]+m,n[1]=a/l[1]*h[1]+f,t[i]=e.clientToWorldPoint(n)}return t},y=w(u);if(t.setPoints(y),"Cloud"==t.markupType){var v=(t.originEditPt||t.originControlPt).slice();t.editPt=w(v)}},e}(),Ki=function(){function e(e,t,i){this.isMobile=i,this.canvas=document.createElement("canvas"),this.viewer=e,this.canvas.id="markupVirtual",this.canvas.width=t.clientWidth,this.canvas.height=t.clientHeight,document.body.appendChild(this.canvas),this.canvas.style.display="none",this.ctx=this.canvas.getContext("2d"),this.lineWidth=Ji.isMobile?18:6}return e.prototype.init=function(e,t){var i=this.ctx;i.save(),i.translate(e[0],e[1]),i.rotate(t),i.beginPath()},e.prototype.drawEdit=function(e,t,i,n,o,s,r,a,l,h){var d=this.ctx;if(d.save(),d.translate(i[0],i[1]),"Arrow"!=n.markupType&&("Text"===n.markupType&&(n.lineWidth=3),d.rotate(n.rotation)),d.beginPath(),d.lineWidth=n.lineWidth+2,d.fillStyle="rgba("+(2*s+2)+",255,255,1)",d.fillRect(-.5*(t[0]-e[0]),-.5*(t[1]-e[1]),t[0]-e[0],t[1]-e[1]),d.fillStyle=d.strokeStyle="rgba("+(2*s+2)+",100,255,1)",d.arc(0,e[1]-i[1]-20,14,0,2*Math.PI,!1),d.fill(),"Arrow"==n.markupType){var c=this.isMobile?12:6;d.fillStyle=d.strokeStyle="rgba("+(2*s+2)+",110,255,1)",d.beginPath(),d.arc(o[0]-i[0]+(o[0]<o[2]?-r/2:r/2),o[1]-i[1]+(o[1]<o[3]?-a/2:a/2),c,0,2*Math.PI,!1),d.fill(),d.stroke(),d.closePath(),d.fillStyle=d.strokeStyle="rgba("+(2*s+2)+",150,255,1)",d.beginPath(),d.arc(o[2]-i[0]+(o[0]<o[2]?r:-r),o[3]-i[1]+(o[1]<o[3]?a:-a),c,0,2*Math.PI,!1),d.fill(),d.stroke(),d.closePath()}else for(var u=h[0],g=h[1],p=0;p<o.length;p+=2){d.fillStyle=d.strokeStyle="rgba("+(2*s+2)+","+(5*p+110)+",255,1)",d.beginPath();var m=[o[p],o[p+1]];c=this.isMobile?12:6;switch(p){case 0:d.arc(m[0]-i[0]-l*u,m[1]-i[1]-l*g,c,0,2*Math.PI,!1);break;case 2:d.arc(m[0]-i[0]-l*u,m[1]-i[1],c,0,2*Math.PI,!1);break;case 4:d.arc(m[0]-i[0]-l*u,m[1]-i[1]+l*g,c,0,2*Math.PI,!1);break;case 6:d.arc(m[0]-i[0],m[1]-i[1]+l*g,c,0,2*Math.PI,!1);break;case 8:d.arc(m[0]-i[0]+l*u,m[1]-i[1]+l*g,c,0,2*Math.PI,!1);break;case 10:d.arc(m[0]-i[0]+l*u,m[1]-i[1],c,0,2*Math.PI,!1);break;case 12:d.arc(m[0]-i[0]+l*u,m[1]-i[1]-l*g,c,0,2*Math.PI,!1);break;case 14:d.arc(m[0]-i[0],m[1]-i[1]-l*g,c,0,2*Math.PI,!1)}d.fill(),d.stroke(),d.closePath()}d.restore()},e.prototype.drawArrow=function(e,t,i,n,o,s,r,a,l,h,d,c,u,g){var p=t-s,m=i-r,f=this.ctx;f.save(),f.lineWidth=Ji.isMobile?18:e.lineWidth+this.lineWidth,f.strokeStyle="rgba("+(2*c+2)+",20,20,1)",f.fillStyle="rgba("+(2*c+2)+",20,255,1)",f.beginPath(),f.moveTo(t,i),f.lineTo(n,o),p=n+s,m=o+r,f.moveTo(p,m),f.lineTo(n,o),p=n+a,m=o+l,f.lineTo(p,m),f.stroke(),f.restore()},e.prototype.drawRect=function(e,t,i,n,o,s){var r=this.ctx;r.save(),r.translate(n[0],n[1]),r.rotate(o),r.beginPath(),r.lineWidth=Ji.isMobile?18:e.lineWidth+this.lineWidth,r.strokeStyle="rgba("+(2*s+2)+",10,10,1)",r.fillStyle="rgba("+(2*s+2)+",10,255,1)",r.rect(-.5*(i[0]-t[0]),-.5*(i[1]-t[1]),i[0]-t[0],i[1]-t[1]),r.closePath(),r.stroke(),r.restore()},e.prototype.drawCross=function(e,t,i,n,o){var s=this.ctx;s.save(),s.translate(i[0],i[1]),s.rotate(n),s.strokeStyle="rgba("+(2*o+2)+",30,30,1)",s.fillStyle="rgba("+(2*o+2)+",30,255,1)",s.beginPath(),s.moveTo(-.5*(t[0]-e[0]),-.5*(t[1]-e[1])),s.lineTo(.5*(t[0]-e[0]),.5*(t[1]-e[1])),s.moveTo(-.5*(t[0]-e[0]),.5*(t[1]-e[1])),s.lineTo(.5*(t[0]-e[0]),-.5*(t[1]-e[1])),s.stroke(),s.restore()},e.prototype.drawCloudRect=function(e,t,i,n,o){var s=this.ctx;s.moveTo(e,t),s.quadraticCurveTo(i[0],i[1],n[0],n[1])},e.prototype.drawEllips=function(e,t,i,n,o,s,r){var a=this.ctx;a.save(),a.strokeStyle="rgba("+(2*o+2)+",50,50,1)",a.fillStyle="rgba("+(2*o+2)+",50,255,1)",a.translate(i[0],i[1]),a.rotate(n),a.beginPath(),a.ellipse(0,0,s,r,0,0,2*Math.PI),a.closePath(),a.stroke(),a.restore()},e.prototype.drawPolyline=function(e,t,i,n,o){var s=this.ctx;s.strokeStyle="rgba("+(2*o+2)+",70,70,1)",s.moveTo(e[0]-i[0],e[1]-i[1]),s.lineTo(t[0]-i[0],t[1]-i[1]),s.stroke()},e.prototype.drawHanddrawing=function(e,t,i,n){var o=this.ctx;o.moveTo(e[0]-n[0],e[1]-n[1]),o.quadraticCurveTo(t[0]-n[0],t[1]-n[1],i[0]-n[0],i[1]-n[1])},e.prototype.isEdge=function(e,t){var i=this.ctx.getImageData(e,t,1,1).data,n=i[0],o=i[1],s=i[2],r=i[3];return s==o&&o<100&&s%10==0&&n>=2&&255==r},e.prototype.hitTest=function(e,t){var i=this.ctx.getImageData(e,t,1,1).data,n=i[0],o=i[1],s=i[2],r=i[3];return n+o+s<3?-1:s==o&&o<100&&s%10==0&&n>=2&&255==r||255==s&&o>99?(n-2)/2:void 0},e.prototype.hitGrip=function(e,t){var i=this.ctx.getImageData(e,t,1,1).data,n=i[0],o=i[1],s=i[2];if(n+o+s+i[3]<3)return-1;if(255==s){if(100==o)return 9;if(255==o)return 10;if(o>=110)return(o-110)/10}return-1},e}(),Qi=mi,Ji=function(){function e(t,i,n){var o=this;this.getDevice=function(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),i=/(?:SymbianOS)/.test(e)||t,n=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e);/(?:Chrome|CriOS)/.test(e);var s=/(?:iPad|PlayBook)/.test(e)||n&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),r=/(?:iPhone)/.test(e)&&!s,a=/(?:iPhone|iPad)/.test(e);return{isPc:!(this.isMobileAgent||r||n||i||s),isMobileApple:a}},this.work=!1,this.alwaysMode=!1,this.restoreState=!1,this.firstTouch=0,this.longPressTime=0,this.longPressTimer=null,this.modelViewer=t,this.canvas=this.modelViewer._markupCanvas||document.createElement("canvas"),this.canvas.id="markup",this.canvas.style.zIndex=10,this.canvas.width=i.clientWidth,this.canvas.height=i.clientHeight,this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0",!this.modelViewer._markupCanvas&&(this.modelViewer._markupCanvas=this.canvas),this.ctx=this.canvas.getContext("2d"),this.wrapDom=i,this.canvas.style.display="none",this.isShow=!1,this.functions={},this.isMobileAgent=n,e.isMobile=n||!this.getDevice().isPc,i.appendChild(this.canvas),this.modelViewer._markupViewers||(this.modelViewer._markupViewers=[]),this.modelViewer._markupViewers.push(this),this.bindEvent();var s=this;this.viewer=t.getViewer?t.getViewer():t,this.viewer.wrapDom=i,this.MarkupVirtualPad=new Ki(this.viewer,i,e.isMobile),this.viewer.markupManager=this.markupManager=new qi(this.MarkupVirtualPad,this),this.editor=this.viewer.markupEditor=new Yi(this.canvas,this.markupManager,this.MarkupVirtualPad,this.getDevice(),this.modelViewer),this.editor.markupManager=this.viewer.markupManager,this.functions.onSelectChange=function(e){},this.functions.onClick=function(e){},this.functions.onTouch=function(e){},this.functions.onLongPress=function(e){},this.functions.itemCompleted=function(e){},this.functions.onDoubleClick=function(e){},this.isEnableAnnotationPick=!0,this.operationTypes=["Delete","Edit","Move","Rotate","Stretch"];this.modelViewer.addEventListener("Resized",(function(){s.canvas.width=i.clientWidth,s.canvas.height=i.clientHeight,s.MarkupVirtualPad.canvas.width=i.clientWidth,s.MarkupVirtualPad.canvas.height=i.clientHeight,s.update()})),e.isMobile&&(this.offsetHeight=this.wrapDom.offsetHeight,setInterval((function(){var e=o.wrapDom.offsetHeight;o.offsetHeight!=e&&(o.offsetHeight=e,o.resize())}),500))}return e.prototype.resize=function(){this.editor.tool.reposition&&this.editor.tool.reposition(this.viewer)},e.prototype.getContainerSize=function(){return this.wrapDom.getBoundingClientRect()},e.prototype.setOperationTypes=function(e){this.operationTypes=e},e.prototype.setIsEnableAnnotationPick=function(e){this.isEnableAnnotationPick=e},e.prototype.hideCanvas=function(){this.isShow=!1,this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.update()}));var e=!0;this.modelViewer._markupViewers.map((function(t){t.isShow&&(e=!1)})),e&&(this.canvas.style.display="none")},e.prototype.showCanvas=function(){this.isShow=!0,this.canvas.style.display="block",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.update()}))},e.prototype.redrawOtherMarkups=function(){var e=this;this.modelViewer._markupViewers.map((function(t){t.isShow&&t!==e&&t.updateOnlySelf()}))},e.prototype.startDrawing=function(){var e=this;this.work=!0,this.alwaysMode=!1,this.modelViewer._markupViewers.map((function(t){t!==e&&(t.editor.setCurIndex(-1),t.alwaysMode=!0)})),this.showCanvas()},e.prototype.switchMode=function(){},e.prototype.initStyle=function(){var e=this.viewer.markupManager;e.markups=[],e.strokeStyle="red",e.lineWidth=3,e.fontSize=14,e.fontFamily="Arial",e.fillStyle="white",e.enableFillStyle=!1},e.prototype.update=function(){this.editor.redraw(this.viewer)},e.prototype.updateOnlySelf=function(){this.editor.redrawOnlySelf(this.viewer)},e.prototype.onlyShowSelf=function(){var e=this;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(t){t===e&&t.updateOnlySelf()}))},e.prototype.recoverAllMarkupState=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.modelViewer._markupViewers.map((function(e){e.isShow&&e.updateOnlySelf()}))},e.prototype.bindEvent=function(){this.getDevice().isPc?(this.wrapDom.addEventListener("dblclick",this.onDoubleClick.bind(this),!1),this.wrapDom.addEventListener("mousedown",this.onMouseDown.bind(this),!0),"ViewerDrawing"===this.modelViewer.getViewerType()?this.wrapDom.parentElement.parentElement.addEventListener("mouseup",this.onMouseUp.bind(this),!0):this.wrapDom.addEventListener("mouseup",this.onMouseUp.bind(this),!1),this.wrapDom.addEventListener("mousemove",this.onMouseMove.bind(this),!1),this.wrapDom.addEventListener("mousewheel",this.onMouseWheel.bind(this),!1),this.wrapDom.addEventListener("DOMMouseScroll",this.onMouseWheel.bind(this),!1),this.wrapDom.addEventListener("contextmenu",this.oncontextmenu.bind(this),!1)):(this.wrapDom.addEventListener("touchstart",this.onTouchstart.bind(this),!0),this.wrapDom.addEventListener("touchend",this.onTouchend.bind(this),!0),this.wrapDom.addEventListener("touchmove",this.onTouchmove.bind(this),!0)),document.addEventListener("keydown",this.onKeyDown.bind(this)),document.addEventListener("keyup",this.onKeyUp.bind(this))},e.prototype.endDrawing=function(){this.work=!1,this.clearAnnotations(),this.editor.redraw(this.viewer),this.hideCanvas(),this.switchMode(),this.restoreState=!1;var e=document.querySelector("#bf-drawing-textEditor");if(e){var t=e.querySelectorAll("textarea");t.length&&(t[t.length-1].style.display="none",t[t.length-1].value="")}},e.prototype.clearAnnotations=function(){this.markupManager.clear(),this.update()},e.prototype.removeSelectedAnnotation=function(){-1!=this.editor.editIndex&&(this.markupManager.remove(this.editor.editIndex),this.editor.editIndex=-1,this.update())},e.prototype.createSnapshot=function(e){},e.prototype.showAnnotation=function(){},e.prototype.setAnnotationType=function(e){this.editor.setMarkupType(e),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)},e.prototype.setAnnotationStyle=function(e){e["stroke-color"]&&this.markupManager.setColor(e["stroke-color"]),e["font-size"]&&this.markupManager.setFontSize(e["font-size"]),e["stroke-width"]&&this.markupManager.setLineWidth(e["stroke-width"]),e["fill-color"]&&this.markupManager.setFillColor(e["fill-color"]),e["font-family"]&&this.markupManager.setFontFamily(e["font-family"])},e.prototype.getAnnotationList=function(){return this.markupManager.markups.slice()},e.prototype.setAnnotationList=function(e){var t=e[0];if(!t)return this.clearAnnotations();if(t.drawPoints&&"number"==typeof t.drawPoints[0])for(var i=0;i<e.length;i++){for(var n=e[i].drawPoints,o=[],s=0;s<n.length;s+=2)o.push([n[s],n[s+1]]);e[i].drawPoints=o}t&&t.draw||(e=Zi.transform2markups(e)),this.markupManager.setMarkups(e),this.restoreState=!0,this.showCanvas(),this.update()},e.prototype.editAnnotationEnd=function(){this.endDrawing()},e.prototype.getCurrentState=function(){return{annotationList:this.getAnnotationList(),state:this.modelViewer.getCurrentState()}},e.prototype.transform=function(e){return e},e.prototype.setState=function(e){var t=this;this.clearAnnotations(),this.modelViewer.setState(e.state),0!==("string"==typeof e.annotationList?JSON.parse(e.annotationList):e.annotationList).length&&setTimeout((function(){if("string"==typeof e.annotationList){var i=t.markupManager.fromString(e.annotationList);t.setAnnotationList(i)}else e.annotationList[0].id?t.setAnnotationList(t.transform(e.annotationList)):t.setAnnotationList(e.annotationList)}),1500)},e.prototype.oncontextmenu=function(e){e.preventDefault()},e.prototype.onDoubleClick=function(e){if(this.isShow){if(clearTimeout(this.clickStore),this.alwaysMode)return e.preventDefault(),void this.editor.onDoubleClick(this.viewer,e);!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),e.preventDefault(),this.editor.onDoubleClick(this.viewer,e)}},e.prototype.onMouseDown=function(e){this.isShow&&(this.mouseDownClientX=e.clientX,this.mouseDownClientY=e.clientY,this.alwaysMode||(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&e.target==this.canvas&&(e.preventDefault(),e.buttons==Qi.LelftButton?(e.stopPropagation(),this.editor.onMouseDown(this.viewer,e)):this.editor.onMouseDown(this.viewer,e))))},e.prototype.onTouchstart=function(e){if(this.isShow){!this.work&&e.touches.length<2&&this.editor.onTouch(this.viewer,e);var t=this;if(clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((function(){t.work||1!==e.changedTouches.length||t.editor.onLongPress(t.viewer,e)}),this.longPressTime),!this.alwaysMode&&"CANVAS"==e.target.tagName.toUpperCase()){var i=Date.now();i-this.firstTouch<500&&this.editor.crtMarkupType&&"handdrawing"!==this.editor.crtMarkupType?this.editor.onDoubleTouch(this.viewer,e):(this.firstTouch=i,!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&e.target==this.canvas&&(e.preventDefault(),e.buttons==Qi.LelftButton&&e.stopPropagation(),this.editor.onTouchstart(this.viewer,e),this.containerSize=this.getContainerSize()))}}},e.prototype.onMouseMove=function(e){if(this.isShow)return this.alwaysMode?(this.update(),void this.editor.onMouseMove(this.viewer,e)):void(this.work&&("Viewer3D"===this.modelViewer.viewerType&&this.modelViewer.snap||"ViewerDrawing"===this.modelViewer.viewerType&&this.modelViewer.snapIsEnabled||(e.preventDefault(),e.stopPropagation()),this.editor.onMouseMove(this.viewer,e)))},e.prototype.onTouchmove=function(e){if(this.isShow){if(clearTimeout(this.longPressTimer),this.alwaysMode||"CANVAS"!=e.target.tagName.toUpperCase())return this.update(),void this.editor.onMouseMove(this.viewer,e);if(this.work){var t=e.touches[0],i=this.containerSize,n=i.left,o=i.top,s=i.width,r=i.height;e.preventDefault(),e.stopPropagation(),t.pageX>n&&t.pageX<n+s&&t.pageY>o&&t.pageY<o+r&&this.editor.onTouchmove(this.viewer,e)}}},e.prototype.onTouchend=function(e){this.isShow&&(clearTimeout(this.longPressTimer),this.alwaysMode||"CANVAS"!=e.target.tagName.toUpperCase()?this.update():(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&(e.preventDefault(),e.stopPropagation(),this.editor.onTouchend(this.viewer,e))))},e.prototype.onMouseWheel=function(e){this.isShow&&(this.alwaysMode||(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&(e.preventDefault(),e.stopPropagation(),this.editor.onMouseWheel(this.viewer,e))))},e.prototype.onMouseUp=function(e){var t=this;this.isShow&&(clearTimeout(this.clickStore),this.mouseDownClientX!==e.clientX||this.mouseDownClientY!==e.clientY||this.editor.getStart()||(this.clickStore=setTimeout((function(){t.editor.onClick(t.viewer,e)}),500)),this.alwaysMode||e.button==Qi.FINISHED?this.editor.onMouseUp(this.viewer,e,!0):(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&(e.preventDefault(),e.stopPropagation(),this.editor.onMouseUp(this.viewer,e,!0))))},e.prototype.onKeyDown=function(e){this.isShow&&this.work&&("textarea"!=document.activeElement.tagName.toLowerCase()&&e.stopPropagation(),this.editor.onKeyDown(this.viewer,e))},e.prototype.onKeyUp=function(e){this.isShow&&this.work&&"textarea"!=document.activeElement.tagName.toLowerCase()&&(e.preventDefault(),e.stopPropagation())},e.prototype.setLongPressTime=function(e){this.longPressTime=e},e}(),en=function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.modelViewer.addEventListener("Rendered",(function(){o.update()})),o.viewer.clientToWorldPoint=function(e){return o.viewer.toWorldPoint(e)},o.viewer.worldToClientPoint=function(e){return e?o.viewer.toScreenPoint([e[0],e[1]]):[]},o.isLock=!1,o}return pi(t,e),t.prototype.getCurrentState=function(){return{annotationList:this.getAnnotationList(),state:JSON.parse(this.modelViewer.getCurrentState())}},t.prototype.startDrawing=function(){var e=this;this.isLock||(this.canvas.style.zIndex=10,this.work=!0,this.alwaysMode=!1,this.modelViewer._markupViewers.map((function(t){t!==e&&(t.editor.setCurIndex(-1),t.alwaysMode=!0)})),this.showCanvas(),this.switchMode())},t.prototype.onTouchstart=function(e){!this.work&&e.target==this.canvas&&e.touches.length<2&&this.editor.onTouch(this.viewer,e);var t=this;if(clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((function(){t.work||1!==e.changedTouches.length||t.editor.onLongPress(t.viewer,e)}),this.longPressTime),!this.alwaysMode&&!this.isLock){var i=Date.now();i-this.firstTouch<500&&this.editor.crtMarkupType&&"handdrawing"!==this.editor.crtMarkupType?this.editor.onDoubleTouch(this.viewer,e):(this.firstTouch=i,!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&e.target==this.canvas&&e.touches.length<2&&(e.preventDefault(),this.editor.onTouchstart(this.viewer,e),this.containerSize=this.getContainerSize()))}},t.prototype.onTouchmove=function(e){if(clearTimeout(this.longPressTimer),this.alwaysMode||this.isLock)this.update();else if(this.work){var t=e.touches[0],i=this.containerSize,n=i.left,o=i.top,s=i.width,r=i.height;e.touches.length<2?(e.preventDefault(),e.stopPropagation(),t.pageX>n&&t.pageX<n+s&&t.pageY>o&&t.pageY<o+r&&this.editor.onTouchmove(this.viewer,e)):this.update()}},t.prototype.showAnnotation=function(){this.alwaysMode=!0,this.canvas.style.zIndex=5,this.editor.editIndex=-1,this.update(),this.showCanvas()},t.prototype.hideAnnotation=function(){this.editor.editIndex=-1,this.editor.setCurIndex(-1),this.hideCanvas()},t.prototype.setState=function(e){if("string"!=typeof e.state&&(e.state=JSON.stringify(e.state)),this.modelViewer.setState(e.state),0!==("string"==typeof e.annotationList?JSON.parse(e.annotationList):e.annotationList).length)if("string"==typeof e.annotationList){var t=this.markupManager.fromString(e.annotationList);this.setAnnotationList(t)}else e.annotationList[0].id?this.setAnnotationList(this.transform(e.annotationList)):this.setAnnotationList(e.annotationList)},t.prototype.onMouseWheel=function(e){this.alwaysMode?this.update():(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&(e.preventDefault(),this.update(),this.editor.onMouseWheel(this.viewer,e)))},t.prototype.createSnapshot=function(e){var t=this.viewer.snapshotPure(),i=document.createElement("canvas");i.width=this.wrapDom.clientWidth,i.height=this.wrapDom.clientHeight,this.onlyShowSelf();var n=i.getContext("2d");n.beginPath(),n.fillStyle=this.wrapDom.style.background,n.fillRect(0,0,i.width,i.height),n.drawImage(t,0,0),n.drawImage(this.canvas,0,0),this.onlyShowSelf(),e(i.toDataURL())},t.prototype.switchMode=function(){},t.prototype.lockAnnotationAction=function(){this.isLock=!0,this.alwaysMode=!0,document.getElementById(Ni.lastTextareaId)&&this.editor.tool.onExit(),this.editor.tool.markup=null,this.editor.tool.bFirstCloudMarkup=!0,this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)},t.prototype.restoreAnnotationAction=function(){this.isLock=!1,this.alwaysMode=!1,this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer),this.startDrawing()},t.prototype.highlightAnnotationByIds=function(e){var t=this,i=this.getAnnotationList();if(e&&i.length&&e.length){Array.isArray(e)||(e=[e]);var n=null;e.forEach((function(e){(n=i.find((function(t){return t.markupId==e})))&&(n.highlightColor=t.markupManager.highlightConfig.highlightColor)})),this.setAnnotationList(i),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)}},t.prototype.clearHighlight=function(){var e=this.getAnnotationList();e.length&&(e.map((function(e){e.highlightColor=""})),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer))},t.prototype.setHighlightConfig=function(e){this.markupManager.highlightConfig=e},t}(Ji),tn=function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.modelViewer.addEventListener("Rendered",(function(){o.update()})),o.viewer.clientToWorldPoint=function(e){return o.viewer.views[o.modelViewer._defaultViewId].toWorldPoint(e)},o.viewer.worldToClientPoint=function(e){return e?o.viewer.views[o.modelViewer._defaultViewId].toScreenPoint([e[0],e[1]]):[]},o}return pi(t,e),t.prototype.getCurrentState=function(){return{annotationList:this.getAnnotationList(),state:JSON.parse(this.modelViewer.getCurrentState())}},t.prototype.startDrawing=function(){var e=this;this.canvas.style.zIndex=10,this.work=!0,this.alwaysMode=!1,this.modelViewer._markupViewers.map((function(t){t!==e&&(t.editor.setCurIndex(-1),t.alwaysMode=!0)})),this.showCanvas(),this.switchMode()},t.prototype.onTouchstart=function(e){if(!this.alwaysMode){var t=Date.now();t-this.firstTouch<500?this.editor.onDoubleTouch(this.viewer,e):(this.firstTouch=t,!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&e.target==this.canvas&&e.touches.length<2&&(e.preventDefault(),this.editor.onTouchstart(this.viewer,e),this.containerSize=this.getContainerSize()))}},t.prototype.onTouchmove=function(e){if(this.alwaysMode)this.update();else if(this.work){var t=e.touches[0],i=this.containerSize,n=i.left,o=i.top,s=i.width,r=i.height;e.touches.length<2?(e.preventDefault(),e.stopPropagation(),t.pageX>n&&t.pageX<n+s&&t.pageY>o&&t.pageY<o+r&&this.editor.onTouchmove(this.viewer,e)):this.update()}},t.prototype.showAnnotation=function(){this.alwaysMode=!0,this.canvas.style.zIndex=5,this.editor.editIndex=-1,this.update(),this.showCanvas()},t.prototype.hideAnnotation=function(){this.editor.editIndex=-1,this.editor.setCurIndex(-1),this.hideCanvas()},t.prototype.setState=function(e){if("string"!=typeof e.state&&(e.state=JSON.stringify(e.state)),this.modelViewer.setState(e.state),0!==("string"==typeof e.annotationList?JSON.parse(e.annotationList):e.annotationList).length)if("string"==typeof e.annotationList){var t=this.markupManager.fromString(e.annotationList);this.setAnnotationList(t)}else e.annotationList[0].id?this.setAnnotationList(this.transform(e.annotationList)):this.setAnnotationList(e.annotationList)},t.prototype.onMouseWheel=function(e){this.alwaysMode?this.update():(!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&(e.preventDefault(),this.update(),this.editor.onMouseWheel(this.viewer,e)))},t.prototype.createSnapshot=function(e){var t=document.createElement("canvas");t.width=this.canvas.clientWidth,t.height=this.canvas.clientHeight,this.onlyShowSelf();var i=t.getContext("2d");i.beginPath(),i.drawImage(this.canvas,0,0),this.recoverAllMarkupState();var n=this;n.viewer.views[n.modelViewer._defaultViewId].snapshotPure().then((function(i){var o=document.createElement("canvas");o.width=n.wrapDom.clientWidth,o.height=n.wrapDom.clientHeight;var s=o.getContext("2d");s.beginPath(),s.fillStyle=n.wrapDom.style.background,s.fillRect(0,0,o.width,o.height),s.drawImage(i,0,0),s.drawImage(t,0,0),e(o.toDataURL())}))},t.prototype.switchMode=function(){},t.prototype.highlightAnnotationByIds=function(e){var t=this,i=this.getAnnotationList();if(e&&i.length&&e.length){Array.isArray(e)||(e=[e]);var n=null;e.forEach((function(e){(n=i.find((function(t){return t.markupId==e})))&&(n.highlightColor=t.markupManager.highlightConfig.highlightColor)})),this.setAnnotationList(i),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)}},t.prototype.clearHighlight=function(){var e=this.getAnnotationList();e.length&&(e.map((function(e){e.highlightColor=""})),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer))},t.prototype.setHighlightConfig=function(e){this.markupManager.highlightConfig=e},t}(Ji),nn=function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.cameraControl=o.viewer.cameraControl,o.viewBox={width:1e3,height:1e3},o.viewer.clientToWorldPoint=function(e){var t={x:e[0],y:e[1],z:0},i=o.modelViewer.clientToWorld(t);return[i.x,i.y,i.z]},o.viewer.worldToClientPoint=function(e){var t={x:e[0],y:e[1],z:e[2]||0},i=o.modelViewer.worldToClient(t);return[i.x,i.y]},o}return pi(t,e),t.prototype.bindEvent=function(){this.getDevice().isPc?(this.wrapDom.addEventListener("dblclick",this.onDoubleClick.bind(this),!0),this.wrapDom.addEventListener("mousedown",this.onMouseDown.bind(this),!0),this.wrapDom.addEventListener("mouseup",this.onMouseUp.bind(this),!0),this.wrapDom.addEventListener("mousemove",this.onMouseMove.bind(this),!0),this.wrapDom.addEventListener("mousewheel",this.onMouseWheel.bind(this),!0),this.wrapDom.addEventListener("DOMMouseScroll",this.onMouseWheel.bind(this),!0),this.wrapDom.addEventListener("contextmenu",this.oncontextmenu.bind(this),!0),document.addEventListener("keydown",this.onKeyDown.bind(this),!0),document.addEventListener("keyup",this.onKeyUp.bind(this),!0)):(this.wrapDom.addEventListener("touchstart",this.onTouchstart.bind(this),!0),this.wrapDom.addEventListener("touchend",this.onTouchend.bind(this),!0),this.wrapDom.addEventListener("touchmove",this.onTouchmove.bind(this),!0))},t.prototype.showAnnotation=function(){this.alwaysMode=!0,this.canvas.style.zIndex=5,this.editor.editIndex=-1,this.update(),this.showCanvas()},t.prototype.hideAnnotation=function(){this.editor.editIndex=-1,this.editor.setCurIndex(-1),this.hideCanvas()},t.prototype.createSnapshot=function(e){var t=this.wrapDom.querySelector(".bf-view canvas"),i=document.createElement("canvas");i.width=this.wrapDom.clientWidth,i.height=this.wrapDom.clientHeight,this.onlyShowSelf();var n=i.getContext("2d");n.beginPath();var o=window.devicePixelRatio||1;n.drawImage(t,0,0,i.width*o,i.height*o,0,0,i.width,i.height),n.drawImage(this.canvas,0,0),this.recoverAllMarkupState(),e(i.toDataURL())},t.prototype.transform=function(e){for(var t=[],i=0;i<e.length;i++){var n,o=e[i],s=o.style,r=s["fill-opacity"];switch(o.shapeType){case 0:var a=this.getArrowPoints(o.size,o.position,-o.rotation);n=new Ti(a,s["stroke-color"],s["stroke-width"],o.rotation);break;case 7:n=new Ri(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 4:var l=this.getCloudPoints(o);(n=new Di(l[0],s["stroke-color"],s["stroke-width"],l[1],o.rotation,r&&s["fill-color"],!0)).close=!0;break;case 1:n=new Mi(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 2:n=new vi(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 3:n=new Si(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation);break;case 5:var h=this.worldToClient({x:o.position.x-.5*o.size.width,y:o.position.y+.5*o.size.height,z:o.position.z}),d=this.worldToClient(o.position),c=this.viewer.clientToWorldPoint([d.x,d.y]);n=new Hi(this.viewer.clientToWorldPoint([h.x,h.y]),decodeURIComponent(o.text),s["stroke-color"],s["font-size"],s["font-family"],o.rotation,null,c)}t.push(n)}return t},t.prototype.getCloudPoints=function(e){var t=e.size.width/e.originSize.width,i=e.size.height/e.originSize.height,n=(new window.THREE.Matrix4).makeScale(t,i,1),o=(new window.THREE.Matrix4).makeRotationZ(-e.rotation),s=(new window.THREE.Matrix4).makeTranslation(e.position.x,e.position.y,e.position.z).multiply(o).multiply(n),r=e.shapePoints.split(","),a=[],l=[],h=!0;e.position;for(var d=1;d<r.length;d+=2){var c=new window.THREE.Vector3,u=this.viewBoxToWorld({x:parseInt(r[d-1]),y:parseInt(r[d])},e.originSize);c.x=u.x,c.y=u.y,c.z=0,c.applyMatrix4(s);var g=this.worldToClient(c),p=this.viewer.clientToWorldPoint([g.x,g.y]);h?a.push(p):l.push(p),h=!h}return[a,l]},t.prototype.viewBoxToWorld=function(e,t){var i=t.width,n=t.height,o=this.viewBox.width,s=this.viewBox.height;return{x:e.x/o*i,y:e.y/s*n}},t.prototype.getDrawPoints=function(e,t){var i=this.worldToClient({x:t.x-.5*e.width,y:t.y-.5*e.height,z:t.z}),n=this.worldToClient({x:t.x+.5*e.width,y:t.y+.5*e.height,z:t.z});return[this.viewer.clientToWorldPoint([i.x,i.y]),this.viewer.clientToWorldPoint([n.x,n.y])]},t.prototype.getArrowPoints=function(e,t,i){var n=this.worldToClient({x:t.x-.5*e.width,y:t.y,z:t.z}),o=this.worldToClient({x:t.x+.5*e.width,y:t.y,z:t.z}),s=this.worldToClient(t);return n=this.markupManager.rotateTransform(s.x,s.y,i,n.x,n.y),o=this.markupManager.rotateTransform(s.x,s.y,i,o.x,o.y),[this.viewer.clientToWorldPoint(n),this.viewer.clientToWorldPoint(o)]},t.prototype.worldToClient=function(e){var t=this.getContainerOffsetToClient(this.wrapDom),i=this.cameraControl.getCamera(),n=new window.THREE.Vector3(e.x,e.y,e.z);return n.applyMatrix4(i.matrixWorld),n.sub(i.position),n.project(i),n.x=Math.floor(.5*(n.x+1)*t.width+.5),n.y=Math.floor(-.5*(n.y-1)*t.height+.5),n.z=0,n},t.prototype.getContainerOffsetToClient=function(e){var t,i;if(e!=document){var n=(i=e).getBoundingClientRect?function(e){var t=e.getBoundingClientRect(),i=document.body,n=document.documentElement,o=n.clientTop||i.clientTop,s=n.clientLeft||i.clientLeft,r=t.top-o,a=t.left-s;return{top:Math.round(r),left:Math.round(a)}}(i):function(e){for(var t=0,i=0;e;)t+=e.offsetTop,i+=e.offsetLeft,e=e.offsetParent;var n=document.body,o=document.documentElement;return{top:t-=window.pageYOffset||o.scrollTop||n.scrollTop,left:i-=window.pageXOffset||o.scrollLeft||n.scrollLeft}}(i);t={width:e.offsetWidth,height:e.offsetHeight,left:n.left,top:n.top}}else t={width:window.innerWidth,height:window.innerHeight,left:0,top:0};return t},t.prototype.highlightAnnotationByIds=function(e){var t=this,i=this.getAnnotationList();if(e&&i.length&&e.length){Array.isArray(e)||(e=[e]);var n=null;e.forEach((function(e){(n=i.find((function(t){return t.markupId==e})))&&(n.highlightColor=t.markupManager.highlightConfig.highlightColor)})),this.setAnnotationList(i),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer)}},t.prototype.clearHighlight=function(){var e=this.getAnnotationList();e.length&&(e.map((function(e){e.highlightColor=""})),this.editor.tool.redraw&&this.editor.tool.redraw(this.viewer))},t.prototype.setHighlightConfig=function(e){this.markupManager.highlightConfig=e},t}(Ji),on=mi,sn=function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.absoluteBasePoint=null,o.screenBasePoint=null,o.zoomFactor={x:1,y:1},o.viewBox={width:1e3,height:1e3},o.viewer.clientToWorldPoint=function(e){var t=o.viewer.clientToWorld({x:e[0],y:e[1]});return[t.x,t.y]},o.viewer.worldToClientPoint=function(e){var t=o.viewer.worldToClient({x:e[0],y:e[1]});return[t.x,t.y]},o}return pi(t,e),t.prototype.onMouseUp=function(e){!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&this.editor.onMouseUp(this.viewer,e)},t.prototype.setState=function(e){if(this.modelViewer.setState(e.state),0!==("string"==typeof e.annotationList?JSON.parse(e.annotationList):e.annotationList).length)if("string"==typeof e.annotationList){var t=this.markupManager.fromString(e.annotationList);this.setAnnotationList(t)}else e.annotationList[0].id?this.setAnnotationList(this.transform(e.annotationList)):this.setAnnotationList(e.annotationList)},t.prototype.createSnapshot=function(e){var t=this;this.viewer._imageRender.createSnapshotAsync("",(function(i){t.getScreenSnapshot(i,e)}))},t.prototype.getScreenSnapshot=function(e,t){var i=document.createElement("canvas"),n=this.getContainerOffsetToClient(this.wrapDom);i.width=n.width,i.height=n.height;var o,s=i.getContext("2d"),r=this;if(t&&e)return(o=new Image).onload=function(){s.drawImage(o,0,0),s.drawImage(r.canvas,0,0);var e=i.toDataURL("image/png");i=s=null,t(e)},o.src=e,null;e&&((o=new Image).src=e,s.drawImage(o,0,0));s.drawImage(this.canvas,0,0);var a=i.toDataURL("image/png");return i=s=null,a},t.prototype.transform=function(e){for(var t=[],i=0;i<e.length;i++){var n,o=e[i],s=o.style,r=s["fill-opacity"];switch(o.shapeType){case 0:var a=this.getArrowPoints(o.size,o.position,-o.rotation);n=new Ti(a,s["stroke-color"],s["stroke-width"],o.rotation);break;case 7:n=new Ri(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 4:var l=this.getCloudPoints(o);n=new Di(l[0],s["stroke-color"],s["stroke-width"],l[1],o.rotation,r&&s["fill-color"]);break;case 1:n=new Mi(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 2:n=new vi(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation,r&&s["fill-color"]);break;case 3:n=new Si(this.getDrawPoints(o.size,o.position),s["stroke-color"],s["stroke-width"],o.rotation);break;case 5:var h=this.worldToClient({x:o.position.x-.5*o.size.width,y:o.position.y+.5*o.size.height,z:o.position.z}),d=this.worldToClient(o.position),c=this.viewer.clientToWorldPoint([d.x,d.y]);n=new Hi(this.viewer.clientToWorldPoint([h.x,h.y]),decodeURIComponent(o.text),s["stroke-color"],s["font-size"],s["font-family"],o.rotation,null,c)}t.push(n)}return t},t.prototype.getContainerOffsetToClient=function(e){var t,i;if(e!=document){var n=(i=e).getBoundingClientRect?function(e){var t=e.getBoundingClientRect(),i=document.body,n=document.documentElement,o=n.clientTop||i.clientTop,s=n.clientLeft||i.clientLeft,r=t.top-o,a=t.left-s;return{top:Math.round(r),left:Math.round(a)}}(i):function(e){for(var t=0,i=0;e;)t+=e.offsetTop,i+=e.offsetLeft,e=e.offsetParent;var n=document.body,o=document.documentElement;return{top:t-=window.pageYOffset||o.scrollTop||n.scrollTop,left:i-=window.pageXOffset||o.scrollLeft||n.scrollLeft}}(i);t={width:e.offsetWidth,height:e.offsetHeight,left:n.left,top:n.top}}else t={width:window.innerWidth,height:window.innerHeight,left:0,top:0};return t},t.prototype.getCloudPoints=function(e){var t=e.size.width/e.originSize.width,i=e.size.height/e.originSize.height,n=(new window.THREE.Matrix4).makeScale(t,i,1),o=(new window.THREE.Matrix4).makeRotationZ(-e.rotation),s=(new window.THREE.Matrix4).makeTranslation(e.position.x,e.position.y,e.position.z).multiply(o).multiply(n),r=e.shapePoints.split(","),a=[],l=[],h=!0;e.position;for(var d=1;d<r.length;d+=2){var c=new window.THREE.Vector3,u=this.viewBoxToWorld({x:parseInt(r[d-1]),y:parseInt(r[d])},e.originSize);c.x=u.x,c.y=u.y,c.z=0,c.applyMatrix4(s);var g=this.worldToClient(c),p=this.viewer.clientToWorldPoint([g.x,g.y]);h?a.push(p):l.push(p),h=!h}return[a,l]},t.prototype.worldToClient=function(e){var t=this.getContainerOffsetToClient(this.wrapDom),i=new window.THREE.Vector3,n=this.absoluteBasePoint,o=this.screenBasePoint;return this.absoluteBasePoint||(n={x:0,y:0}),this.screenBasePoint||(o={x:.5*t.width,y:.5*t.height}),i.x=(e.x-n.x)*this.zoomFactor.x+o.x,i.y=(-e.y-n.y)*this.zoomFactor.y+o.y,i.z=0,i},t.prototype.viewBoxToWorld=function(e,t){var i=t.width,n=t.height,o=this.viewBox.width,s=this.viewBox.height;return{x:e.x/o*i,y:e.y/s*n}},t.prototype.getDrawPoints=function(e,t){var i=this.worldToClient({x:t.x-.5*e.width,y:t.y-.5*e.height,z:t.z}),n=this.worldToClient({x:t.x+.5*e.width,y:t.y+.5*e.height,z:t.z});return[this.viewer.clientToWorldPoint([i.x,i.y]),this.viewer.clientToWorldPoint([n.x,n.y])]},t.prototype.getArrowPoints=function(e,t,i){var n=this.worldToClient({x:t.x-.5*e.width,y:t.y,z:t.z}),o=this.worldToClient({x:t.x+.5*e.width,y:t.y,z:t.z}),s=this.worldToClient(t);return n=this.markupManager.rotateTransform(s.x,s.y,i,n.x,n.y),o=this.markupManager.rotateTransform(s.x,s.y,i,o.x,o.y),[this.viewer.clientToWorldPoint(n),this.viewer.clientToWorldPoint(o)]},t.prototype.onMouseDown=function(e){!this.work&&this.restoreState&&(this.restoreState=!1,this.endDrawing()),this.work&&e.target==this.canvas&&(e.preventDefault(),e.buttons==on.LelftButton?(e.stopPropagation(),this.editor.onMouseDown(this.viewer,e)):this.editor.onMouseDown(this.viewer,e))},t.prototype.onMouseWheel=function(e){this.work&&(e.preventDefault(),this.update(),this.editor.onMouseWheel(this.viewer,e))},t}(Ji);!function(){var t="Bimface.Plugins.Annotation.AnnotationManager",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),o=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(t){var i=this,n=t.viewer;this._opt=t,this.console=n.console,this.isShowAnnotation=!1,this.historyQueue=[],P(this);const o="Mobile"===n._opt.navigatorType;if(e.Bimface.Viewer.Viewer3D&&"Viewer3D"===n.viewerType)this._helper=new nn(n,n._opt.domElement,o);else if(e.Bimface.Viewer.Viewer2D&&n instanceof e.Bimface.Viewer.Viewer2D)this.isViewer2D=!0,this._helper=new sn(n,n._opt.domElement.querySelector(".bf-image"),o);else if(e.Bimface.Viewer.ViewerPDF&&n instanceof e.Bimface.Viewer.ViewerPDF)this._helper=new tn(n,n._opt.domElement.querySelector(".bf-pdf-outer"),o);else{this._helper=new en(n,n._opt.domElement,o);let t={hoverColor:"#ADADAD",highlightColor:"#3DCC93"};n.getDisplayMode&&0===n.getDisplayMode()&&(t={hoverColor:"#FFFFFF",highlightColor:"#3DCC93"}),this._helper.setHighlightConfig&&this._helper.setHighlightConfig(t),this._helper.modelViewer&&this._helper.modelViewer.addEventListener(e.Bimface.Viewer.ViewerDrawingEvent.ViewChanged,(function(){i.hideAnnotation(),i.showAnnotation()}))}this._helper.functions.onSelectChange=e=>{this.onSelectChange(e)},this._helper.functions.itemCompleted=e=>{this.itemCompleted(e)},window.addEventListener("resize",(()=>{this._helper.update()})),this.init()});o.prototype={init:function(){var e=this._opt;e.lineWidth&&this.setLineWidth(e.lineWidth),e.lineColor&&this.setLineColor(e.lineColor),e.fillColor&&this.setFillColor(e.fillColor),e.fontFamily&&this.setFontFamily(e.fontFamily),e.fontSize&&this.setFontSize(e.fontSize)},exit:function(){this.endDrawing()},onSelectChange(e){},onClick(e){this._helper.functions.onClick=e},onTouch(e){this._helper.functions.onTouch=e},onLongPress(e,n){i.send(t,"onLongPress"),0==arguments.length||1==arguments.length&&"number"!=typeof arguments[0]?this.console.warn("Parameter pressTime is required"):2!=arguments.length||"number"==typeof arguments[0]?(this._helper.setLongPressTime(e),this._helper.functions.onLongPress=n):this.console.warn("Incorrect parameter type of pressTime")},itemCompleted(e){this._helper.functions.itemCompleted=e},onDoubleClick(e){this._helper.functions.onDoubleClick=e},enablePick(e){this._helper.setIsEnableAnnotationPick(e)},setOperationMode(e){"[object Array]"===Object.prototype.toString.call(e)&&this._helper.setOperationTypes(e)},restoreOperationMode(){this._helper.setOperationTypes(["Delete","Edit","Move","Rotate","Stretch"])},getAnnotationList:function(){if(this._helper.viewer&&this._helper.viewer.getActiveLayoutId){const e=this._helper.viewer.getActiveLayoutId();0!=e&&(this._helper.currentLayoutId=e)}else this._helper.currentLayoutId&&delete this._helper.currentLayoutId;return this._helper.getAnnotationList()},setAnnotationList:function(e){e.length>0&&e[0].id&&(e=this._helper.transform(e)),this._helper.setAnnotationList(e),this._helper.update()},setState:function(e){this._opt.viewer&&"ViewerDrawing"==this._opt.viewer.viewerType&&void 0!==e.state.viewId&&this._opt.viewer.showViewById(e.state.viewId),this._helper.setState(e)},createSnapshot:function(e){this._helper.createSnapshot(e)},startDrawing:function(){this._helper.startDrawing();var e=document.querySelector(".bf-toolbar-select");e&&(e.style.display="none")},endDrawing:function(){i.send(t,"endDrawing"),this._helper.editAnnotationEnd(),this.isShowAnnotation=!1;var e=document.querySelector(".bf-toolbar-select");e&&(e.style.display="block")},clear:function(){i.send(t,"clear"),this._helper.clearAnnotations()},resize:function(){},setAnnotationType:function(e){i.send(t,"setAnnotationType"),this.restoreAnnotationAction(),this._helper.setAnnotationType(e.toLocaleLowerCase())},setLineWidth:function(e){i.send(t,"setLineWidth"),this._helper.setAnnotationStyle({"stroke-width":e})},setLineColor:function(e){i.send(t,"setLineColor"),this._helper.setAnnotationStyle({"stroke-color":`${e.getRGBA()}`})},setFillColor:function(e){i.send(t,"setFillColor"),this._helper.setAnnotationStyle({"fill-color":`${e.getRGBA()}`})},setFontFamily:function(e){i.send(t,"setFontFamily"),this._helper.setAnnotationStyle({"font-family":e})},setFontSize:function(e){i.send(t,"setFontSize"),this._helper.setAnnotationStyle({"font-size":e})},removeSelectedAnnotation:function(){this._helper.removeSelectedAnnotation()},showAnnotation:function(){this._helper.viewer&&this._helper.viewer.getActiveLayoutId&&this._helper.currentLayoutId&&this._helper.viewer.getActiveLayoutId()!=this._helper.currentLayoutId||this._helper.showAnnotation()},hideAnnotation:function(){this._helper.hideAnnotation()},setStyle:function(e){this._helper.setAnnotationStyle(e)},destroy:function(){this.endDrawing()},getCurrentState:function(){if(this.isViewer2D)var e=this._helper.getCurrentState();else{var t=this._opt.viewer.getViewer();this._opt.windowAdaption&&t.setCameraStateWithFrustum&&t.setCameraStateWithFrustum(!0);e=this._helper.getCurrentState();t.setCameraStateWithFrustum&&t.setCameraStateWithFrustum(!1)}return e},getWorldPosition:function(e){var t=this._opt.viewer,i=t.screenWidth/2,n=t.screenHeight/2,o={x:i+e.position.x,y:n-e.position.y};return t.clientToWorld(o)},inherit:function(e){for(var t in e)this[t]=e[t]},stringifyAnnotationList(e){return this._helper.markupManager.toString(e)},jsonifyAnnotationList(e){return this._helper.markupManager.fromString(e)},lockAnnotationAction(){this._helper.lockAnnotationAction&&this._helper.lockAnnotationAction()},restoreAnnotationAction(){this._helper.restoreAnnotationAction&&this._helper.restoreAnnotationAction()},highlightAnnotationByIds(e){this._helper.highlightAnnotationByIds&&this._helper.highlightAnnotationByIds(e)},clearHighlight(){this._helper.clearHighlight&&this._helper.clearHighlight()},setHighlightConfig(e){this._helper.setHighlightConfig&&this._helper.setHighlightConfig(e)}},n.AnnotationManager=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation").AnnotationToolbarConfig=function(){return{viewer:null,windowAdaption:!1,enableWebHanddrawing:!1}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation");let i=Object.freeze({Saved:"Saved",Cancelled:"Cancelled"});t.AnnotationToolbarEvent=i}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Annotation"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Bimface.Plugins.Annotation.AnnotationToolbarEvent,o=function(t){return P(this),t.viewer.getIsMobileNew&&t.viewer.getIsMobileNew()?function(t,o){var s=o._eventManager=new e.Web.Lang.EventManager;let r=e.Bimface.UI.Control.ControlEvent;var a=t.viewer,l=e.Bimface.Viewer.ViewerDrawing&&a instanceof e.Bimface.Viewer.ViewerDrawing;o.isDrawing=l;var h=e.Bimface.Viewer.ViewerPDF&&a instanceof e.Bimface.Viewer.ViewerPDF;o.isPDF=h;var d=a.getDomElement();l||(d=a.getDomElement().parentElement);var c=i.create("div","bf-annotation bf-hide");o.domElement=c;var u=e.Bimface.Plugins.Annotation.AnnotationTypeOption,g=new e.Bimface.Plugins.Annotation.AnnotationManagerConfig;g.viewer=a,g.windowAdaption=t.windowAdaption,g.annotationCallback=t.annotationCallback;var p=new e.Bimface.UI.Toolbar.ToolbarConfig;p.element=c,p.className="bf-toolbar bf-toolbar-annotation";var m=o.annotationToolbar=new e.Bimface.UI.Toolbar.Toolbar(p);o.annotationToolbar=m,l&&(g.annotationToolbar=m);var f=o._annotationManager=new e.Bimface.Plugins.Annotation.AnnotationManager(g);c.addEventListener("mousedown",(function(e){e.stopPropagation()})),c.addEventListener("touchstart",(function(e){e.stopPropagation()})),c.addEventListener("touchmove",(function(e){e.stopPropagation()}));var w=new e.Bimface.UI.Toolbar.ToolbarConfig;w.element=d,w.className="bf-toolbar bf-annotation-control";var y=o.controlToolbar=new e.Bimface.UI.Toolbar.Toolbar(w);o.controlToolbar.hide();var v=new e.Bimface.UI.Button.ButtonConfig;v.className="bf-save cancel",v.id="annotationCancel_id",v.title=BimfaceLanguage.bf_general_cancel;var b=new e.Bimface.UI.Button.SingleButton(v);b.setHtml(`<span>${BimfaceLanguage.bf_general_cancel}</span>`),b.addEventListener("Click",(function(){f.endDrawing(),s.fireEvent(n.Cancelled),c.addClass("bf-hide"),o.controlToolbar.hide(),C||(C=app.getToolbar("MainToolbar")),C&&C.show(),ae&&ae.hide(),F&&F.hide(),we&&we.hide(),o.restoreDomState(o.domElement.parentElement)})),y.addControl(b);var E=new e.Bimface.UI.Button.ButtonConfig;E.className="bf-save",E.id="annotatioSave_id",E.title=BimfaceLanguage.bf_general_save;var M=new e.Bimface.UI.Button.SingleButton(E);M.setHtml(`<span>${BimfaceLanguage.bf_general_save}</span>`),M.addEventListener("Click",(function(){l||h?s.fireEvent(n.Saved,{annotationList:f.getAnnotationList()}):s.fireEvent(n.Saved,{annotationList:f.getAnnotationList(),state:f.getCurrentState()}),f.endDrawing(),y.hide(),c.addClass("bf-hide"),ae&&ae.hide(),F&&F.hide(),we&&we.hide(),o.restoreDomState(o.domElement.parentElement)})),y.addControl(M);let C=null;d.appendChild(c);let x="Annotation_"+e.Web.Lang.Utility.UUID.createUUID();if(l){var T=new e.Bimface.UI.Button.ButtonConfig;T.className="bf-button gld-bf-drag",T.title="平移",T.id="annotationHand_id",T.groupName=x,T.needTitle=!0;var P=new e.Bimface.UI.Button.SingleButton(T);P.addEventListener("Click",(function(){f.lockAnnotationAction(),se.show(),me.hide()})),m.addControl(P)}var I=new e.Bimface.UI.Button.ButtonConfig;I.className="bf-button gld-bf-narrow ",I.title="箭头",I.id="annotationArrow_id",I.groupName=x,I.needTitle=!0;var S=new e.Bimface.UI.Button.SingleButton(I);S.addEventListener("Click",(function(){f.setAnnotationType(u.Arrow),se.show(),me.setCheckedState(!1),me.hide()})),S.setChecked(),m.addControl(S);var B=new e.Bimface.UI.Button.ButtonConfig;B.className="bf-button gld-bf-n-cloud",B.title="云线框",B.groupName=x,B.id="annotationCloudrect_id",B.needTitle=!0;var _=new e.Bimface.UI.Button.SingleButton(B);_.addEventListener("Click",(function(){f.setAnnotationType(u.CloudRect),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(_);var L=new e.Bimface.UI.Button.ButtonConfig;L.className="bf-button gld-bf-nrectangle",L.title="矩形",L.groupName=x,L.id="annotationRectangle_id",L.needTitle=!0;var D=new e.Bimface.UI.Button.SingleButton(L);D.addEventListener("Click",(function(){f.setAnnotationType(u.Rectangle),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(D);var A=new e.Bimface.UI.Button.ButtonConfig;A.className="bf-button gld-bf-noval",A.title="椭圆",A.groupName=x,A.id="annotationCircle_id",A.needTitle=!0;var V=new e.Bimface.UI.Button.SingleButton(A);V.addEventListener("Click",(function(){f.setAnnotationType(u.Ellips),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(V);var R=new e.Bimface.UI.Button.ButtonConfig;R.className="bf-button gld-bf-mark",R.title="标记",R.groupName=x,R.id="annotationCross_id",R.needTitle=!0;var O=new e.Bimface.UI.Button.SingleButton(R);if(O.addEventListener("Click",(function(){f.setAnnotationType(u.Cross),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(O),a.getIsMobileNew()){var k=new e.Bimface.UI.Button.ButtonConfig;k.className="bf-button gld-bf-n-handdrawing",k.title="手绘线",k.groupName=x,k.id="annotationHanddrawing_id";var H=new e.Bimface.UI.Button.SingleButton(k);H.addEventListener("Click",(function(){f.setAnnotationType(u.Handdrawing),se.show(),me.setCheckedState(!1),me.hide()})),m.addControl(H)}var U=new e.Bimface.UI.Button.ButtonConfig;U.className="bf-button gld-bf-ntext",U.title="文字",U.groupName=x,U.id="annotationText_id",U.needTitle=!0;var N=new e.Bimface.UI.Button.SingleButton(U);N.addEventListener("Click",(function(){f.setAnnotationType(u.Text),se.setCheckedState(!1),se.hide(),me.show()})),m.addControl(N);var G=new e.Bimface.UI.Button.ButtonConfig;G.className="bf-button bf-color",G.title="颜色",G.id="annotationColor_id",G.needTitle=!0;var j=new e.Bimface.UI.Button.ToggleButton(G);j.setHtml('<span class="color-wrapper"><span class="color color-red"></span></span>'),j.addEventListener(r.StateChange,(function(e){e?(se.setCheckedState(!1),me.setCheckedState(!1),F.show(),ae.hide()):F.hide()})),m.addControl(j);var z=new e.Bimface.UI.Toolbar.ToolbarConfig;z.element=d,z.className="bf-toolbar bf-color-control";var F=o.colorToolbar=new e.Bimface.UI.Toolbar.Toolbar(z),W=new e.Bimface.UI.Button.ButtonConfig;W.className="bf-button bf-pl-15",W.title="红",W.groupName="GroupColor",W.id="annotationLineThin_id";var $=new e.Bimface.UI.Button.SingleButton(W);$.setHtml('<span class="color color-red"></span>');const X=new e.Web.Graphics.Color(208,2,27,1);$.addEventListener("Click",(function(){j.setHtml('<span class="color-wrapper"><span class="color color-red"></span></span>'),ne("color-red"),f.setLineColor(X),F.hide(),c.removeClass("bf-hide"),j.setCheckedState(!1)})),F.addControl($);var Y=new e.Bimface.UI.Button.ButtonConfig;Y.className="bf-button",Y.title="黄",Y.groupName="GroupColor",Y.id="annotationLineMiddle_id";var Z=new e.Bimface.UI.Button.SingleButton(Y);const q=new e.Web.Graphics.Color(245,166,35,1);Z.setHtml('<span class="color color-yellow"></span>'),Z.addEventListener("Click",(function(){j.setHtml('<span class="color-wrapper"><span class="color color-yellow"></span></span>'),ne("color-yellow"),f.setLineColor(q),F.hide(),c.removeClass("bf-hide"),j.setCheckedState(!1)})),F.addControl(Z);var K=new e.Bimface.UI.Button.ButtonConfig;K.className="bf-button",K.title="蓝",K.groupName="GroupColor",K.id="annotationLineThick_id";var Q=new e.Bimface.UI.Button.SingleButton(K);Q.setHtml('<span class="color color-blue"></span>');const J=new e.Web.Graphics.Color(74,144,226,1);Q.addEventListener("Click",(function(){j.setHtml('<span class="color-wrapper"><span class="color color-blue"></span></span>'),ne("color-blue"),f.setLineColor(J),F.hide(),c.removeClass("bf-hide"),j.setCheckedState(!1)})),F.addControl(Q);var ee=new e.Bimface.UI.Button.ButtonConfig;ee.className="bf-button",ee.title="绿",ee.groupName="GroupColor",ee.id="annotationLineThick_id";var te=new e.Bimface.UI.Button.SingleButton(ee);te.setHtml('<span class="color color-green"></span>');const ie=new e.Web.Graphics.Color(126,211,33,1);function ne(e){se.element.removeClass("color-red").removeClass("color-yellow").removeClass("color-blue").removeClass("color-green").addClass(e),ae.element.removeClass("color-red").removeClass("color-yellow").removeClass("color-blue").removeClass("color-green").addClass(e)}te.addEventListener("Click",(function(){j.setHtml('<span class="color-wrapper"><span class="color color-green"></span></span>'),ne("color-green"),f.setLineColor(ie),F.hide(),c.removeClass("bf-hide"),j.setCheckedState(!1)})),F.addControl(te),F.hide();var oe=new e.Bimface.UI.Button.ButtonConfig;oe.className="bf-button bf-line color-red",oe.title="粗细",oe.id="annotationLine_id",oe.needTitle=!0;var se=new e.Bimface.UI.Button.ToggleButton(oe);se.setHtml('<span class="line-wrapper"><span class="line" style="height: .05em;"></span></span>'),se.addEventListener(r.StateChange,(function(e){e?(j.setCheckedState(!1),me.setCheckedState(!1),me.hide(),ae.show(),F.hide(),we.hide()):ae.hide()})),m.addControl(se);var re=new e.Bimface.UI.Toolbar.ToolbarConfig;re.element=d,re.className="bf-toolbar bf-line-control color-red";var ae=o.lineToolbar=new e.Bimface.UI.Toolbar.Toolbar(re),le=new e.Bimface.UI.Button.ButtonConfig;le.className="bf-button bf-line-button bf-pl-15",le.title="细",le.groupName="GroupLine",le.id="annotationLineThin_id";var he=new e.Bimface.UI.Button.SingleButton(le);he.setHtml('<span class="line" style="height: .05em;">'),he.addEventListener("Click",(function(){se.setHtml('<span class="line-wrapper"><span class="line" style="height: .05em;"></span></span>'),f.setLineWidth(3),ae.hide(),c.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(he);var de=new e.Bimface.UI.Button.ButtonConfig;de.className="bf-button bf-line-button",de.title="中",de.groupName="GroupLine",de.id="annotationLineMiddle_id";var ce=new e.Bimface.UI.Button.SingleButton(de);ce.setHtml('<span class="line" style="height: .1em;">'),ce.addEventListener("Click",(function(){se.setHtml('<span class="line-wrapper"><span class="line" style="height: .1em;"></span></span>'),f.setLineWidth(6),ae.hide(),c.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(ce);var ue=new e.Bimface.UI.Button.ButtonConfig;ue.className="bf-button bf-line-button",ue.title="粗",ue.groupName="GroupLine",ue.id="annotationLineThick_id";var ge=new e.Bimface.UI.Button.SingleButton(ue);ge.setHtml('<span class="line" style="height: .15em;">'),ge.addEventListener("Click",(function(){se.setHtml('<span class="line-wrapper"><span class="line" style="height: .15em;"></span></span>'),f.setLineWidth(10),ae.hide(),c.removeClass("bf-hide"),se.setCheckedState(!1)})),ae.addControl(ge),ae.hide();var pe=new e.Bimface.UI.Button.ButtonConfig;pe.className="bf-button bf-font",pe.title="字号",pe.id="annotationFont_id",pe.needTitle=!0;var me=new e.Bimface.UI.Button.ToggleButton(pe);me.setHtml('<span class="font-wrapper"><span class="font">14</span></span>'),me.addEventListener(r.StateChange,(function(e){e?(j.setCheckedState(!1),se.setCheckedState(!1),we.show(),ae.hide(),F.hide()):we.hide()})),m.addControl(me),me.hide();var fe=new e.Bimface.UI.Toolbar.ToolbarConfig;fe.element=d,fe.className="bf-toolbar bf-font-control";var we=o.fontToolbar=new e.Bimface.UI.Toolbar.Toolbar(fe),ye=new e.Bimface.UI.Button.ButtonConfig;ye.className="bf-button bf-font-button bf-pl-15",ye.title="字号",ye.groupName="GroupFont",ye.id="annotationSizeSmall_id";var ve=new e.Bimface.UI.Button.SingleButton(ye);ve.setHtml("<span>14</span>"),ve.addEventListener("Click",(function(){me.setHtml('<span class="font-wrapper"><span class="font">14</span></span>'),f.setFontSize(14),we.hide(),c.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(ve);var be=new e.Bimface.UI.Button.ButtonConfig;be.className="bf-button bf-font-button",be.title="字号",be.groupName="GroupFont",be.id="annotationSizeSmall_id";var Ee=new e.Bimface.UI.Button.SingleButton(be);Ee.setHtml("<span>18</span>"),Ee.addEventListener("Click",(function(){me.setHtml('<span class="font-wrapper"><span class="font">18</span></span>'),f.setFontSize(18),we.hide(),c.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(Ee);var Me=new e.Bimface.UI.Button.ButtonConfig;Me.className="bf-button bf-font-button",Me.title="字号",Me.groupName="GroupFont",Me.id="annotationSizeSmall_id";var Ce=new e.Bimface.UI.Button.SingleButton(Me);Ce.setHtml("<span>24</span>"),Ce.addEventListener("Click",(function(){me.setHtml('<span class="font-wrapper"><span class="font">24</span></span>'),f.setFontSize(24),we.hide(),c.removeClass("bf-hide"),me.setCheckedState(!1)})),we.addControl(Ce),we.hide()}(t,this):function(t,o){var s=o._eventManager=new e.Web.Lang.EventManager,r=t.viewer,a=e.Bimface.Viewer.ViewerDrawing&&r instanceof e.Bimface.Viewer.ViewerDrawing;o.isDrawing=a;var l=e.Bimface.Viewer.ViewerPDF&&r instanceof e.Bimface.Viewer.ViewerPDF;o.isPDF=l;var h=i.create("div","bf-annotation bf-hide");o.domElement=h;var d=e.Bimface.Plugins.Annotation.AnnotationTypeOption,c=new e.Bimface.Plugins.Annotation.AnnotationManagerConfig,u=c.lineColor;c.viewer=r,c.windowAdaption=t.windowAdaption,c.annotationCallback=t.annotationCallback;var g=new e.Bimface.UI.Toolbar.ToolbarConfig;g.element=h,g.className="bf-toolbar bf-toolbar-annotation";var p=o.annotationToolbar=new e.Bimface.UI.Toolbar.Toolbar(g);o.annotationToolbar=p,a&&(c.annotationToolbar=p);var m=o._annotationManager=new e.Bimface.Plugins.Annotation.AnnotationManager(c);r.getDomElement().appendChild(h),h.addEventListener("mousedown",(function(e){e.stopPropagation()})),h.addEventListener("touchstart",(function(e){e.stopPropagation()})),h.addEventListener("touchmove",(function(e){e.stopPropagation()}));var f=new e.Bimface.UI.Toolbar.ToolbarConfig;f.element=h,f.className="bf-toolbar bf-toolbar-control";var w=new e.Bimface.UI.Toolbar.Toolbar(f);let y="Annotation_"+e.Web.Lang.Utility.UUID.createUUID();if(a){var v=new e.Bimface.UI.Button.ButtonConfig;v.className="bf-button gld-bf-drag",v.title="视图交互",v.id="annotationHand_id",v.groupName=y;var b=new e.Bimface.UI.Button.SingleButton(v);b.addEventListener("Click",(function(){m.lockAnnotationAction(),ee.show(),he.hide()})),p.addControl(b)}var E=new e.Bimface.UI.Button.ButtonConfig;E.className="bf-button gld-bf-narrow ",E.title="箭头",E.id="annotationArrow_id",E.groupName=y;var M=new e.Bimface.UI.Button.SingleButton(E);M.addEventListener("Click",(function(){m.setAnnotationType(d.Arrow),ee.show(),he.hide()})),M.setChecked(),p.addControl(M);var C=new e.Bimface.UI.Button.ButtonConfig;C.className="bf-button gld-bf-n-cloud",C.title="云线框",C.groupName=y,C.id="annotationCloudrect_id";var x=new e.Bimface.UI.Button.SingleButton(C);x.addEventListener("Click",(function(){m.setAnnotationType(d.CloudRect),ee.show(),he.hide()})),p.addControl(x);var T=new e.Bimface.UI.Button.ButtonConfig;T.className="bf-button gld-bf-ncloud",T.title="云线",T.groupName=y,T.id="annotationCloud_id";var P=new e.Bimface.UI.Button.SingleButton(T);P.addEventListener("Click",(function(){m.setAnnotationType(d.Cloud),ee.show(),he.hide()})),p.addControl(P);var I=new e.Bimface.UI.Button.ButtonConfig;I.className="bf-button gld-bf-n-ployline",I.title="折线",I.groupName=y,I.id="annotationPolyline_id";var S=new e.Bimface.UI.Button.SingleButton(I);S.addEventListener("Click",(function(){m.setAnnotationType(d.Polyline),ee.show(),he.hide()})),p.addControl(S);var B=new e.Bimface.UI.Button.ButtonConfig;B.className="bf-button gld-bf-nrectangle",B.title="矩形",B.groupName=y,B.id="annotationRectangle_id";var _=new e.Bimface.UI.Button.SingleButton(B);_.addEventListener("Click",(function(){m.setAnnotationType(d.Rectangle),ee.show(),he.hide()})),p.addControl(_);var L=new e.Bimface.UI.Button.ButtonConfig;L.className="bf-button gld-bf-noval",L.title="椭圆",L.groupName=y,L.id="annotationCircle_id";var D=new e.Bimface.UI.Button.SingleButton(L);D.addEventListener("Click",(function(){m.setAnnotationType(d.Ellips),ee.show(),he.hide()})),p.addControl(D);var A=new e.Bimface.UI.Button.ButtonConfig;A.className="bf-button gld-bf-mark",A.title="X",A.groupName=y,A.id="annotationCross_id";var V=new e.Bimface.UI.Button.SingleButton(A);if(V.addEventListener("Click",(function(){m.setAnnotationType(d.Cross),ee.show(),he.hide()})),p.addControl(V),t.enableWebHanddrawing){var R=new e.Bimface.UI.Button.ButtonConfig;R.className="bf-button gld-bf-n-handdrawing",R.title="手绘线",R.groupName=y,R.id="annotationHanddrawing_id";var O=new e.Bimface.UI.Button.SingleButton(R);O.addEventListener("Click",(function(){m.setAnnotationType(d.Handdrawing),ee.show(),he.hide()})),p.addControl(O)}var k=new e.Bimface.UI.Button.ButtonConfig;k.className="bf-button gld-bf-ntext",k.title="文字",k.groupName=y,k.id="annotationText_id";var H=new e.Bimface.UI.Button.SingleButton(k);H.addEventListener("Click",(function(){m.setAnnotationType(d.Text),ee.hide(),he.show()})),p.addControl(H);var U=new e.Bimface.UI.Button.ButtonConfig;U.className="bf-combobox bf-color",U.title="颜色",U.id="annotationColor_id";var N=new e.Bimface.UI.Button.ComboBox(U),G=new e.Bimface.UI.Button.ButtonConfig;G.className="bf-button bf-color",G.title="红",G.id="annotationColorRed_id";var j=new e.Bimface.UI.Button.ComboBoxOptionButton(G);j.color=new e.Web.Graphics.Color(208,2,27,1);var z=i.create("div","bf-color-button");z.setCss({backgroundColor:`#${j.color.getHEX()}`}),j.setHtml(z.outerHTML),N.addControl(j);var F=new e.Bimface.UI.Button.ButtonConfig;F.className="bf-button bf-color",F.title="黄",F.id="annotationColorYellow_id";var W=new e.Bimface.UI.Button.ComboBoxOptionButton(F);W.color=new e.Web.Graphics.Color(245,166,35,1);var $=i.create("div","bf-color-button");$.setCss({backgroundColor:`#${W.color.getHEX()}`}),W.setHtml($.outerHTML),N.addControl(W);var X=new e.Bimface.UI.Button.ButtonConfig;X.className="bf-button bf-color",X.title="蓝",X.id="annotationColorBlue_id";var Y=new e.Bimface.UI.Button.ComboBoxOptionButton(X);Y.color=new e.Web.Graphics.Color(74,144,226,1);var Z=i.create("div","bf-color-button");Z.setCss({backgroundColor:`#${Y.color.getHEX()}`}),Y.setHtml(Z.outerHTML),N.addControl(Y);var q=new e.Bimface.UI.Button.ButtonConfig;q.className="bf-button bf-color",q.title="绿",q.id="annotationColorGreen_id";var K=new e.Bimface.UI.Button.ComboBoxOptionButton(q);K.color=new e.Web.Graphics.Color(126,211,33,1);var Q=i.create("div","bf-color-button");Q.setCss({backgroundColor:`#${K.color.getHEX()}`}),K.setHtml(Q.outerHTML),N.addControl(K),p.addControl(N);var J=new e.Bimface.UI.Button.ButtonConfig;J.className="bf-combobox",J.title="粗细",J.id="annotationLine_id";var ee=new e.Bimface.UI.Button.ComboBox(J),te=new e.Bimface.UI.Button.ButtonConfig;te.className="bf-button bf-line",te.title="细",te.id="annotationLineThin_id";var ie=new e.Bimface.UI.Button.ComboBoxOptionButton(te);ie.lineWidth=3;var ne=i.create("div","bf-line-button");ne.setCss({height:`${ie.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-ie.lineWidth)/2+"px 4px"}),ie.element.appendChild(ne),ee.addControl(ie),te.title="中";var oe=new e.Bimface.UI.Button.ComboBoxOptionButton(te);oe.lineWidth=6,oe.id="annotationLineMiddle_id";var se=i.create("div","bf-line-button");se.setCss({height:`${oe.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-oe.lineWidth)/2+"px 4px"}),oe.element.appendChild(se),ee.addControl(oe),te.title="粗";var re=new e.Bimface.UI.Button.ComboBoxOptionButton(te);re.lineWidth=10,re.id="annotationLineThick_id";var ae=i.create("div","bf-line-button");ae.setCss({height:`${re.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-re.lineWidth)/2+"px 4px"}),re.element.appendChild(ae),ee.addControl(re),N.addEventListener("Change",(function(e){m.setLineColor(e.color),(u=e.color).getHEX(),ne.setCss({height:`${ie.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-ie.lineWidth)/2+"px 4px"}),se.setCss({height:`${oe.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-oe.lineWidth)/2+"px 4px"}),ae.setCss({height:`${re.lineWidth}px`,backgroundColor:`#${u.getHEX()}`,margin:(32-re.lineWidth)/2+"px 4px"});var t=ee.getCurrentControl();ee.setSelectedControlById(t.getId())})),ee.addEventListener("Change",(function(e){m.setLineWidth(e.lineWidth)})),p.addControl(ee);var le=new e.Bimface.UI.Button.ButtonConfig;le.className="bf-combobox bf-font-button",le.title="字号",le.id="annotationFont_id";var he=new e.Bimface.UI.Button.ComboBox(le),de=new e.Bimface.UI.Button.ButtonConfig;de.className="bf-button bf-size",de.title="14";var ce=new e.Bimface.UI.Button.ComboBoxOptionButton(de);ce.fontSize=14,ce.id="annotationSizeSmall_id",ce.setHtml("14"),he.addControl(ce),de.title="18";var ue=new e.Bimface.UI.Button.ComboBoxOptionButton(de);ue.fontSize=18,ue.id="annotationSizeMiddle_id",ue.setHtml("18"),he.addControl(ue),de.title="24";var ge=new e.Bimface.UI.Button.ComboBoxOptionButton(de);ge.fontSize=24,ge.id="annotationSizeLarge_id",ge.setHtml("24"),he.addControl(ge),he.addEventListener("Change",(function(e){m.setFontSize(e.fontSize)})),he.hide(),p.addControl(he);var pe=new e.Bimface.UI.Button.ButtonConfig;pe.className="bf-save",pe.title=BimfaceLanguage.bf_general_save;var me=new e.Bimface.UI.Button.SingleButton(pe);me.setHtml(BimfaceLanguage.bf_general_save),me.addEventListener("Click",(function(){a||l?s.fireEvent(n.Saved,{annotationList:m.getAnnotationList()}):s.fireEvent(n.Saved,{annotationList:m.getAnnotationList(),state:m.getCurrentState()}),m.endDrawing(),h.addClass("bf-hide"),o.restoreDomState(o.domElement.parentElement)})),w.addControl(me);var fe=new e.Bimface.UI.Button.ButtonConfig;fe.className="bf-cancel",fe.title=BimfaceLanguage.bf_general_cancel;var we=new e.Bimface.UI.Button.SingleButton(fe);we.setHtml(BimfaceLanguage.bf_general_cancel),we.addEventListener("Click",(function(){m.endDrawing(),s.fireEvent(n.Cancelled),h.addClass("bf-hide"),o.restoreDomState(o.domElement.parentElement)})),w.addControl(we)}(t,this)};o.prototype={getEventManager:function(){return this._eventManager},addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},show:function(e,t){this.isDrawing||this.isPDF||this._annotationManager.clear(),this._annotationManager.startDrawing(),this.controlToolbar&&this.controlToolbar.show(),this.domElement.removeClass("bf-hide"),this.hideDomState(this.domElement.parentElement)},hideDomState(e){let t=e.querySelector(".bf-toolbar.bf-toolbar-search");t&&(t.style.display="none");let i=e.querySelector(".bf-toolbar.bf-layout-btn-wrapper");i&&(i.style.display="none");let n=e.querySelector(".bf-toolbar.bf-tree-toolbar");n&&(n.style.display="none")},restoreDomState(e){let t=e.querySelector(".bf-toolbar.bf-toolbar-search");t&&(t.style.display="block");let i=e.querySelector(".bf-toolbar.bf-layout-btn-wrapper");i&&(i.style.display="block");let n=e.querySelector(".bf-toolbar.bf-tree-toolbar");n&&(n.style.display="block")},getAnnotationManager:function(){return this._annotationManager},exit:function(){this.annotationToolbar.hide(),this.getAnnotationManager().exit()}},t.AnnotationToolbar=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").TagConfig=function(){return{viewer:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(e){var t=this,i=this._viewer=e.viewer.getViewer();if(this._opt=e,this._renderCallback=function(){t.resize()},e.minimap){this.mapHelper=e.minimap;var n=new y.View2dAdapter(this.mapHelper,i);this.mapHelper.setMinimapResizeCallback((function(e){t._tagHelper.updateGroupName(),t._tagHelper.updateDomContainer(),t._tagHelper.resize(e),t._tagHelper.updateByGroup()})),this.mapHelper.setPlaneChangedCallback((function(){t._tagHelper.updateGroupName(),t._tagHelper.updateByGroup()}))}else{n=new y.View3dAdapter(i);i.addCallbacks("render",this._renderCallback)}this._tagHelper=new y.Extensions.MarkerEditor(n),this._tagHelper.disableInteractions(!0),this.init()});i.prototype={init:function(){this._tagHelper.isInitialized()||this._tagHelper.init()},addTag:function(e,t){if(!e)return!1;var i=!1,n=this.getTags();e.userId=e.objectId,e.worldBoundingBox=e.boundingBox,e.worldPosition||(e.worldPosition={x:(e.worldBoundingBox.min.x+e.worldBoundingBox.max.x)/2,y:(e.worldBoundingBox.min.y+e.worldBoundingBox.max.y)/2,z:(e.worldBoundingBox.min.z+e.worldBoundingBox.max.z)/2});for(var o=0,s=n.length;o<s;o++){if(n[o].userId==e.userId)return i=!0,!1}e.floorList?this._tagHelper.setMarkerGroups(e.floorList):this._tagHelper.setMarkerGroups([]),this._tagHelper.updateGroupName(),i||this._tagHelper.createMarkerByIntersect(e,t.shape,t.image,t.size)},deleteTag:function(e,t){if(t)return this._tagHelper.removeMarkerInGroup(e,t),!1;for(var i=this.getTags(),n=0,o=i.length;n<o;n++){var s=i[n];if(s.userId==e)return this._tagHelper.deleteMarker(s),!1}},destroy:function(){this._viewer.removeCallbacks("render",this._renderCallback),this._tagHelper.markerClickCallback=null,this.unLoadTags(),this._tagHelper.clearMarkers(),this._tagHelper=null},loadTags:function(e){this._tagHelper.loadMarkers(e)},unLoadTags:function(){this._tagHelper.unloadMarkers()},getTags:function(){return this._tagHelper.getMarkerInfoList()},getTagById:function(e){return this._tagHelper.getMarker(e)},zoomToSelectedTag:function(){this._tagHelper.zoomToSelectedMarkers()},resize:function(){this._tagHelper.onResize()},onSelected:function(e){this._tagHelper.setMarkerClickCallback(e)}},t.Tag=i}();class rn{constructor(t,i,n){this.viewer=t,this.domContainer=i,this.dimensionItems=n,this.selectedItem=null,this.isEnableSelection=!0,this.offset=i.getBoundingClientRect(),e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hookEvents()}hookEvents(){this.domContainer.addEventListener("mousemove",(e=>{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),this.hitTest(t)?(this.domContainer.style.cursor="pointer",e.preventDefault(),e.stopPropagation()):this.domContainer.style.cursor=""}),!1),this.domContainer.addEventListener("mousedown",(e=>{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top);let i=this.hitTest(t);i?(i.getIsSelected()?(this.setSelectedItem(null),i.unselect()):(this.setSelectedItem(i),i.select()),i&&e.altKey&&console.info(Object.assign({},i.content,{id:i.id})),e.preventDefault(),e.stopPropagation()):this.setSelectedItem(null)}),!1),this.domContainer.addEventListener("dblclick",(e=>{if(!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),this.hitTest(t)&&(e.preventDefault(),e.stopPropagation())}),!1)}hitTest(e){for(var t=this.dimensionItems.length-1;t>=0;t--){let i=this.dimensionItems[t];if(i.getNotation().hitTest(e))return i}for(t=this.dimensionItems.length-1;t>=0;t--){let i=this.dimensionItems[t];if(i.hitTest(e))return i}return null}setSelectedItem(e){this.selectedItem&&(this.selectedItem.actionWhenUnselected(),this.selectedItem.unselect()),this.selectedItem=e,e&&e.actionWhenSelected()}getSelectedItem(){return this.selectedItem}hasSelected(){return null!==this.selectedItem}setIsEnableSelection(e){this.isEnableSelection=e}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension").DimensionContainerConfig=class{constructor(){this.viewer=null,this.contents=[]}};class an{}an.xmlns="http://www.w3.org/2000/svg",an.makeCircle=function(e){var t=document.createElementNS(an.xmlns,"circle");return t.style.fill=e.color,t.setAttribute("r",e.radius+""),t.setAttribute("stroke","#FFFFFF"),t.setAttribute("stroke-width",e.strokeWidth),t.setAttribute("transform","translate("+e.position.x+","+e.position.y+")"),t},an.makeConcentricCircle=function(e){var t=document.createElementNS(an.xmlns,"g"),i=document.createElementNS(an.xmlns,"circle");i.style.fill=e.color,i.setAttribute("r",e.innerRadius+""),i.setAttribute("stroke","#FFFFFF"),i.setAttribute("stroke-width",e.innerStrokeWidth),i.setAttribute("transform","translate("+e.position.x+","+e.position.y+")");var n=i.cloneNode();return n.setAttribute("r",e.outerRadius+""),n.setAttribute("stroke-width",e.outerStrokeWidth||0),t.appendChild(n),t.appendChild(i),t},an.makeLine=function(e){var t=document.createElementNS(an.xmlns,"line");return t.setAttribute("stroke",e.color),t.setAttribute("stroke-width",e.lineWidth),t.setAttribute("x1",e.start.x+""),t.setAttribute("y1",e.start.y+""),t.setAttribute("x2",e.end.x+""),t.setAttribute("y2",e.end.y+""),t},an.makeRectangle=function(e){var t=document.createElementNS(an.xmlns,"rect");return t.setAttribute("stroke-width",2),t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.setAttribute("width",e.width),t.setAttribute("height",e.height),t.setAttribute("rx",e.radius),t.style.fill=e.fillColor||"none",t.setAttribute("fill-opacity",e.fillOpacity||1),t.setAttribute("stroke",e.strokeColor||"none"),t},an.makeText=function(e){var t=document.createElementNS(an.xmlns,"text");t.setAttribute("x",e.x),t.setAttribute("y",e.y),t.setAttribute("fill",e.color||"#000"),t.setAttribute("font-size",e.fontsize);var i=e.content?e.content.split("\n"):[""];if(i.length>1)for(let o=0;o<i.length;o++){var n=document.createElementNS(an.xmlns,"tspan");n.setAttribute("x",e.x),n.setAttribute("y",e.y+30*o),n.textContent=i[o],t.appendChild(n)}else t.textContent=i[0];return t},an.measureText=function(e,t='14px "Microsoft YaHei'){var i=document.createElement("canvas").getContext("2d");return i.font=t,i.measureText(e).width},an.distanceToSegment=function(e,t,i){var o=t.distanceToSquared(i);if(0==o)return e.distanceTo(t);var s=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/o;s=Math.max(0,Math.min(1,s));let r=new n;return r.x=t.x+s*(i.x-t.x),r.y=t.y+s*(i.y-t.y),e.distanceTo(r)};class ln extends class{constructor(e){this.type=e}initialize(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}drawAnnotation(e,t){}calcAnnotationStyle(e,t){}select(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="none"})),this.notationSelected.forEach((e=>{e.style.display="block"})))}unselect(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="block"})),this.notationSelected.forEach((e=>{e.style.display="none"})))}dropShadow(e){this.isInitialized()&&this.notationUnselected.forEach((t=>{t.setAttribute("filter",e),t.setAttribute("filter",e)}))}isInitialized(){return!!this.notationUnselected&&!!this.notationSelected}clear(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}hitTest(e){if(!this.isInitialized())return!1;let t=this.hitTestEpsilon;return this.notationSegmentRects.some((i=>an.distanceToSegment(e,i.start,i.end)<=t))}}{constructor(e){super(e),this.defaultColor="#F99D0B",this.defaultOpacity=1,this.initialize()}initialize(){super.initialize(),this.annotationStyle={height:21,radius:4},this.hitTestEpsilon=this.annotationStyle.height/2}drawAnnotation(e,t,i,o,s){var r=this.calcAnnotationStyle(t,e),a=an.makeRectangle({x:r.offsetRect.x,y:r.offsetRect.y,width:r.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:o||this.defaultColor,fillOpacity:s||this.defaultOpacity});this.notationUnselected.push(a);let l=an.makeRectangle({x:r.offsetRect.x-2,y:r.offsetRect.y-2,width:r.width+4,height:this.annotationStyle.height+4,radius:this.annotationStyle.radius,strokeColor:"#FFFFFF",fillColor:o||this.defaultColor,fillOpacity:s||this.defaultOpacity});this.notationSelected.push(l);let h=new n(r.offsetRect.x,r.offsetRect.y+this.annotationStyle.height/2),d=new n(r.offsetRect.x+r.width,h.y);this.notationSegmentRects.push({start:h,end:d});var c=an.makeText({x:r.offsetText.x,y:r.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});return this.svgGroup=[],this.svgGroup.push(a),this.svgGroup.push(l),this.svgGroup.push(c),this.unselect(),this.svgGroup}calcAnnotationStyle(e,t){var i=0,o=new n(t.x,t.y),s=new n(t.x,t.y);return i=an.measureText(e),o.x-=i/2,o.y-=this.annotationStyle.height/2,s.x=o.x+5,s.y=o.y+19-3.5,{offsetRect:o,offsetText:s,width:i+=10}}}!function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension");t.DrawableItem=class{constructor(t){this.viewer=t.viewer,this.id=e.Web.Lang.Utility.UUID.createUUID(),t.color&&(t.color instanceof e.Web.Graphics.Color||(console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),t.color=null)),this.defaultColor=t.color?"#"+t.color.getHEX():"#F99D0B",this.defaultOpacity=t.color?t.color.getAlpha():1,this.isShow=!0,this.svgGroup=[],this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.hitTestEpsilon=10,this.hitTestSegments=[],this.selectElements=[],this.unSelectElements=[],this.isSelected=!0,this.notation=new ln(this.type),this.unitObj={Kilometer:"km",Meter:"m",Centimeter:"cm",Millimeter:"mm"}}getSvgGroup(){return this.svgGroup}getId(){return this.id}getType(){return this.type}clear(){this.detach(),this.notation.clear(),this.svgGroup=[],this.hitTestSegments=[]}detach(){for(const t of this.svgGroup){var e=t.parentNode;e&&e.removeChild(t)}}attach(e){for(const t of this.svgGroup)e.appendChild(t)}calcLine(e,t){let i=[];this.viewer.getViewer();var o=this.viewer.getDomElement().getBoundingClientRect(),s=this.viewer.viewerAdapter.worldPointsToClient(e,t);if(s){e=new n(s.start.x-o.left,s.start.y-o.top),t=new n(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i}calcTerminalLines(e,t,i){if(0===e.length)return[];let n=[],o=e[0],s=e[1],r=o.clone().sub(s).normalize(),a=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),t),l=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),-t);n.push({start:a,end:l}),r=r.multiplyScalar(-1);let h=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),t),d=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),-t);return n.push({start:h,end:d}),n}select(){for(const e of this.selectElements)e.style.display="none";for(const e of this.unSelectElements)e.style.display="block";this.notation.select(),this.isSelected=!0}unselect(){for(const e of this.selectElements)e.style.display="block";for(const e of this.unSelectElements)e.style.display="none";this.notation.unselect(),this.isSelected=!1}getIsSelected(){return this.isSelected}actionWhenSelected(){}actionWhenUnselected(){}dropShadow(e){this.notation.dropShadow(e)}show(){for(const e of this.svgGroup)e.style.display="block";this.isSelected?this.select():this.unselect(),this.isShow=!0}hide(){for(const e of this.svgGroup)e.style.display="none";this.isShow=!1}getNotation(){return this.notation}hitTest(e){let t=this.hitTestEpsilon;for(let i=0;i<this.hitTestSegments.length-1;i++){if(an.distanceToSegment(e,this.hitTestSegments[i],this.hitTestSegments[i+1])<=t)return!0}return!1}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension");t.LinearConfig=class{constructor(){this.color=null,this.viewer=null}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension"),i=e.Bimface.Plugins.Dimension.DrawableItem;t.Linear=class extends i{constructor(e){super(e),this.viewer=e.viewer,this.color=e.color,this.type="Linear",this.selectElements=[],this.unSelectElements=[],P(this)}initialize(){if(!this.worldPositions)return;let e=this.calcLine(this.viewer.globalUnitUtil.excute(this.worldPositions[0],this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]),this.viewer.globalUnitUtil.excute(this.worldPositions[1],this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]));this.hitTestSegments=e;let t=this.calAuxLines(),i=this.calcTerminalLines(e,Math.PI/2,6.5);this.attachSingleLine(e),this.attachTerminalLines(i),this.attachTerminalPoints([t[0].start,t[2].end]);let n={x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2},o=this.viewer.worldToClient(this.viewer.globalUnitUtil.excute(n,this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]));this.viewer.isInViewFrustum(this.viewer.globalUnitUtil.excute(n,this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]))&&(this.attachNotation([o,o]),this.unselect())}attachTerminalPoints(e){for(const t of e){let e=an.makeCircle({position:t,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(e),this.unSelectElements.push(e)}}attachSingleLine(e){if(0===e.length)return;let t=an.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachTerminalLines(e){if(0!==e.length)for(let t=0;t<2;t++){let i=an.makeLine({start:e[t].start,end:e[t].end,color:this.defaultColor,lineWidth:2});this.selectElements.push(i),this.svgGroup.push(i)}}attachAuxLines(e,t){let i=0;for(const n of e){let e=an.makeLine({start:n.start,end:n.end,color:this.defaultColor,lineWidth:this.lineWidth});e.setAttribute("stroke-dasharray","6,4"),e.style.stroke=t[i++],this.unSelectElements.push(e),this.svgGroup.push(e)}}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.showText,this.id,this.defaultColor,this.defaultOpacity);for(const e of t)this.svgGroup.push(e)}calAuxLines(){let e=this.worldPositions;for(var t=this.viewer.getDomElement().getBoundingClientRect(),i={x:e[1].x,y:e[0].y,z:e[0].z},n={x:e[1].x,y:e[1].y,z:e[0].z},o=[],s=[this.viewer.globalUnitUtil.excute(e[0],this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]),this.viewer.globalUnitUtil.excute(i,this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]),this.viewer.globalUnitUtil.excute(n,this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"]),this.viewer.globalUnitUtil.excute(e[1],this.pointUnit,this.viewer.getGlobalUnit(),["x","y","z"])],r=0;r<s.length-1;r++){var a=this.viewer.viewerAdapter.worldPointsToClient(s[r],s[r+1]);if(a)a.start.x-=t.left,a.start.y-=t.top,a.end.x-=t.left,a.end.y-=t.top;else{a={start:{x:-1,y:-1},end:{x:-1,y:-1}}}o.push(a)}return o}show(){super.show()}hide(){super.hide()}setContent(e){this.content=e,this.pointUnit=e.dimension.pointUnit,this.unit=e.dimension.unit,this.worldPositions=e.dimension.points,this.showText=e.dimension.text?e.dimension.text+"":e.dimension.distance+""||"",this.initialize()}getItemId(){return this.id}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Dimension"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.DimensionContainer=class{constructor(e){var t,n,o=e.viewer;o&&(P(this),this.viewer=o,this._items=[],o.getDomElement().getElementsByClassName("bf-drawable-context").length>0?(t=o.getDomElement().getElementsByClassName("bf-drawable-context")[0]).getElementsByClassName("bf-drawable-svg").length>0?n=t.getElementsByClassName("bf-drawable-svg")[0]:(n=i.createNS("svg","bf-drawable-svg"),t.appendChild(n)):(t=i.create("div","bf-drawable-context"),n=i.createNS("svg","bf-drawable-svg"),o.getDomElement().appendChild(t),t.appendChild(n)),this.eventControl=new rn(o,n,this._items),this.context={rootDomElement:t,dimensionContainer:n},this.dimensionContainer=n,this.id="Dimension",this.viewer.addEventListener("Rendered",(()=>{this.update()})),this.viewer.render(),e.contents&&e.contents.length>0&&this.initDimensions(e.contents))}initDimensions(t){t.map((t=>{if("Distance"==t.dimension.type){let i=new e.Bimface.Plugins.Dimension.LinearConfig;i.viewer=this.viewer;let n=new e.Bimface.Plugins.Dimension.Linear(i);n.setContent(t),this.addItem(n)}}))}addItem(e){this._items.push(e),e.attach(this.dimensionContainer)}addItems(e){e.map((e=>this.addItem(e)))}getAllItems(){return this._items}getItemById(e){let t=null;return this._items.map((i=>{i.id!=e||(t=i)})),t}hideAllItems(){this._items.map((e=>e.hide()))}showAllItems(){this._items.map((e=>e.show()))}update(){this.remove();for(const e of this._items)e.initialize(),e.attach(this.dimensionContainer),!e.isShow&&e.hide();this.eventControl.hasSelected()&&(this.eventControl.getSelectedItem().select(),!this.eventControl.getSelectedItem().isShow&&this.eventControl.getSelectedItem().hide())}clear(){this.remove(),this._items=[]}remove(){for(const e of this._items)e.clear()}}}();class hn{constructor(){}}hn.ifExploded=function(e,t,i){let n="ViewerDrawing"===e.getViewerType(),o="ViewerDrawingSet"===e.getViewerType();if(n||o||t instanceof Glodon.Bimface.Plugins.Drawable.ClusterTag)return t;const s=e.getViewer();if(!s.modelManager)return t;const r=s.modelManager.explosionManager;let a=t.modelId;if(i&&t.layerId){const i=e.getLayerManager().getLayer(t.layerId);if(!i)return t;if("TileLayer"===i.typeName||"TilesetLayer"===i.typeName)return t;a=i.getModelId().toString()}else{if(i&&!t.layerId)return t;a||(a=e._defaultModel.modelId.toString())}t.modelId=a;const l=e.getModel(a).getFloorExplosionDirection(),h=r.getFloorInfos(a),d=s.modelManager.getModel(a).modelExplosion;let c=()=>{if(h&&r.isExploded(a)){let e=t.worldPosition||t.getOriginalPosition(),i=d.getExplosionTranslationByObjId(t.objectId);const n=r.getExplosionParam(a).explosionExtent;if(!t.objectId&&n>0&&(i=this.getCenterExplosionOffset(s,n,t,!0)),i.length()>0){const n={x:e.x-i.x,y:e.y-i.y,z:e.z-i.z};return t.explosionOffset={x:i.x,y:i.y,z:i.z},t.originalPosition?t.originalPosition=n:t.worldPosition=n,t}if(t.levelName){let i=this.getExplodedOffsetByLevelName(h,t.levelName);if(i){const n={x:e.x-i*l.x,y:e.y-i*l.y,z:e.z-i*l.z};t.explosionOffset={x:i*l.x,y:i*l.y,z:i*l.z},t.originalPosition?t.originalPosition=n:t.worldPosition=n}}else this.setDrawableOffsetByFloorInfos(h,t,l)}return t};if(t._config.objectId){let e=s.getComponentInfoByUserId(t._config.objectId);if(e)return t.levelName=e.userData&&e.userData.levelName,c();{if(i)return t;const e=s.modelManager.getModel("ExtrudeBodyManager");return e&&e.getNode(t._config.objectId)&&(t._isBindRoom=!0),t}}return c()},hn.getExplodedOffsetByLevelName=function(e,t){for(const i of e)if(i.name===t)return i.explodedHeight-i.elevation;return 0},hn.setDrawableOffsetByFloorInfos=function(e,t,i){let n=t.worldPosition||t.getOriginalPosition();for(const o of e){const e=o.explodedHeight-o.elevation,s=o.boundingBox;if(n.z-e<s.min.z&&n.z-e>s.max.z)continue;t.levelName=o.name;const r={x:n.x-e*i.x,y:n.y-e*i.y,z:n.z-e*i.z};t.originalPosition?t.originalPosition=r:t.worldPosition=r,t.explosionOffset={x:i.x*e,y:i.y*e,z:i.z*e}}},hn.attachExplosionOffset=function(e,t,i){let n=e.getViewer();if(!i.worldPosition&&!i.position)return;const o=i._config.objectId;let s=null;if(o){s=n.modelManager.getModel(i.modelId).modelExplosion.getExplosionTranslationByObjId(o),i.explosionOffset.x+=s.x,i.explosionOffset.y+=s.y,i.explosionOffset.z+=s.z}else s=this.getCenterExplosionOffset(n,t,i),i.explosionOffset.x=s.x,i.explosionOffset.y=s.y,i.explosionOffset.z=s.z;i.explosionOffset=t?e.globalUnitUtil.revertTranslate(i.explosionOffset,["x","y","z"]):{x:0,y:0,z:0}},hn.getCenterExplosionOffset=function(e,t,i,n){this.scratchVector=new THREE.Vector3,e.getScene().getOriginalBoundingBoxWorld().getCenter(this.scratchVector);const o=(new THREE.Box3).expandByPoint(i.worldPosition||i.getOriginalPosition());return!0===n?CLOUD.Utils.computeAfterExplodeTranslation(this.scratchVector,o,t):CLOUD.Utils.computeExplodeTranslation(this.scratchVector,o,t)},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable").DrawableContainerConfig=function(){return{viewer:null,maxNum:20,affectedBySection:!0,enableRender:!0}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable").DrawableItemConfig=function(){return{id:null,objectId:null,modelId:null,tooltip:"",tooltipStyle:{},draggable:!1,worldPosition:new e.Web.Geometry.Point3d(0,0,0),angle:0,layerId:void 0}},function(){var n="Bimface.Plugins.Drawable.DrawableItem",o=e.Bimface.Data.StatisticsDataManager.getInstance();let s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),r=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Common.MouseButton,function(i){this.id=i.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=i.layerId,this.modelId=i.modelId,this.objectId=i.objectId,i.worldPosition?this.worldPosition=i.worldPosition:console.log("worldPosition must not be empty."),null!=i.viewerDrawingId&&(this.viewerDrawingId=i.viewerDrawingId),this.config=i,this.angle=i.angle,this.explosionOffset=new t,this.explosionExtent=0,this._enableDepthTest=i.enableDepthTest,this._isCover=!1,this._enableDepthTestCallback=null,P(this)});r.prototype={draw:function(e){},onClick:function(e){o.send(n,"onClick"),this._onclick=e},onDoubleClick:function(e){o.send(n,"onClick"),this._doubleClick=e},onRightClick:function(e){o.send(n,"onRightClick"),this._onrightclick=e},onEndDrag:function(e){o.send(n,"onEndDrag"),this._onenddrag=e},setTooltip:function(e){o.send(n,"setTooltip"),this.tipElement.querySelector("span").innerText=e},setTooltipStyle:function(e){for(var t in o.send(n,"setTooltipStyle"),e)this.tipElement.style[t]=e[t],"backgroundColor"===t&&(this.tipElement.childNodes[0].childNodes[0].style.borderTopColor=e[t])},getTooltip:function(){return this.tipElement.querySelector("span").innerText},getTooltipStyle:function(){return this.tipElement.style},getWorldPosition:function(){return this.worldPosition},setWorldPosition:function(e){o.send(n,"setWorldPosition"),this.worldPosition=e},getSize:function(){return{width:this.config.width,height:this.config.height}},hide:function(){o.send(n,"hide"),this._domElement.style.display="none",this.notControlByCameraPosition=!0,this.forceHide=!0},hideByCameraPosition:function(){this.notControlByCameraPosition||(this._domElement.style.display="none",this.forceHide=!0)},show:function(){o.send(n,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this._domElement.style.display="",this.forceHide=!1)},showByCameraPosition:function(){this.forceHide&&(this.notControlByCameraPosition||(this._domElement.style.display="",this.forceHide=!1))},updateVisibility:function(){this.isHideByClustering||this.forceHide?this._domElement.style.display="none":this._domElement.style.display="block"},attachExplosionOffset:function(e,n){if(!this.worldPosition)return;let o=this._config.objectId;if(o){let i=e.modelManager.getBoundingBoxByIds([o]),s=this.assoiatedComponentBbox,r=i;if(s){let e=r.getCenter().clone();e.sub(s.getCenter().clone()),this.explosionOffset=e,this.explosionExtent>0&&0===n&&(this.worldPosition.x+=e.x,this.worldPosition.y+=e.y,this.worldPosition.z+=e.z,this.explosionExtent=0,this.explosionOffset=new t,this.assoiatedComponentBbox=r.clone())}}else{let t=e.getScene().getOriginalBoundingBoxWorld().getCenter(),o=(new i).expandByPoint(this.worldPosition),s=CLOUD.Utils.computeExplodeTranslation(t,o,n);this.explosionOffset=s}},setInitialExplosionInfo:function(e){if("Viewer3D"!==e.getViewerType()&&"ViewerGIS"!==e.getViewerType())return;let t=null;"Viewer3D"===e.getViewerType()?t=this.modelId?e.getModel(this.modelId):e.getDefaultModel():"ViewerGIS"===e.getViewerType()&&(t=e.getLayerManager().getLayer(this.layerId)||null),this.explosionExtent=null===t?0:t.getExplosionExtent();const i=this._config.objectId;if(!i)return;e.getViewer().modelManager.getBoundingBoxByIds([i]).isEmpty()&&(this._config.objectId=null,console.log("Cannot find component with Id "+i))},clearExplosionOffset:function(){this.explosionOffset=new t},getCurrentPosition:function(){return{x:this.worldPosition.x+this.explosionOffset.x,y:this.worldPosition.y+this.explosionOffset.y,z:this.worldPosition.z+this.explosionOffset.z}},getId:function(){return this.id},handleEnableDepthTest(t){if(!this._enableDepthTest||!this.viewer)return;if("Viewer3D"!==this.viewer.getViewerType()&&"ViewerGIS"!==this.viewer.getViewerType())return;if("LeadLabel"==this.name&&this._modelId&&this._objectId&&"Viewer3D"==this.viewer.getViewerType()){this.update&&this.update();let e=this.viewer.getModel(this._modelId).getComponentStatus(this._objectId);if("hidden"==e||"translucent"==e)return void(this._isCover=!1)}!t&&(t=this.viewer.getCameraStatus().position);let i=new THREE.Vector3(...Object.values(t)),n=new THREE.Vector3(...Object.values(this.worldPosition));const o=n.clone().sub(i).normalize(),s=this.viewer.getComponentsByRaycaster(i,o,[]);let r=s.length>0?s[0].distance:n.clone().sub(i).length(),a=1;switch(this.viewer.getUnit()){case e.Bimface.Common.Units.LengthUnits.Kilometer:a=1e-6;break;case e.Bimface.Common.Units.LengthUnits.Meter:a=.001;break;case e.Bimface.Common.Units.LengthUnits.Centimeter:a=.1;break;case e.Bimface.Common.Units.LengthUnits.Millimeter:a=1}let l=n.clone().sub(i).length()>=r+a;this._isCover!=l&&this._enableDepthTestCallback&&this._enableDepthTestCallback(l),this._isCover=l},enableDepthTest:function(e){this._enableDepthTest=e,this.handleEnableDepthTest()},isDepthTestEnabled:function(){return this._enableDepthTest},onObstructionChanged:function(e){this._enableDepthTestCallback=e,this._enableDepthTest&&(this.handleEnableDepthTest(),e(this._isCover))}},s.DrawableItem=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(){this.rootDomElement=i.create("div","bf-drawable-context"),this.clientPosition=null};n.prototype.destroy=function(){this.rootDomElement.parentNode&&this.rootDomElement.parentNode.removeChild(this.rootDomElement)},t.DrawableContext=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.ImageConfig=function(){let e={width:32,height:32,viewer:null,opacity:.75,src:null,offsetX:0,offsetY:0,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1};return Object.assign({},i,e)}}(),function(){var t="Bimface.Plugins.Drawable.Image",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Bimface.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),r=function(e){o.call(this,e);let t=this;this._isDragging=!1;let i=s.create("div","bf-drawable-text"),n=s.create("img","bf-drawable-image");i.draggable=!1,n.src=e.src,n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,n.style.opacity=`${e.opacity}`,n.style.transform=`rotate(${e.angle}deg)`,i.appendChild(n),this._config=e,this._domElement=i,this._imgElement=n;let r=s.create("div","bf-tooltip tooltipTop");r.style.display="none",r.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${e.tooltip}</span></div></div>`,r.style.left=`${e.tooltipStyle.left}`,r.style.top=`${e.tooltipStyle.top}`;var a,l=e.tooltipStyle;this.tipElement=r,this.setTooltipStyle(l),i.appendChild(r),this.clientPosition={},this.visibleDistance=e.visibleDistance;e.draggable&&s.drag({element:i,cursor:"pointer",end:function(e){t._isDragging=!1;var i,n=t.viewer,o="Viewer3D"===n.getViewerType(),s="ViewerGIS"===n.getViewerType(),r={x:e.x-a.x+t.clientPosition.x,y:e.y-a.y+t.clientPosition.y};if(o){var l=n.pickByPoint(r);if(!l||!l.objectId)return void t.update();if(l.objectId){t._config.objectId=l.objectId;let e=n.getViewer().getComponentInfoByUserId(l.objectId);t.levelName=e&&e.userData&&e.userData.levelName,t.setInitialExplosionInfo(n),t.clearExplosionOffset(),t.needForceUpdate=!0}i=l.worldPosition}else if(s){let e=n.getDomElement().getBoundingClientRect(),o=n.getViewer().pickByPoint({x:r.x+e.left,y:r.y+e.top});if(!o||!o.meshId)return void t.update();o.meshId&&(t._config.objectId=o.meshId),i=o.worldPosition}else i=n.clientToWorld(r);i?(t.worldPosition=i,t.update(),t._onenddrag&&t._onenddrag(t)):t.update()},start:function(e){a=e},move:function(){t._isDragging=!0}}),i.addEventListener("mouseup",(function(e){var i=e||window.event;"0"==i.button&&t._onclick&&(!t._isDragging||a.x==i.clientX&&a.y==i.clientY)&&(t.clickTimerId&&clearTimeout(t.clickTimerId),t.clickTimerId=setTimeout((()=>{t.event=i,t._onclick(t),delete t.event}),500))})),i.addEventListener("mousedown",(function(e){var i=e||window.event;i.stopPropagation(),"2"==i.button&&t._onrightclick?t._onrightclick(t):"1"==i.button&&t._onmiddleclick&&t._onmiddleclick(t)})),i.addEventListener("mouseover",(function(e){r&&r.querySelector("span").innerText.length>0&&(r.style.display="block")})),i.addEventListener("mouseout",(function(e){t.tipElement&&(t.tipElement.style.display="none")})),i.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),t._doubleClick&&t._doubleClick(t),t.clickTimerId&&clearTimeout(t.clickTimerId)}))};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(r,o);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._imgElement.style.opacity=e},getSrc:function(){return this._config.src},setSrc:function(e){i.send(t,"setSrc"),this._config.src=e,this._imgElement.src=e},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getAngle:function(){return this.angle},setAngle:function(e){i.send(t,"setAngle"),this.angle=e,this._imgElement.style.transform=`rotate(${e}deg)`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)}},r),n.Image=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.CustomItemConfig=function(){let e={width:0,height:0,opacity:.75,content:"",offsetX:0,offsetY:0,viewer:null,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1};return Object.assign({},i,e)}}(),function(){var t="Bimface.Plugins.Drawable.CustomItem",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),s=e.Bimface.Plugins.Drawable.DrawableItem,r=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),a=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");o.IE11Store={};let l=function(t){s.call(this,t),this._isDragging=!1;let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),o=r.create("div","bf-drawable-text");o.style.width=`${t.width}px`,o.style.height=`${t.height}px`;let a=r.create("div","bf-drawable-contentwrap");var l;o.appendChild(a),this._domElement=o,this.name="customItem",this._contentElement=a,this._config=t,this.clientPosition={},this.visibleDistance=t.visibleDistance,this.setContent(t.content);let h=r.create("div","bf-tooltip");h.style.display="none",h.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${t.tooltip}</span></div></div>`,h.style.left=`${t.width}px`,h.style.top=`-${t.height}px`;var d=t.tooltipStyle;this.tipElement=h,this.setTooltipStyle(d),o.appendChild(h);t.draggable&&r.drag({element:o,cursor:"pointer",end:function(t){i._isDragging=!1;var n=i.viewer,o=e.Bimface.Viewer.Viewer3D&&"Viewer3D"===n.viewerType,s=e.Bimface.Viewer.ViewerGIS&&n instanceof e.Bimface.Viewer.ViewerGIS;const r=e.Bimface.Viewer.ViewerDrawing&&n instanceof e.Bimface.Viewer.ViewerDrawing;var a,h={x:t.x-l.x+i.clientPosition.x,y:t.y-l.y+i.clientPosition.y};if(o){let e=n.getDomElement().getBoundingClientRect(),t=n.pickByPoint({x:h.x+e.left,y:h.y+e.top});if(!t||!t.objectId)return void i.update();if(t.objectId){i._config.objectId=t.objectId;let e=n.getViewer().getComponentInfoByUserId(t.objectId);i.levelName=e&&e.userData&&e.userData.levelName,i.setInitialExplosionInfo(n),i.clearExplosionOffset(),i.needForceUpdate=!0}a=t.worldPosition}else if(s){let e=n.getDomElement().getBoundingClientRect(),t=n.getViewer().pickByPoint({x:h.x+e.left,y:h.y+e.top});if(!t||!t.meshId)return void i.update();t.meshId&&(i._config.objectId=t.meshId),a=t.worldPosition}else if(r){var d=n.getViewer().toWorldPoint([h.x,h.y]);a={x:d[0],y:d[1]}}else a=n.clientToWorld(h);a?(i.worldPosition=a,i.update(),i._onenddrag&&i._onenddrag(i)):i.update()},start:function(e){l=e},move:function(){i._isDragging=!0}}),o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.style.opacity=`${t.opacity}`,o.addEventListener("mouseover",(function(e){i.tipElement&&i.tipElement.querySelector("span").innerText.length>0&&(i.tipElement.style.display="block")})),o.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),o.addEventListener("keydown",(function(e){e.stopPropagation()})),n&&o.addEventListener("mouseup",(function(e){var t=e||window.event;"0"==t.button&&i._onclick&&(!i._isDragging||l.x==t.clientX&&l.y==t.clientY)&&(i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i.event=t,i._onclick(i),delete i.event}),500))})),o.addEventListener("mousedown",(function(e){var t=e||window.event;t.stopPropagation(),"2"==t.button&&i._onrightclick?i._onrightclick(i):"1"==t.button&&i._onmiddleclick&&i._onmiddleclick(i)})),o.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),o.addEventListener("touchstart",(function(e){(e||window.event).stopPropagation()})),o.addEventListener("touchmove",(function(e){(e||window.event).stopPropagation()})),!n&&o.addEventListener("touchend",(function(e){var n=e||window.event;n.stopPropagation(),i._onclick&&(!t.draggable||l.x==n.changedTouches[0].clientX&&l.y==n.changedTouches[0].clientY)&&i._onclick(i)}))};a.Type.inheritPrototype(l,s);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",""==t.innerHTML&&(this.dom&&this.domId?t.appendChild(o.IE11Store[this.domId].cloneNode(!0)):this.text&&(t.innerText=this.text)),e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._domElement.style.opacity=e},getContent:function(){return this._config.content||this.text},setContent:function(n){i.send(t,"setContent"),this._contentElement.innerHTML="",n instanceof HTMLElement?(n.draggable=!1,this._config.content=n,this._domElement.content=n,this.dom=n,this.domId||(this.domId=e.Web.Lang.Utility.UUID.createUUID()),o.IE11Store[this.domId]=n.cloneNode(!0),this._contentElement.appendChild(n)):(this._contentElement.innerHTML=n,this.text=n,this._config.content="")},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){s.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return s.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){s.prototype.onObstructionChanged.call(this,e)},resetClientPosition:function(e){const t=this._domElement,i=this._config;"Viewer3D"!==this.viewer.viewerType&&"ViewerGIS"!==this.viewer.viewerType||(e=this.viewer.worldToClient(e)),t.style.left=e.x+i.offsetX-i.width/2+"px",t.style.top=e.y+i.offsetY-i.height/2+"px"},getContainer:function(){return this._domElement},setContainerVisible(e){this._domElement.style.display=!0===e?"block":"none"}},l),n.CustomItem=l}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.LeadLabelConfig=function(){let t={text:null,viewer:null,containerCss:{boxSizing:"border-box",fontSize:"12px",lineHeight:1.5,borderWidth:"2px",borderStyle:"solid",padding:"5px",borderColor:"#1f93ff",backgroundColor:"#eeeeee",padding:"2px 8px",opacity:.9},lineCss:{width:"2px",color:"#1f93ff"},pointCss:{radius:4,backgroundColor:"#1f93ff",borderColor:"#ffffff",borderStyle:"solid",borderWidth:"1px"},offset:{x:27,y:-47},height:26,width:140,modelId:void 0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1,style:{lineColor:new e.Web.Graphics.Color(31,147,255,1),lineWidth:2,backgroundColor:new e.Web.Graphics.Color(238,238,238,1),fontSize:12}};return Object.assign({},i,t)}}(),function(){var t="Bimface.Plugins.Drawable.LeadLabel",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Bimface.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var r=function(t){o.call(this,t);let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),r=s.create("div","bf-drawable-lead-label"),a=s.create("div","bf-drawable-lead-label-textarea");r.appendChild(a);let l=s.createNS("line","bf-drawable-lead-line"),h=s.createNS("line","bf-drawable-lead-line"),d=s.createNS("circle","bf-drawable-lead-point"),c=s.createNS("g","bf-drawable-group");i._text=t.text,this.name="LeadLabel",this.isAssociateComponentHide=!1,this.visibleDistance=t.visibleDistance,r.setCss(t.containerCss),a.innerText=i._text.replace(/\n/g," ");let u=[r,l,h,d];this._labelCombination=u;let g=s.create("div","bf-tooltip");g.style.display="none",g.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${t.tooltip}</span></div></div>`,g.style.left="0px",g.style.top="0px",this.tipElement=g,this.setTooltipStyle(t.tooltipStyle),r.appendChild(g),r.style.width=parseFloat(t.width)+"px",r.style.minHeight=parseFloat(t.height)+"px";let p=Math.trunc((t.height-8)/18);var m;a.style.webkitLineClamp=p||1,h.setAttribute("stroke-width",t.lineCss.width),h.style.stroke=t.lineCss.color,l.setAttribute("stroke-width",t.lineCss.width),l.style.stroke=t.lineCss.color,d.setAttribute("r",t.pointCss.radius),d.style.fill=t.pointCss.backgroundColor,d.setAttribute("stroke-width",t.pointCss.borderWidth),d.style.stroke=t.pointCss.borderColor,h.setAttribute("x1",0),h.setAttribute("y1",0-t.offset.y+18),h.setAttribute("x2",t.offset.x),h.setAttribute("y2",18),l.setAttribute("x1",t.offset.x),l.setAttribute("y1",18),l.setAttribute("x2",t.offset.x+23),l.setAttribute("y2",18),d.setAttribute("cx",0),d.setAttribute("cy",18-t.offset.y),this.setStyle(t.style),this._isDragging=!1;t.draggable&&s.drag({element:r,cursor:"pointer",start:function(e){m=e},move:function(e){i._isDragging=!0;var n=e.x-m.x+i.clientPosition.x,o=e.y-m.y+i.clientPosition.y;c.setAttribute("transform",`translate(${n},${o+t.offset.y-18})`)},end:function(n){i._isDragging=!1;const o=t.viewer||i.viewer;var s="Viewer3D"===o.viewerType;this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&o instanceof e.Bimface.Viewer.ViewerGIS;var r=o.getDomElement().getBoundingClientRect(),a={x:n.x-m.x+i.clientPosition.x+r.left,y:n.y-m.y+i.clientPosition.y+r.top};if(s){var l=o.pickByPoint(a);if(l){if(i.setWorldPosition(l.worldPosition),i.bindComponentById(l.objectId,l.modelId),l.objectId){i._config.objectId=l.objectId,i._config.modelId=l.modelId;let e=o.getViewer().getComponentInfoByUserId(l.objectId,l.modelId);i.levelName=e&&e.userData&&e.userData.levelName,i.needForceUpdate=!0}i.setInitialExplosionInfo(o),i.clearExplosionOffset()}o.render()}else if(this._isViewerGIS){let e=o.getViewer().pickByPoint({x:a.x,y:a.y});if(!e||!e.meshId)return void i.update();e.meshId&&(i._config.objectId=e.meshId),i.worldPosition=e.worldPosition,i.setWorldPosition(e.worldPosition),i.update()}else{var h=o.clientToWorld(a);h&&i.setWorldPosition(h),o.update()}i._dragEnd&&i._dragEnd(i)}}),r.addEventListener("mousedown",(function(e){(e=e||event).stopPropagation()})),r.addEventListener("mouseover",(function(e){g&&g.querySelector("span").innerText.length>0&&(g.style.display="block")})),r.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),n&&r.addEventListener("click",(function(e){(e=e||event).stopPropagation(),i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i._click&&(i.event=e,i._click(i),delete i.event)}),500)})),r.addEventListener("touchstart",(function(){(event||window.event).stopPropagation(),!n&&i._click&&i._click(i)})),r.addEventListener("contextmenu",(function(e){i._rightClick&&i._rightClick(i)})),r.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),r.addEventListener("mouseenter",(function(e){a.innerText=i._text;let t=r.offsetHeight;r.addClass("bf-drawable-show"),a.addClass("bf-drawable-show"),t>r.offsetHeight&&(r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show"))})),r.addEventListener("mouseleave",(function(e){a.innerText=i._text.replace(/\n/g," "),r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show")})),c.appendChild(h),c.appendChild(l),c.appendChild(d),i._objectId=t.objectId,i._modelId=t.modelId,i._container=r,i._domTextArea=a,i._svgGroup=c,i._config=t,i._offset=t.offset};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(r,o),r.prototype=Object.assign({},o.prototype,{draw:function(t,i){if(!this._isDragging){this._isViewerGIS=e.Bimface.Viewer.ViewerGIS&&this.viewer instanceof e.Bimface.Viewer.ViewerGIS;var n=this._container,o=this._svgGroup,r=this._offset,a=this._config.viewer||this.viewer,l=this._objectId,h=this._modelId;if(a&&l&&!this._isViewerGIS){var d=a.getModel(h).getComponentStatus(l);if("hidden"==d||"translucent"==d)return this.hide(),void(this.isAssociateComponentHide=!0);this.isAssociateComponentHide&&(this.show(),this.isAssociateComponentHide=!1)}!0!==this.isHideByClustering?(this.clientPosition=t.clientPosition,n.style.left=`${t.clientPosition.x+r.x+23}px`,n.style.top=t.clientPosition.y+r.y-18+"px",o.setAttribute("transform",`translate(${t.clientPosition.x},${t.clientPosition.y+r.y-18})`),t.domContainer||(t.domContainer=s.create("div","bf-drawable-container"),t.rootDomElement.appendChild(t.domContainer)),t.svgContainer||(t.rootDomElement.getElementsByClassName("bf-drawable-svg").length>0?t.svgContainer=t.rootDomElement.getElementsByClassName("bf-drawable-svg")[0]:(t.svgContainer=s.createNS("svg","bf-drawable-svg"),t.rootDomElement.appendChild(t.svgContainer))),this.isShow("default"==i),t.rootDomElement.contains&&t.domContainer.contains(n)||(t.domContainer.appendChild(n),t.svgContainer.appendChild(o))):this.hide()}},setDisplayMode:function(e){this.show(),this.displayMode=e,this.isShow()},hide:function(){i.send(t,"hide"),this.forceHide=!0,this.notControlByCameraPosition=!0,this._container.style.display="none",this._svgGroup.style.display="none"},show:function(){i.send(t,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},hideByCameraPosition:function(){this.notControlByCameraPosition||(this.forceHide=!0,this._container.style.display="none",this._svgGroup.style.display="none")},showByCameraPosition:function(){!this.notControlByCameraPosition&&this.forceHide&&(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},onClick:function(e){i.send(t,"onClick"),e&&(this._click=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClick=e)},onDoubleClick:function(e){e&&(this._doubleClick=e)},onEndDrag:function(e){i.send(t,"onEndDrag"),e&&(this._dragEnd=e)},getText:function(){return this._text},setText:function(e){i.send(t,"setText"),this._domTextArea.innerText=e,this._text=e},getOpacity:function(){return this._container.style.opacity},setOpacity:function(e,n){i.send(t,"setOpacity"),this._container.style.opacity=e},getHeight:function(){return parseFloat(this._container.style.height)},setHeight:function(e){i.send(t,"setHeight"),this._container.style.height=parseFloat(e)+"px";let n=Math.trunc((e-8)/18);this._domTextArea.style.webkitLineClamp=n||1},getWidth:function(){return parseFloat(this._container.style.width)},setWidth:function(e){i.send(t,"setWidth"),this._container.style.width=parseFloat(e)+"px"},getObjectId:function(){return this._objectId},associateComponentById:function(e,t){console.log("[BIMFACE WARN]: LeadLabel.associateComponentById() is obsolete, please use LeadLabel.bindComponentById() instead."),this.bindComponentById(e,t)},bindComponentById:function(e,t){let i=(this._config.viewer||this.viewer).getViewer().getComponentInfoByUserId(e);i?(this.levelName=i.userData&&i.userData.levelName,this._objectId=e,this._config.objectId=e,this._modelId=t):console.warn("invalid component id")},clearAssociation:function(){console.log("LeadLabel.clearAssociation() is obsolete, please use LeadLabel.unbind() instead."),this.unbind()},unbind:function(){this._objectId=null,this._modelId=null},isShow:function(e){var t=this._container,i=this._svgGroup;null!=this.displayMode&&(e=1!==this.displayMode),e?(t.removeClass("bf-drawable-mini"),i.removeClass("bf-drawable-mini-svg")):(t.addClass("bf-drawable-mini"),i.addClass("bf-drawable-mini-svg"))},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)},resetClientPosition:function(e){const t=this._container,i=this._config,n=i.viewer||this.viewer;"Viewer3D"!==n.viewerType&&"ViewerGIS"!==n.viewerType||(e=n.worldToClient(e)),t.style.left=`${e.x+i.offset.x+23}px`,t.style.top=e.y+i.offset.y-18+"px",this._svgGroup.setAttribute("transform",`translate(${e.x},${e.y+i.offset.y-18})`)},setContainerVisible:function(e){!0!==e?this.hide():this.show()},setStyle:function(e){if(e&&null!==e){const[t,i,n,o]=this._labelCombination,s=e.lineColor&&e.lineColor.getRGBA();e.lineColor&&(this.config.style.lineColor=e.lineColor,i.style.stroke=s,n.style.stroke=s,t.style.borderColor=s,o.style.fill=s),e.lineWidth&&(this.config.style.lineWidth=e.lineWidth,t.style.borderWidth=e.lineWidth+"px",i.style.strokeWidth=e.lineWidth+"px",n.style.strokeWidth=e.lineWidth+"px",o.style.strokeWidth=e.lineWidth+"px"),e.backgroundColor&&(this.config.style.backgroundColor=e.backgroundColor,t.style.backgroundColor=e.backgroundColor.getRGBA()),e.fontSize&&(this.config.style.fontSize=e.fontSize,t.style.fontSize=e.fontSize+"px")}null!==this.config.style&&null!==e||(this.config.style=new Object),i.send(t,"setStyle")},getStyle:function(){return this.config.style}}),n.LeadLabel=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.MiniTagConfig=function(){return Object.assign({},i,{minimap:null,floorList:[],height:20,width:20,objectId:"",src:"",worldPosition:null,viewer:null})}}();var dn=function(e,t){return dn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},dn(e,t)};function cn(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}dn(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var un=function(){function e(){}return e.create=function(e,t,i){var n=document.createElement(e);return n.id=t||"",n.style.position="absolute",n.style.width="100%",n.style.top=0,n.style.bottom=0,i&&i.appendChild(n),n},e.remove=function(e){var t=e.parentNode;t&&t.removeChild(e)},e.setPosition=function(e,t){e.position=t,e.style.left=t.x+"px",e.style.top=t.y+"px"},e.setOpacity=function(t,i){"opacity"in t.style?t.style.opacity=i:"filter"in t.style&&e._setOpacityIE(t,i)},e._setOpacityIE=function(e,t){var i=!1,n="DXImageTransform.Microsoft.Alpha";try{i=e.filters.item(n)}catch(e){if(1===t)return}t=Math.round(100*t),i?(i.Enabled=100!==t,i.Opacity=t):e.style.filter+=" progid:"+n+"(opacity="+t+")"},e.splitStr=function(e){return e.trim().split(/\s+/g)},e.getContainerOffsetToClient=function(e){var t,i;if(e!=document){var n=(i=e).getBoundingClientRect?function(e){var t=e.getBoundingClientRect(),i=document.body,n=document.documentElement,o=n.clientTop||i.clientTop,s=n.clientLeft||i.clientLeft,r=t.top-o,a=t.left-s;return{top:Math.round(r),left:Math.round(a)}}(i):function(e){for(var t=0,i=0;e;)t+=e.offsetTop,i+=e.offsetLeft,e=e.offsetParent;var n=document.body,o=document.documentElement;return{top:t-=window.pageYOffset||o.scrollTop||n.scrollTop,left:i-=window.pageXOffset||o.scrollLeft||n.scrollLeft}}(i);t={width:e.offsetWidth,height:e.offsetHeight,left:n.left,top:n.top}}else t={width:window.innerWidth,height:window.innerHeight,left:0,top:0};return t},e.setClassName=function(e,t){var i=document.getElementById(e);i&&(i.className=t)},e.addClassName=function(e,t){var i,n,o,s,r,a=document.getElementById(e);if(a&&(n=a,t&&"string"==typeof t&&(i=t.split(/\s+/),1===n.nodeType)))if(n.className||1!==i.length){for(o=" "+n.className+" ",s=0,r=i.length;s<r;++s)o.indexOf(" "+i[s]+" ")<0&&(o+=i[0]+" ");n.className=o.trim()}else n.className=t},e.removeClassName=function(e,t){var i,n,o,s,r,a=document.getElementById(e);if(a&&(o=a,t&&"string"==typeof t&&(i=(t||"").split(/\s+/),1===o.nodeType&&o.className))){for(n=(" "+o.className+" ").replace("O"," "),s=0,r=i.length;s<r;s++)for(;n.indexOf(" "+i[s]+" ")>=0;)n=n.replace(" "+i[s]+" "," ");o.className=t?n.trim():""}},e.showOrHideElement=function(e,t){var i=document.getElementById(e);i&&(i.style.display=t?"":"none")},e.prototype.getStyleString=function(e){var t=[];for(var i in e){var n=e[i];t.push(i),t.push(":"),t.push(n),t.push("; ")}return t.join("")},e.cloneStyle=function(e){var t={};for(var i in e)t[i]=e[i];return t},e.removeStyleAttribute=function(e,t){Array.isArray(t)||(t=[t]),t.forEach((function(t){t in e&&delete e[t]}))},e.trimRight=function(e){if(0===e.length)return"";for(var t=e.length-1,i=t;i>=0;--i)if(" "!==e.charAt(i)){t=i;break}return e.substr(0,t+1)},e.trimLeft=function(e){if(0===e.length)return"";for(var t=0,i=0;i<e.length;++i)if(" "!==e.charAt(i)){t=i;break}return e.substr(t)},e.matchesSelector=function(e,t){if(e.matches)return e.matches(t);if(e.matchesSelector)return e.matchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.mozMatchesSelector)return e.mozMatchesSelector(t);if(e.oMatchesSelector)return e.oMatchesSelector(t);if(e.querySelectorAll){for(var i=(e.document||e.ownerDocument).querySelectorAll(t),n=0;i[n]&&i[n]!==e;)n++;return!!i[n]}return!1},e.toTranslate3d=function(e,t){return"translate3d("+e+"px,"+t+"px,0)"},e.setCursorStyle=function(e,t){var i;switch(t){case"n":case"s":i="ns-resize";break;case"w":case"e":i="ew-resize";break;case"ne":case"sw":i="nesw-resize";break;case"nw":case"se":i="nwse-resize"}e.style.cursor=i},e.debounce=function(e,t){var i,n=this;return void 0===t&&(t=500),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];i&&clearTimeout(i),i=setTimeout((function(){e.apply(n,o),i=void 0}),t)}},e}(),gn=function(){function e(){this.domContainer=null,this.cameraControl=null,this.scene=null,this.name=""}return e.prototype.getName=function(){return this.name},e.prototype.setDomContainer=function(e){this.domContainer=e},e.prototype.getDomContainer=function(){return this.domContainer},e.prototype.worldToClient=function(e){},e.prototype.clientToWorld=function(e){var t=this.getDomContainerBounds(),i=this.cameraControl.camera,n=new window.THREE.Vector3;n.x=e.x/t.width*2-1,n.y=-e.y/t.height*2+1,n.z=0,n.unproject(i);var o=this.getInverseSceneMatrix();return n.applyMatrix4(o),n},e.prototype.getSceneMatrix=function(){return this.scene.getMatrixGlobal()},e.prototype.getInverseSceneMatrix=function(){var e=this.getSceneMatrix(),t=new window.THREE.Matrix4;return t.copy(e).invert(),t},e.prototype.clientToViewport=function(e){var t=this.getDomContainerBounds(),i=new window.THREE.Vector3;return i.x=e.x/t.width*2-1,i.y=-e.y/t.height*2+1,i.z=0,i},e.prototype.getDomContainerBounds=function(e){return un.getContainerOffsetToClient(e||this.domContainer)},e}();window.Glodon.Bimface.Marker={};var pn=function(e){function t(t){var i=e.call(this)||this;return i.name="VIEW3D",i.domContainer=t.domElement,i.cameraControl=t.cameraControl,i.scene=t.getScene(),i}return cn(t,e),t.prototype.worldToClient=function(e){var t=this.getDomContainerBounds(),i=this.cameraControl.camera,n=this.getSceneMatrix(),o=new window.THREE.Vector3(e.x,e.y,e.z);return o.applyMatrix4(n),o.project(i),Math.abs(o.z)>1?null:(o.x=Math.round(.5*(o.x+1)*t.width),o.y=Math.round(-.5*(o.y-1)*t.height),o.z=0,o)},t}(gn);window.Glodon.Bimface.Marker.View3dAdapter=pn;var mn=function(e){function t(t,i){var n=e.call(this)||this;n.name="VIEW2D",n.minimap=t,n.domContainer=t.getMapContainer(),n.cameraControl=i.cameraControl,n.scene=i.getScene();var o=t.viewerFloor?t.viewerFloor.vfData:t.nmEditor.navigationMapData,s=o.width||298,r=o.height||198;return n.initialDomSize={width:s,height:r},n.currentDomSize={width:s,height:r},n._boxSize=new THREE.Vector2,n}return cn(t,e),t.prototype.getInitialDomSize=function(){return this.initialDomSize},t.prototype.resize=function(e){this.currentDomSize=e},t.prototype.getDomContainerBounds=function(){return this.currentDomSize},t.prototype.getMinimap=function(){return this.minimap},t.prototype.calculateBoundary=function(e,t,i,n){var o=(e[1].x-e[0].x)/(t[1].x-t[0].x),s=e[1].x-o*t[1].x;n.x=o*i.x+s;var r=(e[1].y-e[0].y)/(t[1].y-t[0].y),a=e[1].y-r*t[1].y;n.y=r*i.y+a},t.prototype.worldToClient=function(e){var t=this.minimap.nmView?this.minimap.nmView.viewer.globalUnitUtil.translateVector(e):new window.THREE.Vector3(e.x,e.y,e.z);if(this.minimap.nmView&&!this.minimap.nmData.isProfile&&this.minimap.nmData.modelAnchor&&this.minimap.nmData.mapAnchor)return this.calculateBoundary(this.minimap.nmData.mapAnchor,this.minimap.nmData.modelAnchor,t,t),t;var i=this.minimap.nmView?this.scene.boundingBoxWorldWithoutDEM.clone():this.minimap.getAxisGridBox2D();this.worldToNormalizedPoint(t,i);var n=this.getDomContainerBounds(),o={width:n.width/2,height:n.height/2};if(this.normalizedPointToScreen(t,o),t.x+=o.width,t.y+=o.height,this.minimap.nmView){var s=this.domContainer.getElementsByTagName("image")[0].width.baseVal.value,r=this.domContainer.getElementsByTagName("image")[0].height.baseVal.value,a=n.width-s,l=n.height-r;s<n.width&&(t.x=(o.width-a/2)/o.width*t.x+a/2),r<n.height&&(t.y=(o.height-l/2)/o.height*t.y+l/2)}return t},t.prototype.normalizedPointToScreen=function(e,t){e.x=e.x*t.width,e.y=-e.y*t.height},t.prototype.worldToNormalizedPoint=function(e,t){t.getSize(this._boxSize),e.x=(e.x-t.min.x)/this._boxSize.x*2-1,e.y=(e.y-t.min.y)/this._boxSize.y*2-1},t}(gn);window.Glodon.Bimface.Marker.View2dAdapter=mn;var fn=function(e){function t(t,i){var n=e.call(this)||this;n.name="DRAWING",n.minimap=t,n.domContainer=t.getMapContainer(),n.viewer=i;return n.initialDomSize={width:300,height:240},n.currentDomSize={width:300,height:240},n}return cn(t,e),t.prototype.getInitialDomSize=function(){return this.initialDomSize},t.prototype.resize=function(e){this.currentDomSize=e},t.prototype.getDomContainerBounds=function(){return this.currentDomSize},t.prototype.getMinimap=function(){return this.minimap},t.prototype.worldToClient=function(e){var t=this.viewer.getViewer().butterfly.minimapMargin,i=this.viewer.getSceneBoundingBox(),n=this.getDomContainerBounds(),o=Math.abs(i.max.x-i.min.x)*(1+2*t[0].x),s=Math.abs(i.max.y-i.min.y)*(1+2*t[0].y),r=o,a=s,l=i.min.x,h=i.max.x,d=i.min.y,c=i.max.y;o/n.width>=s/n.height?(l=i.min.x-t[0].x*Math.abs(i.max.x-i.min.x),c+=((a=o/n.width*n.height)-(c-d))/2):(c=i.max.y+t[0].y*Math.abs(i.max.y-i.min.y),l-=((r=s/n.height*n.width)-(h-l))/2);var u=(e.x-l)/r,g=(c-e.y)/a,p=this.viewer.drawableContainer._items.find((function(e){return e instanceof window.Glodon.Bimface.Plugins.Drawable.MiniTag}));p&&p.config.width;var m=p&&p.config.height||20;return{x:n.width*u,y:n.height*g-m/2}},t}(gn);window.Glodon.Bimface.Marker.DrawingdAdapter=fn;var wn=function(){function e(t,i){this.canUseThree=!!window.THREE,this.id=t,this.editor=i,this.position=this.canUseThree&&new window.THREE.Vector3||{x:0,y:0},this.boundingBox=this.canUseThree&&new window.THREE.Box3||{min:{x:1/0,y:1/0,z:1/0},max:{x:-1/0,y:-1/0,z:-1/0}},this.shape=null,this.style=e.getDefaultStyle(),this.selected=!1,this.highlighted=!1,this.highlightColor="#000088",this.isDisableInteractions=!1,this.ratioW=1,this.ratioH=1,this.keys={BACKSPACE:8,ALT:18,ESC:27,LEFT:37,UP:38,RIGHT:39,BOTTOM:40,DELETE:46,ZERO:48,A:65,D:68,E:69,Q:81,S:83,W:87,PLUS:187,SUB:189},this.onMouseDownBinded=this.onMouseDown.bind(this),this.onClickBinded=this.onClick.bind(this),this.onDoubleClickBinded=this.onDoubleClick.bind(this),this.onKeyUpBinded=this.onKeyUp.bind(this)}return e.prototype.addDomEventListeners=function(){this.shape.addEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.addEventListener("click",this.onClickBinded,!0),this.shape.addEventListener("dblclick",this.onDoubleClickBinded,!0),this.shape.addEventListener("touchstart",this.onClickBinded,!0),window.addEventListener("keyup",this.onKeyUpBinded)},e.prototype.removeDomEventListeners=function(){this.shape.removeEventListener("mousedown",this.onMouseDownBinded,!0),this.shape.removeEventListener("click",this.onClickBinded,!0),this.shape.removeEventListener("dblclick",this.onDoubleClickBinded,!0),this.shape.removeEventListener("touchstart",this.onClickBinded,!0),window.removeEventListener("keyup",this.onKeyUpBinded)},e.prototype.onMouseDown=function(e){e.preventDefault(),e.stopPropagation(),2==e.button&&this.select(e.button)},e.prototype.onClick=function(e){var t=this;e.preventDefault(),e.stopPropagation(),this.clickTimerId&&clearTimeout(this.clickTimerId),this.clickTimerId=setTimeout((function(){t.select(e.button)}),500)},e.prototype.onDoubleClick=function(e){e.preventDefault(),e.stopPropagation(),this.editor.doubleClickMarker(this),this.clickTimerId&&clearTimeout(this.clickTimerId)},e.prototype.onKeyUp=function(e){if(e.keyCode===this.keys.DELETE)this.editor.deselectMarker(),this.delete()},e.prototype.createShape=function(){},e.prototype.destroy=function(){this.removeDomEventListeners(),this.deselect(),this.setParent(null)},e.prototype.set=function(e,t,i,n){this.userId=e,this.canUseThree&&this.position.set(t.x,t.y,t.z)||(this.position=t),i&&(this.boundingBox=this.canUseThree?i.clone():i),n&&(this.style=un.cloneStyle(n)),this.update()},e.prototype.setRatio=function(e,t){this.ratioW=e,this.ratioH=t},e.prototype.setParent=function(e){var t=this.shape;t&&(t.parentNode&&t.parentNode.removeChild(t),e&&e.appendChild(t))},e.prototype.setStyle=function(e){this.style=un.cloneStyle(e),this.update()},e.prototype.select=function(e){this.selected||(this.selected=!0,this.highlight(!0)),this.editor.selectMarker(this,e)},e.prototype.deselect=function(){this.highlight(!1),this.selected=!1},e.prototype.highlight=function(e){this.isDisableInteractions||(this.highlighted=e,this.update())},e.prototype.disableInteractions=function(e){this.isDisableInteractions=e},e.prototype.delete=function(){this.editor.deleteMarker(this)},e.prototype.getClientPosition=function(){return this.editor.getAdapter().worldToClient(this.position)},e.prototype.getBoundingBox=function(){return this.boundingBox},e.prototype.toNewObject=function(){return{id:this.id,userId:this.userId,shapeType:this.shapeType,cx:this.cx,cy:this.cy,position:this.position?Object.assign({},this.position):null,boundingBox:this.boundingBox?Object.assign({},this.boundingBox):null}},e.prototype.show=function(){this.shape.style.display="block"},e.prototype.hide=function(){this.shape.style.display="none"},e.prototype.update=function(){var e=this.style["stroke-width"],t=this.highlighted?this.highlightColor:this.style["stroke-color"],i=this.style["stroke-opacity"],n=this.style["fill-color"],o=this.style["fill-opacity"],s=this.getClientPosition();if(s){var r=s.x,a=s.y;if(2==this.shapeType)var l=["translate(",r-this.pictureSize.width*this.ratioW*.5,",",a-this.pictureSize.height*this.ratioH*.5,") "].join("");else l=["translate(",r,",",a,") "].join("");this.cx=r,this.cy=a,this.shape.setAttribute("transform",l),this.shape.setAttribute("stroke-width",e),this.shape.setAttribute("stroke",t),this.shape.setAttribute("stroke-opacity",i),this.shape.setAttribute("fill",n),this.shape.setAttribute("fill-opacity",o)}else this.shape.style.display="none"},e.shapeTypes={BUBBLE:0,FLAG:1,COMMON:2},e.getDefaultStyle=function(){var e={"stroke-width":2,"stroke-color":"#fffaff","stroke-opacity":1,"fill-color":"#ff2129","fill-opacity":1};return e},e}(),yn=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=wn.shapeTypes.BUBBLE,n.createShape(),n.addDomEventListeners(),n}return cn(t,e),t}(wn),vn=function(){function e(){}return e.createSvgElement=function(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e);return t.setAttribute("pointer-events","inherit"),t},e.getRGBAString=function(e,t){return t<=0?"none":["rgba("+parseInt("0x"+e.substr(1,2)),",",parseInt("0x"+e.substr(3,2)),",",parseInt("0x"+e.substr(5,2)),",",t,")"].join("")},e.makeFlag=function(){var e=this.createSvgElement("path");return e.setAttribute("d","M0 0 L0 -20 L15 -13 L4 -6.87 L4 0Z"),e},e.makeBubble=function(){var e=this.createSvgElement("path");return e.setAttribute("d","m0.0035,-19.88544c-3.838253,0 -6.95,2.581968 -6.95,5.766754c0,3.185555 6.95,13.933247 6.95,13.933247s6.95,-10.747692 6.95,-13.933247c0,-3.184786 -3.11082,-5.766754 -6.95,-5.766754z"),e},e.makeCommon=function(e,t){var i=this.createSvgElement("image");return i.href.baseVal=e,i.setAttribute("height",t.height.toString()+"px"),i.setAttribute("width",t.width.toString()+"px"),i},e}(),bn=function(e){function t(t,i,n,o){var s=e.call(this,t,i)||this;return s.shapeType=wn.shapeTypes.COMMON,s.pictureSize=o||{width:20,height:20},s.createShape(n),s.addDomEventListeners(),s}return cn(t,e),t.prototype.createShape=function(e){this.shape=vn.makeCommon(e,this.pictureSize)},t.prototype.reset=function(){var e=this.pictureSize.width*this.ratioW,t=this.pictureSize.height*this.ratioH;this.shape.setAttribute("width",e.toString()+"px"),this.shape.setAttribute("height",t.toString()+"px")},t}(wn),En=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shapeType=wn.shapeTypes.COMMON,n.createShape(),n.addDomEventListeners(),n}return cn(t,e),t.prototype.createShape=function(){this.shape=vn.makeFlag()},t}(wn),Mn=function(){function e(e){this.disableInteractions=function(e){this.isDisableInteractions=e},this.adapter=e,this.markers=[],this.mapGroupMarkers={},this.groups=null,this.selectedMarker=null,this.flagColors={red:"#ff2129",green:"#85af03",yellow:"#fe9829"},this.bubbleColors={red:"#f92a24",green:"#86b507",gray:"#ff9326"},this.nextMarkerId=0,this.initialized=!1,this.markerClickCallback=null,this.markerDoubleClickCallback=null,this.markerRightClickCallback=null,this.markersRatioH=1,this.markersRatioW=1}return e.prototype.getAdapter=function(){return this.adapter},e.prototype.updateDomContainer=function(){var e=this.adapter.getDomContainer();this.adapter.setDomContainer(e)},e.prototype.getMarkers=function(){return this.markers},e.prototype.getMarkersByGroupName=function(e){return this.mapGroupMarkers.hasOwnProperty(e)?this.mapGroupMarkers[e]:[]},e.prototype.addMarkerToGroup=function(e,t){this.mapGroupMarkers.hasOwnProperty(t)||(this.mapGroupMarkers[t]=[]),this.mapGroupMarkers[t].push(e)},e.prototype.setMarkerGroups=function(e){this.groups=e},e.prototype.removeMarkerInGroup=function(e,t){for(var i=this.mapGroupMarkers[t],n=0,o=i.length;n<o;n++)if(i[n].userId==e)return i.splice(n,1),void this.updateByGroup()},e.prototype.removeMarker=function(e){for(var t=this.markers,i=0,n=t.length;i<n;i++)if(t[i].userId==e)return t[i].destroy(),void t.splice(i,1)},e.prototype.clearMarkers=function(){this.unloadMarkers(!0),this.markers=[],this.mapGroupMarkers={}},e.prototype.setVisible=function(e,t){var i=this.mapGroupMarkers;for(var n in i){var o=i[n];if(o instanceof Array){var s=o.getObjectByAttribute("id",e);s&&(!0===t?s.show():s.hide())}}},e.prototype.updateByGroup=function(e){var t=e||this.groupName;this.unloadMarkers();var i=this.mapGroupMarkers[t];if(i instanceof Array)for(var n=0,o=i.length;n<o;n++)i[n]&&i[n].setParent(this.svgGroup)},e.prototype.resize=function(e){var t=this.adapter.getInitialDomSize(),i=e.width/t.width,n=e.height/t.height;this.markersRatioH=n,this.markersRatioW=i;var o=this.mapGroupMarkers[this.groupName];if(o instanceof Array){for(var s=0,r=o.length;s<r;s++){var a=o[s];a.setRatio(i,n),a.reset(),a.update()}e.width==t.width&&e.height==t.height||(t=e),this.svg.setAttribute("width",e.width+""),this.svg.setAttribute("height",e.height+"")}},e.prototype.setGroupName=function(e){this.groupName=e},e.prototype.updateGroupName=function(){var e=this.adapter.getMinimap();e&&e.getFloorPlaneName&&(this.groupName=e.getFloorPlaneName())},e.prototype.onResize=function(){if(this.svg){var e=this.adapter.getDomContainerBounds();this.svg.setAttribute("width",e.width+""),this.svg.setAttribute("height",e.height+""),this.updateMarkers()}},e.prototype.init=function(){if(!this.svg){var e=this.adapter.getDomContainerBounds(),t=e.width,i=e.height;this.svg=vn.createSvgElement("svg"),this.svg.style.position="absolute",this.svg.style.display="block",this.svg.style.position="absolute",this.svg.style.display="block",this.svg.style.left="0",this.svg.style.top="0",this.svg.setAttribute("width",t+""),this.svg.setAttribute("height",i+""),this.adapter.getDomContainer().appendChild(this.svg),this.svgGroup=vn.createSvgElement("g"),this.svg.insertBefore(this.svgGroup,this.svg.firstChild)}this.initialized=!0},e.prototype.uninit=function(){this.initialized=!1,this.svg&&(this.unloadMarkers(),this.svgGroup&&this.svgGroup.parentNode&&this.svgGroup.parentNode.removeChild(this.svgGroup),this.svg.parentNode&&this.svg.parentNode.removeChild(this.svg),this.svgGroup=null,this.svg=null,this.markerClickCallback=null,this.markerDoubleClickCallback=null,this.markerRightClickCallback=null)},e.prototype.isInitialized=function(){return this.initialized},e.prototype.generateMarkerId=function(){return++this.nextMarkerId,this.nextMarkerId.toString(10)},e.prototype.clear=function(e){var t=this.markers;if(1==e)for(;t.length;){var i=t[0];this.deleteMarker(i)}var n=this.svgGroup;if(n&&n.childNodes.length>0)for(;n.childNodes.length;)n.removeChild(n.childNodes[0])},e.prototype.addMarker=function(e){var t=this.adapter.getName();if("VIEW3D"!=t&&"DRAWING"!=t&&"VIEW2D"!=t||e.setParent(this.svgGroup),this.markers.push(e),this.groups)for(var i=0,n=this.groups.length;i<n;i++)this.addMarkerToGroup(e,this.groups[i]);this.groupName&&this.updateByGroup(this.groupName)},e.prototype.deleteMarker=function(e){if(e){this.removeMarker(e.userId);var t=this.mapGroupMarkers;for(var i in t)this.removeMarkerInGroup(e.userId,i);t&&this.updateByGroup()}},e.prototype.selectMarker=function(e,t){if(!0===this.isDisableInteractions)return this.markerClickCallback&&0==t&&this.markerClickCallback(e.toNewObject()),void(this.markerRightClickCallback&&2==t&&this.markerRightClickCallback(e.toNewObject()));this.selectedMarker!==e?(this.deselectMarker(),this.selectedMarker=e):this.deselectMarker(),this.markerClickCallback&&(this.selectedMarker?this.markerClickCallback(this.selectedMarker.toNewObject()):this.markerClickCallback(null))},e.prototype.doubleClickMarker=function(e){this.markerDoubleClickCallback&&this.markerDoubleClickCallback(e.toNewObject())},e.prototype.deselectMarker=function(){this.selectedMarker&&(this.selectedMarker.deselect(),this.selectedMarker=null)},e.prototype.enableSVGPaint=function(e){e?this.svg&&this.svg.setAttribute("pointer-events","painted"):this.svg&&this.svg.setAttribute("pointer-events","none")},e.prototype.getMarkerColor=function(e,t){var i=this.bubbleColors.red;switch(e<0&&e>1&&(e=0),t>2&&(t-=3),t<0&&t>2&&(t=0),t){case 0:i=0===e?this.bubbleColors.red:this.flagColors.red;break;case 1:i=0===e?this.bubbleColors.green:this.flagColors.green;break;case 2:i=0===e?this.bubbleColors.gray:this.flagColors.yellow}return i},e.prototype.createMarkerByIntersect=function(e,t,i,n){var o={size:n,id:e.id||this.generateMarkerId(),userId:e.userId,position:e.worldPosition||e.object.point,boundingBox:e.worldBoundingBox||e.object&&e.object.boundingBox,shapeType:t,state:i};this.createMarker(o)},e.prototype.createMarker=function(e){if(e){var t=wn.getDefaultStyle();t["fill-color"]=this.getMarkerColor(e.shapeType,e.state);var i,n=e.id||this.generateMarkerId(),o=wn.shapeTypes;switch(e.shapeType){case o.BUBBLE:i=new yn(n,this);break;case o.COMMON:(i=new bn(n,this,e.state,e.size)).setRatio(this.markersRatioW,this.markersRatioH),i.reset();break;case o.FLAG:default:i=new En(n,this)}this.isDisableInteractions&&i.disableInteractions(!0),i.set(e.userId,e.position,e.boundingBox,t),this.addMarker(i)}},e.prototype.getMarkersBoundingBox=function(){if(this.markers.length<1)return null;for(var e=new window.THREE.Box3,t=0,i=this.markers.length;t<i;t++){var n=this.markers[t];n.getBoundingBox()&&e.union(n.getBoundingBox())}return e},e.prototype.getMarkerInfoList=function(){for(var e=[],t=0,i=this.markers.length;t<i;t++){var n=this.markers[t],o=n.userId+"_"+t,s={id:n.id||o,userId:n.userId,shapeType:n.shapeType,position:n.position,boundingBox:n.boundingBox,state:n.state};e.push(s)}return e},e.prototype.loadMarkers=function(e){this.clear();for(var t=0,i=e.length;t<i;t++){var n=e[t],o=n.userId+"_"+t,s=n.id||o,r=n.userId,a=n.shapeType,l=n.state,h=n.position,d=window.THREE?new window.THREE.Box3:{min:{x:1/0,y:1/0,z:1/0},max:{x:-1/0,y:-1/0,z:-1/0}};d.max.x=n.boundingBox.max.x,d.max.y=n.boundingBox.max.y,d.max.z=n.boundingBox.max.z,d.min.x=n.boundingBox.min.x,d.min.y=n.boundingBox.min.y,d.min.z=n.boundingBox.min.z;var c={id:s,userId:r,position:h,boundingBox:d,shapeType:a,state:l};this.createMarker(c)}},e.prototype.loadMarkersFromIntersect=function(e,t,i){this.clear(),this.createMarkerByIntersect(e,t,i)},e.prototype.unloadMarkers=function(e){this.clear(e)},e.prototype.updateMarkers=function(){for(var e=0,t=this.markers.length;e<t;e++){this.markers[e].update()}},e.prototype.getMarker=function(e){for(var t=this.markers,i=t.length,n=0;n<i;++n)if(t[n].userId==e)return t[n];return null},e.prototype.getMarkerByUserId=function(e){for(var t=this.markers,i=t.length,n=0;n<i;++n)if(t[n].userId==e)return t[n];return null},e.prototype.setMarkerClickCallback=function(e){this.markerClickCallback=e},e.prototype.setMarkerDoubleClickCallback=function(e){this.markerDoubleClickCallback=e},e.prototype.setMarkerRightClickCallback=function(e){this.markerRightClickCallback=e},e.prototype.zoomAndPanMarkerById=function(e,t,i,n){var o,s=this.mapGroupMarkers,r=this.svg.getAttribute("width"),a=this.svg.getAttribute("height"),l=new THREE.Vector2(.5*r,.5*a),h=function(e,o){var s=e.getObjectByAttribute("id",o);if(s){var r=s.getClientPosition(),a=s.pictureSize.width*s.ratioW,h=s.pictureSize.height*s.ratioH,d=new THREE.Vector2(r.x,r.y).clone().sub(l);d.multiplyScalar(n);var c=l.x+d.x-.5*a,u=l.y+d.y-.5*h,g="translate("+(c+t)+","+(u+i)+")";s.shape.setAttribute("transform",g)}};for(var d in this.adapter.minimap.nmData&&h(o=this.markers,e),s){(o=s[d])instanceof Array&&h(o,e)}},e}();!function(){var t="Bimface.Plugins.Drawable.MiniTag",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=e.Bimface.Plugins.Drawable.DrawableItem;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");let s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");var r=function(e){o.call(this,e);var t=this;this.miniTagConfig=e,this._config=e,this.notExecutedFns=[],t.worldPosition=e.worldPosition,this._renderCallback=function(){t.resize()}},a=function(e){for(var t=r._tagHelper.getMarkerInfoList(),i=0,n=t.length;i<n;i++){var o=t[i];o.id==e&&r._tagHelper.deleteMarker(o)}};r.clear=function(){r._tagHelper&&r._tagHelper.clearMarkers()},s.Type.inheritPrototype(r,o),r.prototype=Object.assign({},o.prototype,{init:function(){self.viewer=this.viewer;const t=this;if("ViewerDrawing"==this.viewer.viewerType){self.mapHelper=this.miniTagConfig.minimap;var i=new e.Bimface.Marker.DrawingdAdapter(self.mapHelper,this.viewer)}else if(this.miniTagConfig.minimap){self.mapHelper=this.miniTagConfig.minimap.navigationMap?this.miniTagConfig.minimap.navigationMap:this.miniTagConfig.minimap;i=new e.Bimface.Marker.View2dAdapter(self.mapHelper,this.viewer.getViewer());self.mapHelper.setMinimapResizeCallback&&self.mapHelper.setMinimapResizeCallback((function(e){i.resize(e),r._tagHelper.updateGroupName(),r._tagHelper.updateDomContainer(),r._tagHelper.resize(e),r._tagHelper.updateByGroup()})),self.mapHelper.setPlaneChangedCallback&&self.mapHelper.setPlaneChangedCallback((function(){r._tagHelper.updateGroupName(),r._tagHelper.updateByGroup()}));const n={Floor_Plane_Changed_For_Panel:3001,ZOOM_MOUSE_WHEEL:6e3,PAN_MOUSE_MOVE:7e3};self.mapHelper.viewerFloor?(self.mapHelper.viewerFloor.addEventListener(n.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})),self.mapHelper.viewerFloor.addEventListener(n.PAN_MOUSE_MOVE,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})),self.mapHelper.viewerFloor.addEventListener(n.Floor_Plane_Changed_For_Panel,(function(e){var i=self.mapHelper.viewerFloor,n=i.getPanOffset();t.zoomAndPan(n.x,n.y,i.vfData.zoomFactor)}))):(self.mapHelper.nmEditor.eventManager.addEventListener(n.ZOOM_MOUSE_WHEEL,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})),self.mapHelper.nmEditor.eventManager.addEventListener(n.PAN_MOUSE_MOVE,(function(e){var i=e.data;t.zoomAndPan(i.offsetX,i.offsetY,i.zoomFactor)})))}else{i=new e.Bimface.Marker.View3dAdapter(this.viewer.getViewer());this.viewer.getViewer().addCallbacks("render",t._renderCallback)}this.mapHelper=self.mapHelper,null==r._tagHelper&&(r._tagHelper=new Mn(i)).disableInteractions(!0),r._tagHelper.isInitialized()||r._tagHelper.init(),this.executeUnfinishedFns()},draw:function(){var e=this,t=this.miniTagConfig;t.viewer=e.viewer,function(e,t){if(!e)return!1;var i=!1,n=r._tagHelper.getMarkerInfoList();e.userId=e.objectId;for(var o=0,s=n.length;o<s;o++)if(n[o].id==e.id)return i=!0,!1;e.floorList?r._tagHelper.setMarkerGroups(e.floorList):r._tagHelper.setMarkerGroups([]),"ViewerDrawing"!=e.config.viewer.viewerType&&r._tagHelper.updateGroupName(),i||r._tagHelper.createMarkerByIntersect(e,t.shape,t.image,t.size)}({id:this.id,config:this._config,objectId:t.objectId,worldPosition:t.worldPosition,floorList:t.floorList},{shape:2,image:t.src,size:{width:t.width,height:t.height}});var i=e.mapHelper.viewerFloor;if(i){var n=i.getPanOffset();e.zoomAndPan(n.x,n.y,i.vfData.zoomFactor)}const o=e.mapHelper.nmData;o&&o.imgPosition&&e.zoomAndPan(o.imgPosition.x,o.imgPosition.y,o.zoomFactor)},show:function(){i.send(t,"show"),r._tagHelper&&r._tagHelper.setVisible(this.id,!0)},hide:function(){i.send(t,"hide"),r._tagHelper&&r._tagHelper.setVisible(this.id,!1)},getFloorList:function(){return this.miniTagConfig.floorList},setFloorList:function(e){i.send(t,"setFloorList"),this.miniTagConfig.floorList=e,a(this.id),this.draw()},getHeight:function(){return this.miniTagConfig.height},setHeight:function(e){i.send(t,"setHeight"),this.miniTagConfig.height=e,a(this.id),this.draw()},getId:function(){return this.id},getObjectId:function(){return this.miniTagConfig.objectId},setObjectId:function(e){i.send(t,"setObjectId");var n=this.miniTagConfig;a(this.id),n.objectId=e,this.draw()},getSrc:function(){return this.miniTagConfig.src},setSrc:function(e){i.send(t,"setSrc"),this.miniTagConfig.src=e,a(this.id),this.draw()},getWidth:function(){return this.miniTagConfig.width},setWidth:function(e){i.send(t,"setWidth"),this.miniTagConfig.width=e,a(this.id),this.draw()},getWorldPosition:function(){return this.miniTagConfig.worldPosition},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.miniTagConfig.worldPosition=e,a(this.id),this.draw()},executeUnfinishedFns:function(){this.notExecutedFns&&this.notExecutedFns.map((e=>{switch(e[0]){case"setMarkerClickCallback":r._tagHelper.setMarkerClickCallback(e[1]);break;case"setMarkerDoubleClickCallback":r._tagHelper.setMarkerDoubleClickCallback(e[1]);break;case"setMarkerRightClickCallback":r._tagHelper.setMarkerRightClickCallback(e[1])}})),delete this.notExecutedFns},onClick:function(e){i.send(t,"onClick"),r._tagHelper?r._tagHelper.setMarkerClickCallback(e):this.notExecutedFns.push(["setMarkerClickCallback",e])},onDoubleClick:function(e){i.send(t,"onDoubleClick"),r._tagHelper?r._tagHelper.setMarkerDoubleClickCallback(e):this.notExecutedFns.push(["setMarkerDoubleClickCallback",e])},onRightClick:function(e){i.send(t,"onRightClick"),r._tagHelper?r._tagHelper.setMarkerRightClickCallback(e):this.notExecutedFns.push(["setMarkerRightClickCallback",e])},onEndDrag:function(e){i.send(t,"onEndDrag")},zoomAndPan:function(e,t,i){r._tagHelper&&r._tagHelper.zoomAndPanMarkerById(this.id,e,t,i)}}),n.MiniTag=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=new e.Bimface.Plugins.Drawable.DrawableItemConfig;t.ClusterTagConfig=function(){return Object.assign({},i,{width:52,height:57,content:"",src:null,offsetX:0,offsetY:0})}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),i=e.Bimface.Plugins.Drawable.DrawableItem,n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){i.call(this,t),this.includedTags=[],this.clusterBbox=null,this.attachFilter=t.attachFilter;let o=n.create("div","bf-drawable-cluster");o.style.position="absolute",o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.innerHTML=this.getClusterTagHtml();let s=n.create("div","bf-drawable-cluster-textarea");s.innerText=t.content,o.appendChild(s),this.clusterStyle=e.Bimface.Plugins.Cluster.ClusterStyle.Success,this.forceHide=!1,this._config=t,this._domTextArea=s,this._container=o,this.hookEvents()};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(o,i);!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}({hookEvents:function(){let e=this._container,t=this;this.isMouseDown=!1,e.addEventListener("mouseup",(function(e){t.isMouseDown=!1})),e.addEventListener("mousemove",(function(e){t.isMouseDown||t.onHoverCallback&&t.onHoverCallback({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox})})),e.addEventListener("mousedown",(function(e){(e||window.event).stopPropagation(),t.isMouseDown=!0})),e.addEventListener("click",(function(e){(e||window.event).stopPropagation(),t.clickTimerId&&clearTimeout(t.clickTimerId),t.clickTimerId=setTimeout((()=>{t.onClickCallback&&t.onClickCallback({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox})}),500)})),e.addEventListener("dblclick",(function(e){(e||window.event).stopPropagation(),t._doubleClick&&t._doubleClick({id:t.id,position:t.worldPosition,includedTags:t.getIncluded(),boundingBox:t.clusterBbox}),t.clickTimerId&&clearTimeout(t.clickTimerId)}))},draw:function(e){var t=this._container,i=this._config;t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",e.rootDomElement.appendChild(t)},getClusterTagHtml(){let e='<defs><filter x="-23.9%" y="-21.4%" width="147.7%" height="142.9%" filterUnits="objectBoundingBox" id="filter-clustertag"><feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset><feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur> <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix> <feMerge><feMergeNode in="shadowMatrixOuter1"></feMergeNode><feMergeNode in="SourceGraphic"></feMergeNode></feMerge></filter> </defs>';this.attachFilter||(e="");let t='<svg width="52px" height="57px" version="1.1" transform="translate(0,0)">'+e;return t+=`<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="编组" filter="#filter-clustertag" transform="translate(4.000000, 3.000000)"> <path id="${this.id}" d="M43.7259252,22.0045824 C43.7259252,9.85175882 33.9373645,0.000288235294 21.8628598,0.000288235294 C9.78835514,0.000288235294 0.000205607477,9.85175882 0.000205607477,22.0045824 C0.000205607477,29.7679941 3.99803738,36.5872294 10.0313832,40.5039353 L10.0202804,40.5039353 L21.8628598,48.6045824 L33.7058505,40.5039353 L33.6947477,40.5039353 C39.7276822,36.5872294 43.7259252,29.7679941 43.7259252,22.0045824" id="Fill-1" fill="#32D3A6"></path><circle fill="#FFFFFF" cx="22" cy="22" r="16"></circle></g></g></svg>`,t},setScale:function(e){this._container.style.transform=`scale(${e})`},getText:function(){return this._domTextArea.innerText},setText:function(e){this._domTextArea.innerText=e},updateText:function(){let e=this.getIncluded().length;this.showDetails||e<=99?(e>999&&(this._container.children[0].style.scale=1.5),e>99999?this.setText("99999"):this.setText(e.toString())):this.setText("99+")},show:function(){this._container.style.display="block",this.forceHide=!1},hide:function(){this._container.style.display="none",this.forceHide=!0},onClick:function(e){this.onClickCallback=e},onHover:function(e){this.onHoverCallback=e},include:function(e){this.includedTags.push(e)},isInclude:function(e){for(const t of this.includedTags)if(t.getId()===e)return!0;return!1},setBoundingBox:function(e){this.clusterBbox=e},getIncluded:function(){return this.includedTags},getContainer:function(){return this._container},hideIncludedTags:function(){for(const e of this.includedTags)e.isHideByClustering=!0},showIncludedTags:function(){for(const e of this.includedTags)e.isHideByClustering=!1},getCurrentPosition:function(){return{x:this.worldPosition.x,y:this.worldPosition.y,z:this.worldPosition.z}},setStyle:function(e){this.clusterStyle=e;let t=document.getElementById(this.getId());t&&(t.style.fill=e),this._domTextArea.style.color=e},getStyle:function(){return this.clusterStyle},getOpacity:function(){return""===this._container.style.opacity?1:this._container.style.opacity},setOpacity:function(e){this._container.style.opacity=e},resetClientPosition:function(e){const t=this._container,i=this._config;"Viewer3D"!==this.viewer.viewerType&&"ViewerGIS"!==this.viewer.viewerType||(e=this.viewer.worldToClient(e)),t.style.left=e.x+i.offsetX-i.width/2+"px",t.style.top=e.y+i.offsetY-i.height/2+"px"},setContainerVisible(e){this._container.style.display=!0===e?"block":"none"},play:function(e){if(!(this.clusterBbox&&this.clusterBbox.center&&this.includedTags.length>0))return void console.log("clusterBbox");const t=this.clusterBbox.center,i=this.includedTags,n=i.length;for(let e=0;e<n;e++){const t=i[e];t.originClientPosition=t.clientPosition}this.time=500;let o=(new Date).valueOf(),s=o-16;this.progress=0;let r=()=>{this.animationId=requestAnimationFrame(r),this.progress>=1&&(this.curvePos=1,e&&e(),cancelAnimationFrame(this.animationId),this.progress=0),(e=>{for(let o=0;o<n;o++){const n=i[o];let s=n.originClientPosition;s.x=s.x+(t.x-s.x)*e,s.y=s.y+(t.y-s.y)*e,n.resetClientPosition(s)}})(this.progress),o=(new Date).valueOf();const a=o-s;s=o,this.progress+=a/this.time};r()}},o),t.ClusterTag=o}(),function(){var t="Bimface.Plugins.Drawable.DrawableContainer",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Drawable"),o=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Bimface.Plugins.Drawable.ClusterTag);n.DrawableContainer=class{constructor(t){let i=this,n=t.viewer;if(n.drawableContainer)return n.drawableContainer;n.drawableContainer=this,P(this);let o=e.Bimface.Viewer.ViewerDrawing&&n instanceof e.Bimface.Viewer.ViewerDrawing,s=e.Bimface.Viewer.Viewer3D&&"Viewer3D"===n.viewerType,r=e.Bimface.Viewer.ViewerDrawingSet&&n instanceof e.Bimface.Viewer.ViewerDrawingSet,a=e.Bimface.Viewer.ViewerGIS&&n instanceof e.Bimface.Viewer.ViewerGIS,l=new e.Web.Lang.EventManager,h=new e.Bimface.Plugins.Drawable.DrawableContext;if(this.bIsEnableMinitagUpdate=!0,this.boxMap={},i._enableRender=t.enableRender,n.addEventListener("Rendered",(function(e){i.bIsEnableMinitagUpdate=!1,i.update(e),i.bIsEnableMinitagUpdate=!0})),s||a){let t=null,o=null;n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,(function(e){o||(o=setTimeout((()=>{i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position),o=null}),500)),t&&(clearTimeout(t),t=null),t=setTimeout((()=>{clearTimeout(o),o=null,i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position)}),200)}))}a&&(n.addEventListener(e.Bimface.Viewer.ViewerGISEvent.ViewChanged,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.ViewerGISEvent.LayerVisibleChanged,(function(){i.handleEnableDepthTest()}))),s&&(n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewLoaded,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelVisibleChanged,(function(){i.handleEnableDepthTest()})));let d=()=>{n.getViewer().registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(t=>{let i=this.getAllItems();for(let o=0,s=i.length;o<s;o++)i[o]instanceof e.Bimface.Plugins.Drawable.MiniTag||hn.attachExplosionOffset(n,t.extent,i[o])}))};if(o)n.getRootElement().appendChild(h.rootDomElement);else if(r){n.getActiveDrawing().viewerDrawing.getRootElement().appendChild(h.rootDomElement)}else a?(n.getDomElement().appendChild(h.rootDomElement),this.calculateViewerGISExplosionOffset=e=>{const t=n.getViewer(),o=e.modelId,s=e.floorInfos.length,r=t.getFloorExplosionExtent(o),a=t.getFloorExplosionDirection(o);if(0===r)for(const e of i.getAllItems())e.setInitialExplosionInfo(n);const l=e.floorInfos;let h=[];for(var d=0;d<s;d++){let e=l[d],t=l[d+1],i=l[d-1];if(h.push({box:{min:i?e.boundingBox.min.z:-1/0,max:t?t.boundingBox.min.z:1/0},floorName:e.name,explodedOffset:e.explodedHeight-e.elevation}),h.length==s){this.boxMap[o]=h;break}}const c=n.getLayerManager();let u=this._items;for(let e=0,t=u.length;e<t;e++){if(!u[e].getWorldPosition())continue;const t=c.getLayer(u[e].layerId);if(!t||!t.modelId)continue;if(t.modelId.toString()!==o||!u[e].levelName)continue;let i=h.getObjectByAttribute("floorName",u[e].levelName);i&&(u[e].explosionOffset={x:a.x*i.explodedOffset,y:a.y*i.explodedOffset,z:a.z*i.explodedOffset})}},n.addEventListener(e.Bimface.Viewer.ViewerGISEvent.FloorExplosion,(e=>{this.calculateViewerGISExplosionOffset(e)})),d()):(n.getDomElement().getElementsByClassName("bf-drawable-context").length>0?h.rootDomElement=n.getDomElement().getElementsByClassName("bf-drawable-context")[0]:n.getDomElement().appendChild(h.rootDomElement),t.affectedBySection&&(n.addEventListener(e.Bimface.Plugins.Section.SectionBoxEvent.SectionBoxUpdate,(function(e){i.section=e,i.update()})),n.addEventListener(e.Bimface.Plugins.Section.SectionPlaneEvent.SectionPlaneUpdate,(function(e){i.section=e,i.update()}))),this.calculateViewer3dExplosionOffset=e=>{const t=e.modelId,o=e.floorInfos.length,s=n.getDefaultModel().modelId.toString(),r=n.getModel(t).getFloorExplosionExtent(),a=n.getModel(t).getFloorExplosionDirection();if(0===r)for(const e of i.getAllItems())e.setInitialExplosionInfo(n);let l=[];i.floorInfos=e;var h=function(){let e=i._items;for(let n=0,o=e.length;n<o;n++){let o=e[n].getWorldPosition();if(o)if(!0!==e[n]._isBindRoom)if(e[n].levelName){let t=l.getObjectByAttribute("floorName",e[n].levelName);t&&(e[n].explosionOffset={x:a.x*t.explodedOffset,y:a.y*t.explodedOffset,z:a.z*t.explodedOffset})}else if(t!==s)e[n].explosionOffset={x:e[n].explosionOffset.x,y:e[n].explosionOffset.y,z:e[n].explosionOffset.z};else{let t=!0;for(let i=0;i<l.length;i++){const s=l[i];if(s.box.min<o.z&&s.box.max>o.z){e[n].explosionOffset={x:a.x*s.explodedOffset,y:a.y*s.explodedOffset,z:a.z*s.explodedOffset},e[n].levelName=s.floorName,t=!1;break}}t&&(e[n].explosionOffset={x:0,y:0,z:0})}else{const t=i._viewer.getViewer().modelManager.modelCollection.getById("ExtrudeBodyManager").getNode(e[n]._config.objectId),o=t.explodedHeight,s=t.explodedDirection;e[n].explosionOffset={x:s.x*o,y:s.y*o,z:s.z*o}}}};if(o)for(var d=0;d<o;d++){let t=e.floorInfos[d],n=e.floorInfos[d+1],s=e.floorInfos[d-1];l.push({box:{min:s?t.boundingBox.min.z:-1/0,max:n?n.boundingBox.min.z:1/0},floorName:t.name,explodedOffset:t.explodedHeight-t.elevation}),l.length==o&&(h(),i.boxs=l)}},n.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,(e=>{this.calculateViewer3dExplosionOffset(e)})),d());i._items=[],i._viewer=n,i._context=h,i._isDrawingView=o,i._isDrawingViewSet=r,i._isViewer3D=s,i._isViewerGIS=a,i._areaData={},i.loadAreas=void 0,i.addItemCallback=[],i._maxNum=t.maxNum,i.getEventManager=function(){return l}}showOrHideLabelForCamearPosition(e,t){if(this._isViewer3D||this._isViewerGIS){!e&&(e=this._viewer.getCameraStatus().position),t=t||this._items;for(let i=0;i<t.length;i++)if("number"==typeof t[i].visibleDistance){let n=t[i].worldPosition;Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2)+Math.pow(n.z-e.z,2))>t[i].visibleDistance?t[i].hideByCameraPosition():t[i].showByCameraPosition()}this.bIsEnableMinitagUpdate=!1,this.update(),this.bIsEnableMinitagUpdate=!0}}handleEnableDepthTest(e){(this._isViewer3D||this._isViewerGIS)&&this._items&&this._items.length>0&&this._items.map((t=>{this._viewer.getViewer().camera.frustum.containsPoint(this._viewer.worldToScene(t.worldPosition))&&t.handleEnableDepthTest(e)}))}addItem(n){i.send(t,"addItem");const o=this._items,s=this._viewer;if(n.viewer=s,n.update=this.update.bind(this),!n.worldPosition)return;if(n instanceof e.Bimface.Plugins.Drawable.MiniTag)n.init(),o.push(n),this.update();else{let e=hn.ifExploded(s,n,this._isViewerGIS);e&&("Viewer3D"===this._viewer.getViewerType()&&e.setInitialExplosionInfo(this._viewer),o.push(e),this._enableRender&&this.update())}this.showOrHideLabelForCamearPosition(),n.handleEnableDepthTest&&n.handleEnableDepthTest()}getLevelNameById(t,i){if(!this._spatialRelation){let t=new e.Bimface.Plugins.SpatialRelation.RoomConfig;t.viewer=this._viewer;let i=new e.Bimface.Plugins.SpatialRelation.Room(t);this._spatialRelation=i}let n=this._spatialRelation.getBoundaryByRoomId(t);if(n){if(this._levelsInfo)return levelName=function(e,t){let i=e[0][2];for(let e=0;e<t.length;e++)if(Math.abs(i-t[e].elevation)<5)return t[e].name;return!1}(n,this._levelsInfo),levelName;(this._isViewer3D?this._viewer.getDefaultModel():this._viewer).getMapInfo((e=>{this._levelsInfo=e.axisGrid.Levels,this.addItem(i)}))}}removeItemById(e){i.send(t,"removeItemById");let n=this._items.removeObjectByAttribute("id",e);n=n&&n[0];let o=n._domElement||n._container;n&&this._context.rootDomElement.contains(o)&&o.remove(),n._svgGroup&&this._context.svgContainer.contains(n._svgGroup)&&this._context.svgContainer.removeChild(n._svgGroup),this.update()}getItemById(e){return this._items.getObjectByAttribute("id",e)}getAllItems(){return this._items}addItems(e){if(i.send(t,"addItems"),e.length)for(var n=0;n<e.length;n++)e[n].update=this.update.bind(this),e[n].viewer=this._viewer;if("Viewer3D"===this._viewer.getViewerType()||this._isViewerGIS)for(const t of e){t.viewer=this._viewer,t.init&&t.init();let e=hn.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer)}else for(const t of e)t.viewer=this._viewer,t.init&&t.init(),this._items.push(t);this._enableRender&&this.update()}clear(){i.send(t,"clear"),this._items.map((e=>{let t=e._domElement||e._container;e&&this._context.rootDomElement.contains(t)&&t.remove(),e._svgGroup&&this._context.svgContainer.contains(e._svgGroup)&&this._context.svgContainer.removeChild(e._svgGroup)})),this._items=[],this.update()}update(){let t=this._items,i=this._viewer,n=this._context,o=this._maxNum;var s=document.body.getBoundingClientRect(),r=e.Bimface.Plugins.Drawable.MiniTag;if(this.bIsEnableMinitagUpdate&&r.clear(),this._isDrawingView&&(i=i.getViewer()),this._isDrawingView)for(let o=0,r=t.length;o<r;o++){let r=t[o].getWorldPosition();if(r)if(t[o]instanceof e.Bimface.Plugins.Drawable.ClusterTag){let e=i.toScreenPoint([r.x,r.y]);n.clientPosition={x:e[0],y:e[1]},t[o].draw(n)}else{var a=i.toScreenPoint([r.x,r.y]);if(t[o]._domElement){var l=t[o]._domElement.offsetWidth/2,h=t[o]._domElement.offsetHeight/2;if(t[o].isHideByClustering){t[o]._domElement.style.display="none";continue}if(a[0]<-l||a[0]>s.width+l||a[1]<-h||a[1]>s.height+h){t[o]._domElement.style.display="none";continue}t[o]._domElement.style.display="block",t[o].updateVisibility()}n.clientPosition={x:a[0],y:a[1]},t[o].draw(n)}}else if(this._isDrawingViewSet)for(let o=0,s=t.length;o<s;o++){let s=t[o].getWorldPosition();a=i.getDrawingById(t[o].viewerDrawingId).viewerDrawing.worldToClient(s);if(n.clientPosition=a,t[o]instanceof e.Bimface.Plugins.Drawable.ClusterTag){let e=i.toScreenPoint([s.x,s.y]);n.clientPosition={x:e[0],y:e[1]},t[o].draw(n)}else t[o].updateVisibility(),t[o].draw(n)}else{for(let n=0,o=t.length;n<o;n++){let o=t[n];o.needForceUpdate&&(o=hn.ifExploded(i,o,this._isViewerGIS),o.needForceUpdate=!1);let s=o.getCurrentPosition();o.clientPosition=i.worldToClient(s);let r=o._container||o._domElement,a=o._svgGroup;if(o instanceof e.Bimface.Plugins.Drawable.MiniTag||i.isInViewFrustum(s)){if(this.isHideFromSection(s)||o.forceHide||o.isHideByClustering&&!0!==o.isInAnimation){r&&(r.style.display="none"),a&&(a.style.display="none");continue}r&&(r.style.display=""),a&&(a.style.display="")}else r&&(r.style.display="none"),a&&(a.style.display="none")}t.sort((function(e,t){return e.clientPosition.z>=t.clientPosition.z?1:-1}));for(let i=0;i<t.length;i++){var d="default";i>=o&&(d="mini"),n.clientPosition=t[i].clientPosition,t[i]instanceof e.Bimface.Plugins.Drawable.MiniTag&&0==this.bIsEnableMinitagUpdate||t[i].draw(n,d)}}}isHideFromSection(e){if(!this.section)return!1;if("SectionBox"===this.section.id){let t=this._viewer.getViewer().editorManager.getToolByName("clipByBox").isReverse,i=this.section.isIncluded(e);return t?i:!i}return!this.section.isIncluded(e)}exit(){i.send(t,"exit"),this.clear(),this._context.destroy()}hideItemsById(e){i.send(t,"hideItemsById");let n=this;if(e&&e.length>0)for(let t=0;t<e.length;t++){var o=n.getItemById(e[t]);o&&o.hide()}}hideAllItems(){i.send(t,"hideAllItems");let e=this._items;if(e&&e.length>0)for(let t=0;t<e.length;t++)e[t].hide()}showItemsById(e){i.send(t,"showItemsById");let n=this;if(e&&e.length>0)for(let t=0;t<e.length;t++){var o=n.getItemById(e[t]);o&&o.show()}}showAllItems(){i.send(t,"showAllItems");let e=this._items;if(e&&e.length>0)for(let t=0;t<e.length;t++)e[t].show()}removeClusterTags(e){let t=this.getAllItems();for(let i=t.length-1;i>=0;){let n=t[i];if(n instanceof o&&n.clusterItemId===e){t.splice(i--,1);let e=n.getContainer();this._context.rootDomElement.contains(e)&&e.remove()}else i--}}showItemsByLayerId(e){i.send(t,"showItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;t--){let i=n[t];i.layerId==e&&i.show()}}hideItemsByLayerId(e){i.send(t,"hideItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;t--){let i=n[t];i.layerId==e&&i.hide()}}removeItemsByLayerId(e){i.send(t,"removeItemsByLayerId");let n=this.getAllItems();for(let t=n.length-1;t>=0;){let i=n[t];if(i.layerId==e){let e=i._domElement||i._container;i&&this._context.rootDomElement.contains(e)&&e.remove(),i._svgGroup&&i._svgGroup.parentElement.removeChild(i._svgGroup),n.splice(t--,1)}else t--}}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster").ClusterContainerConfig=function(){return{viewer:null,enableAnimation:!0}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster")),n=e.Web.Lang.Utility.performance;i.ClusterContainer=class{constructor(e){t.send("Bimface.Plugins.Cluster","ClusterContainer"),this.viewer=e.viewer,this.isViewer3D="Viewer3D"===e.viewer.getViewerType()||"ViewerGIS"===e.viewer.getViewerType(),this.clusterItems=[],this._lastZoomFactorData=null,this.hookEvents(e.viewer),this.enableAnimation=!1!==e.enableAnimation,P(this)}hookEvents(e){let t=e.getViewerType();this.isViewer3D?this.hookViewer3DEvents():"ViewerDrawing"===t?this.hookViewerDrawingEvents():this.hookViewerDrawingSetEvents()}hookViewer3DEvents(){var t=this.viewer.getViewer();let i=[];i.push(CLOUD.EVENTS.ON_EDITOR_ZOOM),i.push(CLOUD.EVENTS.ON_EDITOR_PANING),i.push(CLOUD.EVENTS.ON_EDITOR_ROTATING),i.push(CLOUD.EVENTS.ON_EDITOR_WALKING),i.push(CLOUD.EVENTS.ON_CAMERA_ANIMATION_UPDATE);for(const e of i)t.registerEventListener(e,(()=>{this.update()}));t.registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(()=>{this.update(!0)})),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,(()=>{for(const e of this.clusterItems)e.meanShift=null;this.update(!0)}))}hookViewerDrawingEvents(){let t=e.Bimface.Viewer.ViewerDrawingEvent;this.viewer.addEventListener(t.ZoomFactorChanged,(e=>{let t=!1;(null===this._lastZoomFactorData||e>=this._lastZoomFactorData)&&(t=!0),this.update(!1,t),this._lastZoomFactorData=e}))}hookViewerDrawingSetEvents(){let t=e.Bimface.Viewer.ViewerDrawingSetEvent;this.viewer.addEventListener(t.ZoomFactorChanged,(e=>{let t=!1;(null===this._lastZoomFactorData||e>=this._lastZoomFactorData)&&(t=!0),this.update(!1,t),this._lastZoomFactorData=e}))}addCluster(e){e.viewer=this.viewer,e.init(),this.clusterItems.push(e),e.setIsNeedMakingClusterTag(!0)}addClusters(e){for(const t of e)this.addCluster(t)}getClusterById(e){for(const t of this.clusterItems)if(t.getId()===e)return t;return null}getClusters(){return this.clusterItems}removeClustersById(e){let t=this.clusterItems;for(let i=t.length-1;i>=0;){let n=t[i];e.indexOf(n.id)>=0?(n.clearClusterTags(),t.splice(i--,1)):i--}}clear(){for(const e of this.clusterItems)e.clearClusterTags();this.clusterItems=[]}update(e,t){let i=(e,t)=>{for(const i of this.clusterItems){if(this.isViewer3D){if(0===i.calcClusterLevel()){i.clearClusterTags();continue}}(e||i.isNeedClustering())&&i.clustering(t),i.updateClusterTags(this.enableAnimation)}};this.throttleAndDebounceFun||(this.throttleAndDebounceFun=n.throttleAndDebounce(i)),this.isViewer3D?this.throttleAndDebounceFun(e,t):i(e,t)}enableClusterAnimation(e){this.enableAnimation=e}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster").ClusterItemConfig=function(){return{scale:1,tags:[],distance:50,maxLevel:4,style:e.Bimface.Plugins.Cluster.ClusterStyle.Success,minClusterSize:2,viewer:null,showDetails:!1}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster");let i=Object.freeze({Danger:"#FF001F",Information:"#1A82FC",Success:"#32D3A6",Warning:"#FF9D0B"});t.ClusterStyle=i}();class Cn{constructor(e){this.viewer3d=e.viewer,this.currentLevel=0,this._maxLevel=e.maxLevel,this._minClusterSize=e.minClusterSize,this._sceneSize=new THREE.Vector3}prepareTagPositions(e){let i=[];for(let n=0;n<e.length;n++){let o=e[n].getCurrentPosition(),s=new t(o.x,o.y,o.z);s.index=n,i.push(s)}return i}calcSearchRange(e){return this.currentLevel=this.calcClusterLevel(e),this.getSearchRangeScalar(this.currentLevel,this.getMaxLevel())*this.getLength(e)[1]}getSearchRangeScalar(e,t){return.5**(t-e)}calcClusterLevel(e){if(!e)return 0;let t=this.getLength(e),i=this.getMaxLevel(),n=20*t[1]/t[2],o=t[0]*n/t[1],s=Math.exp(Math.log(40)/(i-1)),r=-1;for(let e=i;e>=1;e--)if(o>=.5*s**(e-1)){r=e;break}return-1===r&&(r=0),0===t[1]&&(r=1),r}getLength(e){let n=this.prepareTagPositions(e),o=this.viewer3d.getCameraStatus().position;o=new t(o.x,o.y,o.z);let s=(new i).setFromPoints(n).getSize().length(),r=o.distanceTo(n[0]);n.forEach((e=>{const t=o.distanceTo(e);r=Math.min(r,t)}));let a=.995*this.getCameraMaxRange(),l=[];return l.push(r),l.push(s),l.push(a),l}getCameraMaxRange(){var e=this.viewer3d.getViewer(),t=e.camera;e.getBoundingBoxWorld().getSize(this._sceneSize);const i=.5*this.viewer3d.globalUnitUtil.revertTranslate(this._sceneSize.length())/Math.tan(THREE.Math.degToRad(.5*t.fov));return e.cameraControl.getMaximalRangeofCamera()*i}setMaxLevel(e){this._maxLevel=e}getMaxLevel(){return this._maxLevel}getMinClusterSize(){return this._minClusterSize}setMinClusterSize(e){this._minClusterSize=e}isLevelChanged(e){return this.calcClusterLevel(e)!==this.currentLevel}cullingByFrustum(e){for(const t of e){this.viewer3d.isInViewFrustum(t.worldPosition)?t.show():t.hide()}}getBoundingbox(e){return e.min=e.bbox.min,e.max=e.bbox.max,e}getCenter(e){return e.center}setDistance(){console.log("ClusterItem3D doesn't support setDistance.")}getDistance(){console.log("ClusterItem3D doesn't support getDistance.")}clustering(e,t){e.clustering(t,!0)}}class xn{constructor(e){this.viewerDrawing=e.viewer,this.searchRange=e.distance,this._minClusterSize=e.minClusterSize}prepareTagPositions(e){let i=[];for(let n=0;n<e.length;n++){let o=e[n].getWorldPosition();o=this.viewerDrawing.worldToClient(o);let s=new t(o.x,o.y,o.z);s.index=n,i.push(s)}return i}calcSearchRange(e){return this.searchRange}isLevelChanged(){return!0}setDistance(e){this.searchRange=e}getDistance(){return this.searchRange}setMaxLevel(e){console.log("Drawing clustering has no maxlevel.")}getMaxLevel(){console.log("Drawing clustering has no maxLevel.")}getMinClusterSize(){return this._minClusterSize}setMinClusterSize(e){this._minClusterSize=e}cullingByFrustum(){}getBoundingbox(e){return e}getCenter(e){let t=e.center;return this.viewerDrawing.clientToWorld(t)}clustering(e,t){e.clustering(t,!1,(e=>{const t=this.viewerDrawing.getViewer(),i=t.width,n=t.height;return!(e.x<0||e.x>i||e.y<0||e.y>n)}))}}class Tn{constructor(){}}Tn.time=300,Tn.Play=function(e){const{clusterTags:t,lastClusterTags:i,clusters:n,lastClusters:o,enableAnimation:s,isZoomIn:r,tags:a,container:l}=e;(()=>{for(const e of t)e.updateText()})();!1===s||null===o||(()=>{const e=n.length;if(e!==o.length)return!1;for(let t=0;t<e;t++)if(n[t].id!==o[t].id)return!1;return!0})()||(!0===r?Tn.ZoomInPlay(t,i,n,o,a):Tn.ZoomOutPlay(t,i,n,o,a,l))},Tn.getCluster=function(e,t){for(const i of e)if(i.id===t)return i},Tn.getClusterTag=function(e,t){for(const i of e)if(i.clusterBbox.id===t)return i},Tn.getIndices=function(e){let t=[];for(const i of e.points)t.push(i.index);return t},Tn.getEndClientPosition=function(e){return e instanceof Glodon.Bimface.Plugins.Marker3D.Marker3D?e.position:"Viewer3D"===e.viewer.viewerType||"ViewerGIS"===e.viewer.viewerType?{x:e.worldPosition.x+e.explosionOffset.x,y:e.worldPosition.y+e.explosionOffset.y,z:e.worldPosition.z+e.explosionOffset.z}:e.viewer.worldToClient(e.worldPosition)},Tn.ZoomInPlay=function(e,t,i,n,o,s){for(const n of i){if(n.id===n.parent)continue;const i=n.parent,s=Tn.getClusterTag(t,i);for(const r of t)if(r.clusterBbox.id===i){const t=Tn.getClusterTag(e,n.id),i=r.clusterBbox.center;let a=null;if(t){a=t.clusterBbox.center,Tn.CreateZoomAnimation(t,s,i,a,!0);continue}const l=Tn.getIndices(n);for(const e of l){let t=o[e];t&&(a=Tn.getEndClientPosition(t),a&&(t.setContainerVisible(!0),Tn.CreateZoomAnimation(t,s,i,a,!0)))}}}},Tn.CreateZoomAnimation=function(e,t,i,n,o,s){let r=0,a=e.getOpacity(),l=a;t.show(),!0===o&&(r=1,a=0),t.setOpacity(r),e.setOpacity(a);let h=(new Date).valueOf(),d=h-16,c=0,u=()=>{const o=requestAnimationFrame(u);if(c>=1)return c=1,e.resetClientPosition(n),e.setOpacity(l),s&&s(),void cancelAnimationFrame(o);(o=>{const s={x:i.x+(n.x-i.x)*o,y:i.y+(n.y-i.y)*o,z:i.z+(n.z-i.z)*o};t.setOpacity(Math.abs(r-o)),e.setOpacity(l*Math.abs(1-r-o)),e.resetClientPosition(s)})(c),h=(new Date).valueOf();const a=h-d;d=h,c+=a/this.time};u()},Tn.ZoomOutPlay=function(e,t,i,n,o,s){for(const r of i){const i=r.children;if(0===i.length)continue;const a=Tn.getClusterTag(e,r.id);if(a)for(const e of i){const i=Tn.getClusterTag(t,e),l=r.center;let h=null;if(i){h=i.clusterBbox.center,Tn.CreateZoomOutAnimation(i,a,h,l,s);continue}const d=Tn.getCluster(n,e),c=Tn.getIndices(d);for(const e of c){let t=o[e];t&&(h=Tn.getEndClientPosition(t),h&&Tn.CreateItemZoomOutAnimation(t,a,h,l,s))}}}},Tn.CreateZoomOutAnimation=function(e,t,i,n,o){const s=e.getContainer();o._context.rootDomElement.appendChild(s),Tn.CreateZoomAnimation(e,t,i,n,!1,(()=>{t.show(),s.remove()}))},Tn.CreateItemZoomOutAnimation=function(e,t,i,n,o){e.setContainerVisible(!0),e.isInAnimation=!0,Tn.CreateZoomAnimation(e,t,i,n,!1,(()=>{t.show(),e.isInAnimation=null,e.setContainerVisible(!1)}))},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cluster"));class n{constructor(i){t.send("Bimface.Plugins.Cluster","ClusterItem"),this.config=i,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.setTags(i.tags),this._isVisible=!0,this.clusterTags=[],this._mapTagIsExist={},this._mapClusterTags={},this.mapDrawableStyle={},this.mapClusterException={},this.onClusterChanged=null,this.clusterStyle=i.style,this.scale=i.scale,this._isNeedClustering=!0,this._isNeedMakingClusterTag=!0,this.meanShift=null,this._lastSearchRange=null,this._lastClusters=null,this._lastClusterTags=null,P(this)}init(){this.isViewer3D="Viewer3D"===this.viewer.getViewerType()||"ViewerGIS"===this.viewer.getViewerType(),this.config.viewer=this.viewer,this.impl=this.isViewer3D?new Cn(this.config):new xn(this.config)}setScale(e){this.scale=e,this.makeClusterTags()}getScale(){return this.scale}getId(){return this.id}getTags(){return this._tags}addTags(t){for(let i=0;i<t.length;i++){let n=t[i];n instanceof e.Bimface.Plugins.Drawable.MiniTag||!0!==this._mapTagIsExist[n.id]&&(this._tags.push(n),this._mapTagIsExist[n.id]=!0)}this._isNeedClustering=!0,this.meanShift=null}getMinClusterSize(){return this.impl.getMinClusterSize()}setMinClusterSize(e){"number"==typeof e&&e>0?(this.impl.setMinClusterSize(e),this._isNeedClustering=!0):console.log("Invalid param, please input valid param.")}setTags(e){if(0!==e.length){if(this._tags)for(const e of this._tags)e.isHideByClustering=!1;this._tags=[],this._mapTagIsExist={},this.addTags(e)}}removeTagsByIds(e){for(let t=this._tags.length-1;t>=0;){let i=this._tags[t];e.indexOf(i.id)>=0?(this._tags.splice(t--,1),delete this._mapTagIsExist[i.id],i.isHideByClustering=!1):t--}this._isNeedClustering=!0,this.meanShift=null}setDistance(e){this.impl.setDistance(e)}getDistance(){return this.impl.getDistance()}getMaxLevel(){return this.impl.getMaxLevel()}setMaxLevel(e){this.impl.setMaxLevel(e),this._isNeedClustering=!0}onClick(e){this.onClickCallback=e;for(const e of this.clusterTags)e.onClick(this.onClickCallback)}onDoubleClick(e){this.onDoubleClickCallback=e;for(const e of this.clusterTags)e.onClick(this.onDoubleClickCallback)}onHover(e){this.onHoverCallback=e;for(const e of this.clusterTags)e.onClick(this.onHoverCallback)}hide(){for(const e of this.clusterTags)e.hide();for(let e=0;e<this._tags.length;e++)this._tags[e].isHideByClustering=!0;this._getContainer().update(),this._isVisible=!1}show(){for(const e of this.clusterTags)e.show();this._isVisible=!0,this.clustering(),this.updateClusterTags()}getClusterTagById(e){for(const t of this.clusterTags)if(t.isInclude(e))return t;return null}getClusterTag(e){let t=this._mapClusterTags[e];return t||(console.log("Can't find a cluster tag whose id is "+e),null)}onClusterChange(e){this.onClusterChanged=e}getStyle(){return this.clusterStyle}setStyle(e){this.clusterStyle=e;for(const t of this.clusterTags)t.setStyle(e)}getStyleById(e){let t=this.getClusterTag(e);return t&&t.getStyle()}setStyleById(e,t){let i=this.getClusterTag(e);return i&&i.setStyle(t)}setException(e,t){[].concat(e).forEach((e=>{this.mapDrawableStyle[e]=t}))}removeException(e){[].concat(e).forEach((e=>{delete this.mapDrawableStyle[e]}))}clearException(){let t=Object.keys(this.mapDrawableStyle),i=e.Bimface.Plugins.Cluster.ClusterStyle.Success;t.forEach((e=>{this.mapDrawableStyle[e]=i}))}_updateMapException(){let e=Object.keys(this.mapDrawableStyle);this.mapClusterException={};let t=this.mapClusterException;for(const i of e){let e=this.getClusterTagById(i);if(!e)continue;let n=e.getId(),o=this.mapDrawableStyle[i];t[n]||(t[n]={}),t[n][o]=!0}}_updateCurrentStyle(){this._updateMapException();for(const e of this.clusterTags){let t=e.getId(),i=this.mapClusterException;if(!i[t]){this.setStyleById(t,this.clusterStyle);continue}let n=this._getStyleInOrder(i[t]);n&&this.setStyleById(t,n)}}_getStyleInOrder(t){let i=e.Bimface.Plugins.Cluster.ClusterStyle,n=[i.Danger,i.Warning,i.Information,i.Success];for(const e of n)if(t[e])return e;return i.Success}clustering(t){if(!1===this._isVisible)return;let i=this.getTags();for(const e of i)e.isHideByClustering=!1;let n=this.impl.calcSearchRange(this.getTags()),o=this.impl.prepareTagPositions(this.getTags());null===this.meanShift&&(this.meanShift=new e.Web.Algorithm.MeanShift(o,n)),this.meanShift.setSearchRange(n),this.meanShift.setPoints(o);let s=!0;null!=this._lastSearchRange&&this._lastSearchRange<n&&(s=!1),this.isZoomIn=void 0!==t?t:s,this.impl.clustering(this.meanShift,this.isZoomIn),this._lastSearchRange=n,this._isNeedClustering=!1,this._isNeedMakingClusterTag=!0}updateClusterTags(e){if(!1!==this._isVisible)if(this.isNeedMakingClusterTag())this.makeClusterTags(e),!1===this._isVisible&&this.hide(),this._isNeedMakingClusterTag=!1,this.onClusterChanged&&this.onClusterChanged();else if(this._isVisible)return this.impl.cullingByFrustum(this.clusterTags),this._getClusterContainer().update(),void this._updateCurrentStyle()}makeClusterTags(e){for(let e=0;e<this._tags.length;e++)this._tags[e].isHideByClustering=!1,!0===this._tags[e].forceHide&&(this._tags[e].forceHide=!1);this.clusterTags=[],this._mapClusterTags={};let t=!1;for(const e of this.meanShift.clusters){let i=this._getIndices(e);if(i.length<this.impl.getMinClusterSize())continue;let o=n.makeClusterTag(this.impl.getCenter(e),t,this.scale);t=!0;for(const t of i){let i=this._tags[t];i&&(i.isHideByClustering=!0,o.include(i),o.setBoundingBox(this.impl.getBoundingbox(e)))}o.clusterItemId=this.id,o.showDetails=this.config.showDetails,this.onClickCallback&&o.onClick(this.onClickCallback),this.onDoubleClickCallback&&o.onDoubleClick(this.onDoubleClickCallback),this.onHoverCallback&&o.onHover(this.onHoverCallback),this.clusterTags.push(o),this._mapClusterTags[o.getId()]=o}this.impl.cullingByFrustum(this.clusterTags),this._getClusterContainer().removeClusterTags(this.id),this._getClusterContainer().addItems(this.clusterTags),this._updateCurrentStyle();let i=this._getContainer();i.update(),!0===i.isMarker3DContainer&&(e=!1);const o={clusterTags:this.clusterTags,lastClusterTags:this._lastClusterTags,clusters:this.meanShift.clusters,lastClusters:this._lastClusters,enableAnimation:e,isZoomIn:this.isZoomIn,tags:this._tags,container:this.viewer.drawableContainer};Tn.Play(o),this._lastClusterTags=this.clusterTags,this._lastClusters=this.meanShift.clusters}clearClusterTags(){if(!this._tags)return;for(let e=0;e<this._tags.length;e++)this._tags[e].isHideByClustering=!1,!0===this._tags[e].forceHide&&(this._tags[e].forceHide=!1);this._getClusterContainer().removeClusterTags(this.id),this._getContainer().update()}calcClusterLevel(){return this.impl.calcClusterLevel(this.getTags())}_getClusterContainer(){let t=this.viewer.drawableContainer;if(!t){var i=new e.Bimface.Plugins.Drawable.DrawableContainerConfig;i.viewer=this.viewer,t=new e.Bimface.Plugins.Drawable.DrawableContainer(i)}return t}isNeedClustering(){return this._isNeedClustering||this.impl.isLevelChanged(this.getTags())}isNeedMakingClusterTag(){return this._isNeedMakingClusterTag}setIsNeedMakingClusterTag(e){this._isNeedMakingClusterTag=e}_getContainer(){return this._tags[0]instanceof e.Bimface.Plugins.Marker3D.Marker3D?this.viewer.marker3DContainer:this.viewer.drawableContainer}_getIndices(e){let t=[];for(const i of e.points)t.push(i.index);return t}}n.makeClusterTag=function(t,i,n){let o=new e.Bimface.Plugins.Drawable.ClusterTagConfig;o.worldPosition=t,o.attachFilter=!i;let s=new e.Bimface.Plugins.Drawable.ClusterTag(o);return s.setScale(n),s},i.ClusterItem=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureConfig=function(){return{viewer:null,measureType:e.Bimface.Plugins.Measure.MeasureTypeOption.Distance,color:new e.Web.Graphics.Color(249,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),width:3,radius:25,snapDistance:5,precision:{distance:3,elevation:3,area:3,angle:2,latLon:9},scale:1,units:null,layerType:"TerrainLayer",enableAuxiliaryValue:!1,initialElevation:0,laserXYZ:["X","Y","Z"],minimumDistanceZoom:!1}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure");let i=Object.freeze({Measuring:"Measuring",Measured:"Measured",Reset:"Reset",MeasureSelected:"MeasureSelected",MeasureUnselected:"MeasureUnselected",MeasureResultUpdating:"MeasureResultUpdating",MeasureResultUpdated:"MeasureResultUpdated"});t.MeasureEvent=i}(),function(){let t=Object.freeze({Distance:"Distance",Area:"Area",Angle:"Angle",MinimumDistance:"MinimumDistance",Elevation:"Elevation",Position:"Position",PolylineDistance:"PolylineDistance",TriangleDistance:"TriangleDistance",SpatialArea:"SpatialArea",ProjectedArea:"ProjectedArea",SurfaceArea:"SurfaceArea",GroundlineDistance:"GroundlineDistance",Volume:"Volume",LaserClearDistance:"LaserClearDistance",Slope:"Slope"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureTypeOption=t}(),function(){let t=Object.freeze({None:"None",Kilometer:"Kilometer",Meter:"Meter",Centimeter:"Centimeter",Millimeter:"Millimeter"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").LengthUnits=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureItemConfig=function(){return{id:null,color:new e.Web.Graphics.Color(255,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),fillColor:new e.Web.Graphics.Color(255,157,11,.2),objectColor:new e.Web.Graphics.Color(17,218,183,.9),width:3,radius:25,viewer:null}};class Pn{constructor(e){this.type=e,this.observer=null}initialize(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}drawAnnotation(e,t){}calcAnnotationStyle(e,t){}select(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="none"})),this.notationSelected.forEach((e=>{e.style.display="block"})))}unselect(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="block"})),this.notationSelected.forEach((e=>{e.style.display="none"})))}dropShadow(e){this.isInitialized()&&this.notationUnselected.forEach((t=>{t.setAttribute("filter",e),t.setAttribute("filter",e)}))}isInitialized(){return!!this.notationUnselected&&!!this.notationSelected}clear(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}hitTest(e){if(!this.isInitialized())return!1;let t=this.hitTestEpsilon;return this.notationSegmentRects.some((i=>re.distanceToSegment(e,i.start,i.end)<=t))}}class In extends Pn{constructor(e){super(e),this.defaultColor="#F99D0B",this.initialize()}initialize(){super.initialize(),this.annotationStyle={height:21,radius:4},this.hitTestEpsilon=this.annotationStyle.height/2}drawAnnotation(e,t,i,o){var s=this.calcAnnotationStyle(t,e),r=re.makeRectangle({x:s.offsetRect.x,y:s.offsetRect.y,width:s.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:o||this.defaultColor});this.notationUnselected.push(r);let a=re.makeRectangle({x:s.offsetRect.x-2,y:s.offsetRect.y-2,width:s.width+4,height:this.annotationStyle.height+4,radius:this.annotationStyle.radius,strokeColor:"#FFFFFF",fillColor:o||this.defaultColor});this.notationSelected.push(a);let l=new n(s.offsetRect.x,s.offsetRect.y+this.annotationStyle.height/2),h=new n(s.offsetRect.x+s.width,l.y);this.notationSegmentRects.push({start:l,end:h});var d=re.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});return this.svgGroup=[],this.svgGroup.push(r),this.svgGroup.push(a),this.svgGroup.push(d),this.unselect(),this.svgGroup}calcAnnotationStyle(e,t){var i=0,o=new n(t.x,t.y),s=new n(t.x,t.y);return"Elevation"!==this.type&&(i=re.measureText(e),o.x-=i/2,o.y-=this.annotationStyle.height/2,s.x=o.x+5,s.y=o.y+19-3.5),"Elevation"==this.type&&(o.x-=12,o.y-=39,s.x=o.x+5,s.y=o.y+19-3.5,i=re.measureText(e)),"SpatialArea"==this.type&&(o.x+=i/2+20,s.x+=i/2+20,o.y-=3,s.y-=3),{offsetRect:o,offsetText:s,width:i+=10}}}class Sn extends Pn{constructor(e,t){super(e),this.defaultColor=t||"#20262F",this.initialize()}initialize(){super.initialize(),this.annotationStyle={height:this.calcAnnotationHeight(),radius:this.calcAnnotationRadius(),fillOpacity:.85},this.hitTestEpsilon=this.annotationStyle.height/2}drawAnnotation(e,t,i,o){var s=this.calcAnnotationStyle(t,e,o),r=re.makeRectangle({x:s.offsetRect.x,y:s.offsetRect.y,width:s.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:this.defaultColor,fillOpacity:this.annotationStyle.fillOpacity});let a=new n(s.offsetRect.x,s.offsetRect.y+this.annotationStyle.height/2),l=new n(s.offsetRect.x+s.width,a.y);this.notationSegmentRects.push({start:a,end:l});let h=re.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});this.notationSelected.push(h);let d=re.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#A4A8AE",fontsize:14,content:t});if(this.notationUnselected.push(d),this.svgGroup=[],this.type==Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Position){var c=re.makeRectangle({x:s.offsetArrow.x,y:s.offsetArrow.y,width:7,height:7,radius:0,fillColor:this.defaultColor,fillOpacity:this.annotationStyle.fillOpacity});c.setAttribute("transform",`rotate(45 ${s.offsetArrow.x} ${s.offsetArrow.y})`),this.svgGroup.push(c)}return this.svgGroup.push(r),this.svgGroup.push(d),this.svgGroup.push(h),this.unselect(),this.svgGroup}calcAnnotationStyle(e,t,i){var o=0,s=this.annotationStyle.height,r=new n(t.x,t.y),a=new n(t.x,t.y),l=new n(t.x,t.y);if(this.type==Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Position){e.split("\n").forEach((e=>{let t=re.measureText(e);o=t>o?t:o})),o+=10,r.x-=o/2+5,r.y-=s+8+10,a.x=r.x+10,a.y=r.y+30-3.5}else o=re.measureText(e),!0===i?r.x+=15:r.x-=o/2,r.y-=this.annotationStyle.height/2,a.x=r.x+5,a.y=r.y+19-3.5;return l.y-=22.5,{offsetRect:r,offsetText:a,offsetArrow:l,width:o+=10}}calcAnnotationHeight(){let e=21;return"Position"==this.type&&(e=100),e}calcAnnotationRadius(){let e=4;return"Position"==this.type&&(e=0),e}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=new e.Web.Graphics.Color(17,218,183,.2),o=new e.Web.Graphics.Color(17,218,183,1),s=function(t){this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.nextMeasurePoint=null,this.measurePoints=[],this.maxPointsNum=2,this.measureResult=null,this.measureParams={precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit},this.measureItemConfig=t,this.viewer=t.viewer;t.color.getRGBA();let s=i.createNS("circle","bf-measure-handle");s.setAttribute("stroke-width",0),s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();let r=i.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=n.getRGB();let a=i.createNS("polygon","bf-measure-rect");a.setAttribute("fill",n.getRGBA()),a.setAttribute("stroke",n.getRGB()),a.setAttribute("stroke-width",1);var l=i.createNS("path","bf-measure-foot");l.setAttribute("fill","none"),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("rect","bf-snap-handle");h.setAttribute("width",14),h.setAttribute("height",14),h.setAttribute("fill","none"),h.setAttribute("stroke",o.getRGB()),h.setAttribute("stroke-width",2);const d=i.createNS("path","bf-snap-handle");d.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),d.setAttribute("fill","none"),d.setAttribute("stroke",o.getRGB()),d.setAttribute("stroke-width",2);const c=i.createNS("line","bf-snap-handle");c.setAttribute("x1",0),c.setAttribute("y1",0),c.setAttribute("x2",14),c.setAttribute("y2",14),c.setAttribute("stroke",n.getRGB()),c.setAttribute("stroke-width",2);const u=i.createNS("line","bf-snap-handle");u.setAttribute("x1",14),u.setAttribute("y1",0),u.setAttribute("x2",0),u.setAttribute("y2",14),u.setAttribute("stroke",n.getRGB()),u.setAttribute("stroke-width",2),this.hoverFoot=l,this.hoverPoint=s,this.hoverLine=r,this.hoverPanel=a,this.hoverEndPoint=h,this.hoverMidPoint=d,this.hoverIntersectionPointA=c,this.hoverIntersectionPointB=u,this.hoverPanelSize={width:20,height:20},this.defaultColor=`#${t.color.getHEX()}`||"#F99D0B",this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.measureType=t.measureType,this.notation="ViewerGIS"===this.viewer.getViewerType()?new Sn(this.measureType):new In(this.measureType),this.isReserverd=!1,this.hoverPositionUpdated=!1};s.prototype={stretchOnDirection:function(e,t,i){let n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){},drawLine(e){if(0===e.length)return;let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this._svg.appendChild(t)},drawTerminalPoint(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)},drawNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this._svg.appendChild(e)},drawCaptureItem:function(e){let t=this.hoverPoint,i=this.hoverLine,n=this.hoverPanel,o=this.hoverEndPoint,s=this.hoverMidPoint,r=this.hoverIntersectionPointA,a=this.hoverIntersectionPointB,l=e.hoverPosition&&e.hoverPosition.x,h=e.hoverPosition&&e.hoverPosition.y,d=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",l),t.setAttribute("cy",h),e.svg.appendChild(t);break;case"EndPoint":o.setAttribute("x",l-7),o.setAttribute("y",h-7),e.svg.appendChild(o);break;case"MidPoint":s.setAttribute("d",`M ${l} ${h-7} L ${l+8} ${h+8} L ${l-8} ${h+8} L ${l} ${h-7}`),e.svg.appendChild(s);break;case"IntersectionPoint":r.setAttribute("x1",l-7),r.setAttribute("y1",h-7),r.setAttribute("x2",l+7),r.setAttribute("y2",h+7),e.svg.appendChild(r),a.setAttribute("x1",l+7),a.setAttribute("y1",h-7),a.setAttribute("x2",l-7),a.setAttribute("y2",h+7),e.svg.appendChild(a);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-14} v 14 h 14 M ${t},${i-9} h 9 v 9`),e.svg.appendChild(this.hoverFoot)}else i.setAttribute("x1",e.lineStartPoint.x),i.setAttribute("y1",e.lineStartPoint.y),i.setAttribute("x2",e.lineEndPoint.x),i.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(i);break;case"Panel":let c=e.clientPts,u=c[0].distanceTo(c[1]),g=c[0].distanceTo(c[3]),p=u/d.width,m=g/d.height;if(1!=p){let e=this.stretchOnDirection(c[0],c[1],d.width),t=this.stretchOnDirection(c[2],c[3],d.width);c=e.concat(t)}if(1!=m){let e=this.stretchOnDirection(c[0],c[3],d.height),t=this.stretchOnDirection(c[1],c[2],d.height);c=[e[0],t[0],t[1],e[1]]}let f="";for(let e=0;e<c.length;e++)f+=c[e].x+",",f+=c[e].y+" ";n.setAttribute("points",f),e.svg.appendChild(n)}},reset:function(){if(this.measurePoints=[],this.nextMeasurePoint=null,this.measureResult=null,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},addPoint:function(e){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)},redo:function(){this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?this.measurePoints.pop():this.measurePoints=[]},getPoints:function(){return this.measurePoints},calcLine:function(e,t){let i=[];var n=this.viewer.getViewer(),o=this.viewer.getDomElement().getBoundingClientRect(),s=n.worldPointsToClient(e,t);if(s){e=new THREE.Vector2(s.start.x-o.left,s.start.y-o.top),t=new THREE.Vector2(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i},setMeasureParams:function(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit},setIsReserverd:function(e){this.isReserverd=e},getIsReserverd:function(){return this.isReserverd}},t.MeasureItem=s}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=(new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.maxPointsNum=2,this.measurePoints=[];var t=e.color.getRGBA(),o=n.createNS("circle","bf-measure-handle");o.setAttribute("stroke-width",0),o.setAttribute("r",5),o.setAttribute("stroke","#FFFFFF"),o.setAttribute("stroke-width",2),o.setAttribute("fill",t),o.style.fill=t;var s=o.cloneNode(),r=n.createNS("line","bf-measure-line"),a=r.cloneNode();a.style.strokeWidth=2,a.setAttribute("stroke-dasharray","6,4");var l=a.cloneNode(),h=a.cloneNode();r.style.strokeWidth=e.width,r.style.stroke=e.color.getRGBA(),a.style.stroke="#CC021B",l.style.stroke="#7CCF21",h.style.stroke="#4A90E2",r.setAttribute("stroke-width",e.width),this.line=r,this.lineX=a,this.lineY=l,this.lineZ=h,this.startPoint=o,this.endPoint=s});t.Type.inheritPrototype(o,i.MeasureItem);o.prototype=Object.assign(o.prototype,{stretchOnDirection:function(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){var t=this.line,i=this.lineX,n=this.lineY,o=this.lineZ,s=this.startPoint,r=this.endPoint;if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 2:var a=e.auxLines[0],l=e.auxLines[1],h=e.auxLines[2];a&&(i.setAttribute("x1",a.start.x),i.setAttribute("y1",a.start.y),i.setAttribute("x2",a.end.x),i.setAttribute("y2",a.end.y),e.svg.appendChild(i)),l&&(n.setAttribute("x1",l.start.x),n.setAttribute("y1",l.start.y),n.setAttribute("x2",l.end.x),n.setAttribute("y2",l.end.y),e.svg.appendChild(n)),h&&(o.setAttribute("x1",h.start.x),o.setAttribute("y1",h.start.y),o.setAttribute("x2",h.end.x),o.setAttribute("y2",h.end.y),e.svg.appendChild(o)),s.setAttribute("cx",e.clientPoints[1].x),s.setAttribute("cy",e.clientPoints[1].y),r.setAttribute("cx",e.clientPoints[0].x),r.setAttribute("cy",e.clientPoints[0].y),t.setAttribute("x1",e.clientPoints[0].x),t.setAttribute("y1",e.clientPoints[0].y),t.setAttribute("x2",e.clientPoints[1].x),t.setAttribute("y2",e.clientPoints[1].y),e.svg.appendChild(s),e.svg.appendChild(r),e.svg.appendChild(t);break;case 1:s.setAttribute("cx",e.clientPoints[0].x),s.setAttribute("cy",e.clientPoints[0].y),this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(t.setAttribute("x1",e.clientPoints[0].x),t.setAttribute("y1",e.clientPoints[0].y),t.setAttribute("x2",e.hoverPosition.x),t.setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(t)),e.svg.appendChild(s)}}}),i.MeasureDistanceItem=o}();class Bn{constructor(){}static formatDistance(e,t){if(null==e)return null;let i=t.precision,n=t.scale||1,o=t.unit,s=1;return"Centimeter"===o?s=10:"Meter"===o?s=1e3:"Kilometer"===o&&(s=1e6),"m"===t.defaultUnit&&(n*=1e3),e*=n,e/=s,this.formatPrecision(e,i)}static formatArea(e,t){let i=t.precision,n=t.scale,o=t.unit,s=1;return"Centimeter"===o?s=100:"Meter"===o?s=1e6:"Kilometer"===o&&(s=1e13),"m"===t.defaultUnit&&(n*=1e3),e*=Math.pow(n,2),e/=s,this.formatPrecision(e,i)}static formatCubic(e,t){let i=t.precision,n=t.scale,o=t.unit,s=1;return"Centimeter"===o?s=1e3:"Meter"===o?s=1e9:"Kilometer"===o&&(s=1e19),"m"===t.defaultUnit&&(n*=1e3),e*=Math.pow(n,3),e/=s,i?this.toLocaleString(this.formatPrecision(e,i)):this.formatPrecision(e,i)}static getPostFix(e,t){if("None"===e)return"";let i={None:"",Kilometer:"km",Meter:"m",Centimeter:"cm",Millimeter:"mm"}[e];return t?i+="²":i=" "+i,i}static toLocaleString(e){let t=e.toString();return t=t.replace(/\d{1,3}(?=((\d{3})+(\.\d+)?)$)/g,"$&,"),t}static formatPrecision(e,t){if(e=parseInt(Math.round(e*Math.pow(10,t)))/Math.pow(10,t),0!=t){let i=e.toFixed(t).split(".");e=i[0]+"."+i[1]}else e=this.toLocaleString(e);return e}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=(new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.maxPointsNum=3,this.radius=e.radius,this.measurePoints=[];var t=e.color.getRGBA(),o=n.createNS("circle","bf-measure-handle");o.setAttribute("stroke-width",0),o.setAttribute("r",5),o.setAttribute("stroke","#FFFFFF"),o.setAttribute("stroke-width",2),o.setAttribute("fill",t),o.style.fill=t;var s=o.cloneNode(),r=o.cloneNode(),a=n.createNS("path","bf-measure-angle");a.setAttribute("fill","rgba(0,0,0,0)"),a.setAttribute("stroke",t),a.setAttribute("stroke-width",e.width);var l=n.createNS("line","bf-measure-line");l.style.strokeWidth=e.width,l.style.stroke=t,l.setAttribute("stroke-width",e.width);var h=l.cloneNode(),d=n.create("span","bf-measure-number");d.style.backgroundColor=e.color.getRGBA(),this.points=[o,s,r],this.lines=[l,h],this.angleLine=a,this.text=d});t.Type.inheritPrototype(o,i.MeasureItem);var s={_getPoint:function(e,t,i,n){e=new THREE.Vector2(e.x,e.y),t=new THREE.Vector2(t.x,t.y),i=new THREE.Vector2(i.x,i.y);var o=1,s=e.sub(t),r=i.sub(t);if(s.length()<n||r.length()<n)return!1;s.setLength(n),r.setLength(n);var a=s.angle(),l=180*(r.angle()-a)/Math.PI;return l<0&&(l+=360),o=l<180?1:0,{pointA:t.clone().add(s),pointB:t.clone().add(r),flag:1,direction:o}},draw:function(e,t){var i=this.points;if(this._svg=e.svg,this.drawCaptureItem(e),this.getIsReserverd())return;for(var n=0,o=e.clientPoints.length;n<o;n++)e.clientPoints[n]&&(i[n].setAttribute("cx",e.clientPoints[n].x),i[n].setAttribute("cy",e.clientPoints[n].y),e.svg.appendChild(i[n]));"ViewerGIS"===this.viewer.viewerType?this.drawAngleWithResult(e,t):this.drawAngle(e)},drawAngle:function(e){var t=this.lines,i=this.angleLine;switch(e.clientPoints.length){case 3:t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.clientPoints[1].x),t[0].setAttribute("y2",e.clientPoints[1].y),t[1].setAttribute("x1",e.clientPoints[1].x),t[1].setAttribute("y1",e.clientPoints[1].y),t[1].setAttribute("x2",e.clientPoints[2].x),t[1].setAttribute("y2",e.clientPoints[2].y);var n=this.radius,o=this._getPoint(e.clientPoints[0],e.clientPoints[1],e.clientPoints[2],n);o&&(i.setAttribute("d",`M ${o.pointA.x} ${o.pointA.y} A ${n} ${n} 0 0 ${o.direction} ${o.pointB.x} ${o.pointB.y}`),e.svg.appendChild(i)),e.svg.appendChild(t[1]),e.svg.appendChild(t[0]);break;case 2:t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.clientPoints[1].x),t[0].setAttribute("y2",e.clientPoints[1].y),e.svg.appendChild(t[0]),this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(t[1].setAttribute("x1",e.clientPoints[1].x),t[1].setAttribute("y1",e.clientPoints[1].y),t[1].setAttribute("x2",e.hoverPosition.x),t[1].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(t[1]));break;case 1:this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.hoverPosition.x),t[0].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(t[0]))}},drawAngleWithResult:function(e,t){var i=this.lines,n=this.angleLine;switch(this.measureResult=t.angle,e.clientPoints.length){case 2:i[0].setAttribute("x1",e.clientPoints[0].x),i[0].setAttribute("y1",e.clientPoints[0].y),i[0].setAttribute("x2",e.clientPoints[1].x),i[0].setAttribute("y2",e.clientPoints[1].y),i[1].setAttribute("x1",e.clientPoints[1].x),i[1].setAttribute("y1",e.clientPoints[1].y),i[1].setAttribute("x2",e.hoverPosition.x),i[1].setAttribute("y2",e.hoverPosition.y);var o=this.radius,s=this._getPoint(e.clientPoints[0],e.clientPoints[1],e.hoverPosition,o);s&&(n.setAttribute("d",`M ${s.pointA.x} ${s.pointA.y} A ${o} ${o} 0 0 ${s.direction} ${s.pointB.x} ${s.pointB.y}`),e.svg.appendChild(n)),e.svg.appendChild(i[1]),e.svg.appendChild(i[0]),this.drawNotation(e,s);break;case 1:this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(i[0].setAttribute("x1",e.clientPoints[0].x),i[0].setAttribute("y1",e.clientPoints[0].y),i[0].setAttribute("x2",e.hoverPosition.x),i[0].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(i[0]))}},drawNotation(e,t){if(t){var i=new THREE.Vector2((t.pointA.x+t.pointB.x)/2,(t.pointA.y+t.pointB.y)/2),n=new THREE.Vector2(e.clientPoints[1].x,e.clientPoints[1].y),o=i.clone().sub(n).normalize().multiplyScalar(35);i=n.clone().add(o);let s=this.notation.drawAnnotation(i,this.getMeasureResult(),this.id);for(const t of s)e.svg.appendChild(t)}},getMeasureResult(){this.measureParams.unit;let e=this.measureResult.toString();return Bn.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}};o.prototype=Object.assign(o.prototype,s),i.MeasureAngleItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(e){i.MeasureItem.call(this,e),this.maxPointsNum=2,this.measurePoints=[],this.opt=e,this.minDistanceLine=null,this.svgContainer=n.createNS("svg","bf-minDistanceMeasure-svg"),this.startPoint=n.createNS("circle","bf-minDistanceMeasure-handle"),this.endPoint=n.createNS("circle","bf-minDistanceMeasure-handle"),this.line=n.createNS("line","bf-minDistanceMeasure-line")};t.Type.inheritPrototype(o,i.MeasureItem);o.prototype=Object.assign(o.prototype,{draw:function(e){},setMinDistanceLine:function(e){this.minDistanceLine=e},clearMinDistanceLine:function(){var e=this.startPoint;e.parentNode&&this.svgContainer.removeChild(e);var t=this.endPoint;t.parentNode&&this.svgContainer.removeChild(t);var i=this.line;i.parentNode&&this.svgContainer.removeChild(i)},addPoint:function(e){var t=this.opt.viewer;this.opt.objectColor;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())},reset:function(e){var t=this.opt.viewer;!1!==e&&this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])})),this.measurePoints=[],this.clearMinDistanceLine(),this.minDistanceLine=null,t.render()},redo:function(){var e=this.opt.viewer;if(this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum){var t=this.measurePoints.pop();(t.modelId?e.getModel(t.modelId):e).removeSelectedId([t.userId]),e.render()}else this.reset()}}),i.MeasureMinimumDistanceItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){i.MeasureItem.call(this,t),this.viewer=t.viewer,this.maxPointsNum=1;var o=new e.Web.Graphics.Color(17,218,183,.2),s=n.createNS("circle","bf-measure-handle");s.setAttribute("r",t.width),s.setAttribute("fill",o.getRGB()),s.style.fill=o.getRGB();var r=n.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=o.getRGB();var a=n.createNS("polygon","bf-measure-rect");a.setAttribute("fill",o.getRGBA()),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",1),this.hoverLine=r,this.hoverPoint=s,this.hoverPanel=a,this.hoverPanelSize={width:20,height:20}};t.Type.inheritPrototype(o,i.MeasureItem);o.prototype=Object.assign(o.prototype,{stretchOnDirection:function(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){var t=this.hoverLine,i=this.hoverPoint,n=this.hoverPanel,o=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":i.setAttribute("cx",e.hoverPosition.x),i.setAttribute("cy",e.hoverPosition.y),e.svg.appendChild(i);break;case"Line":t.setAttribute("x1",e.lineStartPoint.x),t.setAttribute("y1",e.lineStartPoint.y),t.setAttribute("x2",e.lineEndPoint.x),t.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(t);break;case"Panel":var s=e.clientPts,r=s[0].distanceTo(s[1]),a=s[0].distanceTo(s[3]),l=r/o.width,h=a/o.height;if(1!=l){var d=this.stretchOnDirection(s[0],s[1],o.width),c=this.stretchOnDirection(s[2],s[3],o.width);s=d.concat(c)}if(1!=h){d=this.stretchOnDirection(s[0],s[3],o.height),c=this.stretchOnDirection(s[1],s[2],o.height);s=[d[0],c[0],c[1],d[1]]}for(var u="",g=0;g<s.length;g++)u+=s[g].x+",",u+=s[g].y+" ";n.setAttribute("points",u),e.svg.appendChild(n)}}}),i.MeasureElevationItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(e){i.MeasureItem.call(this,e),this.maxPointsNum=1,this.measurePoints=[],this.measureAllPoints=[],this.opt=e});t.Type.inheritPrototype(n,i.MeasureItem);var o={draw:function(e){},addPoint:function(e){var t=this.opt.viewer;this.opt.objectColor;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())},reset:function(e){var t=this.opt.viewer;!1!==e&&(console.info(JSON.parse(JSON.stringify(this.measurePoints))),this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])}))),this.measurePoints=[],t.render()}};n.prototype=Object.assign(n.prototype,o),i.MeasureVolumeItem=n}();const _n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),Ln=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class Dn extends _n.MeasureItem{constructor(t){super(t),this.opt=t,this.maxPointsNum=1;const i=new e.Web.Graphics.Color(17,218,183,.2),n=Ln.createNS("circle","bf-measure-handle");n.setAttribute("r",t.width),n.setAttribute("fill",i.getRGB()),n.style.fill=i.getRGB();const o=Ln.createNS("line","bf-measure-line");o.style.strokeWidth=2,o.style.stroke=i.getRGB();const s=Ln.createNS("polygon","bf-measure-rect");s.setAttribute("fill",i.getRGBA()),s.setAttribute("stroke",i.getRGB()),s.setAttribute("stroke-width",1),this.hoverLine=o,this.hoverPoint=n,this.hoverPanel=s,this.hoverPanelSize={width:20,height:20};const r=this.viewer.getDomElement();let a=document.getElementsByClassName("bf-measure-dragbutton")[0];if(!a){a=document.createElement("div"),a.innerHTML='\n <svg width="160px" height="160px" viewBox="0 0 160 160" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <g>\n <g fill="#FFFFFF" fill-opacity="0.3" stroke="#999999" stroke-width="2">\n <path d="M80,1 C82.7908696,1 85.5479441,1.14468216 88.264129,1.4269862 C89.0464893,1.50830005 89.8254567,1.60103155 90.6008619,1.70501165 C95.2372276,2.32673796 99.7462267,3.35063053 104.091601,4.74047874 C109.461201,6.4579211 114.580945,8.73415789 119.382458,11.5007405 C131.430077,18.4424547 141.474355,28.4710659 148.435065,40.506339 C155.154653,52.1247049 159,65.6133154 159,80 C159,101.815248 150.157624,121.565248 135.861436,135.861436 C121.565248,150.157624 101.815248,159 80,159 C58.1847524,159 38.4347524,150.157624 24.1385643,135.861436 C9.84237619,121.565248 1,101.815248 1,80 C1,58.1847524 9.84237619,38.4347524 24.1385643,24.1385643 C38.4347524,9.84237619 58.1847524,1 80,1 Z" id="Oval-2"></path>\n </g>\n <circle fill-opacity="0.8" fill="#FFFFFF" cx="80" cy="80" r="40"></circle>\n <g transform="translate(58.000000, 58.000000)" fill="#32D3A6" fill-rule="nonzero">\n <path d="M23.2727273,27.1515152 L23.2727273,36.8484848 L29.0909091,36.8484848 L22.3030303,44.6060606 L15.5151515,36.8484848 L21.3333333,36.8484848 L21.3333333,27.1515152 L23.2727273,27.1515152 Z M36.8484848,15.5151515 L44.6060606,22.3030303 L36.8484848,29.0909091 L36.8484848,23.2707879 L27.1515152,23.2727273 L27.1515152,21.3333333 L36.8484848,21.3313939 L36.8484848,15.5151515 Z M7.75757576,15.5151515 L7.75757576,21.3333333 L17.4545455,21.3333333 L17.4545455,23.2727273 L7.75757576,23.2727273 L7.75757576,29.0909091 L0,22.3030303 L7.75757576,15.5151515 Z M22.3030303,0 L29.0909091,7.75757576 L23.2727273,7.75757576 L23.2727273,17.4545455 L21.3333333,17.4545455 L21.3333333,7.75757576 L15.5151515,7.75757576 L22.3030303,0 Z" id="形状"></path>\n </g>\n </g>\n </g>\n </svg>\n ',a.className="bf-measure-dragbutton",a.style.display="none";let e=this.dragEvents={touchmove:e=>{let{top:t,left:i}=r.getBoundingClientRect(),{clientX:n,clientY:o}=e.touches[0];this.setButtonPosition(a,n-i,o-t);const s=new Touch({identifier:Date.now(),target:r,clientX:n,clientY:o,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5}),l=new TouchEvent("touchstart",{touches:[s]});r.dispatchEvent(l);const h=new TouchEvent("touchend");r.dispatchEvent(h),e.stopPropagation(),e.preventDefault()}};for(let t in e)a.addEventListener(t,e[t]);r.appendChild(a)}this.dragButton=a,this.dragButtonPoint=null,this.dragButtonVisible=!1,this._result={};const l=this.nextButtons={},h=document.createElement("div");this.nextButtonContainer=h,r.appendChild(h),["positive_X","negative_X","positive_Y","negative_Y","positive_Z"].forEach((e=>{const t=document.createElement("div");t.addEventListener("touchstart",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchmove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchend",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.addEventListener("mousedown",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mousemove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mouseup",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.className=`bf-measure-nextbutton ${e}`;const i={button:t};let n;Object.defineProperty(i,"position",{set:e=>{if(e){t.style.display="block";let{x:i,y:n}=this.viewer.worldToClient(e);i&&n&&this.setButtonPosition(t,i,n)}else t.style.display="none";n=e},get:()=>n}),h.appendChild(t),l[e]=i})),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,(()=>{if(this.dragButtonVisible&&this.dragButtonPoint){this.dragButton.style.display=this.viewer.isInViewFrustum(this.dragButtonPoint)?"block":"none";let{x:e,y:t}=this.viewer.worldToClient(this.dragButtonPoint);e&&t&&this.setButtonPosition(this.dragButton,e,t)}Object.values(l).forEach((e=>{e.position=e.position?e.position.clone():void 0,e.position&&!this.viewer.isInViewFrustum(e.position)&&(e.button.style.display="none")}))}))}computeMeasureResult(t){let i=this.getPoints();if(0===i.length)return;i[0].point=new THREE.Vector3(...Object.values(this.viewer.globalUnitUtil.revertTranslate(i[0].point,["x","y","z"])));let{point:n}=i[0];this._result.pointInfo=i[0];const o=n.clone().add(t.clone().multiplyScalar(1)),s=(e,t)=>{const i=this.viewer.getComponentsByRaycaster(o,t),n=this.viewer.getComponentsByRaycaster(o,t.clone().negate());return this._result[e]=i.length>0&&n.length>0?{enable:!0,direction:t,positiveIntersects:i,negativeIntersects:n,positiveIndex:0,negativeIndex:0}:{enable:!1},this.nextButtons[`positive_${e}`].position=i.length>1&&n.length>0?i[0].position:void 0,"Z"!==e&&(this.nextButtons[`negative_${e}`].position=n.length>1&&i.length>0?n[0].position:void 0),s};let r,a,l;return Math.abs(1-Math.abs(t.z))<.001?(r=new THREE.Vector3(1,0,0),a=new THREE.Vector3(0,1,0),l=new THREE.Vector3(0,0,1)):(r=t.clone().cross(new THREE.Vector3(0,0,1)),r.x<0&&r.negate(),a=t.clone().cross(r),a.y<0&&a.negate(),l=t),s("X",r)("Y",a)("Z",l),!e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.showDragButton(n),this.getMeasureResult()}getMeasureResult(){let e={},{componentId:t,modelId:i,point:n}=this._result.pointInfo;e.pointSelected={x:n.x,y:n.y,z:n.z},e.componentSelected={componentId:t,modelId:i},e.type=this.measureType;const o=t=>{if(this._result[t].enable){let{direction:i,positiveIntersects:n,negativeIntersects:o,positiveIndex:s,negativeIndex:r}=this._result[t],a=n[s],l=o[r];e[`Laser${t}`]={vector:{x:i.x,y:i.y,z:i.z},distance:a.distance+l.distance,endPoints:[{x:a.position.x,y:a.position.y,z:a.position.z,direction:"positive"},{x:l.position.x,y:l.position.y,z:l.position.z,direction:"negative"}],endComponents:[{componentId:a.id,modelId:a.modelId,direction:"positive"},{componentId:l.id,modelId:l.modelId,direction:"negative"}]}}return o};return o("X")("Y")("Z"),e}getNextResult(t){let[i,n]=t.split("_");if(!this._result[n]||!this._result[n].enable)return;let o=this._result[n][`${i}Intersects`],s=++this._result[n][`${i}Index`];o.length<=s&&(this._result[n][`${i}Index`]=s=0),this.opt.measure.measureByInfo({...this.getMeasureResult(),id:e.Web.Lang.Utility.UUID.createUUID()}),this.nextButtons[t].position=o[s].position}draw(e){this.drawCaptureItem(e)}showDragButton(e){this.reset(),this.viewer.render(),this.dragButtonPoint=e,this.dragButtonVisible=!0;let{x:t,y:i}=this.viewer.worldToClient(e);this.dragButton.style.display="block",t&&i&&this.setButtonPosition(this.dragButton,t,i)}hideDragButton(){this.dragButtonVisible=!1,this.dragButton.style.display="none",Object.values(this.nextButtons).forEach((e=>e.position=void 0))}showNextButton(){this.nextButtonContainer.style.display="block"}hideNextButton(){this.nextButtonContainer.style.display="none"}clearNextButton(){Object.values(this.nextButtons).forEach((e=>e.position=void 0))}setButtonPosition(e,t,i){e.style.top=`${i}px`,e.style.left=`${t}px`}}_n.MeasureLaserClearDistanceItem=Dn;class An{constructor(e,t,i,n){this.viewer=e,this.id=t,this.type=i,this.isShow=!0,this.xmlns="http://www.w3.org/2000/svg",this.defaultColor=n.defaultColor||"#F99D0B",this.svgGroup=[],this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.hitTestEpsilon=10,this.hitTestSegments=[],this.selectElements=[],this.unSelectElements=[],this.elementsOnTop=[],this.isSelected=!0,this.mask=null,this.notation="ViewerGIS"===this.viewer.getViewerType()?new Sn(i):new In(i),this.measureParams={precision:0,scale:1,unit:"None"}}getSvgGroup(){return this.svgGroup}getId(){return this.id}getType(){return this.type}clear(e){this.detach(e),this.notation.clear(e),this.svgGroup=[],this.hitTestSegments=[]}detach(e){for(const e of this.svgGroup){(t=e.parentNode)&&t.removeChild(e)}for(const e of this.elementsOnTop){var t;(t=e.parentNode)&&t.removeChild(e)}}attach(e){for(const t of this.svgGroup)e.appendChild(t)}calcLine(e,t){let i=[];this.viewer.getViewer();var o=this.viewer.getDomElement().getBoundingClientRect(),s=this.viewer.viewerAdapter.worldPointsToClient(e,t);if(s){e=new n(s.start.x-o.left,s.start.y-o.top),t=new n(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i}calcTerminalLines(e,t,i){if(0===e.length)return[];let n=[],o=e[0],s=e[1],r=o.clone().sub(s).normalize(),a=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),t),l=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),-t);n.push({start:a,end:l}),r=r.multiplyScalar(-1);let h=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),t),d=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),-t);return n.push({start:h,end:d}),n}select(){for(const e of this.selectElements)e.style.display="none";for(const e of this.unSelectElements)e.style.display="block";this.notation.select(),this.isSelected=!0}unselect(){for(const e of this.selectElements)e.style.display="block";for(const e of this.unSelectElements)e.style.display="none";this.notation.unselect(),this.isSelected=!1}getIsSelected(){return this.isSelected}actionWhenSelected(){}actionWhenUnselected(){}dropShadow(e){this.notation.dropShadow(e)}ifMaskDraw(e,t,i,n,o,s){if("ViewerDrawing"==this.viewer.viewerType){const r=this.viewer.getViewer().getLayoutViewportBoundingBox(t,i,n),a=this.viewer.getViewer().toScreenPoint(r.min),l=this.viewer.getViewer().toScreenPoint(r.max),h=e[0].start?e[0].start:e[0],d=e[1].end?e[1].end:e[1];if(h.x<a[0]||h.x>l[0]||h.y<l[1]||h.y>a[1]||d.x<a[0]||d.x>l[0]||d.y<l[1]||d.y>a[1])this.drawMask(r,!0);else if(-1==n&&-1!=o){const e=this.viewer.getViewer().getLayoutViewportBoundingBox(t,o,s);this.drawMask(e,!isFinite(e.max[0]))}else this.removeMask()}}drawMask(e,t=!0){const i=this.viewer.getViewer().toScreenPoint(e.min),n=this.viewer.getViewer().toScreenPoint(e.max);let o=this.mask=re.makeRectangle({x:t?0:i[0],y:t?0:n[1],width:t?this.viewer.getDomElement().clientWidth:n[0]-i[0],height:t?this.viewer.getDomElement().clientHeight:i[1]-n[1],radius:0,fillColor:0==this.viewer.getViewer().dc.printMode?"#444444":"#DDDDDD",fillOpacity:.7});this.svgGroup.push(o)}removeMask(){this.mask&&(this.mask.style.display="none"),this.mask=null}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}show(){for(const e of this.svgGroup)e.style.display="block";for(const e of this.elementsOnTop)e.style.display="block";this.isShow=!0}hide(){for(const e of this.svgGroup)e.style.display="none";for(const e of this.elementsOnTop)e.style.display="none";this.isShow=!1}getNotation(){return this.notation}hitTest(e){let t=this.hitTestEpsilon;for(let i=0;i<this.hitTestSegments.length-1;i++){if(re.distanceToSegment(e,this.hitTestSegments[i],this.hitTestSegments[i+1])<=t)return!0}return!1}}class Vn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult=t.distance,this.auxLinesResult=[t.distanceX,t.distanceY,t.distanceZ],this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit,enableAuxiliaryValue:n.enableAuxiliaryValue||!1})}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit,this.measureParams.enableAuxiliaryValue=e.enableAuxiliaryValue}initialize(){let e=this.calcLine(this.worldPositions[0],this.worldPositions[1]);this.hitTestSegments=e;let{auxLines:t,auxLinePoints:i}=this.calAuxLines(),n=this.calcTerminalLines(e,Math.PI/2,6.5);this.attachSingleLine(e),this.attachTerminalLines(n);this.attachAuxLines(t,["#CC021B","#7CCF21","#4A90E2"]),this.attachTerminalPoints([t[0].start,t[2].end]);let o={x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2},s=this.viewer.worldToClient(o);this.viewer.isInViewFrustum(o)&&(this.attachNotation([s,s]),this.measureParams.enableAuxiliaryValue&&this.calAuxLinesNotation(i),this.notation.dropShadow(this.filterUrl),this.unselect())}attachTerminalPoints(e){for(const t of e){let e=re.makeCircle({position:t,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(e),e.setAttribute("filter",this.filterUrl),this.unSelectElements.push(e)}}attachSingleLine(e){if(0===e.length)return;let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachTerminalLines(e){if(0!==e.length)for(let t=0;t<2;t++){let i=re.makeLine({start:e[t].start,end:e[t].end,color:this.defaultColor,lineWidth:2});this.selectElements.push(i),this.svgGroup.push(i)}}attachAuxLines(e,t){let i=0;for(const n of e){let e=re.makeLine({start:n.start,end:n.end,color:this.defaultColor,lineWidth:this.lineWidth});e.setAttribute("stroke-dasharray","6,4"),e.style.stroke=t[i++],this.unSelectElements.push(e),this.svgGroup.push(e)}}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.getMeasureResult(this.measureResult),this.id);for(const e of t)this.svgGroup.push(e)}calAuxLinesNotation(e){if(e&&e.length&&4===e.length){let t,i=["#E22532","#6CC91A","#399DFF"];for(let n=0,o=e.length-1;n<o;n++){let o={x:(e[n].x+e[n+1].x)/2,y:(e[n].y+e[n+1].y)/2,z:(e[n].z+e[n+1].z)/2},s=this.viewer.viewerAdapter.worldToCanvas(o);t=this.notation.drawAnnotation({x:s.x,y:s.y},this.getMeasureResult(this.auxLinesResult[n])+"",this.id,i[n]);for(const e of t)this.svgGroup.push(e),this.notation.notationSelected.push(e)}}}calAuxLines(){let e=this.worldPositions;for(var t=this.viewer.getDomElement().getBoundingClientRect(),i={x:e[1].x,y:e[0].y,z:e[0].z},n={x:e[1].x,y:e[1].y,z:e[0].z},o=[],s=[e[0],i,n,e[1]],r=0;r<s.length-1;r++){var a=this.viewer.viewerAdapter.worldPointsToClient(s[r],s[r+1]);if(a)a.start.x-=t.left,a.start.y-=t.top,a.end.x-=t.left,a.end.y-=t.top;else{a={start:{x:-1,y:-1},end:{x:-1,y:-1}}}o.push(a)}return{auxLines:o,auxLinePoints:s}}getMeasureResult(e){let t=this.measureParams.unit;e=e.toString();let i=Bn.formatDistance(e,this.measureParams);return i+=Bn.getPostFix(t,!1),i.split(",").join("")}}class Rn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureAngle=t.angle,this.setMeasureParams({precision:t.precision})}initialize(){let e=this.getClientPoints();if(!e)return;this.hitTestSegments=e;for(let t=0;t<e.length-1;t++){let i=re.makeLine({start:e[t],end:e[t+1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(i)}for(let t=0;t<e.length;t++){let i=re.makeCircle({position:e[t],radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.unSelectElements.push(i),this.svgGroup.push(i),i.setAttribute("filter",this.filterUrl)}var t=this.getArcData(e[0],e[1],e[2]);if(!t)return void this.unselect();var i=re.makePath({color:this.defaultColor,lineWidth:this.lineWidth,arcRadius:25,info:t});this.svgGroup.push(i);var o=new n((t.pointA.x+t.pointB.x)/2,(t.pointA.y+t.pointB.y)/2),s=new n(e[1].x,e[1].y),r=o.clone().sub(s);if(0==r.x&&0==r.y){var a=0==s.clone().sub(t.pointA).y;a&&0==t.direction?r.y=35:a&&1==t.direction?r.y=-35:a||0!=t.direction?a||1!=t.direction||(r.x=35):r.x=-35}else r.normalize().multiplyScalar(35);o=s.clone().add(r);let l=this.notation.drawAnnotation(o,this.getMeasureResult(),this.id);for(const e of l)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}getClientPoints(){let e=[],t=this.calcLine(this.worldPositions[0],this.worldPositions[1]),i=this.calcLine(this.worldPositions[1],this.worldPositions[2]);return t.length>0&&e.push(t[0],t[1]),i.length>0&&(e.length>0?e.push(i[1]):e.push(i[0],i[1])),e}getArcData(e,t,i){if(!e||!t||!i)return!1;e=new n(e.x,e.y),t=new n(t.x,t.y),i=new n(i.x,i.y);var o,s=e.sub(t),r=i.sub(t);if(s.length()<25||r.length()<25)return!1;s.setLength(25),r.setLength(25);var a=s.angle(),l=180*(r.angle()-a)/Math.PI;return l<0&&(l+=360),o=l<180?1:0,{pointA:t.clone().add(s),pointB:t.clone().add(r),flag:1,direction:o}}getMeasureResult(){this.measureParams.unit;let e=this.measureAngle.toString();return Bn.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}}class On extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.elevationPoint=t.points[0],this.elevation="number"==typeof t.elevation?t.elevation:t.points[0].z,this.initialElevation=t.initialElevation,this.setMeasureParams({precision:t.precision,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(this.viewer.isInViewFrustum&&!this.viewer.isInViewFrustum(this.elevationPoint))return;var e=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);e=this.viewer.worldToClient(e);for(var t=[58,-12,-12,-12,0,0,12,-12],i="",n=0;n<t.length;n+=2)t[n]+=e.x,t[n+1]+=e.y,i+=t[n]+","+t[n+1]+" ";var o=re.makePolyline({color:this.defaultColor,width:2,points:i});this.svgGroup.push(o);var s=new THREE.Vector2(e.x,e.y);let r=this.notation.drawAnnotation(s,this.getMeasureResult(),this.id);for(const e of r)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}getMeasureResult(){let e=this.measureParams.unit,t=this.elevation.toString(),i=Bn.formatDistance(t,this.measureParams);return i+=Bn.getPostFix(e,!1),i=i.split(",").join(""),0==i.split(" ")[0]&&(i=`±${i}`),i}hitTest(e){var t=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);t=this.viewer.getViewer().worldToCanvas(t);let i=new THREE.Vector2(t.x-12,t.y-22),n=new THREE.Vector2(t.x+58,t.y-22);return re.distanceToSegment(e,i,n)<=22||this.notation.hitTest(e)}}class kn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.selectedComponentsId=t.points,this.worldPositions=[t.start,t.end],this.measureResult=t.distance,this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){let e=this.calcLine(this.worldPositions[0],this.worldPositions[1]);this.hitTestSegments=e;let t=this.calcTerminalLines(e,Math.PI/3,8);for(let i=0;i<t.length;i++){let n=[];n.push(t[i].start,e[i],t[i].end);let o=re.makePolyline({color:this.defaultColor,width:2,points:re.calcPolylinePoints(n)});this.svgGroup.push(o)}if(0===e.length)return void this.unselect();let i=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(i);let n={x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2},o=this.viewer.worldToClient(n);if(!this.viewer.isInViewFrustum(n))return;let s=this.notation.drawAnnotation({x:o.x,y:o.y},this.getMeasureResult(),this.id);for(const e of s)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}actionWhenSelected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).addSelectedComponentsById([e.userId])})),this.viewer.render()}actionWhenUnselected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).removeSelectedId([e.userId])})),this.viewer.render()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatDistance(t,this.measureParams);return i+=Bn.getPostFix(e,!1),i.split(",").join("")}}class Hn extends An{constructor(e,i,n,o){super(e,n,i.type,o),this.filterUrl=i.filterUrl,this.worldPositions=i.points,this.measureResult=i.area,this.viewPortId=i.viewPortId,this.drawingIndex=i.drawingIndex,this.drawingIndexes=i.drawingIndexes,this.layoutId=i.layoutId||0,this.isOnBorder=i.isOnBorder,this.boundaryPoints=[],this.scratchVector=new t,this.setMeasureParams({precision:i.precision,scale:i.scale,unit:i.unit})}initialize(e=!1,t,i){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;let s=new o,r=this.worldPositions;var a="";this.boundaryPoints=[],!this.previousNormalPoints&&(this.previousNormalPoints=[]);const l=r.length;for(var h=0;h<=l;h++){if(r[h%r.length].viewId&&!r[h%r.length].isActiveLayoutElement&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;let o=this.drawingIndexes?this.worldToClient(r[h%r.length],this.drawingIndexes[h%r.length]):this.worldToClient(r[h%r.length]);e&&h+1<r.length&&this.ifMaskDraw([o,this.worldToClient(r[(h+1)%r.length])],this.layoutId,this.viewPortId,this.drawingIndex,i,t),this.drawingIndexes&&h<l&&(this.mask||(this.previousNormalPoints[h]=[r[h%r.length],this.drawingIndexes[h%r.length]]),this.mask&&(this.worldPositions[h]=this.previousNormalPoints[h][0],this.drawingIndexes[h]=this.previousNormalPoints[h][1])),h!==r.length&&this.hitTestSegments.push(new n(o.x,o.y));let d=re.makeCircle({position:o,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(d),d.setAttribute("filter",this.filterUrl),this.unSelectElements.push(d),this.boundaryPoints.push(o),s.expandByPoint(new n(o.x,o.y)),a+=o.x+","+o.y+" "}var d=re.makePolyline({color:this.defaultColor,fillColor:this.defaultColor,width:2,points:a});d.setAttribute("fill-opacity",.2),this.svgGroup.insert(0,d);var c=s.getCenter(this.scratchVector);let u=this.notation.drawAnnotation(c,this.getMeasureResult());for(const e of u)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect(),!this.viewer.loadedDrawings&&!this.isShow&&this.hide()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatArea(t,this.measureParams);return i+=Bn.getPostFix(e,!0),i.split(",").join("")}worldToClient(e,t=-1){let i=[],n=this.viewer.getViewer();if(e.isActiveLayoutElement)i=n.toScreenPoint(e.point);else{const o=e.point?e.point:e;i=this.isOnBorder?n.toScreenPoint(o):n.toViewportScreenPoint(o,e.viewPortId,-1==t?-1==this.drawingIndex?0:this.drawingIndex:t)}return{x:i[0],y:i[1]}}setViewId(e){this.viewId=e}getViewId(){return this.viewId}hitTest(e){let t=this.boundaryPoints,i=re.isPointInPolygon(e,t),n=!1;for(let t=0;t<this.hitTestSegments.length;t++)if(Math.abs(this.hitTestSegments[t].x-e.x)<=3&&Math.abs(this.hitTestSegments[t].y-e.y)<=3){n=!0;break}return i||n}}class Un extends Vn{constructor(e,t,i,o){super(e,t,i,o),this.filterUrl=t.filterUrl,this.startPoint=new n(t.start[0],t.start[1]),this.endPoint=new n(t.end[0],t.end[1]),this.viewPortId=t.viewPortId,this.measureResult=t.distance,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId||0,this.isOnBorder=t.isOnBorder,this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit}),this.isOnLayoutMeasure=t.isOnLayout}initialize(e=!1,t,i){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.isOnLayoutMeasure&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;const n=()=>{let e=this.calAuxLines(),t=[];return t.push(e[0].start,e[1].end),this.hitTestSegments=t,{auxLines:e,linePoints:t,terminalLines:this.calcTerminalLines(t,Math.PI/2,6.5)}};let{auxLines:o,linePoints:s,terminalLines:r}=n();if(e&&this.ifMaskDraw(r,this.layoutId,this.viewPortId,this.drawingIndex,i,t),this.mask||(this.previousNormalPoints=[this.startPoint.clone(),this.endPoint.clone()]),this.mask){this.startPoint=this.previousNormalPoints[0],this.endPoint=this.previousNormalPoints[1];const e=n();o=e.auxLines,s=e.linePoints,r=e.terminalLines}this.attachSingleLine(s),this.attachTerminalLines(r);this.attachAuxLines(o,["#7CCF21","#CC021B"]),this.attachTerminalPoints(s),this.attachNotation(s),this.notation.dropShadow(this.filterUrl),this.unselect(),!this.viewer.loadedDrawings&&!this.isShow&&this.hide()}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.getMeasureResult(),this.id);for(const e of t)this.svgGroup.push(e)}calAuxLines(){let e=[],t=this.startPoint.clone(),i=this.endPoint.clone(),o={x:i.x,y:t.y};e.push(t,o,i);let s=[];for(let t=0;t<e.length-1;t++){let i=this.worldToClient(e[t],this.drawingIndexes&&this.drawingIndexes[0]),o=this.worldToClient(e[t+1],0==t?this.drawingIndexes&&this.drawingIndexes[0]:this.drawingIndexes&&this.drawingIndexes[1]);s.push({start:new n(i.x,i.y),end:new n(o.x,o.y)})}return s}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatDistance(t,this.measureParams);return i+=Bn.getPostFix(e,!1),i.split(",").join("")}worldToClient(e,t=-1){if(this.isOnLayoutMeasure){let i=this.isOnBorder?this.viewer.worldToClient(e):this.viewer.getViewer().toViewportScreenPoint([e.x,e.y],this.viewPortId,-1==t?this.drawingIndex:t);return{x:i[0],y:i[1]}}return this.viewer.worldToClient(e)}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class Nn extends Rn{constructor(e,t,i,n){super(e,t,i,n),this.isOnLayoutMeasure=t.isOnLayout,this.viewPortId=t.viewPortId,this.drawingIndex=t.drawingIndex,this.layoutId=t.layoutId||0,this.isOnBorder=t.isOnBorder}getClientPoints(){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;let e=[];for(let t=0;t<this.worldPositions.length;t++){if(this.isOnLayoutMeasure&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))continue;let i=new n(this.worldPositions[t][0],this.worldPositions[t][1]),o=this.worldToClient(i,this.worldPositions[t][2]);e.push(new n(o.x,o.y))}return e}worldToClient(e,t){if(this.isOnLayoutMeasure){let i=this.isOnBorder?this.viewer.worldToClient(e):this.viewer.getViewer().toViewportScreenPoint([e.x,e.y],t,this.drawingIndex);return{x:i[0],y:i[1]}}return this.viewer.worldToClient(e)}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class Gn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){let e=this.worldPositions.length;if(!(e<2)){for(let t=1;t<e;t++){let e=this.calcLine(this.worldPositions[t],this.worldPositions[t-1]);0!==e.length&&(1===t&&this.hitTestSegments.push(e[1]),this.hitTestSegments.push(e[0]),this.attachSelectedTerminalPoints(e[0]),this.attachLines(e),this.attachSelectedTerminalPoints(e[1]),this.attachUnselectedTerminalPoints(e[0]),this.attachUnselectedTerminalPoints(e[1]))}this.attachNotations(),this.unselect()}}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachLines(e){let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotations(){const e=this.worldPositions.length,t=this.getMeasureResult();for(let i=1;i<e;i++){let e={x:(this.worldPositions[i].x+this.worldPositions[i-1].x)/2,y:(this.worldPositions[i].y+this.worldPositions[i-1].y)/2,z:(this.worldPositions[i].z+this.worldPositions[i-1].z)/2},n=this.viewer.worldToClient(e);this.viewer.isInViewFrustum(e)&&this.attachNotation([n,n],t.distance[i-1])}let i={x:this.worldPositions[e-1].x,y:this.worldPositions[e-1].y,z:this.worldPositions[e-1].z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.attachNotation([n,n],`总长度:${t.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)}attachNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this.svgGroup.push(e)}getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=Bn.formatDistance(o,this.measureParams),o+=Bn.getPostFix(e,!1),{distance:n,totalDistance:o}}}class jn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.groundInfos=t.groundInfos,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit}),this.borderColor=n.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=n.width||3}initialize(){let e=this.worldPositions.length;if(!(e<2)){for(let t=1;t<e;t++){let e=this.calcLine(this.worldPositions[t],this.worldPositions[t-1]);0!==e.length&&(1===t&&this.hitTestSegments.push(e[1]),this.hitTestSegments.push(e[0]),this.attachSelectedTerminalPoints(e[0]),this.attachSelectedTerminalPoints(e[1]),this.attachUnselectedTerminalPoints(e[0]),this.attachUnselectedTerminalPoints(e[1]))}this.updateGroundLine(this.worldPositions),this.attachNotations(),this.unselect()}}updateGroundLine(e){this.groundLine?this.groundLine.geometry.updateGeometry({points:e}):(this.groundLine=CLOUD.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundLine.onAdded())}clearGroundLine(){this.groundLine&&(this.groundLine.onRemoved(),this.groundLine.dispose(),this.groundLine=null)}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachLines(e){}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotations(){const e=this.worldPositions.length,t=this.getMeasureResult();for(let i=0;i<e-1;i++){let e={x:(this.worldPositions[i].x+this.worldPositions[i+1].x)/2,y:(this.worldPositions[i].y+this.worldPositions[i+1].y)/2,z:(this.worldPositions[i].z+this.worldPositions[i+1].z)/2},n=this.viewer.worldToClient(e);this.viewer.isInViewFrustum(e)&&this.attachNotation([n,n],t.distance[i])}let i={x:this.worldPositions[e-1].x,y:this.worldPositions[e-1].y,z:this.worldPositions[e-1].z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.attachNotation([n,n],`总长度:${t.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)}attachNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this.svgGroup.push(e)}detach(e){super.detach(),e&&this.clearGroundLine()}getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=Bn.formatDistance(o,this.measureParams),o+=Bn.getPostFix(e,!1),{distance:n,totalDistance:o}}}class zn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.positionPoint=t.points[0],this.measureResult={alt:t.altitude,lonLat:t.lonLat},this.innerRadius=3,this.innerStrokeWidth=2,this.outerRadius=7,this.outerStrokeWidth=1,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(!this.viewer.isInViewFrustum(this.positionPoint))return;var e=new THREE.Vector3(this.positionPoint.x,this.positionPoint.y,this.positionPoint.z);e=this.viewer.worldToClient(e),this.attachSelectedCircle(e),this.attachUnselectedCircle(e);var t=new THREE.Vector2(e.x,e.y);let i=this.notation.drawAnnotation(t,this.getMeasureResult(),this.id);for(const e of i)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}attachSelectedCircle(e){let t=re.makeConcentricCircle({innerRadius:this.innerRadius,innerStrokeWidth:this.innerStrokeWidth,outerRadius:this.outerRadius,color:this.defaultColor,position:e});this.selectElements.push(t),this.svgGroup.push(t)}attachUnselectedCircle(e){let t=re.makeConcentricCircle({innerRadius:this.innerRadius,innerStrokeWidth:this.innerStrokeWidth,outerRadius:this.outerRadius,outerStrokeWidth:this.outerStrokeWidth,color:this.defaultColor,position:e});this.unSelectElements.push(t),this.svgGroup.push(t)}hitTest(e){var t=new THREE.Vector3(this.positionPoint.x,this.positionPoint.y,this.positionPoint.z);t=this.viewer.worldToClient(t);let i=new THREE.Vector2(t.x-12,t.y-22),n=new THREE.Vector2(t.x+58,t.y-22);return re.distanceToSegment(e,i,n)<=22||this.notation.hitTest(e)}getMeasureResult(){let e=this.measureParams.unit,{alt:t,lonLat:i}=this.measureResult,{elevation:n,latLon:o}=this.measureParams.precision,s={defaultUnit:this.measureParams.defaultUnit,precision:n,scale:this.measureParams.scale,unit:this.measureParams.unit},r=Bn.formatPrecision(i.latitude.toString(),o),a=Bn.formatPrecision(i.longitude.toString(),o),l=Bn.formatDistance(t.toString(),s);return l+=Bn.getPostFix(e,!1),`经度:${a} ° \n纬度:${r} ° \n高程:${l}`}}class Fn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,horizontalDistance:t.horizontalDistance,verticalDistance:t.verticalDistance},this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(this.worldPositions.length<2)return;let e=this.getMeasureResult();if(this.attachSegmentByTerminalPoints(this.worldPositions,e.distance),this.worldPositions[0].z!=this.worldPositions[1].z){let t=this.worldPositions[0].z<this.worldPositions[1].z?this.worldPositions[0]:this.worldPositions[1],i=this.worldPositions[0].z<this.worldPositions[1].z?this.worldPositions[1]:this.worldPositions[0],n=this.calcTrianglePoint(this.worldPositions);this.attachSegmentByTerminalPoints([t,n],e.verticalDistance),this.attachSegmentByTerminalPoints([i,n],e.horizontalDistance)}else this.attachSegmentByTerminalPoints([this.worldPositions[0],this.worldPositions[0]],e.horizontalDistance);this.notation.dropShadow(this.filterUrl),this.unselect()}calcTrianglePoint(e){if(e.length<2)return null;let t=new THREE.Vector3;return e[0].z<e[1].z?t.set(e[0].x,e[0].y,e[1].z):e[0].z>e[1].z&&t.set(e[1].x,e[1].y,e[0].z),t}attachSegmentByTerminalPoints(e,t){let i=e[0],n=e[1],o=this.calcLine(i,n);this.hitTestSegments=this.hitTestSegments.concat(o),this.attachLine(o),this.attachSelectedTerminalPoints(o),this.attachUnselectedTerminalPoints(o);let s={x:(i.x+n.x)/2,y:(i.y+n.y)/2,z:(i.z+n.z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.attachNotation([r,r],t)}attachSelectedTerminalPoints(e){for(const t of e){let e=re.makeCircle({position:t,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(e),e.setAttribute("filter",this.filterUrl),this.selectElements.push(e)}}attachLine(e){if(0===e.length)return;let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){for(const t of e){let e=re.makeCircle({position:t,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(e),e.setAttribute("filter",this.filterUrl),this.unSelectElements.push(e)}}attachNotation(e,t){if(0===e.length)return;let i=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id);for(const e of i)this.svgGroup.push(e)}getMeasureResult(){const e=this.measureParams.unit;let{distance:t,horizontalDistance:i,verticalDistance:n}=this.measureResult;return t=t.toString(),t=Bn.formatDistance(t,this.measureParams),t+=Bn.getPostFix(e,!1),i=i.toString(),i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n=n.toString(),n=Bn.formatDistance(n,this.measureParams),n+=Bn.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}}class Wn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.fillColor=new Glodon.Web.Graphics.Color(255,157,11,.2),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult=t.area,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){const e=this.worldPositions,t=e.length;if(!(t<3)&&this.areaFrontOfCamera(e)){this.attachArea(e);for(let i=0;i<t;i++){let n=this.viewer.worldToClient(e[i]);n=new THREE.Vector2(n.x,n.y),this.hitTestSegments.push(n),this.attachSelectedTerminalPoints(n),this.attachUnselectedTerminalPoints(n),i==t-1&&this.attachNotation(n,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}this.unselect()}}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachArea(e){let t="";e.forEach((e=>{let i=this.viewer.worldToClient(e);t+=i.x+","+i.y+" "}));let i=re.makePolygon({points:t,width:this.lineWidth,color:this.defaultColor,fillColor:this.fillColor.getRGBA()});this.svgGroup.push(i)}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotation(e,t){let i=this.notation.drawAnnotation({x:e.x,y:e.y},t,this.id,!0);for(const e of i)this.svgGroup.push(e)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_spatial_area}areaFrontOfCamera(e){let t=this.viewer,i=t.getViewer(),n=new THREE.Vector3,o=new THREE.Plane(t.sceneToWorld(i.camera.getWorldDirection(n)).normalize());o.constant=-o.distanceToPoint(t.sceneToWorld(i.camera.position));for(let t=0;t<e.length;t++)if(o.distanceToPoint(e[t])<0)return!1;return!0}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=Bn.formatArea(t,this.measureParams),t+=Bn.getPostFix(e,!0),t}}class $n extends Wn{constructor(e,t,i,n){super(e,t,i,n)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class Xn{constructor(t){t&&(this._opt=t,this.measurePoints=t.points||[],this.fillColor=t.fillColor||new e.Web.Graphics.Color(255,157,11,.2),this.borderColor=t.color||new e.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3,this.update())}setMeasurePoints(e){"[object Array]"===Object.prototype.toString.call(e)?(this.measurePoints=e,this.update()):console.warn("Parameter points is invalid.")}update(){if(this.measurePoints.length<2)this.disposeGroundBorder(),this.disposeGroundSurface();else if(2===this.measurePoints.length)this.disposeGroundSurface(),this.updateGroundBorder(this.measurePoints);else if(this.measurePoints.length>2){this.updateGroundSurface(this.measurePoints);let e=[...this.measurePoints];e.push(this.measurePoints[0]),this.updateGroundBorder(e)}}updateGroundBorder(e){this.groundBorder?this.groundBorder.geometry.updateGeometry({points:e}):(this.groundBorder=CLOUD.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundBorder.onAdded())}updateGroundSurface(e){this.groundSurface?this.groundSurface.geometry.updateGeometry({points:e}):(this.groundSurface=CLOUD.GroundPrimitiveManager.getInstance().createGroundPolygon({points:e,color:this.fillColor}),this.groundSurface.onAdded())}updateTerminalPoints(e){this.selectedGroup||(this.selectedGroup=new THREE.Group,this.add(this.selectedGroup));let t=this.selectedGroup.children;for(let e=t.length-1;e>=0;e--)this.selectedGroup.remove(t[e]);let i=new THREE.CircleGeometry(200,180),n=new THREE.MeshBasicMaterial({color:this.borderColor,side:THREE.DoubleSide,depthTest:!1}),o=new THREE.Mesh(i,n);for(let t=0,i=e.length;t<i;t++){let i=o.clone();i.position.copy(e[t]),this.selectedGroup.add(i)}this.updateMatrixWorld()}hide(){this.hideGroundSurface(),this.hideGroundBorder()}hideGroundSurface(){this.groundSurface&&(this.groundSurface.visible=!1)}hideGroundBorder(){this.groundBorder&&(this.groundBorder.visible=!1)}show(){this.showGroundSurface(),this.showGroundBorder()}showGroundSurface(){this.groundSurface&&(this.groundSurface.visible=!0)}showGroundBorder(){this.groundBorder&&(this.groundBorder.visible=!0)}disposeGroundSurface(){this.groundSurface&&(this.groundSurface.onRemoved(),this.groundSurface.dispose(),this.groundSurface=null)}disposeGroundBorder(){this.groundBorder&&(this.groundBorder.onRemoved(),this.groundBorder.dispose(),this.groundBorder=null)}dispose(){this.measurePoints=null,this.disposeGroundSurface(),this.disposeGroundBorder()}}class Yn extends Wn{constructor(e,t,i,n){super(e,t,i,n),this.measureSurfaceMesh=null,this.layerType=t.layerType}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new Xn({fillColor:new Glodon.Web.Graphics.Color(255,157,11,.2),color:new Glodon.Web.Graphics.Color(255,157,11,1),width:this.lineWidth})),super.initialize()}attachArea(e){this.measureSurfaceMesh.setMeasurePoints(e),this.viewer.render()}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_surface_area}clear(e){super.clear(),this.measureSurfaceMesh&&e&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)}}class Zn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.lineWidth=1,this.data=t,this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){const e={X:"#CC021B",Y:"#7CCF21",Z:"#4A90E2"};let t=[];const i=n=>{const o=this.data[`Laser${n}`];if(o){const s=e[n],[r,a]=o.endPoints,l=new THREE.Vector3(r.x,r.y,r.z),h=new THREE.Vector3(a.x,a.y,a.z),d=o.distance;let c=this.calcLine(l,h);if(2!==c.length)return i;let u=re.makeLine({start:c[0],end:c[1],color:s,lineWidth:this.lineWidth});this.svgGroup.push(u);let g=this.calcTerminalLines(c,5*Math.PI/6,8);for(let e=0;e<g.length;e++){let t=[];t.push(g[e].start,c[e],g[e].end);let i=re.makePolyline({color:s,width:this.lineWidth,points:re.calcPolylinePoints(t)});this.svgGroup.push(i)}let p={x:(l.x+h.x)/2,y:(l.y+h.y)/2,z:(l.z+h.z)/2},m=this.viewer.worldToClient(p);if(!this.viewer.isInViewFrustum(p)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),n=i=>i.x>0&&i.y>0&&i.x<t&&i.y<e;let o=new THREE.Vector3(this.data.pointSelected.x,this.data.pointSelected.y,this.data.pointSelected.z);if(!this.viewer.isInViewFrustum(o))return i;let s=this.viewer.worldToClient(o),r=new THREE.Vector3(s.x,s.y,s.z),a=new THREE.Vector3(m.x,m.y,m.z);const l=100;if(m=r.clone().add(a.clone().sub(r).normalize().multiplyScalar(l)),n(m)||(m=r.clone().add(a.clone().sub(r).normalize().multiplyScalar(-l))),!n(m))return i}let f=this.notation.drawAnnotation({x:m.x,y:m.y},this.getMeasureResult(d),this.id,s);t.push(f)}return i};i("X")("Y")("Z"),t.flat().forEach((e=>this.svgGroup.push(e))),this.unselect()}getMeasureResult(e){let t=this.measureParams.unit,i=e.toString(),n=Bn.formatDistance(i,this.measureParams);return n+=Bn.getPostFix(t,!1),n.split(",").join("")}select(){super.select()}unselect(){super.unselect()}}class qn extends An{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.selectedComponentsId=t.points,this.worldPosition=this.viewer.sceneToWorld(t.volumePosition),this.measureResult=t.volumeResult,this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(!this.measureResult)return;let e=this.viewer.worldToClient(this.worldPosition),t=this.notation.drawAnnotation({x:e.x,y:e.y},this.getMeasureResult(),this.id);for(const e of t)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}actionWhenSelected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).addSelectedComponentsById([e.userId])})),this.viewer.render()}actionWhenUnselected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).removeSelectedId([e.userId])})),this.viewer.render()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatCubic(t,this.measureParams);return i=i+Bn.getPostFix(e,!1)+"³",i.split(",").join("")}}class Kn extends An{constructor(e,t,i,o){super(e,i,t.type,o),this.filterUrl=t.filterUrl,this.isOnLayoutMeasure=t.isOnLayout,this.viewPortId=t.viewPortId,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId||0,this.isOnBorder=t.isOnBorder,this.worldPositions=t.points?t.points:[];for(let e=0;e<this.worldPositions.length;e++)this.worldPositions[e]=new n(this.worldPositions[e][0],this.worldPositions[e][1]);this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(e=!1,t,i){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.isOnLayoutMeasure&&!this.isOnBorder&&this.viewer.isDrawingIndexNotExist(this.drawingIndex))return;let o=this.worldPositions.length;if(!(o<2)){this.previousNormalPoints||(this.previousNormalPoints=[]);for(let s=1;s<o;s++){let o=[this.worldToClient(this.worldPositions[s],this.drawingIndexes[s]),this.worldToClient(this.worldPositions[s-1],this.drawingIndexes[s-1])];0!==o.length&&(e&&this.ifMaskDraw(o,this.layoutId,this.viewPortId,this.drawingIndex,i,t),this.mask||(this.previousNormalPoints[s]=[this.worldPositions[s],this.drawingIndexes[s]],1==s&&(this.previousNormalPoints[0]=[this.worldPositions[0],this.drawingIndexes[0]])),this.mask&&(1==s&&(this.worldPositions[0]=this.previousNormalPoints[0][0],this.drawingIndexes[0]=this.previousNormalPoints[0][1]),this.worldPositions[s]=this.previousNormalPoints[s][0],this.drawingIndexes[s]=this.previousNormalPoints[s][1],o=[this.worldToClient(this.worldPositions[s],this.drawingIndexes[s]),this.worldToClient(this.worldPositions[s-1],this.drawingIndexes[s-1])]),1===s&&this.hitTestSegments.push(new n(o[1].x,o[1].y)),this.hitTestSegments.push(new n(o[0].x,o[0].y)),this.attachSelectedTerminalPoints(o[0]),this.attachLines(o),this.attachSelectedTerminalPoints(o[1]),this.attachUnselectedTerminalPoints(o[0]),this.attachUnselectedTerminalPoints(o[1]))}this.attachNotations(),this.unselect()}}worldToClient(e,t=-1){if(this.isOnLayoutMeasure){let i=this.isOnBorder?this.viewer.worldToClient(e):this.viewer.getViewer().toViewportScreenPoint([e.x,e.y],this.viewPortId,-1==t?this.drawingIndex:t);return{x:i[0],y:i[1]}}return this.viewer.worldToClient(e)}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachLines(e){let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotations(){const e=this.worldPositions.length,t=this.getMeasureResult();for(let i=1;i<e;i++){let e={x:(this.worldPositions[i].x+this.worldPositions[i-1].x)/2,y:(this.worldPositions[i].y+this.worldPositions[i-1].y)/2},n=this.worldToClient(e);this.attachNotation([n,n],t.distance[i-1])}let i={x:this.worldPositions[e-1].x,y:this.worldPositions[e-1].y},n=this.worldToClient(i);n.x+=10+re.measureText(`${BimfaceLanguage.bf_panel_measure_total_distance}:${t.totalDistance}`)/2,n.y-=15,this.attachNotation([n,n],`${BimfaceLanguage.bf_panel_measure_total_distance}:${t.totalDistance}`),this.notation.dropShadow(this.filterUrl)}attachNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this.svgGroup.push(e)}getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=Bn.formatDistance(o,this.measureParams),o+=Bn.getPostFix(e,!1),{distance:n,totalDistance:o}}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class Qn{constructor(e){this.viewer=e}make(e,t,i,n){let o=null,s="ViewerDrawing"===this.viewer.getViewerType(),r={defaultColor:`#${n._opt.color.getHEX()}`,enableAuxiliaryValue:n._opt.enableAuxiliaryValue};switch(e){case"Distance":o=s?new Un(this.viewer,t,i,r):new Vn(this.viewer,t,i,r);break;case"Angle":o=s?new Nn(this.viewer,t,i,r):new Rn(this.viewer,t,i,r);break;case"MinimumDistance":o=new kn(this.viewer,t,i,r);break;case"Elevation":o=new On(this.viewer,t,i,r);break;case"Area":o=new Hn(this.viewer,t,i,r);break;case"GroundlineDistance":o=new jn(this.viewer,t,i,r);break;case"PolylineDistance":o=s?new Kn(this.viewer,t,i,r):new Gn(this.viewer,t,i,r);break;case"Position":o=new zn(this.viewer,t,i,r);break;case"TriangleDistance":o=new Fn(this.viewer,t,i,r);break;case"SpatialArea":o=new Wn(this.viewer,t,i,r);break;case"ProjectedArea":o=new $n(this.viewer,t,i,r);break;case"SurfaceArea":o=new Yn(this.viewer,t,i,r);break;case"LaserClearDistance":o=new Zn(this.viewer,t,i,r),o.measure=n;break;case"Volume":o=new qn(this.viewer,t,i,r)}return o.initialize(),o}}class Jn extends Vn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e,this.distanceX=Math.abs(this.worldPositions[1].x-this.worldPositions[0].x),this.distanceY=Math.abs(this.worldPositions[1].y-this.worldPositions[0].y),this.distanceZ=Math.abs(this.worldPositions[1].z-this.worldPositions[0].z),this.measureResult=Math.sqrt(Math.pow(this.distanceX,2)+Math.pow(this.distanceY,2)+Math.pow(this.distanceZ,2))}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult,distanceX:this.distanceX,distanceY:this.distanceY,distanceZ:this.distanceZ,points:this.worldPositions,type:this.type}}}class eo extends Rn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureAngle=t.measureAngle,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e;var t=new THREE.Vector3(this.worldPositions[0].x-this.worldPositions[1].x,this.worldPositions[0].y-this.worldPositions[1].y,this.worldPositions[0].z-this.worldPositions[1].z),i=new THREE.Vector3(this.worldPositions[2].x-this.worldPositions[1].x,this.worldPositions[2].y-this.worldPositions[1].y,this.worldPositions[2].z-this.worldPositions[1].z),n=t.angleTo(i);this.measureAngle=180*n/Math.PI}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),angle:this.measureAngle,points:this.worldPositions,type:this.type}}}class to extends Un{constructor(e,t){t.start=t.startPoint,t.end=t.endPoint,super(e,t,t.id,{defaultColor:t.defaultColor}),this.startPoint=new n(t.worldPositions[0][0],t.worldPositions[0][1]),this.endPoint=new n(t.worldPositions[1][0],t.worldPositions[1][1]),this.viewPortId=t.viewPortId,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.isOnLayoutMeasure=t.isOnLayoutMeasure,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewPortId&&t!=this.viewPortId)return;0===this.updateIndex?this.startPoint=new n(e[0],e[1]):this.endPoint=new n(e[0],e[1]);let i=this.endPoint.x-this.startPoint.x,o=this.endPoint.y-this.startPoint.y;this.measureResult=Math.sqrt(i*i+o*o)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),start:[this.startPoint.x,this.startPoint.y],end:[this.endPoint.x,this.endPoint.y],points:[[this.startPoint.x,this.startPoint.y],[this.endPoint.x,this.endPoint.y]],viewPortId:this.viewPortId,distance:this.measureResult,isOnLayout:this.isOnLayoutMeasure,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}}class io extends eo{constructor(e,t){super(e,t),this.isOnLayoutMeasure=t.isOnLayoutMeasure,this.viewPortId=t.viewPortId,this.drawingIndex=t.drawingIndex,this.layoutId=t.layoutId,this.drawingIndex=t.drawingIndex,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewer.loadedDrawings.length>0&&!Number.isNaN(this.layoutId)&&this.viewer.getCurrentViewId(!0)!=this.layoutId)return;if(this.viewPortId&&t!=this.viewPortId)return;this.worldPositions[this.updateIndex]=e;let i=this.getClientPoints();this.measureAngle=this.angleByArr([i[0].x,i[0].y],[i[1].x,i[1].y],[i[2].x,i[2].y])}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),angle:this.measureAngle,points:this.worldPositions,isOnLayout:this.isOnLayoutMeasure,viewPortId:this.viewPortId,drawingIndex:this.drawingIndex,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}angleByArr(e,t,i){let n=Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)),o=Math.sqrt(Math.pow(t[0]-i[0],2)+Math.pow(t[1]-i[1],2)),s=Math.sqrt(Math.pow(e[0]-i[0],2)+Math.pow(e[1]-i[1],2)),r=(Math.pow(n,2)+Math.pow(o,2)-Math.pow(s,2))/(2*n*o);return r=r.toFixed(12),180*Math.acos(r)/Math.PI}getClientPoints(){let e=[];for(let t=0;t<this.worldPositions.length;t++){let i=new n(this.worldPositions[t][0],this.worldPositions[t][1]),o=this.worldToClient(i,this.worldPositions[t][2]);e.push(new n(o.x,o.y))}return e}worldToClient(e,t){if(this.isOnLayoutMeasure){let i=this.viewer.getViewer().toViewportScreenPoint([e.x,e.y],t,this.drawingIndex);return{x:i[0],y:i[1]}}return this.viewer.worldToClient(e)}setViewId(e){this.viewId=e}getViewId(){return this.viewId}}class no extends Hn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.viewPortId=t.viewPortId,this.updateIndex=t.updateIndex,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewPortId&&t!=this.viewPortId)return;this.worldPositions[this.updateIndex]={point:[e[0],e[1]],viewPortId:t,isActiveLayoutElement:-1===t};let i=[];for(var n=0;n<this.worldPositions.length;n++)i.push(this.worldPositions[n].point);this.measureResult=this.getArea(i)}getArea(e){var t=e.length;if(t<3)return 0;for(var i=e[0][1]*(e[t-1][0]-e[1][0]),n=1;n<t;++n)i+=e[n][1]*(e[n-1][0]-e[(n+1)%t][0]);return Math.abs(i/2)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,viewPortId:this.viewPortId,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}}class oo extends Kn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.isOnLayoutMeasure=t.isOnLayoutMeasure,this.viewPortId=t.viewPortId,this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.drawingIndex=t.drawingIndex,this.drawingIndexes=t.drawingIndexes,this.layoutId=t.layoutId,this.isOnBorder=t.isOnBorder}calculate(e,t){if(this.viewPortId&&t!=this.viewPortId)return;this.worldPositions[this.updateIndex]=new n(e[0],e[1]);let i=[],o=0;for(let e=1;e<this.worldPositions.length;e++){let t=this.worldPositions[e].x-this.worldPositions[e-1].x,n=this.worldPositions[e].y-this.worldPositions[e-1].y,s=Math.sqrt(t*t+n*n);i.push(s),o+=s}this.measureResult={distance:i,totalDistance:o}}getInfo(){let e=[];for(let t=0;t<this.worldPositions.length;t++)e.push([this.worldPositions[t].x,this.worldPositions[t].y]);return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,isOnLayout:this.isOnLayoutMeasure,viewPortId:this.viewPortId,points:e,drawingIndex:this.drawingIndex,drawingIndexes:this.drawingIndexes,layoutId:this.layoutId,isOnBorder:this.isOnBorder,type:this.type}}}class so extends Gn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e;let t=this.worldPositions.length,i=[],n=0;for(let e=1;e<t;e++){let t=this.worldPositions[e].distanceTo(this.worldPositions[e-1]);i.push(t),n+=t}this.measureResult={distance:i,totalDistance:n}}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,points:this.worldPositions,type:this.type}}}class ro extends Fn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult.distance=this.worldPositions[0].distanceTo(this.worldPositions[1]);let t=this.worldPositions[0].clone(),i=0,n=0;this.worldPositions[0].z<this.worldPositions[1].z?(t.set(this.worldPositions[0].x,this.worldPositions[0].y,this.worldPositions[1].z),i=t.distanceTo(this.worldPositions[1]),n=t.distanceTo(this.worldPositions[0])):this.worldPositions[0].z>this.worldPositions[1].z&&(t.set(this.worldPositions[1].x,this.worldPositions[1].y,this.worldPositions[0].z),i=t.distanceTo(this.worldPositions[0]),n=t.distanceTo(this.worldPositions[1])),this.measureResult.horizontalDistance=i,this.measureResult.verticalDistance=n}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,horizontalDistance:this.measureResult.horizontalDistance,verticalDistance:this.measureResult.verticalDistance,points:this.worldPositions,type:this.type}}}class ao extends Wn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.selectElements=[],this.unSelectElements=[]}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=re.calcSpatialArea(this.worldPositions)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type}}}class lo extends ao{constructor(e,t){super(e,t)}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=re.calcProjectedArea(this.worldPositions)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class ho extends ao{constructor(e,t){super(e,t),this.measureSurfaceMesh=null,this.layerType=t.layerType}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=re.calcSurfaceArea(this.worldPositions,this.viewer,this.layerType)}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new Xn({fillColor:new Glodon.Web.Graphics.Color(255,157,11,.2),color:new Glodon.Web.Graphics.Color(255,157,11,1),width:this.lineWidth})),super.initialize()}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type,layerType:this.layerType}}attachArea(e){this.measureSurfaceMesh.setMeasurePoints(e),this.viewer.render()}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_surface_area}clear(){super.clear(),this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)}}class co extends jn{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.groundInfos=t.groundInfos,this.isFirst=!0,this.lastGroundLineMes={},this.borderColor=t.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3}init(){this.updateGroundLine(this.worldPositions)}debounce(e,t=300){let i=null;return function(...n){i&&(clearTimeout(i),i=null),i=setTimeout((()=>{e(...n)}),t)}}calculate(e){this.isFirst&&(this.init(),this.isFirst=!1),this.worldPositions[this.updateIndex]=e;let t=()=>{this.isEnd||this.handle()};this.debounceFun||(this.debounceFun=this.debounce(t)),this.debounceFun(),this.updateGroundLine(this.worldPositions)}handle(){this.groundInfos.length!==this.measureResult.distance.length&&this.groundInfos.pop(),this.updateIndex>0&&(this.groundInfos[this.updateIndex-1]=this.calculateGroundlineDistance(this.worldPositions[this.updateIndex-1],this.worldPositions[this.updateIndex])),this.updateIndex<this.worldPositions.length-1&&(this.groundInfos[this.updateIndex]=this.calculateGroundlineDistance(this.worldPositions[this.updateIndex],this.worldPositions[this.updateIndex+1]));let e=[],t=0;for(let i=0;i<this.groundInfos.length;i++){let n=this.groundInfos[i];e.push(n.length),t+=n.length}this.measureResult.distance=e,this.measureResult.totalDistance=t}end(){this.handle(),this.isEnd=!0}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,points:this.worldPositions,groundInfos:this.groundInfos,type:this.type}}clear(){super.clear(),this.clearGroundLine()}calculateGroundlineDistance(e,t){if(!e||!t)return null;let i=this.viewer,n=new THREE.Vector3(e.x,e.y,e.z),o=new THREE.Vector3(t.x,t.y,t.z);if(n.equals(o))return null;if(this.lastPoint0&&this.lastPoint1&&n.equals(this.lastPoint0)&&o.equals(this.lastPoint1))return this.lastGroundInfo;let s,r=[];r.push(n),r.push(o),s=new THREE.CatmullRomCurve3(r),s.tension=0,s.type="catmullrom";var a=new CLOUD.Raycaster,l=new THREE.Vector3,h=i.getViewer().cameraControl.getIntersectContext(null),d=new CLOUD.IntersectHelper(i.getViewer());a.camera=h.camera,a.viewportSize=h.viewportSize;var c=[];s.getPoints(100).forEach((e=>{l.copy(e),(l=i.worldToScene(e)).y=1e4,a.set(l,new THREE.Vector3(0,-1,0));let t=d.getObjectsByRaycaster(h,a,!0);if(t.length>0){let e;e=i.sceneToWorld(t[0].point),c.push(e)}else c.push(e)})),s=null;let u=new Glodon.Bimface.Plugins.Geometry.SplineCurve(c);return u.projectToGround(!0),this.lastPoint0=n,this.lastPoint1=o,this.lastGroundInfo={length:u.length,midPoint:u.getPointByParameter(.5),endPoint:u.getPointByParameter(1),status:"finished"},this.lastGroundInfo}}class uo{constructor(e,t,i){this.domContainer=e,this.viewer=t,this.measure=i,this.drawable=null,this.isDrawed=!1,this.lastMeasureType="",this.currentMeasureType=""}createDrawable(e){this.lastMeasureType=this.measure.type,this.currentMeasureType=e.type;let t="ViewerDrawing"===this.viewer.getViewerType();switch(e.type){case"Distance":this.drawable=t?new to(this.viewer,e):new Jn(this.viewer,e);break;case"Angle":this.drawable=t?new io(this.viewer,e):new eo(this.viewer,e);break;case"PolylineDistance":this.drawable=t?new oo(this.viewer,e):new so(this.viewer,e);break;case"Area":this.drawable=new no(this.viewer,e);break;case"TriangleDistance":this.drawable=new ro(this.viewer,e);break;case"SpatialArea":this.drawable=new ao(this.viewer,e);break;case"ProjectedArea":this.drawable=new lo(this.viewer,e);break;case"SurfaceArea":this.drawable=new ho(this.viewer,e);break;case"GroundlineDistance":this.drawable=new co(this.viewer,e);break;default:this.drawable=null}}draw(e,t){if(!this.drawable)return;this.isDrawed||this.measure.setMeasureType(this.currentMeasureType),this.isDrawed=!0;let i="ViewerDrawing"===this.viewer.getViewerType(),n={x:i&&!this.viewer.isFullScreen?e.clientX-t.left:e.clientX,y:i&&!this.viewer.isFullScreen?e.clientY-t.top:e.clientY},o={};if(i){var s=[],r=this.viewer._drawingViewer.snapToPoint(n.x,n.y),a=r.GetViewPortId&&r.GetViewPortId();if(r.GetPoint().length>0&&(s=[r.GetPoint()[0],r.GetPoint()[1],a]),!r.GetID()){let e=this.viewer._drawingViewer.toScreenPoint(r.GetPoint()),t=this.viewer._drawingViewer.toModelWorld(e);s=t,a=t[2]}o=s,this.drawable.calculate(o,a)}else{let e=this.viewer.getViewer().pickToPoint(n,5);e&&e.pickPoint&&(o=this.viewer.sceneToWorld(e.pickPoint),this.drawable.calculate(o))}let l=this.drawable.getInfo();this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,l),this.drawable.clear(),this.drawable.initialize(!0,i&&r&&r.GetDrawingIndex(),i&&r&&r.GetViewPortId()),this.drawable.select(),this.drawable.attach(this.domContainer)}end(){if(!this.drawable||!this.isDrawed)return;this.drawable.end&&this.drawable.end();let e=this.drawable.getInfo();this.measure.drawableManager.addItem(e),this.drawable.clear(),this.drawable=null,this.isDrawed=!1,this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdated,e)}update(){this.drawable&&this.isDrawed&&(this.drawable.clear(),this.drawable.initialize(),this.drawable.select(),this.drawable.attach(this.domContainer))}}class go{constructor(t,i,n){this.domContainer=t,this.measureItems=i,this.manage=n,this.measureUpdateManage=new uo(t,n.viewer,n.measure),this.selectedItem=null,this.selectionChanged=null,this.hoverChanged=null,this.isEnableSelection=!0,this.mousedownHitItem=null,this.offset=t.getBoundingClientRect(),e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hookEvents()}hookEvents(){this.domContainer.addEventListener("mousemove",(e=>{if(this.manage.measure.isSelectItem=!1,!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);if(this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),!this.isMoveed&&this.mouseDownPoint&&(Math.abs(this.mouseDownPoint.x-e.clientX)>=1||Math.abs(this.mouseDownPoint.y-e.clientY)>=1)&&(this.isMoveed=!0),this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type){let t={x:e.clientX,y:e.clientY},i=this.manage.viewer.getViewer().pickToPoint(t,5);if(i&&i.pickPoint){let e=this.manage.viewer.sceneToWorld(i.pickPoint);this.mouseDownHelperHitItem.update(e)}return void(this.isMouseDownHelperHitItemMove=!0)}if(!this.isMouseDownMove&&this.mousedownPoint&&Math.abs(this.mousedownPoint.x-t.x)>=1&&Math.abs(this.mousedownPoint.y-t.y)>=1&&(this.isMouseDownMove=!0,this.mousedownPoint=null),this.isMouseDownMove&&(this.selectPointItemId&&(this.manage.removeItemById(this.selectPointItemId),this.selectPointItemId=null),this.measureUpdateManage.draw(e,this.offset)),this.isMouseDown)return;let i=this.hitTest(t);if("Viewer3D"===this.manage.viewer.viewerType){i=this.manage.measure.measureHelper.hitTest(new n(e.clientX,e.clientY),new n(t.x,t.y))||i}this.hoverChanged(i),i?(this.domContainer.style.cursor="default",e.preventDefault(),e.stopPropagation()):this.domContainer.style.cursor=""}),!1),this.domContainer.addEventListener("mousedown",(e=>{if(this.mousedownHitItem=null,this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!0,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint={x:e.clientX,y:e.clientY},!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);if(this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),"Viewer3D"===this.manage.viewer.viewerType){let i=this.manage.measure.measureHelper.hitTestPoint(new n(e.clientX,e.clientY),new n(t.x,t.y));i&&(this.mouseDownHelperHitItem=i);let o=this.manage.measure.measureHelper.hitTest(new n(e.clientX,e.clientY),new n(t.x,t.y));if(o)return this.manage.measure.isSelectItem=!0,o.getIsSelected()?(this.selectionChanged(null),this.setSelectedItem(null),o.unselect()):(this.selectionChanged(o),this.setSelectedItem(o),o.select()),e.preventDefault(),void e.stopPropagation()}let i=this.hitTest(t);if(this.mousedownHitItem=i,i){this.manage.measure.isSelectItem=!0;for(let e=0;e<i.hitTestSegments.length;e++)if(Math.abs(i.hitTestSegments[e].x-t.x)<=3&&Math.abs(i.hitTestSegments[e].y-t.y)<=3){let n={...i,...i.measureParams,updateIndex:e};this.measureUpdateManage.createDrawable(n),this.measureUpdateManage.drawable&&(this.selectPointItemId=i.id,this.mousedownPoint=t);break}i.getIsSelected()?(this.selectionChanged(null),this.setSelectedItem(null),i.unselect()):(this.selectionChanged(i),this.setSelectedItem(i),i.select()),e.preventDefault(),e.stopPropagation()}}),!1),this.domContainer.addEventListener("mouseup",(e=>{this.manage.measure.isSelectItem=!1,this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type&&this.isMouseDownHelperHitItemMove&&(this.mouseDownHelperHitItem.endUpdate(this.manage.mapMeasureInfo),this.setSelectedItem(this.mouseDownHelperHitItem),this.mouseDownHelperHitItem.select(),this.mouseDownHelperHitItem=null),this.measureUpdateManage.end(),this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!1,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint=null,this.mousedownHitItem&&(e.preventDefault(),e.stopPropagation())}),!1),this.domContainer.addEventListener("dblclick",(()=>{event.preventDefault(),event.stopPropagation()}),!1)}hitTest(e){for(var t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.getNotation().hitTest(e))return i}for(t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.hitTest(e))return i}return null}setSelectedItem(e){this.selectedItem&&(this.selectedItem.actionWhenUnselected(),this.selectedItem.unselect()),this.selectedItem=e,e&&e.actionWhenSelected()}getSelectedItem(){return this.selectedItem}hasSelected(){return null!==this.selectedItem}setIsEnableSelection(e){this.isEnableSelection=e}}class po{constructor(e){this.filterId=e.filterId,this.filterUnits=e.filterUnits,this.stdDeviation=e.stdDeviation,this.feOffset1=e.feOffset1,this.feOffset2=e.feOffset2,this.shadowOpacity=e.opacity,this.initialize()}initialize(){let e=document.createElementNS(this.xmlns,"defs"),t=document.createElementNS(this.xmlns,"filter");t.setAttribute("id",this.filterId),t.setAttribute("filterUnits",this.filterUnits);let i=document.createElementNS(this.xmlns,"feGaussianBlur");i.setAttribute("in","SourceAlpha"),i.setAttribute("stdDeviation",this.stdDeviation),t.appendChild(i);let n=document.createElementNS(this.xmlns,"feOffset");n.setAttribute("dx",this.feOffset1.dx),n.setAttribute("dy",this.feOffset1.dy),n.setAttribute("result","offsetblur");let o=document.createElementNS(this.xmlns,"feOffset");o.setAttribute("dx",this.feOffset2.dx),o.setAttribute("dy",this.feOffset2.dy),o.setAttribute("result","offsetblur"),t.appendChild(n),t.appendChild(o);let s=document.createElementNS(this.xmlns,"feComponentTransfer"),r=document.createElementNS(this.xmlns,"feFuncA");r.setAttribute("type","linear"),r.setAttribute("slope",this.shadowOpacity),s.appendChild(r),t.appendChild(s);let a=document.createElementNS(this.xmlns,"feMerge"),l=document.createElementNS(this.xmlns,"feMergeNode"),h=document.createElementNS(this.xmlns,"feMergeNode");h.setAttribute("in","SourceGraphic");let d=document.createElementNS(this.xmlns,"feMergeNode");d.setAttribute("in","SourceGraphic"),a.appendChild(l),a.appendChild(h),a.appendChild(d),t.appendChild(a),e.appendChild(t),this.dropShadowDefs=e}attach(e){this.dropShadowDefs||this.initialize(),e.appendChild(this.dropShadowDefs);let t=e.innerHTML;e.removeChild(this.dropShadowDefs),e.innerHTML=t}getFilterUrl(){return"url(#"+this.filterId+")"}}let mo=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),fo=new e.Web.Graphics.Color(17,218,183,.2),wo=new e.Web.Graphics.Color(17,218,183,1);class yo{constructor(t){this.object3D=new THREE.Object3D,this.children=[],this.id=t&&t.id||e.Web.Lang.Utility.UUID.createUUID(),this.measure=t.measure,this.nextMeasurePoint=null,this.measurePoints=[],this.maxPointsNum=2,this.measureResult=null,this.measureParams={precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit},this.measureItemConfig=t,this.linewidth="number"==typeof t.width?t.width>10||t.width<1?3:t.width:3,this.viewer=t.viewer,this.selectChild=null,this.isEndDrawing=!1,this._config=t,this.helper=t.helper,this.hoveredObject=null,this.selectedObject=null,this.object3D.visible=!0,this.isSelected=!0,this.helperEvents={},this.color=t.color instanceof e.Web.Graphics.Color?"#"+t.color.getHEX():"#ff9d0b",this.svgContainer=this.helper.svgContainer,this.notationGroup=[],this.notation=new In(t.measureType);let i=mo.createNS("circle","bf-measure-handle");i.setAttribute("stroke-width",0),i.setAttribute("r",6),i.setAttribute("fill",fo.getRGB()),i.style.fill=fo.getRGB();let n=mo.createNS("line","bf-measure-line");n.style.strokeWidth=2,n.style.stroke=fo.getRGB();let o=mo.createNS("polygon","bf-measure-rect");o.setAttribute("fill",fo.getRGBA()),o.setAttribute("stroke",fo.getRGB()),o.setAttribute("stroke-width",1);var s=mo.createNS("path","bf-measure-foot");s.setAttribute("fill","none"),s.setAttribute("stroke",fo.getRGB()),s.setAttribute("stroke-width",2);const r=mo.createNS("rect","bf-snap-handle");r.setAttribute("width",14),r.setAttribute("height",14),r.setAttribute("fill","none"),r.setAttribute("stroke",wo.getRGB()),r.setAttribute("stroke-width",2);const a=mo.createNS("path","bf-snap-handle");a.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),a.setAttribute("fill","none"),a.setAttribute("stroke",wo.getRGB()),a.setAttribute("stroke-width",2);const l=mo.createNS("line","bf-snap-handle");l.setAttribute("x1",0),l.setAttribute("y1",0),l.setAttribute("x2",14),l.setAttribute("y2",14),l.setAttribute("stroke",fo.getRGB()),l.setAttribute("stroke-width",2);const h=mo.createNS("line","bf-snap-handle");h.setAttribute("x1",14),h.setAttribute("y1",0),h.setAttribute("x2",0),h.setAttribute("y2",14),h.setAttribute("stroke",fo.getRGB()),h.setAttribute("stroke-width",2),this.hoverFoot=s,this.hoverPoint=i,this.hoverLine=n,this.hoverPanel=o,this.hoverEndPoint=r,this.hoverMidPoint=a,this.hoverIntersectionPointA=l,this.hoverIntersectionPointB=h,this.hoverPanelSize={width:20,height:20},this.isReserverd=!1,this.hoverPositionUpdated=!1}init(){}getConfig(){return this._config}getCloudViewer(){return this.helper.viewer}draw(){}endDraw(){}update(){}endUpdate(){}select(){this.isSelected=!0}unselect(){this.isSelected=!1}getIsSelected(){return this.isSelected}actionWhenSelected(){}actionWhenUnselected(){}updateResult(){}attachNotation(e){if(0===e.length)return;let t=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},this.getMeasureResult(),this.id);for(const e of t)this.notationGroup.push(e);this.attach(this.notationGroup)}attach(e){if(0!=e.length)for(const t of e)this.svgContainer.appendChild(t)}detach(e){if(0!=e.length)for(const i of e){var t=i.parentNode;t&&t.removeChild(i)}}updateNotationPositionFun(e,t){let i=this.viewer.worldToScene({x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2,z:(t[0].z+t[1].z)/2});i=new THREE.Vector3(i.x,i.y,i.z);let o,s=i.applyMatrix4(this.viewer.getViewer().camera.matrixWorldInverse.clone()).applyMatrix4(this.viewer.getViewer().camera.projectionMatrix);o=Math.abs(s.x)>1||Math.abs(s.y)>1||Math.abs(s.z)>1?{x:-100,y:-100}:this.viewer.worldToClient({x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2,z:(t[0].z+t[1].z)/2});let r=this.notation.calcAnnotationStyle(this.getMeasureResult(),o);e[0].setAttribute("x",r.offsetRect.x),e[0].setAttribute("y",r.offsetRect.y),e[1].setAttribute("x",r.offsetRect.x-2),e[1].setAttribute("y",r.offsetRect.y-2),e[2].setAttribute("x",r.offsetText.x),e[2].setAttribute("y",r.offsetText.y);let a=new n(r.offsetRect.x,r.offsetRect.y+this.notation.annotationStyle.height/2),l=new n(r.offsetRect.x+r.width,a.y);this.notation.notationSegmentRects.push({start:a,end:l})}hitTest(e,t){let i=null;return this.children.some((n=>{const o=n.hitTest(e,t);return o&&(i=n),o})),this.hoveredObject=i,this.hoveredObject?!!this.hoveredObject:this.notation.hitTest(t)}hitTestPoint(e,t){let i=null;return this.children.some((n=>{const o="Point"==n.type&&n.hitTest(e,t);return o&&(i=n),o})),this.selectChild=i,!!this.selectChild}add(e){this.children.push(e),this.object3D.add(e.object3D)}remove(e){for(let t=0;t<this.children.length;t++)if(this.children[t]===e){this.object3D.remove(e.object3D),this.children.splice(t,1);break}}addHelperEvent(e,t){this.helperEvents[e]=t,this.helper.group.addEventListener(e,t)}getLinearColor(e){const t=new THREE.Color(e),i=e=>{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}destroy(){for(this._destroyed=!0,Object.entries(this.helperEvents).forEach((([e,t])=>{this.helper.group.removeEventListener(e,t)}));this.children.length>0;)this.children[0].destroy(),this.object3D.remove(this.children[0].object3D),this.children.splice(0,1);this.helper.viewer.render(),this.removeAllSvg()}removeAllSvg(){this.detach(this.notationGroup),this.notationGroup=[]}stretchOnDirection(e,t,i){let n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]}drawCaptureItem(e){let t=this.hoverPoint,i=this.hoverLine,n=this.hoverPanel,o=this.hoverEndPoint,s=this.hoverMidPoint,r=this.hoverIntersectionPointA,a=this.hoverIntersectionPointB,l=e.hoverPosition&&e.hoverPosition.x,h=e.hoverPosition&&e.hoverPosition.y,d=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",l),t.setAttribute("cy",h),e.svg.appendChild(t);break;case"EndPoint":o.setAttribute("x",l-7),o.setAttribute("y",h-7),e.svg.appendChild(o);break;case"MidPoint":s.setAttribute("d",`M ${l} ${h-7} L ${l+8} ${h+8} L ${l-8} ${h+8} L ${l} ${h-7}`),e.svg.appendChild(s);break;case"IntersectionPoint":r.setAttribute("x1",l-7),r.setAttribute("y1",h-7),r.setAttribute("x2",l+7),r.setAttribute("y2",h+7),e.svg.appendChild(r),a.setAttribute("x1",l+7),a.setAttribute("y1",h-7),a.setAttribute("x2",l-7),a.setAttribute("y2",h+7),e.svg.appendChild(a);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-14} v 14 h 14 M ${t},${i-9} h 9 v 9`),e.svg.appendChild(this.hoverFoot)}else i.setAttribute("x1",e.lineStartPoint.x),i.setAttribute("y1",e.lineStartPoint.y),i.setAttribute("x2",e.lineEndPoint.x),i.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(i);break;case"Panel":let c=e.clientPts,u=c[0].distanceTo(c[1]),g=c[0].distanceTo(c[3]),p=u/d.width,m=g/d.height;if(1!=p){let e=this.stretchOnDirection(c[0],c[1],d.width),t=this.stretchOnDirection(c[2],c[3],d.width);c=e.concat(t)}if(1!=m){let e=this.stretchOnDirection(c[0],c[3],d.height),t=this.stretchOnDirection(c[1],c[2],d.height);c=[e[0],t[0],t[1],e[1]]}let f="";for(let e=0;e<c.length;e++)f+=c[e].x+",",f+=c[e].y+" ";n.setAttribute("points",f),e.svg.appendChild(n)}}reset(){if(this.measurePoints=[],this.nextMeasurePoint=null,this.measureResult=null,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}}addPoint(e){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}redo(){this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?this.measurePoints.pop():this.measurePoints=[]}getId(){return this.id}getType(){return this.type}getPoints(){return this.measurePoints}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}setIsReserverd(e){this.isReserverd=e}getIsReserverd(){return this.isReserverd}getOrthogonalityCameraScaleValue(){return 1/(this.getCloudViewer().camera.zoom/this.getCloudViewer().camera.position.clone().sub(this.getCloudViewer().camera.target.clone()).length())}}class vo{constructor(e){this.object3D=new THREE.Object3D,this._config=e,this.name=e.name,this.viewer=e.viewer,this._cloudViewer=this.viewer.getViewer(),this.control=e.control,this.init&&this.init()}init(){}getConfig(){return this._config}getViewer(){return this.viewer}getCloudViewer(){return this._cloudViewer}updateMaterialResolution(){}hitTest(){return!1}getLinearColor(e){const t=new THREE.Color(e),i=e=>{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}getOrthogonalityCameraScaleValue(){return 1/(this.getCloudViewer().camera.zoom/this.getCloudViewer().camera.position.clone().sub(this.getCloudViewer().camera.target.clone()).length())}destroy(){this.object3D.children.forEach((e=>{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&e.material.dispose&&e.material.dispose()}))}}class bo extends vo{constructor(e){super(e),this.type="Point",this.isSelected=!1}init(){const{point:e,showText:t,noBorder:i}=this.getConfig();this.bgColor=this.getConfig().bgColor||"#ff9d0b",this.borderColor=this.getConfig().borderColor||"#FFFFFF",this.noBorder=i,this.object3D.position.set(e.x,e.y,e.z),this.showText=0!=t||t,this.object3D.updateMatrixWorld(),this.addPoint(),this.addRigidBody(),super.init()}update(e){this.object3D.position.set(e.x,e.y,e.z),this.object3D.updateMatrixWorld()}addPoint(){this.updateScaleFactor(),this.defaultTexture=this.getTexture();const e=new CLOUD.SpriteShaderMaterial({map:this.defaultTexture,depthTest:!1}),t=this.point=new THREE.Sprite(e);t.renderOrder=CLOUD.EnumRenderOrder.Effect+200,this.object3D.add(t)}getTexture(e){const t=document.createElement("canvas");t.width=16,t.height=16;const i=t.getContext("2d");this.noBorder||(i.beginPath(),i.arc(8,8,8,0,2*Math.PI),i.fillStyle="#"+this.getLinearColor(this.borderColor).getHexString(),i.fill()),i.beginPath(),i.arc(8,8,5.5,0,2*Math.PI),i.fillStyle="#"+this.getLinearColor(this.bgColor).getHexString(),i.fill();return new THREE.CanvasTexture(t)}addRigidBody(){const e=new THREE.BoxGeometry(1,1,1),t=new THREE.MeshBasicMaterial,i=this.rigidBody=new THREE.Mesh(e,t);i.visible=!1,this.object3D.add(i)}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=10*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.object3D.updateMatrixWorld()}hitTest(e){const t=[];return this.rigidBody.raycast(e,t),t.length>0}}class Eo extends vo{constructor(e){super(e)}init(){const{points:e,color:t,dashSize:i,gapSize:n}=this.getConfig();this.isNotHitTest=this.getConfig().isNotHitTest||!1,this.points=e,this.linewidth=this.getConfig().linewidth||3,this.dashSize=i,this.gapSize=n;const o=[];e.forEach((e=>o.push(e.x,e.y,e.z))),this.addLine(o,{color:this.getLinearColor(t)}),super.init()}addLine(e,t){const i=new THREE.LineGeometry;if(i.setPositions(e),!this.lineMaterial){let e;!0===this.getConfig().dashed?(e=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!0,dashSize:this.dashSize||1,gapSize:this.gapSize||1,dashScale:.1,depthTest:!1,...t}),e.defines.USE_DASH=""):e=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!1,depthTest:!1,...t}),e.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=e}const n=new THREE.Line2(i,this.lineMaterial);n.computeLineDistances(),n.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.object3D.add(n),this.line=n}update(e){this.points=e,this.object3D.remove(this.line),this.line.geometry.dispose();const t=[];e.forEach((e=>t.push(e.x,e.y,e.z))),this.addLine(t),this.object3D.updateMatrixWorld()}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}updateScaleFactor(e,t){if(!0===this.getConfig().dashed){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.points[0].clone().add(this.points[1]).multiplyScalar(.5),n=e.clone().sub(i.clone()).length(),o=t.angleTo(i.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=n/this.getCloudViewer().domElement.offsetHeight*.8;s<.2?s*=1.8:s<.5?s*=1.4:s<1&&(s*=1.2),this.line.material.dashSize=s,this.line.material.gapSize=s,this.line.computeLineDistances()}}hitTest(e,t){if(this.isNotHitTest)return!1;if(2!=this.points.length)return!1;let i=this.viewer.worldToClient(this.viewer.sceneToWorld(this.points[0])),o=this.viewer.worldToClient(this.viewer.sceneToWorld(this.points[1]));var s=new n(i.x,i.y),r=new n(o.x,o.y);return re.distanceToSegment(t,s,r)<=10}}class Mo extends vo{constructor(e){super(e)}init(){const{point:e,color:t}=this.getConfig();this.point=e,this.anotherPoint=this.getConfig().anotherPoint;this.object3D.position.set(e.x,e.y,e.z),this.addLine([10,0,0,-10,0,0],{color:this.getLinearColor(t)}),super.init(),this.updateScaleFactor()}addLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:2,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.object3D.add(o),this.line=o}update(e){this.point=e,this.object3D.position.set(e.x,e.y,e.z),this.object3D.updateMatrixWorld()}updateAnotherPoint(e){this.anotherPoint=e,this.updateDirection(),this.object3D.updateMatrixWorld()}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}updateScaleFactor(e,t,i){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var n=this.object3D.position,o=e.clone().sub(n.clone()).length(),s=t.angleTo(this.object3D.position.clone().sub(e.clone()));o=Math.sin(Math.PI/2-s)*o,this.getCloudViewer().camera.isPerspective||(o=this.getOrthogonalityCameraScaleValue());var r=.4*o/this.getCloudViewer().domElement.offsetHeight;if(this.object3D.scale.set(r,r,r),this.updateDirection(),i){let e=this.point.clone().sub(this.anotherPoint.clone()).normalize();var a=this.point.clone().add(e.clone().multiplyScalar(r*i));this.object3D.position.set(a.x,a.y,a.z)}this.object3D.updateMatrixWorld()}updateDirection(){var e=this.viewer.getDomElement().getBoundingClientRect(),t=this.viewer.worldToClient(this.viewer.sceneToWorld(this.anotherPoint)),i=this.getCloudViewer().cameraControl.getRaycaster(t.x+e.left,t.y+e.top);let n=i.ray.origin.clone(),o=i.ray.direction.clone(),s=(new THREE.Plane).setFromNormalAndCoplanarPoint(o,this.point),r=new THREE.Vector3,a=s.projectPoint(n,r),l=this.point.clone().sub(a).normalize().clone().normalize().cross(o.clone().normalize()).normalize();var h=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),l);this.line.quaternion.set(h.x,h.y,h.z,h.w)}hitTest(e){return!1}}class Co extends yo{constructor(e){super(e),this.name="distance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Distance,this.maxPointsNum=2,this.measurePoints=[],this.points=[],this.auxLines=[],this.auxLinesNotationGroup=[],this.selectedArr=[],this.canEdit=!0,this.firstUpdate=!0,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}stretchOnDirection(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]}initByData(e){this.id=e.id,this.setData(e),this.point1=new bo({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[0]),bgColor:this.color}),this.points.push(this.point1),this.add(this.point1),this.point2=new bo({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[1]),bgColor:this.color}),this.points.push(this.point2),this.add(this.point2),this.line=new Eo({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line),this.endDraw(),this.unselect()}draw(e){if(!this.getIsReserverd())switch(this._svg=e.svg,this.drawCaptureItem(e),e.clientPoints.length){case 2:let t=new bo({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.add(t),this.point2=t,this.points.push(t),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 1:if(!this.point1){let t=new bo({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t)}this.line?this.line.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line=new Eo({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line)),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.addAuxLines(),this.measureParams.enableAuxiliaryValue&&this.calAuxLinesNotation();let e=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([e,e]),this.line.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.linePoint1=new Mo({control:this,name:"linePoint1",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[0]),anotherPoint:this.viewer.worldToScene(this.measurePoints[1]),color:this.color}),this.add(this.linePoint1),this.linePoint2=new Mo({control:this,name:"linePoint2",viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[1]),anotherPoint:this.viewer.worldToScene(this.measurePoints[0]),color:this.color}),this.add(this.linePoint2)}update(e){this.firstUpdate&&(this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.select(),this.firstUpdate=!1),"point1"==this.selectChild.name?this.measurePoints[0]=e:this.measurePoints[1]=e,this.selectChild.update(this.viewer.worldToScene(e)),this.line.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.updateAuxLines(),this.calculate(),this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let t=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([t,t]),this.notation.select(),this.linePoint1.update(this.viewer.worldToScene(this.measurePoints[0])),this.linePoint2.update(this.viewer.worldToScene(this.measurePoints[1])),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render(),this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,this.getInfo())}endUpdate(){this.firstUpdate=!0,this.measureParams.enableAuxiliaryValue&&(this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.calAuxLinesNotation()),this.linePoint1.updateAnotherPoint(this.viewer.worldToScene(this.measurePoints[1])),this.linePoint2.updateAnotherPoint(this.viewer.worldToScene(this.measurePoints[0])),this.info.distance=this.measureResult,this.info.distanceX=this.distanceX,this.info.distanceY=this.distanceY,this.info.distanceZ=this.distanceZ,this.info.points=this.measurePoints}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient({x:(this.measurePoints[0].x+this.measurePoints[1].x)/2,y:(this.measurePoints[0].y+this.measurePoints[1].y)/2,z:(this.measurePoints[0].z+this.measurePoints[1].z)/2});this.attachNotation([e,e]),this.auxLinesNotationGroup.length>0&&this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[],this.measureParams.enableAuxiliaryValue&&this.calAuxLinesNotation(),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}getInfo(){return{id:this.id,distance:this.measureResult,distanceX:this.distanceX,distanceY:this.distanceY,distanceZ:this.distanceZ,points:this.measurePoints,type:this.type}}calculate(){this.distanceX=Math.abs(this.measurePoints[1].x-this.measurePoints[0].x),this.distanceY=Math.abs(this.measurePoints[1].y-this.measurePoints[0].y),this.distanceZ=Math.abs(this.measurePoints[1].z-this.measurePoints[0].z),this.auxLinesResult=[this.distanceX,this.distanceY,this.distanceZ],this.measureResult=Math.sqrt(Math.pow(this.distanceX,2)+Math.pow(this.distanceY,2)+Math.pow(this.distanceZ,2))}addAuxLines(){let e=["#CC021B","#7CCF21","#4A90E2"];for(var t={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},i={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},n=[this.measurePoints[0],t,i,this.measurePoints[1]],o=0;o<n.length-1;o++){let t=new Eo({control:this,name:"Line",viewer:this.viewer,isNotHitTest:!0,points:[this.viewer.worldToScene(n[o]),this.viewer.worldToScene(n[o+1])],color:e[o],linewidth:this.linewidth,dashed:!0});t.object3D.visible=!1,this.auxLines.push(t),this.selectedArr.push(t),this.add(t)}}updateAuxLines(){for(var e={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},t={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},i=[this.measurePoints[0],e,t,this.measurePoints[1]],n=0;n<i.length-1;n++)this.auxLines[n].update([this.viewer.worldToScene(i[n]),this.viewer.worldToScene(i[n+1])])}calAuxLinesNotation(){var e={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},t={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},i=[this.measurePoints[0],e,t,this.measurePoints[1]];if(i&&i.length&&4===i.length){let e,t=["#E22532","#6CC91A","#399DFF"];for(let n=0,o=i.length-1;n<o;n++){let o={x:(i[n].x+i[n+1].x)/2,y:(i[n].y+i[n+1].y)/2,z:(i[n].z+i[n+1].z)/2},s=this.viewer.worldToClient(o);e=this.notation.drawAnnotation({x:s.x,y:s.y},this.getMeasureResult(this.auxLinesResult[n])+"",this.id,t[n]),this.auxLinesNotationGroup.push(e),this.attach(e);for(const t of e)this.notation.notationSelected.push(t)}}}setData(e){this.info=e,this.id=e.id,this.measureResult=e.distance,this.measurePoints=e.points,this.worldPositions=e.points,this.auxLinesResult=[e.distanceX,e.distanceY,e.distanceZ],this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit,enableAuxiliaryValue:e.enableAuxiliaryValue||!1}),this.calculate()}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit,this.measureParams.enableAuxiliaryValue=e.enableAuxiliaryValue}getMeasureResult(e){let t=this.measureParams.unit,i=e||this.measureResult.toString(),n=Bn.formatDistance(i,this.measureParams);return n+=Bn.getPostFix(t,!1),n.split(",").join("")}select(){super.select(),this.selectedArr.map((e=>{e.object3D.visible=!0})),this.notation.select(),this.point1.object3D.visible=!0,this.point2.object3D.visible=!0,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.selectedArr.map((e=>{e.object3D.visible=!1})),this.notation.unselect(),this.point1.object3D.visible=!1,this.point2.object3D.visible=!1,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.points.forEach((e=>e.updateScaleFactor(t,i))),this.updateNotationPosition(),this.linePoint1&&this.linePoint1.updateScaleFactor(t,i,this.linewidth),this.linePoint2&&this.linePoint2.updateScaleFactor(t,i,this.linewidth),this.auxLines.forEach((e=>e.updateScaleFactor(t,i)))}updateNotationPosition(){if(this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,this.measurePoints),this.auxLinesNotationGroup.length>0)){var e={x:this.measurePoints[1].x,y:this.measurePoints[0].y,z:this.measurePoints[0].z},t={x:this.measurePoints[1].x,y:this.measurePoints[1].y,z:this.measurePoints[0].z},i=[this.measurePoints[0],e,t,this.measurePoints[1]];for(let e=0,t=i.length-1;e<t;e++)this.updateNotationPositionFun(this.auxLinesNotationGroup[e],[i[e],i[e+1]])}}removeAllSvg(){super.removeAllSvg(),this.auxLinesNotationGroup.length>0&&(this.auxLinesNotationGroup.map((e=>this.detach(e))),this.auxLinesNotationGroup=[])}reset(){this.children=[],this.measurePoints=[],this.points=[],this.auxLines=[],this.notationGroup=[],this.auxLinesNotationGroup=[],this.selectedArr=[],this.line=null,this.point1=null,this.point2=null,this.text=null,this.textUnselect=null,this.linePoint1=null,this.linePoint2=null,this.object3D.clear()}redo(){1==this.measurePoints.length&&(this.remove(this.point1),this.remove(this.line),this.point1=null,this.line=null,this.points.pop()),super.redo()}}class xo extends vo{constructor(e){super(e)}init(){const{point:e,color:t,direction:i}=this.getConfig();this.dir=i,this.point=e;this.line1=this.getLine([0,0,0,3,0,-3],{color:this.getLinearColor(t)}),this.object3D.add(this.line1);this.line2=this.getLine([0,0,0,-3,0,-3],{color:this.getLinearColor(t)}),this.object3D.add(this.line2),this.addRigidBody(),this.object3D.position.set(e.x,e.y,e.z),super.init(),this.updateScaleFactor()}getLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:2,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);return o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,o}addRigidBody(){const e=new THREE.BoxGeometry(8,8,8),t=new THREE.MeshBasicMaterial,i=this.rigidBody=new THREE.Mesh(e,t);i.visible=!1,this.object3D.add(i)}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1.6*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.updateDirection(),this.object3D.updateMatrixWorld()}updateDirection(){let e=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();this.directionQuaternion=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,-1),this.dir.clone().normalize());const t=this.control.object3D.quaternion.clone().invert(),i=new THREE.Vector3(0,1,0).applyQuaternion(this.directionQuaternion),n=new THREE.Plane(new THREE.Vector3(...Object.values(this.dir)).normalize()),o=new THREE.Vector3;n.projectPoint(e.clone().applyQuaternion(t),o);const s=(new THREE.Quaternion).setFromUnitVectors(i,o.normalize()).multiply(this.directionQuaternion.clone());this.object3D.quaternion.set(s.x,s.y,s.z,s.w),this.object3D.updateMatrixWorld(!0)}updateMaterialResolution(){this.line1.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.line2.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}hitTest(e){const t=[];return this.rigidBody.raycast(e,t),t.length>0}}class To extends yo{constructor(e){super(e),this.name="minimumDistance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance,this.maxPointsNum=2,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){this.isEndDrawing=!0,this.line=new Eo({helper:this.helper,control:this,name:"Line",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[0]),this.viewer.worldToScene(this.worldPositions[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line);let e=this.viewer.worldToClient({x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2});this.attachNotation([e,e]),this.lineTriangle1=new xo({control:this,name:"lineTriangle1",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[0]),direction:this.viewer.worldToScene(this.worldPositions[0]).sub(this.viewer.worldToScene(this.worldPositions[1])),color:this.color}),this.add(this.lineTriangle1),this.lineTriangle2=new xo({control:this,name:"lineTriangle2",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[1]),direction:this.viewer.worldToScene(this.worldPositions[1]).sub(this.viewer.worldToScene(this.worldPositions[0])),color:this.color}),this.add(this.lineTriangle2)}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient({x:(this.worldPositions[0].x+this.worldPositions[1].x)/2,y:(this.worldPositions[0].y+this.worldPositions[1].y)/2,z:(this.worldPositions[0].z+this.worldPositions[1].z)/2});this.attachNotation([e,e]),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}setMinDistanceLine(e){this.minDistanceLine=e}clearMinDistanceLine(){}addPoint(e){var t=this.viewer;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())}reset(e){var t=this.viewer;!1!==e&&this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])})),this.measurePoints=[],this.clearMinDistanceLine(),this.minDistanceLine=null,t.render()}redo(){var e=this.viewer;if(this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum){var t=this.measurePoints.pop();(t.modelId?e.getModel(t.modelId):e).removeSelectedId([t.userId]),e.render()}else this.reset()}getInfo(){return{id:this.id,distance:this.measureResult,points:this.selectedComponentsId,type:this.type}}setData(e){this.info=e,this.id=e.id,this.selectedComponentsId=e.points,this.worldPositions=[e.start,e.end],this.measureResult=e.distance,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}actionWhenSelected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).addSelectedComponentsById([e.userId])})),this.viewer.render()}actionWhenUnselected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).removeSelectedId([e.userId])})),this.viewer.render()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatDistance(t,this.measureParams);return i+=Bn.getPostFix(e,!1),i.split(",").join("")}select(){super.select(),this.notation.select()}unselect(){super.unselect(),this.notation.unselect()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.updateNotationPosition(),this.lineTriangle1&&this.lineTriangle1.updateScaleFactor(t,i),this.lineTriangle2&&this.lineTriangle2.updateScaleFactor(t,i)}updateNotationPosition(){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,this.worldPositions))}}class Po extends vo{constructor(e){super(e)}init(){const{center:e,radius:t,thetaStart:i,thetaLength:n,material:o,quaternion:s}=this.getConfig();this.addArc(e,t,i,n,o,s),super.init()}addArc(e,t,i,n,o,s){const r=new THREE.EllipseCurve(0,0,t,t,i,i+n,!1,0).getPoints(128),a=[];r.forEach((e=>a.push(e.x||0,e.y||0,e.z||0)));const l=new THREE.LineGeometry;l.setPositions(a);let h=new THREE.LineMaterial({linewidth:o.linewidth||2,dashed:!1,depthTest:!1,transparent:!0,color:this.getLinearColor(o.color)});h.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const d=new THREE.Line2(l,h);d.position.set(e.x,e.y,e.z),s&&d.quaternion.set(s.x,s.y,s.z,s.w),d.renderOrder=CLOUD.EnumRenderOrder.Effect+100,this.line=d,this.object3D.add(d)}updateMaterialResolution(){this.line.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}}class Io extends yo{constructor(e){super(e),this.name="angle",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Angle,this.maxPointsNum=3,this.measurePoints=[],this.points=[],this.canEdit=!0,this.firstUpdate=!0,this.normalLength=70,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e);var t=new bo({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[0]),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t),t=new bo({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[1]),bgColor:this.color}),this.point2=t,this.points.push(t),this.add(t),t=new bo({control:this,name:"point3",viewer:this.viewer,point:this.viewer.worldToScene(this.worldPositions[2]),bgColor:this.color}),this.add(t),this.point3=t,this.points.push(t),this.line1=new Eo({control:this,name:"line1",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[0]),this.viewer.worldToScene(this.worldPositions[1])],color:this.color,linewidth:this.linewidth}),this.add(this.line1),this.line2=new Eo({control:this,name:"line2",viewer:this.viewer,points:[this.viewer.worldToScene(this.worldPositions[1]),this.viewer.worldToScene(this.worldPositions[2])],color:this.color,linewidth:this.linewidth}),this.add(this.line2),this.endDraw(),this.unselect()}draw(e){if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 3:let t=new bo({control:this,name:"point3",viewer:this.viewer,point:this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[2],["x","y","z"])),bgColor:this.color});this.add(t),this.point3=t,this.points.push(t),this.line2.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[2],["x","y","z"]))]),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 2:if(!this.point2){let e=new bo({control:this,name:"point2",viewer:this.viewer,point:this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),bgColor:this.color});this.point2=e,this.points.push(e),this.add(e)}this.line2?this.line2.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line2=new Eo({control:this,name:"line2",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line2)),this.line1.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[1],["x","y","z"]))]),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;case 1:if(!this.point1){let t=new bo({control:this,name:"point1",viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.point1=t,this.points.push(t),this.add(t)}this.line1?this.line1.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.line1=new Eo({control:this,name:"line1",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.line1)),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.line1.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.line2.update([this.viewer.worldToScene(this.measurePoints[1]),this.viewer.worldToScene(this.measurePoints[2])]),this.addText(),this.addCurve(),this.updateScaleFactor(),this.viewer.getViewer().render()}addText(){this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());var e=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),t=this.viewer.worldToScene(this.measurePoints[2]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone());let i=e.normalize().clone().add(t.normalize().clone()).normalize();var n=this.viewer.worldToScene(this.measurePoints[1]).clone().add(i.clone().multiplyScalar(this.normalLength));let o=this.viewer.worldToClient(this.viewer.sceneToWorld(n));this.attachNotation([o,o])}addCurve(){let e=(new THREE.Plane).setFromCoplanarPoints(this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1]),this.viewer.worldToScene(this.measurePoints[2])),t=e.normal.z<0?e.normal:new THREE.Vector3(-e.normal.x,-e.normal.y,-e.normal.z),i=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),t);var n=new THREE.Vector3(1,0,0).clone().applyQuaternion(i),o=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),s=n.angleTo(o);n.clone().cross(o).angleTo(t)<Math.PI/2<=0&&(s=2*Math.PI-s);var r=this.viewer.worldToScene(this.measurePoints[2]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),a=n.angleTo(r);var l;n.clone().cross(r).angleTo(t)<Math.PI/2<=0&&(a=2*Math.PI-a),l=0;let h=Math.min(s,a),d=Math.max(s,a);l=d-h<=Math.PI?h:d,this.curve&&this.remove(this.curve);let c=this.measurePoints[1].clone().sub(this.measurePoints[0].clone()).angleTo(this.measurePoints[1].clone().sub(this.measurePoints[2].clone()));c=c-.002<=0?0:c-.002,this.curve=new Po({control:this,name:"arc",viewer:this.viewer,center:this.viewer.worldToScene(this.measurePoints[1]),radius:this.normalLength,thetaStart:l,thetaLength:c,material:{color:this.color},quaternion:i}),this.add(this.curve)}update(e){this.firstUpdate&&(this.select(),this.firstUpdate=!1),"point1"==this.selectChild.name?this.measurePoints[0]=e:"point2"==this.selectChild.name?this.measurePoints[1]=e:this.measurePoints[2]=e,this.selectChild.update(this.viewer.worldToScene(e)),this.line1.update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[1])]),this.line2.update([this.viewer.worldToScene(this.measurePoints[1]),this.viewer.worldToScene(this.measurePoints[2])]),this.calculate(),this.addText(),this.notation.select(),this.addCurve(),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render(),this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,this.getInfo())}endUpdate(){this.firstUpdate=!0,this.calculate(),this.info.angle=this.measureAngle,this.info.points=this.worldPositions}calculate(){this.worldPositions=this.measurePoints;var e=new THREE.Vector3(this.worldPositions[0].x-this.worldPositions[1].x,this.worldPositions[0].y-this.worldPositions[1].y,this.worldPositions[0].z-this.worldPositions[1].z),t=new THREE.Vector3(this.worldPositions[2].x-this.worldPositions[1].x,this.worldPositions[2].y-this.worldPositions[1].y,this.worldPositions[2].z-this.worldPositions[1].z),i=e.angleTo(t);this.measureAngle=180*i/Math.PI}updateResult(){this.addText(),this.isSelected?this.select():this.unselect(),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}getInfo(){return{id:this.id,points:this.worldPositions,angle:this.measureAngle,type:this.type}}setData(e){this.info=e,this.id=e.id,this.worldPositions=e.points,this.measurePoints=e.points;for(let e=0;e<this.measurePoints.length;e++)this.measurePoints[e]=new THREE.Vector3(this.measurePoints[e].x,this.measurePoints[e].y,this.measurePoints[e].z);this.measureAngle=e.angle,this.setMeasureParams({precision:e.precision})}getMeasureResult(){let e=this.measureAngle.toString();return Bn.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}select(){super.select(),this.notation.select(),this.point1.object3D.visible=!0,this.point2.object3D.visible=!0,this.point3.object3D.visible=!0,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.notation.unselect(),this.point1.object3D.visible=!1,this.point2.object3D.visible=!1,this.point3.object3D.visible=!1,this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.points.forEach((e=>e.updateScaleFactor(t,i))),this.updateCurveScaleFactor(t,i)}updateCurveScaleFactor(e,t){if(!this.isEndDrawing)return;var i=this.viewer.worldToScene(this.measurePoints[0]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone()),n=this.viewer.worldToScene(this.measurePoints[2]).clone().sub(this.viewer.worldToScene(this.measurePoints[1]).clone());let o=.9*i.length(),s=.9*n.length();e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var r=this.curve.line.position,a=e.clone().sub(r.clone()).length(),l=t.angleTo(this.curve.line.position.clone().sub(e.clone()));a=Math.sin(Math.PI/2-l)*a,this.getCloudViewer().camera.isPerspective||(a=this.getOrthogonalityCameraScaleValue());var h=.4*a/this.getCloudViewer().domElement.offsetHeight;h=Math.min(h*this.normalLength,o,s)/this.normalLength,this.curve.line.scale.set(h,h,h),this.curve.object3D.updateMatrixWorld();let d=i.normalize().clone().add(n.normalize().clone()).normalize();var c=this.viewer.worldToScene(this.measurePoints[1]).clone().add(d.clone().multiplyScalar(this.normalLength*h));let u=this.viewer.sceneToWorld(c);this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[u,u])}reset(){this.children=[],this.measurePoints=[],this.points=[],this.line1=null,this.line2=null,this.point1=null,this.point2=null,this.point3=null,this.object3D.clear()}redo(){1==this.measurePoints.length?(this.remove(this.point1),this.remove(this.line1),this.point1=null,this.line1=null,this.points.pop()):2==this.measurePoints.length&&(this.remove(this.point2),this.remove(this.line2),this.point2=null,this.line2=null,this.points.pop()),super.redo()}}class So extends yo{constructor(e){super(e),this.name="elevation",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Elevation,this.maxPointsNum=1,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){this.isEndDrawing=!0;let e=this.viewer.worldToClient(this.elevationPoint);this.attachNotation([e,e]),this.addPolyline()}addPolyline(){var e=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);e=this.viewer.worldToClient(e);for(var t=[58,-12,-12,-12,0,0,12,-12],i="",n=0;n<t.length;n+=2)t[n]+=e.x,t[n+1]+=e.y,i+=t[n]+","+t[n+1]+" ";var o=re.makePolyline({color:this.color,width:2,points:i});this.elevationPolyline=o,this.attach([this.elevationPolyline])}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient(this.elevationPoint);this.attachNotation([e,e]),this.detach([this.elevationPolyline]),this.addPolyline(),this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,points:[this.elevationPoint],initialElevation:this.initialElevation,elevation:this.elevation,type:this.type}}setData(e){this.info=e,this.id=e.id,this.elevationPoint=e.points[0],this.elevation="number"==typeof e.elevation?e.elevation:e.points[0].z,this.initialElevation=e.initialElevation,this.setMeasureParams({precision:e.precision,unit:e.unit,defaultUnit:e.defaultUnit})}getMeasureResult(){let e=this.measureParams.unit,t=this.elevation.toString(),i=Bn.formatDistance(t,this.measureParams);return i+=Bn.getPostFix(e,!1),i=i.split(",").join(""),0==i.split(" ")[0]&&(i=`±${i}`),i}select(){super.select(),this.notation.select()}unselect(){super.unselect(),this.notation.unselect()}updateScaleFactor(e){this.updateNotationPosition()}updateNotationPosition(){if(!this.isEndDrawing)return;this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[this.elevationPoint,this.elevationPoint]);var e=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);let t=this.viewer.worldToClient(e);this.viewer.isInViewFrustum(e)||(t={x:-100,y:-100});for(var i=[58,-12,-12,-12,0,0,12,-12],n="",o=0;o<i.length;o+=2)i[o]+=t.x,i[o+1]+=t.y,n+=i[o]+","+i[o+1]+" ";this.elevationPolyline.setAttribute("points",n)}hitTest(e,t){if(!this.isEndDrawing)return!1;var i=new THREE.Vector3(this.elevationPoint.x,this.elevationPoint.y,this.elevationPoint.z);i=this.viewer.worldToClient(i);let n=new THREE.Vector2(i.x-12,i.y-22),o=new THREE.Vector2(i.x+58,i.y-22);return re.distanceToSegment(t,n,o)<=22||this.notation.hitTest(t)}destroy(){super.destroy(),this.elevationPolyline&&(this.detach([this.elevationPolyline]),this.elevationPolyline=null)}}class Bo extends yo{constructor(e){super(e),this.name="volume",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Volume,this.maxPointsNum=1,this.measurePoints=[],this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect()}draw(e){}endDraw(){if(this.isEndDrawing=!0,!this.measureResult)return;let e=this.viewer.worldToClient(this.worldPosition);this.attachNotation([e,e])}updateResult(){if(!this.measureResult)return;this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient(this.worldPosition);this.attachNotation([e,e]),this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,volumeResult:this.measureResult,points:this.selectedComponentsId,volumePosition:this.viewer.worldToScene(this.worldPosition),type:this.type}}setData(e){this.info=e,this.id=e.id,this.selectedComponentsId=e.points,this.worldPosition=this.viewer.sceneToWorld(e.volumePosition),this.measureResult=e.volumeResult,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}addPoint(e){var t=this._config.viewer;this.measurePoints.length==this.maxPointsNum&&this.reset();var i=!1;this.measurePoints.some((t=>(t.modelId===e.modelId&&t.userId===e.userId&&(i=!0),i))),i||(this.measurePoints.push(e),(e.modelId?t.getModel(e.modelId):t).addSelectedComponentsById([e.userId]),t.render())}reset(e){var t=this._config.viewer;!1!==e&&this.measurePoints.forEach((e=>{(e.modelId?t.getModel(e.modelId):t).removeSelectedId([e.userId])})),this.measurePoints=[],t.render()}actionWhenSelected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).addSelectedComponentsById([e.userId])})),this.viewer.render()}actionWhenUnselected(){this.selectedComponentsId.forEach((e=>{(e.modelId?this.viewer.getModel(e.modelId):this.viewer).removeSelectedId([e.userId])})),this.viewer.render()}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString(),i=Bn.formatCubic(t,this.measureParams);return i=i+Bn.getPostFix(e,!1)+"³",i.split(",").join("")}select(){super.select(),this.notation.select()}unselect(){super.unselect(),this.notation.unselect()}updateScaleFactor(e){this.updateNotationPosition()}updateNotationPosition(){this.isEndDrawing&&this.measureResult&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[this.worldPosition,this.worldPosition]))}}class _o extends vo{constructor(e){super(e)}init(){const{point:e,color:t,direction:i}=this.getConfig();this.dir=i,this.point=e,this.linewidth=this.getConfig().linewidth||1;this.line1=this.getLine([0,0,0,2,0,-4],{color:this.getLinearColor(t)}),this.object3D.add(this.line1);this.line2=this.getLine([0,0,0,-2,0,-4],{color:this.getLinearColor(t)}),this.object3D.add(this.line2),this.object3D.position.set(e.x,e.y,e.z),super.init(),this.updateScaleFactor()}getLine(e,t){const i=new THREE.LineGeometry;i.setPositions(e);let n=new THREE.LineMaterial({linewidth:this.linewidth,dashed:!1,depthTest:!1,...t});n.resolution.set(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.lineMaterial=n;const o=new THREE.Line2(i,this.lineMaterial);return o.computeLineDistances(),o.renderOrder=CLOUD.EnumRenderOrder.Effect+100,o}updateScaleFactor(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.object3D.position,n=e.clone().sub(i.clone()).length(),o=t.angleTo(this.object3D.position.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1.6*n/this.getCloudViewer().domElement.offsetHeight;this.object3D.scale.set(s,s,s),this.updateDirection(),this.object3D.updateMatrixWorld()}updateDirection(){let e=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();this.directionQuaternion=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,-1),this.dir.clone().normalize());const t=this.control.object3D.quaternion.clone().invert(),i=new THREE.Vector3(0,1,0).applyQuaternion(this.directionQuaternion),n=new THREE.Plane(new THREE.Vector3(...Object.values(this.dir)).normalize()),o=new THREE.Vector3;n.projectPoint(e.clone().applyQuaternion(t),o);const s=(new THREE.Quaternion).setFromUnitVectors(i,o.normalize()).multiply(this.directionQuaternion.clone());this.object3D.quaternion.set(s.x,s.y,s.z,s.w),this.object3D.updateMatrixWorld(!0)}updateMaterialResolution(){this.line1.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.line2.material.resolution=new THREE.Vector2(this.getCloudViewer().domElement.clientWidth,this.getCloudViewer().domElement.clientHeight),this.object3D.updateMatrixWorld()}}class Lo extends yo{constructor(e){super(e),this.name="laserClearDistance",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance,this.maxPointsNum=1,this.lineArrowGroup={},this.lineGroup={},this.allNotationGroup={},this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)));const t=this.viewer.getDomElement();let i=document.getElementsByClassName("bf-measure-dragbutton")[0];if(!i){i=document.createElement("div"),i.innerHTML='\n <svg width="160px" height="160px" viewBox="0 0 160 160" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <g>\n <g fill="#FFFFFF" fill-opacity="0.3" stroke="#999999" stroke-width="2">\n <path d="M80,1 C82.7908696,1 85.5479441,1.14468216 88.264129,1.4269862 C89.0464893,1.50830005 89.8254567,1.60103155 90.6008619,1.70501165 C95.2372276,2.32673796 99.7462267,3.35063053 104.091601,4.74047874 C109.461201,6.4579211 114.580945,8.73415789 119.382458,11.5007405 C131.430077,18.4424547 141.474355,28.4710659 148.435065,40.506339 C155.154653,52.1247049 159,65.6133154 159,80 C159,101.815248 150.157624,121.565248 135.861436,135.861436 C121.565248,150.157624 101.815248,159 80,159 C58.1847524,159 38.4347524,150.157624 24.1385643,135.861436 C9.84237619,121.565248 1,101.815248 1,80 C1,58.1847524 9.84237619,38.4347524 24.1385643,24.1385643 C38.4347524,9.84237619 58.1847524,1 80,1 Z" id="Oval-2"></path>\n </g>\n <circle fill-opacity="0.8" fill="#FFFFFF" cx="80" cy="80" r="40"></circle>\n <g transform="translate(58.000000, 58.000000)" fill="#32D3A6" fill-rule="nonzero">\n <path d="M23.2727273,27.1515152 L23.2727273,36.8484848 L29.0909091,36.8484848 L22.3030303,44.6060606 L15.5151515,36.8484848 L21.3333333,36.8484848 L21.3333333,27.1515152 L23.2727273,27.1515152 Z M36.8484848,15.5151515 L44.6060606,22.3030303 L36.8484848,29.0909091 L36.8484848,23.2707879 L27.1515152,23.2727273 L27.1515152,21.3333333 L36.8484848,21.3313939 L36.8484848,15.5151515 Z M7.75757576,15.5151515 L7.75757576,21.3333333 L17.4545455,21.3333333 L17.4545455,23.2727273 L7.75757576,23.2727273 L7.75757576,29.0909091 L0,22.3030303 L7.75757576,15.5151515 Z M22.3030303,0 L29.0909091,7.75757576 L23.2727273,7.75757576 L23.2727273,17.4545455 L21.3333333,17.4545455 L21.3333333,7.75757576 L15.5151515,7.75757576 L22.3030303,0 Z" id="形状"></path>\n </g>\n </g>\n </g>\n </svg>\n ',i.className="bf-measure-dragbutton",i.style.display="none";let e=this.dragEvents={touchmove:e=>{let{top:n,left:o}=t.getBoundingClientRect(),{clientX:s,clientY:r}=e.touches[0];this.setButtonPosition(i,s-o,r-n);const a=new Touch({identifier:Date.now(),target:t,clientX:s,clientY:r,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5}),l=new TouchEvent("touchstart",{touches:[a]});t.dispatchEvent(l);const h=new TouchEvent("touchend");t.dispatchEvent(h),e.stopPropagation(),e.preventDefault()}};for(let t in e)i.addEventListener(t,e[t]);t.appendChild(i)}this.dragButton=i,this.dragButtonPoint=null,this.dragButtonVisible=!1,this._result={};const n=this.nextButtons={},o=document.createElement("div");this.nextButtonContainer=o,t.appendChild(o),["positive_X","negative_X","positive_Y","negative_Y","positive_Z"].forEach((e=>{const t=document.createElement("div");t.addEventListener("touchstart",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchmove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("touchend",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.addEventListener("mousedown",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mousemove",(e=>{e.stopPropagation(),e.preventDefault()})),t.addEventListener("mouseup",(t=>{this.getNextResult(e),t.stopPropagation(),t.preventDefault()})),t.className=`bf-measure-nextbutton ${e}`;const i={button:t};let s;Object.defineProperty(i,"position",{set:e=>{if(e){t.style.display="block";let{x:i,y:n}=this.viewer.worldToClient(e);i&&n&&this.setButtonPosition(t,i,n)}else t.style.display="none";s=e},get:()=>s}),o.appendChild(t),n[e]=i})),this.fun=()=>{if(this.dragButtonVisible&&this.dragButtonPoint){this.dragButton.style.display=this.viewer.isInViewFrustum(this.dragButtonPoint)?"block":"none";let{x:e,y:t}=this.viewer.worldToClient(this.dragButtonPoint);e&&t&&this.setButtonPosition(this.dragButton,e,t)}Object.values(n).forEach((e=>{e.position=e.position?e.position.clone():void 0,e.position&&!this.viewer.isInViewFrustum(e.position)&&(e.button.style.display="none")}))},this.viewer.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,this.fun)}initByData(e){this.id=e.id,this.setData(e),this.measurePoints.push({componentId:e.componentSelected.componentId,modelId:e.componentSelected.modelId,point:this.viewer.globalUnitUtil.translate(e.pointSelected,["x","y","z"])}),this.computeMeasureResult(e.intersectNormal),this.endDraw(),this.unselect()}draw(e){this.drawCaptureItem(e)}endDraw(){this.isEndDrawing=!0;const e=this.measure.getMeasureParams().laserXYZ,t={X:"#CC021B",Y:"#7CCF21",Z:"#4A90E2"},i=n=>{const o=this.data[`Laser${n}`];if(o&&-1!==e.indexOf(n)){const e=t[n],[i,s]=o.endPoints,r=new THREE.Vector3(i.x,i.y,i.z),a=new THREE.Vector3(s.x,s.y,s.z),l=o.distance;this.lineGroup[n]=new Eo({control:this,name:"line",viewer:this.viewer,points:[this.viewer.worldToScene(r),this.viewer.worldToScene(a)],linewidth:this.lineWidth,isNotHitTest:!0,color:e}),this.add(this.lineGroup[n]),this.lineArrowGroup[n+"start"]=new _o({control:this,name:n+"start",viewer:this.viewer,point:this.viewer.worldToScene(r),direction:this.viewer.worldToScene(a).sub(this.viewer.worldToScene(r)),linewidth:this.lineWidth,color:e}),this.add(this.lineArrowGroup[n+"start"]),this.lineArrowGroup[n+"end"]=new _o({control:this,name:n+"end",viewer:this.viewer,point:this.viewer.worldToScene(a),direction:this.viewer.worldToScene(r).sub(this.viewer.worldToScene(a)),linewidth:this.lineWidth,color:e}),this.add(this.lineArrowGroup[n+"end"]);let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2,z:(r.z+a.z)/2},d=this.viewer.worldToClient(h);if(!this.viewer.isInViewFrustum(h)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x<t&&i.y<e;let n=new THREE.Vector3(this.data.pointSelected.x,this.data.pointSelected.y,this.data.pointSelected.z);if(this.viewer.isInViewFrustum(n)){let e=this.viewer.worldToClient(n),t=new THREE.Vector3(e.x,e.y,e.z),o=new THREE.Vector3(d.x,d.y,d.z);const s=100;d=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(s)),i(d)||(d=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(-s))),i(d)||(d={x:-100,y:-100})}else d={x:-100,y:-100}}let c=this.notation.drawAnnotation({x:d.x,y:d.y},this.getMeasureResultText(l),this.id,e);this.allNotationGroup[n]=c,this.attach(c)}return i};i("X")("Y")("Z")}updateResult(){const e={X:"#CC021B",Y:"#7CCF21",Z:"#4A90E2"},t=this.measure.getMeasureParams().laserXYZ;this.notation.clear();const i=n=>{const o=this.data[`Laser${n}`];if(o&&-1!==t.indexOf(n)){const t=e[n],[i,s]=o.endPoints,r=new THREE.Vector3(i.x,i.y,i.z),a=new THREE.Vector3(s.x,s.y,s.z),l=o.distance;let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2,z:(r.z+a.z)/2},d=this.viewer.worldToClient(h);if(!this.viewer.isInViewFrustum(h)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x<t&&i.y<e;let n=new THREE.Vector3(this.data.pointSelected.x,this.data.pointSelected.y,this.data.pointSelected.z);if(this.viewer.isInViewFrustum(n)){let e=this.viewer.worldToClient(n),t=new THREE.Vector3(e.x,e.y,e.z),o=new THREE.Vector3(d.x,d.y,d.z);const s=100;d=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(s)),i(d)||(d=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(-s))),i(d)||(d={x:-100,y:-100})}else d={x:-100,y:-100}}let c=this.notation.drawAnnotation({x:d.x,y:d.y},this.getMeasureResultText(l),this.id,t);this.detach(this.allNotationGroup[n]),this.allNotationGroup[n]=c,this.attach(c)}return i};i("X")("Y")("Z"),this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,data:this.data,type:this.type}}setData(e){this.info=e,this.id=e.id,this.lineWidth=1,this.data=e,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}getMeasureResultText(e){let t=this.measureParams.unit,i=e.toString(),n=Bn.formatDistance(i,this.measureParams);return n+=Bn.getPostFix(t,!1),n.split(",").join("")}computeMeasureResult(e){e=new THREE.Vector3(e.x,e.y,e.z),this.intersectNormal=e;let t=this.getPoints();const i=this.measure.getMeasureParams().laserXYZ;if(0===t.length)return;t[0].point=new THREE.Vector3(...Object.values(this.viewer.globalUnitUtil.revertTranslate(t[0].point,["x","y","z"])));let{point:n}=t[0];this._result.pointInfo=t[0];let o=this.viewer.globalUnitUtil.excute(1,"mm",this.viewer.getUnit());const s=n.clone().add(e.clone().multiplyScalar(o)),r=(e,t)=>{const n=this.viewer.getComponentsByRaycaster(s,t),o=this.viewer.getComponentsByRaycaster(s,t.clone().negate());return this._result[e]=n.length>0&&o.length>0?{enable:!0,direction:t,positiveIntersects:n,negativeIntersects:o,positiveIndex:0,negativeIndex:0}:{enable:!1},this.nextButtons[`positive_${e}`].position=n.length>1&&o.length>0&&-1!==i.indexOf(e)?n[0].position:void 0,"Z"!==e&&(this.nextButtons[`negative_${e}`].position=o.length>1&&n.length>0&&-1!==i.indexOf(e)?o[0].position:void 0),r};let a,l,h;return Math.abs(1-Math.abs(e.z))<.001?(a=new THREE.Vector3(1,0,0),l=new THREE.Vector3(0,1,0),h=new THREE.Vector3(0,0,1)):(a=e.clone().cross(new THREE.Vector3(0,0,1)),a.x<0&&a.negate(),l=e.clone().cross(a),l.y<0&&l.negate(),h=e),r("X",a)("Y",l)("Z",h),!Glodon.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.showDragButton(n),this.getMeasureResult()}getMeasureResult(){let e={},{componentId:t,modelId:i,point:n}=this._result.pointInfo;const o=this.measure.getMeasureParams().laserXYZ;e.pointSelected={x:n.x,y:n.y,z:n.z},e.componentSelected={componentId:t,modelId:i},e.type=this.type;const s=t=>{if(this._result[t].enable&&-1!==o.indexOf(t)){let{direction:i,positiveIntersects:n,negativeIntersects:o,positiveIndex:s,negativeIndex:r}=this._result[t],a=n[s],l=o[r];e[`Laser${t}`]={vector:{x:i.x,y:i.y,z:i.z},distance:a.distance+l.distance,endPoints:[{x:a.position.x,y:a.position.y,z:a.position.z,direction:"positive"},{x:l.position.x,y:l.position.y,z:l.position.z,direction:"negative"}],endComponents:[{componentId:a.id,modelId:a.modelId,direction:"positive"},{componentId:l.id,modelId:l.modelId,direction:"negative"}]}}return s};return s("X")("Y")("Z"),e.intersectNormal=this.intersectNormal,e}getNextResult(e){let[t,i]=e.split("_");if(!this._result[i]||!this._result[i].enable)return;let n=this._result[i][`${t}Intersects`],o=++this._result[i][`${t}Index`];n.length<=o&&(this._result[i][`${t}Index`]=o=0),this.data=this.getMeasureResult(),this.nextButtons[e].position=n[o].position,this.updateLinesPosition(),this.updateResult(),this.updateScaleFactor()}updateLinesPosition(){const e=this.measure.getMeasureParams().laserXYZ,t=i=>{const n=this.data[`Laser${i}`];if(n&&-1!==e.indexOf(i)){const[e,t]=n.endPoints,o=new THREE.Vector3(e.x,e.y,e.z),s=new THREE.Vector3(t.x,t.y,t.z);this.lineGroup[i].update([this.viewer.worldToScene(o),this.viewer.worldToScene(s)]),this.lineArrowGroup[i+"start"].object3D.position.copy(this.viewer.worldToScene(o)),this.lineArrowGroup[i+"end"].object3D.position.copy(this.viewer.worldToScene(s))}return t};t("X")("Y")("Z"),this.object3D.updateMatrixWorld(),this.viewer.render()}showDragButton(e){this.reset(),this.viewer.render(),this.dragButtonPoint=e,this.dragButtonVisible=!0;let{x:t,y:i}=this.viewer.worldToClient(e);this.dragButton.style.display="block",t&&i&&this.setButtonPosition(this.dragButton,t,i)}hideDragButton(){this.dragButtonVisible=!1,this.dragButton.style.display="none",Object.values(this.nextButtons).forEach((e=>e.position=void 0))}showNextButton(){this.nextButtonContainer.style.display="block"}hideNextButton(){this.nextButtonContainer.style.display="none"}clearNextButton(){Object.values(this.nextButtons).forEach((e=>e.position=void 0))}setButtonPosition(e,t,i){e.style.top=`${i}px`,e.style.left=`${t}px`}select(){super.select(),this.notation.select(),this.showNextButton()}unselect(){super.unselect(),this.notation.unselect(),Glodon.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hideNextButton()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize());for(let e in this.lineArrowGroup)this.lineArrowGroup[e]&&this.lineArrowGroup[e].updateScaleFactor(t,i);this.updateNotationPosition()}updateNotationPosition(){if(!this.isEndDrawing)return;this.notation.notationSegmentRects=[];const e=this.measure.getMeasureParams().laserXYZ,t=i=>{const o=this.data[`Laser${i}`];if(o&&-1!==e.indexOf(i)){const[e,t]=o.endPoints,s=new THREE.Vector3(e.x,e.y,e.z),r=new THREE.Vector3(t.x,t.y,t.z),a=o.distance;let l={x:(s.x+r.x)/2,y:(s.y+r.y)/2,z:(s.z+r.z)/2},h=this.viewer.worldToClient(l);if(!this.viewer.isInViewFrustum(l)){const{offsetHeight:e,offsetWidth:t}=this.viewer.getDomElement(),i=i=>i.x>0&&i.y>0&&i.x<t&&i.y<e;let n=new THREE.Vector3(this.data.pointSelected.x,this.data.pointSelected.y,this.data.pointSelected.z);if(this.viewer.isInViewFrustum(n)){let e=this.viewer.worldToClient(n),t=new THREE.Vector3(e.x,e.y,e.z),o=new THREE.Vector3(h.x,h.y,h.z);const s=100;h=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(s)),i(h)||(h=t.clone().add(o.clone().sub(t).normalize().multiplyScalar(-s))),i(h)||(h={x:-100,y:-100})}else h={x:-100,y:-100}}let d=this.notation.calcAnnotationStyle(this.getMeasureResultText(a),h);this.allNotationGroup[i][0].setAttribute("x",d.offsetRect.x),this.allNotationGroup[i][0].setAttribute("y",d.offsetRect.y),this.allNotationGroup[i][1].setAttribute("x",d.offsetRect.x-2),this.allNotationGroup[i][1].setAttribute("y",d.offsetRect.y-2),this.allNotationGroup[i][2].setAttribute("x",d.offsetText.x),this.allNotationGroup[i][2].setAttribute("y",d.offsetText.y);let c=new n(d.offsetRect.x,d.offsetRect.y+this.notation.annotationStyle.height/2),u=new n(d.offsetRect.x+d.width,c.y);this.notation.notationSegmentRects.push({start:c,end:u})}return t};t("X")("Y")("Z")}destroy(){super.destroy(),this.viewer.getDomElement().removeChild(this.nextButtonContainer),this.viewer.removeEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.CameraPositionChanged,this.fun)}removeAllSvg(){for(let e in this.allNotationGroup)this.detach(this.allNotationGroup[e]);this.allNotationGroup={}}}class Do extends vo{constructor(e){super(e)}init(){const{point:e,color:t,direction:i}=this.getConfig();this.direction=i,this.arrow=this.getArrow(e,i,t),this.object3D.add(this.arrow),super.init()}getArrow(e,t,i){const n=new THREE.BufferGeometry,o=new Float32Array([-7,0,0,7,0,0,0,0,14]);n.setAttribute("position",new THREE.BufferAttribute(o,3));const s=new Ao({depthTest:!1,side:THREE.DoubleSide,color:this.getLinearColor(i)}),r=new THREE.Mesh(n,s),a=new THREE.Vector3(...Object.values(t)).normalize(),l=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),a);r.applyQuaternion(l);const h=new THREE.Vector3(...Object.values(e));return r.position.set(h.x,h.y,h.z),r.scale.set(.8,.8,.8),r.renderOrder=CLOUD.EnumRenderOrder.Effect+1e3,r.updateMatrixWorld(!0),r}updateScaleFactor(e,t){}updateDirection(e){if(!e)return;const t=this.control.object3D.quaternion.clone().invert();this.directionQuaternion=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),this.direction.clone().normalize());const i=new THREE.Vector3(0,1,0).applyQuaternion(this.directionQuaternion),n=new THREE.Plane(new THREE.Vector3(...Object.values(this.direction)).normalize()),o=new THREE.Vector3;n.projectPoint(e.clone().applyQuaternion(t),o);const s=(new THREE.Quaternion).setFromUnitVectors(i,o.normalize()).multiply(this.directionQuaternion.clone());this.arrow.quaternion.set(s.x,s.y,s.z,s.w),this.arrow.updateMatrixWorld(!0),this.object3D.updateMatrixWorld()}}class Ao{constructor(e){let t=new THREE.ShaderMaterial({type:"BasicMaterial",uniforms:THREE.UniformsUtils.clone(THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog])),fragmentShader:"\n uniform vec3 diffuse;\n uniform float opacity;\n\n void main() {\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <alphatest_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n\n }\n ",clipping:!1});return Object.defineProperties(t,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}}}),t.setValues(e),t}}class Vo extends yo{constructor(e){super(e),this.name="slope",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Slope,this.maxPointsNum=1,this.measurePoints=[],this.helper=e.helper,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e),this.endDraw(),this.unselect(),this.updateScaleFactor()}draw(e){this.drawCaptureItem(e)}drawCaptureItem(e){let t=this.hoverPanel,i=this.hoverPanelSize;if("Panel"===e.hoverObjectType){let n=e.clientPts,o=n[0].distanceTo(n[1]),s=n[0].distanceTo(n[3]),r=o/i.width,a=s/i.height;if(1!=r){let e=this.stretchOnDirection(n[0],n[1],i.width),t=this.stretchOnDirection(n[2],n[3],i.width);n=e.concat(t)}if(1!=a){let e=this.stretchOnDirection(n[0],n[3],i.height),t=this.stretchOnDirection(n[1],n[2],i.height);n=[e[0],t[0],t[1],e[1]]}let l="";for(let e=0;e<n.length;e++)l+=n[e].x+",",l+=n[e].y+" ";t.setAttribute("points",l),e.svg.appendChild(t)}}endDraw(){this.isEndDrawing=!0,this.point=new bo({control:this,name:"point",viewer:this.viewer,point:this.viewer.worldToScene(this.slopePoint),bgColor:this.color}),this.add(this.point),this.pointUnselect=new bo({control:this,name:"pointUnselect",viewer:this.viewer,point:this.viewer.worldToScene(this.slopePoint),noBorder:!0,bgColor:this.color,borderColor:this.color}),this.add(this.pointUnselect);let e=new THREE.Object3D,t=this.viewer.worldToScene(this.slopePoint),i=this.viewer.worldToScene(this.slopeDir),n=new THREE.Vector3(0,0,0).clone().add(i.normalize().clone().multiplyScalar(90));this.line=new Eo({control:this,name:"line",viewer:this.viewer,points:[new THREE.Vector3(0,0,0),n],color:this.color,linewidth:this.linewidth}),e.add(this.line.object3D),this.arrow=new Do({control:this,name:"arrow",viewer:this.viewer,point:n,direction:this.viewer.worldToScene(this.slopeDir),color:this.color}),e.add(this.arrow.object3D),this.obj3d=e,this.obj3d.position.set(t.x,t.y,t.z),this.object3D.add(e);let o=new THREE.Vector3(0,0,0).clone().add(i.normalize().clone().multiplyScalar(100)),s=new THREE.Vector3(o.x,0,o.z);o.angleTo(s)>.01&&(this.dashLine=new Eo({control:this,name:"Line",viewer:this.viewer,isNotHitTest:!0,points:[new THREE.Vector3(0,0,0),s],color:"#7CCF21",linewidth:2,dashed:!0,dashSize:.4,gapSize:.4}),e.add(this.dashLine.object3D)),s.length()>20&&o.angleTo(s)>.01&&this.addCurve([o,new THREE.Vector3(0,0,0),s]);let r=this.viewer.worldToClient(this.slopePoint);this.attachNotation([r,r]),this.updateScaleFactor()}addCurve(e){let t=(new THREE.Plane).setFromCoplanarPoints(e[0],e[1],e[2]),i=t.normal.z<0?t.normal:new THREE.Vector3(-t.normal.x,-t.normal.y,-t.normal.z),n=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),i);var o=new THREE.Vector3(1,0,0).clone().applyQuaternion(n),s=e[0].clone().sub(e[1].clone()),r=o.angleTo(s);o.clone().cross(s).z>=0&&(r=2*Math.PI-r);var a,l=e[2].clone().sub(e[1].clone()),h=o.angleTo(l);(o.clone().cross(l).z>0&&(h=2*Math.PI-h),r>h)?a=l.clone().cross(s).z>=0?r:h:a=s.clone().cross(l).z>0?h:r;this.curve&&this.remove(this.curve);let d=e[1].clone().sub(e[0].clone()).angleTo(e[1].clone().sub(e[2].clone()));this.curve=new Po({control:this,name:"arc",viewer:this.viewer,center:e[1],radius:18,thetaStart:a,thetaLength:d,material:{color:this.color},quaternion:n}),this.obj3d.add(this.curve.object3D)}updateResult(){this.isSelected?this.select():this.unselect()}getInfo(){return{id:this.id,slope:this.slope,point:this.slopePoint,normal:this.slopeNormal,type:this.type}}setData(e){this.info=e,this.id=e.id,this.slope=e.slope,this.slopePoint=e.point,this.slopeNormal=e.normal,this.slopeDir=e.slopeDir}getMeasureResult(){return this.slope+" %"}select(){super.select(),this.point.object3D.visible=!0,this.pointUnselect.object3D.visible=!1,this.notation.select(),this.dashLine&&(this.dashLine.object3D.visible=!0),this.curve&&(this.curve.object3D.visible=!0),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.point.object3D.visible=!1,this.pointUnselect.object3D.visible=!0,this.notation.unselect(),this.dashLine&&(this.dashLine.object3D.visible=!1),this.curve&&(this.curve.object3D.visible=!1),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}hitTest(e,t){let i=null;this.children.some((n=>{const o=n.hitTest(e,t);return o&&(i=n),o})),this.hoveredObject=i;let n=this.hitTestArrow(e,t);return this.hoveredObject?!!this.hoveredObject:n||this.notation.hitTest(t)}hitTestArrow(e,t){if(!this.slopePoint||!this.worldPoint2)return!1;let i=this.viewer.worldToClient(this.slopePoint),o=this.viewer.worldToClient(this.worldPoint2);var s=new n(i.x,i.y),r=new n(o.x,o.y);return re.distanceToSegment(t,s,r)<=10}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.point&&this.point.updateScaleFactor(t,i),this.pointUnselect&&this.pointUnselect.updateScaleFactor(t,i),this.arrow&&this.arrow.updateDirection(i),this.obj3d&&this.updateScaleFactorArrow(t,i)}updateScaleFactorArrow(e,t){e=e||this.getCloudViewer().camera.position.clone(),t=t||this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize();var i=this.viewer.worldToScene(this.slopePoint),n=e.clone().sub(i.clone()).length(),o=t.angleTo(i.clone().sub(e.clone()));n=Math.sin(Math.PI/2-o)*n,this.getCloudViewer().camera.isPerspective||(n=this.getOrthogonalityCameraScaleValue());var s=1*n/this.getCloudViewer().domElement.offsetHeight;this.obj3d.scale.set(s,s,s),this.obj3d.updateMatrixWorld();let r=this.viewer.worldToScene(this.slopePoint),a=this.viewer.worldToScene(this.slopeDir),l=r.clone().add(a.normalize().clone().multiplyScalar(90*s)),h=this.viewer.sceneToWorld(l);this.worldPoint2=h,this.updateNotationPosition({x:(this.slopePoint.x+h.x)/2,y:(this.slopePoint.y+h.y)/2,z:(this.slopePoint.z+h.z)/2})}updateNotationPosition(e){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[e,e]))}}class Ro extends vo{constructor(e){super(e)}init(){const{points:e,color:t,opacity:i}=this.getConfig();this.color=t,this.opacity=i||1,this.trangles=[],this.trangleArr=re.getAllTriangle(e);for(let e=0;e<this.trangleArr.length;e++)this.drawTrangle(this.trangleArr[e][0],this.trangleArr[e][1],this.trangleArr[e][2]);super.init()}drawTrangle(e,t,i){const n=new THREE.BufferGeometry,o=new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z,i.x,i.y,i.z]);n.setAttribute("position",new THREE.BufferAttribute(o,3)),n.computeVertexNormals();const s=new THREE.MeshBasicMaterial({color:this.getLinearColor(this.color),depthTest:!1,depthWrite:!0,side:2,transparent:!0,opacity:this.opacity}),r=new THREE.Mesh(n,s);r.renderOrder=CLOUD.EnumRenderOrder.Effect,r.position.set(0,0,0),r.name="drawTrangle",this.trangles.push(r),this.object3D.add(r),this.object3D.updateMatrixWorld()}updatePosition(e){this.getConfig().position=e,this.position.set(e.x,e.y,e.z),this.updateMatrixWorld(!0)}getArea(){let e=0;for(let t=0;t<this.trangleArr.length;t++){e+=(new THREE.Triangle).set(this.viewer.sceneToWorld(this.trangleArr[t][0]),this.viewer.sceneToWorld(this.trangleArr[t][1]),this.viewer.sceneToWorld(this.trangleArr[t][2])).getArea()}return e}update(e){this.trangles.length>0&&(this.trangles.forEach((e=>{this.object3D.remove(e),e.geometry.dispose()})),this.trangles=[]),this.getConfig().points=e,this.trangleArr=re.getAllTriangle(e);for(let e=0;e<this.trangleArr.length;e++)this.drawTrangle(this.trangleArr[e][0],this.trangleArr[e][1],this.trangleArr[e][2])}}class Oo extends yo{constructor(e){super(e),this.name="spatialArea",this.type=Glodon.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea,this.maxPointsNum=1e4,this.points=[],this.unselectPoints=[],this.lines=[],this.lastLine=null,this.spaceShape=null,this.triangles=[],this.lastTriangles=null,this.measurePoints=[],this.canEdit=!0,this.firstUpdate=!0,this.addHelperEvent("CameraChanged",(e=>this.updateScaleFactor(e)))}initByData(e){this.id=e.id,this.setData(e);for(let e=0;e<this.measurePoints.length;e++){const t=new bo({control:this,name:"point-"+e,viewer:this.viewer,point:this.viewer.worldToScene(this.measurePoints[e]),bgColor:this.color});let i,n;this.add(t),this.points.push(t),e===this.measurePoints.length-1?(i=this.measurePoints[0],n=this.measurePoints[e]):(i=this.measurePoints[e],n=this.measurePoints[e+1]);const o=new Eo({control:this,name:"line"+e,viewer:this.viewer,points:[this.viewer.worldToScene(i),this.viewer.worldToScene(n)],color:this.color,linewidth:this.linewidth});this.add(o),this.lines.push(o)}this.endDraw(),this.unselect()}draw(e){if(!this.getIsReserverd())switch(this._svg=e.svg,this.drawCaptureItem(e),e.clientPoints.length){case 0:break;case 1:if(!this.points[e.clientPoints.length-1]){const t=this.points[e.clientPoints.length-1]=new bo({control:this,name:"point-"+(e.clientPoints.length-1),viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.add(t)}if(this.lines[e.clientPoints.length-1])this.lines[e.clientPoints.length-1].update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[e.clientPoints.length-1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]);else{const t=this.lines[e.clientPoints.length-1]=new Eo({control:this,name:"line"+e.clientPoints.length,viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[e.clientPoints.length-1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth});this.add(t)}this.object3D.updateMatrixWorld(),this.viewer.getViewer().render();break;default:if(!this.points[e.clientPoints.length-1]){const t=this.points[e.clientPoints.length-1]=new bo({control:this,name:"point-"+(e.clientPoints.length-1),viewer:this.viewer,point:this.viewer.worldToScene(e.worldPosition),bgColor:this.color});this.add(t)}if(this.lines[e.clientPoints.length-1])this.lines[e.clientPoints.length-1].update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[e.clientPoints.length-1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]);else{const t=this.lines[e.clientPoints.length-1]=new Eo({control:this,name:"line"+e.clientPoints.length,viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[e.clientPoints.length-1],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth});this.add(t)}if(this.lastLine?this.lastLine.update([this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)]):(this.lastLine=new Eo({control:this,name:"lastLine",viewer:this.viewer,points:[this.viewer.worldToScene(this.viewer.globalUnitUtil.revertTranslate(this.measurePoints[0],["x","y","z"])),this.viewer.worldToScene(e.worldPosition)],color:this.color,linewidth:this.linewidth}),this.add(this.lastLine)),e.clientPoints.length>=2){let t=[],i=[];if(this.measurePoints.map((e=>i.push(this.viewer.globalUnitUtil.revertTranslate(e,["x","y","z"])))),i.push(e.worldPosition),i.map((e=>t.push(this.viewer.worldToScene(e)))),this.spaceShape)this.spaceShape.update(t);else{let e=this.spaceShape=new Ro({control:this,name:"spaceShape",viewer:this.viewer,points:t,color:this.color,linewidth:this.linewidth,opacity:.3});this.add(e)}let n=this.spaceShape.getArea();this.measureResult=n,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let o=this.viewer.worldToClient(e.worldPosition);this.attachNotation([o,o]),this.notation.select()}this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}}endDraw(){this.isEndDrawing=!0,this.lastLine&&this.remove(this.lastLine),this.lines[this.lines.length-1].update([this.viewer.worldToScene(this.measurePoints[0]),this.viewer.worldToScene(this.measurePoints[this.measurePoints.length-1])]);let e=[];if(this.measurePoints.map((t=>e.push(this.viewer.worldToScene(t)))),this.spaceShape)this.spaceShape.update(e);else{let t=this.spaceShape=new Ro({control:this,name:"spaceShape",viewer:this.viewer,points:e,color:this.color,linewidth:this.linewidth,opacity:.3});this.add(t)}this.measurePoints.map((e=>{let t=new bo({control:this,name:"pointUnselect",viewer:this.viewer,point:this.viewer.worldToScene(e),noBorder:!0,bgColor:this.color,borderColor:this.color});t.object3D.visible=!1,t.hitTest=()=>!1,this.add(t),this.unselectPoints.push(t)})),this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let t=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([t,t]),this.notation.select()}update(e){this.firstUpdate&&(this.select(),this.firstUpdate=!1);let t=+this.selectChild.name.split("-")[1];this.measurePoints[t]=e,this.selectChild.update(this.viewer.worldToScene(e)),this.unselectPoints[t].update(this.viewer.worldToScene(e));for(let e=0;e<this.measurePoints.length;e++){let t,i;e===this.measurePoints.length-1?(t=this.measurePoints[0],i=this.measurePoints[e]):(t=this.measurePoints[e],i=this.measurePoints[e+1]),this.lines[e].update([this.viewer.worldToScene(t),this.viewer.worldToScene(i)])}let i=[];this.measurePoints.map((e=>i.push(this.viewer.worldToScene(e)))),this.spaceShape.update(i);let n=this.spaceShape.getArea();this.measureResult=n,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear());let o=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([o,o]),this.notation.select(),this.updateScaleFactor(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render(),this.measure.getEventManager().fireEvent(Glodon.Bimface.Plugins.Measure.MeasureEvent.MeasureResultUpdating,this.getInfo())}endUpdate(){this.firstUpdate=!0,this.info.area=this.measureResult,this.info.points=this.measurePoints}updateResult(){this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear();let e=this.viewer.worldToClient(this.measurePoints[this.measurePoints.length-1]);this.attachNotation([e,e]),this.isSelected?this.select():this.unselect(),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}getInfo(){return{id:this.id,area:this.measureResult,points:this.measurePoints,type:this.type}}setData(e){this.info=e,this.id=e.id,this.measureResult=e.area,this.measurePoints=e.points,this.setMeasureParams({precision:e.precision,scale:e.scale,unit:e.unit,defaultUnit:e.defaultUnit})}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=Bn.formatArea(t,this.measureParams),t+=Bn.getPostFix(e,!0),`${BimfaceLanguage.bf_panel_measure_spatial_area}:`+t}select(){super.select(),this.notation.select(),this.points.forEach((e=>{e.object3D.visible=!0})),this.unselectPoints.forEach((e=>{e.object3D.visible=!1})),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}unselect(){super.unselect(),this.notation.unselect(),this.points.forEach((e=>{e.object3D.visible=!1})),this.unselectPoints.forEach((e=>{e.object3D.visible=!0})),this.object3D.updateMatrixWorld(),this.viewer.getViewer().render()}updateScaleFactor(e){let t,i;e?(t=e.cameraPosition,i=e.cameraDirection):(t=this.getCloudViewer().camera.position.clone(),i=this.getCloudViewer().camera.target.clone().sub(this.getCloudViewer().camera.position).normalize()),this.points.forEach((e=>e.updateScaleFactor(t,i))),this.unselectPoints.forEach((e=>e.updateScaleFactor(t,i))),this.updateNotationPosition()}updateNotationPosition(){this.isEndDrawing&&(this.notation.notationSegmentRects=[],this.updateNotationPositionFun(this.notationGroup,[this.measurePoints[this.measurePoints.length-1],this.measurePoints[this.measurePoints.length-1]]))}reset(){this.children=[],this.measurePoints=[],this.points=[],this.unselectPoints=[],this.lines=[],this.lastLine=null,this.spaceShape=null,this.triangles=[],this.lastTriangles=null,this.notationGroup.length>0&&(this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear()),this.notationGroup=[],this.object3D.clear()}redo(){this.measurePoints.length>0&&(this.measurePoints.length<=1&&this.reset(),this.remove(this.points[this.points.length-1]),this.remove(this.lines[this.lines.length-1]),this.lines.pop(),this.points.pop(),1===this.points.length&&(this.remove(this.lastLine),this.remove(this.spaceShape),this.detach(this.notationGroup),this.notationGroup=[],this.notation.clear(),this.spaceShape=null,this.lastLine=null)),super.redo()}}class ko{constructor(e,t,i){this.domContainer=e,this.viewer=t,this.measure=i,this.viewId=0,this.itemList=[],this.mapMeasureInfo={},this.initShadowManager(),this.drawableFactory=new Qn(t,i),this.hookViewer3DEvents(),this.controlObj={[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Distance]:Co,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance]:To,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Angle]:Io,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Elevation]:So,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Volume]:Bo,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance]:Lo,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.Slope]:Vo,[Glodon.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea]:Oo}}hookViewer3DEvents(){this.selectionControl=new go(this.domContainer,this.itemList,this),this.selectionControl.selectionChanged=e=>{if(e){let t=this.mapMeasureInfo[e.getId()];if(t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t),this.bringToFront(e),this.itemClickCallback){let t=this.mapMeasureInfo[e.getId()];this.itemClickCallback(t)}}else this.eventListener.fireEvent("MeasureUnselected",{})},this.selectionControl.hoverChanged=e=>{e?(this.measure.disableMeasureCursor(),this.measure.setIsEnableSnap(!1)):e&&!this.measure.isMeasureOpen()||(this.measure.enableMeasureCursor(),this.measure.setIsEnableSnap(!0))},this.viewer.addEventListener("Rendered",(()=>{this.update(),this.selectionControl&&this.selectionControl.measureUpdateManage.update()})),document.addEventListener("keyup",(e=>{if(46===e.keyCode){let e=this.selectionControl.getSelectedItem();e&&(this.eventListener.fireEvent("MeasureSelected",{type:e.getType(),isDataEmpty:!0}),this.removeItemById(e.getId()),this.selectionControl.setSelectedItem(null))}})),(!this.isViewer3D()||this.measure._opt.isCreateByUI)&&this.viewer.addEventListener("ButtonOnToolbarClicked",(e=>{if("LeftSubToolbar"===e.id&&(this.selectionControl.setSelectedItem(null),this.showExclusiveByViewId(e.viewId),this.viewId=e.viewId),"Measure"===e.id){let t=this.selectionControl.getSelectedItem();if(e.isChecked){if(this.showAll(),t){let e=this.mapMeasureInfo[t.getId()];e.type=t.getType(),t&&t.actionWhenSelected(),this.eventListener.fireEvent("MeasureSelected",e)}}else this.hideAll(),t&&t.actionWhenUnselected()}}))}addItem(e){let t=e.type,i=e.id;if(this.mapMeasureInfo[i])return;this.mapMeasureInfo[i]=e,e.filterUrl=this.dropShadowManager.getFilterUrl();const n=this.measure.getMeasureParams();for(let t in n)e.hasOwnProperty(t)||(e[t]=n[t]);if(this.isViewer3D())return this.measure.measureItem.setData(e),this.measure.measureItem.endDraw(),this.measure.measureItem.select(),this.selectionControl.setSelectedItem(this.measure.measureItem),void(n.minimumDistanceZoom&&"MinimumDistance"===t&&this.viewer.getCamera().zoomToBoundingBox(e.boundingBox));let o=this.drawableFactory.make(t,e,i,this.measure);"ViewerDrawing"===this.viewer.getViewerType()&&o.setViewId&&o.setViewId(this.viewId),o.attach(this.domContainer),o.select(),this.selectionControl.setSelectedItem(o),this.itemList.push(o)}removeItemById(e){this.mapMeasureInfo[e]&&(this.isViewer3D()&&this.measure.measureHelper.removeById(e),delete this.mapMeasureInfo[e]);for(var t=0;t<this.itemList.length;t++)if(this.itemList[t].getId()===e){this.itemList[t].clear(!0),this.itemList.splice(t,1);break}}removeItemsByType(e){if(this.isViewer3D())return this.measure.measureHelper.children.map((t=>{t.type==e&&delete this.mapMeasureInfo[t.id]})),void this.measure.measureHelper.removeByType(e);for(var t=0;t<this.itemList.length;t++)this.itemList[t].type===e&&(this.mapMeasureInfo[this.itemList[t].id]&&delete this.mapMeasureInfo[this.itemList[t].id],this.itemList[t].clear(!0),this.itemList.splice(t,1))}update(){this.clear();for(const e of this.itemList)e.initialize(),e.attach(this.domContainer),e.dropShadow(this.dropShadowManager.getFilterUrl());this.selectionControl.hasSelected()&&!this.isViewer3D()&&this.selectionControl.getSelectedItem().select()}clear(e){for(const t of this.itemList)t.clear(e);e&&(this.itemList.length=0,this.selectionControl.setSelectedItem(null),this.eventListener.fireEvent("MeasureUnselected",{}),this.mapMeasureInfo={}),e&&this.isViewer3D()&&this.measure.measureHelper.removeAllDrawFinished()}unselctedAll(){for(const e of this.itemList)e.unselect();this.isViewer3D()&&this.measure.measureHelper.unselctedAll(),this.selectionControl.selectedItem=null}isViewer3D(){return"Viewer3D"==this.measure._opt.viewer.viewerType}hideAll(){for(const e of this.itemList)e.measureSurfaceMesh&&e.measureSurfaceMesh.hide();this.domContainer.style.display="none",this.isViewer3D()&&this.measure.measureHelper.hideAll()}showAll(){for(const e of this.itemList)e.measureSurfaceMesh&&e.measureSurfaceMesh.show();this.domContainer.style.display="block",this.update(),this.isViewer3D()&&this.measure.measureHelper.showAll()}onClick(e){e&&(this.itemClickCallback=e)}save(){let e=[],t=Object.keys(this.mapMeasureInfo);for(const i of t)e.push(this.mapMeasureInfo[i]);return e}load(e){for(var t=0;t<e.length;t++){var i=e[t];this.isViewer3D()?this.addMeasureControl(i):this.addItem(i)}this.unselctedAll()}addMeasureControl(e){let t=e.type,i=e.id;if(this.mapMeasureInfo[i])return;this.mapMeasureInfo[i]=e;const n=this.measure.getMeasureParams();for(let t in n)e.hasOwnProperty(t)||(e[t]=n[t]);var o=Object.assign({measure:this.measure,helper:this.measure.measureHelper},this.measure._opt),s=new this.controlObj[t](o);s.initByData(e),this.measure.measureHelper.add(s)}setEventListener(e){this.eventListener=e,this.eventListener.addEvent("Measuring",(()=>{this.selectionControl.setSelectedItem(null),this.setIsEnableSelection(!1)})),this.eventListener.addEvent("Measured",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("Reset",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("MeasureParamsUpdated",(()=>{this.measure.measureItem&&this.measure.measureItem.setMeasureParams(this.measure.getMeasureParams());for(const e of this.itemList){let t=this.measure.getMeasureParams(e.type);e.setMeasureParams(t),this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit,this.mapMeasureInfo[e.id].enableAuxiliaryValue=t.enableAuxiliaryValue||!1,this.mapMeasureInfo[e.id].laserXYZ=t.laserXYZ,this.mapMeasureInfo[e.id].minimumDistanceZoom=t.minimumDistanceZoom}if(this.isViewer3D()&&this.measure.measureHelper.children.map((e=>{if(e.isEndDrawing){let t=this.measure.getMeasureParams(e.type);e.setMeasureParams(t),this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit,this.mapMeasureInfo[e.id].enableAuxiliaryValue=t.enableAuxiliaryValue||!1,this.mapMeasureInfo[e.id].laserXYZ=t.laserXYZ,this.mapMeasureInfo[e.id].minimumDistanceZoom=t.minimumDistanceZoom,e.updateResult()}})),this.update(),this.selectionControl.hasSelected()){let e=this.selectionControl.getSelectedItem(),t=this.mapMeasureInfo[e.getId()];t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t)}}))}bringToFront(e){if(!this.isViewer3D()){for(var t=0;t<this.itemList.length;t++)if(this.itemList[t].getId()===e.getId()){this.itemList.splice(t,1);break}e.detach(),this.itemList.push(e),e.attach(this.domContainer)}}initShadowManager(){this.dropShadowManager=new po({filterId:"dropShadow",filterUnits:"userSpaceOnUse",stdDeviation:"2",feOffset1:{dx:5,dy:5},feOffset2:{dx:-5,dy:-5},opacity:"0.3"}),this.dropShadowManager.attach(this.domContainer)}getSelectedItem(){return this.selectionControl.getSelectedItem()}showExclusiveByViewId(e){for(const t of this.itemList)t.getViewId()===e?t.show():t.hide()}setIsEnableSelection(e){this.selectionControl.setIsEnableSelection(e)}}class Ho{constructor(e){this.group=new CLOUD.ObjectGroup,this.children=[],this.name="MeasureHelper",this.viewer=e,this.viewer.registerEventListener(CLOUD.EVENTS.ON_CAMERA_CHANGED_AND_RENDERED,this.cameraChangedUpdate.bind(this)),this.updateFun=this.updateMaterialResolution.bind(this),window.addEventListener("resize",this.updateFun)}cameraChangedUpdate(){const e=this.viewer.camera.target.clone().sub(this.viewer.camera.position).normalize(),t=this.viewer.camera.position.clone(),i=this.viewer.camera.fov;this.group.dispatchEvent({type:"CameraChanged",cameraDirection:e,cameraPosition:t,cameraFov:i})}add(e){this.children.push(e),this.group.add(e.object3D)}remove(e){for(let t=0;t<this.children.length;t++)if(this.children[t]===e){this.group.remove(e.object3D),e.destroy(),this.children.splice(t,1);break}}removeAllDrawFinished(){for(let e=0;e<this.children.length;e++)this.children[e].isEndDrawing&&(this.group.remove(this.children[e].object3D),this.children[e].destroy(),this.children.splice(e--,1));this.viewer.render()}removeNotDrawingFinished(){for(let e=0;e<this.children.length;e++)this.children[e].isEndDrawing||(this.group.remove(this.children[e].object3D),this.children[e].destroy(),this.children.splice(e--,1));this.viewer.render()}removeById(e){for(let t=0;t<this.children.length;t++)if(this.children[t].id==e){this.group.remove(this.children[t].object3D),this.children[t].destroy(),this.children.splice(t,1);break}this.viewer.render()}removeByType(e){for(let t=0;t<this.children.length;t++)this.children[t].isEndDrawing&&this.children[t].type==e&&(this.group.remove(this.children[t].object3D),this.children[t].destroy(),this.children.splice(t--,1));this.viewer.render()}showAll(){this.group.visible=!0,this.viewer.render(),this.showLaserClearDistance()}showLaserClearDistance(){this.children.map((e=>{e.isEndDrawing&&"LaserClearDistance"==e.type&&e.showNextButton()}))}hideAll(){this.group.visible=!1,this.viewer.render(),this.hideLaserClearDistance()}hideLaserClearDistance(){this.children.map((e=>{e.isEndDrawing&&"LaserClearDistance"==e.type&&e.hideNextButton()}))}hitTest(e,t){var i=new THREE.Vector2(e.x,e.y),n=this.viewer.cameraControl.getRaycaster(i.x,i.y);let o=n.ray.origin.clone(),s=n.ray.direction.clone();return n.set(o,s),this.children.find((e=>e.hitTest(n,t)))}hitTestPoint(e,t){var i=new THREE.Vector2(e.x,e.y),n=this.viewer.cameraControl.getRaycaster(i.x,i.y);let o=n.ray.origin.clone(),s=n.ray.direction.clone();return n.set(o,s),this.children.find((e=>e.hitTestPoint(n,t)))}unselctedAll(){this.children.map((e=>e.isEndDrawing&&e.unselect()))}updateMaterialResolution(){this.children.map((e=>{e.isEndDrawing&&e.children.map((e=>{e.updateMaterialResolution()}))}))}destroy(){for(;this.children.length>0;)this.children[0].destroy(),this.group.remove(this.children[0].object3D),this.children.splice(0,1);this.viewer.render(),window.removeEventListener("resize",this.updateFun)}}!function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=null,s=[],a=null,l=null,h=[],d=function(t){var n=t.viewer,o=this,s=new e.Web.Lang.EventManager,r=i.create("div","bf-measure-conext");o.isOpen=!1,this.initialElevation=t.initialElevation,n.addEventListener("Rendered",(function(){o.isOpen&&o.update()})),this.measureHelper=new Ho(n.getViewer()),n.getViewer().getInteractionScene().add(this.measureHelper.group),n.addEventListener("MiniMapOperate",(()=>{this.measureHelper.cameraChangedUpdate()})),this.controlObj={[e.Bimface.Plugins.Measure.MeasureTypeOption.Distance]:Co,[e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance]:To,[e.Bimface.Plugins.Measure.MeasureTypeOption.Angle]:Io,[e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation]:So,[e.Bimface.Plugins.Measure.MeasureTypeOption.Volume]:Bo,[e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance]:Lo,[e.Bimface.Plugins.Measure.MeasureTypeOption.Slope]:Vo,[e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea]:Oo},this._measureItemMap={},this.context={rootDomElement:r},this._opt=t,this.getEventManager=function(){return s},this.isEnableSnap=!0,this._p1=new THREE.Vector3,this._p2=new THREE.Vector3;var a=n.getViewer();a.registerEventListener(y.EVENTS.ON_MEASURE_PICK,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(y.EVENTS.ON_VOLUME_MEASURE_END,(function(e){o.isOpen&&o.measureByPoint(e)})),a.registerEventListener(y.EVENTS.ON_MEASURE_RESET,(function(t){if(o.isOpen){if(o.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea&&o.measureItem&&o.measureItem.getPoints().length>2)return void o.measureByInfo(o.getInfo());o.measureItem.reset(),o.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset)}}))};d.prototype={init:function(){var e=this.context,t=this._opt.viewer;t.getDomElement().appendChild(e.rootDomElement);var n=i.createNS("svg","bf-measure-svg"),o=i.createNS("svg","bf-measure-svg");this.measureHelper.svgContainer=o;var s=i.create("div","bf-measure-text");e.rootDomElement.innerHTML="",e.rootDomElement.appendChild(n),e.rootDomElement.appendChild(o),this.drawableManager=new ko(o,t,this),this.drawableManager.setEventListener(this.getEventManager()),this.switchOn(),e.svg=n,e.text=s,t.render()},enableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=`url(${r}),auto`},disableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=""},hideDragButton(){!e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.measureItem&&this.measureItem.hideDragButton&&this.measureItem.hideDragButton()},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),this.enableMeasureCursor();let t=this._opt.viewer.getViewer();if(this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.Volume?(t.editorManager.disableTool(y.EditToolMode.PICK_BY_MEASURE),t.editorManager.enableTool(t,y.EditToolMode.VOLUME_MEASURE)):(t.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),t.editorManager.enableTool(t,y.EditToolMode.PICK_BY_MEASURE)),this._measureItemMap[this.type])this.measureItem=this._measureItemMap[this.type];else{let t=new e.Bimface.Plugins.Measure.MeasureItemConfig;t=Object.assign(t,this._opt,this.getMeasureParams()),t.measure=this,t.measureType=this.type,t.helper=this.measureHelper,this.measureItem=new this.controlObj[this.type](t),this.measureHelper.removeNotDrawingFinished(),this.measureHelper.add(this.measureItem)}},switchOn:function(){this.isOpen||(this.activeByMeasureType(),this.isOpen=!0,this.drawableManager.setIsEnableSelection(!0),this.context.rootDomElement.setAttribute("style","display: block"),this.context.rootDomElement.addClass("bf-measure-conext-open"),this.measureHelper.showAll())},switchOff:function(){if(this.isOpen){this.hideDragButton();var e=this,t=e._opt.viewer.getViewer();this.disableMeasureCursor(),t.editorManager.disableTool(y.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),e.reset(),e.measureItem=null,this.isOpen=!1,this.drawableManager.setIsEnableSelection(!1)}},measureByPoint:function(t){var i=this,r=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),d=i.measureItem;if(t){n=t.pickPoint?t.pickPoint:null,t.pointType?a=t.pointType:t.pickPlane?(a="Panel",l=t.normal):t.pickLine?(a="Line",s=t.pickLine):a=t.pickPoint?"Point":null;var c=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume;if(t.pick&&t.pickPoint||c){var u=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation,g=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance;const n=this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance;if(u)d.redo(),d.addPoint(t.pickPoint),d.draw(this.context);else if(g&&t.userId&&t.modelId){const e=this.drawableManager.selectionControl.selectedItem;e&&e.name!==this.type&&this.drawableManager.selectionControl.setSelectedItem(null),d.addPoint({userId:t.userId,modelId:t.modelId})}else{if(!(!g||t.userId&&t.modelId))return void i.update();if(c&&t.objectId){for(let i in this.drawableManager.mapMeasureInfo){if(this.drawableManager.mapMeasureInfo[i].type!==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume)continue;let n=this.drawableManager.mapMeasureInfo[i].points[0];if(n.modelId===t.modelId&&n.userId===t.objectId){this.drawableManager.removeItemById(i);break}}this.volumeResult=t.volume,this.volumePosition=t.position,d.addPoint({userId:t.objectId,modelId:t.modelId})}else if(n)t.userId&&d.addPoint({componentId:t.userId,modelId:t.modelId,point:t.pickPoint});else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Slope){if(!t.pickPlane)return void i.update();d.addPoint({normal:t.normal,point:t.pickPoint})}else this.type,e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea,d.addPoint(this.context.footPoint?o:t.pickPoint),i.update()}var p=d.getPoints();h=d.getPoints(),p.length==d.maxPointsNum?this.measureByInfo(this.getInfo()):(r||(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,i.getInfo()))}else this.isEnableSnap&&i.update()}},measureByInfo(t){const i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();i?t.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance&&this.drawableManager.removeItemsByType(e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance):(this.drawableManager.clear(!0),this.measureHelper.removeAllDrawFinished()),this.drawableManager.addItem(t),i||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,t);let n=new e.Bimface.Plugins.Measure.MeasureItemConfig;n=Object.assign(n,this._opt,this.getMeasureParams()),n.measure=this,n.measureType=this.type,n.helper=this.measureHelper,this.measureItem=new this.controlObj[this.type](n),this.measureHelper.removeNotDrawingFinished(),this.measureHelper.add(this.measureItem)},measureMinimum:function(){},reset:function(){this.isOpen&&(this.measureItem.reset(),this.context.svg.innerHTML="",this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset))},measuringRedo(){this.redo(),this.getInfo().points&&!this.getInfo().points.length&&this.drawableManager.setIsEnableSelection(!0)},measuredRedo(t){if(this.isOpen){const i=this._opt.viewer,n=i.getSelectedComponents();if(this.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance||this.measureItem.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume){const e=h.map((e=>e.userId)),o=n.reduce(((t,i)=>(e.includes(i)||t.push(i),t)),[]);o.length?(i.removeSelectedId(o),i.render()):(i.clearSelectedComponents(),t&&t())}else n.length?(i.clearSelectedComponents(),i.render()):t&&t()}},setIsEnableSnap:function(e){e||(this.context.svg.innerHTML=""),this.isEnableSnap=e},update:function(){var t=this.measureItem,i=this.context,r=this._opt.viewer,h=r.getDomElement(),d=h.getBoundingClientRect(),c=r.getViewer(),u=t.getPoints(),g=[],p=[];if(i.svg.innerHTML="",i.footPoint=null,n?(i.worldPosition=r.globalUnitUtil.revertTranslate(n,["x","y","z"]),i.hoverPosition=c.worldToCanvas(n),i.hoverPositionDS=c.getScene().worldToDrawing(n),0!=u.length&&(g=u.concat([n]))):(i.hoverPosition=null,0!=u.length&&(g=u.concat(u[u.length-1]))),i.hoverObjectType=a,"Line"==a&&2==s.length){i.lineStartPoint=c.worldToCanvas(s[0]),i.lineEndPoint=c.worldToCanvas(s[1]);var m=new THREE.Vector2(i.lineStartPoint.x,i.lineStartPoint.y),f=new THREE.Vector2(i.lineEndPoint.x,i.lineEndPoint.y),w=new THREE.Box2;w.min.set(h.clientLeft,h.clientTop),w.max.set(w.min.x+h.clientWidth,w.min.y+h.clientHeight);var v=!w.containsPoint(m),b=!w.containsPoint(f),E={start:m,end:f},M=y.CameraUtil.lineIntersectWithRect(E,w);if(v&&b)2==M.length&&(i.lineStartPoint=M[0],i.lineEndPoint=M[1]);else if(v||b)for(var C=new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y),x=v?f.clone():m.clone(),T=x.clone().sub(C).normalize(),P=0;P<M.length;P++){if(x.clone().sub(M[P]).normalize().dot(T)>0){i.lineStartPoint=x,i.lineEndPoint=M[P];break}}let e=u[u.length-1];if(e){const{x:t,y:n}=c.worldToCanvas(e),a=new THREE.Vector2(t,n),l=new THREE.Vector2(i.hoverPosition.x,i.hoverPosition.y);if(a.distanceTo(l)>5){let t=s[0].clone(),n=s[1].clone();const a=t.x-n.x,h=t.y-n.y,d=t.z-n.z;let c=(e.x-t.x)*(t.x-n.x)+(e.y-t.y)*(t.y-n.y)+(e.z-t.z)*(t.z-n.z);c/=Math.pow(a,2)+Math.pow(h,2)+Math.pow(d,2);let u=new THREE.Vector3(t.x+c*a,t.y+c*h,t.z+c*d),g=r.worldToClient(u);l.distanceTo(g)<=5&&(i.footPoint=g,i.hoverPosition=g,o=u)}}}if("Panel"==i.hoverObjectType){i.normal=c.getScene().worldToDrawing(l),i.normal.normalize();var I=c.cameraControl,S=new THREE.Plane;S.setFromNormalAndCoplanarPoint(i.normal,i.hoverPositionDS);var B=new THREE.Vector2(i.hoverPosition.x-10,i.hoverPosition.y-10),_=new THREE.Vector2(i.hoverPosition.x+10,i.hoverPosition.y-10),L=i.hoverPositionDS,D=I.getRaycaster(B.x,B.y);if(this._p1=D.ray.intersectPlane(S,this._p1),D=I.getRaycaster(_.x,_.y),this._p2=D.ray.intersectPlane(S,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var A=new THREE.Vector3(1,0,0),V=new THREE.Vector3(0,1,0),R=new THREE.Vector3(0,0,1),O=Math.abs(i.normal.clone().dot(A))<=.0025,k=Math.abs(i.normal.clone().dot(R))<=.0025;if(O&&k)var H=A.clone(),U=R.clone();else H=V.clone().cross(i.normal).normalize(),U=i.normal.clone().cross(H).normalize();var N=this._p1.distanceTo(this._p2)/2,G=H.clone().multiplyScalar(N),j=U.clone().multiplyScalar(N),z=L.clone().sub(G).add(j),F=L.clone().add(G).add(j),W=L.clone().sub(G).sub(j),$=L.clone().add(G).sub(j),X=[];X.push(z,F,$,W);for(var Y=[],Z=I.getContainerDimensions(),q=0;q<X.length;q++){var K=y.CameraUtil.drawingToCanvas(I.camera,X[q],Z.width,Z.height);Y.push(new THREE.Vector3(K.x,K.y,0))}i.clientPts=Y}for(P=0;P<g.length-1;P++){if(ne=c.worldPointsToClient(g[P],g[P+1])){var Q={x:ne.start.x-d.left,y:ne.start.y-d.top};p.push(Q)}}if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance&&u.length==t.maxPointsNum){var J={x:u[1].x,y:u[0].y,z:u[0].z},ee={x:u[1].x,y:u[1].y,z:u[0].z},te=[],ie=[u[0],J,ee,u[1]];for(q=0;q<ie.length-1;q++){var ne;(ne=c.worldPointsToClient(ie[q],ie[q+1]))&&(ne.start.x-=d.left,ne.start.y-=d.top,ne.end.x-=d.left,ne.end.y-=d.top),te.push(ne)}i.auxLines=te}i.clientPoints=p,!this.isSelectItem&&t.draw(i)},getInfo:function(){var t={},i=this.measureItem,n=this._opt.viewer,o=i.getPoints();if(t.type=this.type,t.id=e.Web.Lang.Utility.UUID.createUUID(),this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.LaserClearDistance&&1===o.length)l&&Object.assign(t,i.computeMeasureResult(l));else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.MinimumDistance){if(2==o.length){var s=n.getMinimumComponentDistanceById(`[${o[0].modelId}]${o[0].userId}`,`[${o[1].modelId}]${o[1].userId}`);t.distance=s.minDistance,t.start=s.start,t.end=s.end,t._start=s.start,t._end=s.end,t._distance=s.minDistance}if(t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]),this.getMeasureParams().minimumDistanceZoom&&2==o.length){let e=[];e[0]=n.getModel(o[0].modelId).getBoundingBoxById(o[0].userId),e[1]=n.getModel(o[1].modelId).getBoundingBoxById(o[1].userId);let i={x:Math.min(e[0].min.x,e[1].min.x),y:Math.min(e[0].min.y,e[1].min.y),z:Math.min(e[0].min.z,e[1].min.z)},s={x:Math.max(e[0].max.x,e[1].max.x),y:Math.max(e[0].max.y,e[1].max.y),z:Math.max(e[0].max.z,e[1].max.z)},r=new THREE.Vector3(i.x,i.y,i.z),a=new THREE.Vector3(s.x,s.y,s.z);t.boundingBox=(new THREE.Box3).setFromPoints([r,a])}}else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Volume){let e=n.globalUnitUtil.revertTranslate.bind(n.globalUnitUtil);t.volumeResult=e(e(e(this.volumeResult))),t.volumePosition=e(this.volumePosition),t.notSupport=!this.volumeResult,t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"])}else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation)t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]),t.points.length>0&&(t.elevation=t.points[0].z-n.globalUnitUtil.excute(this.initialElevation,"m",this.getDefaultUnit())),t.initialElevation=this.initialElevation;else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Slope)if(o[0]){let e;if(0===o[0].normal.x&&0===o[0].normal.y)e=new THREE.Vector3(0,-1,0);else{let t=n.globalUnitUtil.revertVector(o[0].normal,["x","y","z"]).normalize(),i=n.globalUnitUtil.revertVector(o[0].point,["x","y","z"]),s=i.clone().add(t.clone().multiplyScalar(10)),r=i.clone().add(new THREE.Vector3(0,0,-1).clone().multiplyScalar(10));e=(new THREE.Plane).setFromCoplanarPoints(i,s,r).normal.clone().cross(t)}var r=e.angleTo(new THREE.Vector3(0,0,-1));r=r>Math.PI/2?Math.PI/2-(Math.PI-r):Math.PI/2-r;let i=Math.tan(r);i=i>10?9.9999:i,t.point=n.globalUnitUtil.revertVector(o[0].point,["x","y","z"]),t.normal=o[0].normal,t.slopeDir=e,t.slope=(100*i).toFixed(2)}else t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]);else if(this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea){t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]);let e=re.calcSpatialArea(t.points);t.area=e}else if(t.points=n.globalUnitUtil.revertTranslate(o,["x","y","z"]),this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance)o&&2==o.length&&(t.distanceX=Math.abs(t.points[1].x-t.points[0].x),t.distanceY=Math.abs(t.points[1].y-t.points[0].y),t.distanceZ=Math.abs(t.points[1].z-t.points[0].z),t.distance=Math.sqrt(Math.pow(t.distanceX,2)+Math.pow(t.distanceY,2)+Math.pow(t.distanceZ,2)));else if(3==o.length){var a=new THREE.Vector3(t.points[0].x-t.points[1].x,t.points[0].y-t.points[1].y,t.points[0].z-t.points[1].z),h=new THREE.Vector3(t.points[2].x-t.points[1].x,t.points[2].y-t.points[1].y,t.points[2].z-t.points[1].z),d=a.angleTo(h);t.angle=180*d/Math.PI}return t},redo:function(){this.measureItem.redo(),this.update(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,this.getInfo())},exit:function(){this.switchOff(),this.context.rootDomElement.setAttribute("style","display: none"),this.context.rootDomElement.removeClass("bf-measure-conext-open"),this.measureHelper.hideAll()},setInitialElevation(e){"number"==typeof e?this.initialElevation=e:this._opt.viewer.console.warn("The data type of initialElevation is wrong")},getInitialElevation(){return this.initialElevation},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return this._opt.viewer._defaultUnit},getEngineUnit:function(){return this._opt.viewer.globalUnitUtil.isBimtilesAsset()?"m":this._opt.viewer.globalUnitUtil.getDefaultUnit()}},t.MeasureViewer3D=d}(),function(){var t="Bimface.Plugins.Measure.MeasureDrawing",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){let i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();this._opt=t,this.isOpen=!1;var n=t.viewer,s=n.getViewer();this.viewer=n,this.viewerDrawing=s,this.domElement=n.getDomElement();var r=new e.Web.Lang.EventManager;let a=this;this.getEventManager=function(){return r},n.setSnapDistance(t.snapDistance);let l=o.createNS("svg","bf-measure-svg");l.style.position="absolute",l.style.left=0,l.style.top=0,l.style.width="100%",l.style.height="100%",s.dom.appendChild(l),this.drawableManager=new ko(l,n,this),this.drawableManager.setEventListener(r),n.addEventListener("Measured",(t=>{if(!t)return;i||this.drawableManager.clear(!0),t.id=e.Web.Lang.Utility.UUID.createUUID(),this.drawableManager.addItem(t),i||this.drawableManager.unselctedAll();let o=t.type,{type:s,id:r,points:l}=t,h={type:s,id:r,points:l};h[o.toLowerCase()]=t[o.toLowerCase()],h.type=o,a.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,h),delete n.isMeasuring})),n.addEventListener("Measuring",(t=>{i||this.drawableManager.clear(!0),t.id=e.Web.Lang.Utility.UUID.createUUID(),a.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,t),n.isMeasuring=!0})),n.addEventListener("Reset",(()=>{this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset),delete n.isMeasuring}))};s.prototype={init:function(e){i.send(t,"init");e&&(this._callback=e),this.switchOn()},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||this.drawableManager.clear(!0);let t=this.viewerDrawing.mouseEditorMgr,i={color:`#${this._opt.color.getHEX()}`};this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance&&(i.measureResultFormat=Bn,i.measure=this,i.totalLengthText=BimfaceLanguage.bf_panel_measure_total_distance),t.activeEditorByName(`${this.type}Measure`,i)},switchOn:function(){i.send(t,"switchOn"),this.isOpen||(this.isOpen=!0,this.enableMeasureCursor(),this.activeByMeasureType(),this.drawableManager.setIsEnableSelection(!0))},enableMeasureCursor:function(){this.domElement.firstElementChild.style.cursor=`url(${r}),auto`},enableOcclusionCursor:function(){this.domElement.firstElementChild.style.cursor=`url(${h}),auto`},disableMeasureCursor:function(){this.domElement.firstElementChild.style.cursor=""},switchOff:function(){i.send(t,"switchOff"),this.isOpen&&(this.isOpen=!1,this.disableMeasureCursor(),this.measureItem=null,this.viewerDrawing.mouseEditorMgr.editors.forEach((e=>{e.auxMobileMeasureTool&&(e.auxMobileMeasureTool.center=null)})),this.viewerDrawing.mouseEditorMgr.activeEditorByName("pick"),this.drawableManager.setIsEnableSelection(!1))},reset:function(){i.send(t,"reset");var n=this.viewerDrawing.mouseEditorMgr.getEditor();n.reset&&n.reset(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset),this.viewerDrawing.update()},update:function(){i.send(t,"update")},exit:function(){i.send(t,"exit"),this.switchOff()},isMeasureOpen:function(){return this.isOpen},setIsEnableSnap:function(e){let t=this.viewerDrawing.mouseEditorMgr.getEditor();t.setIsEnableSnap&&t.setIsEnableSnap(e)},getDefaultUnit:function(){return null}},n.MeasureDrawing=s}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0!==this.measureEnd||this.measurePoints.length==this.maxPointsNum){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}else this.maxPointsNum=this.measurePoints.length},draw:function(e,t){if(this.measureResult=t,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.getMeasureResult();this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.drawLine([e.clientPoints[0],e.hoverPosition]),this.drawNotations();break;default:for(let t=1;t<e.clientPoints.length;t++)this.drawTerminalPoint(e.clientPoints[t-1]),this.drawLine([e.clientPoints[t-1],e.clientPoints[t]]),this.drawTerminalPoint(e.clientPoints[t]),e.hoverPosition&&t==e.clientPoints.length-1&&this.drawLine([e.clientPoints[t],e.hoverPosition]);this.drawNotations()}},drawNotations(){let e=[...this.measurePoints];this.hoverPositionUpdated&&this.nextMeasurePoint&&e.push(this.nextMeasurePoint);const t=e.length,i=this.getMeasureResult();for(let n=1;n<t;n++){let t={x:(e[n].x+e[n-1].x)/2,y:(e[n].y+e[n-1].y)/2,z:(e[n].z+e[n-1].z)/2},o=this.viewer.worldToClient(t);this.viewer.isInViewFrustum(t)&&this.drawNotation([o,o],i.distance[n-1])}let n={x:e[t-1].x,y:e[t-1].y,z:e[t-1].z},o=this.viewer.worldToClient(n);this.viewer.isInViewFrustum(n)&&this.drawNotation([o,o],`总长度:${i.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)},getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=Bn.formatDistance(o,this.measureParams),o+=Bn.getPostFix(e,!1),{distance:n,totalDistance:o}}};n.prototype=Object.assign(n.prototype,o),i.MeasurePolylineDistanceItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){i.MeasureItem.call(this,t),this.viewer=t.viewer,this.maxPointsNum=1;var o=new e.Web.Graphics.Color(17,218,183,.2),s=n.createNS("circle","bf-measure-handle");s.setAttribute("r",t.width),s.setAttribute("fill",o.getRGB()),s.style.fill=o.getRGB();var r=n.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=o.getRGB();var a=n.createNS("polygon","bf-measure-rect");a.setAttribute("fill",o.getRGBA()),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",1),this.hoverLine=r,this.hoverPoint=s,this.hoverPanel=a,this.hoverPanelSize={width:20,height:20}};t.Type.inheritPrototype(o,i.MeasureItem);o.prototype=Object.assign(o.prototype,{draw:function(e){this.drawCaptureItem(e)}}),i.MeasurePositionItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e)});t.Type.inheritPrototype(n,i.MeasureItem);var o={draw:function(e,t){const i=this.measurePoints,n=this.nextMeasurePoint;if(this._svg=e.svg,this.measureResult={distance:t.distance,horizontalDistance:t.horizontalDistance,verticalDistance:t.verticalDistance},this.drawCaptureItem(e),this.getIsReserverd()||0==i.length)return;let o=i.concat([n]),s=this.getMeasureResult(),r=this.calcLine(o[0],o[1]);if(this.drawTerminalPoint(r[0]),this.drawBorderlineByPoints(o,s.distance),o[0].z!=o[1].z){let e=o[0].z<o[1].z?o[0]:o[1],t=o[0].z<o[1].z?o[1]:o[0],i=this.calcTrianglePoint(o);this.drawBorderlineByPoints([e,i],s.verticalDistance),this.drawBorderlineByPoints([t,i],s.horizontalDistance)}else this.drawBorderlineByPoints([o[0],o[0]],s.horizontalDistance)},calcTrianglePoint(e){if(e.length<2)return null;let t=new THREE.Vector3;return e[0].z<e[1].z?t.set(e[0].x,e[0].y,e[1].z):e[0].z>e[1].z&&t.set(e[1].x,e[1].y,e[0].z),t},drawBorderlineByPoints(e,t){let i=e[0],n=e[1],o=this.calcLine(i,n);this.drawLine(o);let s={x:(i.x+n.x)/2,y:(i.y+n.y)/2,z:(i.z+n.z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.drawNotation([r,r],t)},drawNotation:function(e,t){if(0===e.length)return;let i=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id);for(const e of i)this._svg.appendChild(e)},getMeasureResult:function(){const e=this.measureParams.unit;let{distance:t,horizontalDistance:i,verticalDistance:n}=this.measureResult;return t=t.toString(),t=Bn.formatDistance(t,this.measureParams),t+=Bn.getPostFix(e,!1),i=i.toString(),i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(e,!1),n=n.toString(),n=Bn.formatDistance(n,this.measureParams),n+=Bn.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}};n.prototype=Object.assign(n.prototype,o),i.MeasureTriangleDistanceItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.measureEnd=!1,this.minPointsNum=3,this.maxPointsNum=1/0});t.Type.inheritPrototype(n,i.MeasureItem);var o={addPoint:function(e){if(!0!==this.measureEnd||this.measurePoints.length==this.maxPointsNum){if(this.measurePoints.length==this.maxPointsNum)this.measureEnd=!1,this.maxPointsNum=1/0,this.measurePoints=[],this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}else this.maxPointsNum=this.measurePoints.length},reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},draw:function(e,t){if(this.measureResult=t.area,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:if(e.hoverPosition){let t=re.makeLine({start:e.clientPoints[0],end:e.hoverPosition,color:this.measureItemConfig.color.getRGBA(),lineWidth:this.measureItemConfig.width});e.svg.appendChild(t)}let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e.clientPoints[0]});t.setAttribute("filter",this.filterUrl),e.svg.appendChild(t);break;default:this.drawArea(e.clientPoints,e.hoverPosition),this.drawNotation(e.hoverPosition,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}},drawArea:function(e,t){const i=t?e.concat(t):e;let n="";i.forEach((e=>{n+=e.x+","+e.y+" "}));let o=re.makePolygon({points:n,width:this.measureItemConfig.width,color:this.measureItemConfig.color.getRGBA(),fillColor:this.measureItemConfig.fillColor.getRGBA()});this._svg.appendChild(o),e.forEach((e=>{let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)}))},drawNotation:function(e,t){let i=this.notation.drawAnnotation({x:e.x,y:e.y},t,this.id,!0);for(const e of i)this._svg.appendChild(e)},getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_spatial_area,getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=Bn.formatArea(t,this.measureParams),t+=Bn.getPostFix(e,!0),t}};n.prototype=Object.assign(n.prototype,o),i.MeasureSpatialAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e)});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_projected_area};n.prototype=Object.assign(n.prototype,o),i.MeasureProjectedAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e),this.defaultColor=e.color,this.fillColor=e.fillColor,this.borderWidth=e.width,this.measureSurfaceMesh=null});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)},draw:function(e,t){if(this.measureResult=t.area,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(this.measurePoints.length){case 0:this.measureSurfaceMesh&&this.measureSurfaceMesh.dispose();break;case 1:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition);break;default:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition),this.drawNotation(e.hoverPosition,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}},drawArea(t,i){const n=this.viewer.getDomElement().getBoundingClientRect&&this.viewer.getDomElement().getBoundingClientRect(),o=n?n.x:0,s=n?n.y:0,r={x:i.x+o,y:i.y+s,z:i.z};let a=this.viewer.clientToWorld(r),l=[...t];l.push(a),this.measureSurfaceMesh||(this.measureSurfaceMesh=new Xn({fillColor:new e.Web.Graphics.Color(255,157,11,.2),color:new e.Web.Graphics.Color(255,157,11,1),width:this.borderWidth})),this.measureSurfaceMesh.setMeasurePoints(l),this.viewer.render()},drawTerminals(e,t){t&&e.concat(t);e.forEach((e=>{let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)}))},getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_surface_area};n.prototype=Object.assign(n.prototype,o),i.MeasureSurfaceAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(t){i.MeasureItem.call(this,t),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2,this.groundInfos=[],this.mesh=null,this.borderColor=t.color||new e.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3,this.groundLineInfos=[],this.lastGroundLineMes={}});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},redo(){this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?(this.measurePoints.pop(),this.groundLineInfos.pop()):this.measurePoints=[],this.groundInfos=[],this.clearGroundLine()},clear:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0===this.measureEnd&&this.measurePoints.length!=this.maxPointsNum)return this.maxPointsNum=this.measurePoints.length,this.groundInfos.length==this.measurePoints.length&&this.groundInfos.pop(),void this.clearGroundLine();if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1),this.measurePoints.length>1&&this.groundLineInfos.push(this.calculateGroundlineDistance(this.measurePoints[this.measurePoints.length-2],this.measurePoints[this.measurePoints.length-1]))},updateGroundLine(e){this.groundLine?this.groundLine.geometry.updateGeometry({points:e}):(this.groundLine=y.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundLine.onAdded()),this.viewer.render()},clearGroundLine(){this.groundLine&&(this.groundLine.onRemoved(),this.groundLine.dispose(),this.groundLine=null)},calculateGroundlineDistance(t,i){if(!t||!i)return null;let n=this.viewer,o=new THREE.Vector3(t.x,t.y,t.z),s=new THREE.Vector3(i.x,i.y,i.z);if(o.equals(s))return null;if(this.lastPoint0&&this.lastPoint1&&o.equals(this.lastPoint0)&&s.equals(this.lastPoint1))return this.lastGroundInfo;let r,a=[];a.push(o),a.push(s),r=new THREE.CatmullRomCurve3(a),r.tension=0,r.type="catmullrom";var l=new y.Raycaster,h=new THREE.Vector3,d=n.getViewer().cameraControl.getIntersectContext(null),c=new y.IntersectHelper(n.getViewer());l.camera=d.camera,l.viewportSize=d.viewportSize;var u=[];r.getPoints(100).forEach((e=>{h.copy(e),(h=n.worldToScene(e)).y=1e4,l.set(h,new THREE.Vector3(0,-1,0));let t=c.getObjectsByRaycaster(d,l,!0);if(t.length>0){let e;e=n.sceneToWorld(t[0].point),u.push(e)}else u.push(e)})),r=null;let g=new e.Bimface.Plugins.Geometry.SplineCurve(u);return g.projectToGround(!0),this.lastPoint0=o,this.lastPoint1=s,this.lastGroundInfo={length:g.length,midPoint:g.getPointByParameter(.5),endPoint:g.getPointByParameter(1),status:"finished"},this.lastGroundInfo},draw:function(e,t){if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.nextMeasurePoint&&this.updateGroundLine([...this.measurePoints,this.nextMeasurePoint]),this.drawNotations();break;default:for(let t=1;t<e.clientPoints.length;t++)this.drawTerminalPoint(e.clientPoints[t-1]),this.drawTerminalPoint(e.clientPoints[t]);this.updateGroundLine([...this.measurePoints,this.nextMeasurePoint]),this.drawNotations()}},drawNotations(){let e=null,t=0,i=[...this.measurePoints,this.nextMeasurePoint];for(let n=0;n<this.groundInfos.length;n++){let o=this.groundInfos[n],s={x:(i[n].x+i[n+1].x)/2,y:(i[n].y+i[n+1].y)/2,z:(i[n].z+i[n+1].z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.drawNotation([r,r],this.formatDistance(o.length)),t+=o.length,n===this.groundInfos.length-1&&(e=i[n+1])}if(e){let i={x:e.x,y:e.y,z:e.z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.drawNotation([n,n],`总长度:${this.formatDistance(t)}`,!0)}this.notation.dropShadow(this.filterUrl)},formatDistance(e){let t=this.measureParams.unit,i=e.toString();return i=Bn.formatDistance(i,this.measureParams),i+=Bn.getPostFix(t,!1),i}};n.prototype=Object.assign(n.prototype,o),i.MeasureGroundlineDistanceItem=n}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=[],s=null,a=null,l=function(t){this.viewer3D=t.viewer;var n=new e.Web.Lang.EventManager,o=i.create("div","bf-measure-conext");this.isOpen=!1,this.context={rootDomElement:o},this._opt=t,this.type=t.measureType,this.getEventManager=function(){return n},this.isEnableSnap=!0,this._p1=new THREE.Vector3,this._p2=new THREE.Vector3};l.prototype={init:function(){var e=this.context,t=this._opt.viewer;t.getDomElement().appendChild(e.rootDomElement);var n=i.createNS("svg","bf-measure-svg"),o=i.createNS("svg","bf-measure-svg"),s=i.create("div","bf-measure-text");e.rootDomElement.innerHTML="",e.rootDomElement.appendChild(n),e.rootDomElement.appendChild(o),this.drawableManager=new ko(o,t,this),this.drawableManager.setEventListener(this.getEventManager()),this._hookEvents(),this.switchOn(),e.svg=n,e.text=s,t.render()},_onViewerRender(){this.isOpen&&this.update()},_onCloudViewerMeasuring(e){this.isOpen&&(this.measureItem.hoverPositionUpdated=!0,this.measureByPoint(e))},_onCloudViewerMeasureReset(t){if(!this.isOpen)return;const i=this.measureItem;this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Position||this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.TriangleDistance||this.type==e.Bimface.Plugins.Measure.MeasureTypeOption.Angle||i.getPoints().length<i.minPointsNum?(i.reset(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset)):i.getPoints().length!=i.maxPointsNum&&(i.measureEnd=!0,this.measureByPoint(t))},_hookEvents(){const t=this.viewer3D,i=t.getViewer();this._onRenderBinded=this._onViewerRender.bind(this),this._onMeasuringBinded=this._onCloudViewerMeasuring.bind(this),this._onMeasureResetBinded=this._onCloudViewerMeasureReset.bind(this),t.addEventListener(e.Bimface.Viewer.Viewer3DEvent.Rendered,this._onRenderBinded),i.registerEventListener(y.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.registerEventListener(y.EVENTS.ON_MEASURE_RESET,this._onMeasureResetBinded)},_unhookEvents(){const t=this.viewer3D,i=t.getViewer();t.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.Rendered,this._onRenderBinded),i.unregisterEventListener(y.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.unregisterEventListener(y.EVENTS.ON_MEASURE_RESET,this._onMeasureResetBinded)},enableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=`url(${r}),auto`},disableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=""},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||this.drawableManager.clear(!0),this.enableMeasureCursor();let t,i=this._opt.viewer.getViewer();this.type===e.Bimface.Plugins.Measure.MeasureTypeOption.Volume?(i.editorManager.disableTool(y.EditToolMode.PICK_BY_MEASURE),i.editorManager.enableTool(i,y.EditToolMode.VOLUME_MEASURE)):(i.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),i.editorManager.enableTool(i,y.EditToolMode.PICK_BY_MEASURE));let n=new e.Bimface.Plugins.Measure.MeasureItemConfig;switch(n=Object.assign(n,this._opt,this.getMeasureParams()),this.type){case e.Bimface.Plugins.Measure.MeasureTypeOption.Angle:t=new e.Bimface.Plugins.Measure.MeasureAngleItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance:t=new e.Bimface.Plugins.Measure.MeasurePolylineDistanceItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Position:t=new e.Bimface.Plugins.Measure.MeasurePositionItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.TriangleDistance:t=new e.Bimface.Plugins.Measure.MeasureTriangleDistanceItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:t=new e.Bimface.Plugins.Measure.MeasureSpatialAreaItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:t=new e.Bimface.Plugins.Measure.MeasureProjectedAreaItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:t=new e.Bimface.Plugins.Measure.MeasureSurfaceAreaItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.GroundlineDistance:t=new e.Bimface.Plugins.Measure.MeasureGroundlineDistanceItem(n);break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Volume:t=new e.Bimface.Plugins.Measure.MeasureVolumeItem(n)}this.measureItem=t},switchOn:function(){this.isOpen||(this.activeByMeasureType(),this.isOpen=!0,this.drawableManager.setIsEnableSelection(!0))},switchOff:function(){if(this.isOpen){var e=this,t=e._opt.viewer.getViewer();this.disableMeasureCursor(),t.editorManager.disableTool(y.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),e.reset(),e.measureItem=null,this.isOpen=!1,this.drawableManager.setIsEnableSelection(!1)}},measureByPoint:function(t){var i=this,r=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),l=i.measureItem;t&&(n=t.pickPoint?t.pickPoint:null,t.pointType?s=t.pointType:t.pickPlane?(s="Panel",a=t.normal):t.pickLine?(s="Line",o=t.pickLine):s=t.pickPoint?"Point":null,!t.modelId&&(s=null),t.pick&&t.pickPoint?(l.addPoint(t.pickPoint),l.getPoints().length==l.maxPointsNum?(r||this.drawableManager.clear(!0),this.drawableManager.addItem(this.getInfo(!0,null,!0)),r||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measured,i.getInfo(!0,null,!0)),l.reset()):(r||this.drawableManager.clear(!0),i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,i.getInfo())),i.update()):this.isEnableSnap&&i.update())},reset:function(){this.isOpen&&(this.measureItem.reset(),this.context.svg.innerHTML="",this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Reset))},setIsEnableSnap:function(e){e||(this.context.svg.innerHTML=""),this.isEnableSnap=e},update:function(){var e=this.measureItem,t=this.context,i=this._opt.viewer,r=i.getDomElement(),l=r.getBoundingClientRect(),h=i.getViewer(),d=e.getPoints(),c=[],u=[];if(this.context.svg.innerHTML="",t.footPoint=null,n?(t.hoverPosition=i.worldToClient(n),t.hoverPositionDS=h.getScene().worldToDrawing(n),e.nextMeasurePoint=n):t.hoverPosition=e.nextMeasurePoint?i.worldToClient(e.nextMeasurePoint):null,0!=d.length&&(c=d.concat([e.nextMeasurePoint])),t.hoverObjectType=s,"Line"==s&&2==o.length){t.lineStartPoint=i.worldToClient(o[0]),t.lineEndPoint=i.worldToClient(o[1]);var g=new THREE.Vector2(t.lineStartPoint.x,t.lineStartPoint.y),p=new THREE.Vector2(t.lineEndPoint.x,t.lineEndPoint.y),m=new THREE.Box2;m.min.set(r.clientLeft,r.clientTop),m.max.set(m.min.x+r.clientWidth,m.min.y+r.clientHeight);var f=!m.containsPoint(g),w=!m.containsPoint(p),v={start:g,end:p},b=y.CameraUtil.lineIntersectWithRect(v,m);if(f&&w)2==b.length&&(t.lineStartPoint=b[0],t.lineEndPoint=b[1]);else if(f||w)for(var E=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y),M=f?p.clone():g.clone(),C=M.clone().sub(E).normalize(),x=0;x<b.length;x++){if(M.clone().sub(b[x]).normalize().dot(C)>0){t.lineStartPoint=M,t.lineEndPoint=b[x];break}}let e=d[d.length-1];if(e){const{x:n,y:s}=i.worldToClient(e),r=new THREE.Vector2(n,s),a=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y);if(r.distanceTo(a)>5){let n=o[0].clone(),s=o[1].clone();const r=n.x-s.x,l=n.y-s.y,h=n.z-s.z;let d=(e.x-n.x)*(n.x-s.x)+(e.y-n.y)*(n.y-s.y)+(e.z-n.z)*(n.z-s.z);d/=Math.pow(r,2)+Math.pow(l,2)+Math.pow(h,2);let c=new THREE.Vector3(n.x+d*r,n.y+d*l,n.z+d*h),u=i.worldToClient(c);a.distanceTo(u)<=5&&(t.footPoint=u,t.hoverPosition=u)}}}if("Panel"==t.hoverObjectType){t.normal=h.getScene().worldToDrawing(a),t.normal.normalize();var T=h.cameraControl,P=new THREE.Plane;P.setFromNormalAndCoplanarPoint(t.normal,t.hoverPositionDS);var I=new THREE.Vector2(t.hoverPosition.x-10,t.hoverPosition.y-10),S=new THREE.Vector2(t.hoverPosition.x+10,t.hoverPosition.y-10),B=t.hoverPositionDS,_=T.getRaycaster(I.x,I.y);if(this._p1=_.ray.intersectPlane(P,this._p1),_=T.getRaycaster(S.x,S.y),this._p2=_.ray.intersectPlane(P,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var L=new THREE.Vector3(1,0,0),D=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,0,1),V=Math.abs(t.normal.clone().dot(L))<=.0025,R=Math.abs(t.normal.clone().dot(A))<=.0025;if(V&&R)var O=L.clone(),k=A.clone();else O=D.clone().cross(t.normal).normalize(),k=t.normal.clone().cross(O).normalize();var H=this._p1.distanceTo(this._p2)/2,U=O.clone().multiplyScalar(H),N=k.clone().multiplyScalar(H),G=B.clone().sub(U).add(N),j=B.clone().add(U).add(N),z=B.clone().sub(U).sub(N),F=B.clone().add(U).sub(N),W=[];W.push(G,j,F,z);for(var $=[],X=T.getContainerDimensions(),Y=0;Y<W.length;Y++){var Z=y.CameraUtil.drawingToCanvas(T.camera,W[Y],X.width,X.height);$.push(new THREE.Vector3(Z.x,Z.y,0))}t.clientPts=$}for(x=0;x<c.length-1;x++){var q=h.worldPointsToClient(c[x],c[x+1]);if(q){var K={x:q.start.x-l.left,y:q.start.y-l.top};u.push(K)}}t.clientPoints=u;let Q=this.getInfo(!0,c);e.draw(t,Q)},getInfo:function(t,i,n){var o={},s=this.measureItem,r=this._opt.viewer;i=i||s.getPoints();switch(o.type=this.type,o.id=e.Web.Lang.Utility.UUID.createUUID(),o.points=i,this.type){case e.Bimface.Plugins.Measure.MeasureTypeOption.Angle:if(3==i.length){var a=new THREE.Vector3(i[0].x-i[1].x,i[0].y-i[1].y,i[0].z-i[1].z),l=new THREE.Vector3(i[2].x-i[1].x,i[2].y-i[1].y,i[2].z-i[1].z),h=a.angleTo(l);o.angle=180*h/Math.PI}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Position:if(1==i.length){o.coordinateSystem="GCJ-02";let e=r.worldToLatLon(i[0]);o.lonLat={longitude:e.lon,latitude:e.lat},o.altitude=i[0].z}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance:if(i&&i.length>=2){let e=i.length;o.distance=[],o.totalDistance=0;for(let t=1;t<e;t++){let e=i[t].distanceTo(i[t-1]);o.distance.push(e),o.totalDistance+=e}}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.GroundlineDistance:if(i&&i.length>=2){o.distance=[],o.totalDistance=0,o.positions=[],o.groundInfos=s.groundInfos,s.lastGroundLineMes.point&&(s.lastGroundLineMes.point.x==s.nextMeasurePoint.x&&s.lastGroundLineMes.point.y==s.nextMeasurePoint.y&&s.lastGroundLineMes.point.z==s.nextMeasurePoint.z?(new Date).getTime()-s.lastGroundLineMes.time>300&&(this.groundLineInfo=s.calculateGroundlineDistance(s.measurePoints[s.measurePoints.length-1],s.nextMeasurePoint)):s.lastGroundLineMes.time=(new Date).getTime()),s.lastGroundLineMes.point=s.nextMeasurePoint,s.groundInfos=this.groundLineInfo&&!s.measureEnd?[...s.groundLineInfos,this.groundLineInfo]:s.groundLineInfos;for(let e=0;e<s.groundInfos.length;e++){let t=s.groundInfos[e];o.distance.push(t.length),o.totalDistance+=t.length;let i={midPoint:t.midPoint,endPoint:t.endPoint};o.positions.push(i)}}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.TriangleDistance:if(2==i.length){o.distance=o.points[0].distanceTo(o.points[1]);let e=i[0].clone(),t=0,n=0;i[0].z<i[1].z?(e.set(i[0].x,i[0].y,i[1].z),t=e.distanceTo(i[1]),n=e.distanceTo(i[0])):i[0].z>i[1].z&&(e.set(i[1].x,i[1].y,i[0].z),t=e.distanceTo(i[0]),n=e.distanceTo(i[1])),Object.assign(o,{horizontalDistance:t,verticalDistance:n})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:if(i.length>=3&&t){let e=re.calcSpatialArea(i);Object.assign(o,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:if(i.length>=3&&t){let e=re.calcProjectedArea(i);Object.assign(o,{area:e})}break;case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:i.length>=3&&t&&(void 0===this.surfaceAreaValue||n?this.surfaceAreaValue=re.calcSurfaceArea(i,r,this.layerType):(this.surfaceAreaLastTime||(this.surfaceAreaLastTime=(new Date).getTime()),(new Date).getTime()-this.surfaceAreaLastTime>=300&&(this.surfaceAreaValue=re.calcSurfaceArea(i,r,this.layerType),this.surfaceAreaLastTime=(new Date).getTime())),Object.assign(o,{area:this.surfaceAreaValue,layerType:this.layerType}))}return o},redo:function(){this.measureItem.redo(),this.update(),this.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureEvent.Measuring,this.getInfo())},exit:function(){this.switchOff(),this._unhookEvents()},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return"m"},getEngineUnit:function(){return this._opt.viewer.globalUnitUtil.isBimtilesAsset()?"m":this._opt.viewer.globalUnitUtil.getDefaultUnit()}},t.MeasureViewerGIS=l}(),function(){var t="Bimface.Plugins.Measure.Measure",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t.viewer;if(i){P(this);var s=new e.Web.Lang.EventManager,r=o.create("div","bf-measure-conext");this.context={rootDomElement:r},this.id="Measure","ViewerGIS"===i.getViewerType()&&t.measureType==e.Bimface.Plugins.Measure.MeasureTypeOption.Distance&&(t.measureType=e.Bimface.Plugins.Measure.MeasureTypeOption.PolylineDistance),this._opt=t,this.type=t.measureType,this.layerType=t.layerType,this.getEventManager=function(){return s},"Viewer3D"===i.getViewerType()?(n.MeasureViewer3D.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewer3D.prototype)):"ViewerGIS"===i.getViewerType()?(n.MeasureViewerGIS.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureViewerGIS.prototype)):(n.MeasureDrawing.call(this,t),this.inherit(e.Bimface.Plugins.Measure.MeasureDrawing.prototype)),this._setDefaultUnits(t),this._setDefaultPrecisions(t),this.init()}};s.prototype={inherit:function(e){for(var t in e)this[t]=e[t]},addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},_setDefaultUnits:function(t){const i=t.viewer.getViewerType();if(null!=t.lengthUnits&&null==t.units){switch(i){case"Viewer3D":case"ViewerGIS":t.units={distance:t.lengthUnits,elevation:t.lengthUnits,area:t.lengthUnits};break;case"ViewerDrawing":t.units={distance:t.lengthUnits,area:t.lengthUnits}}return}const n=this.getDefaultUnit();"m"===n?t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Meter:"mm"===n&&(t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Millimeter);const o=t.units&&t.units.distance||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.Millimeter,s=t.units&&t.units.distance||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.None,r=t.units&&t.units.elevation||e.Bimface.Common.Units.LengthUnits.Meter,a=t.units&&t.units.area||e.Bimface.Common.Units.LengthUnits.Meter,l=t.units&&t.units.area||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.Millimeter,h=t.units&&t.units.area||e.Bimface.Common.Units.LengthUnits.None;switch(i){case"Viewer3D":t.units={distance:o,elevation:r,area:l};break;case"ViewerGIS":t.units={distance:o,elevation:r,area:a};break;case"ViewerDrawing":t.units={distance:s,area:h}}},_setDefaultPrecisions:function(e){if("number"==typeof e.precision)e.obsoletePrecision=e.precision,e.precision={distance:e.obsoletePrecision,elevation:e.obsoletePrecision,area:e.obsoletePrecision,angle:e.obsoletePrecision,latLon:e.obsoletePrecision};else{let{distance:t=3,elevation:i=3,area:n=3,angle:o=2,latLon:s=9}=e.precision;e.precision={distance:t,elevation:i,area:n,angle:o,latLon:s}}},getMeasureType:function(){return this.type},setMeasureType:function(e){i.send(t,"setMeasureType"),this.hideDragButton&&this.hideDragButton(),this.type=e,this.reset(),this.activeByMeasureType(),this.getEventManager().fireEvent("typeChange",e)},setPrecision:function(e){"number"==typeof e||"string"==typeof e?(this._opt.obsoletePrecision=e,this._opt.precision={distance:e,elevation:e,area:e,angle:e,latLon:e}):this._opt.precision=Object.assign(this._opt.precision,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getPrecision:function(){return void 0!==this._opt.obsoletePrecision?this._opt.obsoletePrecision:this._opt.precision},setScale:function(e){this._opt.scale=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getScale:function(){return this._opt.scale},setLengthUnits:function(e){this._opt.lengthUnits=e;for(const t in this._opt.units)this._opt.units[t]=e;this.getEventManager().fireEvent("MeasureParamsUpdated")},getLengthUnits:function(){return this._opt.lengthUnits},setUnits:function(e){this._opt.units=Object.assign(this._opt.units,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getUnits:function(){return this._opt.units},getAllItems:function(){return this.drawableManager.save()},setItems:function(e){this.clear(),this.drawableManager.load(e)},clear:function(){this.drawableManager.clear(!0),this.hideDragButton&&this.hideDragButton()},hideAllItems:function(){this.drawableManager.hideAll()},showAllItems:function(){this.drawableManager.showAll()},onClick:function(e){this.drawableManager.onClick(e)},removeSelectedItem:function(){this.drawableManager.unselctedAll()},getSelectedItem:function(){return this.drawableManager.getSelectedItem()},setLayerType:function(e){this.layerType=e},getMeasureParams:function(t){let i={scale:this.getScale(),defaultUnit:this.getDefaultUnit(),laserXYZ:this.getLaserXYZ()};switch(t||this.type){case e.Bimface.Plugins.Measure.MeasureTypeOption.Angle:i=Object.assign(i,{precision:this._opt.precision.angle,unit:"°"});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Elevation:i=Object.assign(i,{precision:this._opt.precision.elevation,unit:this.getUnits().elevation});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Area:case e.Bimface.Plugins.Measure.MeasureTypeOption.SpatialArea:case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:case e.Bimface.Plugins.Measure.MeasureTypeOption.SurfaceArea:i=Object.assign(i,{precision:this._opt.precision.area,unit:this.getUnits().area});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Position:i=Object.assign(i,{precision:{elevation:this._opt.precision.elevation,latLon:this._opt.precision.latLon},unit:this.getUnits().elevation});break;case e.Bimface.Plugins.Measure.MeasureTypeOption.Slope:i=Object.assign(i,{unit:"%"});break;default:i=Object.assign(i,{precision:this._opt.precision.distance,unit:this.getUnits().distance,enableAuxiliaryValue:this._opt.enableAuxiliaryValue||!1,minimumDistanceZoom:this.getMinimumDistanceZoom()})}return i},enableAuxiliaryValue(e){i.send(t,"enableAuxiliaryValue"),this._opt.enableAuxiliaryValue=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},isEnableAuxiliaryValue(){return i.send(t,"isEnableAuxiliaryValue"),this._opt.enableAuxiliaryValue},setLaserXYZ(e){i.send(t,"setLaserXYZ"),this._opt.laserXYZ=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getLaserXYZ(){return this._opt.laserXYZ},setMinimumDistanceZoom(e){i.send(t,"setMinimumDistanceZoom"),this._opt.minimumDistanceZoom=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getMinimumDistanceZoom(){return this._opt.minimumDistanceZoom}},n.Measure=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureRayConfig=function(){return{viewer:null,targetsHintColor:new e.Web.Graphics.Color(245,127,35,.6)}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure").MeasureRayItemConfig=function(){return{id:null,color:new e.Web.Graphics.Color(245,127,35,1),width:2,startPoint:new e.Web.Geometry.Point3d(0,0,0),endPoint:new e.Web.Geometry.Point3d(0,0,0),startObjectId:null,endObjectId:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){this.id=t.id||e.Web.Lang.Utility.UUID.createUUID();this.startPoint=t.startPoint,this.endPoint=t.endPoint;this.startComponentId=t.startComponentId,this.endComponentId=t.endComponentId;var n=i.createNS("defs","bf-defs");n.innerHTML=`\n <marker id="end" markerWidth="6" markerHeight="6" refx="5" refy="3" orient="auto" markerUnits="strokeWidth">\n <path d="M0,0 L0,6 L6,3 z" fill="${t.color.getRGBA()}" />\n </marker>`;var o=i.create("i","bf-measure-handle");o.style.width=12*t.width+"px",o.style.height=12*t.width+"px",o.style.backgroundColor=t.color.getRGBA(),o.style.lineHeight=12*t.width+"px";var s=i.createNS("line","bf-measure-line");s.style.stroke=t.color.getRGBA(),s.setAttribute("stroke-width",t.width);var r=i.create("span","bf-measure-number");r.style.backgroundColor=t.color.getRGBA(),this.domElement=n,this.line=s,this.circle=o,this.text=r};n.prototype={draw:function(e){var t=this.domElement,i=this.line,n=this.circle,o=this.text,s=Math.abs(e.endPoint.x-e.startPoint.x),r=Math.abs(e.endPoint.y-e.startPoint.y),a=Math.abs(e.endPoint.z-e.startPoint.z),l=Math.sqrt(Math.pow(s,2)+Math.pow(r,2)+Math.pow(a,2));i.setAttribute("x1",e.startPoint.x),i.setAttribute("y1",e.startPoint.y),i.setAttribute("x2",e.endPoint.x),i.setAttribute("y2",e.endPoint.y),n.style.left=`${e.startPoint.x}px`,n.style.top=`${e.startPoint.y}px`,e.isMove&&(n.style.border="2px solid #fff"),l<15?i.removeAttribute("marker-end"):i.setAttribute("marker-end","url(#end)"),o.innerText=e.distance,e.svg.appendChild(t),e.svg.appendChild(i),e.text.appendChild(n),0==e.distance?n.innerText="0":(o.style.left=(e.startPoint.x+e.endPoint.x)/2+"px",o.style.top=(e.startPoint.y+e.endPoint.y)/2+"px",o.style.transform="translate(-50%, 0)",o.style.marginTop="2px",e.text.appendChild(o))}},t.MeasureRayItem=n}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure");let i=Object.freeze({Measured:"Measured",Clear:"Clear"});t.MeasureRayEvent=i}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){var n=t.viewer;if(n)if("Viewer3D"===n.viewerType){var o=this,s=new e.Web.Lang.EventManager,r=i.create("div","bf-measure-conext");n.addEventListener("Rendered",(function(){o.measureItem&&o.update()})),this.context={rootDomElement:r},this._opt=t,this._enableMove=!1,this._events={mousedown:function(){this._startTime=(new Date).getTime()},mouseup:function(e){if(0==e.button||1==e.button)if(o._enableMove)o._enableMove=!1,o.measureByPoint(e);else{var t=this._startTime;(new Date).getTime()-t<300&&o.measureByPoint(e)}},mousemove:function(e){o._enableMove&&(e.stopPropagation(),o.measureByPoint(e))}},this.getEventManager=function(){return s}}else console.log("Viewer2D is not supported.")};n.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},switchOn:function(e){var t=this.context,n=this;n._opt.viewer.getDomElement().appendChild(t.rootDomElement),e&&(n._callback=e),n._opt.viewer.getModels().forEach((e=>{e.setSelectedComponentsById()}));var o=i.createNS("svg","bf-measure-svg"),s=i.create("div","bf-measure-text");t.rootDomElement.appendChild(o),t.rootDomElement.appendChild(s),t.svg=o,t.text=s,t.rootDomElement.addEventListener("mousedown",n._events.mousedown),t.rootDomElement.addEventListener("mouseup",n._events.mouseup),t.rootDomElement.addEventListener("mousemove",n._events.mousemove)},switchOff:function(){var e=this.context.rootDomElement,t=this,i=t._opt.viewer;t.measureItem&&(i.restoreComponentsColorById([t.measureItem.startComponentId,t.measureItem.endComponentId]),i.render()),e.removeEventListener("mousedown",t._events.mousedown),e.removeEventListener("mouseup",t._events.mouseup),e.removeEventListener("mousemove",t._events.mousemove),e.innerHTML="",e.remove(),t.measureItem=null},reset:function(){this.clear()},clear:function(){var t=this.context,i=this,n=i._opt.viewer;i.measureItem&&(n.restoreComponentsColorById([i.measureItem.startComponentId,i.measureItem.endComponentId]),n.render()),t.svg.innerHTML="",t.text.innerHTML="",i.measureItem=null,i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureRayEvent.Clear,data)},measureByPoint:function(t){var i=this,n=i._opt.viewer,o=n.getViewer().pickByPointWithNormal(t);if(o){i.measureItem&&n.restoreComponentsColorById([i.measureItem.startComponentId,i.measureItem.endComponentId]);e.Bimface.Viewer.Viewer3DEvent;var s=i._getContextData(o),r=new e.Bimface.Plugins.Measure.MeasureRayItemConfig;r.startComponentId=s.startComponentId,r.endComponentId=s.endComponentId,r.startPoint=s.startPoint,r.endPoint=s.endPoint;var a=new e.Bimface.Plugins.Measure.MeasureRayItem(r);a.circle.addEventListener("mousedown",(function(e){2!=e.button&&(i._enableMove=!0)})),i.context.distance=s.distance,n.overrideComponentsColorById([s.startComponentId,s.endComponentId],i._opt.targetsHintColor),setTimeout((function(){i.update(),n.render()}),100),i.measureItem=a,i.getEventManager().fireEvent(e.Bimface.Plugins.Measure.MeasureRayEvent.Measured,s)}},update:function(){var t=this.measureItem,i=this.context,n=this._opt.viewer;i.svg.innerHTML="",i.text.innerHTML="",i.isMove=this._enableMove;var o=n.worldToClient(t.startPoint),s=n.worldToClient(t.endPoint);o&&s&&(i.startPoint=new e.Web.Geometry.Point3d(o.x,o.y,o.z),i.endPoint=new e.Web.Geometry.Point3d(s.x,s.y,s.z),t.draw(i))},exit:function(){this.switchOff()},_getContextData:function(e){var t,i,n={};return t=i=e[0],e.length>1&&(i=e[1]),n.startComponentId=t.userId,n.startPoint=t.worldPosition,n.endComponentId=i.userId,n.endPoint=i.worldPosition,n.distanceX=Math.round(Math.abs(n.endPoint.x-n.startPoint.x)),n.distanceY=Math.round(Math.abs(n.endPoint.y-n.startPoint.y)),n.distanceZ=Math.round(Math.abs(n.endPoint.z-n.startPoint.z)),n.distance=Math.round(Math.sqrt(Math.pow(n.distanceX,2)+Math.pow(n.distanceY,2)+Math.pow(n.distanceZ,2))),n}},t.MeasureRay=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D").Marker3DContainerConfig=function(){return{viewer:null,type:null,layerId:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D").Marker3DConfig=function(){return{id:null,objectId:null,size:30,tooltip:"",tooltipStyle:{color:"#333",fontSize:"14px",borderWidth:"1px",borderColor:"#666",borderStyle:"solid",backgroundColor:"#fff"},src:null,canvas:null,worldPosition:new e.Web.Geometry.Point3d(0,0,0),modelId:void 0,layerId:void 0,hoverAnimation:!0}},function(){var t="Bimface.Plugins.Marker3D.Marker3D",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=this;this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=t.layerId,this.modelId=t.modelId,this.objectId=t.objectId,this.size=t.size,this.iconUrl=t.canvas?t.canvas.toDataURL():t.src,this.position={x:t.worldPosition.x,y:t.worldPosition.y,z:t.worldPosition.z},this.hoverAnimation=t.hoverAnimation,this.originalPosition=new THREE.Vector3(this.position.x,this.position.y,this.position.z),this.explosionOffset=new THREE.Vector3,this.tooltip=t.tooltip,this.tooltipElement=o.create("div","bf-tooltip"),this.tooltipElement.innerHTML=t.tooltip,this.tooltipElement.setCss(t.tooltipStyle),this.isHideByClustering=!1,this._tooltipCallback=function(e,t,n){var o=i.tooltipElement;n.appendChild(o);var s=o.offsetWidth,r=o.offsetHeight;o.style.left=t.x-s/2+"px",o.style.top=t.y-r-i.size+"px",i._hoverCallback&&i._hoverCallback(e)},this._config=t,this.scratchVector=new THREE.Vector3,this.scratchVector_2=new THREE.Vector3,P(this)};s.prototype={getId:function(){return this.id},getWorldPosition:function(){return this.container?this.container._viewer.globalUnitUtil.revertVector(this.position):this.position},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.position={x:e.x,y:e.y,z:e.z},this.originalPosition=new THREE.Vector3(this.position.x,this.position.y,this.position.z),this.update()},getSize:function(){return this.size},setSize:function(e){i.send(t,"setSize"),this.size=e,this.update()},getSrc:function(){return this.iconUrl},setSrc:function(e){i.send(t,"setSrc"),this.iconUrl=e,this.update()},getTooltip:function(){return this.tooltip},setTooltip:function(e){i.send(t,"setTooltip"),this.tooltip=e,this.tooltipElement.innerHTML=e},onClick:function(e){i.send(t,"onClick"),e&&(this._clickCallback=e)},onHover:function(e){i.send(t,"onHover"),e&&(this._hoverCallback=e)},onDoubleClick:function(e){i.send(t,"onDoubleClick"),e&&(this._doubleClickCallback=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClickCallback=e)},update:function(){i.send(t,"update"),this.container&&this.container.update()},isHideByClustering:function(){return this.isHideByClustering},hideByClustering:function(e){this.isHideByClustering=!!e},attachExplosionOffset:function(e,t){if(!this.getWorldPosition())return;let i=this._config.objectId;if(i){let n=e.modelManager.getBoundingBoxByIds([i]),o=this.assoiatedComponentBbox,s=n;if(o){let e=s.getCenter(this.scratchVector).clone();e.sub(o.getCenter(this.scratchVector_2).clone()),this.explosionOffset=e,this.explosionExtent>0&&0===t&&(this.originalPosition.x+=this.explosionDirection*e.x,this.originalPosition.y+=this.explosionDirection*e.y,this.originalPosition.z+=this.explosionDirection*e.z,this.explosionExtent=0,this.explosionOffset=new THREE.Vector3,this.assoiatedComponentBbox=s.clone())}}else{let i=e.getScene().getOriginalBoundingBoxWorld().getCenter(this.scratchVector),n=(new THREE.Box3).expandByPoint(this.getWorldPosition()),o=CLOUD.Utils.computeExplodeTranslation(i,n,t);this.explosionOffset=o}},updatePosition:function(){this.container?(this.position.x=this.container._viewer.globalUnitUtil.translate(this.originalPosition.x+this.explosionOffset.x),this.position.y=this.container._viewer.globalUnitUtil.translate(this.originalPosition.y+this.explosionOffset.y),this.position.z=this.container._viewer.globalUnitUtil.translate(this.originalPosition.z+this.explosionOffset.z)):(this.position.x=this.originalPosition.x+this.explosionOffset.x,this.position.y=this.originalPosition.y+this.explosionOffset.y,this.position.z=this.originalPosition.z+this.explosionOffset.z)},getOriginalPosition:function(){return this.originalPosition},setInitialExplosionInfo:function(e){if("Viewer3D"!==e.getViewerType()&&"ViewerGIS"!==e.getViewerType())return;let t=null;"Viewer3D"===e.getViewerType()?t=this.modelId?e.getModel(this.modelId):e.getDefaultModel():"ViewerGIS"===e.getViewerType()&&(t=e.getLayerManager().getLayer(this.layerId)),this.explosionExtent=null===t?t.getExplosionExtent():0;let i=this._config.objectId;if(i){let t=e.getViewer().modelManager.getBoundingBoxByIds([i]);t.isEmpty()?(this._config.objectId=null,console.log("Cannot find component with Id "+i)):this.assoiatedComponentBbox=t.clone()}},getCurrentPosition:function(){return this.container?this.container._viewer.globalUnitUtil.revertVector(this.position):this.position},getHoverAnimation:function(){return this.hoverAnimation},setHoverAnimation:function(e){null!=e&&(this.hoverAnimation=e,this.update())},setContainerVisible:function(e){this.hideByClustering(!e),this.update()},getOpacity:function(){return 1},setOpacity:function(e){},resetClientPosition:function(e){this.setWorldPosition(e)}},n.Marker3D=s}(),function(){var t="Bimface.Plugins.Marker3D.Marker3DContainer",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Marker3D");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");n.Marker3DContainer=class{constructor(t){e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(!t.viewer)return void console.log("viewer must not be empty.");this.isMarker3DContainer=!0;const i="Viewer3D"===t.viewer.viewerType,n=e.Bimface.Viewer.ViewerGIS&&t.viewer instanceof e.Bimface.Viewer.ViewerGIS;var o=t.viewer.getDomElement(),s=t.viewer.getViewer();if(!i&&!n)return void console.log("Viewer2D is not supported.");if(P(this),"ViewerGIS"===t.viewer.getViewerType()&&"ShpPoint"===t.type)this._helper=new y.ShpPointMarker(s,t.layerId);else{if(t.viewer.marker3DContainer)return t.viewer.marker3DContainer;t.viewer.marker3DContainer=this,this._helper=new y.Marker3D(s,!0)}var r=this;this._viewer=t.viewer,this._items=[],this._areaData={},this.loadAreas=void 0,this.getLevelCallback=[],this.boxMap={},this.hoverListenerAdded=!1,this._isViewerGIS=n,this._pick=e=>{if(!e.doubleClick&&2!==e.event.button){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._clickCallback&&i._clickCallback(i)}}},this._doublePick=e=>{if(e.doubleClick){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._doubleClickCallback&&i._doubleClickCallback(i)}}},this._rightPick=e=>{if(2==e.event.button){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._rightClickCallback&&i._rightClickCallback(i)}}},this._hover=e=>{var t=this;t.tooltipElement&&o.contains(t.tooltipElement)&&(o.removeChild(t.tooltipElement),t.tooltipElement=null);var i=e.intersectInfo;if(i&&i.objectType===y.PICKABLETYPE.Marker3d){var n=t.getItemById(i.selectedObjectId);t.tooltipElement=n.tooltipElement,n._tooltipCallback&&""!=t.tooltipElement.innerHTML&&n._tooltipCallback(n,e.canvasPos,o)}},s.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,r._pick),s.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,r._rightPick),s.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,r._doublePick),i?(this.calculateViewer3dExplosionOffset=e=>{const i=e.modelId,n=e.floorInfos.length,o=t.viewer.getDefaultModel().modelId.toString(),s=t.viewer.getModel(i).getFloorExplosionExtent(),a=t.viewer.getModel(i).getFloorExplosionDirection();if(0===s)for(const e of r.getAllItems())e.setInitialExplosionInfo(t.viewer);let l=[];r.floorInfos=e;var h=function(){let e=r._items;for(let t=0,n=e.length;t<n;t++){let n=e[t].getWorldPosition();if(n)if(!0!==e[t]._isBindRoom)if(e[t].levelName){let i=l.getObjectByAttribute("floorName",e[t].levelName);i&&(e[t].explosionOffset={x:a.x*i.explodedOffset,y:a.y*i.explodedOffset,z:a.z*i.explodedOffset})}else if(i!==o)e[t].explosionOffset={x:e[t].explosionOffset.x,y:e[t].explosionOffset.y,z:e[t].explosionOffset.z};else{let i=!0;for(let o=0;o<l.length;o++){const s=l[o];if(s.box.min<n.z&&s.box.max>n.z){e[t].explosionOffset={x:a.x*s.explodedOffset,y:a.y*s.explodedOffset,z:a.z*s.explodedOffset},e[t].levelName=s.floorName,i=!1;break}}i&&(e[t].explosionOffset={x:0,y:0,z:0})}else{const i=r._viewer.getViewer().modelManager.modelCollection.getById("ExtrudeBodyManager").getNode(e[t]._config.objectId),n=i.explodedHeight,o=i.explodedDirection;e[t].explosionOffset={x:o.x*n,y:o.y*n,z:o.z*n}}}};if(n)for(var d=0;d<n;d++){let t=e.floorInfos[d],i=e.floorInfos[d+1],o=e.floorInfos[d-1];l.push({box:{min:o?t.boundingBox.min.z:-1/0,max:i?i.boundingBox.min.z:1/0},floorName:t.name,explodedOffset:t.explodedHeight-t.elevation}),l.length==n&&(h(),r.boxs=l)}r.update()},t.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,(e=>{this.calculateViewer3dExplosionOffset(e)}))):n&&(this.calculateViewerGISExplosionOffset=e=>{const i=t.viewer,n=i.getViewer(),o=e.modelId,s=e.floorInfos.length,a=n.getFloorExplosionExtent(o),l=n.getFloorExplosionDirection(o);if(0===a)for(const e of r.getAllItems())e.setInitialExplosionInfo(i);const h=e.floorInfos;let d=[];for(var c=0;c<s;c++){let e=h[c],t=h[c+1],i=h[c-1];if(d.push({box:{min:i?e.boundingBox.min.z:-1/0,max:t?t.boundingBox.min.z:1/0},floorName:e.name,explodedOffset:e.explodedHeight-e.elevation}),d.length==s){this.boxMap[o]=d;break}}const u=i.getLayerManager();let g=this._items;for(let e=0,t=g.length;e<t;e++){if(!g[e].getWorldPosition())continue;const t=u.getLayer(g[e].layerId);if(!t||!t.modelId)continue;if(t.modelId.toString()!==o||!g[e].levelName)continue;let i=d.getObjectByAttribute("floorName",g[e].levelName);i&&(g[e].explosionOffset={x:l.x*i.explodedOffset,y:l.y*i.explodedOffset,z:l.z*i.explodedOffset})}this.update()},t.viewer.addEventListener(e.Bimface.Viewer.ViewerGISEvent.FloorExplosion,(e=>{this.calculateViewerGISExplosionOffset(e)}))),t.viewer.getViewer().registerEventListener(y.EVENTS.ON_EXPLOSION,(e=>{let i=this.getAllItems();for(const n of i)hn.attachExplosionOffset(t.viewer,e.extent,n);this.update()}))}addItem(e){i.send(t,"addItem"),e.container=this;let n=hn.ifExploded(this._viewer,e,this._isViewerGIS);n&&(n.setInitialExplosionInfo(this._viewer),n.updatePosition(),this._items.push(n),this._helper.add([n],(()=>{this._viewer.render()}))),this.addTipsHoverListener()}addTipsHoverListener(){if(!this.hoverListenerAdded){const i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();var t=this._viewer.getViewer();i&&t.registerEventListener(y.EVENTS.ON_HOVER_PICK,this._hover),this.hoverListenerAdded=i}}getLevelNameById(t,i){if(!this._spatialRelation){let t=new e.Bimface.Plugins.SpatialRelation.RoomConfig;t.viewer=this._viewer;let i=new e.Bimface.Plugins.SpatialRelation.Room(t);this._spatialRelation=i}let n=this._spatialRelation.getBoundaryByRoomId(t);if(n){if(this._levelsInfo)return levelName=function(e,t){let i=e[0][2];for(let e=0;e<t.length;e++)if(Math.abs(i-t[e].elevation)<5)return t[e].name;return!1}(n,this._levelsInfo),levelName;this._viewer.getDefaultModel().getMapInfo((e=>{this._levelsInfo=e.axisGrid.Levels,this.addItem(i)}))}}addItems(e){i.send(t,"addItems");for(const t of e){let e=hn.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer),t.updatePosition()}this._helper.add(e),this.addTipsHoverListener()}removeItemById(e){i.send(t,"removeItemById"),this._items.removeObjectByAttribute("id",e),this._helper.removeById(e)}getItemById(e){return this._items.getObjectByAttribute("id",e)}getAllItems(){return[...this._items]}clear(){i.send(t,"clear");var n=this._viewer.getViewer();let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();n.unregisterEventListener(y.EVENTS.ON_CLICK_PICK,this._pick),o&&n.unregisterEventListener(y.EVENTS.ON_HOVER_PICK,this._hover),this.hoverListenerAdded=!1,this._items=[],this._helper.clear(!0),this._viewer.render()}update(){this._helper.clear();let e=this._items.slice();for(let t=0,i=e.length;t<i;t++){e[t].getWorldPosition()&&e[t].updatePosition()}let t=[];for(let i=0,n=e.length;i<n;i++)!1===e[i].isHideByClustering&&t.push(e[i]);this._helper.add(t),this._viewer.render()}hideItemsById(e){i.send(t,"hideItemsById"),this._helper.hideByIds(e),this._viewer.render()}hideAllItems(){i.send(t,"hideAllItems"),this._helper.hide(),this._viewer.render()}showItemsById(e){i.send(t,"showItemsById"),this._helper.showByIds(e),this._viewer.render()}showAllItems(){i.send(t,"showAllItems"),this._helper.show(),this._viewer.render()}}}(),function(){let t=Object.freeze({Forward:"Forward",Reverse:"Reverse"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionBoxDirection=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionBoxConfig=function(){return{viewer:null,direction:e.Bimface.Plugins.Section.SectionBoxDirection.Forward,isHatchEnabled:!0,hatchByMaterial:!1,enableSnap:!0,isOutlineEnabled:!0,filter:null}},function(){let t=Object.freeze({SectionBoxUpdate:"SectionBoxUpdate",SectionBoxChanged:"SectionBoxChanged"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionBoxEvent=t}(),function(){var t,i,n="Bimface.Plugins.Section.SectionBox",o=e.Bimface.Data.StatisticsDataManager.getInstance(),s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section"),r=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),function(n){var o=this,r=n.viewer;if(!r)return void console.log("domElement must not be empty.");const a="Viewer3D"===r.viewerType,l=r instanceof e.Bimface.Viewer.ViewerGIS;if(a||l){if(P(this),r._sectionPlane&&(r._sectionPlane.hidePlane(),r._sectionPlane.exit()),n.hatchByMaterial&&r.getViewer().getClipCapsManager().enableHatchByMaterial(n.hatchByMaterial,!0),y.GlobalData.CalculateClippingLine=!!n.isOutlineEnabled,y.GlobalData.SnapClippingLine=!!n.enableSnap,t&&r==i)return t.id=n.id,t.reset(),t;if(t=this,i=r,r._sectionBox)return r._sectionBox.showBox(),r._sectionBox;r._sectionBox=this,this.sectionBoxEvent=s.SectionBoxEvent,this.eventManager=r.getEventManager(),o.id=n.id||"SectionBox",o._opt=n,o._viewer=r,o.boxState=!0,o._boxDirection=n.direction,o.init(),n.filter&&o.setFilter(n.filter),o.enableHatch(n.isHatchEnabled)}else console.log("Viewer2D is not supported.")});r.prototype={hookEvens:function(){var e=this._viewer.getViewer(),t=this._viewer.getDomElement();e.registerEventListener(y.EVENTS.ON_CLIP_HOVER,(function(e){e.onClipBox?t.style.cursor=`url(${a}),auto`:t.style.removeProperty("cursor")}));var i=this;e.registerEventListener(y.EVENTS.ON_CLIP_MOUSE_MOVE,(function(e){i.eventManager.fireEvent(i.sectionBoxEvent.SectionBoxChanged)}))},init:function(){o.send(n,"init");var e=this._opt.viewer.getViewer(),t=this;e.editorManager.enableTool(e,y.EditToolMode.CLIP_BY_BOX),this._sectionBox=new y.ClipPlaneService(e),y.ClipPlaneManager.getInstance(e.getScene()).observer=function(){t.eventManager.fireEvent(t.sectionBoxEvent.SectionBoxUpdate,t)},this._sectionBox.reset(),this._sectionBox.toggle(!0,!0),this._sectionBox.setVisible(!0),"Reverse"===t._boxDirection?this._sectionBox.changeDirection(!0):this._sectionBox.changeDirection(!1),e.getModelManager().updatePickingMaterial(),this.hookEvens(),this.fireSectionBoxVisibleChangedEvent(!0)},addEventListener:function(e,t){this.eventManager.addEvent(e,t)},removeEventListener:function(e,t){this.eventManager.removeEvent(e,t)},fireSectionBoxVisibleChangedEvent:function(e){requestAnimationFrame((()=>{this._opt.viewer.getEventManager().fireEvent("SectionBoxVisibleChanged",e)}))},setBox:function(e){o.send(n,"setBox");var t=this._sectionBox.getEditor();e=this._viewer.globalUnitUtil.translate(e,["x","y","z"]),t.calculateOffsetByBox(e.min,e.max),y.GlobalData.ClippingCapsType==y.EnumClippingCapsTypes.ClipBox&&this._sectionBox&&this._sectionBox.getEditor().clipPlanes.reCalculateClippingIds()},getBox:function(){},hideBox:function(){o.send(n,"hideBox"),this._sectionBox&&this._sectionBox.setVisible(!1),this._viewer.render()},showBox:function(){o.send(n,"showBox"),this._sectionBox&&this._sectionBox.setVisible(!0),this._viewer.render()},setProgress:function(e,t){var i={x:["Left","Right"],y:["Back","Front"],z:["Bottom","Top"]};t&&(this._sectionBox.setProcess(i[e][0],t[0]/100),2==t.length&&this._sectionBox.setProcess(i[e][1],1-t[1]/100))},getProgress:function(e){var t=[],i={x:["Left","Right"],y:["Back","Front"],z:["Bottom","Top"]};return t.push(100*this._sectionBox.getProcess(i[e][0])),t.push(100-100*this._sectionBox.getProcess(i[e][1])),t},reCalculateClippingIds(e){this._sectionBox.reCalculateClippingIds(e)},reset:function(){o.send(n,"reset"),this._sectionBox&&this._sectionBox.toggle(!0,!0),this._sectionBox&&this._sectionBox.reset("Rotate"),this.showBox()},enable:function(e){o.send(n,"enable");var t=this._opt.viewer,i=t.getViewer().getScene();y.ClipPlaneManager.getInstance(i).enable(e,e),t.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionBoxVisibleChangedEvent(e)},fitToModel:function(){o.send(n,"fitToModel"),this.reset();var e=this._sectionBox.recalculate().clone();e.isEmpty()&&e.expandByPoint(new THREE.Vector3),e=this._viewer.globalUnitUtil.revertTranslate(e,["x","y","z"]),this.setBox(e),this._sectionBox.getEditor()._isVisible()&&this.showBox(),this.eventManager.fireEvent(this.sectionBoxEvent.SectionBoxChanged)},isIncluded:function(e){var t=this._opt.viewer,i=t.getViewer().getScene(),n=y.ClipPlaneManager.getInstance(i).getClipBoundingBox(),o=t.worldToScene(e);return n.containsPoint(o)},exit:function(){o.send(n,"exit");var e=this._opt.viewer.getViewer(),i=this._viewer.getDomElement();this.clearFilter(),this.reset(),e.getModelManager().updatePickingMaterial(),e.editorManager.disableTool(y.EditToolMode.CLIP_BY_BOX),e.getClipCapsManager().resetClippingCapsStatus(),i.style.removeProperty("cursor"),this._sectionBox=null,this._opt.viewer._sectionBox=null,t=null,this.eventManager.fireEvent(this.sectionBoxEvent.SectionBoxUpdate,null),e.unregisterEventListener(y.EVENTS.ON_CLIP_HOVER,(function(e){e.onClipBox?i.style.cursor=`url(${a}),auto`:i.style.removeProperty("cursor")})),y.GlobalData.SnapClippingLine=!1,y.GlobalData.CalculateClippingLine=!0,this.fireSectionBoxVisibleChangedEvent(!1)},lockBox:function(e){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").lockBoxFaces(e)},unlockBox:function(){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").unlockBox()},getState:function(){var e=this._opt.viewer,t=this._sectionBox.saveState(),i=t.boundingBox;return i.min=e.sceneToWorld(i.min),i.max=e.sceneToWorld(i.max),t.center=e.globalUnitUtil.revertVector(t.center),t.position=e.globalUnitUtil.revertVector(t.position),t},setState:function(e){var t=this._opt.viewer,i=Object.assign({},e.boundingBox),n=Object.assign({},e);n.cneter=Object.assign({},e.center),n.position=Object.assign({},e.position);var o=n.boundingBox;o.min=t.worldToScene(o.min),o.max=t.worldToScene(o.max),n.center=t.globalUnitUtil.translateVector(n.center),n.position=t.globalUnitUtil.translateVector(n.position),n.quaternion&&n.quaternion instanceof Array&&(n.quaternion=new THREE.Quaternion(...n.quaternion)),this._sectionBox.loadState(n),e.boundingBox=i},restore:function(){var e=this._sectionBox.getEditor()._isVisible();this._sectionBox.toggle(!0,e),this._sectionBox.reset("Rotate")},getSectionBox:function(){o.send(n,"getSectionBox");var e=this._opt.viewer,t=this._sectionBox.saveState().boundingBox,i=e.getViewer().getScene().getMatrixGlobal();return i.invert(),t=e.globalUnitUtil.revertTranslate(t,["x","y","z"]),(t=new THREE.Box3(new THREE.Vector3(t.min.x,t.min.y,t.min.z),new THREE.Vector3(t.max.x,t.max.y,t.max.z))).applyMatrix4(i),t},setSectionBox:function(e){o.send(n,"setSectionBox");var t=this._opt.viewer,i=t.getViewer().getScene(),s=y.ClipPlaneManager.getInstance(i);e=t.globalUnitUtil.translate(e,["x","y","z"]);var r=(i=t.getViewer().getScene()).getMatrixGlobal(),a=new THREE.Box3(new THREE.Vector3(e.min.x,e.min.y,e.min.z),new THREE.Vector3(e.max.x,e.max.y,e.max.z));a.isEmpty()?console.warn("The x,y,z of box.min must be smaller than box.max"):(a.applyMatrix4(r),s.setSectionBox(a.min,a.max))},update:function(){this._sectionBox.update()},setObjectsById(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsById(e)})),this._sectionBox.update(),this._opt.viewer.render()},setObjectsByObjectData(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsByObjectData(e)})),this._sectionBox.update(),this._opt.viewer.render()},restoreObjects(){this._opt.viewer.getModels().forEach((e=>{e.clearLocalClipping()})),this._sectionBox.update(),this._opt.viewer.render()},setFilter(e){if(!(e&&e instanceof Array))return void console.log("conditions should be Array.");const t=this._opt.viewer,i=t.getViewer();for(const i of e){if(i.layerId){const e=t.getLayerManager().getLayer(i.layerId);if(!e)continue;i.modelId=e.getModelId()}let e;if(i.modelId)e=t.getModel(i.modelId);else if(e=t.getModel(),void 0===e)continue;i.objectIds?e.localClippingComponentsById(i.objectIds):i.objectData?e.localClippingComponentsByObjectData(i.objectData):e.localClippingComponentsByObjectData([])}this._sectionBox.update(),i.getModelManager().updatePickingMaterial(),this.fireSectionBoxVisibleChangedEvent(!1),this._opt.viewer.render()},clearFilter(){this.restoreObjects(),this.fireSectionBoxVisibleChangedEvent(!0)},changeClipDirection(e){this._opt.viewer.getViewer().editorManager.getToolByName("clipByBox").changeDirection(e),this.fireSectionBoxVisibleChangedEvent(!e)},rotateByAxis(e,t){if(o.send(n,"rotateByAxis"),"XAxis"!==e&&"YAxis"!==e&&"ZAxis"!==e)return void console.warn("Rotate axis must be XAxis,YAxis or ZAxis.");if(isNaN(t))return void console.warn("the degree input is not a number");let i,s=THREE.Math.degToRad(t);switch(e){case"XAxis":i="x";break;case"YAxis":i="z",s=-s;break;case"ZAxis":i="y"}const r=this._opt.viewer;r.getViewer().editorManager.getToolByName("clipByBox").rotateSectionBox(i,s),r.render()},setBoxByVectors(e,t,i,s){o.send(n,"setBoxByVectors"),this.reset();let r=e=>void 0!==e.x&&void 0!==e.y&&void 0!==e.z;if(!(r(e)&&r(t)&&r(i)&&r(s)))return void console.warn("the object input is invalid.");const a=new THREE.Vector3(t.x,t.y,0),l=new THREE.Vector3(i.x,i.y,0),h=new THREE.Vector3(0,0,s.z),d=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),c=new THREE.Vector3(-a.y,a.x,0),u=Math.abs(l.dot(c)/c.length()),g=Math.abs(h.z);let p=new THREE.Box3;p.min=new THREE.Vector3(e.x-d,e.y-u,e.z-g),p.max=new THREE.Vector3(e.x+d,e.y+u,e.z+g),this.setBox(p),a.y<0&&(a.x=-a.x,a.y=-a.y);const m=THREE.Math.radToDeg(Math.acos(a.clone().normalize().dot(new THREE.Vector3(1,0,0))));this.rotateByAxis("ZAxis",m)},enableHatch(e){this._opt.viewer._sectionPlane||y.GlobalData.ClippingCapsType!=e&&y.GlobalData.ClippingCapsType!=y.EnumClippingCapsTypes.ClipPlane&&(y.GlobalData.ClippingCapsType=e?y.EnumClippingCapsTypes.ClipBox:y.EnumClippingCapsTypes.None,this._sectionBox&&this._sectionBox.visibleCapsWireframe(e),e&&this._sectionBox&&this._sectionBox.getEditor().clipPlanes.reCalculateClippingIds(),this._opt.viewer.render())},isHatchEnabled:()=>y.GlobalData.ClippingCapsType==y.EnumClippingCapsTypes.ClipBox,enableSnap(e){y.GlobalData.SnapClippingLine=!!e},enableOutline(e){y.GlobalData.CalculateClippingLine!==e&&(y.GlobalData.CalculateClippingLine=!!e,this._sectionBox.reCalculateClippingIds())}},s.SectionBox=r}(),function(){let t=Object.freeze({Forward:"Forward",Reverse:"Reverse"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlaneDirection=t}(),function(){let t=Object.freeze({X:"X",Y:"Y",Z:"Z"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlanePlane=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlaneConfig=function(){return{viewer:null,progress:50,plane:e.Bimface.Plugins.Section.SectionPlanePlane.X,direction:e.Bimface.Plugins.Section.SectionPlaneDirection.Forward,isHatchEnabled:!0,hatchByMaterial:!1,enableSnap:!0,isOutlineEnabled:!0,filter:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CoordinateDrawer=class{constructor(e,t){this.coordinateSystem=e,this.viewer=t,this.container=this.viewer.domElement,this.mapDrawables={},this.initialize()}initialize(){this.xmlns="http://www.w3.org/2000/svg";var e=i.create("div","bf-coordinate-drawer");e.style.left="0px",e.style.top="0px",e.style.width=this.container.offsetWidth+"px",e.style.height=this.container.offsetHeight+"px",e.style.position="absolute",e.style.zIndex=5,this.group=document.createElementNS(this.xmlns,"svg"),this.group.setAttribute("width",this.container.offsetWidth+""),this.group.setAttribute("height",this.container.offsetHeight+""),e.appendChild(this.group),this.container.appendChild(e)}makeCircle(e,t){var i=this.mapDrawables;null==i[e]&&(i[e]=document.createElementNS(this.xmlns,"circle"),this.group.appendChild(i[e]));var n=i[e];n.style.fill=t.color||"#FF0000",n.setAttribute("r",t.radius+""),n.setAttribute("transform","translate("+t.center.x+","+t.center.y+")")}show(e,t){var i=this.getDrawable(e);i&&(i.style.display=t?"block":"none")}fill(e,t){this.getDrawable(e).style.fill=t?"block":"none"}makeLine(e,t){var i=this.mapDrawables;null==i[e]&&(i[e]=document.createElementNS(this.xmlns,"line"),this.group.appendChild(i[e]));var n=i[e];n.setAttribute("stroke",t.color||"#000000"),n.setAttribute("stroke-width",t.width||3),n.setAttribute("x1",t.start.x+""),n.setAttribute("y1",t.start.y+""),n.setAttribute("x2",t.end.x+""),n.setAttribute("y2",t.end.y+"")}makeDashLine(e,t){this.makeLine(e,t),this.mapDrawables[e].setAttribute("stroke-dasharray",t.dashArray)}makePolyline(e,t){var i=null,n=this.mapDrawables;null==n[e]&&(n[e]=document.createElementNS(this.xmlns,"polyline"),this.group.appendChild(n[e])),(i=n[e]).setAttribute("stroke",t.color||"#A9A9A9"),i.setAttribute("stroke-width",t.width||3),i.style.fill="none",i.setAttribute("points",t.points)}makeDefs(e){var t=this.mapDrawables;null==t[e]&&(t[e]=document.createElementNS(this.xmlns,"defs"),null==t.marker&&(t.marker=this.makeMarker(),t[e].appendChild(t.marker)),this.group.appendChild(t[e]))}makeMarker(){var e=document.createElementNS(this.xmlns,"marker");e.setAttribute("id","arrow"),e.setAttribute("viewBox","0 0 10 10"),e.setAttribute("refX","5"),e.setAttribute("refY","5"),e.setAttribute("markerWidth","6"),e.setAttribute("markerHeight","6"),e.setAttribute("orient","auto-start-reverse");var t=document.createElementNS(this.xmlns,"path");return t.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),t.style.fill="#11DAB7",this.mapDrawables.arrow=t,e.appendChild(t),e}getDrawable(e){return this.mapDrawables[e]}attach(){this.getDrawable("axisZ").setAttribute("marker-end","url(#arrow)")}setColor(e,t){this.getDrawable(e).setAttribute("stroke",t)}fill(e,t){this.getDrawable(e).style.fill=t}hideAll(e){let t=1==e?"none":"block";this.group.parentNode.style.display=t}destroy(){for(var e=this.group.children,t=0;t<e.length;t++)this.group.removeChild(e[t]);var i=this.group.parentNode;i&&i.removeChild(this.group)}}}(),function(){let t=Object.freeze({SectionPlaneUpdate:"SectionPlaneUpdate",SectionPlaneChanged:"SectionPlaneChanged"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionPlaneEvent=t}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CoordinateAction=class{constructor(e,t){this.coordinateSystem=e,this.viewer=e.viewer.getViewer(),this.drawingImpl=t,this.viewportOffset=this.viewer.domElement.getBoundingClientRect(),this.cameraControl=this.viewer.cameraControl,this.fillClipPlane=y.FillClipPlaneManager.getInstance(this.viewer.getScene()),this.initialize(),this.eventManager=e.viewer.getEventManager()}initialize(){this.arrowMouseDown=!1,this.circleXMouseDown=!1,this.circleYMouseDown=!1,this.firstClickDown=!0,this.firstRotate=!0,this.lineOut=!0,this.arrowOut=!0,this.translateStartPt=new THREE.Vector2,this.translateEndPt=new THREE.Vector2,this.rotateAngleA=0,this.rotateAngleB=0,this.config=this.coordinateSystem.config,this.sectionPlaneEvent=e.Bimface.Plugins.Section.SectionPlaneEvent}registerArrowEvents(){var e=this.drawingImpl.getDrawable("axisZ"),t=this,i=this.config.colors;e.onmouseover=function(){1!=t.circleXMouseDown&&1!=t.circleYMouseDown&&(t.drawingImpl.setColor("axisZ",i.highLight),t.drawingImpl.fill("arrow",i.highLight),t.drawingImpl.setColor("tipArcX",i.default),t.drawingImpl.fill("cubeX",i.default),t.drawingImpl.setColor("tipArcY",i.default),t.drawingImpl.fill("cubeY",i.default),t.lineOut=!1)},e.onmouseout=function(){1!=t.circleXMouseDown&&1!=t.circleYMouseDown&&0==t.arrowMouseDown&&1==t.arrowOut&&(t.drawingImpl.setColor("axisZ",i.arrow),t.drawingImpl.fill("arrow",i.arrow),t.drawingImpl.setColor("tipArcX",i.tipArcX),t.drawingImpl.fill("cubeX",i.cubeX),t.drawingImpl.setColor("tipArcY",i.tipArcY),t.drawingImpl.fill("cubeY",i.cubeY),t.lineOut=!0)},e.onmousedown=function(e){t.arrowMouseDown=!0,t.lineOut=!1;var i=t.config.colors;t.drawingImpl.setColor("axisZ",i.highLight),t.drawingImpl.fill("arrow",i.highLight),t.coordinateSystem.colorUpdate=!1,t.translateStartPt.set(e.clientX,e.clientY)};var n=this.drawingImpl.getDrawable("arrow");n.onmouseover=function(){if(1!=t.circleXMouseDown&&1!=t.circleYMouseDown){t.arrowOut=!1;var e=t.config.colors;t.drawingImpl.fill("arrow",e.highLight),t.drawingImpl.setColor("axisZ",e.highLight),t.drawingImpl.setColor("tipArcX",e.default),t.drawingImpl.fill("cubeX",e.default),t.drawingImpl.setColor("tipArcY",e.default),t.drawingImpl.fill("cubeY",e.default)}},n.onmouseout=function(){if(1!=t.circleXMouseDown&&1!=t.circleYMouseDown&&0==t.arrowMouseDown&&1==t.lineOut){t.arrowOut=!0;var e=t.config.colors;t.drawingImpl.setColor("axisZ",e.arrow),t.drawingImpl.fill("arrow",e.arrow),t.drawingImpl.setColor("tipArcX",e.tipArcX),t.drawingImpl.fill("cubeX",e.cubeX),t.drawingImpl.setColor("tipArcY",e.tipArcY),t.drawingImpl.fill("cubeY",e.cubeY)}},n.onmousedown=function(e){t.arrowMouseDown=!0,t.arrowOut=!1;var i=t.config.colors;t.drawingImpl.setColor("axisZ",i.highLight),t.drawingImpl.fill("arrow",i.highLight),t.translateStartPt.set(e.clientX,e.clientY)},document.onmousemove=function(e){if(1==t.arrowMouseDown){if(t.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1,t.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0}),!(e.clientX==t.translateStartPt.x&&e.clientY==t.translateStartPt.y)){var i=t.fillClipPlane.renderClipPlane,n=i.normal.clone();n.w=i.constant;var o=t.cameraControl.movePlane(n,e,t.translateStartPt,!1,t.fillClipPlane.position.clone());null!=o&&t.fillClipPlane.offset(o),t.translateStartPt.set(e.clientX,e.clientY),t.cameraControl.setCameraChanging(!0),t.cameraControl.update(!0)}t.coordinateSystem.update();var s=t.config.colors;t.drawingImpl.setColor("axisZ",s.highLight),t.drawingImpl.fill("arrow",s.highLight),t.drawingImpl.setColor("tipArcX",s.default),t.drawingImpl.fill("cubeX",s.default),t.drawingImpl.setColor("tipArcY",s.default),t.drawingImpl.fill("cubeY",s.default),e.preventDefault(),e.stopPropagation(),t.fireSectionPlaneChangedEvent()}},document.onmouseup=function(){if(0==t.arrowMouseDown)return;t.arrowMouseDown=!1,t.coordinateSystem.colorUpdate=!0;var e=t.config.colors;t.drawingImpl.setColor("axisZ",e.arrow),t.drawingImpl.fill("arrow",e.arrow),t.drawingImpl.setColor("tipArcX",e.tipArcX),t.drawingImpl.fill("cubeX",e.cubeX),t.drawingImpl.setColor("tipArcY",e.tipArcY),t.drawingImpl.fill("cubeY",e.cubeY),y.GlobalData.ClippingCaps=!0,t.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_MOUSE_MOVE_END,onClipPlane:!0}),t.fillClipPlane.calculateClippingIds(),t.viewer.render()}}registerCircleXEvents(){var e=this,t=this.config.colors,i=this.drawingImpl.getDrawable("tipArcX");i.onmousedown=function(){e.circleXMouseDown=!0,e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.enableCircleXMovement()},i.onmouseout=function(){0==e.circleXMouseDown&&(e.drawingImpl.setColor("axisZ",t.arrow),e.drawingImpl.fill("arrow",t.arrow),e.drawingImpl.setColor("tipArcY",t.tipArcY),e.drawingImpl.fill("cubeY",t.cubeY),e.coordinateSystem.circleToArc("tipArcX"))},document.addEventListener("mouseup",(function(){if(1==e.circleXMouseDown){y.GlobalData.ClippingCaps=!0,e.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_MOUSE_MOVE_END,onClipPlane:!0}),e.fillClipPlane.calculateClippingIds(),e.viewer.render()}e.circleXMouseDown=!1,e.circleXMouseDown=!1,e.firstClickDown=!0,e.firstRotate=!1,e.lastRotateX=0,e.lastRotateY=0,e.drawingImpl.show("tipArcY",!0),e.drawingImpl.show("axisY",!0),e.drawingImpl.show("axisZ",!0),e.drawingImpl.show("cubeY",!0),e.coordinateSystem.update(),e.drawingImpl.show("dashLineX",!1),e.drawingImpl.setColor("axisZ",t.arrow),e.drawingImpl.fill("arrow",t.arrow)}))}registerCircleYEvents(){var e=this,t=this.config.colors,i=this.drawingImpl.getDrawable("tipArcY");i.onmousedown=function(){e.circleYMouseDown=!0,e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.enableCircleYMovement()},i.onmouseout=function(){0==e.circleYMouseDown&&(e.drawingImpl.setColor("axisZ",t.arrow),e.drawingImpl.fill("arrow",t.arrow),e.coordinateSystem.circleToArc("tipArcY"),e.drawingImpl.setColor("tipArcX",t.tipArcX),e.drawingImpl.fill("cubeX",t.cubeX))},document.addEventListener("mouseup",(function(){if(1==e.circleYMouseDown){y.GlobalData.ClippingCaps=!0,e.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_MOUSE_MOVE_END,onClipPlane:!0}),e.fillClipPlane.calculateClippingIds(),e.viewer.render()}e.circleYMouseDown=!1,e.drawingImpl.show("tipArcX",!0),e.drawingImpl.show("cubeX",!0),e.coordinateSystem.update(),e.drawingImpl.show("dashLineY",!1),e.drawingImpl.setColor("axisZ",t.arrow),e.drawingImpl.fill("arrow",t.arrow)}))}enableCircleXMovement(){var e=this,t=this.config.colors;document.addEventListener("mousemove",(function(i){if(1==e.circleXMouseDown){e.drawingImpl.show("dashLineX",!0),e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1,e.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0});var n=e.fillClipPlane.normalIndex,o=e.viewportOffset,s=new THREE.Vector2(i.clientX-o.left,i.clientY-o.top),r=e.calcRotateAngleIndex(s,e.coordinateSystem.discretePointsX);1==e.firstClickDown&&(e.lastIndex=r);var a=2*(r-e.lastIndex);(n>3||"Reverse"==e.coordinateSystem.planeDirection)&&(a=-a),e.drawingImpl.show("tipArcY",!1),e.coordinateSystem.updateAxisZ();var l=e.fillClipPlane.renderClipPlane.normal.clone(),h=e.coordinateSystem.getCoordinateAxis(),d=e.config.styles;e.coordinateSystem.drawClipPlaneCircle("tipArcZ",h.start.clone(),d.auxCircleRadius,e.coordinateSystem.dirX,l);var c=e.coordinateSystem.drawingToCanvas(h.start.clone()),u=e.coordinateSystem.drawingToCanvas(h.endY.clone());e.coordinateSystem.drawAxisY(c,u,t.highLight),e.coordinateSystem.drawCubeX("cubeX",u,d.cubeRadius),e.drawingImpl.show("cubeY",!1);var g="x";n<2&&(g="y"),e.fillClipPlane.rotateAngleOffset(a,g),e.coordinateSystem.backwardCoordinate(),1==e.firstClickDown?e.firstClickDown=!1:e.lastIndex=r,e.translateStartPt.set(i.clientX,i.clientY),e.viewer.render(),i.preventDefault(),i.stopPropagation(),e.fireSectionPlaneChangedEvent()}}))}enableCircleYMovement(){var e=this,t=this.config.colors;document.addEventListener("mousemove",(function(i){if(1==e.circleYMouseDown){e.drawingImpl.show("dashLineY",!0),e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1,e.viewer.modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0});var n=e.fillClipPlane.normalIndex,o=e.viewportOffset,s=new THREE.Vector2(i.clientX-o.left,i.clientY-o.top),r=e.calcRotateAngleIndex(s,e.coordinateSystem.discretePointsY);1==e.firstClickDown&&(e.lastIndex=r);var a=2*(r-e.lastIndex);n>3&&(a=-a,"Reverse"==e.coordinateSystem.planeDirection&&(a=-a)),e.drawingImpl.show("tipArcX",!1),e.coordinateSystem.updateAxisZ();var l=e.fillClipPlane.renderClipPlane.normal.clone(),h=e.coordinateSystem.getCoordinateAxis(),d=e.config.styles;e.coordinateSystem.drawClipPlaneCircle("tipArcZ",h.start.clone(),d.auxCircleRadius,e.coordinateSystem.dirX.clone(),l.clone());var c=e.coordinateSystem.drawingToCanvas(h.start.clone()),u=e.coordinateSystem.drawingToCanvas(h.endX.clone());e.coordinateSystem.drawAxisX(c,u,t.highLight),e.coordinateSystem.drawCubeY("cubeY",u,d.cubeRadius),e.drawingImpl.show("cubeX",!1);var g="z";n>3&&(g="y"),e.fillClipPlane.rotateAngleOffset(a,g),e.coordinateSystem.backwardCoordinate(),1==e.firstClickDown?e.firstClickDown=!1:e.lastIndex=r,e.translateStartPt.set(i.clientX,i.clientY),e.viewer.render(),i.preventDefault(),i.stopPropagation(),e.fireSectionPlaneChangedEvent()}}))}registerTipArcXEvents(){var e=this,t=this.config.colors,i=this.drawingImpl.getDrawable("tipArcX");i.onmouseover=function(){0==e.circleYMouseDown&&(e.coordinateSystem.arcToCircle("tipArcX"),e.drawingImpl.setColor("tipArcY",t.default),e.drawingImpl.fill("cubeY",t.default),e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.registerCircleXEvents())},i.onmouseout=function(){0==e.circleXMouseDown&&e.coordinateSystem.circleToArc("tipArcX")}}registerTipArcYEvents(){var e=this,t=this.config.colors,i=this.drawingImpl.getDrawable("tipArcY");i.onmouseover=function(){0==e.circleXMouseDown&&(e.coordinateSystem.arcToCircle("tipArcY"),e.drawingImpl.setColor("tipArcX",t.default),e.drawingImpl.fill("cubeX",t.default),e.drawingImpl.setColor("axisZ",t.default),e.drawingImpl.fill("arrow",t.default),e.registerCircleYEvents())},i.onmouseout=function(){0==e.circleYMouseDown&&e.coordinateSystem.circleToArc("tipArcY")}}calcRotateAngleIndex(e,t){for(var i=this.coordinateSystem.cOrigin,n=this.createLine(e,i),o=-1,s=Number.POSITIVE_INFINITY,r=0;r<90;r++){var a=t[r].clone(),l=this.disPointToLine(a,n);l<s&&(s=l,o=r)}var h=90+o;return t[o].clone().distanceTo(e)<t[h].clone().distanceTo(e)?o:h}createLine(e,t){var i={};if(e.x==t.x)i.A=1,i.B=0,i.C=-e.x;else{var n=(t.y-e.y)/(t.x-e.x),o=t.y-n*t.x;i.A=n,i.B=-1,i.C=o}return i}disPointToLine(e,t){return Math.abs(t.A*e.x+t.B*e.y+t.C)/Math.sqrt(t.A*t.A+t.B*t.B)}fireSectionPlaneChangedEvent(){const e=this.coordinateSystem.viewer._sectionPlane;this.eventManager.fireEvent(this.sectionPlaneEvent.SectionPlaneChanged,e.getSectionPlane())}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").CoordinateSystemConfig=function(){return{colors:{tipArcX:"#0000FF",cubeX:"#0000FF",tipArcY:"#FF0000",cubeY:"#FF0000",highLight:"#FFFF00",tipLine:"#11DAB7",arrow:"#11DAB7",default:"#A9A9A9"},styles:{dashArray:"10 8",originRadius:5,auxCircleRadius:100,tipLineLength:500,cubeRadius:5,axisXWidth:2,axisYWidth:2,axisZWidth:3,axisXLength:100,axisYLength:100,axisZLength:165,segments:180,tipArcLeftCounts:15,tipArcRightCounts:60}}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");const i="#A8A8A8",n="#F9E000",o="#32D3A6",s="#FFA200",r="#FF2905",a="#1922FB";class l{constructor(e){let t=new THREE.ShaderMaterial({type:"BasicMaterial",uniforms:THREE.UniformsUtils.clone(THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog])),fragmentShader:"\n uniform vec3 diffuse;\n uniform float opacity;\n\n void main() {\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <alphatest_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n\n }\n ",clipping:!1});return Object.defineProperties(t,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}}}),t.setValues(e),t}}t.CoordinateControl=class{constructor(t){this.object3D=new THREE.Object3D,this.name="SectionPlaneControl",this._config=t,this.viewer=t.viewer,this.system=t.system,this.cameraControl=this.viewer.getViewer().cameraControl,this.fillClipPlane=y.FillClipPlaneManager.getInstance(this.viewer.getViewer().getScene()),this.eventManager=this.system.viewer.getEventManager(),this.sectionPlaneEvent=e.Bimface.Plugins.Section.SectionPlaneEvent,this.viewportOffset=this.viewer.getViewer().domElement.getBoundingClientRect(),this.defaultDistance=1500,this.firstClickDown=!0,this.arrowMouseDown=!1,this.circleXMouseDown=!1,this.circleYMouseDown=!1,this.centerPosition=null,this.projectCenterPosition=new THREE.Vector3,this.planeMouseDown=!1,this.translateStartPt=new THREE.Vector2,this.object3D.visible=!1,this._destroyed=!1,this.raycaster=new THREE.Raycaster;let i=this;this.domElementEvents=[{element:this.viewer.getViewer().domElement,type:"mousemove",event:e=>{if(this.arrowMouseDown){if(i.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1,this.viewer.getViewer().modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_PLANE_MOUSE_MOVE,onClipPlane:!0}),!(e.clientX==i.translateStartPt.x&&e.clientY==i.translateStartPt.y)){var t=i.fillClipPlane.renderClipPlane,n=t.normal.clone();n.w=t.constant;var o=i.cameraControl.movePlane(n,e,i.translateStartPt,!1,i.fillClipPlane.state.position.clone());null!=o&&i.fillClipPlane.offset(o),i.translateStartPt.set(e.clientX,e.clientY),i.cameraControl.setCameraChanging(!0),i.cameraControl.update(!0)}this.centerPosition&&(this.centerPosition=this.fillClipPlane.state.position.clone().add(this.dirCenter.clone().multiplyScalar(this.lengthCenter||0)),this.fillClipPlane.updateBasePoint(this.centerPosition),this.fillClipPlane.update());let s=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;return this.object3D.position.set(s.x,s.y,s.z),i.update(),i.fireSectionPlaneChangedEvent(),e.preventDefault(),void e.stopPropagation()}if(this.circleYMouseDown){i.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1;let t=this.system.getCoordinateAxisForPoint(this.centerPosition);var s=i.fillClipPlane.normalIndex;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},this.intersectPlane);this.oldDir||(this.oldDir=n.clone().sub(t.start.clone()).normalize());let o=n.clone().sub(t.start.clone()).normalize();const r=this.oldDir.clone().cross(o);let a=o.angleTo(this.oldDir);r.angleTo(this.intersectPlane.normal)<Math.PI/2&&(a=-a);let l=new THREE.Vector3(0,0,1);0==s||1==s?(0==s&&(a=-a),l=new THREE.Vector3(0,0,1)):2==s||3==s?(2==s&&(a=-a),l=new THREE.Vector3(1,0,0)):4!=s&&5!=s||(l=new THREE.Vector3(1,0,0));const h=t.start.clone().sub(i.fillClipPlane.state.position);i.fillClipPlane.state.position.add(h);const d=i.fillClipPlane.state.quaternion.clone().invert(),c=(new THREE.Quaternion).setFromAxisAngle(l,a);i.fillClipPlane.state.quaternion.multiply(c),i.fillClipPlane.state.position.sub(h.applyQuaternion(d).applyQuaternion(i.fillClipPlane.state.quaternion)),i.fillClipPlane.update();let u=i.fillClipPlane.uniforms.vClipPlane.value[0],g=(new THREE.Plane).setComponents(-u.x,-u.y,-u.z,-u.w),p=g.distanceToPoint(i.fillClipPlane.center);return i.fillClipPlane.planeOffset=p,i.fillClipPlane.state.planeMeshCenter.copy(i.fillClipPlane.center).add(g.normal.clone().multiplyScalar(p)),this.oldDir=o,i.update(),i.viewer.render(),e.preventDefault(),e.stopPropagation(),void i.fireSectionPlaneChangedEvent()}if(this.circleXMouseDown){i.fillClipPlane.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1;var r=this.system.getCoordinateAxisForPoint(this.centerPosition);s=i.fillClipPlane.normalIndex;let t=this.getIntersectPosition({x:e.clientX,y:e.clientY},this.intersectPlane);this.oldDir||(this.oldDir=t.clone().sub(r.start.clone()).normalize());let n=t.clone().sub(r.start.clone()).normalize();const o=this.oldDir.clone().cross(n);let a=n.angleTo(this.oldDir);o.angleTo(this.intersectPlane.normal)<Math.PI/2&&(a=-a);let l=new THREE.Vector3(0,1,0);0==s||1==s||2==s||3==s?l=new THREE.Vector3(0,1,0):4!=s&&5!=s||(4==s&&(a=-a),l=new THREE.Vector3(0,0,1));const h=r.start.clone().sub(i.fillClipPlane.state.position);i.fillClipPlane.state.position.add(h);const d=i.fillClipPlane.state.quaternion.clone().invert(),c=(new THREE.Quaternion).setFromAxisAngle(l,a);i.fillClipPlane.state.quaternion.multiply(c),i.fillClipPlane.state.position.sub(h.applyQuaternion(d).applyQuaternion(i.fillClipPlane.state.quaternion)),i.fillClipPlane.update(),this.oldDir=n;let u=i.fillClipPlane.uniforms.vClipPlane.value[0],g=(new THREE.Plane).setComponents(-u.x,-u.y,-u.z,-u.w),p=g.distanceToPoint(i.fillClipPlane.center);return i.fillClipPlane.planeOffset=p,i.fillClipPlane.state.planeMeshCenter.copy(i.fillClipPlane.center).add(g.normal.clone().multiplyScalar(p)),i.update(),i.viewer.render(),e.preventDefault(),e.stopPropagation(),void i.fireSectionPlaneChangedEvent()}if(this.planeMouseDown){var a=new THREE.Vector2(e.clientX-this.offsetCenterPoint.x+i.viewportOffset.left,e.clientY-this.offsetCenterPoint.y+i.viewportOffset.top),l=this.viewer.getViewer().cameraControl.getRaycaster(a.x,a.y),h=[];if(this.fillClipPlane.planeMesh.raycast(l,h),h.length>0){const e=h[0].point;i.centerPosition=e,i.fillClipPlane.updateBasePoint(i.centerPosition)}let t=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;return this.object3D.position.set(t.x,t.y,t.z),i.update(),i.viewer.render(),e.preventDefault(),void e.stopPropagation()}a=new THREE.Vector2(e.clientX,e.clientY);let d=(l=this.viewer.getViewer().cameraControl.getRaycaster(a.x,a.y)).ray.origin.clone(),c=l.ray.direction.clone();this.raycaster.set(d,c),this.hitTest(this.raycaster)}},{element:this.viewer.getViewer().domElement,type:"mousedown",event:e=>{if(this.picked){if(this.centerPosition||(this.centerPosition=this.system.getCoordinateAxisForPoint().start),this.fillClipPlane.setBasePoint(this.centerPosition),"arrowRigidBody"==this.picked.name)this.arrowMouseDown=!0,i.translateStartPt.set(e.clientX,e.clientY),this.centerPosition&&(this.dirCenter=this.centerPosition.clone().sub(this.fillClipPlane.state.position.clone()).normalize(),this.lengthCenter=this.centerPosition.clone().sub(this.fillClipPlane.state.position.clone()).length());else if("circleEdgeRigidBodyX"==this.picked.name){this.circleXMouseDown=!0;var t=this.system.getCoordinateAxisForPoint(this.centerPosition);this.mouseDownQuaternion=this.object3D.quaternion.clone();let i=new THREE.Plane;i.setFromCoplanarPoints(t.start,t.endZ,t.endX),this.intersectPlane=i;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},i);this.oldDir=n.clone().sub(t.start.clone()).normalize()}else if("circleEdgeRigidBodyY"==this.picked.name){this.circleYMouseDown=!0;t=this.system.getCoordinateAxisForPoint(this.centerPosition);this.mouseDownQuaternion=this.object3D.quaternion.clone();let i=new THREE.Plane;i.setFromCoplanarPoints(t.start,t.endZ,t.endY),this.intersectPlane=i;let n=this.getIntersectPosition({x:e.clientX,y:e.clientY},i);this.oldDir=n.clone().sub(t.start.clone()).normalize()}else if("plane"==this.picked.name){this.planeMouseDown=!0;t=this.system.getCoordinateAxisForPoint(this.centerPosition);let i=this.viewer.worldToClient(this.viewer.sceneToWorld(t.start));this.offsetCenterPoint={x:e.clientX-i.x,y:e.clientY-i.y}}e.preventDefault(),e.stopPropagation()}}},{element:this.viewer.getViewer().domElement,type:"mouseup",event:e=>{if(i.update(),this.arrowMouseDown||this.circleXMouseDown||this.circleYMouseDown){y.GlobalData.ClippingCaps=!0,i.fillClipPlane.calculateClippingIds(),this.viewer.getViewer().modelManager.dispatchEvent({type:y.EVENTS.ON_CLIP_MOUSE_MOVE_END,onClipPlane:!0})}this.arrowMouseDown=!1,this.circleXMouseDown=!1,this.circleYMouseDown=!1,this.planeMouseDown=!1,this.firstClickDown=!0,this.oldDir=null,i.viewer.render()}}],this.addDomElementEvents()}addDomElementEvents(){this.domElementEvents.forEach((({element:e,type:t,useCapture:i,event:n})=>{e.addEventListener(t,n,i)}))}getIntersectPosition(e,t){const i=this.viewer.getViewer().cameraControl.getRaycaster(e.x,e.y).ray.direction.clone().normalize(),n=this.viewer.getViewer().camera.position.clone(),o=new THREE.Ray(n,i),s=new THREE.Vector3;return o.intersectPlane(t,s),s}hitTest(e){if(this.picked=null,this.object3D.visible){if(this.object3D.children.some((t=>{const i=[];return t.canRaycast&&t.raycast(e,i),i.length>0&&(this.picked=t),i.length>0})),this.arrowHover=!1,this.planeHover=!1,this.circleEdgeXHover=!1,this.circleEdgeYHover=!1,this.picked)switch(this.lastPickedName&&this.lastPickedName==this.picked.name||this.highlightActionList.forEach((e=>e.stop())),this.lastPickedName=this.picked.name,this.picked.name){case"plane":this.planeHover=!0,this.handlePlaneHoverEvent();break;case"arrowRigidBody":this.arrowHover=!0,this.handleArrowHoverEvent();break;case"circleEdgeRigidBodyX":this.circleEdgeXHover=!0,this.handleCircleEdgeXHoverEvent();break;case"circleEdgeRigidBodyY":this.circleEdgeYHover=!0,this.handleCircleEdgeYHoverEvent()}else this.lastPickedName=null,this.handleNormaleEvent();this.viewer.render()}}handlePlaneHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeXGray,this.actionCircleEdgeYGray,this.actionPlaneHightlight])}handlePlaneMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!0,this.axisDashedY.visible=!0,this.axisDashedZ.visible=!0,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!0,this.circleEdgeGrayY.visible=!0,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!0,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!0,this.object3D.updateMatrixWorld()}handleArrowHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZHightlight,this.actionSphereZHightlight,this.actionArrowHightlight,this.actionCircleEdgeXGray,this.actionCircleEdgeYGray,this.actionPlaneGray])}handleArrowMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!0,this.axisDashedY.visible=!0,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!0,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!0,this.arrowGray.visible=!1,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleCircleEdgeXHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!0,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeYGray,this.actionPlaneGray,this.actionCircleEdgeHoverX])}handleCircleEdgeXMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!0,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!1,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!1,this.sphereY.visible=!1,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!0,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleCircleEdgeYHoverEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!0,this.plane.visible=!1,this.planeGray.visible=!0,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.highlightHandle([this.actionAxisZGray,this.actionSphereZGray,this.actionArrowGray,this.actionCircleEdgeXGray,this.actionPlaneGray,this.actionCircleEdgeHoverY])}handleCircleEdgeYMoveEvent(){this.axisX.visible=!1,this.axisY.visible=!1,this.axisZ.visible=!1,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!0,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!0,this.axisGrayZ.visible=!1,this.arrow.visible=!1,this.arrowHighlight.visible=!1,this.arrowGray.visible=!0,this.circleEdgeX.visible=!1,this.circleEdgeY.visible=!1,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!1,this.circleEdgeHoverY.visible=!0,this.plane.visible=!1,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!1,this.sphereY.visible=!1,this.sphereZ.visible=!1,this.sphereHighlightZ.visible=!0,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld()}handleNormaleEvent(){this.axisX.visible=!0,this.axisY.visible=!0,this.axisZ.visible=!0,this.axisDashedX.visible=!1,this.axisDashedY.visible=!1,this.axisDashedZ.visible=!1,this.axisZArrow.visible=!1,this.axisHighlightZ.visible=!1,this.axisHighlightZPoint.visible=!1,this.axisGrayZ.visible=!1,this.arrow.visible=!0,this.arrowHighlight.visible=!1,this.arrowGray.visible=!1,this.circleEdgeX.visible=!0,this.circleEdgeY.visible=!0,this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX.visible=!0,this.circleEdgeHoverY.visible=!0,this.plane.visible=!0,this.planeGray.visible=!1,this.planeHighlight.visible=!1,this.sphereX.visible=!0,this.sphereY.visible=!0,this.sphereZ.visible=!0,this.sphereHighlightZ.visible=!1,this.sphereGrayZ.visible=!1,this.object3D.updateMatrixWorld(),this.cancelHighlight()}highlightHandle(e){this.highlightActionList=[],this.animationList=[],e.map((e=>{this.highlightActionList.push(e.action),this.addAnimation(e)})),this.setHighlight()}getLinearColor(e){const t=new THREE.Color(e),i=e=>{let t;return t=e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),t},n=i(t.r),o=i(t.g),s=i(t.b);new THREE.Color(n,o,s);return t}createLine(e,t,n={}){const o=new THREE.LineGeometry;let s;o.setPositions(t),n.isDashed?(s=new THREE.LineMaterial({color:this.getLinearColor(n.color||i),linewidth:n.linewidth||2,dashed:!0,dashSize:1,gapSize:1,dashScale:.1,depthTest:!1}),s.defines.USE_DASH=""):s=new THREE.LineMaterial({color:this.getLinearColor(n.color||i),linewidth:n.linewidth||2,dashed:!1,depthTest:!1}),s.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const r=new THREE.Line2(o,s);return r.computeLineDistances(),r.renderOrder=y.EnumRenderOrder.Effect+1e3,r.name=e,r}createArrow(e,t,i,n){const o=new THREE.BufferGeometry,s=new Float32Array([-7,0,0,7,0,0,0,0,14]);o.setAttribute("position",new THREE.BufferAttribute(s,3));const r=new l({depthTest:!1,color:this.getLinearColor(n)}),a=new THREE.Mesh(o,r),h=new THREE.Vector3(...Object.values(i)).normalize(),d=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),h);a.applyQuaternion(d);const c=new THREE.Vector3(...Object.values(t));return a.position.set(c.x,c.y,c.z),a.name=e,a.renderOrder=y.EnumRenderOrder.Effect+1e3,a.updateMatrixWorld(!0),a}createArrowRigidBody(e,t,i,n){const o=i.length(),s=new THREE.CylinderGeometry(5,5,o,3),r=y.MaterialUtil.createStandardMaterial(n);var a=new THREE.Mesh(s,r);a.name=e;const l=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),i.clone().normalize());return a.applyQuaternion(l),a.position.set(t.x,t.y,t.z),a.canRaycast=!0,a.updateMatrixWorld(),a.visible=!1,a}createCircleEdge(e,t,i,n,o,s,r){const a=new THREE.EllipseCurve(0,0,i,i,n,n+o,!1,0).getPoints(128),l=[];a.forEach((e=>l.push(e.x||0,e.y||0,e.z||0)));const h=new THREE.LineGeometry;h.setPositions(l);let d=new THREE.LineMaterial({linewidth:s.linewidth||2,dashed:!1,depthTest:!1,transparent:!0,color:this.getLinearColor(s.color)});d.resolution.set(this.viewer.getViewer().domElement.clientWidth,this.viewer.getViewer().domElement.clientHeight);const c=new THREE.Line2(h,d);return c.name=e,c.position.set(t.x,t.y,t.z),r&&c.quaternion.set(r.x,r.y,r.z,r.w),c.renderOrder=y.EnumRenderOrder.Effect+100,c}createCircleEdgeRigidBody(e,t,n,o){const s=new THREE.TorusGeometry(n,3,5,16,Math.PI/2);let r=new THREE.MeshBasicMaterial({color:i});const a=new THREE.Mesh(s,r);return a.canRaycast=!0,a.name=e,a.position.set(t.x,t.y,t.z),o&&a.quaternion.set(o.x,o.y,o.z,o.w),a.visible=!1,a}createPlane(e,t,i,n){const o=new THREE.BufferGeometry,s=new Float32Array([-10,0,-10,10,0,-10,10,0,10,10,0,10,-10,0,10,-10,0,-10]);o.setAttribute("position",new THREE.BufferAttribute(s,3));const r=new l({depthTest:!1,side:2,transparent:!0,color:this.getLinearColor(n)}),a=new THREE.Mesh(o,r);i=new THREE.Vector3(...Object.values(i)).normalize();const h=new THREE.Vector3(...Object.values(t));a.position.set(h.x,h.y,h.z);let d=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),new THREE.Vector3(1,0,0));return a.quaternion.set(d.x,d.y,d.z,d.w),a.name=e,a.canRaycast=!0,a.renderOrder=y.EnumRenderOrder.Effect+1e3,a.updateMatrixWorld(!0),a}createSphere(e,t,n={}){var o=new THREE.SphereGeometry(6,200,200);const s=new l({depthTest:!1,transparent:!0,color:this.getLinearColor(n.color||i)});var r=new THREE.Mesh(o,s);return r.name=e,r.renderOrder=y.EnumRenderOrder.Effect+100,r.position.set(t.x,t.y,t.z),r}createBasicMaterial(e,t){let i=new THREE.Color(t);return new THREE.ShaderMaterial({fragmentShader:`void main() {\n\tgl_FragColor = vec4( ${i.r}, ${i.g}, ${i.b}, 1 );\n}`,...e})}getPointFormDir(e,t){var i=this.system.config.styles;return e.clone().add(t.clone().multiplyScalar(i.axisXLength))}changeVisible(e){this.object3D.visible=e,this.object3D.updateMatrixWorld()}resetCenterPosition(){this.centerPosition=null,this.fillClipPlane.updateBasePoint(this.fillClipPlane.state.position),this.update()}centerPositionProjectionToClipPlane(){if(this.centerPosition){var e=this.system.getCoordinateAxisForPoint();let t=new THREE.Plane;t.setFromCoplanarPoints(e.start,e.endY,e.endX),t.projectPoint(this.centerPosition,this.projectCenterPosition),this.centerPosition.copy(this.projectCenterPosition),this.update()}}getCoordinateAxis(){var e=new THREE.Vector3(1,0,0),t=new THREE.Vector3(0,1,0),i=new THREE.Vector3(0,0,1),n=this.system.config.styles,o=new THREE.Vector3(0,0,0),s=o.clone().add(i.clone().multiplyScalar(n.axisXLength)),r=o.clone().add(t.clone().multiplyScalar(n.axisYLength)),a=o.clone().add(e.clone().multiplyScalar(n.axisZLength)),l=o.clone().add(e.clone().multiplyScalar(n.axisXLength)),h=o.clone().add(i.clone().multiplyScalar(n.axisXLength/5)),d=o.clone().add(t.clone().multiplyScalar(n.axisYLength/5));return{start:o,endX:s,endY:r,endZ:a,endZPoint:l,endPlaneX:h,endPlaneY:d}}init(){this.addItems(),this.update(),this.animationTimeScale=4,this.highlightActionList=[],this.animationList=[],this.clock=new THREE.Clock;const e=()=>{if(this._destroyed)return;const t=this.clock.getDelta();let i=!1;this.animationList.forEach((({mixer:e,action:n,object:o})=>{n.isRunning()&&(i=!0,e.update(t),o.updateMatrixWorld(!0))})),i&&this.viewer.getViewer().render(),requestAnimationFrame(e)};e(),this.initHighlightAnimation()}setCenterPosition(e){this.centerPosition=e,this.update()}update(){let e=this.centerPosition?this.centerPosition:this.fillClipPlane.state?this.fillClipPlane.state.position:this.fillClipPlane.position;this.object3D.position.set(e.x,e.y,e.z);var t=this.system.cameraControl.camera,i=this.centerPosition||this.fillClipPlane.state.position,o=t.position.clone().sub(i.clone()).length();this.viewer.getViewer().camera.isPerspective||(o=1/(this.viewer.getViewer().camera.zoom/this.viewer.getViewer().camera.position.clone().sub(this.viewer.getViewer().camera.target.clone()).length()));var s=o/this.defaultDistance;this.object3D.scale.set(s,s,s);let r,a=this.fillClipPlane.state.quaternion;if(0===this.fillClipPlane.normalIndex?r=null:1===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(-1,0,0)):2===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,-1)):3===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,1)):4===this.fillClipPlane.normalIndex?r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(-1,0,0)).multiply((new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0))):5===this.fillClipPlane.normalIndex&&(r=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(0,-1,0)).multiply((new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(1,0,0),new THREE.Vector3(0,0,1)))),r&&(a=a.clone().multiply(r)),this.object3D.quaternion.set(a.x,a.y,a.z,a.w),this.planeHover&&this.handlePlaneHoverEvent(),this.planeMouseDown&&this.handlePlaneMoveEvent(),this.arrowHover&&this.handleArrowHoverEvent(),this.arrowMouseDown&&this.handleArrowMoveEvent(),this.circleEdgeXHover&&this.handleCircleEdgeXHoverEvent(),this.circleXMouseDown&&this.handleCircleEdgeXMoveEvent(),this.circleEdgeYHover&&this.handleCircleEdgeYHoverEvent(),this.circleYMouseDown&&this.handleCircleEdgeYMoveEvent(),this.axisStartDir&&this.object3D.remove(this.axisStartDir),this.circleXMouseDown||this.circleYMouseDown){let e=new THREE.Vector3(0,0,0),t=this.getPointFormDir(e,new THREE.Vector3(1,0,0));this.axisStartDir=this.createLine("axisStartDir",[...Object.values(e),...Object.values(t)],{linewidth:1,color:n});let i=this.object3D.quaternion.clone().invert();i=i.clone().multiply(this.mouseDownQuaternion.clone()),this.axisStartDir.quaternion.multiply(i),this.object3D.add(this.axisStartDir)}this.updateArrowDirection(this.arrow),this.updateArrowDirection(this.arrowHighlight),this.updateArrowDirection(this.arrowGray),this.object3D.updateMatrixWorld()}updateArrowDirection(e){const t=this.object3D.quaternion.clone().invert();let i=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,0,1),new THREE.Vector3(1,0,0));const n=new THREE.Vector3(0,1,0).applyQuaternion(i),o=new THREE.Plane(new THREE.Vector3(...Object.values(new THREE.Vector3(1,0,0))).normalize()),s=new THREE.Vector3;let r=this.viewer.getViewer().camera.target.clone().sub(this.viewer.getViewer().camera.position).normalize();o.projectPoint(r.clone().applyQuaternion(t),s);const a=(new THREE.Quaternion).setFromUnitVectors(n,s.normalize()).multiply(i.clone());e.quaternion.set(a.x,a.y,a.z,a.w),e.updateMatrixWorld(!0)}addItems(){var e=this.getCoordinateAxis();this.axisX&&this.object3D.remove(this.axisX),this.axisY&&this.object3D.remove(this.axisY),this.axisZ&&this.object3D.remove(this.axisZ),this.axisX=this.createLine("axisX",[...Object.values(e.start),...Object.values(e.endX)]),this.axisY=this.createLine("axisY",[...Object.values(e.start),...Object.values(e.endY)]),this.axisZ=this.createLine("axisZ",[...Object.values(e.start),...Object.values(e.endZ)],{color:o}),this.object3D.add(this.axisX),this.object3D.add(this.axisY),this.object3D.add(this.axisZ),this.axisDashedX&&this.object3D.remove(this.axisDashedX),this.axisDashedX=this.createLine("axisDashedX",[...Object.values(e.start),...Object.values(e.endX)],{isDashed:!0}),this.object3D.add(this.axisDashedX),this.axisDashedX.visible=!1,this.axisDashedY&&this.object3D.remove(this.axisDashedY),this.axisDashedY=this.createLine("axisDashedX",[...Object.values(e.start),...Object.values(e.endY)],{isDashed:!0}),this.object3D.add(this.axisDashedY),this.axisDashedY.visible=!1,this.axisDashedZ&&this.object3D.remove(this.axisDashedZ),this.axisDashedZ=this.createLine("axisDashedZ",[...Object.values(e.start),...Object.values(e.endZPoint)],{isDashed:!0}),this.object3D.add(this.axisDashedZ),this.axisDashedZ.visible=!1,this.axisZArrow&&this.object3D.remove(this.axisZArrow),this.axisZArrow=this.createLine("axisZArrow",[...Object.values(e.endZPoint),...Object.values(e.endZ)]),this.object3D.add(this.axisZArrow),this.axisZArrow.visible=!1,this.axisHighlightZ&&this.object3D.remove(this.axisHighlightZ),this.axisHighlightZ=this.createLine("axisHighlightZ",[...Object.values(e.start),...Object.values(e.endZ)],{color:n}),this.object3D.add(this.axisHighlightZ),this.axisHighlightZ.visible=!1,this.axisHighlightZPoint&&this.object3D.remove(this.axisHighlightZPoint),this.axisHighlightZPoint=this.createLine("axisHighlightZPoint",[...Object.values(e.start),...Object.values(e.endZPoint)],{color:n}),this.object3D.add(this.axisHighlightZPoint),this.axisHighlightZPoint.visible=!1,this.axisGrayZ&&this.object3D.remove(this.axisGrayZ),this.axisGrayZ=this.createLine("axisGrayZ",[...Object.values(e.start),...Object.values(e.endZ)]),this.object3D.add(this.axisGrayZ),this.axisGrayZ.visible=!1,this.arrow&&this.object3D.remove(this.arrow),this.arrow=this.createArrow("arrow",e.endZ,e.endZ.clone().sub(e.start),o),this.object3D.add(this.arrow),this.arrowHighlight&&this.object3D.remove(this.arrowHighlight),this.arrowHighlight=this.createArrow("arrowHighlight",e.endZ,e.endZ.clone().sub(e.start),n),this.object3D.add(this.arrowHighlight),this.arrowHighlight.visible=!1,this.arrowGray&&this.object3D.remove(this.arrowGray),this.arrowGray=this.createArrow("arrowGray",e.endZ,e.endZ.clone().sub(e.start),i),this.object3D.add(this.arrowGray),this.arrowGray.visible=!1;let t=(new THREE.Quaternion).setFromUnitVectors(new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1)),l=e.start.clone().sub(e.endX.clone()).length();this.circleEdgeX&&this.object3D.remove(this.circleEdgeX),this.circleEdgeX=this.createCircleEdge("circleEdgeX",e.start,l,.015*Math.PI,.47*Math.PI,{color:r},t),this.object3D.add(this.circleEdgeX),this.circleEdgeY&&this.object3D.remove(this.circleEdgeY),this.circleEdgeY=this.createCircleEdge("circleEdgeY",e.start,l,.015*Math.PI,.47*Math.PI,{color:a}),this.object3D.add(this.circleEdgeY),this.circleEdgeGrayX&&this.object3D.remove(this.circleEdgeGrayX),this.circleEdgeGrayX=this.createCircleEdge("circleEdgeGrayX",e.start,l,.015*Math.PI,.47*Math.PI,{color:i},t),this.object3D.add(this.circleEdgeGrayX),this.circleEdgeGrayX.visible=!1,this.circleEdgeGrayY&&this.object3D.remove(this.circleEdgeGrayY),this.circleEdgeGrayY=this.createCircleEdge("circleEdgeGrayY",e.start,l,.015*Math.PI,.47*Math.PI,{color:i}),this.object3D.add(this.circleEdgeGrayY),this.circleEdgeGrayY.visible=!1,this.circleEdgeHoverX&&this.object3D.remove(this.circleEdgeHoverX),this.circleEdgeHoverX=this.createCircleEdge("circleEdgeHoverX",e.start,l,0,2*Math.PI,{color:n,linewidth:1},t),this.object3D.add(this.circleEdgeHoverX),this.circleEdgeHoverX.material.opacity=0,this.circleEdgeHoverY&&this.object3D.remove(this.circleEdgeHoverY),this.circleEdgeHoverY=this.createCircleEdge("circleEdgeHoverY",e.start,l,0,2*Math.PI,{color:n,linewidth:1}),this.object3D.add(this.circleEdgeHoverY),this.circleEdgeHoverY.material.opacity=0,this.circleEdgeRigidBodyX&&this.object3D.remove(this.circleEdgeRigidBodyX),this.circleEdgeRigidBodyX=this.createCircleEdgeRigidBody("circleEdgeRigidBodyX",e.start,l,t),this.object3D.add(this.circleEdgeRigidBodyX),this.circleEdgeRigidBodyY&&this.object3D.remove(this.circleEdgeRigidBodyY),this.circleEdgeRigidBodyY=this.createCircleEdgeRigidBody("circleEdgeRigidBodyY",e.start,l),this.object3D.add(this.circleEdgeRigidBodyY),this.plane&&this.object3D.remove(this.plane);let h=e.endPlaneX.clone().sub(e.start.clone()),d=e.endPlaneY.clone().sub(e.start.clone()),c=h.clone().add(d);this.plane=this.createPlane("plane",e.start.clone().add(c),e.start.clone().sub(e.endZ.clone()).normalize(),s),this.object3D.add(this.plane),this.planeGray&&this.object3D.remove(this.planeGray),this.planeGray=this.createPlane("planeGray",e.start.clone().add(c),e.start.clone().sub(e.endZ.clone()).normalize(),i),this.object3D.add(this.planeGray),this.planeGray.visible=!1,this.planeHighlight&&this.object3D.remove(this.planeHighlight),this.planeHighlight=this.createPlane("planeHighlight",e.start.clone().add(c),e.start.clone().sub(e.endZ.clone()).normalize(),n),this.object3D.add(this.planeHighlight),this.planeHighlight.visible=!1,this.sphereX&&this.object3D.remove(this.sphereX),this.sphereX=this.createSphere("sphereX",e.endX),this.object3D.add(this.sphereX),this.sphereY&&this.object3D.remove(this.sphereY),this.sphereY=this.createSphere("sphereY",e.endY),this.object3D.add(this.sphereY),this.sphereZ&&this.object3D.remove(this.sphereZ),this.sphereZ=this.createSphere("sphereZ",e.endZPoint,{color:o}),this.object3D.add(this.sphereZ),this.sphereHighlightZ&&this.object3D.remove(this.sphereHighlightZ),this.sphereHighlightZ=this.createSphere("sphereHighlightZ",e.endZPoint,{color:n}),this.object3D.add(this.sphereHighlightZ),this.sphereHighlightZ.visible=!1,this.sphereGrayZ&&this.object3D.remove(this.sphereGrayZ),this.sphereGrayZ=this.createSphere("sphereGrayZ",e.endZPoint,{color:i}),this.object3D.add(this.sphereGrayZ),this.sphereGrayZ.visible=!1,this.arrowRigidBody&&this.object3D.remove(this.arrowRigidBody);let u=new THREE.Vector3((e.start.x+e.endZ.x)/2,(e.start.y+e.endZ.y)/2,(e.start.z+e.endZ.z)/2);this.arrowRigidBody=this.createArrowRigidBody("arrowRigidBody",u,e.endZ.clone().sub(e.start),{color:o}),this.object3D.add(this.arrowRigidBody),this.object3D.updateMatrixWorld()}setHighlight(){this.highlightActionList.forEach((e=>{e.timeScale=this.animationTimeScale,e.paused=!1,e.play()}))}cancelHighlight(){this.highlightActionList.forEach((e=>{e.timeScale=-this.animationTimeScale,e.paused=!1,e.play()}))}initHighlightAnimation(){this.actionAxisZGray=this.getActionHightlight(this.axisZ,this.axisZ.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionSphereZGray=this.getActionHightlight(this.sphereZ,this.sphereZ.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionArrowGray=this.getActionHightlight(this.arrow,this.arrow.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionAxisZHightlight=this.getActionHightlight(this.axisZ,this.axisZ.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionSphereZHightlight=this.getActionHightlight(this.sphereZ,this.sphereZ.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionArrowHightlight=this.getActionHightlight(this.arrow,this.arrow.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionCircleEdgeXGray=this.getActionHightlight(this.circleEdgeX,this.circleEdgeX.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionCircleEdgeYGray=this.getActionHightlight(this.circleEdgeY,this.circleEdgeY.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionPlaneGray=this.getActionHightlight(this.plane,this.plane.material.color.toArray(),new THREE.Color(this.getLinearColor(i)).toArray()),this.actionPlaneHightlight=this.getActionHightlight(this.plane,this.plane.material.color.toArray(),new THREE.Color(this.getLinearColor(n)).toArray()),this.actionCircleEdgeHoverX=this.getActionHightlight(this.circleEdgeHoverX,[0],[1],"opacity"),this.actionCircleEdgeHoverY=this.getActionHightlight(this.circleEdgeHoverY,[0],[1],"opacity")}getActionHightlight(e,t,i,n){const o=new THREE.ColorKeyframeTrack(".material.color",[0,1],[...t,...i]),s=new THREE.NumberKeyframeTrack(".material.opacity",[0,1],[...t,...i]),r=new THREE.AnimationClip("Action",1,["opacity"==n?s:o]);let a=new THREE.AnimationMixer(e),l=a.clipAction(r);return l.setLoop(THREE.LoopOnce),l.timeScale=this.animationTimeScale,l.clampWhenFinished=!0,{mixer:a,action:l,object:e}}addAnimation({mixer:e,action:t,object:i}){this.animationList.push({mixer:e,action:t,object:i})}fireSectionPlaneChangedEvent(){const e=this.system.viewer._sectionPlane;this.eventManager.fireEvent(this.sectionPlaneEvent.SectionPlaneChanged,e.getSectionPlane())}destroy(){this.object3D.clear(),this._destroyed=!0,this.centerPosition=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CoordinateSystem=class{constructor(t){this.viewer=t;let i=this.viewer.getViewer();this.cameraControl=i.cameraControl,this.fillClipPlane=y.FillClipPlaneManager.getInstance(i.getScene()),this.container=i.domElement,this.config=new e.Bimface.Plugins.Section.CoordinateSystemConfig,this.updateBinded=this.update.bind(this),this.initialize(),this.coordinateControl=new e.Bimface.Plugins.Section.CoordinateControl({viewer:t,system:this}),i.getInteractionScene().add(this.coordinateControl.object3D)}initialize(){this.enable=!0,this.boundingBox=new THREE.Box2}setDirection(e){this.planeDirection=e}saveTransform(e){this.savedCamera=e.clone()}getCoordinateAxisForPoint(e){var t=this.fillClipPlane.renderClipPlane.normal.clone(),i=this.fillClipPlane.getCoordinate(),n=i.axisY.clone(),o=t.clone().cross(n.clone());this.fillClipPlane.normalIndex>3&&(n=(o=i.axisX.clone()).clone().cross(t.clone()));var s=this.cameraControl.camera;this.defaultDistance=1500;var r=this.config.styles,a=e||this.fillClipPlane.state.position.clone(),l=s.position.clone().sub(a.clone()).length(),h=a.clone().add(o.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength)),d=a.clone().add(n.clone().multiplyScalar(l/this.defaultDistance*r.axisYLength)),c=a.clone().add(t.clone().multiplyScalar(l/this.defaultDistance*r.axisZLength)),u=a.clone().add(t.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength)),g=a.clone().add(o.clone().multiplyScalar(l/this.defaultDistance*r.axisXLength/5)),p=a.clone().add(n.clone().multiplyScalar(l/this.defaultDistance*r.axisYLength/5));return this.dirX=o,this.dirY=n,{start:a,endX:h,endY:d,endZ:c,endZPoint:u,endPlaneX:g,endPlaneY:p}}update(e){1!=e&&1==this.bIsCoordinateHided||(this.coordinateControl.update(),this.updateBbox())}hide(e){this.bIsCoordinateHided=e,this.coordinateControl.changeVisible(!e)}destroy(){this.coordinateControl.destroy()}updateBbox(){let e=this.getCoordinateAxisForPoint(this.coordinateControl.centerPosition),t=this.viewer.worldToClient(this.viewer.sceneToWorld(e.start.clone())),i=[this.viewer.worldToClient(this.viewer.sceneToWorld(e.endX.clone())),this.viewer.worldToClient(this.viewer.sceneToWorld(e.endY.clone())),this.viewer.worldToClient(this.viewer.sceneToWorld(e.endZ.clone()))],n=t.x,o=t.y,s=t.x,r=t.y;for(let e=0;e<i.length;e++)i[e].x<n&&(n=i[e].x),i[e].x>s&&(s=i[e].x),i[e].y<o&&(o=i[e].y),i[e].y>r&&(r=i[e].y);this.boundingBox=new THREE.Box2,this.boundingBox.min=new THREE.Vector2(n,o),this.boundingBox.max=new THREE.Vector2(s,r),this.boundingBox.expandByScalar(10)}insideBoundingBox(e){return this.boundingBox.containsPoint(e.clone())}backwardCoordinate(){var e=this.cameraControl.camera.position,t=this.cameraControl.camera.target.clone().sub(e.clone()).normalize(),i=this.fillClipPlane.renderClipPlane.normal.clone();t.angleTo(i);Math.PI}}}(),function(){var t="Bimface.Plugins.Section.SectionPlane",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");let o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");var s={Forward:0,Reverse:1},r={X:0,Y:2,Z:4},a=function(t){var i=this,n=t.viewer;if(n)if("Viewer3D"===n.viewerType||n instanceof e.Bimface.Viewer.ViewerGIS){if(P(this),n._sectionBox&&(n._sectionBox.hideBox(),!1!==t.exitSectionBox&&n._sectionBox.exit()),t.hatchByMaterial&&n.getViewer().getClipCapsManager().enableHatchByMaterial(t.hatchByMaterial,!1),y.GlobalData.CalculateClippingLine=!!t.isOutlineEnabled,y.GlobalData.SnapClippingLine=!!t.enableSnap,n._sectionPlane)return n._sectionPlane.showPlane(),n._sectionPlane;n._sectionPlane=this,i.id=t.id,i._opt=t,i.mode=t.mode,i._plane=t.plane,i._direction=t.direction,i._progress=-1,this.onFloorExplosionBinded=this.onFloorExplosion.bind(this),this.onClipMouseHoverBinded=this.onClipMouseHover.bind(this),this.onClipMouseMoveBinded=this.onClipMouseMove.bind(this),this.onEditorEndBinded=this.onEditorEnd.bind(this),i.init(),i.setPlane(t.plane),this._boxSize=new THREE.Vector3,t.filter&&i.setFilter(t.filter),i.enableHatch(t.isHatchEnabled)}else console.log("viewer should be Viewer3D or ViewerGIS.");else console.log("domElement must not be empty.")};a.prototype={init:function(){i.send(t,"init"),this.enableCoordinate=!0;var n=this._opt.viewer,o=n.getViewer(),s=this;this.coordinateSystem=new e.Bimface.Plugins.Section.CoordinateSystem(n),this.coordinateSystem.setDirection(this._direction),y.GlobalData.ClippingCaps=!0,o.editorManager.enableTool(o,y.EditToolMode.CLIP_FILL),this._sectionTool=y.FillClipPlaneManager.getInstance(o.getScene()),this._sectionTool.observer=function(){var t=e.Bimface.Plugins.Section.SectionPlaneEvent;n.getEventManager().fireEvent(t.SectionPlaneUpdate,s)},this._sectionTool.enable(!0,!0),o.getModelManager().updatePickingMaterial(),this.hookEvens(),this.coordinateSystem.coordinateControl.init(),this.fireSectionPlaneVisibleChangedEvent(!0)},hookEvens:function(){var t=this.coordinateSystem,i=this._opt.viewer.getViewer(),n=o.throttle;i.registerEventListener(y.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),i.registerEventListener(y.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),i.registerEventListener(y.EVENTS.ON_EDITOR_ZOOM,n(t.updateBinded,50)),i.registerEventListener(y.EVENTS.ON_CAMERA_ANIMATION_UPDATE,n(t.updateBinded,50)),i.registerEventListener(y.EVENTS.ON_EDITOR_END,this.onEditorEndBinded),this._opt.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,this.onFloorExplosionBinded)},onFloorExplosion:function(){this.resetSectionTool(),this._opt.viewer.render()},onClipMouseHover:function(e){var t=this.coordinateSystem,i=this._opt.viewer.getDomElement();if(0!=this.enableCoordinate)if(t.update(!0),e.onClipPlane)t.hide(!1);else{i.style.cursor="";var n=new THREE.Vector2(e.event.offsetX,e.event.offsetY);t.insideBoundingBox(n)?t.hide(!1):t.hide(!0)}},onClipMouseMove:function(){this.coordinateSystem.update()},onEditorEnd:function(){this.coordinateSystem.update(!0)},fireSectionPlaneMobileChangedEvent:function(){this._opt.viewer.getEventManager().fireEvent("SectionPlaneMobileChanged",this.getSectionPlane())},fireSectionPlaneStateChangedEvent:function(){this._opt.viewer.getEventManager().fireEvent("SectionPlaneStateChanged",this.getSectionPlane())},fireSectionPlaneVisibleChangedEvent:function(e){requestAnimationFrame((()=>{this._opt.viewer.getEventManager().fireEvent("SectionPlaneVisibleChanged",e)}))},exit:function(){var t=this._opt.viewer.getViewer(),i=y.FillClipPlaneManager.getInstance(t.getScene());this.borderParamWidth&&this.borderParamHeight&&this.setBorder(this.borderParamWidth,this.borderParamHeight,!1),this.clearFilter(),t.getModelManager().updatePickingMaterial(),t.editorManager.disableTool(y.EditToolMode.CLIP_FILL),i.clearCapsWireframe(),y.GlobalData.ClippingCaps=!1,i.enable(!1,!1),this.coordinateSystem.destroy(),t.getScene().removeObjectGroup(i),t.getScene().fillClipPlane=null,t.getClipCapsManager().resetClippingCapsStatus();let n=e.Bimface.Plugins.Section.SectionPlaneEvent;this._opt.viewer.getEventManager().fireEvent(n.SectionPlaneUpdate,null),this._sectionTool=null,this._opt.viewer._sectionPlane=null,t.unregisterEventListener(y.EVENTS.ON_CLIP_HOVER,this.onClipMouseHoverBinded),t.unregisterEventListener(y.EVENTS.ON_CLIP_MOUSE_MOVE,this.onClipMouseMoveBinded),t.unregisterEventListener(y.EVENTS.ON_EDITOR_END,this.onEditorEndBinded),this._opt.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.FloorExplosion,this.onFloorExplosionBinded),y.GlobalData.SnapClippingLine=!1,y.GlobalData.CalculateClippingLine=!0,this.fireSectionPlaneVisibleChangedEvent(!1)},setProgress:function(e){if(i.send(t,"setProgress"),!1!==this._sectionTool.isEnabled()){var n=1-e/50;this._progress=e,this._sectionTool.setProcess(n),this.coordinateSystem.coordinateControl.update(),this._sectionTool.calculateClippingIds(),this.coordinateSystem.coordinateControl.centerPositionProjectionToClipPlane(),this.fireSectionPlaneStateChangedEvent()}},setOriginProgress:function(e){var t=e/100;this._progress=e,this._sectionTool.setProcess(t),this.coordinateSystem.coordinateControl.update(),this._sectionTool.calculateClippingIds(),this.coordinateSystem.coordinateControl.centerPositionProjectionToClipPlane()},getOriginProgress:function(){return 100*this._sectionTool.getProcess()},setDistanceProgress:function(e){if(!e.start||0==Math.abs(e.end.x-e.start.x)&&0==Math.abs(e.end.y-e.start.y))return;let t,i,n,o,s=1;n=this._sectionTool.renderClipPlane.normal.clone().normalize(),o=n.clone().negate();const r=this._opt.viewer;if(r.getCamera()._cloudCamera.position.clone().sub(r.getCamera()._cloudCamera.target.clone()).normalize().angleTo(n)<.2)return;const a=e=>{const t=r.getViewer().cameraControl.getRaycaster(e.x,e.y),i=t.ray.direction.clone().cross(t.ray.direction.clone().cross(n.clone())).normalize(),a=new THREE.Plane(i),l=-a.distanceToPoint(r.getCamera()._cloudCamera.position);a.set(i,l),s*=1;let h=new THREE.Vector3;if(new THREE.Ray(this._sectionTool.center,n).intersectPlane(a,h),0==h.x&&0==h.y&&0==h.z){let e=n.clone();n=o.clone(),o=e,s*=-1,new THREE.Ray(this._sectionTool.center,n).intersectPlane(a,h)}return h},l=r.getViewer().getBoundingBoxWorld(),h=r.getViewer().worldToDrawing(l.max),d=r.getViewer().worldToDrawing(l.min),c=a(e.start),u=a(e.end);t=h.clone().projectOnVector(n).distanceTo(d.clone().projectOnVector(n)),i=u.clone().projectOnVector(n).distanceTo(c.clone().projectOnVector(n));const g=e.progress/100*t,p=u.clone().sub(c.clone()).angleTo(n)<.001?1:-1;this._sectionTool.setProcess((g+s*p*i)/t),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneMobileChangedEvent()},getProgress:function(){return 50*(1-this._sectionTool.getProcess())},changeClipDirection(){let e=this.getSectionPlane();e.normal.x=-1*e.normal.x,e.normal.y=-1*e.normal.y,e.normal.z=-1*e.normal.z;let t=this.coordinateSystem.coordinateControl.centerPosition;this.setSectionPlane(e),t&&(this.coordinateSystem.coordinateControl.centerPosition=t),this.coordinateSystem.updateBinded()},setPlane:function(e){i.send(t,"setPlane");var n=s[this._direction]+r[e];if(this._plane=e,!1===this._sectionTool.isEnabled())return;this._sectionTool.changeNormal(n),this.setProgress(this._opt.progress),this.coordinateSystem.coordinateControl.resetCenterPosition();this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionPlaneStateChangedEvent()},getPlane:function(){return this._plane},setDirection:function(e){i.send(t,"setDirection");var n=s[e]+r[this._plane];this._direction=e,this._sectionTool.changeNormal(n),this.setProgress(this._opt.progress);this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass(),this.fireSectionPlaneStateChangedEvent()},getDirection:function(){return this._direction},setRotateAngle:function(e,t){this._sectionTool.setRotateAngle(e,t)},getRotateAngle:function(){return this._sectionTool.getRotateAngle()},hidePlane:function(){i.send(t,"hidePlane"),this._sectionTool&&(this._sectionTool.visible=!1),this.enableCoordinate=!1,this.coordinateSystem.hide(!0);this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass()},showPlane:function(){if(i.send(t,"showPlane"),this._sectionTool&&!1===this._sectionTool.isEnabled())return;this._sectionTool&&(this._sectionTool.visible=!0),this.enableCoordinate=!0;this._opt.viewer.getViewer().getModelManager().forceUpdateGTAOPass()},rotateByAxis:function(e,n,o=!0){if(i.send(t,"rotateByAxis"),"YAxis"===e||"ZAxis"===e){var a="",l=0,h=s[this.getDirection()]+r[this._plane];0==h||1==h?(l="YAxis"===e?-n:n,a="YAxis"===e?"y":"z"):2==h||3==h?(l="YAxis"===e?-n:n,a="YAxis"===e?"x":"z"):4!=h&&5!=h||(l="YAxis"===e?n:-n,a="YAxis"===e?"x":"y"),l="Reverse"===this._direction?n:l,this._sectionTool&&(this._sectionTool.rotateAngleOffset(l,a),o&&this._sectionTool.calculateClippingIds()),this.fireSectionPlaneStateChangedEvent()}else console.log("Rotate axis must be YAxis or ZAxis.")},reset:function(){i.send(t,"reset");var e=this;e.setPlane(e._opt.plane),e.setDirection(e._opt.direction),e.setProgress(e._opt.progress)},enable:function(e){i.send(t,"enable"),!e&&this._sectionTool.clearCapsWireframe(),this.borderParamWidth&&this.borderParamHeight&&this.setBorder(this.borderParamWidth,this.borderParamHeight,e),this._sectionTool.enable(e,e),e&&this._sectionTool.reCalculateClippingIds(),e?this.showPlane():this.hidePlane(),this._opt.viewer.render(),this.fireSectionPlaneVisibleChangedEvent(e)},getState:function(){return this._sectionTool.store()},isIncluded:function(e){var t=this._opt.viewer,i=t.getViewer().getScene(),n=y.FillClipPlaneManager.getInstance(i),o=n.renderClipPlane.normal.clone().normalize(),s=n.state.position,r=t.worldToScene(e),a=new THREE.Vector3;return a.subVectors(r,s).normalize(),o.angleTo(a)>Math.PI/2},setPositionByPlane:function(e,t,i){if(!1===this._sectionTool.isEnabled())return;var o=this._opt.viewer;e=o.worldToScene(e),t=o.getViewer().worldToDrawing(t),i=o.globalUnitUtil.translate(i);var s=new THREE.Vector3(e.x,e.y,e.z),r=new THREE.Vector3(t.x,t.y,t.z),a=s.clone().add(r.clone().multiplyScalar(i));this._opt.plane=n.SectionPlanePlane.X,this._opt.direction=n.SectionPlaneDirection.Forward,this.reset(),this._sectionTool.update();var l=new THREE.Vector3(1,0,0),h=new THREE.Vector3(0,1,0);let d=1,c=r.clone().projectOnPlane(h);if(c.length()>1e-6){c.normalize(),d=l.clone().cross(c).y>0?1:-1;let e=l.clone().angleTo(c);this.rotateByAxis("ZAxis",e*THREE.Math.RAD2DEG*d,!1)}let u=c.clone().angleTo(r.clone());if(d=r.y<0?1:-1,this.rotateByAxis("YAxis",u*THREE.Math.RAD2DEG*d,!1),"ViewerGIS"===o.viewerType)this._sectionTool.state.position.copy(a),this._sectionTool.state.planeMeshCenter.copy(a),this._sectionTool.updateBasePoint(a);else{const e=a.clone().sub(this._sectionTool.center).projectOnVector(r);let t=e.length();Math.abs(e.angleTo(r))>Math.PI/2&&(t*=-1);t+=.1,this._sectionTool.setOffset(t),this.coordinateSystem.coordinateControl.update()}this._sectionTool.update(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},setState:function(e){i.send(t,"setState");let n=e.quaternion;e.quaternion&&e.quaternion instanceof Array&&(n=new THREE.Quaternion(...e.quaternion)),this._sectionTool.restore({...e,quaternion:n}),this.coordinateSystem.coordinateControl.centerPosition=e.basePoint?new THREE.Vector3(e.basePoint.x,e.basePoint.y,e.basePoint.z):new THREE.Vector3(e.position.x,e.position.y,e.position.z),this.fireSectionPlaneStateChangedEvent()},restoreRotation:function(){this._sectionTool.restoreRotation(),this._sectionTool.update(),this.coordinateSystem.coordinateControl.setCenterPosition(this._sectionTool.state.position),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},getSectionPlane:function(){var e=this._opt.viewer,t=this._sectionTool.state.position.clone(),i=this._sectionTool.renderClipPlane.normal.clone();return t=e.sceneToWorld(t),i=e.sceneToWorld(i),(i=new THREE.Vector3(i.x,i.y,i.z)).normalize(),{position:t,normal:i}},setSectionPlane:function(e){var t=this._opt.viewer;this.coordinateSystem.coordinateControl.centerPosition;this.reset();var i=t.worldToScene(e.position),n=t.worldToScene(e.normal);(n=new THREE.Vector3(n.x,n.y,n.z)).normalize();var o=new THREE.Vector3(1,0,0),s=new THREE.Quaternion;s.setFromUnitVectors(o,n);var r=new THREE.Euler;r.setFromQuaternion(s),r.x=0,s.setFromEuler(r),s.x=-s.x;var a=this._sectionTool.uniforms.vClipPlane.value[0].clone(),l=new THREE.Vector3(a.x,a.y,a.z);l.normalize();var h=new THREE.Vector3(i.x,i.y,i.z).sub(this._sectionTool.center);this._sectionTool.planeOffset=h.x/l.x,this._sectionTool.state.quaternion.copy(s),this._sectionTool.state.position.copy(i),this._sectionTool.updateBasePoint(i),this._sectionTool.update(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},resetSectionTool:function(){var e=this._opt.viewer.getViewer().getScene(),t=e.getBoundingBox();t.getSize(this._boxSize),this._sectionTool.resize(this._boxSize.multiplyScalar(e.expandScalar)),t.getCenter(this._sectionTool.center),t.getCenter(this._sectionTool.state.position),this.coordinateSystem.coordinateControl.centerPosition=this._sectionTool.state.position.clone(),this._sectionTool.setBasePoint(this._sectionTool.state.position),this._sectionTool.update(),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),this.fireSectionPlaneStateChangedEvent()},setObjectsById(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsById(e)})),this._sectionTool.update(),this._opt.viewer.render()},setObjectsByObjectData(e){this._opt.viewer.getModels().forEach((t=>{t.localClippingComponentsByObjectData(e)})),this._sectionTool.update(),this._opt.viewer.render()},restoreObjects(){this._opt.viewer.getModels().forEach((e=>{e.clearLocalClipping()})),this._sectionTool.update(),this._opt.viewer.render()},setFilter(t){if(t&&t instanceof Array){var i=this._opt.viewer,n=i.getViewer();if("Viewer3D"===i.viewerType)for(var o=0;o<t.length;o++){let e=null;if((s=t[o]).modelId){let t=i.getModel(s.modelId);if(!t){console.warn("invalid modelId.");continue}e=t}else if(e=i.getModel(),!e){console.warn("invalid modelId.");continue}s.objectIds||s.objectData?s.objectIds?e.localClippingComponentsById(s.objectIds):s.objectData&&e.localClippingComponentsByObjectData(s.objectData):i.getViewer().modelManager.getModel(e.modelId).enableLocalClippingMode(!0)}else if(i instanceof e.Bimface.Viewer.ViewerGIS)for(o=0;o<t.length;o++){var s;if(!(s=t[o]).layerId){console.warn("invalid layerId.");continue}var r=i.getLayerManager().getLayer(s.layerId);if(!r){console.warn("invalid layerId.");continue}const e=i.getModel(r.customId||r.modelId);e?s.objectIds||s.objectData?s.objectIds?e.localClippingComponentsById(s.objectIds):s.objectData&&e.localClippingComponentsByObjectData(s.objectData):i.getViewer().modelManager.getModel(e.modelId).enableLocalClippingMode(!0):console.warn("invalid layerId.")}this._sectionTool.update(),this._sectionTool.clearCapsWireframe(),this._sectionTool.calculateClippingIds(),n.getModelManager().updatePickingMaterial(),this.fireSectionPlaneVisibleChangedEvent(!1),this._opt.viewer.render()}else console.log("filter should be Array.")},clearFilter(){var e=this._opt.viewer;e.getModels().forEach((t=>{e.getViewer().modelManager.getModel(t.modelId).enableLocalClippingMode(!1)})),this.restoreObjects(),this.fireSectionPlaneVisibleChangedEvent(!0)},setBorder(t,i,n){this.borderParamWidth=t,this.borderParamHeight=i;var o=20,s=20;"Viewer3D"===this._opt.viewer.viewerType?(o=this._opt.viewer.worldToScene({x:t,y:0,z:0}).x,s=this._opt.viewer.worldToScene({x:i,y:0,z:0}).x):this._opt.viewer instanceof e.Bimface.Viewer.ViewerGIS&&(o=t?this._opt.viewer.globalUnitUtil.translate(t):o,s=i?this._opt.viewer.globalUnitUtil.translate(i):s),o=Math.max(1,o),s=Math.max(1,s),this._sectionTool.setBorder(o,s,n),this.coordinateSystem.coordinateControl.setCenterPosition(this._sectionTool.state.position),this._sectionTool.calculateClippingIds()},drawComponentContours(){let e=this._opt.viewer.getViewer().getScene().getOrCreateObjectGroup(y.ObjectGroupType.CAPSWIREFRAME,{globalSpace:!0});const t=this._sectionTool.capsIntersectContour;for(const i in t){const n=t[i],o=this._opt.viewer.getModel(i).getModelTransformationAdaptedUnit();(new THREE.Matrix4).fromArray(o);for(const t in n){n[t].clippingContours.map((t=>{t.map((t=>{const i=new THREE.BufferGeometry;i.setFromPoints(t),i.computeBoundingSphere();let n=new THREE.Line(i,new THREE.LineBasicMaterial({color:16711680,depthTest:!1}));e.add(n),n.updateMatrixWorld(!0)}))}))}}},getComponentContours(t,i){if(!this._sectionTool)return void console.warn("The SectionPlane is unavailable");const n=this._opt.viewer;let o=t;if(n instanceof e.Bimface.Viewer.ViewerGIS){const e=n.getLayerManager().getLayer(t);if(!e)return void console.warn("Parameter layerId is invalid.");o=e.getModelId()}const s=n.getModel(o);if(!s)return void console.warn("Parameter modelId is invalid.");let r=s.getComponentContours(i);if(n instanceof e.Bimface.Viewer.ViewerGIS){const e=r.length;for(let i=0;i<e;++i)delete r[i].modelId,r[i].layerId=t}return r},enableHatch(e){this._opt.viewer._sectionBox||y.GlobalData.ClippingCapsType!=e&&y.GlobalData.ClippingCapsType!=y.EnumClippingCapsTypes.ClipBox&&(y.GlobalData.ClippingCapsType=e?y.EnumClippingCapsTypes.ClipPlane:y.EnumClippingCapsTypes.None,this._opt.viewer.render())},isHatchEnabled:()=>y.GlobalData.ClippingCapsType==y.EnumClippingCapsTypes.ClipPlane,enableSnap(e){y.GlobalData.SnapClippingLine=!!e},enableOutline(e){y.GlobalData.CalculateClippingLine!==e&&(y.GlobalData.CalculateClippingLine=!!e,this._sectionTool.calculateClippingIds())}},n.SectionPlane=a}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionRegionConfig=class{constructor(){const e={viewer:null,boundary:null,height:0,enableSnap:!0,filter:null,isOutlineEnabled:!0};for(let t in e)this[t]=e[t]}};class Uo{constructor(t){e.Bimface.Data.StatisticsDataManager.getInstance().send("Bimface.Plugins.Section.SectionRegion","bf_c_SectionRegion_new");let i=t.viewer;if(!i)return void console.log("domElement must not be empty.");const n="Viewer3D"===i.viewerType,o=i instanceof e.Bimface.Viewer.ViewerGIS;if(n||o){if(P(this),y.GlobalData.CalculateClippingLine=!!t.isOutlineEnabled,y.GlobalData.SnapClippingLine=!!t.enableSnap,i._sectionPlane&&(i._sectionPlane.hidePlane(),i._sectionPlane.exit()),i._sectionBox&&(i._sectionBox.hideBox(),i._sectionBox.exit()),i._sectionRegion)return i._sectionRegion;i._sectionRegion=this,this.eventManager=i.getEventManager(),this._opt=t,this._viewer=i,this.cloudViewer=this._viewer.getViewer(),this._disableFilter=!0,this.reset(),t.filter&&this.setFilter(t.filter)}else console.log("Viewer2D is not supported.")}init(){const e=this.cloudViewer.getScene().getMatrixGlobal();let t=this.boundary[0].z;this.height<0&&(t+=this.height);let i=this.boundary.map((e=>new THREE.Vector3(e.x,e.y,t)));i.push(i[0]),Uo.isClockwiseBoundary(i)||i.reverse(),y.ClipRegionManager.setEnableFilter(!1),i=this._viewer.globalUnitUtil.translate(i,["x","y","z"]);for(let t=0;t<i.length;t++)i[t]=new THREE.Vector3(i[t].x,i[t].y,i[t].z).applyMatrix4(e);let n=this._viewer.globalUnitUtil.translate(this.height);n=new THREE.Vector3(0,0,n).applyMatrix4(e).y,y.ClipRegionManager.setClipRegion(this.cloudViewer,i,Math.abs(n)),this._viewer.render()}changeClipDirection(e){this.clipDirection=e,y.ClipRegionManager.changeClipDirection(this.cloudViewer,e),this._viewer.render()}reset(){this.boundary=this._opt.boundary,e.Bimface.Plugins.Geometry.PlaneBufferGeometry.checkIntersect(this.boundary)?console.warn("Failed to create plane, the plane border is self-intersecting."):(this.height=this._opt.height,this.init(),this.changeClipDirection(!1))}enable(e){e?(this.init(),this.changeClipDirection(this.clipDirection)):this.exit()}exit(){y.ClipRegionManager.exit(this.cloudViewer),this._viewer.render(),this._viewer._sectionRegion=null,y.GlobalData.SnapClippingLine=!1,y.GlobalData.CalculateClippingLine=!0}hide(){y.ClipRegionManager.hide(this.cloudViewer),this._viewer.render()}show(){y.ClipRegionManager.show(this.cloudViewer),this._viewer.render()}getBoundary(){return this.boundary}getHeight(){return this.height}setHeight(e){this.height=e,this.init()}setBoundary(t){e.Bimface.Plugins.Geometry.PlaneBufferGeometry.checkIntersect(t)?console.warn("Failed to create plane, the plane border is self-intersecting."):(this.boundary=t,this.init())}setFilter(t){if(!(t&&t instanceof Array))return void console.log("conditions should be Array.");let i=!1;y.ClipRegionManager.setEnableFilter(!0);var n=this._opt.viewer,o=n.getViewer();if("Viewer3D"===n.viewerType)for(var s=0;s<t.length;s++){let e=null;if((r=t[s]).modelId){let t=n.getModel(r.modelId);if(!t){console.warn("invalid modelId.");continue}e=t}else if(e=n.getModel(),!e){console.warn("invalid modelId.");continue}i=!0,r.objectIds||r.objectData?r.objectIds?e.localClippingComponentsById(r.objectIds):r.objectData&&e.localClippingComponentsByObjectData(r.objectData):e.localClippingComponentsByObjectData([])}else if(n instanceof e.Bimface.Viewer.ViewerGIS)for(s=0;s<t.length;s++){var r;if(!(r=t[s]).layerId){console.warn("invalid layerId.");continue}var a=n.getLayerManager().getLayer(r.layerId);if(!a){console.warn("invalid layerId.");continue}const e=n.getModel(a.customId||a.modelId);e?(i=!0,r.objectIds||r.objectData?r.objectIds?(n.getViewer().modelManager.getModel(e.modelId).enableLocalClippingMode(!0),e.localClippingComponentsById(r.objectIds)):r.objectData&&(n.getViewer().modelManager.getModel(e.modelId).enableLocalClippingMode(!0),e.localClippingComponentsByObjectData(r.objectData)):(n.getViewer().modelManager.getModel(e.modelId).enableLocalClippingMode(!0),e.localClippingComponentsByObjectData([]))):console.warn("invalid layerId.")}i||y.ClipRegionManager.setEnableFilter(!1),y.ClipRegionManager.setUpdateOnce(),o.getModelManager().updatePickingMaterial(),this._viewer.render()}clearFilter(){this._opt.viewer.getModels().forEach((e=>{e.clearLocalClipping()})),y.ClipRegionManager.setEnableFilter(!1),this._disableFilter=!0,y.ClipRegionManager.setUpdateOnce(),this._opt.viewer.render()}enableSnap(e){y.GlobalData.SnapClippingLine=!!e}enableOutline(e){y.GlobalData.CalculateClippingLine!==e&&(y.GlobalData.CalculateClippingLine=!!e)}static isClockwiseBoundary(e){let t=0;const i=e.length;for(let n=0;n<i-1;n++)t+=-.5*(e[n+1].y+e[n].y)*(e[n+1].x-e[n].x);return!(t>0)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Section").SectionRegion=Uo,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough").WalkthroughConfig=function(){return{viewer:null,time:10,stopCallback:null,camera:null}},function(){var t="Bimface.Plugins.Walkthrough",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");n.Walkthrough=class{constructor(t){var i=t.viewer,n=i.getViewer();i?"Viewer3D"===i.getViewerType()||"ViewerGIS"===i.getViewerType()?(P(this),this._viewer=i,this.bPause=!1,this.cameraStatus=null,this._walkthrough=new y.Walkthrough,this._player=new y.WalkthroughPlayer(n),this._player.setWalkthrough(this._walkthrough),t.stopCallback&&this._player.addStopPlayCallback(t.stopCallback),this.setWalkthroughTime(t.time),this.console=new e.Web.Common.Console,this.camera=t.camera,this.nearPoint=null,this.farPoint=null):console.log("ViewerType is not supported."):console.log("viewer must not be empty.")}addKeyFrame(n){i.send(t,"addKeyFrame");var o=this._viewer,s=o.getViewer().camera,r={id:e.Web.Lang.Utility.UUID.createUUID(),position:s.position.clone(),target:s.target.clone(),name:n};if(this._walkthrough.addKeyFrame(r),this._walkthrough.checkFrameTimeMode()){const e=this._walkthrough.getKeyFrames();e.length>1&&void 0===e[e.length-2].timeBetweenFrames&&(e[e.length-2].timeBetweenFrames=5)}var a=Object.assign({},r);return a.position=o.sceneToWorld(r.position),a.target=o.sceneToWorld(r.target),a.coordinateSystem="world",a}setKeyFrameCallback(e){i.send(t,"setKeyFrameCallback"),this._player.setKeyFrameCallback(e)}removeKeyFrame(e){i.send(t,"removeKeyFrame"),this._walkthrough.removeKeyFrame(e)}clearKeyFrames(){i.send(t,"clearKeyFrames"),this._walkthrough.clearFrames()}setKeyFrames(e){i.send(t,"setKeyFrames"),"string"==typeof e&&(e=JSON.parse(e));var n=[];e.forEach((e=>{var t=Object.assign({},e);"world"===t.coordinateSystem&&(t.position=this._viewer.worldToScene(e.position),t.target=this._viewer.worldToScene(e.target)),n.push(t)})),this._walkthrough.setKeyFrameList(n)}getKeyFrames(){var e=this._walkthrough.getKeyFrames(),t=[];return e.forEach((e=>{var i=Object.assign({},e);i.position=this._viewer.sceneToWorld(e.position),i.target=this._viewer.sceneToWorld(e.target),i.coordinateSystem="world",t.push(i)})),t}setWalkthroughTime(e){i.send(t,"setWalkthroughTime"),c.assertType(e,"obj")?e.frameTime?this._walkthrough.setWalkthroughTime(e.frameTime):this._walkthrough.setWalkthroughTime(e.totalTime):this._walkthrough.setWalkthroughTime(e)}setCamera(e){if(!e||!e.near&&!e.far)return;this.camera=e,this.cameraStatus=this._viewer.getCameraStatus();const t=this.cameraStatus.position,i=this.cameraStatus.target,n=new THREE.Vector3(i.x-t.x,i.y-t.y,i.z-t.z).normalize(),o=this._viewer.getViewer(),s=this._viewer.globalUnitUtil;if(this.camera.near){const e=this.camera.near;this.nearPoint={x:t.x+e*n.x,y:t.y+e*n.y,z:t.z+e*n.z},this.nearPoint=s.translateVector(this.nearPoint),this.nearPoint=o.worldToDrawing(this.nearPoint)}if(this.camera.far){const e=this.camera.far;this.farPoint={x:t.x+e*n.x,y:t.y+e*n.y,z:t.z+e*n.z},this.farPoint=s.translateVector(this.farPoint),this.farPoint=o.worldToDrawing(this.farPoint)}}getCamera(){return this.camera}setDisableAnimation(e){this.disableAnimation=e}play(e){if(!this.disableAnimation){i.send(t,"play");var n=this._viewer.getViewer();this.setCamera(this.camera),(this.nearPoint||this.farPoint)&&(n.calculateNearFar(void 0,this.nearPoint,this.farPoint),n.enableCameraNearFar=!1);var o=this._player,s=this.cameraStatus;if((r=n.cameraControl.camera).up.set(0,1,0),r.realUp.set(0,1,0),e&&o.startFrom(e),o.stop(!1),!0===this.bPause){var r=n.getCamera();s&&function(e){var t=(e=JSON.parse(e)).position,i=e.target,n={position:new THREE.Vector3(t.x,t.y,t.z),target:new THREE.Vector3(i.x,i.y,i.z)},o=s,r=n.position.clone().sub(o.position),a=n.target.clone().sub(o.target);return r.length()>0||a.length()>0}(r)&&(this._player.camera.position.copy(this._viewer.worldToScene(s.position)),this._player.camera.target.copy(this._viewer.worldToScene(s.target)))}o.walkthrough.keyFrameList&&o.walkthrough.keyFrameList.length>0?(o.play(),this.bPause=!1):this.console.warn("The parameter[keyFrames] cannot be null")}}pause(){this.disableAnimation||(i.send(t,"pause"),this.bPause=!0,this.cameraStatus=this._viewer.getCameraStatus(),this._player.pause())}setProgress(e){this.disableAnimation||"number"==typeof e&&(e<0||e>1||(this._player.setProgress(e),this.cameraStatus=this._viewer.getCameraStatus()))}stop(){this.disableAnimation||(i.send(t,"stop"),this._player.stop(!0),this.bPause=!1)}stopCallback(e){i.send(t,"stopCallback"),e&&(this._stopCallback=e,this._player.addStopPlayCallback(e))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment").SegmentConfig=function(){return{viewer:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment").IsolateOption=Object.freeze({Hidden:"Hidden",Translucent:"Translucent",PartlyTranslucent:"PartlyTranslucent"}),function(){var t="Bimface.Plugins.Segment",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Segment");n.Segment=class{constructor(e){this._viewer=e.viewer,this._segmentInfoMap=null,this._segmentInfoArray=null,this._segmentIdArray=null,this._elementIdMap={},this._loading=!1,this._segmentInfoAcquired=!1,this._segmentIdMapFromComponentId={},this._traversedSegmentIdMap={},this._fullElementIdsLoadEnabled=!0,P(this)}destroy(){this._viewer=null,this._segmentInfoMap=null,this._segmentInfoArray=null,this._segmentIdArray=null,this._elementIdMap=null,this._segmentIdMapFromComponentId=null,this._traversedSegmentIdMap=null}_hasSegmentInfo(e){return!(!this._segmentInfoMap||!this._segmentInfoMap[e])}_getSegmentInfoById(e){return this._segmentInfoMap?this._segmentInfoMap[e]:null}_removeDuplication(e){for(var t={},i=0,n=e.length;i<n;i++)this._hasSegmentInfo(e[i])&&!t[e[i]]&&(t[e[i]]=!0);return Object.keys(t)}_getSegmentElementIdsByIdx(e,t,i){var n=this,o=this._viewer,s=e[t];n._elementIdMap[s]?i&&i():o.getSegmentElementIds(s,(function(e){e.data&&(n._elementIdMap[s]=e.data,n.segmentFileInfoMap[s].elementIds=n._elementIdMap[s]),i&&i()}),(function(){i&&i()}))}_getSegmentElementIds(e,t){e||(e=this._segmentIdArray);var i=e.length,n=this;i>0?requestAnimationFrame(function e(o,s){var r=s;return function(){n._getSegmentElementIdsByIdx(o,r,(function(){r<i-1?requestAnimationFrame(e(o,r+1)):t&&t()}))}}(e,0)):t&&t()}_getSegmentFullElementIds(e){const t=this;this._viewer.getSegmentElementIds("full",(function(i){const n=i.data;n&&n.forEach((e=>{t._elementIdMap[e.segmentId]=e.elementIds,t.segmentFileInfoMap[e.segmentId].elementIds=e.elementIds})),e&&e()}),(function(){e&&e()}))}_getSegmentMetadataByIdx(e,t,i){var n=this._viewer,o=e[t],s=this.segmentFilePathMap[o].metadata,r=this.segmentFilePathMap[o].databag;n.getSegmentManager().getSegmentMetadata(o,r,s,(function(){i&&i()}),(function(){i&&i()}))}_getSegmentMetadata(e){var t=Object.keys(this.segmentFilePathMap),i=t.length,n=this;i>0?requestAnimationFrame(function t(o,s){var r=s;return function(){n._getSegmentMetadataByIdx(o,r,(function(){r<i-1?requestAnimationFrame(t(o,r+1)):e&&e()}))}}(t,0)):e&&e()}_loadMetadata(e){for(var t=this._viewer,i=this._segmentIdArray,n=this.segmentFilePathMap={},o=this.segmentFileInfoMap={},s=0,r=i.length;s<r;s++){var a=i[s],l=this._getSegmentInfoById(a).partialElementFiles,h=[];if(l)for(var d=0,c=l.length;d<c;d++){var u=l[d].databagId;if(u){var g=null;n[u]?g=n[u]:(g={databag:t.getDatabagResource(u),metadata:t.getPartialElementsMetadataFile(u),fileId:l[d].fileId},n[u]=g),h.push(g)}}o[a]={id:a,paths:h}}this._getSegmentMetadata(e)}_loadSegments(e,t){if(e=e||this._segmentIdArray){for(var i=this._viewer,n=this._removeDuplication(e),o=[],s=0,r=n.length;s<r;s++){var a=this.segmentFileInfoMap[n[s]];a&&o.push(a)}0!==o.length?i.getSegmentManager().loadSegments(o,(function(){t&&t()})):t&&t()}else t&&t()}getSegmentInfo(e){function n(e,t){if(e.subGroups)for(var i=e.subGroups,o=0,s=i.length;o<s;o++)n(i[o],t);else if(e.segments)for(var r=0,a=e.segments.length;r<a;r++){var l=e.segments[r];t[l.id]=l}}if(i.send(t,"getSegmentInfo"),this._loading)return null;if(this._segmentInfoAcquired)return e&&e(this._segmentInfoArray),this._segmentInfoArray;var o=this;return this._loading=!0,this._viewer.getSegmentTree((function(t){for(var i=t.data,s=o._segmentInfoMap={},r=0,a=i.length;r<a;r++)n(i[r],s);o._segmentIdArray=Object.keys(o._segmentInfoMap),o._segmentInfoArray=[];for(var l=o._segmentInfoArray.length=o._segmentIdArray.length,h=0;h<l;h++)o._segmentInfoArray[h]=o._segmentInfoMap[o._segmentIdArray[h]];o._loadMetadata((function(){o._loading=!1,o._segmentInfoAcquired=!0,e&&e(o._segmentInfoArray)}))}),(function(e){console.error("request segment data error!")})),null}_loadSegmentsWithFullElementIds(e,t){this._fullElementIdsLoaded?this._loadSegments(e,t):this._getSegmentFullElementIds((()=>{this._fullElementIdsLoaded=!0,this._loadSegments(e,t)}))}loadSegments(e,n){i.send(t,"loadSegments");var o=this;this._fullElementIdsLoadEnabled?this._segmentInfoAcquired?this._loadSegmentsWithFullElementIds(e,n):this.getSegmentInfo((function(t){o._loadSegmentsWithFullElementIds(e,n)})):this._segmentInfoAcquired?o._getSegmentElementIds(e,(function(){o._loadSegments(e,n)})):this.getSegmentInfo((function(t){o._getSegmentElementIds(e,(function(){o._loadSegments(e,n)}))}))}unloadSegments(e){i.send(t,"unloadSegments"),(e=e||this._segmentIdArray)&&(this._viewer.getSegmentManager().unloadSegments(this._removeDuplication(e)),this._viewer.render())}hideComponentsBySegment(e){i.send(t,"hideComponentsBySegment"),this._viewer.getSegmentManager().hideComponentsBySegment(this._removeDuplication(e)),this._viewer.render()}showComponentsBySegment(e){i.send(t,"showComponentsBySegment"),this._viewer.getSegmentManager().showComponentsBySegment(this._removeDuplication(e)),this._viewer.render()}isolateComponentsBySegment(n,o){i.send(t,"isolateComponentsBySegment");var s=void 0,r=e.Bimface.Plugins.Segment.IsolateOption;switch(o){case r.Hidden:s=this._viewer.getSegmentManager().getSegmentIsolateOption().HIDDEN;break;case r.Translucent:s=this._viewer.getSegmentManager().getSegmentIsolateOption().TRANSLUCENT;break;case r.PartlyTranslucent:s=this._viewer.getSegmentManager().getSegmentIsolateOption().PARTLYTRANSLUCENT}void 0!==s&&(this._viewer.getSegmentManager().isolateComponentsBySegment(this._removeDuplication(n),s),this._viewer.render())}disable(){this._viewer.getSegmentManager().disable(),this._viewer.render()}enable(){this._viewer.getSegmentManager().enable(),this._viewer.render()}getSegementIds(e){if(!this._segmentInfoAcquired)return console.error("Call the function getSegmentInfo() first!"),null;var t=this._segmentIdMapFromComponentId;if(t[e])return t[e];for(var i=Object.keys(this._elementIdMap),n=0,o=i.length;n<o;n++){var s=i[n];if(!this._traversedSegmentIdMap[s]){this._traversedSegmentIdMap[s]=!0;for(var r=this._elementIdMap[s],a=0,l=r.length;a<l;a++){var h=r[a];t[h]||(t[h]=[]),t[h].push(s)}}}var d=this._viewer.getSegmentManager().getSegmentIdsByPartialElementId(e);return d&&(t[e]=d),t[e]}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid");i.HighlightBorderLines=class{constructor(e){this.svgContainer=e,this.initialize(),this.visibility=!1}initialize(){var e=t.createNS("line","bf-axisgrid-line"),i=e.cloneNode();i.style.strokeWidth=1,i.style.stroke="#ffffff",i.style.opacity=.5,this.svgContainer.appendChild(i),this.lineLeft=i;var n=e.cloneNode();n.style.strokeWidth=1,n.style.stroke="#ffffff",n.style.opacity=.5,this.svgContainer.appendChild(n),this.lineRight=n}updateBorderLeft(e,t){var i=new THREE.Vector2(e.x,e.y),n=new THREE.Vector2(t.x,t.y);e.y==t.y?(i.y-=2,n.y-=2):(i.x-=2,n.x-=2),this.moveLineTo(this.lineLeft,i,n)}updateBorderRight(e,t){var i=new THREE.Vector2(e.x,e.y),n=new THREE.Vector2(t.x,t.y);e.y==t.y?(i.y+=2,n.y+=2):(i.x+=2,n.x+=2),this.moveLineTo(this.lineRight,i,n)}hide(){this.lineLeft.style.display="none",this.lineRight.style.display="none",this.visibility=!1}show(){this.lineLeft.style.display="block",this.lineRight.style.display="block",this.visibility=!0}update(e,t){0!=this.visibility&&(this.updateBorderLeft(e,t),this.updateBorderRight(e,t))}moveLineTo(e,t,i){e.setAttribute("x1",t.x),e.setAttribute("y1",t.y),e.setAttribute("x2",i.x),e.setAttribute("y2",i.y)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid");i.HighlightLine=class{constructor(t,i){this.svgContainer=t,this.viewer=i,this.borderline=new e.Bimface.Plugins.AxisGrid.HighlightBorderLines(t),this.initialize(),this.visibility=!1}initialize(){var e=t.createNS("line","bf-axisgrid-line");e.style.strokeWidth=2,e.style.stroke="#32D5A7",this.svgContainer.appendChild(e),this.line=e}hide(){this.line.style.display="none",this.borderline.hide(),this.visibility=!1}show(){this.line.style.display="block",this.borderline.show(),this.visibility=!0}setLine(e){this.highlightLine=e}setHeight(e){this.axisgridHeight=e}update(){if(0!=this.visibility){var e=this.highlightLine,t=new THREE.Vector3(e[0],e[1],this.axisgridHeight),i=new THREE.Vector3(e[3],e[4],this.axisgridHeight),n=this.worldPointsToClient(t,i);n&&(this.moveLineTo(this.line,n.start,n.end),this.borderline.update(n.start,n.end))}}worldPointsToClient(e,t){var i=this.viewer.getDomElement().getBoundingClientRect(),n=this.viewer.getViewer().worldPointsToClient(e,t);return n&&(n.start.x-=i.left,n.start.y-=i.top,n.end.x-=i.left,n.end.y-=i.top),n}moveLineTo(e,t,i){e.setAttribute("x1",t.x),e.setAttribute("y1",t.y),e.setAttribute("x2",i.x),e.setAttribute("y2",i.y)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid");i.HighlightIntersectLines=class{constructor(t,i){this.svgContainer=t,this.viewer=i,this.horizBorderline=new e.Bimface.Plugins.AxisGrid.HighlightBorderLines(t),this.verticalBorderline=new e.Bimface.Plugins.AxisGrid.HighlightBorderLines(t),this.initialize(),this.visibility=!1}initialize(){var e=t.createNS("line","bf-axisgrid-line"),i=e.cloneNode();i.style.strokeWidth=2,i.style.stroke="#32D5A7",this.svgContainer.appendChild(i),this.svgHorizLine=i;var n=e.cloneNode();n.style.strokeWidth=2,n.style.stroke="#32D5A7",this.svgContainer.appendChild(n),this.svgVerticalLine=n;var o=t.createNS("circle","bf-axisgrid-point");o.setAttribute("r",3),o.setAttribute("fill","#32D5A7"),this.svgContainer.appendChild(o),this.hoverPoint=o,this.hide()}setLine(e,t){this.horizLine=e,this.verticalLine=t}setPoint(e){this.intersectPoint=e}setHeight(e){this.axisgridHeight=e}update(){if(0!=this.visibility){var e=this.horizLine,t=this.verticalLine,i=this.viewer.worldToClient(this.intersectPoint),n=new THREE.Vector3(e[0],e[1],this.axisgridHeight),o=new THREE.Vector3(e[3],e[4],this.axisgridHeight),s=new THREE.Vector3(t[0],t[1],this.axisgridHeight),r=new THREE.Vector3(t[3],t[4],this.axisgridHeight),a=this.worldPointsToClient(n,o);a&&(this.moveLineTo(this.svgHorizLine,a.start,a.end),this.horizBorderline.update(a.start,a.end));var l=this.worldPointsToClient(s,r);l&&(this.moveLineTo(this.svgVerticalLine,l.start,l.end),this.verticalBorderline.update(l.start,l.end)),this.movePointTo(this.hoverPoint,i.x,i.y)}}worldPointsToClient(e,t){var i=this.viewer.getDomElement().getBoundingClientRect(),n=this.viewer.getViewer().worldPointsToClient(e,t);return n&&(n.start.x-=i.left,n.start.y-=i.top,n.end.x-=i.left,n.end.y-=i.top),n}hide(){this.svgHorizLine.style.display="none",this.svgVerticalLine.style.display="none",this.hoverPoint.style.display="none",this.horizBorderline.hide(),this.verticalBorderline.hide(),this.visibility=!1}show(){this.svgHorizLine.style.display="block",this.svgVerticalLine.style.display="block",this.hoverPoint.style.display="block",this.horizBorderline.show(),this.verticalBorderline.show(),this.visibility=!0}moveLineTo(e,t,i){e.setAttribute("x1",t.x),e.setAttribute("y1",t.y),e.setAttribute("x2",i.x),e.setAttribute("y2",i.y)}movePointTo(e,t,i){e.setAttribute("cx",t),e.setAttribute("cy",i)}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid");n.AxisGridManager=class{constructor(n){t.send("Bimface.Plugins.AxisGrid","AxisGridManager"),this.snapMinDistance=5,this.viewer=n.viewer,this.registerEvent(),this.domContainer=i.create("div","bf-axisgrid-conext"),this.domContainer.style.position="absolute",this.domContainer.style.left=0,this.domContainer.style.top=0,this.domContainer.style.width="100%",this.domContainer.style.height="100%",this.svgContainer=i.createNS("svg","bf-axisgrid-svg"),this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.domContainer.appendChild(this.svgContainer),this.viewer.getDomElement().appendChild(this.domContainer);var o=e.Bimface.Plugins.AxisGrid;this.highlightLine=new o.HighlightLine(this.svgContainer,this.viewer),this.highlightIntersectLines=new o.HighlightIntersectLines(this.svgContainer,this.viewer),P(this)}registerEvent(){var t=e.Bimface.Viewer.Viewer3DEvent,i=this,n=this.viewer.getEventManager(),o=null;const s="AxisGrids";function r(e,t){if(!e)return;const i=new THREE.Line3(new THREE.Vector3(e[0],e[1],e[2]),new THREE.Vector3(e[3],e[4],e[5]));i.applyMatrix4(t);const n=[i.start.x,i.start.y,i.start.z,i.end.x,i.end.y,i.end.z];return n.name=e.name,n}function a(e){if(!e.snapLines.gridLine)return!1;const a=i.viewer.getViewer(),l=CLOUD.AxisGridManager.getInstance(a.getScene(),e.modelId).modelTransformation;var h=!0,d=e.point,c=new THREE.Vector3(0,0,e.height).applyMatrix4(l).z,u=e.snapLines,g=e.nearestPoint,p=u.intersectLines,m=r(u.gridLine,l),f=a.worldToCanvas(d),w=a.worldToCanvas(g.toGridLine),y=a.worldToCanvas(g.toIntersection),v=i.distance(f,w),b=i.distance(f,y),E=null;if(b<=i.snapMinDistance&&void 0!==p){i.highlightIntersectLines.show(),i.highlightLine.hide();var M=r(p[0],l),C=r(p[1],l);E=M.name+"-"+C.name,i.highlightIntersectLines.setHeight(c),i.highlightIntersectLines.setLine(M,C),i.highlightIntersectLines.setPoint(g.toIntersection),i.highlightIntersectLines.update()}else v<=i.snapMinDistance?(E=m.name,i.highlightLine.show(),i.highlightIntersectLines.hide(),i.highlightLine.setHeight(c),i.highlightLine.setLine(m),i.highlightLine.update(c)):(o=null,i.highlightLine.hide(),i.highlightIntersectLines.hide(),h=!1);return o!=E&&(b<=i.snapMinDistance||v<=i.snapMinDistance)&&(n.fireEvent(t.Hover,{objectType:s,objectId:E,worldPosition:d}),o=E),h}this.viewer.addEventListener(t.AxisGridHover,(function(e){for(const t of e.snaps){if(a(t))break}})),this.viewer.addEventListener(t.Rendered,(function(){var e=e||window.event,t=i.viewer.getViewer(),n=t.getScene();if(!n.axisGridEnableHover)return i.highlightLine.hide(),void i.highlightIntersectLines.hide();i.viewer.getModels().forEach((o=>{let s=o.modelId;var r=CLOUD.AxisGridManager.getInstance(n,s);if(e&&"mousewheel"==e.type){var l=n.getMatrixGlobal(),h=new THREE.Vector2(e.clientX,e.clientY),d=t.cameraControl.getRaycaster(h.x,h.y),c=r.getIntersectPoints(d,l),u=r.snapOnFloors(c);if(u&&0==u.length)return i.highlightLine.hide(),void i.highlightIntersectLines.hide();for(const e of u){if(a(e))break}}})),i.highlightLine.update(),i.highlightIntersectLines.update()}))}distance(e,t){var i=e.x-t.x,n=e.y-t.y,o=e.z-t.z;return Math.sqrt(i*i+n*n+o*o)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AxisGrid").AxisGridManagerConfig=function(){return{viewer:null}},function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.EditPoint=class{constructor(e,t,i){this.viewer3D=e,this.worldPosition=!0===i?null:t,this.clientPosition=!0===i?t:null,this.svgElement=null,this.xmlns="http://www.w3.org/2000/svg",this.glodonColor="#11DAB7",this.gridHighlightColor="#FF7F00",this.observer=function(){},this.uuid=-1,this.initialize()}initialize(){this.worldPosition?this.clientPosition=this.viewer3D.worldToClient(this.worldPosition):this.worldPosition=this.viewer3D.clientToWorld(this.clientPosition);let e=document.createElementNS(this.xmlns,"circle");e.setAttribute("r",3),e.setAttribute("style","stroke: "+this.glodonColor+"; stroke-width: 1; fill: #ffffff"),e.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")"),this.svgElement=e}setObserver(e){this.observer=e}hightlight(){this.svgElement.style.stroke=this.gridHighlightColor}cancelHightlight(){this.svgElement.style.stroke=this.glodonColor}distanceTo(e){let t=e.x-this.clientPosition.x,i=e.y-this.clientPosition.y;return Math.sqrt(t*t+i*i)}detach(){this.svgElement.parentNode.removeChild(this.svgElement)}update(e){1==e?this.worldPosition=this.viewer3D.clientToWorld(this.clientPosition):this.clientPosition=this.viewer3D.worldToClient(this.worldPosition),this.svgElement.setAttribute("transform","translate("+this.clientPosition.x+","+this.clientPosition.y+")")}isEqualWith(e){return e.uuid==this.uuid}getWorldPosition(){let e=this.worldPosition;return[e.x,e.y,e.z]}getClientPosition(){return new THREE.Vector2(this.clientPosition.x,this.clientPosition.y)}setClientPosition(e){this.clientPosition.x=e.x,this.clientPosition.y=e.y}getSvgElement(){return this.svgElement}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.EditEdge=class{constructor(e){this.svgElement=null,this.xmlns="http://www.w3.org/2000/svg",this.gridHighlightColor="#FF7F00",this.editPoints=e,this.initialize(),this.hide()}initialize(){let e=this.editPoints[0],t=this.editPoints[1],i=document.createElementNS(this.xmlns,"line");i.setAttribute("stroke",this.gridHighlightColor),i.setAttribute("stroke-width",3),i.setAttribute("x1",e.getClientPosition().x+""),i.setAttribute("y1",e.getClientPosition().y+""),i.setAttribute("x2",t.getClientPosition().x+""),i.setAttribute("y2",t.getClientPosition().y+""),this.svgElement=i}show(){this.update(),this.svgElement.style.display="block"}hide(){this.svgElement.style.display="none"}update(){let e=this.editPoints[0],t=this.editPoints[1];this.svgElement.setAttribute("x1",e.getClientPosition().x+""),this.svgElement.setAttribute("y1",e.getClientPosition().y+""),this.svgElement.setAttribute("x2",t.getClientPosition().x+""),this.svgElement.setAttribute("y2",t.getClientPosition().y+"")}detach(){this.svgElement.parentNode.removeChild(this.svgElement)}startWithNull(){return null==this.editPoints[0]}endWith(e){return this.editPoints[1].isEqualWith(e)}distanceTo(e){let t=e.x-this.clientPosition.x,i=e.y-this.clientPosition.y;return Math.sqrt(t*t+i*i)}getSvgElement(){return this.svgElement}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.Boundary=class{constructor(e){this.editPoints=e,this.polyline=null,this.xmlns="http://www.w3.org/2000/svg",this.glodonColor="#11DAB7",this.boundaryHighlightColor="#FF7F00",this.initialize()}initialize(){this.setObserver();let e=this.formatPolyline(this.editPoints),t=document.createElementNS(this.xmlns,"polyline");t.setAttribute("stroke",this.glodonColor),t.setAttribute("stroke-width",2),t.style.fill=this.glodonColor,t.style.fillOpacity="0.4",t.setAttribute("points",e),this.polyline=t}setObserver(){this.updateBinded=this.update.bind(this);for(const e of this.editPoints)e.setObserver(this.updateBinded)}formatPolyline(e){let t="";for(let i of e){let e=i.getClientPosition();t+=e.x+","+e.y,t+=" "}let i=e[0].getClientPosition();return t+=i.x+","+i.y,t+=" ",t}update(){let e=this.formatPolyline(this.editPoints);this.polyline.setAttribute("points",e)}rebuild(e){this.editPoints=e,this.initialize()}getSvgElement(){return this.polyline}}}();class No{constructor(){}}No.distanceToSegment=function(e,t,i){let n=this.nearestPointOnSegment(e,t,i);return e.distanceTo(n)},No.nearestPointOnSegment=function(e,t,i){var n=t.distanceToSquared(i);if(0==n)return e.distanceTo(t);var o=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;o=Math.max(0,Math.min(1,o));let s=new THREE.Vector2;return s.x=t.x+o*(i.x-t.x),s.y=t.y+o*(i.y-t.y),s};class Go{constructor(e){this.drawables=[],this.drawableStyle=e,this.style={},this.id="",this.hitTestEpsilon=10,this.highlightColor="#FFF227",this.grayColor="#BBBBBB"}attach(e){this.drawables.forEach((t=>{if(t instanceof Go)for(const i of t.getDrawables())e.appendChild(i);else e.appendChild(t)}))}detach(){for(const t of this.drawables){if(t instanceof Go)for(const i of t.getDrawables()){var e;(e=i.parentNode)&&e.removeChild(i)}else(e=t.parentNode)&&e.removeChild(t),this.drawables=[]}}hitTest(e){}setDefault(){}select(e){}setGray(){}magnify(){}resetSize(){}hide(){}show(){}isArrow(){return!1}getId(){return this.id}getDrawables(){return this.drawables}toVector2(e){return new THREE.Vector2(e.x,e.y)}toVector3(e){return new THREE.Vector3(e.x,e.y,e.z)}}class jo extends Go{constructor(e){super(),this.id=e.id,this.color=e.color,this.length=e.length||130,this.markerWidth=e.markerWidth||4,this.markerHeight=e.markerHeight||4,this.lineWidth=e.lineWidth||4,this.start=null,this.target=null}update(e,t){this.drawables=[];let i=re.makeMarker({id:this.id,color:this.color,markerWidth:this.markerWidth,markerHeight:this.markerHeight});this.drawables.push(i);let n={color:this.color,lineWidth:`${this.lineWidth}px`,start:e,end:t};this.start=e,this.target=t;let o=re.makeLine(n);o.setAttribute("marker-end","url(#"+this.id+")"),this.drawables.push(o)}setDefault(){this.drawables[1].style.stroke=this.color;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.color)}setGray(){this.drawables[1].style.stroke=this.grayColor;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.grayColor)}select(){this.drawables[1].style.stroke=this.highlightColor;let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.fill=this.highlightColor)}hitTest(e){let t=this.hitTestEpsilon;const i=new THREE.Vector3(e.x,e.y,0),n=new THREE.Line3(new THREE.Vector3(this.start.x,this.start.y,0),new THREE.Vector3(this.target.x,this.target.y,0)),o=new THREE.Vector3;return n.closestPointToPoint(i,!0,o),o.distanceTo(i)<=t?this:null}hide(){let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.display="none"),this.drawables[1].style.display="none"}show(){this.drawables[1].style.display="block";let e=document.getElementById(this.id)&&document.getElementById(this.id).children[0];e&&(e.style.display="block")}getDirection(){let e=this.target.clone().sub(this.start).normalize();return new THREE.Vector3(e.x,e.y,0)}magnify(){let e=document.getElementById(this.id);e.setAttribute("markerWidth",6),e.setAttribute("markerHeight",6)}resetSize(){let e=document.getElementById(this.id);e.setAttribute("markerWidth",4),e.setAttribute("markerHeight",4)}isArrow(){return!0}}class zo{constructor(){this.glodonColor="#32D3A6",this.highlightColor="#F99D0B",this.hitTestEpsilon=5,this.drawables=[],this.upSegment=[],this.downSegment=[]}update(e){this.drawables=[],this.upSegment=[],this.downSegment=[],this.points=e;for(let t=0;t<e.length;t++){let i=re.makeLine({start:e[t],end:e[(t+1)%4],lineWidth:"2px",color:this.glodonColor});this.drawables.push(i)}let t={},i=[...e,e[0]];t.points=re.calcPolylinePoints(i),t.width="1px",t.color="rgba(0,0,0,0)",t.fillColor="rgba(50, 211, 166, 0.1)";let n=re.makePolyline(t);this.drawables.push(n),this.upSegment.push(this.drawables[3]),this.downSegment.push(this.drawables[1]);let o=[new THREE.Vector2((e[0].x+e[3].x)/2,(e[0].y+e[3].y)/2),new THREE.Vector2((e[1].x+e[2].x)/2,(e[1].y+e[2].y)/2)],s=10,r=0,a=["1","2","3","4"];for(const e of o){let t=new jo({id:a[r++],color:this.glodonColor,length:8,lineWidth:3,markerWidth:4,markerHeight:4});t.update(e,e.clone().add(new THREE.Vector2(0,s))),s*=-1,t.getDrawables().forEach((e=>{this.drawables.push(e),r<=2&&this.upSegment.push(e),r>2&&this.downSegment.push(e)})),t.id=a[r++],t.update(e,e.clone().add(new THREE.Vector2(0,s))),s*=-1,t.getDrawables().forEach((e=>{this.drawables.push(e),r<=2&&this.upSegment.push(e),r>2&&this.downSegment.push(e)}))}}hitTest(e){let t=new THREE.Vector2(e.x,e.y),i=this.points[0],n=this.points[3],o=this.points[1],s=this.points[2],r=[];r.push(new THREE.Vector2(i.x,i.y)),r.push(new THREE.Vector2(n.x,n.y));let a=[];a.push(new THREE.Vector2(o.x,o.y)),a.push(new THREE.Vector2(s.x,s.y));let l=No.distanceToSegment(t,r[0],r[1]);return l<=this.hitTestEpsilon?"up-segment":(l=No.distanceToSegment(t,a[0],a[1]),l<=this.hitTestEpsilon?"down-segment":null)}detach(){for(const t of this.drawables){var e=t.parentNode;e&&e.removeChild(t),this.drawables=[]}}getDrawables(){return this.drawables}highlight(e){let t="up-segment"==e?this.upSegment:this.downSegment;for(const e of[0,2,4])t[e].style.stroke=this.highlightColor;let i="up-segment"==e?["1","2"]:["3","4"];for(const e of i){document.getElementById(e).children[0].style.fill=this.highlightColor}}cancelHighlight(){for(const e of[0,2,4])this.upSegment[e].style.stroke=this.glodonColor,this.downSegment[e].style.stroke=this.glodonColor;for(const e of["1","2","3","4"]){document.getElementById(e).children[0].style.fill=this.glodonColor}}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing"));i.RoomData=class{constructor(e,i){t.send("Bimface.Plugins.RoomEditing","RoomData"),this.viewer=e,this.roomBoundary=i,this.editHeight=null,this.editPoints=[],this.editEdges=[],this.boundary=null,this.editPointUuid=0,this.onEditPointDeletion=null,this.onEditPointAddition=null,this.isEditHeightEnabled=!1,this.roomHeightOffset={from:0,to:0}}build(){if(this.isEditHeightEnabled)!this.editHeight&&this.makeHeight();else{let t;this.makeEditPoints(),this.makeEditEdges(),this.makeBoundary();let i=this.viewer.roomManager;if(i&&i.getRoomById(this.editRoomId)){t=i.getRoomById(this.editRoomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId)}this.roomHeightOffset.from=t.min.z,this.roomHeightOffset.to=t.max.z}}makeHeight(){let t;this.editHeight=new zo;let i=this.viewer.roomManager;if(i&&i.getRoomById(this.editRoomId)){t=i.getRoomById(this.editRoomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId)}this.roomHeightOffset.from=t.min.z,this.roomHeightOffset.to=t.max.z}makeEditPoints(){for(let e=0;e<this.roomBoundary.length-1;e++){const t=this.roomBoundary[e];let n=new THREE.Vector3(t[0],t[1]),o=new i.EditPoint(this.viewer,n);o.uuid=this.editPointUuid++,this.editPoints.push(o)}}deleteEditPoint(e){for(let t=0;t<this.editPoints.length;t++){let i=this.editPoints[t];if(i.isEqualWith(e)){i.detach(),this.editPoints.splice(t,1),this.onEditPointDeletion(i);break}}}addEditPoint(e,t){let n=e.editPoints[0],o=e.editPoints[1];e.detach();let s=this.editEdges.findIndex((e=>e.endWith(o)));this.editEdges.splice(s,1);let r=this.editPoints.findIndex((e=>e.isEqualWith(n))),a=new THREE.Vector2(t.x,t.y),l=new i.EditPoint(this.viewer,a,!0);l.uuid=this.editPointUuid++,this.editPoints.splice(r+1,0,l);let h=new i.EditEdge([n,l]);this.editEdges.splice(s,0,h);let d=new i.EditEdge([l,o]);this.editEdges.splice(s+1,0,d),this.onEditPointAddition()}getEditPointCounts(){return this.editPoints.length}makeEditEdges(){for(let e=0;e<this.editPoints.length;e++){let t=[];t.push(this.editPoints[e]);let n=e==this.editPoints.length-1?0:e+1;t.push(this.editPoints[n]);let o=new i.EditEdge(t);this.editEdges.push(o)}}mergeEditEdges(e,t){t=null==t?2:t;let n=this.editEdges[e],o=this.editEdges[(e+t-1)%this.editEdges.length],s=[];s.push(n.editPoints[0]),s.push(o.editPoints[1]);let r=new i.EditEdge(s);this.editEdges.splice(e,0,r),this.editEdges.splice(e+1,t)}makeBoundary(){let e=this.editPoints;this.boundary=new i.Boundary(e)}getEditPoints(){return this.editPoints}getEditEdges(){return this.editEdges}getBoundary(){return this.boundary}getEditHeight(){return this.editHeight}setEditRoomId(e){this.editRoomId=e}getRoomSectionPoints(){let t,i=this.viewer.roomManager;if(i&&i.getRoomById(this.editRoomId)){t=i.getRoomById(this.editRoomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.editRoomId)}t=this.viewer.globalUnitUtil.translateBBox(t);let n=t.min,o=t.max,s=[],r=(n.y+o.y)/2,a=this.viewer.globalUnitUtil.translate(this.roomHeightOffset,["from","to"]);s.push(new THREE.Vector3(n.x,r,a.to)),s.push(new THREE.Vector3(n.x,r,a.from)),s.push(new THREE.Vector3(o.x,r,a.from)),s.push(new THREE.Vector3(o.x,r,a.to));let l=[];for(const e of s)l.push(this.viewer.getViewer().worldToCanvas(e));return this.roomHeightOnCanvas=l[1].y-l[0].y,l}updateRoomHeightOffset(e,t){let i=this.roomHeightOnCanvas,n=(this.roomHeightOffset.to-this.roomHeightOffset.from)/i,o=100;"Meter"===this.viewer.globalUnitUtil.getGlobalUnit()&&(o/=1e3),"up-segment"===e?(this.roomHeightOffset.to-=t.y*n,this.roomHeightOffset.to<this.roomHeightOffset.from+o&&(this.roomHeightOffset.to=this.roomHeightOffset.from+o)):(this.roomHeightOffset.from-=t.y*n,this.roomHeightOffset.from>this.roomHeightOffset.to-o&&(this.roomHeightOffset.from=this.roomHeightOffset.to-o))}getRoomHeightOffset(){return[this.roomHeightOffset.from,this.roomHeightOffset.to]}updateRoomBoundary(e){const t=this.roomBoundary;let i=new THREE.Vector3;for(let n=0;n<t.length;n++)i.fromArray(t[n]).applyMatrix4(e),t[n]=i.toArray()}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing"));i.RoomView=class{constructor(e,i){t.send("Bimface.Plugins.RoomEditing","RoomView"),this.roomData=e,this.svgContainer=i,this.eventManager=null;let n=this;this.roomData.onEditPointDeletion=function(e){n.detachDrawables(),n.updateBoundary(),n.updateEditEdges(e),n.attachDrawables()},this.roomData.onEditPointAddition=function(){n.detachDrawables(),n.updateBoundary(),n.attachDrawables()}}setEventManager(e){this.eventManager=e}getEventManager(){return this.eventManager}getData(){return this.roomData}attachDrawables(){if(this.roomData.isEditHeightEnabled){let e=this.roomData.getEditHeight().getDrawables();for(const t of e)this.svgContainer.appendChild(t);return}let e=this.roomData.getBoundary().getSvgElement();this.svgContainer.appendChild(e);for(const e of this.roomData.getEditEdges())this.svgContainer.appendChild(e.getSvgElement());for(const e of this.roomData.getEditPoints())this.svgContainer.appendChild(e.getSvgElement())}detachDrawables(){let e=this.svgContainer.children;for(;e.length>0;){let t=e[0];this.svgContainer.removeChild(t)}}update(){if(this.roomData.isEditHeightEnabled){return this.roomData.getEditHeight().update(this.roomData.getRoomSectionPoints()),this.detachDrawables(),void this.attachDrawables()}for(const e of this.roomData.getEditPoints())e.update();for(const e of this.roomData.getEditEdges())e.update();this.roomData.getBoundary().update()}updateBoundary(){let e=this.roomData.getBoundary();e.setObserver(),e.update()}updateEditEdges(e){let t=this.roomData.getEditEdges().findIndex((t=>t.endWith(e)));this.roomData.mergeEditEdges(t,2)}addCloudViewerEvents(e){this.updateBinded=this.update.bind(this),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.registerEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}removeCloudViewerEvents(e){e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_ZOOM,this.updateBinded),e.unregisterEventListener(CLOUD.EVENTS.ON_EDITOR_PANING,this.updateBinded)}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.PickEditor=class{constructor(e){this.roomView=e,this.roomData=e.getData(),this.snapEditPoint=null}begin(e){let t=new THREE.Vector3(e.x,e.y),i=this.snaping(t);this.snapEditPoint=i}onEditing(e){let t=new THREE.Vector3(e.x,e.y);if(null!=this.snapEditPoint)this.snapEditPoint.setClientPosition(t),this.snapEditPoint.update(!0),this.snapEditPoint.observer();else{let e=this.snaping(t);e?e.hightlight():this.cancelHightlight()}}end(e){this.snapEditPoint=null}snaping(e){for(const t of this.roomData.getEditPoints())if(t.distanceTo(e)<=5)return t;return null}cancelHightlight(){for(const e of this.roomData.getEditPoints())e.cancelHightlight()}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.AdditionEditor=class{constructor(e){this.roomView=e,this.roomData=e.getData(),this.snapEditEdge=null,this.beginPoint=new THREE.Vector2,this.eventManager=this.roomView.getEventManager()}begin(e){this.beginPoint.set(e.x,e.y),this.snapEditEdge=this.snaping(this.beginPoint)}onEditing(e){let t=new THREE.Vector2(e.x,e.y);if(null==this.snapEditEdge){let e=this.snaping(t);e?(this.hideAllEdges(),e.show(),this.eventManager.fireEvent("RoomEditorAddEnter")):(this.hideAllEdges(),this.eventManager.fireEvent("RoomEditorAddExit"))}else this.eventManager.fireEvent("RoomEditorAddExit")}end(e){if(null==this.snapEditEdge)return;let t=new THREE.Vector2(e.x,e.y);if(!1===t.equals(this.beginPoint))return void(this.snapEditEdge=null);let i=this.snapEditEdge.editPoints[0].getClientPosition(),n=this.snapEditEdge.editPoints[1].getClientPosition();this.roomData.addEditPoint(this.snapEditEdge,No.nearestPointOnSegment(t,i,n)),this.snapEditEdge=null}hideAllEdges(){for(const e of this.roomData.getEditEdges())e.hide()}snaping(e){let t=null,i=Number.MAX_SAFE_INTEGER;for(const n of this.roomData.getEditEdges()){let o=n.editPoints[0].getClientPosition(),s=n.editPoints[1].getClientPosition(),r=No.distanceToSegment(e,o,s);r<i&&(i=r,t=n)}return i<=5?t:null}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");t.DeletionEditor=class{constructor(e){this.roomView=e,this.roomData=e.getData(),this.snapEditPoint=null,this.beginPoint=new THREE.Vector2,this.eventManager=this.roomView.getEventManager()}begin(e){this.beginPoint.set(e.x,e.y),this.snapEditPoint=this.snaping(this.beginPoint)}onEditing(e){let t=new THREE.Vector3(e.x,e.y);if(null==this.snapEditPoint){let e=this.snaping(t);e?(e.hightlight(),this.eventManager.fireEvent("RoomEditorDeleteEnter")):(this.cancelHightlight(),this.eventManager.fireEvent("RoomEditorDeleteExit"))}else this.eventManager.fireEvent("RoomEditorDeleteExit")}end(e){if(null==this.snapEditPoint)return;if(!1!==new THREE.Vector2(e.x,e.y).equals(this.beginPoint)){if(this.roomData.getEditPointCounts()<=3)return this.eventManager.fireEvent("DeletionError"),void(this.snapEditPoint=null);this.roomData.deleteEditPoint(this.snapEditPoint),this.snapEditPoint=null}else this.snapEditPoint=null}snaping(e){for(const t of this.roomData.getEditPoints())if(t.distanceTo(e)<=5)return t;return null}cancelHightlight(){for(const e of this.roomData.getEditPoints())e.cancelHightlight()}}}();class Fo{constructor(e){this.roomView=e,this.roomData=e.getData(),this.snapSegmentId=null,this.lastPoint=new THREE.Vector2,this.beginPoint=new THREE.Vector2}begin(e){this.beginPoint.set(e.x,e.y),this.snapSegmentId=this.snaping(this.beginPoint),this.lastPoint.set(e.x,e.y)}onEditing(e){let t=new THREE.Vector2(e.x,e.y),i=this.roomData.getEditHeight();if(null==this.snapSegmentId){let e=this.snaping(t);e?i.highlight(e):i.cancelHighlight()}else{let e=t.clone().sub(this.lastPoint);this.roomData.updateRoomHeightOffset(this.snapSegmentId,e),this.roomView.update(),i.highlight(this.snapSegmentId),this.lastPoint.set(t.x,t.y)}}end(e){if(null==this.snapSegmentId)return;new THREE.Vector2(e.x,e.y).equals(this.beginPoint),this.snapSegmentId=null}snaping(e){return this.roomData.getEditHeight().hitTest(e)}cancelHightlight(){this.roomData.getEditHeight().cancelHightlight()}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing");n.RoomEditor=class{constructor(e){t.send("Bimface.Plugins.RoomEditing","RoomEditor"),P(this),this.bIsOnEditing=!1,this.viewer=e.viewer,this.roomEditorToolBar=e.roomEditorToolBar,this.lastAnimationState=null,this.restoreCameraStatus=null,this.roomId=e.roomId;let i=this.viewer.roomManager;if(i&&i.getRoomById(this.roomId)){let e=i.getRoomById(this.roomId);this.roomInfo=e.roomInfo}else this.roomInfo=this.viewer.mapCustomizedRoom[e.roomId];this.restoreStates={camera:null,sectionPlane:null},this.mapUIVisibility={"bf-tree-toolbar":"none","bf-modelTree-panel":"none","bf-toolbar-bottom":"none","bf-property-panel":"none","bf-measurement-panel":"none","bf-sectionPlane-panel":"none","bf-pickSectionPlane-panel":"none","bf-sectionBox-panel":"none","bf-settings-panel":"none","bf-basicInfo-panel":"none","bf-map-panel":"none"},this.initialize(),this.scratchVector=new THREE.Vector3,this.scratchVector_1=new THREE.Vector3}initialize(){this.domContainer=i.create("div","bf-RoomEditor-conext"),this.domContainer.style.position="absolute",this.domContainer.style.left=0,this.domContainer.style.top=0,this.domContainer.style.width="100%",this.domContainer.style.height="100%",this.svgContainer=i.createNS("svg","bf-RoomEditor-svg"),this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.domContainer.appendChild(this.svgContainer),this.viewer.getDomElement().appendChild(this.domContainer),this.addDomEventListeners(),this.offset=this.viewer.getDomElement().getBoundingClientRect();let t,o=this.viewer.getEventManager(),s=this.viewer.roomManager;if(s&&s.getRoomById(this.roomId)){t=s.getRoomById(this.roomId).getOldBoundary()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer,hasInitialized:!0}).getBoundaryByRoomId(this.roomId)}for(let e=0;e<t.length;e++){let i=(new THREE.Vector3).fromArray(t[e]);t[e]=i.toArray()}this.roomData=new n.RoomData(this.viewer,t),this.roomData.setEditRoomId(this.roomId),this.roomView=new n.RoomView(this.roomData,this.svgContainer),this.roomView.setEventManager(o),this.activeEditor=new n.PickEditor(this.roomView)}updateRoomData(){const e=this.getBindedModelTransform();this.roomData.updateRoomBoundary(e)}getBindedModelId(){return CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId)}getBindedModelTransform(){const e=this.getBindedModelId(),t=this.viewer.getModel(e)._getModelTransformation();let i=(new THREE.Matrix4).fromArray(t),n=new THREE.Vector3,o=new THREE.Quaternion,s=new THREE.Vector3;return i.decompose(n,o,s),n=this.viewer.globalUnitUtil.revertVector(n),i.compose(n,o,s),i}getBindedModelTransformInv(){const e=this.getBindedModelId(),t=this.viewer.getModel(e)._getModelTransformation();let i=(new THREE.Matrix4).fromArray(t),n=new THREE.Vector3,o=new THREE.Quaternion,s=new THREE.Vector3;return i.decompose(n,o,s),n=this.viewer.globalUnitUtil.revertVector(n),i.compose(n,o,s),i.invert()}onEnter(){let t=this.viewer.getViewer();this.bIsOnEditing=!0,this.restoreCameraStatus=this.viewer.getCameraStatus(),this.lastAnimationState=this.viewer.getCameraAnimation(),this.recordUIVisibility(),this.viewer.setCameraAnimation(!0),this.updateRoomData();let i,n=this,o=this.viewer.roomManager;if(o&&o.getRoomById(this.roomId)){i=o.getRoomById(this.roomId).getRoomBoundingBox().applyMatrix4(this.viewer.getViewer().getScene().getMatrixGlobal().clone())}else{i=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.roomId).applyMatrix4(this.viewer.getViewer().getScene().getMatrixGlobal().clone())}i=this.viewer.globalUnitUtil.translateBBox(i),this.setBimfaceUIVisibility(!1),this.viewer.getViewer().setStandardView(CLOUD.EnumStandardView.Top,1,null,(()=>{n.viewHouseVisibility=n.viewer._getViewHouseVisibility(),n.viewHouseVisibility&&n.viewer.hideViewHouse(),n.viewer._enableCursor(!1),t.getFilter().deactivateAll(),n.viewer._enableSelectionChanged(!1),n.viewer.setCameraAnimation(!1),n.viewer.setCameraType("OrthographicCamera"),n.viewer.enableOrbit(!1),n.viewer.hideRoomsById([this.roomId]),n.roomData.build(),n.roomView.attachDrawables(),n.roomView.addCloudViewerEvents(t),n.roomEditorToolBar.show(),n.viewer.render()}),i)}recordUIVisibility(){let e=Object.keys(this.mapUIVisibility);for(const t of e){let e=document.getElementsByClassName(t);e.length>0&&(this.mapUIVisibility[t]=e[0].style.display)}}save(){let e=this.roomInfo.boundary.offsetZ||0,t=[],i=[];const n=this.getBindedModelTransformInv(),o=new THREE.Vector3;let s=this.roomData.getRoomHeightOffset(),r=new THREE.Vector3(0,0,s[0]).applyMatrix4(this.viewer.getViewer().getModelManager().getModel(this.getBindedModelId()).transformMatrix.clone().invert()).z;for(const s of this.roomData.getEditPoints()){let a=s.getWorldPosition();o.fromArray(a).applyMatrix4(n),a=o.toArray();let l=a;l[2]=e,t.push(l),i.push({x:l[0],y:l[1],z:r})}return{boundary:this.viewer.createBoundary(t),outerBoundary:i,height:s[1]-s[0],id:this.roomId}}checkIntersect(){let t=new THREE.Vector3,i=new THREE.Vector3(10,10),n=[];n.push(t,new THREE.Vector3(10,0),i,new THREE.Vector3(0,10));new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(n);let o=[];for(const e of this.roomData.getEditPoints()){let t=e.getWorldPosition(),i=new THREE.Vector2(t[0],t[1]);o.push(i)}return e.Bimface.Plugins.Geometry.PlaneBufferGeometry.checkIntersect(o)}onExit(t){let i=this.viewer.getViewer();if(this.roomView.removeCloudViewerEvents(i),this.removeDomEventListeners(),this.roomView.detachDrawables(),this.bIsOnEditing=!1,this.viewHouseVisibility&&this.viewer.showViewHouse(),this.viewer._enableCursor(!0),this.viewer.setCameraAnimation(this.lastAnimationState),i.getFilter().activateAll(),this.viewer._enableSelectionChanged(!0),this.viewer.enableOrbit(!0),!0!==t){let t=this.save(),i=this.roomInfo.faceColor,n=this.roomInfo.frameColor;const o=this.getBindedModelId();let s=this.viewer.roomManager;if(s&&s.getRoomById(t.id)){let e=s.getRoomById(t.id),i=this.roomData.getRoomHeightOffset(),n=this.viewer.getViewer().getModelManager().getModel(o).transformMatrix.clone(),r=new THREE.Vector3,a=new THREE.Quaternion,l=new THREE.Vector3;n.decompose(r,a,l),r=this.viewer.globalUnitUtil.revertVector(r),n.compose(r,a,l),i[0]=new THREE.Vector3(0,0,i[0]).applyMatrix4(n.clone().invert()).z,i[1]=new THREE.Vector3(0,0,i[1]).applyMatrix4(n.clone().invert()).z;let h=t.boundary,d=[];for(let e=0;e<h.roomBoundary.length-1;e++){let t=h.roomBoundary[e];d.push([t.x,t.y,i[0]])}s.clearRoomsById([t.id],!1),e.roomInfo.boundary=this.viewer.createBoundary(d),e.roomInfo.height=i[1]-i[0],e.roomInfo.offset=i,s.addRoom(e)}else{this.viewer.createRoom(t.boundary,t.height,t.id,i,n);let s=this.roomData.getRoomHeightOffset();s[0]=new THREE.Vector3(0,0,s[0]).applyMatrix4(this.viewer.getViewer().getModelManager().getModel(o).transformMatrix.clone().invert()).z,s[1]=new THREE.Vector3(0,0,s[1]).applyMatrix4(this.viewer.getViewer().getModelManager().getModel(o).transformMatrix.clone().invert()).z;let r=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer});r.setBottomHeightByRoomId(this.roomId,s[0]),r.setTopHeightByRoomId(this.roomId,s[1]),this.viewer.bindRoomByModelId(t.id,o)}}else this.viewer.showRoomsById([this.roomId]);this.viewer.setCameraType("PerspectiveCamera");let n=this.viewer._sectionPlane;if(n){n.setPlane("Z"),n.setDirection("Forward");let e=this.roomData.getRoomHeightOffset(),t=this.viewer.getViewer().getBoundingBoxWorld(),i=this.viewer.getViewer().getScene().getExpandScalar(),o=(new THREE.Box3).setFromCenterAndSize(t.getCenter(this.scratchVector),t.getSize(this.scratchVector_1).multiplyScalar(i)),s=o.min.z,r=o.max.z,a=10;"m"===this.viewer._defaultUnit&&(a/=1e3);let l=this._calcSectionPlaneProgress(s,r,this.viewer.globalUnitUtil.translate(e[1]+a));n.setProgress(l)}this.isInHeightEditor=!1;let o=this;this.viewer.setCameraStatus(this.restoreCameraStatus,(function(){o.viewer.render()}))}makeSectionPlane(){let t,i=this.viewer.roomManager;if(i&&i.getRoomById(this.roomId)){t=i.getRoomById(this.roomId).getRoomBoundingBox()}else{t=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer}).getRoomBoundingBoxById(this.roomId)}t=this.viewer.globalUnitUtil.translateBBox(t);let n=(t.min.y+t.max.y)/2,o=this.viewer.getViewer().getBoundingBoxWorld(),s=this._calcSectionPlaneProgress(o.min.y,o.max.y,n),r=this.viewer._sectionPlane;r&&(r.setPlane("Y"),r.setDirection("Reverse"),r.setProgress(s))}_calcSectionPlaneProgress(e,t,i){return 100-(i-e)/(t-e)*100}destroySectionPlane(){this.sectionPlane.exit(),this.sectionPlane=null}getIsOnEditing(){return this.bIsOnEditing}setBimfaceUIVisibility(e){let t=Object.keys(this.mapUIVisibility);for(const i of t){let t=document.getElementsByClassName(i);0!=t.length&&(t[0].style.display=0==e?"none":this.mapUIVisibility[i])}}addDomEventListeners(){this.onMouseDownBinded=this.onMouseDown.bind(this),this.onMouseMoveBinded=this.onMouseMove.bind(this),this.onMouseUpBinded=this.onMouseUp.bind(this),this.onMouseDoubleClickBinded=this.onMouseDoubleClick.bind(this),this.onWindowResizeBinded=this.onWindowResize.bind(this);let e=this.svgContainer;e.addEventListener("mousemove",this.onMouseMoveBinded,!1),e.addEventListener("mousedown",this.onMouseDownBinded,!1),document.addEventListener("mouseup",this.onMouseUpBinded,!1),e.addEventListener("dblclick",this.onMouseDoubleClickBinded,!1),window.addEventListener("resize",this.onWindowResizeBinded,!1)}removeDomEventListeners(){let e=this.svgContainer;e.removeEventListener("mousemove",this.onMouseMoveBinded),e.removeEventListener("mousedown",this.onMouseDownBinded),document.removeEventListener("mouseup",this.onMouseUpBinded),e.removeEventListener("dblclick",this.onMouseDoubleClickBinded),window.removeEventListener("resize",this.onWindowResizeBinded)}destroySvgContainer(){this.roomView.detachDrawables(),this.domContainer.removeChild(this.svgContainer),this.svgContainer=null,this.viewer.getDomElement().removeChild(this.domContainer),this.domContainer=null}activateEditor(e){switch(e){case"Pick":this.roomData.isEditHeightEnabled=!1,this.activeEditor=new n.PickEditor(this.roomView),this._activateFromHeightEditor();break;case"Add":this.roomData.isEditHeightEnabled=!1,this.activeEditor=new n.AdditionEditor(this.roomView),this._activateFromHeightEditor();break;case"Delete":this.roomData.isEditHeightEnabled=!1,this.activeEditor=new n.DeletionEditor(this.roomView),this._activateFromHeightEditor();break;case"Height":this.roomData.isEditHeightEnabled=!0,this._activateHeightEditor(),this.activeEditor=new Fo(this.roomView)}}_activateFromHeightEditor(){if(!this.isInHeightEditor)return;let e=this.viewer.getCameraAnimation();this.viewer.setCameraAnimation(!1),this.viewer.setCameraStatus(this.restoreCameraStatus2,(()=>requestAnimationFrame((()=>{let t=this.viewer._sectionPlane;t&&(t.setPlane("Z"),t.setDirection("Forward"),t.setProgress(this.restoreSectionPlaneProgress)),this.roomView.detachDrawables(),this.roomView.attachDrawables(),this.viewer.render(),this.viewer.setCameraAnimation(e),this.roomView.update()})))),this.isInHeightEditor=!1}_activateHeightEditor(){this.isInHeightEditor=!0,this.restoreCameraStatus2=this.viewer.getCameraStatus(),this.viewer._sectionPlane&&(this.restoreSectionPlaneProgress=this.viewer._sectionPlane.getProgress()),this.makeSectionPlane();let t=this.viewer,i=this.roomView,n=this.viewer.getCameraAnimation();this.viewer.setCameraAnimation(!1),t.setView(e.Bimface.Viewer.ViewOption.South,(()=>{let o,s=this.viewer.roomManager;if(s&&s.getRoomById(this.roomId)){o=s.getRoomById(this.roomId).getRoomBoundingBox()}else{o=new e.Bimface.Plugins.SpatialRelation.Room({viewer:t}).getRoomBoundingBoxById(this.roomId)}o=this.viewer.globalUnitUtil.translateBBox(o),t.getViewer().zoomToBBox(o,.5,void 0,void 0,1e3),t.setCameraType("OrthographicCamera"),i.getData().build(),i.update(),this.viewer.setCameraAnimation(n)}))}activateByRoomId(t){let i;this.isInHeightEditor=!1,this.roomId=t;let o=this.viewer.roomManager;if(o&&o.getRoomById(this.roomId)){let e=o.getRoomById(this.roomId);this.roomInfo=e.roomInfo,i=e.getOldBoundary()}else{this.roomInfo=this.viewer.mapCustomizedRoom[t],i=new e.Bimface.Plugins.SpatialRelation.Room({viewer:this.viewer,hasInitialized:!0}).getBoundaryByRoomId(t)}this.roomData=new n.RoomData(this.viewer,i),this.roomData.setEditRoomId(t),this.roomView=new n.RoomView(this.roomData,this.svgContainer),this.roomView.setEventManager(this.viewer.getEventManager()),this.viewer.enableOrbit(!1),this.viewer._enableCursor(!1),this.activateEditor("Pick"),this.addDomEventListeners()}onMouseDown(e){if(e.button===THREE.MOUSE.LEFT){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.begin(t)}}onMouseMove(e){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.onEditing(t)}onMouseUp(e){if(e.button===THREE.MOUSE.LEFT){let t={x:e.clientX-this.offset.left,y:e.clientY-this.offset.top};this.activeEditor.end(t),e.preventDefault(),e.stopPropagation()}}onMouseDoubleClick(e){e.preventDefault(),e.stopPropagation()}onWindowResize(){this.roomView.update()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RoomEditing").RoomEidtorConfig=function(){return{viewer:null,roomId:null}},function(){let t="Bimface.Plugins.RevitHelpers",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers"));n.DrawingHelper=class{constructor(e){i.send(t,"DrawingHelper"),P(this),this.viewer3D=e.viewer,this.databagId=e.viewer._data.databagId,this.modelId=e.modelId,this.modelId&&!this.viewer3D._models[this.modelId]&&(this.modelId=null,this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")),this.dataViews=null,this.integrateDataViews={},this.drawingViews=[],this.drawingIds=[],this.drawingList=[],this.integrateDrawingList={},this._config=e,this.mapDrawingVisibility={},this.mapDrawingObject={},this.supportViewTypeMap={FloorPlan:!0,Elevation:!0,Section:!0};let n=e.viewer.getViewer().getScene();this.customPlaneManager=CLOUD.CustomPlaneManager.getInstance(n),this.initialize()}initialize(){let e=this;"integrateModel"==this.viewer3D.getModel(this.modelId||null)._data.modelType&&null!=this.viewer3D.getModel(this.modelId||null)._data.integrateDrawings?e._config.viewer.getLinksJson((function(t){t&&e.formatLinksData(t)})):"singleModel"==this.viewer3D.getModel(this.modelId||null)._data.modelType&&this.getViews((function(t){let i=JSON.parse(t).viewList;for(let t=0;t<i.length;t++){const s=i[t];if(s.preview.path&&e.supportViewTypeMap[s.viewType]){e.drawingIds.push(s.id);var o=n.DrawingView.toObject(s.viewPoint);o.origin.z+=s.elevation,e.drawingList.push({id:s.id,name:s.name,viewPort:o}),e.drawingViews.push(s)}}}))}createDrawingView(){return new n.DrawingView(this.viewer3D,this.drawingViews)}formatLinksData(e){let t={},i=(e,o)=>{for(let s=0;s<e.length;s++){let r,a=e[s],{linkTransform:l,fileId:h,name:d,links:c}=a;l.indexOf("]")>0?r=n(l,h,d,o):t[h]?t[h]instanceof Array?t[h].push(o):t[h]=[o,t[h]]:t[h]=o,c.length>0&&i(c,r)}},n=(e,i,n,o)=>{let s=new THREE.Matrix4;return e&&s.set.apply(s,JSON.parse(e)),s.transpose(),o&&s.premultiply(o),t[i]?t[i]instanceof Array?t[i].push(s):t[i]=[s,t[i]]:t[i]=s,s};for(let t=0;t<e.length;t++){let o,s=e[t],{linkTransform:r,fileId:a,name:l,links:h}=s;o=r.indexOf("]")>0?n(r,a,l):new THREE.Matrix4,h.length>0&&i(h,o)}this.transforms=t}getViews(e){if(this.dataViews)return void(e&&e(this.dataViews));let t=this;(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViews((function(i){t.dataViews=i,e&&e(i.data)}))}getViewsById(e,t){if(this.integrateDrawingList[e])return void(t&&t(this.integrateDrawingList[e]));let i=this;(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViewsById(e,(function(o){if(!o.data)return t&&t([]);i.integrateDataViews[e]=o,i.integrateDataViews.resourceHost=o.resourceHost;let s=JSON.parse(o.data).viewList,r=[];for(let e=0;e<s.length;e++){const t=s[e];if(t.preview.path&&i.supportViewTypeMap[t.viewType]){i.drawingIds.push(t.id);var a=n.DrawingView.toObject(t.viewPoint);a.origin.z+=t.elevation;var l={id:t.id,name:t.name,viewPort:a};r.push(l),i.drawingViews.push(t)}}i.drawingList=i.drawingList.concat(r),i.integrateDrawingList[e]=r,t&&t(r)}))}isInclude(e){return this.drawingIds.indexOf(e)>=0}getDrawingList(e,t){if(!e){let e=JSON.parse(JSON.stringify(this.drawingList));return e.forEach((e=>{e.viewPort&&e.viewPort.origin&&(e.viewPort.origin=this.viewer3D.globalUnitUtil.revertTranslate(e.viewPort.origin,["x","y","z"]))})),t&&t(e),e}{if("integrateModel"==this.viewer3D.getModel(this.modelId)._data.modelType){let t=!1,i=this.viewer3D.getModel(this.modelId)._data.integratedFileIds;for(let n in i){if(i[n].indexOf(e)>-1){t=!0;break}}if(!t)return void this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")}let i=this;this.getViewsById(e,(function(e){return e.forEach((e=>{e.viewPort&&e.viewPort.origin&&(e.viewPort.origin=i.viewer3D.globalUnitUtil.revertTranslate(e.viewPort.origin,["x","y","z"]))})),t&&t(e),e}))}}addDrawingsById(e,t,i){let n=this,o=0;for(let s=0;s<e.length;s++){const r=e[s];if(this.isInclude(r)){this.mapDrawingObject.hasOwnProperty(r)&&(this.removeDrawingsById([r]),console.warn("Duplicate id."));let s=this.createDrawingView();s.activeViewById(r);let a=this.drawingIds.indexOf(r),l=this.drawingViews[a],h=(this.dataViews||this.integrateDataViews).resourceHost+"/"+n.databagId+"/"+l.preview.path;if(null==l.preview.path)return void console.warn("No thumbnail in databag.");if(++o,l.id.indexOf(".")>0){let n=l.id.split(".")[0];if(this.transforms&&this.transforms[n])if(this.transforms[n].slice)for(let s=0,a=this.transforms[n];s<a.length;s++){let n=this.createDrawingView();n.activeViewById(r),n.setLinkFileTranslation(a[s]);let l=n.getOutline3D();this.addPlane(l,t,h,e,o,r,i,s+1==a.length,n)}else{s.setLinkFileTranslation(this.transforms[n]);let a=s.getOutline3D();this.addPlane(a,t,h,e,o,r,i,!0,s)}else{let n=s.getOutline3D();this.addPlane(n,t,h,e,o,r,i,!0,s)}}else{let a=s.getOutline3D();this.addPlane(a,t,h,e,o,r,(function(){n.viewer3D.render(),i&&i()}),!0,s)}}}}addPlane(e,t,i,n,o,s,r,a,l){let h=this;this.customPlaneManager.addPlane(e.min,e.max,i,(function(e){h.mapDrawingObject[s]||(h.mapDrawingObject[s]=[]),"number"!=typeof t&&(t=0),l.update(e,h.viewer3D.globalUnitUtil.translate(t)),l=null,h.mapDrawingObject[s].push(e),a&&o==n.length&&r&&r()}))}clearDrawings(){let e=this.drawingIds;this.removeDrawingsById(e)}hideAllDrawings(){let e=this.drawingIds;this.hideDrawingsById(e)}hideDrawingsById(e){for(let t=0;t<e.length;t++){const i=e[t];if(this.isInclude(i)&&this.mapDrawingObject[i]){let e=this;this.mapDrawingObject[i].forEach((function(t){e.customPlaneManager.hidePlane(t)}))}}this.viewer3D.render()}removeDrawingsById(e){for(let t=0;t<e.length;t++){const i=e[t];if(this.isInclude(i)&&this.mapDrawingObject[i]){let e=this;this.mapDrawingObject[i].forEach((function(t){e.customPlaneManager.removePlane(t)})),delete this.mapDrawingObject[i]}}this.viewer3D.render()}setDrawingsOpacityById(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(this.isInclude(n)&&this.mapDrawingObject[n]){let e=this;this.mapDrawingObject[n].forEach((function(i){e.customPlaneManager.setPlaneOpacity(i,t)}))}}this.viewer3D.render()}showAllDrawings(){let e=this.drawingIds;this.showDrawingsById(e)}showDrawingsById(e){for(let t=0;t<e.length;t++){const i=e[t];if(this.isInclude(i)&&this.mapDrawingObject[i]){let e=this;this.mapDrawingObject[i].forEach((function(t){e.customPlaneManager.showPlane(t)}))}}this.viewer3D.render()}getViewsTree(e,n){if(i.send(t,"getViewsTree"),"[object Function]"===Object.prototype.toString.call(e)&&(n=e,e=""),"integrateModel"==this.viewer3D.getModel(this.modelId)._data.modelType){let t=!1,i=this.viewer3D.getModel(this.modelId)._data.integratedFileIds;for(let n in i){if(i[n].indexOf(e)>-1){t=!0;break}}if(!t)return void this.viewer3D.console.warn("Incorrect parameter fileId or incorrect member modelId of DrawingHelperConfig.")}(this.modelId?this.viewer3D.getModel(this.modelId)._getMetaDataManager().dataManager:this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager).getViewsTree(e,(e=>n(this.viewer3D.globalUnitUtil.excute(e,"mm",this.viewer3D.globalUnitUtil.getGlobalUnit(),["cropBox","outline","elevation"]))))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers").DrawingHelperConfig=function(){return{viewer:null,modelId:""}};class Wo{constructor(e,t,i){this.viewer3D=e,this.objectType=t,this.name="Translation",this._eventManager=i,this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1,"ExternalObject"===t&&(this.externalObjectManager=new Glodon.Bimface.Plugins.ExternalObject.ExternalObjectManager(e))}setEditedObjectId(e){if(this.handleEditedObjectId(e),e=this.editedObjectId,this.viewer3D instanceof Glodon.Bimface.Viewer.ViewerGIS){const t=this.viewer3D.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i<t.length;i++){let n=!1;const o=t[i].getExternalObjectManager(),s=o.getAllObjectIds();if(this.isEditedMulti()){for(let t=0;t<e.length;t++)if(s.includes(e[i])){this.externalObjectManager=o,n=!0;break}if(n)break}else if(s.includes(e)){this.externalObjectManager=o;break}}}this.isEditedMulti()&&this.init()}handleEditedObjectId(e){this.editedObjectId=Array.isArray(e)&&1===e.length?e[0]:e}getEditedObjectId(){return this.editedObjectId}isEditedMulti(){return Array.isArray(this.editedObjectId)&&this.editedObjectId.length>1}init(){if(!this.initialized&&this.isEditedMulti()){const e=this.editedObjectId[0];this.singleModelMatrixInvert=this.getModelTransformMatrix(e).invert();const t=this.editedObjectId.reduce(((e,t)=>{const{min:i,max:n}=this.getSingleBoundingBoxWorld(t);return e.push(i,n),e}),[]),{min:i,max:n}=(new THREE.Box3).setFromPoints(t);this.initialCenter=(new THREE.Vector3).addVectors(i,n).multiplyScalar(.5),this.initialBoundingBoxPoints=[new THREE.Vector3(i.x,i.y,i.z),new THREE.Vector3(n.x,i.y,i.z),new THREE.Vector3(n.x,n.y,i.z),new THREE.Vector3(i.x,n.y,i.z),new THREE.Vector3(i.x,i.y,n.z),new THREE.Vector3(n.x,i.y,n.z),new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(i.x,n.y,n.z)],this.initialized=!0}}resetInitialValues(){this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1}getBoundingBoxWorld(){const e=this.objectType;if(this.isEditedMulti()){return(new THREE.Box3).setFromPoints(this.initialBoundingBoxPoints.map((e=>e.clone().applyMatrix4(this.transformMatrix))))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundingBoxWorld()}getTransformMatrix(){return this.isEditedMulti()?this.transformMatrix:this.getModelTransformMatrix(this.editedObjectId)}getSingleBoundingBoxWorld(e){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(e);return this.viewer3D.getViewer().getModelManager().getModel(e).getBoundingBoxWorld()}getModelTransformMatrix(e){if("ExternalObject"===this.objectType){let t=this.viewer3D.getExternalComponentManager().getGroupTransform(e);return(new THREE.Matrix4).compose(t.position,t.rotate,t.scale)}return this.viewer3D.getViewer().getModelManager().getModel(e).getTransformMatrix().clone()}getBoundaryPoints(){const e=this.objectType;if(this.isEditedMulti()){const e=this.transformMatrix;return this.initialBoundingBoxPoints.map((t=>t.clone().applyMatrix4(e)))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundaryPoints(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundaryPoints()}getBoundingBox(){let e=this.getBoundaryPoints(),t=this.getRotationMatrix().invert(),i=[];return e.map((e=>i.push(e.clone().applyMatrix4(t)))),(new THREE.Box3).setFromPoints(i)}getRotationMatrix(){let e=new THREE.Matrix4,t=this.getTransformMatrix();return e.extractRotation(t),e}_fireModelEvent(e){const t=this._eventManager,i=Array.isArray(this.editedObjectId)?this.editedObjectId:[this.editedObjectId],n={};i.map((e=>{n[e]=this.viewer3D.getModel(e).getModelTransformationAdaptedUnit()})),t.fireEvent(e,{modelId:i,transformation:n})}updateController(e){}updateTransformMatrix(){const e=this.editedObjectId[0],t=this.getModelTransformMatrix(e);this.transformMatrix=t.multiply(this.singleModelMatrixInvert)}_scaleOnBasePoint(e,t,i){const n=new THREE.Vector3,o=new THREE.Quaternion,s=new THREE.Vector3;e.decompose(n,o,s),s.multiply(i);const r=i.clone().sub(new THREE.Vector3(1,1,1)),a=o.clone(),l=a.clone().invert(),h=n.clone(),d=t.clone().sub(h).applyQuaternion(l).multiply(r).applyQuaternion(a);n.sub(d);return(new THREE.Matrix4).compose(n,o,s)}_rotateOnBasePoint(e,t,i,n){const o=new THREE.Vector3,s=new THREE.Quaternion,r=new THREE.Vector3;e.decompose(o,s,r);const a=s.clone().invert(),l=(new THREE.Quaternion).setFromAxisAngle(i,n);s.multiply(l);const h=o.clone(),d=t.clone().sub(h).applyQuaternion(a).applyQuaternion(s);o.sub(d).add(t.clone().sub(h));return(new THREE.Matrix4).compose(o,s,r)}getExternalObjectTransform(e){const t=this.externalObjectManager.getTransformation(e);return(new THREE.Matrix4).fromArray(t)}setRotation(e,t){const i=this.objectType,n=t;if(this.isEditedMulti()){const t=this.editedObjectId.length,i=this.viewer3D.globalUnitUtil.revertVector(this.initialCenter.clone().applyMatrix4(this.transformMatrix)),o=this.transformMatrix.clone();let s;switch(n){case"xy":s=new THREE.Vector3(0,0,1);break;case"xz":s=new THREE.Vector3(0,1,0);break;case"yz":s=new THREE.Vector3(1,0,0)}const r=this._rotateOnBasePoint(this.transformMatrix.clone(),i,s,e),a=o.clone().invert();for(let e=0;e<t;e++){const t=this.editedObjectId[e];let i;if("ExternalObject"===this.objectType)i=this.getExternalObjectTransform(t);else{const e=this.viewer3D.getModel(t).getModelTransformation();i=(new THREE.Matrix4).fromArray(e)}const n=r.clone().multiply(a.clone().multiply(i));"ExternalObject"===this.objectType?this.externalObjectManager.setTransformation(t,n.elements):this.viewer3D.getModel(t).setModelTransformation(n.elements)}this.updateTransformMatrix()}else{const t=this.viewer3D.globalUnitUtil.revertVector(this.getEditObjectCenter());if("ExternalObject"===i)"xy"===n&&this.externalObjectManager.setRotationZ(this.editedObjectId,t,e),"xz"===n&&this.externalObjectManager.setRotationY(this.editedObjectId,t,e),"yz"===n&&this.externalObjectManager.setRotationX(this.editedObjectId,t,e);else if("Model"==i){const i=this.viewer3D.getModel(this.editedObjectId);"xy"===n&&i.setModelRotationZ(t,e),"xz"===n&&i.setModelRotationY(t,e),"yz"===n&&i.setModelRotationX(t,e)}}"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}getEditObjectCenter(){return this._modelCenter=new THREE.Vector3,this.getBoundingBoxWorld().getCenter(this._modelCenter),this._modelCenter}setObjectScale(e,t){const i=this.objectType;if(this.isEditedMulti()){const n=this.editedObjectId.length,o=this.transformMatrix.clone(),s=this._scaleOnBasePoint(this.transformMatrix.clone(),e,t),r=o.clone().invert();for(let e=0;e<n;e++){const t=this.editedObjectId[e],n="ExternalObject"===i?this.getExternalObjectTransform(t).elements:this.viewer3D.getModel(t).getModelTransformation(),o=(new THREE.Matrix4).fromArray(n),a=s.clone().multiply(r.clone().multiply(o));"ExternalObject"===this.objectType?this.externalObjectManager.setTransformation(t,a.elements):this.viewer3D.getModel(t).setModelTransformation(a.elements)}this.updateTransformMatrix()}else"ExternalObject"===i?this.externalObjectManager.scaleOnBasePoint(this.getEditedObjectId(),e,t):"Model"===i&&this.viewer3D.getModel(this.getEditedObjectId()).setModelScale(e,t),"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}setObjectTranslation(e){const t=this.objectType;if(this.isEditedMulti())this.editedObjectId.forEach((i=>{if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}));else{const i=this.editedObjectId;if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}this.isEditedMulti()&&this.updateTransformMatrix(),"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}setName(e){this.name=e}}Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Web.Lang.Utility.Dom");let $o=Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Bimface.Plugins.ObjectEditor");class Xo{constructor(e,t){this.viewer=e,this.editObjectType=t,P(this),this.activeEditors=[],this.rotationController={X:!0,Y:!0,Z:!0},this.translationController={X:!0,Y:!0,Z:!0},this.scaleController={Uniform:!0,X:!0,Y:!0,Z:!0},this.initilize()}initilize(){this.initHelperAndEvent();let e=new Glodon.Web.Lang.EventManager;this.getEventManager=function(){return e},this.activeEditor=new Wo(this.viewer,this.editObjectType,e)}initHelperAndEvent(){this.helper=CLOUD.Interaction.InteractionHelper.getInstance(this.viewer.getViewer()),this.helperEvents={},this.addHelperEvent("TransformStarted",(e=>{"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformStart")})),this.addHelperEvent("TransformChanged",(e=>{if("Translation"===e.id){let t=e.control.position.clone(),i={x:t.x-this.objectPositon.x,y:t.y-this.objectPositon.y,z:t.z-this.objectPositon.z};this.activeEditor.setObjectTranslation(this.viewer.globalUnitUtil.revertTranslate(i,["x","y","z"])),this.objectPositon=t}else if("Scale"===e.id){let t=e.control.scaleInfo,i={};if(t){let n=this.activeEditor.getBoundaryPoints(),o=null;const s=(e,t,i,o)=>{let s=n[e],r=n[t],a=n[i],l=n[o];return(new THREE.Vector3).add(s).add(r).add(a).add(l).multiplyScalar(.25)};switch(t.type){case"AxisX":o=s(0,3,7,4),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisXN":o=s(1,2,6,5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisY":o=s(0,1,5,4),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisYN":o=s(2,3,7,6),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisZ":o=s(0,1,2,3),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;case"AxisZN":o=s(4,5,6,7),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;default:o=s(0,1,2,3).add(s(4,5,6,7)).multiplyScalar(.5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,t.scaleFactor/this.objectScale.y,t.scaleFactor/this.objectScale.z)}o=this.viewer.globalUnitUtil.revertVector(o),this.activeEditor.setObjectScale(o,i),e.control.update(this.activeEditor.getBoundingBox());let r=new THREE.Vector3;this.activeEditor.getBoundingBoxWorld().getCenter(r),e.control.setPosition(r),this.objectScale={x:t.scaleFactor,y:t.scaleFactor,z:t.scaleFactor}}}else if("Rotate"===e.id){let t=e.control.rotateInfo,i="";if(t){switch(t.type){case"ringX":default:i="yz";break;case"ringY":i="xz";break;case"ringZ":i="xy"}switch(this.activeEditor.setRotation(t.angle,i),t.type){case"ringX":e.control.rotateX(t.angle);break;case"ringY":e.control.rotateY(t.angle);break;default:e.control.rotateZ(t.angle)}}}})),this.addHelperEvent("TransformFinished",(e=>{"Scale"===e.id&&(this.objectScale={x:1,y:1,z:1}),"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformEnd")}))}addHelperEvent(e,t){this.helperEvents[e]=t,this.helper.addEventListener(e,t)}setEditedObjectId(e){this.editedObjectId=e,Array.isArray(e)&&this.activeEditor.resetInitialValues(),this.activeEditor.setEditedObjectId(e),this.dispose();let t=new THREE.Vector3;switch(this.activeEditor.name){case"Translation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.updateController()}attachInitDrawables(){}getEditedObjectId(){return this.editedObjectId}activateEditor(e){this.dispose();let t=new THREE.Vector3;switch(e){case"Translation":this.activeEditor.setName("Translation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.setName("Scaling"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.setName("Rotation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.activeEditor.setEditedObjectId(this.editedObjectId),this.updateController()}changeControlArrowDirection(){const e=this.viewer.getViewer().camera._direction&&this.viewer.getViewer().camera._direction.clone().applyMatrix4(this.helper.invertMatrix).normalize(),t=this.viewer.getViewer().camera.position.clone().applyMatrix4(this.helper.invertMatrix),i=this.viewer.getViewer().camera.fov;this.helper.dispatchEvent({type:"CameraChanged",cameraDirection:e,cameraPosition:t,cameraFov:i})}dispose(){this.helper.removeControl("Translation"),this.helper.removeControl("Scale"),this.helper.removeControl("Rotate")}hide(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!1),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!1),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!1),this.viewer.render()}show(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!0),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!0),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!0),this.viewer.render()}onExit(){this.dispose(),this.isExitNow=!0,Object.entries(this.helperEvents).forEach((([e,t])=>{this.helper.removeEventListener(e,t)})),this.viewer.render()}updateController(e,t){switch(t){case"Translation":null!=e.X&&(this.translationController.X=e.X),null!=e.Y&&(this.translationController.Y=e.Y),null!=e.Z&&(this.translationController.Z=e.Z);break;case"Rotation":null!=e.X&&(this.rotationController.X=e.X),null!=e.Y&&(this.rotationController.Y=e.Y),null!=e.Z&&(this.rotationController.Z=e.Z);break;case"Scaling":null!=e.X&&(this.scaleController.X=e.X),null!=e.Y&&(this.scaleController.Y=e.Y),null!=e.Z&&(this.scaleController.Z=e.Z),null!=e.Uniform&&(this.scaleController.Uniform=e.Uniform)}const i={...this.scaleController};this.activeEditor&&this.activeEditor.isEditedMulti()&&(i.X=i.Y=i.Z=!1),this.helper.getControl("Translation")&&this.helper.getControl("Translation").updateAxisVisible(this.translationController),this.helper.getControl("Rotate")&&this.helper.getControl("Rotate").updateAxisVisible(this.rotationController),this.helper.getControl("Scale")&&this.helper.getControl("Scale").updateAxisVisible(i)}}$o.ObjectEditorManager=Xo;const Yo="Exit",Zo="EditingModeChanged",qo=e.Bimface.Data.StatisticsDataManager.getInstance(),Ko="bf_interaction.sceneEditor";let Qo=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class Jo{constructor(e){this.viewer=e.viewer,this.objectId=e.objectId,P(this),this.viewer._objectEditorToolbar&&this.viewer._objectEditorToolbar.exit(),this.mode=null,this.toolBarButtons={translate:!e.buttonVisibility.hasOwnProperty("translate")||e.buttonVisibility.translate,rotate:!e.buttonVisibility.hasOwnProperty("rotate")||e.buttonVisibility.rotate,scale:!e.buttonVisibility.hasOwnProperty("scale")||e.buttonVisibility.scale},this.viewer._objectEditorToolbar=this,this.rotationController={X:!e.rotationController.hasOwnProperty("X")||e.rotationController.X,Y:!e.rotationController.hasOwnProperty("Y")||e.rotationController.Y,Z:!e.rotationController.hasOwnProperty("Z")||e.rotationController.Z},this.translationController={X:!e.translationController.hasOwnProperty("X")||e.translationController.X,Y:!e.translationController.hasOwnProperty("Y")||e.translationController.Y,Z:!e.translationController.hasOwnProperty("Z")||e.translationController.Z},Array.isArray(this.objectId)&&this.objectId.length>1?this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!!e.scaleController.hasOwnProperty("X")&&e.scaleController.X,Y:!!e.scaleController.hasOwnProperty("Y")&&e.scaleController.Y,Z:!!e.scaleController.hasOwnProperty("Z")&&e.scaleController.Z}:this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!e.scaleController.hasOwnProperty("X")||e.scaleController.X,Y:!e.scaleController.hasOwnProperty("Y")||e.scaleController.Y,Z:!e.scaleController.hasOwnProperty("Z")||e.scaleController.Z}}setRotationController(e){e&&(this.rotationController=e),this.objectEditorManager.updateController(this.rotationController,"Rotation")}getRotationController(){let e={};return e.X=!this.rotationController.hasOwnProperty("X")||this.rotationController.X,e.Y=!this.rotationController.hasOwnProperty("Y")||this.rotationController.Y,e.Z=!this.rotationController.hasOwnProperty("Z")||this.rotationController.Z,e}setTranslationController(e){e&&(this.translationController=e),this.objectEditorManager.updateController(this.translationController,"Translation")}getTranslationController(){let e={};return e.X=!this.translationController.hasOwnProperty("X")||this.translationController.X,e.Y=!this.translationController.hasOwnProperty("Y")||this.translationController.Y,e.Z=!this.translationController.hasOwnProperty("Z")||this.translationController.Z,e}setScaleController(e){e&&(this.scaleController=e),this.objectEditorManager.updateController(this.scaleController,"Scaling")}getScaleController(){let e={};return e.X=!this.scaleController.hasOwnProperty("X")||this.scaleController.X,e.Y=!this.scaleController.hasOwnProperty("Y")||this.scaleController.Y,e.Z=!this.scaleController.hasOwnProperty("Z")||this.scaleController.Z,e.Uniform=!this.scaleController.hasOwnProperty("Uniform")||this.scaleController.Uniform,e}setButtonVisibility(e){e&&(this.toolBarButtons=e,this._updateButtonsVisibility())}getButtonVisibility(){let e={};return e.translate=!this.toolBarButtons.hasOwnProperty("translate")||this.toolBarButtons.translate,e.rotate=!this.toolBarButtons.hasOwnProperty("rotate")||this.toolBarButtons.rotate,e.scale=!this.toolBarButtons.hasOwnProperty("scale")||this.toolBarButtons.scale,e}_updateButtonsVisibility(){this.toolBarButtons.scale||this.toolBarButtons.rotate||this.toolBarButtons.translate?(this.switchToolbarAllHide=!1,this.show()):(this.setBimfaceUIVisibility(!1),this.switchToolbar.hide(),this.switchToolbarAllHide=!0);let e=this.switchToolbar.getControls(),t=this.getButton("Translation",e),i=this.getButton("Rotation",e),n=this.getButton("Scaling",e);this.toolBarButtons.translate?t.show():t.hide(),this.toolBarButtons.rotate?i.show():i.hide(),this.toolBarButtons.scale?n.show():n.hide()}_updateController(){this.objectEditorManager&&(this.objectEditorManager.updateController(this.translationController,"Translation"),this.objectEditorManager.updateController(this.rotationController,"Rotation"),this.objectEditorManager.updateController(this.scaleController,"Scaling"))}setEditingMode(e){if(this.objectEditorManager){switch(e){case"rotation":this.mode="rotation",this.objectEditorManager.activateEditor("Rotation");break;case"translation":this.mode="translation",this.objectEditorManager.activateEditor("Translation");break;case"scale":this.mode="scale",this.objectEditorManager.activateEditor("Scaling")}this.objectEditorManager.show()}}getEditingMode(){return this.mode}setEditedObjectId(e){this.objectEditorManager.setEditedObjectId(e)}getEditedObjectId(){return this.objectEditorManager.getEditedObjectId()}show(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!1),this.modelEditor.show(),this.switchToolbarAllHide||this.switchToolbar.show(),this.objectEditorManager.show())}hide(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!0),this.modelEditor.hide(),this.switchToolbar.hide(),this.objectEditorManager.hide())}exit(){this._destroyed||(this.hide(),this._getEventManager().fireEvent(Yo),this.objectEditorManager.onExit(),delete this.viewer._objectEditorToolbar,this.destroy())}destroy(){this.domElement&&this.domElement.remove(),this.domElement=null,this.viewer=null,this.objectId=null,this.objectEditorManager=null,this._destroyed=!0}update(){}updateManagerController(e,t){this.objectEditorManager.updateController(e,type)}initialize(){this.mapUIVisibility={"bf-tree-toolbar":"none","bf-modelTree-panel":"none","bf-toolbar-bottom":"none","bf-property-panel":"none","bf-measurement-panel":"none","bf-sectionPlane-panel":"none","bf-pickSectionPlane-panel":"none","bf-sectionBox-panel":"none","bf-settings-panel":"none","bf-basicInfo-panel":"none","bf-map-panel":"none"},this.recordUIVisibility()}toolBarDom(t=!1){const i=this;let n=[];const o=Qo.create("div",t?"bf-effectToolbar":"bf-roomEditorToolbar");if(i.domElement=o,o.style.zIndex=1,o.addEventListener("mousedown",(e=>(e.stopPropagation(),!1))),t){const t=new e.Bimface.UI.Toolbar.ToolbarConfig;t.element=o,t.className="bf-toolbar bf-toolbar-effectToolbar switch-btn";let s=this.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(t);i.modelEditor=s,n.push(s);const r=new e.Bimface.UI.Button.ButtonConfig;r.className="bf-button bimface-icon gld-bf-edit-24",r.title="点击隐藏编辑控件",r.checkedState=!0;const a=new e.Bimface.UI.Button.ToggleButton(r);a.addEventListener("StateChange",(e=>{e?(a.element.title="点击隐藏编辑控件",qo.send(Ko,"editorStatusOn"),this.objectEditorManager.show(),this.objectEditorManager.activateEditor("Translation")):(a.element.title="点击显示编辑控件",qo.send(Ko,"editorStatusOff"),this._getEventManager().fireEvent(Yo),this.objectEditorManager.dispose(),this.objectEditorManager.hide()),this.toggleOtherButtons(e)})),s.addControl(a)}if(void 0===this.switchToolbar){var s=e.Bimface.UI.Toolbar.ToolbarConfig();s.className=t?"bf-toolbar bf-toolbar-effectToolbar":"bf-toolbar bf-toolbar-roomEditor",s.element=o,s.buttons=["ModelEditingTranslate","ModelEditingRotate","ModelEditingScale"],this.viewer.getDomElement().appendChild(o),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(s),n.push(this.switchToolbar)}let r=e.Bimface.UI.Control.ControlEvent,a=this.switchToolbar.getControls();this.uncheckOthers("Translation",a);let l=["Translation","Rotation","Scaling"];i._editingMode="Translation";for(let e=0;e<a.length;e++){let t=a[e];t.addEventListener(r.Click,(function(){if(t.isChecked()){i.objectEditorManager.activateEditor(l[e]),i.uncheckOthers(t.getId(),a);let n="Scaling"===t.getId()?"Scale":t.getId();i._getEventManager().fireEvent(Zo,{previousEditingMode:i._editingMode,followingEditingMode:n}),i._editingMode=n}else t.toggleCheckedState()}))}if(!t){const t=new e.Bimface.UI.Toolbar.ToolbarConfig;t.element=o,t.className="bf-toolbar bf-toolbar-roomEditor";let s=i.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(t);i.modelEditor=s,n.push(s);const r=new e.Bimface.UI.Button.ButtonConfig;r.className="bf-modeleditor-cancel",r.title=BimfaceLanguage.bf_general_exit;const a=new e.Bimface.UI.Button.SingleButton(r);a.setHtml("退出"===BimfaceLanguage.bf_general_exit?"退 出":BimfaceLanguage.bf_general_exit),a.addEventListener("Click",(()=>{this.exit()})),s.addControl(a)}this.viewer.getDomElement().appendChild(o),this._updateButtonsVisibility(),this._updateController()}recordUIVisibility(){let e=Object.keys(this.mapUIVisibility);for(const t of e){let e=document.getElementsByClassName(t);e.length>0&&(this.mapUIVisibility[t]=e[0].style.display)}}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getButton(e,t){for(let i=0;i<t.length;i++){let n=t[i];if(n.getId()===e)return n}}setBimfaceUIVisibility(e){let t=Object.keys(this.mapUIVisibility);for(const i of t){let t=document.getElementsByClassName(i);0!=t.length&&(t[0].style.display=0==e?"none":this.mapUIVisibility[i])}}_getEventManager(){return this.objectEditorManager.getEventManager()}addEventListener(e,t){this._getEventManager().addEvent(e,t)}removeEventListener(e,t){this._getEventManager().removeEvent(e,t)}toggleOtherButtons(e){let t,i=this.switchToolbar.getControls();i.length&&(t=i[0],t.element.parentElement.style.display=e?"flex":"none");for(let n=0;n<i.length;n++)t=i[n],e&&(0===n?t.setCheckedState(!0):t.setCheckedState(!1))}}function es(e){let t=e.modelId;if(Array.isArray(e.ids)&&e.ids.length>0)return"ViewerGIS"===e.viewer.getViewerType()?e.ids.reduce(((t,i)=>{const n=e.viewer.getLayerManager().getLayer(i);return n&&t.push(n.getModelId()),t}),[]):e.ids;if("ViewerGIS"===e.viewer.getViewerType()&&e.layerId){const i=e.viewer.getLayerManager().getLayer(e.layerId);i&&(t=i.getModelId())}return t}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor").ModelEditorToolbarConfig=function(){return{viewer:null,modelId:null,layerId:null,app:null,buttonVisibility:{},translationController:{},rotationController:{},scaleController:{},ids:null}},function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor"));i.ModelEditorToolbar=class extends Jo{constructor(e){t.send("Bimface.Plugins.ModelEditor","ModelEditorToolbar"),e.objectId=es(e),super(e),this.name="ModelEditorToolbar",this.editedId=e.objectId,this.initialize(),this.toolBarDom(e.isGisEdit)}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedModelId(e){super.setEditedObjectId(e)}getEditedModelId(){return super.getEditedObjectId()}setEditedModel(e){const t=es({viewer:this.viewer,modelId:e,layerId:e});super.setEditedObjectId(t),this.editedId=e}getEditedModel(){return this.editedId}setEditedModels(e){const t=es({viewer:this.viewer,ids:e,layerIds:e});super.setEditedObjectId(t),this.editedId=e}getEditedModels(){return this.editedId}show(){super.show()}hide(){super.hide()}exit(){super.exit(),CLOUD.GlobalData.GTAO=this.enableGTAO}setRotationController(e){super.setRotationController(e)}getRotationController(){return super.getRotationController()}setTranslationController(e){super.setTranslationController(e)}getTranslationController(){return super.getTranslationController()}setScaleController(e){super.setScaleController(e)}getScaleController(){return super.getScaleController()}setEditingMode(e){super.setEditingMode(e)}getEditingMode(){return super.getEditingMode()}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}initialize(){super.initialize(),this.objectEditorManager=new Xo(this.viewer,"Model"),this.objectEditorManager.setEditedObjectId(this.objectId),this.enableGTAO=CLOUD.GlobalData.GTAO,!0===this.enableGTAO&&(CLOUD.GlobalData.GTAO=!1)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ModelEditor");let i=Object.freeze({ModelTransformStart:"ModelTransformStart",ModelTransforming:"ModelTransforming",ModelTransformEnd:"ModelTransformEnd",Exit:"Exit",EditingModeChanged:"EditingModeChanged"});t.ModelEditorToolbarEvent=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").ExternalObjectEditorToolbarConfig=function(){return{viewer:null,id:null,app:null,buttonVisibility:{},translationController:{},rotationController:{},scaleController:{},ids:null}};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject").ExternalObjectEditorToolbarEvent={Exit:"Exit",EditingModeChanged:"EditingModeChanged"};var ts,is,ns,os,ss;!function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ExternalObject"));i.ExternalObjectEditorToolbar=class extends Jo{constructor(e){t.send("Bimface.Plugins.ExternalObject","ExternalObjectEditorToolbar"),e.objectId=e.id||e.ids,super(e),this.name="ExternalObjectEditorToolbar",this.initialize(),this.toolBarDom(),P(this)}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedExternalObjectId(e){super.setEditedObjectId(e)}getEditedExternalObjectId(){return super.getEditedObjectId()}setEditedExternalObjectIds(e){super.setEditedObjectId(e)}getEditedExternalObjectIds(){return super.getEditedObjectId()}show(){super.show()}hide(){super.hide()}exit(){super.exit()}setRotationController(e){super.setRotationController(e)}getRotationController(){return super.getRotationController()}setTranslationController(e){super.setTranslationController(e)}getTranslationController(){return super.getTranslationController()}setScaleController(e){super.setScaleController(e)}getScaleController(){return super.getScaleController()}setEditingMode(e){super.setEditingMode(e)}getEditingMode(){return super.getEditingMode()}initialize(){super.initialize(),this.objectEditorManager=new Xo(this.viewer,"ExternalObject"),this.objectEditorManager.setEditedObjectId(this.objectId)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}}}(),function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation"));i.Room=class{constructor(e){t.send("Bimface.Plugins.SpatialRelation","Room"),this.viewer3D=e.viewer,this.databagId=e.viewer._data.databagId,this.toleranceType={STRICT:"STRICT",ORDINARY:"ORDINARY",LENIENT:"LENIENT"},this.tolerence=.25,this.mapRoomBbox={},this.mapRoomBoundary={},this.mapRoomId={},this.mapArea={},this.allComponentIds=null,P(this),!0!==e.hasInitialized&&this.initialize()}initialize(){let e=this;"singleMode"===this.viewer3D._data.modelType&&this.getRooms((function(t){let i=JSON.parse(t);for(const t of i)e.mapRoomId[t.id]=!0,e.mapRoomBbox[t.id]=(new THREE.Box3).setFromPoints([t.bboxMin,t.bboxMax])}))}getRooms(e){const t=this;this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager.getRooms((function(i){if(e)if(i&&i.length&&i[0].annotationPosition){const n=JSON.parse(JSON.stringify(i));i=t.viewer3D.globalUnitUtil.revertTranslate(t.viewer3D.globalUnitUtil.revertTranslate(i,["x","y","z","perimeter","area"]),["area"]);for(let e=0;e<i.length;e++)i[e].annotationPosition=n[e].annotationPosition;e(i)}else e(t.viewer3D.globalUnitUtil.revertTranslate(t.viewer3D.globalUnitUtil.revertTranslate(i,["x","y","z","perimeter","area"]),["area"]))}))}getRoomBoundary(e,t){this.mapRoomId[e]&&this.viewer3D.getDefaultModel()._getMetaDataManager().dataManager.getRoomBoundary(e,(function(e){t&&t(e)}))}getAreaByRoomId(e){let t=this,i=new Array;for(const n of e){let e={id:n,unit:"m2",value:null};if(t.mapArea[n])e.value=t.mapArea[n];else{let i=t._getRoomBoundaryById(n);i?"m"===this.viewer3D.getDefaultUnit()?e.value=Math.abs(THREE.ShapeUtils.area(i)):e.value=Math.abs(THREE.ShapeUtils.area(i))/1e6:console.warn(`Input room id ${n} is invalid.`)}i.push(e)}return i}getBoundaryByRoomId(e){let t=new Array,i=this.viewer3D.getCustomizedRoom();if(e in i){let n=this._getRoomBoundaryById(e);for(let o=0,s=n.length;o<s;o++){let s=new Array;s.push(n[o].x),s.push(n[o].y),s.push(i[e].offset[0]),t.push(s)}}else console.warn(`Input room id ${e} is not exist.`);return this.viewer3D.globalUnitUtil.revertTranslate(t)}getHeightByRoomId(e){let t,i=this.viewer3D.getCustomizedRoom();return e in i?t=i[e].height:console.warn(`Input room id ${e} is not exist.`),this.viewer3D.globalUnitUtil.revertTranslate(t)}setBoundaryByRoomId(e,t){let i,n=this.viewer3D.getCustomizedRoom();if(e in n){let o=n[e];if(this.viewer3D.clearRoomsById(e,!1),"string"==typeof t&&(t=JSON.parse(t)),t instanceof Array)if(2==t.length)i=this.viewer3D.createBoundary(t[0],t[1]);else{if(!(t.length>0))return;i=this.viewer3D.createBoundary(1==t.length&&t[0]||t)}else i=t;if(!i)return void console.warn("The custom room data is not standard");o.offset=this.viewer3D.globalUnitUtil.revertTranslate(o.offset),i.offsetZ-=o.offset[0],this.viewer3D.createRoomByOffset(i,o.offset,e,o.faceColor,o.frameColor,!1),this.viewer3D.render();let s={id:e,unit:"m2",value:null},r=this._getRoomBoundaryById(e);"m"===this.viewer3D.getDefaultUnit()?s.value=Math.abs(THREE.ShapeUtils.area(r)):s.value=Math.abs(THREE.ShapeUtils.area(r))/1e6}else console.warn(`Input room id ${e} is not exist.`)}enableDepthTest(e,t){const i=this.viewer3D.getViewer();CLOUD.ExtrudeBodyManager.getInstance(i).enableDepthTest(e,t)}getModelComponentIds(){if(this.allComponentIds&&"ViewerGIS"!==this.viewer3D.viewerType)return this.allComponentIds;let e=this.viewer3D.getViewer();return this.allComponentIds=e.getAllModelUserIds(),this.allComponentIds}getComponentsByRoomId(e,t,i,n){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let o=this;this.getRoomBoundary(e,(function(t){let i=JSON.parse(t);i.hasOwnProperty("loops")&&(i=i.loops[0]);let n=[];for(const e of i)n.push({x:e[0].x,y:e[0].y});o.mapRoomBoundary[e]=n}));let s=[],r=this.getModelComponentIds();for(const n in r)for(const o of r[n]){let r=this.viewer3D.getViewer().getComponentInfoByUserId(o,n).boundingBox;this.roomContains(e,r,t,i)&&s.push(o)}n&&n(s)}getRoomsByComponentId(e,t,i,n){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let o=[],s=this.viewer3D.getCustomizedRoom(),r=Object.keys(s);for(let n=0;n<r.length;n++){let s=r[n],a=this.viewer3D.getViewer().getComponentInfoByUserId(e).boundingBox;a=this.viewer3D.globalUnitUtil.revertBBox(a),this.roomContains(s,a,t,i)&&o.push(s)}n&&n(o)}roomContains(e,t,i,n){if(!this.viewer3D.getCustomizedRoom()[e]&&!this.mapRoomBoundary[e])return void console.warn("Input room id is invalid.");let o=this.isRoomContainBoundingBoxByZ(e,t,n);if(0==o)return o;let s=this.isRoomBoundingBoxContainBoundingBoxByXY(e,t,i);if(0==s)return s;let r=this.isRoomBoundaryContainBoundingBoxByXY(e,t,i);return 0!=r||r}getRoomBoundingBoxById(e){let t=this.getCustomizedRoom(e),i=CLOUD.ExtrudeBodyManager.getInstance(this.viewer3D.getViewer()).getBindedModelId(e);if(t){let e=t.boundingBox,n=t.offset;e.min.z=n[0],e.max.z=n[1];let o=(new THREE.Box3).setFromPoints([new THREE.Vector3(e.min.x,e.min.y,e.min.z),new THREE.Vector3(e.max.x,e.max.y,e.max.z)]).clone().applyMatrix4(this.viewer3D.getViewer().getModelManager().getModel(i).transformMatrix.clone());return this.viewer3D.globalUnitUtil.revertBBox(o)}if(this.mapRoomBbox[e]){let t=this.mapRoomBbox[e].clone().applyMatrix4(this.viewer3D.getViewer().getModelManager().getModel(i).transformMatrix.clone());return this.viewer3D.globalUnitUtil.revertBBox(t)}}getCustomizedRoom(e){let t=this.viewer3D.getCustomizedRoom()[e];if(!t)return null;if(t.boundary&&"user"!=t.boundary.belong){let e=[],i=[],n=t.boundary;for(let t=0;t<n.loops.length;t++){let o=n.loops[t],s=[];for(const e of o)s.push([e[0].x,e[0].y,e[0].z]);0==t?e=s:s.length>2&&i.push(s)}let o=this.viewer3D.createBoundary(e,i);return o.offset=[...t.offset],o}return t.boundary.offset=t.offset,t.boundary}_getRoomBoundaryById(e){return this.viewer3D.getCustomizedRoom()[e]?this.getCustomizedRoom(e).roomBoundary:this.mapRoomBoundary[e]}isRoomContainBoundingBoxByZ(e,t,i){let n=this.getRoomBoundingBoxById(e),o=n.min.z,s=n.max.z,r=t.max.z,a=t.min.z,l=this.tolerence;if(i==this.toleranceType.STRICT)return a>=o-l&&r<=s+l;if(i==this.toleranceType.ORDINARY){let e=(a+r)/2;return this.isBetween(e,o,s)&&(this.isBetween(a,o,s)||this.isBetween(r,o,s))}return i==this.toleranceType.LENIENT?a<=s+l&&r>=o-l:void 0}setTopHeightByRoomId(e,t){let i=this.getCustomizedRoom(e);if(i){let n=this.viewer3D.getCustomizedRoom()[e];this.viewer3D.clearRoomsById([e],!1);let o=[];for(let e=0;e<i.roomBoundary.length-1;e++){let t=i.roomBoundary[e];o.push([t.x,t.y,0])}let s=this.viewer3D.createBoundary(o);t=this.viewer3D.globalUnitUtil.translate(t);let r=[i.offset[0],t];this.viewer3D.createRoomByOffset(s,r,e,n.faceColor,n.frameColor,!0)}else console.log("No room exists whose id is "+e)}setBottomHeightByRoomId(e,t){let i=this.getCustomizedRoom(e);if(i){let n=this.viewer3D.getCustomizedRoom()[e];this.viewer3D.clearRoomsById([e],!1);let o=[];for(let e=0;e<i.roomBoundary.length-1;e++){let t=i.roomBoundary[e];o.push([t.x,t.y,0])}let s=this.viewer3D.createBoundary(o),r=[t=this.viewer3D.globalUnitUtil.translate(t),i.offset[1]];this.viewer3D.createRoomByOffset(s,r,e,n.faceColor,n.frameColor,!0)}else console.log("No room exists whose id is "+e)}isRoomBoundingBoxContainBoundingBoxByXY(e,t,i){let n=this.getRoomBoundingBoxById(e),o=n.min.x,s=n.max.x,r=n.min.y,a=n.max.y,l=t.min.x,h=t.max.x,d=t.min.y,c=t.max.y,u=this.tolerence;return i==this.toleranceType.STRICT?l>=o-u&&h<=s+u&&d>=r-u&&c<=a+u:i==this.toleranceType.ORDINARY||i==this.toleranceType.LENIENT?l<=s+u&&h>=o-u&&d<=a+u&&c>=r-u:void 0}isRoomBoundaryContainBoundingBoxByXY(e,t,i){let n=this.toFivePos(t),o=this._getRoomBoundaryById(e);o=this.viewer3D.globalUnitUtil.revertTranslate(o,["x","y","z"]);let s=[],r=CLOUD.ExtrudeBodyManager.getInstance(this.viewer3D.getViewer()).getBindedModelId(e);for(let e=0;e<o.length;e++){let t=new THREE.Vector3(o[e].x,o[e].y,0).clone().applyMatrix4(this.viewer3D.getViewer().getModelManager().getModel(r).transformMatrix.clone());s.push({x:t.x,y:t.y})}o=s;let a=0;for(let e=0;e<n.length;e++){const t=n[e];this.containsInBoundary(t,o)&&a++}let l=!1;return i==this.toleranceType.STRICT?l=5==a:i==this.toleranceType.ORDINARY?l=a>=3:i==this.toleranceType.LENIENT&&(l=a>=1),l}isBetween(e,t,i){let n=this.tolerence;return e<=i+n&&e>=t-n}toFivePos(e){let t=[];return t.push(new THREE.Vector2(e.min.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.max.y)),t.push(new THREE.Vector2(e.min.x,e.max.y)),t.push(new THREE.Vector2((e.min.x+e.max.x)/2,(e.min.y+e.max.y)/2)),t}containsInBoundary(e,t,i){let n=!1;for(let i=0;i<t.length-1;i++)if(this.isOnSegment(e,t[i],t[i+1])){n=!0;break}if(n)return!i;for(var o=e.x,s=e.y,r=!1,a=0,l=t.length-1;a<t.length;l=a++){var h=t[a].x||t[a][0],d=t[a].y||t[a][1],c=t[l].x||t[l][0],u=t[l].y||t[l][1];d>s!=u>s&&o<(c-h)*(s-d)/(u-d)+h&&(r=!r)}return r}isOnSegment(e,t,i){if(e.x>Math.max(t.x,i.x)||e.x<Math.min(t.x,i.x))return!1;if(e.y>Math.max(t.y,i.y)||e.y<Math.min(t.y,i.y))return!1;if(t.x!=i.x){let n=(i.y-t.y)/(i.x-t.x),o=i.y-n*i.x;if(n*e.x+o==e.y)return!0}else if(e.x==t.x)return!0;return!1}isPointInside(e,t,i){!1!==i&&(i=!0);let{roomBoundary:n,roomInnerBoundary:o}=this.getCustomizedRoom(t);n=this.viewer3D.globalUnitUtil.revertTranslate(n,["x","y","z"]),o&&(o=this.viewer3D.globalUnitUtil.revertTranslate(o,["x","y","z"]));let s=[],r=CLOUD.ExtrudeBodyManager.getInstance(this.viewer3D.getViewer()).getBindedModelId(t);for(let e=0;e<n.length;e++){let t=new THREE.Vector3(n[e].x,n[e].y,0).clone().applyMatrix4(this.viewer3D.getViewer().getModelManager().getModel(r).transformMatrix.clone());s.push({x:t.x,y:t.y})}if(n=s,o&&o.length>0){let e=[];for(let t=0;t<o.length;t++){let i=[];for(let e=0;e<o[t].length;e++){let n=new THREE.Vector3(o[t][e].x,o[t][e].y,0).clone().applyMatrix4(this.viewer3D.getViewer().getModelManager().getModel(r).transformMatrix.clone());i.push({x:n.x,y:n.y})}e.push(i)}o=e}if(!this.containsInBoundary(e,n,i))return!1;if(o&&o.find((t=>this.containsInBoundary(e,t,i))))return!1;let a=Number(e.z.toFixed(10)),l=this.getRoomBoundingBoxById(t),h=Number(l.min.z.toFixed(10)),d=Number(l.max.z.toFixed(10));return i?a>h&&a<d:a>=h&&a<=d}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation").RoomConfig=function(){return{viewer:null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");let n=Object.freeze({Saved:"Saved",Cancelled:"Cancelled"});t.RoomEditorToolbarEvent=n,i.RoomEditorToolbarEvent=n}(),function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation");var o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Application.UI.Button");let s=e.Bimface.Plugins.SpatialRelation.RoomEditorToolbarEvent;class r{constructor(i){t.send("Bimface.Plugins.SpatialRelation","RoomEditorToolbar"),this.id="RoomEditorToolbar",this.viewer=i.viewer,this.roomId=i.roomId,this.databagId=i.viewer._data.databagId,this.eventManager=new e.Web.Lang.EventManager,P(this),this.initialize(),this.toolBarDom()}initialize(){const t=e.Bimface.Plugins.RoomEditing,i=new t.RoomEidtorConfig;i.viewer=this.viewer,i.roomId=this.roomId,i.roomEditorToolBar=this,this.roomEditor=new t.RoomEditor(i),this.roomEditor.onEnter(),this.registerRoomEditorEvents()}toolBarDom(){const t=this;let n=[];const o=i.create("div","bf-roomEditorToolbar");if(t.domElement=o,void 0===this.switchToolbar){var r=e.Bimface.UI.Toolbar.ToolbarConfig();r.className="bf-toolbar bf-toolbar-roomEditor",r.element=o,r.buttons=["RoomEditingDrag","RoomEditingAdd","RoomEditingDelete","RoomEditingHeight"],this.viewer.getDomElement().appendChild(o),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(r),n.push(this.switchToolbar)}let a=e.Bimface.UI.Control.ControlEvent,l=this.switchToolbar.getControls();this.uncheckOthers("Drag",l);let h=["Pick","Add","Delete","Height"];for(let e=0;e<l.length;e++){let i=l[e];i.addEventListener(a.Click,(function(){i.isChecked()?(t.roomEditor.activateEditor(h[e]),t.uncheckOthers(i.getId(),l)):i.toggleCheckedState()}))}const d=new e.Bimface.UI.Toolbar.ToolbarConfig;d.element=o,d.className="bf-toolbar bf-toolbar-roomEditor";let c=t.roomToolbar=new e.Bimface.UI.Toolbar.Toolbar(d);t.roomToolbar=c,n.push(c);const u=new e.Bimface.UI.Button.ButtonConfig;u.className="bf-save",u.title=BimfaceLanguage.bf_general_save;const g=new e.Bimface.UI.Button.SingleButton(u);g.setHtml(BimfaceLanguage.bf_general_save),g.addEventListener("Click",(function(){const e=t.roomEditor.save(),i={roomId:t.roomId,boundary:e.outerBoundary,height:e.height};t.eventManager.fireEvent(s.Saved,i),t.update()})),c.addControl(g);const p=new e.Bimface.UI.Button.ButtonConfig;p.className="bf-cancel",p.title=BimfaceLanguage.bf_general_cancel;const m=new e.Bimface.UI.Button.SingleButton(p);m.setHtml(BimfaceLanguage.bf_general_cancel),m.addEventListener("Click",(function(){t.eventManager.fireEvent(s.Cancelled),t.exit()})),c.addControl(m),this.viewer.getDomElement().appendChild(o),this.roomToolbar.hide(),this.switchToolbar.hide()}registerRoomEditorEvents(){let t=this;this.viewer.addEventListener("DeletionError",(function(){if(!t.deletionErrorTips){const i=new e.Bimface.UI.Tips.TipsConfig;i.element=t.viewer.getDomElement(),i.className="bf-tips bf-roomEditor-tips",i.timeOut=3e3,i.html=`<div><i class="icon-warning"></i>${BimfaceLanguage.bf_panel_roomEdit_insufficientNode}</div>`,t.deletionErrorTips=new e.Bimface.UI.Tips.Tips(i)}t.deletionErrorTips.show()}));let i=this.viewer.getDomElement();this.viewer.addEventListener("RoomEditorAddEnter",(function(){i.addClass("roomEditor-addtion")})),this.viewer.addEventListener("RoomEditorAddExit",(function(){i.removeClass("roomEditor-addtion")})),this.viewer.addEventListener("RoomEditorDeleteEnter",(function(){i.addClass("roomEditor-deletion")})),this.viewer.addEventListener("RoomEditorDeleteExit",(function(){i.removeClass("roomEditor-deletion")}))}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}show(){this.roomToolbar.show(),this.switchToolbar.show()}hide(){this.roomEditor.setBimfaceUIVisibility(!0),this.roomToolbar.hide(),this.switchToolbar.hide()}update(){if(!0!==this.roomEditor.checkIntersect())this.hide(),this.roomEditor.onExit();else{if(!this.intersectTips){const t=new e.Bimface.UI.Tips.TipsConfig;t.element=this.viewer.getDomElement(),t.className="bf-tips bf-roomEditor-tips",t.timeOut=3e3,t.html=`<div><i class="icon-warning"></i>${BimfaceLanguage.bf_panel_roomEdit_selfIntersection}</div>`,this.intersectTips=new e.Bimface.UI.Tips.Tips(t)}this.intersectTips.show()}}exit(){this.hide(),this.roomEditor.onExit(!0)}}n.RoomEditorToolbar=r,o.RoomEditorToolbar=r}(),ts=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SpatialRelation"),is=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms"),ns=function(){return{viewer:null,roomId:null,app:null}},ts.RoomEditorToolbarConfig=ns,is.RoomEditorToolbarConfig=ns,function(){e.Bimface.Data.StatisticsDataManager.getInstance();const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids");class n{constructor(t){this.console=new e.Web.Common.Console,this.validConfig(t)?(this.id="SolidToolbar",t.roomId=t.sectionId,t.floor=t.floorId,this._config=t,this._viewer=t.viewer,this._modelId=t.modelId,this._floorId=t.floorId,this._height=t.height,this._unit=t.unit,this._roomId=t.sectionId,this._controlId=t.controlId,this.eventManager=new e.Web.Lang.EventManager,this._defaultContextMenuDisplay=t.viewer._opt.enableToggleContextMenuDisplay,this.eventManager.addEvent(i.SolidToolbarEvent.Saved,(()=>requestAnimationFrame((()=>this._viewer.toggleContextMenuDisplay(this._defaultContextMenuDisplay))))),P(this)):this.console.warn("初始化参数错误")}validConfig(e){return!!e.viewer&&(!!e.floorId&&(!!e.name&&(!!e.sectionId&&!!e.conditions)))}setCamera(){this._viewer.getViewer().setHomeView(0),this._viewer.getViewer().setHomeView(1),this._viewer.setCameraType("OrthographicCamera"),this._viewer.getModels().map((e=>e.isolateComponentsById([void 0],"MakeOthersTranslucent"))),this._viewer.enableSnap(!0)}initialize(){if(this._initialized)return;const n=this;this.setCamera();const o=document.createElement("div","bf-solidToolbar");n.domElement=o;const s=e.Bimface.UI.Toolbar.ToolbarConfig();s.id="SolidToolbar",s.className="bf-toolbar bf-solidToolbar",s.element=o;this._viewer.getDomElement().appendChild(o),this.drawToolbar=new e.Bimface.UI.Toolbar.Toolbar(s),[].push(this.drawToolbar),this._viewer.getModel(this._modelId).getAreas((o=>{const s=o.find((e=>e.id==n._floorId));s&&(null==n._config.height&&(s.height?n._config.height=s.height:n._config.height="Millimeter"==n._viewer.getGlobalUnit()?3e3:3),n._config.elevation="Millimeter"==n._viewer.getGlobalUnit()?s.elevation/1e3:s.elevation),n.loadScripts().then((()=>{n.solidDrawTool=new e.Bimface.Interactions.Separation(n._config),n.solidDrawTool.addEventListener("DrawFinished",(()=>{n.destroyToolbar(),n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().solidToolbar=n,n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)})),n.solidDrawTool.addEventListener("EditCompleted",(()=>{n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)})),n._initialized=!0,n.getEventManager().fireEvent(i.SolidToolbarEvent.Initialized),n._viewer.toggleContextMenuDisplay(!1)}));const r=e.Bimface.UI.Button.ButtonConfig();r.className="bf-draw-rectangle gld-bimface gld-bf-nrectangle",r.title="绘制矩形";const a=new e.Bimface.UI.Button.ToggleButton(r);a.addEventListener("Click",(function(){a.isChecked()&&(n.solidDrawTool.type=0,h.setCheckedState(!1),n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.drawPolyLineTool&&n.solidDrawTool.drawPolyLineTool.exit(),n.solidDrawTool.drawRectangle())})),n.drawToolbar.addControl(a);const l=e.Bimface.UI.Button.ButtonConfig();l.className="bf-draw-polyline gld-bimface gld-bf-polygon",l.title="绘制多段线";const h=new e.Bimface.UI.Button.ToggleButton(l);h.addEventListener("Click",(function(){h.isChecked()&&(n.solidDrawTool.type=0,a.setCheckedState(!1),n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.drawRectangleTool&&(n.solidDrawTool.drawRectangleTool.exit(),delete n.solidDrawTool.drawRectangleTool),n.solidDrawTool.drawPolyLine())})),n.drawToolbar.addControl(h);const d=new e.Bimface.Application.UI.Button.DividerLine;n.drawToolbar.addControl(d);const c=t.create("label","bf-grid-container"),u=document.createElement("input");u.type="checkbox",u.className="bf-checkbox-input",u.checked="checked",c.appendChild(u);const g=document.createElement("span");g.className="grid-text",g.innerText="轴网",c.appendChild(g),c.addEventListener("change",(function(){u.checked?n._viewer.getModel(n._modelId).showAxisGridsByFloor(n._config.fileId,n._floorId):n._viewer.getModel(n._modelId).removeAllAxisGrids()})),n.drawToolbar.element.appendChild(c)}))}loadScripts(){if(n._scriptsLoaded)return Promise.resolve();const e=new Promise((e=>{$.loadThirdPartyByName("interactions",e)})),t=new Promise((e=>{$.loadThirdPartyByName("clipper",e)}));return new Promise((i=>{Promise.all([e,t]).then((()=>{n._scriptsLoaded=!0,i()}))}))}cancelDraw(){this.solidDrawTool.drawPolyLineTool&&this.solidDrawTool.drawPolyLineTool.exit(),this.solidDrawTool.drawRectangleTool&&this.solidDrawTool.drawRectangleTool.exit(),this._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),this._viewer.enableSnap(!1)}getToolbar(){return this}getSolidSeparation(){return this.solidDrawTool}edit(){if(this.setCamera(),!this.drawToolbar){const t=this._viewer.getModel(this._modelId).getRoomManager().getRoomById(this._roomId);if(!this.solidDrawTool){const n=this;return void this.loadScripts().then((()=>{n.solidDrawTool=new e.Bimface.Interactions.Separation(n._config),n.solidDrawTool.room=t,t.solidToolbar=n,n._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),n.solidDrawTool.edit(),n._initialized=!0,n.getEventManager().fireEvent(i.SolidToolbarEvent.Initialized),n._viewer.toggleContextMenuDisplay(!1),n.solidDrawTool.addEventListener("EditCompleted",(()=>{n._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),n.getSolid().updateSolidInfo(),n.getEventManager().fireEvent(i.SolidToolbarEvent.Saved,n.getSolid()._solidInfo)}))}))}this.solidDrawTool.room=t,t.solidToolbar=this}this._viewer.lockAxis(e.Bimface.Viewer.AxisOption.Z),this.solidDrawTool.edit()}cancelEdit(){const t=this._viewer.getModel(this._modelId).getRoomManager();t&&t.showRoomsById([this._roomId]),this._viewer.unlockAxis(e.Bimface.Viewer.AxisOption.Z),this.solidDrawTool.editPolygon&&this.solidDrawTool.editPolygon.exit(),this._viewer.enableSnap(!1)}hide(){this.drawToolbar.hide()}show(){this.drawToolbar.show()}destroyToolbar(){this.drawToolbar.destroy()}hideContent(){this.drawToolbar.hide(),this.solidDrawTool.hide()}showContent(){this.drawToolbar.show(),this.solidDrawTool.show()}exitSection(){this._viewer._sectionPlane&&this._viewer._sectionPlane.exit(),this.cancelDraw(),this.cancelEdit(),this._viewer.toggleContextMenuDisplay(this._defaultContextMenuDisplay)}getSolid(){return this.solidDrawTool.getRoom()}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getEventManager(){return this.eventManager}addEventListener(e,t){this.getEventManager().addEvent(e,t)}removeEventListener(e,t){this.getEventManager().removeEvent(e,t)}destroy(){this.exitSection(),this.drawToolbar=null,this.console=null,this._config=null,this._viewer=null,this.eventManager=null,this.domElement&&this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement)}}i.SolidToolbar=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids").SolidToolbarConfig=function(){return{controlId:null,viewer:null,modelId:null,floor:null,height:null,name:null,sectionId:null,fileId:null,unit:null,roomColor:null,frameColor:null,enableAxisGrids:!0,overlapType:"plus"}},os=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Solids"),ss=Object.freeze({Saved:"Saved",Deleted:"Deleted",Initialized:"Initialized"}),os.SolidToolbarEvent=ss,function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers"));i.MEPTopologyHelper=class{constructor(e){t.send("Bimface.Plugins.RevitHelpers","MEPTopologyHelper"),this.databagId=e.viewer._data.databagId,this.modelType=e.viewer._data.modelType,this.viewer=e.viewer,P(this)}_findNetworkById(t,i){var n,o,s=this;s._FILEID_CACHE!=s.fileId&&(s._API_CACHE=null),"integrateModel"==s.modelType?(n=`${g.resourceHost}/${s.databagId}/metadata/${s.fileId}/mepsystem.json`,o=`metadata/${s.fileId}/mepsystem.json`,s._FILEID_CACHE=s.fileId):(n=`${g.resourceHost}/${s.databagId}/metadata/mepsystem.json`,o="metadata/mepsystem.json"),s._API_CACHE?s._getNetwork(t,s._API_CACHE,(function(e){i(e)})):e.Web.Lang.Utility.HttpRequest.ajax({url:"Local"!=s.viewer._data.dataEnvType?e.Web.Lang.Utility.HttpRequest.getUrl({url:n,path:o,APIHost:s.viewer._opt.APIHost,loadMode:s.viewer._data.loadMode,fileId:s.viewer._data.modelId,viewToken:s.viewer._data.viewToken,modelType:s.viewer._data.modelType}):n,success:function(e){var n=JSON.parse(e);s._API_CACHE=n,s._getNetwork(t,n,(function(e){i(e)}))}})}_getNetwork(e,t,i){var n=this;n._NETWORK_LENGTH=0,t.systems.map((function(o,s){o.network[e]&&(n._NETWORK_LENGTH++,i(o.network)),s==t.systems.length-1&&0==n._NETWORK_LENGTH&&console.log("此ID不存在于Network中")}))}_transform(e){let t=[];for(let i in e)/^__STEP/.test(i)||(t[t.length]={type:i,id:e[i]});return t}_walk(e,t,i,n){let o="up"===i?"flowFrom":"flowInto",s=[t];for(;s.length;){let t=s.pop(),i=e[t];if(!i)continue;i.id=t,n(i,e);let r=i[o];r&&[].push.apply(s,[...r].reverse())}}_BFSwalk(e,t,i,n){let o="up"===i?"flowFrom":"flowInto",s=[t];for(;0!==s.length;){let t=s.shift(),i=e[t];i&&(i.id=t,n(i,i[o],e),[].push.apply(s,i[o]))}}_deduplicate(e){return e.map((function(e){return e.reduce((function(e,t,i){return i%2==0?-1===e.indexOf(t)&&e.push(t):/\d+/.test(e[e.length-1])||e.push(t),e}),[])}))}_formatToObj(e){var t,i=this,n={};return e.forEach((function(e){e.forEach((function(e,o){if(o%2==0)t=e,n[e]||(n[e]=[]);else{let o;o="integrateModel"==i.modelType?`${i.fileId}.${e}`:e,-1===n[t].indexOf(o)&&n[t].push(o)}}))})),n}_formatNewData(e,t){let i;for(let t in e){if(-1!=Object.keys(e[t]).indexOf("flowFrom")){i=e;break}{let n=[],o=[];e[t].neighbours.map((e=>{"bidirectional"!==e.direction&&("in"===e.direction?n.push(e.id):o.push(e.id))})),Object.assign(e[t],{flowFrom:n},{flowInto:o}),i=e}}return i}getDownstreamComponentsById(e,t){const i=this;"integrateModel"==i.modelType&&(i.fileId=e.split(".")[0],e=e.split(".")[1]),i._findNetworkById(e,(n=>{if(!n)return t();let o=i._formatNewData(n),s={};i._BFSwalk(o,e,"down",(function(t){t.id!==e&&("integrateModel"==i.modelType&&(t.id=`${i.fileId}.${t.id}`),s[t.type]?s[t.type].push(t.id):s[t.type]=[t.id])})),t(i._transform(s))}))}getConnectedComponentsById(e,t){var i=this;"integrateModel"==i.modelType&&(i.fileId=e.split(".")[0],e=e.split(".")[1]),i._findNetworkById(e,(n=>{if(!n)return t();let o=i._formatNewData(n),s={up:{routes:[[]]},down:{routes:[[]]}};["up","down"].forEach((t=>this._walk(o,e,t,(function(i,n){let o=s[t].routes,r=o.length-1;if("末端"===o[r].slice(-2,-1)[0]){if("末端"===i.type)return o[o.length]=o[r].slice(0,-1).concat(i.id);{let e=i["up"===t?"flowInto":"flowFrom"][0];o[o.length]=o[r].slice(0,o[r].indexOf(e)+1),r++}}e!=i.id&&(o[r].push(i.type),o[r].push(i.id))}))));let r=i._deduplicate(s.up.routes),a=i._deduplicate(s.down.routes),l=this._transform(i._formatToObj(r)),h=this._transform(i._formatToObj(a));t({up:l,down:h})}))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers").MEPTopologyHelperConfig=function(){return{viewer:null}},function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.RevitHelpers");class n{constructor(e,i){t.send("Bimface.Plugins.RevitHelpers","DrawingView"),this.viewer3D=e,this.drawingViews=i,this.activeViewId=null,this.activeDrawingView=null,this.viewPoint=null,this.planTranslation=null,this.linkFileTranslation=new THREE.Vector3}activeViewById(e){this.activeViewId=e;for(const e of this.drawingViews)if(e.id==this.activeViewId){this.activeDrawingView=e;let t=e.viewPoint.origin;this.coordViewPoint=new THREE.Vector3(t[0],t[1],t[2])}}formatViewMatrix(e){let t=this.activeDrawingView.viewPoint.rightDirection,i=this.activeDrawingView.viewPoint.upDirection,n=new THREE.Vector3(t[0],t[1],t[2]),o=new THREE.Vector3(i[0],i[1],i[2]);e=null==e?new THREE.Vector3:e;let s=new THREE.Matrix4;return s.makeBasis(n,o,e),s}update(e,t){this.makeTranslation(e,t),"FloorPlan"==this.activeDrawingView.viewType?this.rotateFloorPlan(e):this.rotateElevation(e)}makeTranslation(e,t){let i=this.activeDrawingView.viewPoint.viewDirection,n=new THREE.Vector3(i[0],i[1],i[2]).multiplyScalar(t),o=this.planTranslation,s=this.linkFileTranslation;e.translateX(o.x+s.x+n.x),e.translateY(o.y+s.y+n.y),e.translateZ(o.z+s.z+n.z)}rotateFloorPlan(e){let t=this.activeDrawingView.viewPoint.upDirection,i=new THREE.Vector3(t[0],t[1],t[2]),n=new THREE.Vector3(0,1,0).angleTo(i);new THREE.Vector3(0,1,0).cross(i).length()>0&&(n=-n),e.rotateZ(n),e.updateMatrixWorld()}rotateElevation(e){let t=this.activeDrawingView.viewPoint.viewDirection,i=new THREE.Vector3(t[0],t[1],t[2]),n=i.angleTo(new THREE.Vector3(0,-1,0));i.cross(new THREE.Vector3(0,-1,0)).z>0&&(n=-n),e.rotateX(Math.PI/2),e.rotateY(n),e.updateMatrixWorld()}getOutline3D(){let e=this.activeDrawingView.outline,t=this.activeDrawingView.viewPoint.scale,i=this.activeDrawingView.elevation,n=new THREE.Vector3(e[0]*t,e[1]*t,0),o=new THREE.Vector3(e[0]*t,e[3]*t,0),s=new THREE.Vector3(e[2]*t,e[3]*t,0),r=new THREE.Vector3(e[2]*t,e[1]*t,0),a=this.formatViewMatrix(),l=n.applyMatrix4(a),h=o.applyMatrix4(a),d=s.applyMatrix4(a),c=r.applyMatrix4(a);this.planTranslation=l.clone().add(d).multiplyScalar(.5),this.planTranslation.add(this.coordViewPoint);let u=h.clone().sub(l).length(),g=c.clone().sub(l).length(),p=new THREE.Vector3(-g/2,-u/2,i),m=new THREE.Vector3(g/2,u/2,i);return new THREE.Box3(p,m)}setLinkFileTranslation(e){this.linkFileTranslation.x=e.elements[12],this.linkFileTranslation.y=e.elements[13],this.linkFileTranslation.z=e.elements[14]}}n.toObject=function(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n instanceof Array&&(t[i]={x:n[0],y:n[1],z:n[2]})}return t},i.DrawingView=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Snap").SnapConfig=function(){return{id:null,color:new e.Web.Graphics.Color(249,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),objectColor:new e.Web.Graphics.Color(17,218,183,.9),width:3,radius:25,viewer:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Snap"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){this.viewer=t.viewer,this.maxPointsNum=1;var n=new e.Web.Graphics.Color(17,218,183,.2);let o=new e.Web.Graphics.Color(17,218,183,1);var s=i.createNS("circle","bf-snap-handle");s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();const r=i.createNS("rect","bf-snap-handle");r.setAttribute("width",14),r.setAttribute("height",14),r.setAttribute("fill","none"),r.setAttribute("stroke",o.getRGB()),r.setAttribute("stroke-width",2);const a=i.createNS("path","bf-snap-handle");a.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),a.setAttribute("fill","none"),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",2);const l=i.createNS("line","bf-snap-handle");l.setAttribute("x1",0),l.setAttribute("y1",0),l.setAttribute("x2",14),l.setAttribute("y2",14),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("line","bf-snap-handle");h.setAttribute("x1",14),h.setAttribute("y1",0),h.setAttribute("x2",0),h.setAttribute("y2",14),h.setAttribute("stroke",n.getRGB()),h.setAttribute("stroke-width",2);var d=i.createNS("line","bf-snap-line");d.style.strokeWidth=2,d.style.stroke=n.getRGB();var c=i.createNS("polygon","bf-snap-rect");c.setAttribute("fill",n.getRGBA()),c.setAttribute("stroke",n.getRGB()),c.setAttribute("stroke-width",1),this.hoverLine=d,this.hoverPoint=s,this.hoverEndPoint=r,this.hoverMidPoint=a,this.hoverIntersectionPointA=l,this.hoverIntersectionPointB=h,this.hoverPanel=c,this.hoverPanelSize={width:20,height:20}};n.prototype=Object.assign(n.prototype,{stretchOnDirection:function(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){var t=this.hoverLine,i=this.hoverPoint;const n=this.hoverEndPoint,o=this.hoverMidPoint,s=this.hoverIntersectionPointA,r=this.hoverIntersectionPointB,a=e.hoverPosition&&e.hoverPosition.x,l=e.hoverPosition&&e.hoverPosition.y;var h=this.hoverPanel,d=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":i.setAttribute("cx",e.hoverPosition.x),i.setAttribute("cy",e.hoverPosition.y),e.svg.appendChild(i);break;case"EndPoint":n.setAttribute("x",a-7),n.setAttribute("y",l-7),e.svg.appendChild(n);break;case"MidPoint":o.setAttribute("d",`M ${a} ${l-7} L ${a+8} ${l+8} L ${a-8} ${l+8} L ${a} ${l-7}`),e.svg.appendChild(o);break;case"IntersectionPoint":s.setAttribute("x1",a-7),s.setAttribute("y1",l-7),s.setAttribute("x2",a+7),s.setAttribute("y2",l+7),e.svg.appendChild(s),r.setAttribute("x1",a+7),r.setAttribute("y1",l-7),r.setAttribute("x2",a-7),r.setAttribute("y2",l+7),e.svg.appendChild(r);break;case"Line":t.setAttribute("x1",e.lineStartPoint.x),t.setAttribute("y1",e.lineStartPoint.y),t.setAttribute("x2",e.lineEndPoint.x),t.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(t);break;case"Panel":var c=e.clientPts,u=c[0].distanceTo(c[1]),g=c[0].distanceTo(c[3]),p=u/d.width,m=g/d.height;if(1!=p){var f=this.stretchOnDirection(c[0],c[1],d.width),w=this.stretchOnDirection(c[2],c[3],d.width);c=f.concat(w)}if(1!=m){f=this.stretchOnDirection(c[0],c[3],d.height),w=this.stretchOnDirection(c[1],c[2],d.height);c=[f[0],w[0],w[1],f[1]]}for(var y="",v=0;v<c.length;v++)y+=c[v].x+",",y+=c[v].y+" ";h.setAttribute("points",y),e.svg.appendChild(h)}}}),t.SnapItem=n}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Snap"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=[],s=null,r=null,a=function(t){var n=t.viewer,o=this;this.snapMode=t.snapMode,o.isOpen=!1,this._p1=new THREE.Vector3,this._p2=new THREE.Vector3;var s=new e.Web.Lang.EventManager,r=i.create("div","bf-snap-conext");this.context={rootDomElement:r},this._opt=t,this.getEventManager=function(){return s},P(this),o.init(t),n.addEventListener("Rendered",(function(){o.isOpen&&o.update()}))};a.prototype={init:function(t){var n=this,o=n.context,s=n._opt.viewer;n.isOpen=!0,s.getDomElement().appendChild(o.rootDomElement),s.getModels().forEach((e=>{e.setSelectedComponentsById()}));var r=i.createNS("svg","bf-snap-svg");o.rootDomElement.innerHTML="",o.rootDomElement.appendChild(r),o.svg=r;var a=new e.Bimface.Plugins.Snap.SnapItem(t);n.snapItem=a,s.render()},snapByPoint:function(e){n=e.pickPoint?e.pickPoint:null;let t=this.snapMode?this.snapMode.getSnap3DList():["line","face","endpoint","midpoint","intersection"];if(e.pointType&&t.includes({EndPoint:"endpoint",MidPoint:"midpoint",IntersectionPoint:"intersection"}[e.pointType])?s=e.pointType:e.pickPlane&&t.includes("face")?(s="Panel",r=e.normal):e.pickLine&&t.includes("line")?(s="Line",o=e.pickLine):s=null,!this.isNeedSnap(e))return this.context.pickPoint=n,this.context.hoverPosition=n,void(this.context.hoverObjectType=s);this.update()},isNeedSnap:function(e){if(!this.snapMode)return!0;let t=this.snapMode.getSnap3DList(),i="face",n="line",o="endpoint",s="midpoint",r="intersection",a=!1,l=!1,h=!1,d=!1;e.pointType&&(l=t.includes(o)||t.includes(s)||t.includes(r)),e.pickPlane&&(h=t.includes(i)),e.pickLine&&(d=t.includes(n)),a=l||h||d;let c=this.snapMode.getSnapCondition(),u=this._opt.viewer.getViewer().getUserdataByUserId(e.userId),g=this.isMatchConditions(u,c.objectData),p=!0,m=!0;if("ViewerGIS"==this._opt.viewer.getViewerType())if(e.modelId){let t=this._opt.viewer.getModel(e.modelId)._layer.id;c.layerIds&&c.layerIds.length>0&&c.layerIds.indexOf(t)<0&&(p=!1)}else p=!1;"Viewer3D"==this._opt.viewer.getViewerType()&&c.modelIds&&c.modelIds.length>0&&c.modelIds.indexOf(e.modelId)<0&&(m=!1);let f=a&&g&&p&&m;return f||this.reset(),f},isMatchConditions:function(e,t){if(!e||!t)return!0;for(var i=!0,n=0,o=t.length;n<o;n++){var s=t[n];for(var r in s)if(e[r]!==s[r]){i=!1;break}if(i)break;n<t.length-1&&(i=!0)}return i},update:function(){var e=this.context,t=this._opt.viewer,i=t.getDomElement(),a=i.getBoundingClientRect(),l=t.getViewer(),h=[],d=[];if(this.context.svg.innerHTML="",n?(e.pickPoint=n,e.hoverPosition=l.worldToCanvas(n),e.hoverPositionDS=l.getScene().worldToDrawing(n)):e.hoverPosition=null,e.hoverObjectType=s,"Line"==s&&2==o.length){e.lineStartPoint=l.worldToCanvas(o[0]),e.lineEndPoint=l.worldToCanvas(o[1]);var c=new THREE.Vector2(e.lineStartPoint.x,e.lineStartPoint.y),u=new THREE.Vector2(e.lineEndPoint.x,e.lineEndPoint.y),g=new THREE.Box2;g.min.set(i.clientLeft,i.clientTop),g.max.set(g.min.x+i.clientWidth,g.min.y+i.clientHeight);var p=!g.containsPoint(c),m=!g.containsPoint(u),f={start:c,end:u},w=y.CameraUtil.lineIntersectWithRect(f,g);if(p&&m)2==w.length&&(e.lineStartPoint=w[0],e.lineEndPoint=w[1]);else if(p||m)for(var v=new THREE.Vector2(e.hoverPosition.x,e.hoverPosition.y),b=p?u.clone():c.clone(),E=b.clone().sub(v).normalize(),M=0;M<w.length;M++){if(b.clone().sub(w[M]).normalize().dot(E)>0){e.lineStartPoint=b,e.lineEndPoint=w[M];break}}}if("Panel"==e.hoverObjectType){e.normal=l.getScene().worldToDrawing(r),e.normal.normalize();var C=l.cameraControl,x=new THREE.Plane;x.setFromNormalAndCoplanarPoint(e.normal,e.hoverPositionDS);var T=new THREE.Vector2(e.hoverPosition.x-10,e.hoverPosition.y-10),P=new THREE.Vector2(e.hoverPosition.x+10,e.hoverPosition.y-10),I=e.hoverPositionDS,S=C.getRaycaster(T.x,T.y);if(this._p1=S.ray.intersectPlane(x,this._p1),S=C.getRaycaster(P.x,P.y),this._p2=S.ray.intersectPlane(x,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var B=new THREE.Vector3(1,0,0),_=new THREE.Vector3(0,1,0),L=new THREE.Vector3(0,0,1),D=Math.abs(e.normal.clone().dot(B))<=.0025,A=Math.abs(e.normal.clone().dot(L))<=.0025;if(D&&A)var V=B.clone(),R=L.clone();else V=_.clone().cross(e.normal).normalize(),R=e.normal.clone().cross(V).normalize();var O=this._p1.distanceTo(this._p2)/2,k=V.clone().multiplyScalar(O),H=R.clone().multiplyScalar(O),U=I.clone().sub(k).add(H),N=I.clone().add(k).add(H),G=I.clone().sub(k).sub(H),j=I.clone().add(k).sub(H),z=[];z.push(U,N,j,G);for(var F=[],W=C.getContainerDimensions(),$=0;$<z.length;$++){var X=y.CameraUtil.drawingToCanvas(C.camera,z[$],W.width,W.height);F.push(new THREE.Vector3(X.x,X.y,0))}e.clientPts=F}for(M=0;M<h.length-1;M++){var Y=l.worldPointsToClient(h[M],h[M+1]);if(Y){var Z={x:Y.start.x-a.left,y:Y.start.y-a.top};d.push(Z)}}e.clientPoints=d,this.snapItem.draw(e)},reset:function(){s=null,this.context.svg.innerHTML=""},destroy:function(){var e=this.context.rootDomElement,t=this;t.reset(),e.remove(),t.snapItem=null,t.isOpen=!1}},t.Snap=a}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough").WalkthroughManagerConfig=function(){return{viewer:null}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Walkthrough");i.WalkthroughManager=class{constructor(e){var t=e.viewer;t?"Viewer3D"===t.getViewerType()||"ViewerGIS"===t.getViewerType()?(P(this),this._viewer=t,this._walkthroughMap={}):console.log("ViewerType is not supported."):console.log("viewer must not be empty.")}addWalkthrough(t,i){var n=e.Web.Lang.Utility.UUID.createUUID(),o={id:n,walkthrough:i};return i._walkthrough.setName(t),this._walkthroughMap[n]=o,n}removeWalkthrough(e){"[object String]"===Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"===Object.prototype.toString.call(e)&&e.forEach((e=>{delete this._walkthroughMap[e]}))}setWalkthroughList(t){if("[object Object]"===Object.prototype.toString.call(t)){var i=t.coordinate;t.data.forEach((t=>{var n=new e.Bimface.Plugins.Walkthrough.WalkthroughConfig;n.viewer=this._viewer;var o=new e.Bimface.Plugins.Walkthrough.Walkthrough(n),s=t.coordinateSystem||i;"world"===s&&t.keyFrames.forEach((e=>{e.coordinateSystem=s})),o.setKeyFrames(t.keyFrames),o.setWalkthroughTime(t.time),o._walkthrough.setName(t.name),this._walkthroughMap[t.id]={id:t.id,walkthrough:o}}))}}getWalkthroughList(){var e={data:[],version:1};for(var t in this._walkthroughMap){var i={id:t},n=this._walkthroughMap[t].walkthrough;i.keyFrames=n.getKeyFrames(),i.keyFrames.forEach((e=>{delete e.coordinateSystem})),i.name=n._walkthrough.getName(),i.time=n._walkthrough.walkthroughTime,i.coordinateSystem="world",e.data.push(i)}return e}exportVideo(e,i){t.send("Bimface.Plugins.Walkthrough.WalkthroughManager","exportVideo");const n=this,o=this._walkthroughMap[e],s=this._viewer.getViewer().getRenderer().domElement;let r=document.createElement("canvas");r.width=s.width,r.height=s.height;let a=r.getContext("2d"),l=null==this._viewer._opt.backgroundColor.direction?this._viewer._opt.backgroundColorDirection:this._viewer._opt.backgroundColor.direction;0==l&&(l=2*Math.PI);const h=(e,t,i)=>{let n=2*Math.PI,o=i;for(;o<-Math.PI;)o+=n;for(;o>Math.PI;)o-=n;let s,r=Math.atan2(t,e),a=Math.tan(o);s=o>-r&&o<=r?1:o>r&&o<=Math.PI-r?2:o>Math.PI-r||o<=-(Math.PI-r)?3:4;let l={x:e/2,y:t/2},h=e/2,d=t/2;switch(s){case 1:l.x=e,l.y=d-e/2*a;break;case 2:l.x=h+t/(2*a),l.y=0;break;case 3:l.x=0,l.y=d+e/2*a;break;case 4:l.x=h-t/(2*a),l.y=t}return{x:l.x,y:l.y,region:s}},d=(e=>{const t=1.5*Math.PI-e;return{theta:t,revTheta:t+Math.PI}})(l);let c=h(r.width,r.height,d.theta),u=h(r.width,r.height,d.revTheta);Math.abs(c.x-u.x)<.01&&(c.x=0,u.x=0),Math.abs(c.xy-u.y)<.01&&(c.y=0,u.y=0);const g=a.createLinearGradient(c.x,c.y,u.x,u.y);o.walkthrough.stop(),o.walkthrough.play(),o.walkthrough.setDisableAnimation(!0);const p=this._viewer._opt.backgroundColor.colors||this._viewer._opt.backgroundColor,m=()=>{a&&(a.clearRect(0,0,r.width,r.height),p.map((e=>{const t=`#${(e.color||e).red.toString(16).padStart(2,"0")}${(e.color||e).green.toString(16).padStart(2,"0")}${(e.color||e).blue.toString(16).padStart(2,"0")}`,i=e.stop?parseInt(e.stop.split("%")[0])/100:0;g.addColorStop(i,t)})),a.fillStyle=g,a.fillRect(0,0,r.width,r.height),a.drawImage(s,0,0),requestAnimationFrame(m))};requestAnimationFrame(m);const f=r.captureStream();this.mediaRecorder=new MediaRecorder(f,{videoBitsPerSecond:85e5,mimeType:"video/webm; codecs=h264"});const w=[];this.mediaRecorder.ondataavailable=e=>{w.push(e.data)},this.mediaRecorder.onstop=()=>{const e=new Blob(w,{type:"video/webm"});i&&i(e),r=null,a=null,n._viewer.render()},this.mediaRecorder.start();const y=o.walkthrough._stopCallback;o.walkthrough.stopCallback((()=>{n.mediaRecorder&&"inactive"!=n.mediaRecorder.state&&(n.mediaRecorder.stop(),delete n.mediaRecorder),y&&y(),o.walkthrough.setDisableAnimation(!1)}))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").NorthArrowConfig=function(){return{domElement:null,viewer:null,right:10,top:10}};class rs{constructor(e,t,i){this.element=e,this.northArrowElement=t,this.textElement=e.lastElementChild,this._camera=i,this._rotate=0,this._minRadius=4,this._maxRadius=48,this.init()}init(){let e,t,i,n,o;this.isDragging=!1,this.events={mouseout:()=>{this.isDragging||this.element.firstElementChild.setAttribute("filter","")},mousedown:i=>{this.isDragging=!0,e=i.offsetX-50,t=i.offsetY-60,o=this._camera.getYawPitch().pitch,this.element.setAttribute("class","bf-northarrow-yawactive")},mouseover:function(){this.firstElementChild.setAttribute("filter","url(#bf-northarrow-dropshadow)")}};for(let e in this.events)this.element.addEventListener(e,this.events[e].bind(this.element));const s=()=>{this.isDragging=!1,this.element.firstElementChild.setAttribute("filter",""),this.element.setAttribute("class","bf-northarrow-yaw")},r=(i,n)=>{let s=i-e,r=n-t,a=Math.atan(n/i),l=Math.atan(t/e),h=180*Math.abs(a-l)/Math.PI;i>0&&i>Math.abs(n)&&e>0&&e>Math.abs(t)?r>0?this._rotate+=h:this._rotate-=h:i<0&&i<-Math.abs(n)&&e<0&&e<-Math.abs(t)?r>0?this._rotate-=h:this._rotate+=h:(a=Math.atan(i/n),l=Math.atan(e/t),h=180*Math.abs(a-l)/Math.PI,n>0&&t>0?s>0?this._rotate-=h:this._rotate+=h:s>0?this._rotate+=h:this._rotate-=h),this.element.setAttribute("transform",`rotate(${this._rotate}, 0, 0)`);let d=this._rotate*Math.PI/180;this._camera.setCameraFromYawPitch({yaw:d,pitch:o,target:!0},!0),e=i,t=n};this.northArrowEvents={mousemove:e=>{this.isDragging&&(i=e.offsetX-50,n=e.offsetY-60,r(i,n))},mouseup:e=>{this.isDragging&&s()}};for(let e in this.northArrowEvents)this.northArrowElement.addEventListener(e,this.northArrowEvents[e]);this.northArrowParentEvents={mousemove:e=>{this.isDragging&&(i=e.offsetX-50-this.northArrowElement.offsetLeft,n=e.offsetY-60-this.northArrowElement.offsetTop,r(i,n))},mouseup:e=>{this.isDragging&&s()}};for(let e in this.northArrowParentEvents)this.northArrowElement.parentElement.addEventListener(e,this.northArrowParentEvents[e]);this.textEvents={dblclick:e=>{o=this._camera.getYawPitch().pitch,this._camera.setCameraFromYawPitch({yaw:0,pitch:o,target:!0},!1)}};for(let e in this.textEvents)this.textElement.addEventListener(e,this.textEvents[e])}update(){if(this.isDragging)return;let{yaw:e}=this._camera.getYawPitch();this._rotate=180*e/Math.PI,this.element.setAttribute("transform",`rotate(${this._rotate}, 0, 0)`)}destroy(){if(this.events)for(let e in this.events)this.element.removeEventListener(e,this.events[e]);if(this.northArrowEvents)for(let e in this.northArrowEvents)this.northArrowElement.removeEventListener(e,this.northArrowEvents[e]);if(this.northArrowParentEvents)for(let e in this.northArrowParentEvents)this.northArrowElement.parentElement.removeEventListener(e,this.northArrowParentEvents[e]);if(this.textEvents)for(let e in this.textEvents)this.textElement.removeEventListener(e,this.textEvents[e])}}class as{constructor(e,t){this.elements=e,this._camera=t,this.minPitch=-Math.PI/2,this.maxPitch=Math.PI/2,this.init()}init(){const e=this._camera;let t,i,n=this,o=!1,s=!1;this.events={mousedown:function(){o=!0;let r=e.getYawPitch();i=r.yaw,t=r.pitch;let a=Math.PI/1e3;const l=()=>{if(t=-t,t>n.maxPitch&&(t=n.maxPitch),t<n.minPitch&&(t=n.minPitch),t>n.minPitch&&t-a>n.minPitch&&"bf-northarrow-pitchdown"===this.className.baseVal)t-=a,s=!0;else{if(!(t<n.maxPitch&&t+a<n.maxPitch&&"bf-northarrow-pitchup"===this.className.baseVal))return;t+=a,s=!1}t=-t,e.setCameraFromYawPitch({yaw:i,pitch:t,target:!0,isDownDirection:s},!0),o&&requestAnimationFrame(l)};l()},mouseup:()=>{o=!1},mouseover:function(){this.firstElementChild.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.firstElementChild.setAttribute("filter",""),o=!1},dblclick:function(){if("bf-northarrow-pitchup"===this.className.baseVal){let o=e.getYawPitch();i=o.yaw,t=o.pitch;let r=Math.PI/200;const a=()=>{t=-t,t>n.maxPitch&&(t=n.maxPitch),t<n.minPitch&&(t=n.minPitch),t<n.maxPitch&&t+r<n.maxPitch&&(t+=r,s=!1,t=-t,e.setCameraFromYawPitch({yaw:i,pitch:t,target:!0,isDownDirection:s},!0),requestAnimationFrame(a))};a()}}};for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}class ls{constructor(e,t){this.elements=e,this._camera=t,this.init()}init(){const e=this._camera;let t=!1;this.events={mousedown:function(){t=!0;const i=()=>{switch(/bf-northarrow-pan(.*)/.exec(this.className.baseVal)[1]){case"up":e.panInDirection(!0);break;case"down":e.panInDirection(!1);break;case"left":e.panInHorizontal(!0);break;case"right":e.panInHorizontal(!1)}t&&requestAnimationFrame(i)};i()},mouseup:()=>{t=!1},mouseover:function(){this.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.setAttribute("filter",""),t=!1}};for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}class hs{constructor(e,t){this.elements=e,this._camera=t,this.init()}init(){const e=this._camera;let t=!1;this.events={mousedown:function(){t=!0;const i=()=>{"bf-northarrow-zoomin"===this.className.baseVal?e.zoomIn():e.zoomOut(),t&&requestAnimationFrame(i)};i()},mouseup:()=>{t=!1}},this.events.mouseout=this.events.mouseup;for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}!function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.NorthArrow=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-northarrow");n.style.top=`${e.top}px`,n.style.right=`${e.right}px`,t.appendChild(n),this.domElement=n,this._camera=e.viewer._camera,this.init(),P(this)}init(){this.drawElements((()=>{this.addDomElementEvents(),this.northArrowYaw=new rs(this.elements.yaw,this.domElement,this._camera),this.northArrowPitch=new as({pitchUp:this.elements.pitchUp,pitchDown:this.elements.pitchDown},this._camera),this.northArrowZoom=new hs({zoomIn:this.elements.zoomIn,zoomOut:this.elements.zoomOut},this._camera),this.northArrowPan=new ls({panUp:this.elements.panUp,panDown:this.elements.panDown,panLeft:this.elements.panLeft,panRight:this.elements.panRight},this._camera),this.addRenderCallback()}))}drawElements(e){this.domElement.innerHTML='\n <svg height="180" width="100" class="bf-northarrow-svg" onselectstart="return false;">\n <defs>\n <filter id="bf-northarrow-dropshadow" x="-10" y="-10" width="100" height="100">\n <feDropShadow dx="0" dy="0" stdDeviation="0" \n flood-color="cyan"/>\n </filter>\n </defs>\n \n <g class="bf-northarrow-pitchup" transform="translate(50, 12)" width="500" height="100">\n <path d="M-15,0 A50,50 0 0,1 15,0 A3,3 0 0,1 14.5,8 A42,42 0 0,0 -14.5,8 A3,3 0 0,1 -15,0 Z" shape-rendering="geometricPrecision" />\n <path d="M-4,3 L0,-1 4,3" shape-rendering="geometricPrecision" />\n </g>\n\n <g transform="translate(50, 60)">\n <g class="bf-northarrow-yaw">\n <path d="M39,0 A39,39 0 0,0 -39,0 L-29,0 A29,29 0 0,1 29,0 L39,0 A39,39 0 0,1 0,39 L0,29 A29,29 0 0,0 29,0 L39,0 M-39,0 A39,39 0 0,0 0,39 L0,29 A29,29 0 0,1 -29,0 L-39,0 Z" shape-rendering="geometricPrecision" />\n <g transform="translate(-40, -40)">\n <path />\n <path d="M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z M40,1 C18.4608948,1 1,18.4608948 1,40 C1,61.5391052 18.4608948,79 40,79 C61.5391052,79 79,61.5391052 79,40 C79,18.4608948 61.5391052,1 40,1 Z" shape-rendering="geometricPrecision" />\n <path d="M40,11 C56.0162577,11 69,23.9837423 69,40 C69,56.0162577 56.0162577,69 40,69 C23.9837423,69 11,56.0162577 11,40 C11,23.9837423 23.9837423,11 40,11 Z M40,12 C24.536027,12 12,24.536027 12,40 C12,55.463973 24.536027,68 40,68 C55.463973,68 68,55.463973 68,40 C68,24.536027 55.463973,12 40,12 Z" shape-rendering="geometricPrecision" />\n <rect x="1" y="40" width="10" height="1" />\n <rect x="69" y="40" width="10" height="1" />\n <rect x="39" y="69" width="1" height="10" />\n <path />\n </g>\n <text x="0" y="-30">N</text>\n </g>\n </g>\n\n <g class="bf-northarrow-pitchdown" transform="translate(50, 108)">\n <path d="M-15,0 A50,50 0 0,0 15,0 A3,3 0 0,0 14.5,-8 A42,42 0 0,1 -14.5,-8 A3,3 0 0,0 -15,0 Z" shape-rendering="geometricPrecision" />\n <path d="M-4,-3 L0,1 4,-3" shape-rendering="geometricPrecision" />\n </g>\n\n <g transform="translate(50, 60)">\n <g class="bf-northarrow-panup" transform="translate(-7, -24)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-pandown" transform="translate(-7, 14) rotate(180, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-panleft" transform="translate(-24, -5) rotate(-90, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-panright" transform="translate(10, -5) rotate(90, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n\n </g>\n\n <g transform="translate(50, 118)">\n <g transform="translate(-13, 0)">\n <rect id="Rectangle" fill="#2A313B" opacity="0.78" x="0" y="0" width="26" height="53" />\n <path d="M26,0 L26,53 L0,53 L0,0 L26,0 Z M25,1 L1,1 L1,52 L25,52 L25,1 Z" fill="#969FAE" fill-rule="nonzero" />\n <rect fill="#969FAE" x="3" y="26" width="20" height="1" />\n </g>\n <g class="bf-northarrow-zoomin">\n <path d="M-13,0 L13,0 13,26 -13,26 Z" />\n <polygon points="5 5 5 0 7 0 7 5 12 5 12 7 7 7 7 12 5 12 5 7 0 7 0 5" transform="translate(-6, 7)" />\n </g>\n <g class="bf-northarrow-zoomout">\n <path d="M-13,26 L13,26 13,52 -13,52 Z" />\n <rect x="0" y="0" width="12" height="2" transform="translate(-6, 39)" />\n </g>\n </g>\n </svg>\n ',this.elements={},["pitchUp","pitchDown","yaw","panUp","panDown","panLeft","panRight","zoomIn","zoomOut"].forEach((e=>{const t=this.domElement.querySelector(`.bf-northarrow-${e.toLowerCase()}`);this.elements[e]=t})),e()}addDomElementEvents(){this.domElementEvents={mouseover:()=>{this.elements.pitchUp.style.opacity=1,this.elements.pitchDown.style.opacity=1},mouseout:()=>{this.elements.pitchUp.style.opacity=0,this.elements.pitchDown.style.opacity=0},mousedown:e=>(e.stopPropagation(),!1)},this.domElementEvents.mousemove=this.domElementEvents.mouseup=this.domElementEvents.mousedown,this.domElementEvents.mouseout();for(let e in this.domElementEvents)this.domElement.addEventListener(e,this.domElementEvents[e])}addRenderCallback(){this.renderCallback=()=>{this.northArrowYaw&&this.northArrowYaw.update()},this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){if(this.domElement&&this.domElementEvents)for(let e in this.domElementEvents)this.domElement.removeEventListener(e,this.domElementEvents[e]);this.northArrowYaw&&this.northArrowYaw.destroy(),this.northArrowPitch&&this.northArrowPitch.destroy(),this.northArrowPan&&this.northArrowPan.destroy(),this.northArrowZoom&&this.northArrowZoom.destroy(),this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}setLimitPitch(e=null,t=null){this.northArrowPitch.minPitch=null!=e?e:-Math.PI/2,this.northArrowPitch.maxPitch=null!=t?t:Math.PI/2}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").ScaleBarConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.performance,o=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7];t.ScaleBar=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-scale");n.style.bottom=`${e.bottom}px`,n.style.right=`${e.right}px`,t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,this.lastUpdateTime=Date.now(),this.enableScale=!0,this._value=void 0,P(this),this.init()}init(){this.drawElements((()=>{this.addRenderCallback()}))}drawElements(e){this.domElement.innerHTML='\n <svg height="36px" width="140px" class="bf-scale-svg" onselectstart="return false;">\n <rect x="0" y="0" width="140px" height="36px" style="fill:#20262F;opacity:0.85;stroke-width:1px;stroke:#3B4554"/>\n <path class="bf-scale-bar" fill="none"/>\n <text class= "bf-scale-label" fill="#cccccc"></text>\n </svg>\n ',this.barElement=this.domElement.querySelector(".bf-scale-bar"),this.labelElement=this.domElement.querySelector(".bf-scale-label"),this.domElement.style.display="none",e()}addRenderCallback(){this.renderCallback=n.throttleAndDebounce((()=>{if(this.enableScale&&!this._opt.viewer._isDestroyed){var e=this._opt.viewer.getViewer().camera,t=this._opt.viewer.getViewer().getViewportSize();if(e.position.y<0)this.domElement.style.display="none";else{var i=new THREE.Vector3(t.width/2,t.height-1),n=new THREE.Vector3(t.width/2+1,t.height-1),s=this._opt.viewer.getViewer().pickByPoint(i,!0,!1),r=this._opt.viewer.getViewer().pickByPoint(n,!0,!1);if(s&&r&&s.worldPosition&&r.worldPosition){var a=s.worldPosition.distanceTo(r.worldPosition);if(this._pixelDistance=a,a<0)this.domElement.style.display="none";else{for(var l,h=o.length-1;!l&&h>=0;--h)o[h]/a<=120&&(l=o[h]);if(l){var d;this._value=l,d=l>=1e3?(l/1e3).toString()+"km":l.toString()+"m",this.labelElement.textContent=d;var c=this.labelElement.getBoundingClientRect().width||43;this.labelElement.setAttribute("x",70-c/2),this.labelElement.setAttribute("y",23);var u=l/a,g="M"+(70-u/2).toString()+" 20 L"+(70-u/2).toString()+" 28 L"+(70+u/2).toString()+" 28 L"+(70+u/2).toString()+" 20";this.barElement.setAttribute("d",g),this.domElement.style.display="block"}else this._value=void 0,this._pixelDistance=void 0,this.domElement.style.display="none"}}else this.domElement.style.display="none"}}}),500),this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enableScale=!0}hide(){this.domElement.style.display="none",this.enableScale=!1}isVisible(){return this.enableScale}getValue(){return this._pixelDistance}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").InfoBarConfig=function(){return{domElement:null,viewer:null,right:0,bottom:0}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=e.Web.Lang.Utility.performance;t.InfoBar=class{constructor(e){this._opt=e;const t=e.domElement,o=i.create("div","bf-infobar");o.style.bottom=`${e.bottom}px`,o.style.right=`${e.right}px`,o.style.display="none",t.appendChild(o),this.domElement=o,this.enable=!0,this._info={},this._inited=!1,this.isMouseClicked=!1,P(this);this._mousemoveCallback=n.throttleAndDebounce((e=>{if(!this.enable)return;if(this.isMouseClicked)return;let t=this._opt.viewer.getViewer().pickByPoint(e,!1,!1);if(!t)return;let i=t.worldPosition,n=i.z,{lat:o,lon:s}=this._opt.viewer.worldToLatLon(i);this._info={latitude:o,longtitude:s,altitude:n};let r=`${o.toFixed(6)}${o>=0?"N":"S"}&nbsp;&nbsp;${s.toFixed(6)}${s>=0?"E":"W"}&nbsp;&nbsp;${"-0.000"===n.toFixed(3)?"0.000":n.toFixed(3)}m`;this.domElement.innerHTML=r,this._inited||(this.domElement.style.display="block",this._inited=!0)}),250),this._mousedownCallback=()=>{this.isMouseClicked=!0},this._mouseupCallback=()=>{this.isMouseClicked=!1},this.init()}init(){this._opt.domElement.addEventListener("mousedown",this._mousedownCallback),this._opt.domElement.addEventListener("mouseup",this._mouseupCallback),this._opt.domElement.addEventListener("mousemove",this._mousemoveCallback)}destroy(){this._opt.domElement.removeEventListener("mousemove",this._mousemoveCallback),this._opt.domElement.removeEventListener("mousedown",this._mousedownCallback),this._opt.domElement.removeEventListener("mouseup",this._mouseupCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enable=!0}hide(){this.domElement.style.display="none",this.enable=!1}isVisible(){return this.enable}getValue(){return this._info}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins").CreditConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.Credit=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div",`bf-credit ${e.class||""}`);t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,P(this)}drawElements(){const{credit:t,text:i,link:n,copyright:o}=this._opt;if(t===e.Bimface.Common.Credit.None)this.domElement.innerHTML="";else this.domElement.innerHTML=`\n <div class='copyright'>${o}\n <div class='divider'></div>\n <a class='text' href='${n}' target='_blank'>${i}</a> \n </div>\n `}destroy(){this._opt.domElement.removeChild(this.domElement)}update(e){this._opt=Object.assign({},this._opt,e),this.drawElements()}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search").SearchConfig=function(){return{wrapElement:null,viewer:null}},function(){var t="Bimface.Plugins.Search",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t;if(this._opt=i,this.clear(),!i.viewer)return console.log("viewer is not defined."),!1;let n=new e.Web.Lang.EventManager;this.getEventManager=function(){return n},this.buttonIcon=o.create("div","bf-button gld-bf-search bf-search-btn"),this.element=o.create("div","bf-search-toolbar bf-hide"),i.wrapElement.appendChild(this.buttonIcon),i.wrapElement.appendChild(this.element),this.init()};s.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},clickSearch(e){const t=this._opt.viewer,i=this.element.querySelector("input").value;return""==i?(this.clear(),void this.update(e)):i===this._data.text?this.clickArrow(!0,e):void t.search({text:i},(t=>{this._data.index=t.length>0?1:0;let n=this.formatResult(t);this._data.all=n.length,this._data.result=n,this._data.text=i,this.hasData=!!this._data.result.length,this._opt.UI.getPanel("MobileLayoutListPanel")&&n.length>0&&this._opt.UI.getPanel("MobileLayoutListPanel").updateStatusByDataType(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(e),this._data.index&&this.zoomToBbox(n[this._data.index-1])}))},clickArrow(e,t){const i=e?this._data.index+1:this._data.index-1,n=this._data.result;this._opt.UI;n.length>0&&(this._data.index=e?i>n.length?1:i:i>0&&i||n.length,this._opt.UI.getPanel("MobileLayoutListPanel")&&n.length>0&&this._opt.UI.getPanel("MobileLayoutListPanel").updateStatusByDataType(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(t),this.zoomToBbox(n[this._data.index-1]))},init:function(){i.send(t,"init"),document.addEventListener("keyup",(e=>{e&&13==e.keyCode&&this.element.querySelector("input")==document.activeElement&&this.clickSearch(!0)})),this.element.addEventListener("click",(e=>{let t=e.target;t.hasClass("bf-search")?this.clickSearch():t.hasClass("gld-bf-arrowup")?this.clickArrow():t.hasClass("gld-bf-arrowdown")&&this.clickArrow(!0)})),this.buttonIcon.addEventListener("click",(e=>{this.buttonIcon.addClass("bf-hide"),this.element.removeClass("bf-hide"),this.update(!0);let t=this._opt.UI.getToolbar("LeftSubToolbar");t&&(t.getControl("MobileLayoutList").setCheckedState(!1),t.getControl("MobileLayoutList").hide())})),this.update()},formatResult(e){let t=[];for(let i=0;i<e.length;i++){const n=e[i];for(let e=0;e<n.data.length;e++){const i=n.data[e];t.push({viewId:n.viewId,content:n.content,modelId:n.modelId,boundingBox:i.boundingBox})}}return t},update:function(e){i.send(t,"update"),this.element.innerHTML=`\n <div class="bf-input-wrapper">\n <i class="gld-bimface gld-bf-arrowdown bf-search-back"></i>\n <input value="${this._data.text||""}" type="text" inputmode="search" maxlength="30" placeholder="${BimfaceLanguage.bf_btn_search_textInput}" />\n <div class="bf-right-btns">\n <i class="gld-bimface gld-bf-mark bf-clear ${this._data.text?"":"bf-hidden"}"></i>\n <div class="bf-line ${this._data.text?"":"bf-hidden"}""></div>\n <div title="${BimfaceLanguage.bf_btn_search_search}" class='bf-button gld-bf-search bf-search'></div>\n </div>\n </div>\n <div class='count-wrapper bf-hide'>\n <span class='count'>${this._data.index}/${this._data.all}</span>\n <div title="${BimfaceLanguage.bf_btn_search_previous}" class='bf-button gld-bf-arrowup'></div>\n <div title="${BimfaceLanguage.bf_btn_search_next}" class='bf-button gld-bf-arrowdown'></div>\n </div>\n `;const n=this.element.querySelector(".bf-search-back");n&&n.addEventListener("click",(e=>{this.element.querySelector("input").value="",this.buttonIcon.removeClass("bf-hide"),this.element.addClass("bf-hide"),this.clear();let t=this._opt.UI.getToolbar("LeftSubToolbar");t&&t.getControl("MobileLayoutList").show()}));let o=this.element.querySelector("input");if(e){o.focus();const e=this._data.text;o.value="",o.value=e}o.addEventListener("input",(e=>{this.updateClearBtn(o.value)}));this.element.querySelector(".bf-right-btns .bf-clear").addEventListener("click",(()=>{o.value="",this.clear(),this.updateClearBtn(),this.updateCountRow()})),this.updateCountRow()},clear:function(){this._data={index:0,all:0,text:"",result:[]},this.hasData=!!this._data.result.length},updateClearBtn(e){const t=this.element.querySelector(".bf-right-btns .bf-clear"),i=this.element.querySelector(".bf-right-btns .bf-line");e?(t.removeClass("bf-hidden"),i.removeClass("bf-hidden")):(t.addClass("bf-hidden"),i.addClass("bf-hidden"))},updateCountRow(){const e=this.element.querySelector(".count-wrapper");this.hasData?e.removeClass("bf-hide"):e.addClass("bf-hide")},zoomToBbox(e){const t=this._opt.viewer;t.showViewById(e.viewId),t.zoomToBoundingBox(e.boundingBox)},destroy(){this._opt=null,this.element=null,this._data=null}},n.MobileSearch=s}(),function(){var t="Bimface.Plugins.Search",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Search"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=t;if(this._opt=i,this.clear(),!i.viewer)return console.log("viewer is not defined."),!1;let n=new e.Web.Lang.EventManager;this.getEventManager=function(){return n},this.element=o.create("div","bf-search-toolbar"),this.searchPanel=o.create("ul","bf-search-panel"),this.searchPanel.id="bf-search-panel",i.wrapElement.appendChild(this.element),i.wrapElement.appendChild(this.searchPanel),this.init()};s.prototype={addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},clickSearch(e){const t=this._opt.viewer,i=this.element.querySelector("input").value;return""==i?(this.clear(),this.searchPanel.innerHTML="",void this.update(e)):i===this._data.text?this.clickArrow(!0,e):void t.search({text:i},(t=>{this._data.index=t.length>0?1:0;let n=this.formatResult(t);this._data.all=n.length,this._data.result=n,this._data.text=i,this._opt.UI.getToolbar("LeftSubToolbar")&&n.length>0&&this._opt.UI.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(e),this._data.index&&this.zoomToBbox(n[this._data.index-1])}))},clickArrow(e,t){this.searchPanel.getElementsByClassName("bf-search-result-content").length>0&&(this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#ccc");const i=e?this._data.index+1:this._data.index-1,n=this._data.result,o=this._opt.UI;n.length>0&&(this._data.index=e?i>n.length?1:i:i>0&&i||n.length,o.getToolbar("LeftSubToolbar")&&o.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==n[this._data.index-1].viewId?"Model":n[this._data.index-1].viewId),this.update(t),this.zoomToBbox(n[this._data.index-1]))},clickSearchPanel(e){if(void 0!==e){this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#ccc",this._data.index=e;let t=this._data.result;this._opt.UI.getToolbar("LeftSubToolbar")&&t.length>0&&this._opt.UI.getToolbar("LeftSubToolbar").getControl("LayoutList").setSelectedUiById(0==t[this._data.index-1].viewId?"Model":t[this._data.index-1].viewId),this.update(!0),this._data.index&&this.zoomToBbox(t[this._data.index-1])}},init:function(){i.send(t,"init"),this.onKeyup=e=>{e&&13==e.keyCode&&this.element.querySelector("input")==document.activeElement&&this.clickSearch(!0)},document.addEventListener("keyup",this.onKeyup),this.onClick=e=>{let t=e.target;t.hasClass("gld-bf-search")?this.clickSearch():t.hasClass("gld-bf-arrowup")?this.clickArrow():t.hasClass("gld-bf-arrowdown")&&this.clickArrow(!0)},this.element.addEventListener("click",this.onClick),this.onSearchPanelClick=e=>{this.clickSearchPanel(e.target.index)},this.searchPanel.addEventListener("click",this.onSearchPanelClick),this.update()},formatResult(e){let t=[],i=0;this.searchPanel.innerHTML="";for(let n=0;n<e.length;n++){const s=e[n];for(let e=0;e<s.data.length;e++){i+=1;const n=s.data[e],r=o.create("li","bf-search-result-content");r.textContent=s.content,r.id="bf-search-result-content",r.title=s.content,r.index=i,this.searchPanel.appendChild(r),t.push({viewId:s.viewId,content:s.content,modelId:s.modelId,boundingBox:n.boundingBox})}}return t},update:function(e){if(i.send(t,"update"),this.element.innerHTML=`<input value="${this._data.text||""}" maxlength="30" placeholder="${BimfaceLanguage.bf_btn_search_textInput}" /><div title="${BimfaceLanguage.bf_btn_search_search}" class='bf-button gld-bf-search'></div><div class='line'></div><span class='count'>${this._data.index}/${this._data.all}</span><div title="${BimfaceLanguage.bf_btn_search_previous}" class='bf-button gld-bf-arrowup'></div><div title="${BimfaceLanguage.bf_btn_search_next}" class='bf-button gld-bf-arrowdown'></div>`,this.searchPanel.getElementsByClassName("bf-search-result-content").length>0&&(this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].style.color="#32D3A6",this._opt.wrapElement.querySelectorAll("li")[this._data.index-1].scrollIntoViewIfNeeded(!0)),e){let e=this.element.querySelector("input");e.focus();const t=this._data.text;e.value="",e.value=t}},clear:function(){this._data={index:0,all:0,text:"",text:"",result:[]}},zoomToBbox(e){const t=this._opt.viewer;t.showViewById(e.viewId),t.zoomToBoundingBox(e.boundingBox)},destroy:function(){document.removeEventListener("keyup",this.onKeyup),this.element&&this.element.removeEventListener("click",this.onClick),this.searchPanel&&this.searchPanel.removeEventListener("click",this.onSearchPanelClick),this._opt=null,this._data=null,this.element=null,this.searchPanel=null}},n.Search=s}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox").SkyBoxStyle=Object.freeze({BlueSky:"BlueSky",CloudySky:"CloudySky",DarkNight:"DarkNight",Galaxy:"Galaxy",Cosmos:"Cosmos",MoonrisePureskyDark:"MoonrisePureskyDark",MountainGround:"MountainGround",CloudPuresky:"CloudPuresky",MistyMorning:"MistyMorning",Puresky:"Puresky",SunsetPuresky:"SunsetPuresky",GreyPuresky:"GreyPuresky",OvercastPuresky:"OvercastPuresky",Customized:"Customized"}),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox");t.SkyBoxManagerConfig=class{constructor(){this.customizedImage=null,this.style=null,this.viewer=null,this.initializeVisible=!0}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.SkyBox");i.SkyBoxManager=class{constructor(e){t.send("Bimface.Plugins.SkyBox.SkyBoxManager","bf_c_skyBoxMng_new"),this._customizedImage=e.customizedImage,this._style=e.style,this._viewer=e.viewer,this._enabled=!1,this.exrArr=["MoonrisePureskyDark","MountainGround","CloudPuresky","MistyMorning","Puresky","SunsetPuresky","GreyPuresky","OvercastPuresky"],P(this),this.enableSkyBox(e.initializeVisible)}setCustomizedImage(e){this._customizedImage!=e&&(this._customizedImage=e,this._updateSkyBox())}getCustomizedImage(){return this._customizedImage}setStyle(e){this._style!=e&&(this._style=e,this._updateSkyBox())}getStyle(){return this._style}enableSkyBox(e){if(this._enabled!=e){if(this._enabled=e,!this._enabled)this._viewer.getViewer().IBLManager.removeSkyBox();this._updateSkyBox()}}getSenceType(){return e.Bimface.Common.Type.EffectType.SkyBoxManager}show(){this.enableSkyBox(!0)}hide(){this.enableSkyBox(!1)}destroy(){this.enableSkyBox(!1),this._customizedImage=null,this._style=null,this._viewer=null}getParams(){return{customizedImage:this._customizedImage,style:this._style}}_updateSkyBox(){if(this._enabled){var t=this._viewer.getViewer().IBLManager,i=this._style,n=this._viewer._data,o=[];if(this._style==e.Bimface.Plugins.SkyBox.SkyBoxStyle.Customized&&this._customizedImage)o.push(this._customizedImage.right),o.push(this._customizedImage.left),o.push(this._customizedImage.top),o.push(this._customizedImage.bottom),o.push(this._customizedImage.front),o.push(this._customizedImage.back);else if(this._style==e.Bimface.Plugins.SkyBox.SkyBoxStyle.Customized)i=e.Bimface.Plugins.SkyBox.SkyBoxStyle.CloudySky;else{if(this.exrArr.indexOf(this._style)>=0){if(this._viewer.visualization&&this._viewer.visualization.active&&this._viewer.getModel().isBimtilesModel()&&!e.Web.Lang.Utility.ClientHelper.getIsMac()){var s=(n.dataEnvType==_.Local?n.sdkPath:g.staticHost)+"/resources/Setting/SkyBox/"+i+".exr";this._viewer.getViewer().skyBoxMapManager.loadEquirectangularMap(s,(e=>{this._viewer.getViewer().setDeferBackground(e),this._viewer.getViewer().setRenderStateChanged(!0),this._viewer.getViewer().setDefferBackgroundRotation(new THREE.Euler(0,0,0)),this._viewer.getViewer().render()}))}return}i=this._style}if(0==o.length&&i){s=(n.dataEnvType==_.Local?n.sdkPath:g.staticHost)+"/resources/SkyBox/Pics/"+i;const e=["posx.jpg","negx.jpg","posy.jpg","negy.jpg","posz.jpg","negz.jpg"];for(var r=0;r<6;++r)o.push(s+"/EnvMap_"+e[r])}t.loadSkyBox(o,!1),t.setSkyBoxType(i)}}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Ground");t.GroundConfig=class{constructor(){this.elevation=0,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Ground");i.Ground=class{constructor(e){t.send("Bimface.Plugins.Ground.Ground","createGround"),this._color=e.color,this._viewer=e.viewer,this._elevation=e.elevation,this._ground=this._viewer.getViewer().createGround(e),P(this)}destroy(){this._viewer.getViewer().removeGround(),this._ground=null}setElevation(e){this._ground.setElevation(this._viewer.globalUnitUtil.translate(e))}getElevation(){return this._viewer.globalUnitUtil.revertTranslate(this._ground.getElevation())}show(){console.log("This function is not available now")}hide(){console.log("This function is not available now")}update(){console.log("This function is not available now")}setColor(){console.log("This function is not available now")}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AuxMobile").AuxMobileConfig=function(){return{editor:null,width:3,viewer:null}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.AuxMobile"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.AuxMobile=class{constructor(e){this.viewer=e.viewer,this.touchEndCounts=0,this.editor=e.editor,this.showAuxBall=!1,this.outerCircleRadius=40,this.outerCircleFillStyle="rgba(0, 0, 0, 0.65)",this.outerCircleBorderWidth=4,this.outerCircleBorderColor="#999999",this.innerCircleRadius=20,this.innerCircleFillStyle="rgba(255, 255, 255, 0.8)",this.innerCircleBorderWidth=2,this.ballOuterCircleRadius=40,this.ballOuterCircleFillStyle="rgba(255, 255, 255, 0.3)",this.ballOuterCircleBorderWidth=1,this.ballOuterCircleBorderColor="#999999",this.ballInnerCircleRadius=20,this.ballInnerCircleFillStyle="rgba(255, 255, 255, 0.8)",this.ballInnerCircleBorderWidth=2,this.ballDirectionCircleRadius=4,this.ballDirectionCircleFillStyle="rgba(50, 211, 166, 1)",this.ballDirectionCircleBorderWidth=1,this.triangleWidth=12,this.triangleFillStyle="rgba(0, 0, 0, 0.65)",this.triangleBorderWidth=1,this.triangleBorderColor="#999999";let t=this.canvas=i.create("canvas","bf-aux-mobile"),n=this.viewer.getDomElement();t.width=n.offsetWidth,t.height=n.offsetHeight,this.ctx=t.getContext("2d"),n.append(t),this.initPos()}initPos(){let e={x:this.canvas.width/2,y:this.canvas.height/2};this.draw(this.updateAux(e))}setEditor(e){this.editor=e}updateAux(e){this.center=e;let t={outerCircle:{}};if(t.outerCircle.center=e,this.showAuxBall)t.outerCircle.radius=this.ballOuterCircleRadius,t.innerCircle={},t.innerCircle.center=e,t.innerCircle.radius=this.ballInnerCircleRadius;else{t.outerCircle.radius=this.outerCircleRadius,t.innerCircle={},t.innerCircle.center=e,t.innerCircle.radius=this.innerCircleRadius,t.triangle=[];let i={x:e.x-this.outerCircleRadius,y:e.y-this.outerCircleRadius};t.triangle.push({x:i.x,y:i.y}),t.triangle.push({x:i.x+this.triangleWidth,y:i.y}),t.triangle.push({x:i.x,y:i.y+this.triangleWidth})}return t}draw(e){let t=this.ctx;t.clearRect(0,0,this.canvas.width,this.canvas.height);let i=e.outerCircle;t.strokeStyle=this.outerCircleBorderColor,t.lineWidth=this.outerCircleBorderWidth,t.fillStyle=this.outerCircleFillStyle,t.beginPath(),t.arc(i.center.x,i.center.y,i.radius,0,2*Math.PI,!0),t.fill(),t.stroke();let n=e.innerCircle;t.fillStyle=this.innerCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,n.radius,0,2*Math.PI,!0),t.fill();let o=e.triangle;t.lineWidth=this.triangleBorderWidth,t.fillStyle=this.triangleFillStyle,t.beginPath(),t.moveTo(o[0].x,o[0].y),t.lineTo(o[1].x,o[1].y),t.lineTo(o[2].x,o[2].y),t.closePath(),t.fill(),t.stroke()}drawBall(e){let t=this.ctx;t.clearRect(0,0,this.canvas.width,this.canvas.height);let i=e.outerCircle;t.strokeStyle=this.ballOuterCircleBorderColor,t.lineWidth=this.ballOuterCircleBorderWidth,t.fillStyle=this.ballOuterCircleFillStyle,t.beginPath(),t.arc(i.center.x,i.center.y,i.radius,0,2*Math.PI,!0),t.fill(),t.stroke();let n=e.innerCircle;t.fillStyle=this.ballInnerCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,n.radius,0,2*Math.PI,!0),t.fill(),t.lineWidth=this.ballDirectionCircleBorderWidth,t.fillStyle=this.ballDirectionCircleFillStyle,t.beginPath(),t.arc(n.center.x,n.center.y,this.ballDirectionCircleRadius,0,2*Math.PI,!0),t.fill(),t.moveTo(n.center.x-this.ballDirectionCircleRadius-3,n.center.y-this.ballDirectionCircleRadius-2),t.lineTo(n.center.x-this.ballDirectionCircleRadius-13,n.center.y),t.lineTo(n.center.x-this.ballDirectionCircleRadius-3,n.center.y+this.ballDirectionCircleRadius+2),t.closePath(),t.fill(),t.beginPath(),t.moveTo(n.center.x+this.ballDirectionCircleRadius+3,n.center.y-this.ballDirectionCircleRadius-2),t.lineTo(n.center.x+this.ballDirectionCircleRadius+13,n.center.y),t.lineTo(n.center.x+this.ballDirectionCircleRadius+3,n.center.y+this.ballDirectionCircleRadius+2),t.closePath(),t.fill()}getRealPoint(e){let t=this.canvas.getBoundingClientRect(),i=this.outerCircleRadius,n=this.outerCircleRadius;return{x:e.x-i+t.left,y:e.y-n+t.top}}getBallRealPoint(e){let t=this.outerCircleRadius,i=this.outerCircleRadius;return{x:e.x-t,y:e.y-i}}showBall(){let e=this.getBallRealPoint(this.center);this.showAuxBall=!0,this.drawBall(this.updateAux(e))}showCanvas(){this.canvas.style.display="block"}hideCanvas(){this.canvas.style.display="none"}formatPoint(e){let t=this.canvas.getBoundingClientRect();return{x:e.x-t.left,y:e.y-t.top}}onTouchStart(e,t){if(t=this.formatPoint(t),!this.touchOnAux(t))return;this.startPoint=t,e.stopImmediatePropagation(),e.preventDefault(),this.editor.touchStartCallback(t)}onTouchMove(e,t){if(t=this.formatPoint(t),!this.touchOnAux(t))return;e.stopImmediatePropagation(),e.preventDefault();let i=this.editor,n=this.updateAux({x:t.x,y:t.y});if(this.showAuxBall){this.drawBall(n);let e=this.startPoint;i.touchMoveCallback({start:e,end:t})}else{this.draw(n);let e=this.getRealPoint(t);i.touchMoveCallback(e)}}onTouchEnd(e,t,i){if(this.startPoint=null,!t)return;if(t=this.formatPoint(t),!this.touchOnAux(t))return;e.stopImmediatePropagation(),e.preventDefault();let n=this.editor;if(this.showAuxBall)n.touchEndCallback(this.center);else{let e=this.getRealPoint(t);n.touchEndCallback(e)}}vectorAngle(e,t){let i=Math.sqrt(e.reduce(((e,t)=>e+Math.pow(t,2)),0)),n=Math.sqrt(t.reduce(((e,t)=>e+Math.pow(t,2)),0));return Math.acos(e.reduce(((e,i,n)=>e+i*t[n]),0)/(i*n))}getNormal(){let e=this.viewer.getViewer().getScene();return CLOUD.FillClipPlaneManager.getInstance(e).renderClipPlane.normal}getCoordinate(){let e=this.viewer._sectionPlane.coordinateSystem,t=e.getCoordinateAxis();return{start:e.drawingToCanvas(t.start.clone()),endZ:e.drawingToCanvas(t.endZ.clone())}}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="",this.showAuxBall=!1,this.initPos()}destroy(){this.canvas.remove()}redraw(){if(this.center){let e=this.updateAux(this.center);this.draw(e)}}touchOnAux(e){const{center:t,outerCircleRadius:i,ballOuterCircleRadius:n,showAuxBall:o}=this,s=e;let r=t.x-s.x,a=t.y-s.y;return Math.sqrt(r*r+a*a)<=(o&&n||i)}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClashDetective").ClashDetectivePanelConfig=class{constructor(){this.viewer=null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClashDetective"),i=e.Bimface.Data.StatisticsDataManager.getInstance();t.ClashDetectivePanel=class{constructor(t){i.send("Bimface.Plugins.ClashDetective.ClashDetectivePanel","bf_c_clashDetectivePanel_new");let n=this;if(this._console=new e.Web.Common.Console,P(this),!t)return void this._console.error("clashDetectivePanelConfig must not be empty.");if(!t.viewer||"Viewer3D"===!t.viewer.viewerType)return void this._console.error("viewer must not be empty or viewer3d.");this.clashDetectivePanelConfig=t,this.viewer=t.viewer,this.unitType=this.viewer.getUnit(),this.modelUnit=this.unitType;const o=n.viewer.getModels();o.length&&(this.modelUnit="m"===o[0]._manifest.Metadata.Unit?"Meter":"Millimeter"),this.clashResult={},this.currentIndex=0,this.hasModelA=!1,this.hasModelB=!1,this.isIntegrateA=!1,this.isIntegrateB=!1,this.transMultiplyingMap={"Millimeter-Millimeter":1,"Millimeter-Centimeter":.1,"Millimeter-Meter":.001,"Millimeter-Kilometer":1e-7,"Meter-Millimeter":1e3,"Meter-Centimeter":100,"Meter-Meter":1,"Meter-Kilometer":.001},this.bBoxBorderMap={Millimeter:2e3,Centimeter:200,Meter:2,Kilometer:.002};var s=new e.Bimface.UI.Panel.PanelConfig;s.title=BimfaceLanguage.bf_panel_clashDetective_clashDetective,s.className="bf-panel clash-detective-panel-wrapper",s.id="clashDetective";let r=e.Web.Lang.Utility.ClientHelper.getIsDesktop();s.css=r?{right:"10px",top:"10px",width:"300px",height:"416px"}:{left:0,top:0,width:"100%",height:"100%"};var a=new e.Bimface.UI.Panel.Panel(s);let l,h;a.addEventListener("Hide",(()=>{this.clearIsolation();let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item"),this.currentIndex=0})),this.clashDetectivePanel=a,this.viewer.clashDetectivePanel=a,this.makeOthersTranslucent=e.Bimface.Viewer.IsolateOption.MakeOthersTranslucent,n._updateModelName=function(e){h=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdA)),!h||e!=n.modelIdA&&e!=h.modelId||(n.modelUnit="m"===h._manifest.Metadata.Unit?"Meter":"Millimeter",n.hasModelA=!0,l=document.getElementById("cdModelAName"),l&&(l.setAttribute("class","active"),l.removeAttribute("title"),l.innerText=`${h._data.name}${n.isIntegrateA?"(集成模型)":""}`)),h=n.viewer.getModels().find((e=>e._data.modelId==n.modelIdB)),!h||e!=n.modelIdB&&e!=h.modelId||(n.modelUnit="m"===h._manifest.Metadata.Unit?"Meter":"Millimeter",n.hasModelB=!0,l&&(l=document.getElementById("cdModelBName"),l.setAttribute("class","active"),l.removeAttribute("title"),l.innerText=`${h._data.name}${n.isIntegrateB?"(集成模型)":""}`))},this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,this._updateModelName)}setActiveItem(e,t=!1){if(e<=0||this.clashResult&&this.clashResult.results.length&&e>this.clashResult.results.length)return;if(!t){let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item")}let i=this.clashResult.results[e-1],n=document.querySelector(`#itemId_${e}`);n&&n.setAttribute("class","cd-r-list-item active"),this.currentIndex=e,(this.hasModelA||this.hasModelB)&&(this.isolateComponentsById(i),this.zoomToBoundingBox(i.position,this.unitType,this.modelUnit))}zoomToBoundingBox(e,t,i){let n=this.transformToBoundingBox(e,t,i);this.viewer.zoomToBoundingBox(n)}transformToBoundingBox(e,t,i){const n=this.viewer.getGlobalUnit()?1:this.transMultiplyingMap[`${i}-${t}`],o=this.bBoxBorderMap[t];return{max:{x:e.x*n+o,y:e.y*n+o,z:e.z*n+o},min:{x:e.x*n-o,y:e.y*n-o,z:e.z*n-o}}}destroy(){this.clashDetectivePanel.close(),this.clearIsolation(),this.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,this._updateModelName)}show(){this.clashDetectivePanel.show()}hide(){this.clashDetectivePanel.hide(),this.clearIsolation();let e=document.querySelector(`#itemId_${this.currentIndex}`);e&&e.setAttribute("class","cd-r-list-item"),this.currentIndex=0}setData(e){let t=this;this.clashDetectivePanel.clear(),this.clashResult=e,this.modelIdA=e.selectionA.fileId||e.selectionA.integrateId,this.modelIdB=e.selectionB.fileId||e.selectionB.integrateId,e.selectionA.integrateId&&(this.isIntegrateA=!0),e.selectionB.integrateId&&(this.isIntegrateB=!0);let i=[],n="";e.results.forEach(((e,t)=>{n=`\n <li class="cd-r-list-item" id="itemId_${t+1}">\n <span class="cd-r-list-item-left">${BimfaceLanguage.bf_panel_clashDetective_clash_num}${t+1}:</span>\n <div class="cd-r-list-item-right">\n <p><span>${BimfaceLanguage.bf_panel_clashDetective_componentA}:</span><span>${e.objectIdA}</span></p>\n <p><span>${BimfaceLanguage.bf_panel_clashDetective_componentB}:</span><span>${e.objectIdB}</span></p>\n </div>\n </li>`,i.push(n)}));let o=this.modelIdA,s=this.modelIdB,r=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdA)),a=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdB));r&&(this.hasModelA=!0,o=r._data.name),a&&(this.hasModelB=!0,s=a._data.name);let l=`\n <section class="cd-r-title-wrapper">\n <div class="cd-r-title-item">\n <span>${BimfaceLanguage.bf_panel_clashDetective_modelA}:</span>\n <span id="cdModelAName" class="${this.hasModelA?"active":""}" title="${this.hasModelA?"":"模型未加载"}">\n ${o}${this.isIntegrateA?"(集成模型)":""}\n </span>\n </div>\n <div class="cd-r-title-item">\n <span>${BimfaceLanguage.bf_panel_clashDetective_modelB}:</span>\n <span id="cdModelBName" class="${this.hasModelB?"active":""}" title="${this.hasModelB?"":"模型未加载"}">\n ${s}${this.isIntegrateB?"(集成模型)":""}\n </span>\n </div>\n </section>\n <ul class="cd-r-list-wrapper">\n ${i.join("")}\n </ul>\n `;this.clashDetectivePanel.setHtml(l),this.viewer._opt.domElement.appendChild(this.clashDetectivePanel.element);document.querySelectorAll(".cd-r-list-item").forEach(((e,i)=>{let n=i+1;e.addEventListener("click",(function(){0===t.currentIndex?t.setActiveItem(n,!0):t.currentIndex!==n&&t.setActiveItem(n,!1)}))}))}isolateComponentsById(t){this.clearIsolation();let i=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdA));i&&(i.isolateComponentsById([t.objectIdA,t.objectIdB],this.makeOthersTranslucent),i.overrideComponentsColorById([t.objectIdA],new e.Web.Graphics.Color(229,120,115,1)),i.overrideComponentsFrameColor({ids:[[t.objectIdA]]},new e.Web.Graphics.Color(255,96,88,1)));let n=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdB));n&&(n.isolateComponentsById([t.objectIdA,t.objectIdB],this.makeOthersTranslucent),n.overrideComponentsColorById([t.objectIdB],new e.Web.Graphics.Color(105,205,112,1)),n.overrideComponentsFrameColor({ids:[[t.objectIdB]]},new e.Web.Graphics.Color(75,217,82,1))),this.viewer.render()}clearIsolation(){let e=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdA));e&&(e.clearOverrideColorComponents(),e.restoreComponentsFrameColor({all:!0}),e.clearIsolation());let t=this.viewer.getModels().find((e=>e._data.modelId==this.modelIdB));t&&(t.clearOverrideColorComponents(),t.restoreComponentsFrameColor({all:!0}),t.clearIsolation()),this.viewer.render()}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClashDetective");let n=e.Web.Lang.Utility.HttpRequest;i.ClashDetectiveManager=class{constructor(i){t.send("Bimface.Plugins.ClashDetective.ClashDetectiveManager","bf_c_clashDetectiveMng_new"),this.viewer=i,this._console=new e.Web.Common.Console,P(this)}loadClashDetectiveResult(e,t){let i=this;function o(e){i._console.error(e.message)}n.ajax({url:`${i.viewer._opt.APIHost}/inside/databag?viewToken=${e}`,async:!0,success:function(s){const r=JSON.parse(s);if("success"==r.code){let s=r.data&&r.data.modelId;s&&n.ajax({url:`${i.viewer._opt.APIHost}/data/clashDetective/${s}/result?view_token=${e}`,async:!0,success:function(e){var n=JSON.parse(e);"success"==n.code?t&&t(i.viewer.globalUnitUtil.revertTranslate(n.data,["x","y","z"])):o(n)},failure:e=>{o(JSON.parse(e))}})}else o(r)},failure:e=>{o(JSON.parse(e))}})}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClearanceHeightCheck");t.ClearanceHeightCheckPanelConfig=class{constructor(){this.clearanceHeightCheckResult=null,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();let i=e.Web.Lang.Utility.HttpRequest;var n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ClearanceHeightCheck");n.ClearanceHeightCheckPanel=class{constructor(i){if(t.send("Bimface.Plugins.ClearanceHeightCheck.ClearanceHeightCheckPanel","bf_clearanceHeightCheckPanel_new"),this._console=new e.Web.Common.Console,P(this),!i)return void this._console.error("clearanceHeightCheckPanelConfig must not be empty.");if(!i.viewer||"Viewer3D"===!i.viewer.viewerType)return void this._console.error("viewer must not be empty or viewer3d.");this.clearanceHeightCheckPanelConfig=i,this.viewer=i.viewer,this.checkResultData=i.clearanceHeightCheckResult,this.unitType=this.viewer.getUnit(),this.model=this.viewer.getModel(),this.clearanceComponentsList=[],this.clearanceHeightId="",this.nodeData=null;var n=new e.Bimface.UI.Panel.PanelConfig;n.title="净空分析",n.className="bf-panel clearance-heightcheck-panel-wrapper",n.id="ClearanceHeightCheck";let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();n.css=o?{right:"10px",top:"10px",width:"440px",height:"530px"}:{left:0,top:0,width:"100%",height:"100%"};var s=new e.Bimface.UI.Panel.Panel(n);s.addEventListener("Hide",(()=>{let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item"),this.nodeData&&this.nodeData.deselect(),this.clearAllRooms(),this.clearAll(),this.clearSection()})),this.clearanceHeightCheckPanel=s,this.viewer.clearanceHeightCheckPanel=s,this.checkResultData&&this.setData(this.checkResultData),this.defaultComponentsDisplayMode={mode:"default",option:{unqualifiedObjectColor:new e.Web.Graphics.Color(255,96,88,.6),qualifiedObjectColor:new e.Web.Graphics.Color(75,217,82,.6)}},this.currentComponentsDisplayMode=this.defaultComponentsDisplayMode,this.defaultRoomDisplayMode={mode:"default",option:{qualifiedRoomColor:new e.Web.Graphics.Color(255,184,0,.6),qualifiedRoomFrameColor:new e.Web.Graphics.Color(255,184,0,1),unqualifiedRoomColor:new e.Web.Graphics.Color(88,135,255,.6),unqualifiedRoomFrameColor:new e.Web.Graphics.Color(88,135,255,1)}},this.currentRoomDisplayMode=this.defaultRoomDisplayMode,this.roomManager=this.viewer.getRoomManager(),this.componentsUnit="mm"}clearSection(){this._sectionPlane&&this._sectionPlane.exit(),this._sectionPlane=null}zoomToBoundingBox(e){this.viewer.getViewer().zoomToBBox(e,.5,void 0,void 0,1e3)}zoomToArea(t,i,n,o=!1,s){this.clearSection();let r=new THREE.Vector3,a=new THREE.Vector3,l=this.viewer;if(i){let i;var h=1600,d=10;"m"===l.globalUnitUtil.getDefaultUnit()&&(h/=1e3,d/=1e3);const u=(()=>"mm"===l.globalUnitUtil.getDefaultUnit()&&!0===l.getViewer().hasBimtilesModel()?.001:"m"!==l.globalUnitUtil.getDefaultUnit()||l.getViewer().hasBimtilesModel()?1:1e3)();i=n/u+h+d,h*=u;var c=l.getCameraAnimation();l.setCameraAnimation(!1),l.setView(e.Bimface.Viewer.ViewOption.Top);let g=l.getViewer().getBoundingBoxWorld();o?this.zoomToBoundingBox(g):this.zoomToBoundingBox(t),l.setCameraAnimation(c);let p=this._sectionPlane=this.makeSectionPlane(l),m=l.getViewer().getScene().getExpandScalar(),f=(new THREE.Box3).setFromCenterAndSize(g.getCenter(r),g.getSize(a).multiplyScalar(m)),w=f.min.z,y=f.max.z;const v=l.getDefaultModel().modelId;let b=100-(i-w)/(y-w)*100;if(s){let e=CLOUD.ExtrudeBodyManager.getInstance(l.getViewer()).getNode(s);if(e){b=100-(i+e.geometry.boundingBox.clone().applyMatrix4(l.getViewer().getModelManager().getModel(v).transformMatrix).min.z-w)/(y-w)*100}}p.setPlane("Z"),p.setDirection("Forward"),p.setProgress(b),p.hidePlane(),CLOUD.GlobalData.ClippingCaps=!0,l.render()}else this.roomManager.hideAllRooms(),l.getModels().forEach((e=>{e.clearIsolation()})),this.clearSection(),l.render()}makeSectionPlane(t){let i=new e.Bimface.Plugins.Section.SectionPlaneConfig;return i.viewer=t,i.id="SectionPlane",i.plane=e.Bimface.Plugins.Section.SectionPlanePlane.Z,i.direction=e.Bimface.Plugins.Section.SectionPlaneDirection.Forward,i.exitSectionBox=!1,new e.Bimface.Plugins.Section.SectionPlane(i)}setComponentsDisplayMode(e,t){this.currentComponentsDisplayMode={mode:e,option:t}}getComponentsDisplayMode(){return this.currentComponentsDisplayMode}setRoomsDisplayMode(e,t){this.currentRoomDisplayMode={mode:e,option:t}}getRoomsDisplayMode(){return this.currentRoomDisplayMode}setActiveItem(e,t){if(e<0||this.clearanceComponentsList&&this.clearanceComponentsList.length&&e>this.clearanceComponentsList.length)return;if(this.currentIndex!==e){let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item")}let i=this.getElement().querySelector(`#clrhcItemId_${e}`);i&&i.setAttribute("class","bf-clrhc-list-item active"),this.currentIndex=e,this.zoomToObjectById(t)}zoomToObjectById(e){this.viewer.clearSelectedComponents(),this.viewer.setSelectedComponentsById([e]),this.viewer.zoomToSelectedComponents(),this.viewer.render()}isolateComponentsById(t){this.model.isolateComponentsById(t,e.Bimface.Viewer.IsolateOption.MakeOthersTranslucent),this.viewer.render()}clearIsolateComponents(){this.model.clearOverrideColorComponents(),this.model.restoreComponentsFrameColor({all:!0}),this.model.clearIsolation(),this.viewer.render()}getElement(){return this.clearanceHeightCheckPanel.element}destroy(){this.clearAll(),this.clearAllRooms(),this.clearanceHeightCheckPanel.close(),this.clearSection()}show(){this.clearanceHeightCheckPanel.show()}hide(){this.clearanceHeightCheckPanel.hide();let e=this.getElement().querySelector(`#clrhcItemId_${this.currentIndex}`);e&&e.setAttribute("class","bf-clrhc-list-item"),this.currentIndex=0}buildSpaceList(e){const t=[];return e.forEach((e=>t.push(...e.space))),t}getSpaceInfoBySpaceId(e){return this.spaceList.find((t=>t.spaceId===e))}setData(e){let t=[];this.clearanceHeightCheckPanel.clear(),this.checkResultData=e,this.clearanceHeightId=e.clearanceHeightId,e.results&&e.results.length&&(t=e.results,this.spaceList=this.buildSpaceList(t));this.clearanceHeightCheckPanel.setHtml('\n <artical class="cleanrance-body-wrapper">\n <section id="cleanranceTreeId" class="cleanrance-body-left bf-scroll-bar">\n </section>\n <section id="cleanranceRoomId" class="cleanrance-body-right">\n </section>\n </artical>\n '),this.viewer._opt.domElement.appendChild(this.getElement()),this.viewer.getFloors((e=>{let i=this.mergeData(t,e),n=this.createTree(i);this.getElement().querySelector("#cleanranceTreeId").appendChild(n.element)})),this.clearAll()}mergeData(e,t){return e.forEach((e=>{let i=t.find((t=>e.levelId===t.id));e.name=i&&i.name||"其它",e.elevation=i.elevation})),e}getDataByPath(e,t,n,o=(()=>{})){i.ajax({url:`${this.viewer._opt.APIHost}/${e}`,type:"POST",data:JSON.stringify(t||{}),headers:{"Content-Type":"application/json"},async:!0,success:e=>{var t=JSON.parse(e);"success"==t.code||"bimfaceservice-0000"===t.code?n&&n(t.data):o(t)},failure:e=>{var t=JSON.parse(e);o(t)}})}setCleanranceRoomData(e){let t=this.viewer._data.viewToken;const i=this.model.getMetaData();let n={fileId:this.viewer._data.modelId};"integrateModel"===i.modelType&&(n={integrateId:this.viewer._data.modelId}),this.getDataByPath(`data/v1/feature-management/spaces/${e.id}/properties?view_token=${t}`,n,(i=>{this.clearAllRooms(),i&&(this.createRoomBySpacesProperties(i),this.viewer.render(),this.zoomToBoundingBox({max:i.bboxMax,min:i.bboxMin})),n={clearanceHeightId:this.clearanceHeightId,spaceId:e.id},this.getDataByPath(`data/v1/feature-management/spaces/clearance-height-check/components-results?view_token=${t}`,n,(e=>{e&&e.object&&e.object.length?(this.clearanceComponentsList=e.object,this.componentsUnit=e.unit||"mm"):this.clearanceComponentsList=[],this.showComponentsByOption(1)}))}))}showComponentsByOption(e){let t=[],i="",n="",o=this.clearanceComponentsList;e&&(o=this.clearanceComponentsList.filter((t=>2===e?t.isQualified:!t.isQualified))),this.overrideColorForComponents(o),o.forEach(((e,n)=>{i=`\n <li class="bf-clrhc-list-item" id="clrhcItemId_${n}">\n <div class="bf-clrhc-list-item-left">\n <p><span>构件ID</span><span>${e.objectId}</span></p>\n <p><span>净高</span><span>${e.clearanceHeight} ${this.nodeData.extData.unit}</span></p>\n </div>\n <span class="bf-clrhc-list-item-right ${e.isQualified?"bf-qlf-yes":"bf-qlf-no"}">\n <span></span>${e.isQualified?"符合":"不符合"}\n </span>\n </li>\n `,t.push(i)})),this.currentComponentsList=o;let s=0,r=0;this.nodeData.extData.clearanceHeight&&(s=this.nodeData.extData.clearanceHeight.toFixed&&this.nodeData.extData.clearanceHeight.toFixed(3)-0),this.nodeData.extData.targetHeight&&(r=this.nodeData.extData.targetHeight.toFixed&&this.nodeData.extData.targetHeight.toFixed(3)-0),n=`\n <div class="cleanrance-body-right-info">\n <span class="cleanrance-title">${this.nodeData.extData.name}</span>\n <div class="cleanrance-value-wrapper">\n <div class="cleanrance-real-hight">\n <span>实际净高 (${this.nodeData.extData.unit})</span>\n <span>${s}</span>\n </div>\n <div class="cleanrance-real-hight">\n <span>目标净高 (${this.nodeData.extData.unit})</span>\n <span>${r}</span>\n </div>\n </div>\n </div>\n <div class="cleanrance-body-right-select-wrapper">\n <span>净高结果</span>\n <div id="cleanranceSelectId" class="select"></div>\n </div>\n <ul class="bf-clrhc-list-wrapper bf-scroll-bar">\n ${t.join("")}\n </ul>\n `,this.getElement().querySelector("#cleanranceRoomId").innerHTML=n,this.createSelect(0===this.currentSelectOption?0:this.currentSelectOption||1);this.getElement().querySelectorAll(".bf-clrhc-list-item").forEach(((e,t)=>{e.addEventListener("click",(()=>{this.setActiveItem(t,o[t].objectId)}))}))}overrideColorForComponents(e){e.forEach((e=>{let t=this.getComponentColorsByCondition({height:e.clearanceHeight,status:e.isQualified,spaceUnit:this.componentsUnit});this.overrideColor(e.objectId,t,t)})),this.viewer.render()}overrideColor(e,t,i){this.model.overrideComponentsColorById([e],t),this.model.overrideComponentsFrameColor({ids:[e]},i)}createSelect(t){var i=new e.Bimface.UI.Select.SelectConfig;i.className="bf-select bf-select-clearance",i.options=[{id:0,name:"全部"},{id:1,name:"不符合"},{id:2,name:"符合"}];let n=new e.Bimface.UI.Select.Select(i);n.setCurrentOption(t),n.addEventListener("Change",(e=>{this.selectChange(e)})),this.getElement().querySelector("#cleanranceSelectId").appendChild(n.element)}selectChange(e){this.clearAll(),this.currentSelectOption=e.id,this.showComponentsByOption(e.id)}createTreeNode(t){if(t){var i=new e.Bimface.UI.Tree.TreeNodeConfig;if(i.isChecked=!1,i.hasCheckbox=!1,i.selection="root"!==t.type,"spaceId"===t.type){var n=new e.Bimface.UI.Button.ButtonConfig;n.className="bf-tree-icon bf-qlf-no",t.isQualified&&(n.className="bf-tree-icon bf-qlf-yes"),n.title=BimfaceLanguage.bf_panel_modelTree_transparent;var o=new e.Bimface.UI.Button.Button(n);i.icon=o}var s=new e.Bimface.UI.Tree.TreeNode(i);return s.type=t.type,s.status=t.status,s.filter=t.type,s.elevation=t.elevation,s.extData=t.space||t.spaceInfo,s.setData(`${t.id}`,t.name),s}}createTree(t){if(!t||0==t.length)return;var i=this.createTreeNode({type:"root",id:"all",name:"全部"});i.expand();var n=new e.Bimface.UI.Tree.Tree(i);let o,s;for(let e=0,n=t.length;e<n;e++){o=t[e],o.type="levelId",o.id=o.levelId,o.status=o.isQualified;let n=this.createTreeNode(o);if(i.addChildNode(n),o.space&&o.space.length)for(let e=0,t=o.space.length;e<t;e++)s=o.space[e],s.type="spaceId",s.id=s.spaceId,s.status=s.isQualified,s.name=s.spaceName,s.spaceInfo=s,n.addChildNode(this.createTreeNode(s))}return n.addEventListener("SelectionChanged",((e,t)=>{this.nodeData=e,this.clearAll(!1),this.clearAllRooms(),this.clearSection(),"levelId"===e.type?(this.clearRightContent(),t&&this.createRoomForLevelId(e.id)):"spaceId"===e.type&&(this.currentSelectOption=1,t?this.setCleanranceRoomData(e):this.clearRightContent())})),n}clearAllRooms(){this.roomManager.clearAllRooms(),this.viewer.render()}createRoomForLevelId(e){let t=this.viewer._data.viewToken,i=this.buildSpaceIdListByLevelId(e);const n=this.model.getMetaData();let o={fileId:this.viewer._data.modelId,spaceIdList:i};"integrateModel"===n.modelType&&(o={integrateId:this.viewer._data.modelId,spaceIdList:i}),this.clearAll(),this.getDataByPath(`data/v1/feature-management/spaces/properties?view_token=${t}`,o,(e=>{e&&e.length&&(this.zoomToArea(null,!0,e[0].bboxMax.z,!0,null),e.forEach((e=>{this.createRoomBySpacesProperties(e)})))}))}enableDepthTest(e,t=!1){this.rooms.enableDepthTest([e],t),viewer3D.render()}clearAll(e=!0){this.clearOverrideColor(),this.currentIndex=0,e&&this.clearRightContent()}createRoomBySpacesProperties(t){let i,n,o;i=t.boundary;try{n={outer:i.outer,inner:i.inner};const s=this.getSpaceInfoBySpaceId(t.spaceId);let{roomColor:r,roomFrameColor:a}=this.getRoomColorsByCondition({height:s.clearanceHeight,status:s.isQualified,spaceUnit:s.unit});o={boundary:n,height:t.height,unit:t.unit};let l=new e.Bimface.Plugins.Rooms.RoomConfig;l.viewer=this.viewer,l.roomId=t.spaceId,l.geometry=o,l.roomColor=r,l.frameColor=a;const h=new e.Bimface.Plugins.Rooms.Room(l);this.roomManager.addRoom(h),this.viewer.render()}catch(e){console.warn(`Invalid room boundary [spaceId: ${t.spaceId}]!`)}}getComponentColorsByCondition(e){let{height:t,status:i,spaceUnit:n}=e;const o=this.getComponentsDisplayMode(),{mode:s}=o;let r;if("byStatus"===s||"default"===s)r=i?o.option.qualifiedObjectColor:o.option.unqualifiedObjectColor;else if("byHeight"===s){const e=o.option.unit;let i=o.option.colorList;t=this.viewer.globalUnitUtil.excute(t,n,e);const s=i.find((e=>t>=e.heightRange[0]&&t<e.heightRange[1]));s&&(r=s.color)}return r||(r=this.defaultComponentsDisplayMode.option.unqualifiedObjectColor),r}getRoomColorsByCondition(e){let{height:t,status:i,spaceUnit:n}=e;const o=this.getRoomsDisplayMode(),{mode:s}=o;let r,a;if("byStatus"===s||"default"===s)i?(r=o.option.qualifiedRoomColor,a=o.option.qualifiedRoomFrameColor):(r=o.option.unqualifiedRoomColor,a=o.option.unqualifiedRoomFrameColor);else if("byHeight"===s){const e=o.option.unit;let i=o.option.colorList;t=this.viewer.globalUnitUtil.excute(t,n,e);const s=i.find((e=>t>=e.heightRange[0]&&t<e.heightRange[1]));s&&(r=s.roomColor,a=s.roomFrameColor)}return r&&a||(r=this.defaultRoomDisplayMode.option.unqualifiedRoomColor,a=this.defaultRoomDisplayMode.option.unqualifiedRoomFrameColor),{roomColor:r,roomFrameColor:a}}transferBoundary(e,t=!1){const i=[];return e?(t?e.forEach((e=>{let t=[];e.forEach((e=>t.push([e.x-0,e.y-0,e.z-0]))),i.push(t)})):e.forEach((e=>i.push([e.x-0,e.y-0,e.z-0]))),i):i}buildSpaceIdListByLevelId(e){let t=[],i=this.checkResultData.results.find((t=>t.levelId===e));return i&&i.space&&i.space.forEach((e=>{t.push(e.spaceId)})),t}clearRightContent(){this.getElement().querySelector("#cleanranceRoomId").innerHTML='<span class="gld-bimface gld-bf-information"><span>请选择对应空间</span></span>'}clearOverrideColor(){this.viewer.clearSelectedComponents(),this.model.clearOverrideColorComponents(),this.model.restoreComponentsFrameColor({all:!0}),this.viewer.render()}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");t.Room=class{constructor(t){this.viewer=t.viewer,this.roomId=t.roomId,this.modelId=t.modelId,this.geometry=t.geometry,this.roomColor=t.roomColor,this.frameColor=t.frameColor,this.enableSelected=t.enableSelected,this.console=this.viewer.console,this.isValid=!0,this.unit=null,t.geometry.unit?this.unit="m"==t.geometry.unit||"Meter"==t.geometry.unit?"m":"mm":this.unit=this.viewer.globalUnitUtil.getGlobalUnit(),P(this),this.toleranceType={STRICT:"STRICT",ORDINARY:"ORDINARY",LENIENT:"LENIENT"},this.tolerence=.25;let i=this.geometry.boundary,n=this.geometry.grid,o=this.geometry.height,s=this.geometry.offset;if(i){if("String"===Object.prototype.toString.call(i).slice(8,-1)&&(i=JSON.parse(i)),i.outer){let e=[];if(i.outer.map((t=>{e.push([Number(t.x),Number(t.y),Number(t.z)])})),i.inner&&i.inner.length>0){let t=[];i.inner.map((e=>{let i=[];e.map((e=>{i.push([Number(e.x),Number(e.y),Number(e.z)])})),t.push(i)})),i=this.viewer.createBoundary(e,t)}else i=this.viewer.createBoundary(e)}}else if(n){let e=n.ids,t=n.fileId;const o=this.viewer.getViewer().getScene(),s=this.modelId||this.viewer.getDefaultModel().modelId;t&&t!=s||(t="default");const r=CLOUD.AxisGridManager.getInstance(o,s);if(!r.mapFileIdGridjson[t])return this.console.warn("createRoomByAxisGrids - 请先加载对应轴网,再调用接口."),void(this.isValid=!1);let a=r.getPartitionByAxisGrids(t,e),l=[],h=(new THREE.Matrix4).fromArray(this.viewer.getModel(s)._getModelTransformation()).invert();for(let e=0;e<a.length;e++)l.push(a[e].clone().applyMatrix4(h));a=l;let d=[];if(!(a&&a.length>0))return this.console.warn("createRoomByAxisGrids - 所选轴线未形成闭合区域,或传入了多余轴线."),void(this.isValid=!1);{a.forEach((e=>{d.push([e.x,e.y,e.z])}));let e=this.viewer.createBoundary(d),t=this.viewer.globalUnitUtil.getDefaultUnit(),n=this.unit;i=this.viewer.globalUnitUtil.excute(e,t,n,["offsetZ","x","y","z"])}}if(o)o=o;else if(s&&s.length>=2){var r=s[0];o=s[1]-s[0];var a=i.clone?i.clone():JSON.parse(JSON.stringify(i));if(i.roomInnerBoundary&&(a.roomInnerBoundary=JSON.parse(JSON.stringify(i.roomInnerBoundary))),a.loops&&a.loops.length>0)for(var l=a.loops[0],h=l.length,d=0;d<h;++d)for(var c=l[d].length,u=0;u<c;++u)l[d][u].z+=r;else a.offsetZ+=r;i=a}i=this.translateForUnit(i,["offsetZ","x","y","z"]),o=this.translateForUnit(o);var g=this.roomId||e.Web.Lang.Utility.UUID.createUUID();this.roomId=g;var p=this.roomColor||new e.Web.Graphics.Color(3,71,177,.4),m=this.frameColor||new e.Web.Graphics.Color(3,71,177,1);this.roomInfo={faceColor:p,frameColor:m,id:g,boundary:i,offset:[i.offsetZ||0,(i.offsetZ||0)+o],height:o,enableSelected:this.enableSelected}}bindRoomByModelId(e){if(!e||!this.viewer.getModel(e))return void this.console.warn(`Invalid modelId [${e}]`);const t=this.viewer.getViewer(),i=CLOUD.ExtrudeBodyManager.getInstance(t);if(!i.getNode(this.roomId))return void this.console.warn(`Invalid roomId [${this.roomId}]`);let n=i.getBindedModelId(this.roomId);n&&i.unbindModel(this.roomId,n),i.bindModel(this.roomId,e),this.modelId=e,this.viewer.render()}enableDepthTest(e){const t=this.viewer.getViewer();CLOUD.ExtrudeBodyManager.getInstance(t).enableDepthTest([this.roomId],e),this.viewer.render()}getArea(){let e={id:this.roomId,unit:"m2",value:null},t=this.getCustomizedRoom().roomBoundary,i=this.viewer._opt.unit||this.viewer.getDefaultUnit();return e.value=Math.abs(THREE.ShapeUtils.area(t)),"Meter"!==this.viewer.globalUnitUtil.unitMap[i]&&(e.unit="mm2"),e}getOldBoundary(){let e=new Array,t=this.getCustomizedRoom().roomBoundary,i=this.getCustomizedRoom().offsetZ;for(let n=0,o=t.length;n<o;n++){let o=new Array;o.push(t[n].x),o.push(t[n].y),o.push(i),e.push(o)}return e}getBoundary(){let e={},t=this.getCustomizedRoom().roomBoundary,i=this.getCustomizedRoom().offsetZ,n=[];for(let e=0,o=t.length;e<o-1;e++)n.push({x:t[e].x,y:t[e].y,z:i});e.outer=n;let o=this.getCustomizedRoom().roomInnerBoundary;if(o&&o.length>0){let t=[];o.map((e=>{let n=[];for(let t=0;t<e.length-1;t++)n.push({x:e[t].x,y:e[t].y,z:i});t.push(n)})),e.inner=t}return e}getComponents(e,t,i){null==e&&(e=this.toleranceType.ORDINARY),null==t&&(t=this.toleranceType.STRICT);let n=[],o=this.getAllComponentIds();for(const i in o)for(const s of o[i]){let o=this.viewer.globalUnitUtil.revertBBox(this.viewer.getViewer().getComponentInfoByUserId(s,i).boundingBox);this.roomContains(o,e,t)&&n.push(s)}return i&&i(n),n}getHeight(){return this.roomInfo.height}getRoomColor(){var t=this.viewer.getViewer(),i=CLOUD.ExtrudeBodyManager.getInstance(t).getNodeColorById(this.roomId);return new e.Web.Graphics.Color(i.red,i.green,i.blue,i.alpha)}getRoomFrameColor(){var t=this.viewer.getViewer(),i=CLOUD.ExtrudeBodyManager.getInstance(t).getWireframeColorById(this.roomId);return new e.Web.Graphics.Color(i.red,i.green,i.blue,i.alpha)}getProperty(e){let t=this.modelId||this.viewer.getDefaultModel().modelId;this.viewer.getModel(t)._getMetaDataManager().getRoomProperty(this.roomId,(t=>{t?(t.boundary&&(t.boundary=JSON.parse(t.boundary)),t=this.viewer.globalUnitUtil.revertTranslate(t,["area","x","y","z","perimeter"]),(t=this.viewer.globalUnitUtil.revertTranslate(t,["area"])).boundary=JSON.stringify(t.boundary),e&&e(t)):e&&e(t)}))}isPointInside(e,t){!1!==t&&(t=!0);let{roomBoundary:i,roomInnerBoundary:n}=this.getCustomizedRoom(),o=[],s=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId),r=this.viewer.getViewer().getModelManager().getModel(s).transformMatrix.clone(),a=new THREE.Vector3,l=new THREE.Quaternion,h=new THREE.Vector3;r.decompose(a,l,h),a=this.viewer.globalUnitUtil.revertVector(a),r.compose(a,l,h);for(let e=0;e<i.length;e++){let t=new THREE.Vector3(i[e].x,i[e].y,0).clone().applyMatrix4(r);o.push({x:t.x,y:t.y})}if(i=o,n&&newInnerBoundary.length>0){let e=[];for(let t=0;t<n.length;t++){let i=[];for(let e=0;e<n[t].length;e++){let o=new THREE.Vector3(n[t][e].x,n[t][e].y,0).clone().applyMatrix4(r);i.push({x:o.x,y:o.y})}e.push(i)}n=e}if(!this.containsInBoundary(e,i,t))return!1;if(n&&n.find((i=>this.containsInBoundary(e,i,t))))return!1;let d=Number(e.z.toFixed(10)),c=this.getRoomBoundingBox(),u=Number(c.min.z.toFixed(10)),g=Number(c.max.z.toFixed(10));return t?d>u&&d<g:d>=u&&d<=g}setBoundary(e,t){if(!this.roomManager)return;this.roomManager.clearRoomsById([this.roomId],!1);if("String"===Object.prototype.toString.call(e).slice(8,-1)&&(e=JSON.parse(e)),e.outer){let t=[];if(e.outer.map((e=>{t.push([e.x,e.y,e.z])})),e.inner&&e.inner.length>0){let i=[];e.inner.map((e=>{let t=[];e.map((e=>{t.push([e.x,e.y,e.z])})),i.push(t)})),e=this.viewer.createBoundary(t,i)}else e=this.viewer.createBoundary(t)}t&&(this.unit="m"==t?"m":"mm",e=this.translateForUnit(e,["offsetZ","x","y","z"])),this.roomInfo.boundary=e,this.roomInfo.offset=[e.offsetZ||0,(e.offsetZ||0)+this.roomInfo.height],this.roomManager.addRoom(this),CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).applySelection(),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setHeight(e,t){if(!this.roomManager)return;this.roomManager.clearRoomsById([this.roomId],!1),t&&(this.unit="m"==t?"m":"mm",e=this.translateForUnit(e));let i=this.roomInfo.boundary.offsetZ;this.roomInfo.height=e,this.roomInfo.offset=[i||0,(i||0)+e],this.roomManager.addRoom(this),CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).applySelection(),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setRoomColor(e){var t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()),i=t.createMaterial({color:parseInt(e.getHEX(),16),transparent:!0,opacity:e.getAlpha()});this.roomInfo.faceColor=e;var n=t.createMaterial({color:parseInt(this.roomInfo.frameColor.getHEX(),16),opacity:this.roomInfo.frameColor.getAlpha()});t.setNodeMaterial(this.roomId,i,n),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}setRoomFrameColor(e){var t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()),i=t.createMaterial({color:parseInt(this.roomInfo.faceColor.getHEX(),16),transparent:!0,opacity:this.roomInfo.faceColor.getAlpha()}),n=t.createMaterial({color:parseInt(e.getHEX(),16),opacity:e.getAlpha()});this.roomInfo.frameColor=e,t.setNodeMaterial(this.roomId,i,n),this.viewer.render(),this.roomModelManager&&this.updateSolidInfo()}updateSolidInfo(e){const t=e?"Meter"==e.unit||"m"==e.unit?"m":"mm":this.unit?"Meter"==this.unit||"m"==this.unit?"m":"mm":"Meter"==this.viewer.globalUnitUtil.getGlobalUnit()||"m"==this.viewer.globalUnitUtil.getGlobalUnit()?"m":"mm",i={modelId:this.modelId,modelType:this.viewer.getModel(this.modelId)._data.modelType,sectionId:this.roomId,conditions:e?e.conditions:this.conditions,section:{id:this.roomId,name:e?e.name:this.name,unit:t,color:e?e.color:this.getRoomColor(),frameColor:e?e.frameColor:this.getRoomFrameColor(),geometry:{type:"extrusion",height:e?e.height:this.getHeight(),boundary:e?e.boundary:[{lineType:"Line",points:this.getBoundary().outer}]}}};this._solidInfo=i}translateForUnit(e,t){if(this.unit){let i=this.viewer.globalUnitUtil.getGlobalUnit();return this.viewer.globalUnitUtil.excute(e,this.unit,i,t)}return e}getAllComponentIds(){return this.viewer.getViewer().getAllModelUserIds()}getCustomizedRoom(){let e=this.roomInfo;if(e.boundary&&"user"!=e.boundary.belong){let t=[],i=[],n=e.boundary;for(let e=0;e<n.loops.length;e++){let o=n.loops[e],s=[];for(const e of o)s.push([e[0].x,e[0].y,e[0].z]);0==e?t=s:s.length>2&&i.push(s)}let o=this.viewer.createBoundary(t,i);return o.offset=[o.offsetZ,o.offsetZ+e.height],o}return e.boundary.offset=e.offset,e.boundary}isContainsObjectId(e,t,i){null==t&&(t=this.toleranceType.ORDINARY),null==i&&(i=this.toleranceType.STRICT);let n=this.viewer.globalUnitUtil.revertBBox(this.viewer.getViewer().getComponentInfoByUserId(e).boundingBox);return this.roomContains(n,t,i)}roomContains(e,t,i){let n=this.isRoomContainBoundingBoxByZ(e,i);if(0==n)return n;let o=this.isRoomBoundingBoxContainBoundingBoxByXY(e,t);if(0==o)return o;let s=this.isRoomBoundaryContainBoundingBoxByXY(e,t);return 0!=s||s}isRoomContainBoundingBoxByZ(e,t){let i=this.getRoomBoundingBox(),n=i.min.z,o=i.max.z,s=e.max.z,r=e.min.z,a=this.tolerence,l=this.viewer._opt.unit||this.viewer.getDefaultUnit();if("Meter"===this.viewer.globalUnitUtil.unitMap[l]&&(a/=1e3),t==this.toleranceType.STRICT)return r>=n-a&&s<=o+a;if(t==this.toleranceType.ORDINARY){let e=(r+s)/2;return this.isBetween(e,n,o)&&(this.isBetween(r,n,o)||this.isBetween(s,n,o))}return t==this.toleranceType.LENIENT?r<=o+a&&s>=n-a:void 0}isRoomBoundingBoxContainBoundingBoxByXY(e,t){let i=this.getRoomBoundingBox(),n=i.min.x,o=i.max.x,s=i.min.y,r=i.max.y,a=e.min.x,l=e.max.x,h=e.min.y,d=e.max.y,c=this.tolerence,u=this.viewer._opt.unit||this.viewer.getDefaultUnit();return"Meter"===this.viewer.globalUnitUtil.unitMap[u]&&(c/=1e3),t==this.toleranceType.STRICT?a>=n-c&&l<=o+c&&h>=s-c&&d<=r+c:t==this.toleranceType.ORDINARY||t==this.toleranceType.LENIENT?a<=o+c&&l>=n-c&&h<=r+c&&d>=s-c:void 0}isRoomBoundaryContainBoundingBoxByXY(e,t){let i=this.toFivePos(e),n=this.getCustomizedRoom().roomBoundary,o=[],s=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId);for(let e=0;e<n.length;e++){let t=this.viewer.getViewer().getModelManager().getModel(s).transformMatrix.clone(),i=new THREE.Vector3,r=new THREE.Quaternion,a=new THREE.Vector3;t.decompose(i,r,a),i=this.viewer.globalUnitUtil.revertVector(i),t.compose(i,r,a);let l=new THREE.Vector3(n[e].x,n[e].y,0).clone().applyMatrix4(t);o.push({x:l.x,y:l.y})}n=o;let r=0;for(let e=0;e<i.length;e++){const t=i[e];this.containsInBoundary(t,n)&&r++}let a=!1;return t==this.toleranceType.STRICT?a=5==r:t==this.toleranceType.ORDINARY?a=r>=3:t==this.toleranceType.LENIENT&&(a=r>=1),a}getRoomBoundingBox(){let e=this.getCustomizedRoom(),t=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getBindedModelId(this.roomId),i=e.boundingBox,n=e.offset;i.min.z=n[0],i.max.z=n[1];let o=this.viewer.getViewer().getModelManager().getModel(t).transformMatrix.clone(),s=new THREE.Vector3,r=new THREE.Quaternion,a=new THREE.Vector3;return o.decompose(s,r,a),s=this.viewer.globalUnitUtil.revertVector(s),o.compose(s,r,a),(new THREE.Box3).setFromPoints([new THREE.Vector3(i.min.x,i.min.y,i.min.z),new THREE.Vector3(i.max.x,i.max.y,i.max.z)]).clone().applyMatrix4(o)}toFivePos(e){let t=[];return t.push(new THREE.Vector2(e.min.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.min.y)),t.push(new THREE.Vector2(e.max.x,e.max.y)),t.push(new THREE.Vector2(e.min.x,e.max.y)),t.push(new THREE.Vector2((e.min.x+e.max.x)/2,(e.min.y+e.max.y)/2)),t}containsInBoundary(e,t,i){let n=!1;for(let i=0;i<t.length-1;i++)if(this.isOnSegment(e,t[i],t[i+1])){n=!0;break}if(n)return!i;for(var o=e.x,s=e.y,r=!1,a=0,l=t.length-1;a<t.length;l=a++){var h=t[a].x||t[a][0],d=t[a].y||t[a][1],c=t[l].x||t[l][0],u=t[l].y||t[l][1];d>s!=u>s&&o<(c-h)*(s-d)/(u-d)+h&&(r=!r)}return r}isOnSegment(e,t,i){if(e.x>Math.max(t.x,i.x)||e.x<Math.min(t.x,i.x))return!1;if(e.y>Math.max(t.y,i.y)||e.y<Math.min(t.y,i.y))return!1;if(t.x!=i.x){let n=(i.y-t.y)/(i.x-t.x),o=i.y-n*i.x;if(n*e.x+o==e.y)return!0}else if(e.x==t.x)return!0;return!1}isBetween(e,t,i){let n=this.tolerence;return e<=i+n&&e>=t-n}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms").RoomConfig=class{constructor(){this.viewer=null,this.roomId=null,this.modelId=null,this.geometry=null,this.roomColor=null,this.frameColor=null,this.enableSelected=!0}},function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");t.RoomManager=class{constructor(e){if(this.viewer=e.viewer,this.viewer.roomManager&&!e.modelMode)return this.viewer.roomManager;this.rooms=[],!e.modelMode&&(this.viewer.roomManager=this),P(this)}addRoom(e){let t=!1;for(let i=0;i<this.rooms.length;i++)if(this.rooms[i].roomId==e.roomId){t=!0;break}if(t)return;if(!e.isValid)return;var i=CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer());let{id:n,boundary:o,height:s,faceColor:r,frameColor:a,enableSelected:l}={...e.roomInfo};this.setRoomSelectableById([n],l);var h=i.createMaterial({color:parseInt(r.getHEX(),16),transparent:!0,opacity:r.getAlpha()}),d=i.createMaterial({color:parseInt(a.getHEX(),16),opacity:a.getAlpha()});let c=this.viewer.globalUnitUtil.translate(o,["offsetZ","x","y","z"]),u=this.viewer.globalUnitUtil.translate(s);i.addNode(n,c,u,h,d),c.offsetZ&&(o.offsetZ=this.viewer.globalUnitUtil.revertTranslate(c.offsetZ));let g=e.modelId||this.viewer.getDefaultModel().modelId;i.bindModel(n,g),this.viewer.getViewer().modelManager.updateSceneBoundingBox(),this.viewer.updateSceneBoundingBox(!1),this.rooms.push(e),e.roomManager=this}clearAllRooms(){var e=this.viewer.getViewer();CLOUD.ExtrudeBodyManager.getInstance(e).clearNodes(),this.rooms=[]}clearRoomsById(e,t=!0){var i=this.viewer.getViewer(),n=CLOUD.ExtrudeBodyManager.getInstance(i);if(e&&e.length>0)for(var o=0;o<e.length;o++){if(t){const t=this.getRoomById(e[o]);t&&t.drawTool&&(t.solidToolbar&&t.solidToolbar.getEventManager()&&t.solidToolbar.getEventManager().fireEvent("Deleted",t),t.drawTool.exit())}n.removeNodeById(e[o]);for(let t=0;t<this.rooms.length;t++)if(e[o]==this.rooms[t].roomId){this.rooms.splice(t,1);break}}}getAllRooms(){return[].concat(this.rooms)}getRoomById(e){let t=null;for(let i=0;i<this.rooms.length;i++)if(this.rooms[i].roomId==e){t=this.rooms[i];break}return t}getRoomsByComponentId(e,t,i,n){let o=[],s=this.rooms;for(let n=0;n<s.length;n++)s[n].isContainsObjectId(e,t,i)&&o.push(s[n]);return n&&n(o),o}hideAllRooms(){var e=this.viewer.getViewer();CLOUD.ExtrudeBodyManager.getInstance(e).hideAllNodes()}hideRoomsById(e){var t=this.viewer.getViewer(),i=CLOUD.ExtrudeBodyManager.getInstance(t);if(e&&e.length>0)for(var n=0;n<e.length;n++){i.setNodeVisibleById(e[n],!1);const t=this.getRoomById(e[n]);t&&t.drawTool&&t.drawTool.hide()}}showAllRooms(){var e=this.viewer.getViewer();CLOUD.ExtrudeBodyManager.getInstance(e).showAllNodes()}showRoomsById(e){var t=this.viewer.getViewer(),i=CLOUD.ExtrudeBodyManager.getInstance(t);if(e&&e.length>0)for(var n=0;n<e.length;n++){i.setNodeVisibleById(e[n],!0);const t=this.getRoomById(e[n]);t&&t.drawTool&&t.drawTool.show()}}setRoomSelectableById(e,t){if(!Array.isArray(e))return;CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).setRoomSelectableById(e,t)}getRoomSelectableById(e){return CLOUD.ExtrudeBodyManager.getInstance(this.viewer.getViewer()).getRoomSelectableById(e)}update(){}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");t.RoomManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Rooms");class i extends e.Bimface.Plugins.Rooms.RoomManager{constructor(e){super(e),this.modelRooms=[],this.modelId=e.modelId,this.config=e,this.viewer=e.viewer,this.viewerManager=e.viewer.getRoomManager(),P(this)}initRooms(t){if(!t)return;const i=this;t.map((t=>{t.modelId==i.modelId&&t.sections.map((n=>{const o=i.modelRooms.find((e=>e.roomId==n.id));if(o)return delete o.roomModelManager,o.setBoundary({outer:n.geometry.boundary[0].points}),o.setHeight(n.geometry.height),o.setRoomColor(new e.Web.Graphics.Color(n.color.red,n.color.green,n.color.blue,n.color.alpha)),o.setRoomFrameColor(new e.Web.Graphics.Color(n.frameColor.red,n.frameColor.green,n.frameColor.blue,n.frameColor.alpha)),void(o.roomModelManager=i);const s=new e.Bimface.Plugins.Rooms.RoomConfig;s.viewer=i.viewer,s.roomId=n.id,s.modelId=i.modelId,s.geometry={type:"extrusion",boundary:{outer:n.geometry.boundary[0].points},height:n.geometry.height,unit:n.unit},s.roomColor=new e.Web.Graphics.Color(n.color.red,n.color.green,n.color.blue,n.color.alpha),s.frameColor=new e.Web.Graphics.Color(n.frameColor.red,n.frameColor.green,n.frameColor.blue,n.frameColor.alpha);const r=new e.Bimface.Plugins.Rooms.Room(s);r.name=n.name,r.conditions=t.conditions,i.addRoom(r),r.roomModelManager=i}))}))}addRoom(e){this.modelRooms.push(e),this.viewerManager.addRoom(e),e.bindRoomByModelId(this.modelId)}getAllRoomIds(){return this.modelRooms.map((e=>e.roomId))}getAllRooms(){return this.modelRooms}hideAllRooms(){const e=this.getAllRoomIds();this.viewerManager.hideRoomsById(e)}showAllRooms(){const e=this.getAllRoomIds();this.viewerManager.showRoomsById(e)}clearAllRooms(){const e=this.getAllRoomIds();this.viewerManager.clearRoomsById(e)}clearRoomsById(e){this.viewerManager.clearRoomsById(e)}getRoomById(e){return this.viewerManager.getRoomById(e)}getRoomsByComponentId(e,t,i,n){return this.viewerManager.getRoomsByComponentId(e,t,i,n)}hideRoomsById(e){this.viewerManager.hideRoomsById(e)}showRoomsById(e){this.viewerManager.showRoomsById(e)}convertToClipperData(e){const t="Meter"==this.viewer.getGlobalUnit();return e.map((e=>{e.X=t?1e3*e.x:e.x,e.Y=t?1e3*e.y:e.y})),e}reConvertClipperData(e,t){const i="Meter"==this.viewer.getGlobalUnit();return e.map((e=>{e.x=i?e.X/1e3:e.X,e.y=i?e.Y/1e3:e.Y,e.z=t.getBoundary().outer[0].z})),e}loadAndCalculateOverLap(e,t){this.calculateOverlapArea(e,t)}calculateOverlapArea(e,t="plus"){const i=this.viewerManager.getRoomById(e);this.modelRooms.filter((e=>Math.abs(e.getBoundary().outer[0].z-i.getBoundary().outer[0].z)<1e-4)).map((n=>{if(n.roomId!==e){let e,o,s=new ClipperLib.Paths;"minus"==t?(e=this.convertToClipperData(n.getBoundary().outer),o=this.convertToClipperData(i.getBoundary().outer)):(o=this.convertToClipperData(n.getBoundary().outer),e=this.convertToClipperData(i.getBoundary().outer));const r=new ClipperLib.Clipper;r.AddPath(e,ClipperLib.PolyType.ptSubject,!0),r.AddPath(o,ClipperLib.PolyType.ptClip,!0),r.Execute(ClipperLib.ClipType.ctDifference,s,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),"minus"==t?n.setBoundary({outer:this.reConvertClipperData(s[0],n)},this.config.unit):i.setBoundary({outer:this.reConvertClipperData(s[0],n)},this.config.unit)}}))}}t.RoomModelManager=i}(),function(){var t="Bimface.Plugins.Material.Material",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Material");n.Material=class{constructor(n){var o=this;if(i.send(t,"bf_c_mat_newMat"),n)if(P(this),this.id=n.id,this.offset=n.offset,this.rotation=n.rotation,this.scale=n.scale,this.isReverse=n.reverse,this.src=n.src,this.canvas=n.canvas,this.viewer=n.viewer,this.callback=n.callback,this.textureType=n.textureType,this._width=512,this._height=512,this.changedWidth=null,this.changedHeight=null,this.meshGroupArray=new Array,Object.defineProperty(o,"width",{get:function(){return o._width},set:function(e){o._width!=e&&(o._width=e,null!=o.changedWidth&&o.changedWidth())}}),Object.defineProperty(o,"height",{get:function(){return o._height},set:function(e){o._height!=e&&(o._height=e,null!=o.changedHeight&&o.changedHeight())}}),this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)){switch(this.transparent=n.transparent,this.material=new y.CloudStandardMaterial,this.materialV3=new y.CloudStandardBatchedMaterialV3,this.materialV3.bumpMap=null,this.materialV3.packingMatMap=null,this.material.metalness=this.materialV3.metalness=.5,this.material.roughness=this.materialV3.roughness=.5,this.material.name=this.materialV3.name=this.id,n.side){case THREE.FrontSide:this.material.side=this.materialV3.side=THREE.FrontSide;break;case THREE.BackSide:this.material.side=this.materialV3.side=THREE.BackSide;break;case THREE.DoubleSide:this.material.side=this.materialV3.side=THREE.DoubleSide;break;default:console.warn("the side para is invalid,default frontSide"),this.material.side=this.materialV3.side=THREE.FrontSide}"image"==this.textureType&&(this.canvas?this._loadCanvasTexture(this.callback):this._loadTexture(this.callback)),"video"==this.textureType&&this._loadVideoTexture(this.callback),"live"==this.textureType&&this._loadLiveTexture(this.callback),this.materialV3Map={},this.objectList={},this.objectData={},this.extObjArray=new Array,this.hasExtID=!1,this.extObjMng=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this.viewer)}else console.log("ERROR::viewer must not be empty or viewer2d.");else console.log("ERROR::materialConfig must not be empty.")}_updateTextureScale(e){const t=[...this.scale];this.isReverse&&(t[0]=-t[0]),e.repeat.fromArray(t)}_loadTexture(e,t){if(!this.src)return;var i=new THREE.Texture,n=this;function o(t){i.image=y.MaterialUtil.ensurePowerOfTwo(t),i.needsUpdate=!0,null!=t.width&&""!=t.width&&(n.width=t.width),null!=t.height&&""!=t.height&&(n.height=t.height),i.offset.fromArray(n.offset),i.rotation=THREE.Math.degToRad(n.rotation),n._updateTextureScale(i),i.colorSpace=THREE.SRGBColorSpace,y.MaterialUtil.updateUVMatrix2(i),i.wrapS=THREE.RepeatWrapping,i.wrapT=THREE.RepeatWrapping,n.enableTransparent(n.transparent),n.material.needsUpdate=!0,n.materialV3.needsUpdate=!0,n._updateMaterialMap(),e&&e(i)}n.material.map=i,n.materialV3.map=n.material.map;const s=this.viewer.getViewer().modelManager.getImageByUrl(this.src);s?o(s):(new TEST.CryptoResourceLoader).loadURL(this.src,(e=>{var i=new Blob([e],{type:"jpeg"});let n=new Image;n.onload=function(){o(n)},n.onerror=e=>{console.log(e),t&&t(e)},n.src=URL.createObjectURL(i)}),null,(e=>{console.log(e),t&&t(e)}))}_loadVideoTexture(e){if(!this.src)return;var t=this;let i=document.createElement("video"),n=new THREE.VideoTexture(i);t.material.map=n,t.materialV3.map=n,t.video=i,i.crossOrigin="anonymous",i.addEventListener("loadedmetadata",(function(i){null!=n.image.videoWidth&&""!=n.image.videoWidth&&(t.width=n.image.videoWidth),null!=n.image.videoHeight&&""!=n.image.videoHeight&&(t.height=n.image.videoHeight),n.offset.fromArray(t.offset),n.rotation=THREE.Math.degToRad(t.rotation),t._updateTextureScale(n),y.MaterialUtil.updateUVMatrix2(n),n.wrapS=THREE.ClampToEdgeWrapping,n.wrapT=THREE.ClampToEdgeWrapping,n.minFilter=THREE.LinearFilter,n.magFilter=THREE.LinearFilter,n.needsUpdate=!0,e&&e()}),!1),i.preload="auto",i.autoload=!0,i.autoplay=!0,i.loop=!0,i.muted=!1,i.src=this.src}_loadLiveTexture(e){this.src&&$.loadThirdPartyByName("Video",(()=>{if(!videojs||"function"!=typeof videojs)return void console.warn("videoJs is not loaded!");let t=document.createElement("video"),i=document.createElement("source");i.type="application/x-mpegURL",i.src=this.src,t.appendChild(i),t.id=this.src,t.crossOrigin="anonymous",this.video=t;let n=videojs(t,void 0,(()=>{})).play();void 0!==n&&n.then((()=>{let i=new THREE.VideoTexture(t);null!=i.image.videoWidth&&""!=i.image.videoWidth&&(this.width=i.image.videoWidth),null!=i.image.videoHeight&&""!=i.image.videoHeight&&(this.height=i.image.videoHeight),i.offset.fromArray(this.offset),i.rotation=THREE.Math.degToRad(this.rotation),this._updateTextureScale(i),y.MaterialUtil.updateUVMatrix2(i),i.wrapS=THREE.ClampToEdgeWrapping,i.wrapT=THREE.ClampToEdgeWrapping,i.minFilter=THREE.LinearFilter,i.magFilter=THREE.LinearFilter,this.material.map=i,this.materialV3.map=i,this.video=t,i.needsUpdate=!0,e&&e()})),t.addEventListener("loadedmetadata",(e=>{}),!1),t.preload="auto",t.autoload=!0,t.autoplay=!1,t.loop=!0,t.muted=!0,t.src=this.src}))}_loadCanvasTexture(e){if(this.canvas){var t=new THREE.CanvasTexture(this.canvas);null!=this.canvas.width&&""!=this.canvas.width&&(this.width=this.canvas.width),null!=this.canvas.height&&""!=this.canvas.height&&(this.height=this.canvas.height),t.offset.fromArray(this.offset),t.rotation=THREE.Math.degToRad(this.rotation),this._updateTextureScale(t),y.MaterialUtil.updateUVMatrix2(t),t.colorSpace=THREE.SRGBColorSpace,t.wrapS=THREE.RepeatWrapping,t.wrapT=THREE.RepeatWrapping,this.material.map=t,this.materialV3.map=t,this.enableTransparent(this.transparent),e&&e(t)}}enableTransparent(e){if(this.transparent=e,this.transparent?(this.material.transparent=!0,this.material.alphaMap=this.material.map,this.material.alphaTest=.01,this.materialV3.transparent=!0,this.materialV3.alphaMap=this.materialV3.map,this.materialV3.alphaTest=.01):(this.material.transparent=!1,this.material.alphaMap=null,this.material.alphaTest=0,this.materialV3.transparent=!1,this.materialV3.alphaMap=null,this.materialV3.alphaTest=0),this.material.needsUpdate=!0,this.materialV3.needsUpdate=!0,this.materialV3.bindMaterial)for(let e=0;e<this.materialV3.bindMaterial.length;++e)this.materialV3.bindMaterial[e].transparent=this.materialV3.transparent,this.materialV3.bindMaterial[e].alphaMap=this.materialV3.alphaMap,this.materialV3.bindMaterial[e].alphaTest=this.materialV3.alphaTest,this.materialV3.bindMaterial[e].needsUpdate=!0;this.meshGroupArray.forEach((e=>{e.traverse((e=>{1==e.isMesh&&"cloudStandardV3"==e.material.type&&(this.transparent?(this.materialV3Map[e.material.uuid].transparent=!0,this.materialV3Map[e.material.uuid].alphaMap=this.material.map,this.materialV3Map[e.material.uuid].alphaTest=.01):(this.materialV3Map[e.material.uuid].transparent=!1,this.materialV3Map[e.material.uuid].alphaMap=null,this.materialV3Map[e.material.uuid].alphaTest=0),this.materialV3Map[e.material.uuid].needsUpdate=!0)}))}))}overrideComponentsMaterialById(e,n){if(i.send(t,"bf_c_mat_override"),!(e instanceof Array))return void console.log("ERROR::ids should be Array");let o=n;if(!o)if(this.extObjMng.getAllObjectIds().indexOf(e[0])>-1)o=this.extObjMng.modelId,this.hasExtID=!0;else{o=this.viewer.getDefaultModel().modelId}this.objectList[o]||(this.objectList[o]=[]),this.objectList[o].push(...e);const s=this.viewer.getViewer(),r=s.getFilter(),a=s.getModelManager().getModel(o);if(!a)return;y.BimTilesVersionControl.isVersion_3(a.dataVersion)?r.addToOverrideListByMaterialAndId(e,this.materialV3,o):r.addToOverrideListByMaterialAndId(e,this.material,o)}_fillMaterialMap(e){let t=!1;return e.traverse((e=>{1==e.isMesh&&"cloudStandardV3"==e.material.type&&(this.materialV3Map[e.material.uuid]=e.material,this.materialV3Map[e.material.uuid].map=this.material.map,this.materialV3Map[e.material.uuid].bumpMap=null,this.materialV3Map[e.material.uuid].packingMatMap=null,this.materialV3Map[e.material.uuid].metalness=.5,this.materialV3Map[e.material.uuid].roughness=.5,this.materialV3Map[e.material.uuid].needsUpdate=!0,t=!0)})),t}_updateMaterialMap(){for(const e in this.materialV3Map)this.materialV3Map[e].needsUpdate=!0}overrideComponentsMaterialByObjectData(e,n){if(i.send(t,"bf_c_mat_override"),!(e instanceof Array))return void console.log("ERROR::conditions should be Array");let o=n;if(!o)if(this.extObjMng.getAllObjectIds().indexOf(e[0])>-1)o=this.extObjMng.modelId,this.hasExtID=!0;else{o=this.viewer.getDefaultModel().modelId}this.objectData[o]||(this.objectData[o]=[]);const s=this.viewer.getViewer(),r=s.getModelManager().getModel(o),a=y.BimTilesVersionControl.isVersion_3(r.dataVersion),l=s.getFilter();a?(this.objectData[o]||(this.objectData[o]=[]),this.objectData[o].push(...e),l.addToOverrideListByMaterial(e,this.materialV3,o)):(this.objectData[o]||(this.objectData[o]=[]),this.objectData[o].push(...e),l.addToOverrideListByMaterial(e,this.material,o))}clearOverrideComponentsMaterial(e){let t=e;if(!t)if(this.hasExtID)t=this.extObjMng.modelId;else{t=this.viewer.getDefaultModel().modelId}const i=this.viewer.getViewer(),n=i.getFilter(),o=i.getModelManager().getModel(t),s=y.BimTilesVersionControl.isVersion_3(o.dataVersion),r=this.objectList[t],a=this.objectData[t];s?(r&&(r.length&&n.addToOverrideListByMaterialAndId(r,null,t),delete this.objectList[t]),a&&(a.length&&n.addToOverrideListByMaterial(a,null,t),delete a[t])):(r&&(r.length&&n.addToOverrideListByMaterialAndId(r,null,t),delete this.objectList[t]),a&&(a.length&&n.addToOverrideListByMaterial(a,null,t),delete this.objectData[t]))}getId(){return i.send(t,"bf_c_mat_getId"),this.id}getOffset(){return this.offset}getRotation(){return this.rotation}getScale(){return this.scale}getSrc(){return this.src}getCanvas(){return this.canvas}setOffset(e){if(e instanceof Array&&2==e.length){if(this.offset=e,this.material&&this.material.map&&(this.material.map.offset.fromArray(e),y.MaterialUtil.updateUVMatrix2(this.material.map),this.meshGroupArray.forEach((t=>{t.traverse((t=>{1==t.isMesh&&"cloudStandardV3"==t.material.type&&(this.materialV3Map[t.material.uuid].map.offset.fromArray(e),y.MaterialUtil.updateUVMatrix2(this.materialV3Map[t.material.uuid].map))}))})),this.material.needsUpdate=!0,this.materialV3.needsUpdate=!0,this.materialV3.bindMaterial))for(let t=0;t<this.materialV3.bindMaterial.length;++t)this.materialV3.bindMaterial[t].map&&(this.materialV3.bindMaterial[t].map.offset.fromArray(e),y.MaterialUtil.updateUVMatrix2(this.materialV3.bindMaterial[t].map))}else console.log("ERROR::offset should be array of 2 elements")}setRotation(e){if(i.send(t,"bf_c_mat_setRotation"),this.rotation=e,this.material&&this.material.map&&(this.material.map.rotation=THREE.Math.degToRad(this.rotation),y.MaterialUtil.updateUVMatrix2(this.material.map),this.meshGroupArray.forEach((e=>{e.traverse((e=>{if(1==e.isMesh&&"cloudStandardV3"==e.material.type){this.materialV3Map[e.material.uuid].map.rotation;THREE.Math.degToRad(this.rotation),y.MaterialUtil.updateUVMatrix2(this.materialV3Map[e.material.uuid].map)}}))})),this.material.needsUpdate=!0,this.materialV3.needsUpdate=!0,this.materialV3.bindMaterial))for(let e=0;e<this.materialV3.bindMaterial.length;++e){if(!this.materialV3.bindMaterial[e].map)continue;let t=this.materialV3.bindMaterial[e].map.rotation;t=THREE.Math.degToRad(this.rotation),y.MaterialUtil.updateUVMatrix2(this.materialV3.bindMaterial[e].map)}}setScale(e){if(i.send(t,"bf_c_mat_setScale"),e instanceof Array&&2==e.length){if(this.scale=e,this.material&&this.material.map&&(this._updateTextureScale(this.material.map),y.MaterialUtil.updateUVMatrix2(this.material.map),this.meshGroupArray.forEach((e=>{e.traverse((e=>{if(1==e.isMesh&&"cloudStandardV3"==e.material.type){var t=this.materialV3Map[e.material.uuid].map;this._updateTextureScale(this.material.map),y.MaterialUtil.updateUVMatrix2(t)}}))})),this.material.map.needsUpdate=!0,this.material.needsUpdate=!0,this.materialV3.needsUpdate=!0,this.materialV3.bindMaterial))for(let e=0;e<this.materialV3.bindMaterial.length;++e){let t=this.materialV3.bindMaterial[e].map;t&&(this._updateTextureScale(t),y.MaterialUtil.updateUVMatrix2(t))}}else console.log("ERROR::scale should be array of 2 elements")}setSrc(e){this.src=e,"image"==this.textureType&&this._loadTexture(this.callback),"video"==this.textureType&&this._loadVideoTexture(this.callback)}setCanvas(e){this.canvas=e,this._loadCanvasTexture(this.callback)}reverse(){this.isReverse=!this.isReverse;const e=this.material.map;if(this.material&&e&&(this._updateTextureScale(e),y.MaterialUtil.updateUVMatrix2(e),this.meshGroupArray.forEach((e=>{e.traverse((e=>{if(1==e.isMesh&&"cloudStandardV3"==e.material.type){const t=this.materialV3Map[e.material.uuid].map;this._updateTextureScale(t),y.MaterialUtil.updateUVMatrix2(t)}}))})),e.needsUpdate=!0,this.material.needsUpdate=!0,this.materialV3.needsUpdate=!0,this.materialV3.bindMaterial))for(let e=0;e<this.materialV3.bindMaterial;++e){const t=this.materialV3.bindMaterial[e].map;t&&(this._updateTextureScale(t),y.MaterialUtil.updateUVMatrix2(t))}}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Material");t.MaterialConfig=class{constructor(){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.offset=[0,0],this.rotation=0,this.scale=[1,1],this.src=null,this.canvas=null,this.transparent=!1,this.side=0,this.viewer=null,this.callback=null,this.textureType="image",this.reverse=!1}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Material");i.MaterialContainer=class{constructor(){t.send("Bimface.Plugins.Material.MaterialContainer","bf_c_mat_newMatContainer"),this.materials={},P(this)}addMaterial(e){this.materials[e.id]=e}clear(){for(var e in this.materials)this.materials[e].clearOverrideComponentsMaterial();this.materials={}}removeMaterialById(e){this.materials[e]&&(this.materials[e].clearOverrideComponentsMaterial(),delete this.materials[e])}getAllMaterials(){return Object.values(this.materials)}getMaterialById(e){return this.materials[e]}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.AnimationContainer=class{constructor(){t.send("Bimface.Plugins.Animation.AnimationContainer","bf_c_animation_newContainer"),this.animations={},this._console=new e.Web.Common.Console,P(this)}addAnimation(e){this.animations[e.id]=e}clear(){for(var e in this._console.obsolete("AnimationContainer.clear","AnimationContainer.destroy or AnimationContainer.stop"),this.animations)this.animations[e].stop&&(this.animations[e].stop(),delete this.animations[e])}getAllAnimations(){return Object.values(this.animations)}getAnimationById(e){return this.animations[e]}removeAnimationById(e){this.animations[e]&&(this.animations[e].stop(),delete this.animations[e])}destroy(){for(var e in this.animations)this.animations[e].destroy&&(this.animations[e].destroy(),delete this.animations[e])}stop(){for(var e in this.animations)this.animations[e].stop&&(this.animations[e].stop(),delete this.animations[e])}}}(),function(){var t="Bimface.Plugins.Animation.FlowEffect",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");n.FlowEffect=class{constructor(e){i.send(t,"bf_c_flow_newFlow"),e?(this.material=e.material,this.speed=e.speed,this.viewer=e.viewer,this.id=e.id,this.viewer&&"Viewer3D"!==!this.viewer.viewerType?(this.animationId=0,P(this)):console.log("ERROR::viewer must not be empty or viewer2d.")):console.log("ERROR::flowEffectConfig must not be empty.")}getSpeed(){return this.speed}setSpeed(e){i.send(t,"bf_c_flow_setSpeed"),e instanceof Array&&2==e.length?this.speed=e:console.log("ERROR::speed should be array of 2 elements")}play(){var e=this;!function t(){e.animationId=requestAnimationFrame(t);var i=e.material.getOffset();e.material.setOffset([i[0]+e.speed[0],i[1]+e.speed[1]]),e.viewer.render()}()}stop(){cancelAnimationFrame(this.animationId)}getId(){return i.send(t,"bf_c_flow_id"),this.id}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation").FlowEffectConfig=class{constructor(){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.material=null,this.speed=[0,0],this.viewer=null}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.PathAnimation=class{constructor(i){t.send("Bimface.Plugins.Animation.FlowEffect","bf_c_animation_newPath"),i?(this.loop=i.loop,this.isPitchEnabled=i.isPitchEnabled,this.isYawEnabled=i.isYawEnabled,this.objectIds=i.objectIds.length>0?i.objectIds:i.objectNames,this.objectNames=i.objectNames,this.path=i.path instanceof e.Bimface.Plugins.Geometry.SplineCurve?i.path.curve:i.path,this.time=i.time,this.viewer=i.viewer,this.originYaw=i.originYaw,this.originPitch=i.originPitch,this.projectGround=!!i.isProjectGround&&i.isProjectGround,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.animationId=0,this.curvePos=0,this.initDirection=new THREE.Vector3(1,0,0),this.realGroundPath=null,this.projectGround&&this._genGroundPath(),this.viewer&&"Viewer3D"!==!this.viewer.viewerType?this.path?P(this):console.log("ERROR::path must not be empty"):console.log("ERROR::viewer must not be empty or viewer2d.")):console.log("ERROR::pathAnimationConfig must not be empty.")}getId(){return this.id}getLoop(){return this.loop}getObjectNames(){return this.objectNames}getObjectIds(){return this.objectIds}getPath(){return this.path}getPitch(){return this.isPitchEnabled}getYaw(){return this.isYawEnabled}getTime(){return this.time}getOriginYaw(){return this.originYaw}getOriginPitch(){return this.originPitch}setLoop(e){this.loop=e}setObjectsByName(e){this.objectNames=e,this.objectIds=e}setObjectsById(e){this.objectIds=e}setOriginPitch(e){this.originPitch=e}setOriginYaw(e){this.originYaw=e}setPitch(e){this.isPitchEnabled=e}setYaw(e){this.isYawEnabled=e}setTime(e){this.time=e}setProjectGround(e){this.projectGround=e,this._genGroundPath()}_genGroundPath(){if(!this.realGroundPath&&this.path){const e=new CLOUD.Raycaster;let t=new THREE.Vector3;const i=this.viewer.getViewer().cameraControl.getIntersectContext(null),n=new CLOUD.IntersectHelper(this.viewer.getViewer());e.camera=i.camera,e.viewportSize=i.viewportSize;let o=[];const s=this.viewer.externalComponentManager._getNodeGroup(),r=s.visible;s.visible=!1;const a=this.viewer.getViewer().getScene().getBoundingBox();this.path.getPoints(200).forEach((s=>{t.copy(s),t=this.viewer.getViewer().worldToDrawing(s),t.y=a.max.y+1,e.set(t,new THREE.Vector3(0,-1,0));let r=n.getObjectsByRaycaster(i,e,!0);if(0===r.length)return void o.push(s);let l=this.viewer.getViewer().drawingToWorld(r[0].point);o.push(l)})),this.realGroundPath=new THREE.CatmullRomCurve3(o),s.visible=r}}_setCameraAnimation(e,t,i){this.camera=e;var n=this.viewer.getViewer().getScene().getMatrixGlobal(),o=new THREE.Vector3(t,0,0);o.applyMatrix4(n),this._cameraDistance=o.x,this._cameraAngle=i<0?2*Math.PI+i:i}_controlCamera(e,t,i){if(this.camera){t.applyAxisAngle(i,this._cameraAngle);var n=this.viewer.getViewer().getScene().getMatrixGlobal();e.applyMatrix4(n),t.applyMatrix4(n),t.normalize(),this.camera.LookAt(e,t,this.camera.up,this._cameraDistance)}}play(t){if(!this.path||!this.viewer)return void console.log("ERROR::viewer or path must not be empty.");var i,n,o,s=this,r=new THREE.Quaternion,a=new THREE.Quaternion,l=new THREE.Vector3(0,0,1),h=new THREE.Vector3,d=(new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0)),c=new THREE.Vector3(0,1,0);let u=new THREE.Vector3,g=new THREE.Vector3,p=new THREE.Vector3,m=(new Date).valueOf(),f=m-16;!function w(){s.animationId=requestAnimationFrame(w),s.curvePos>=1&&(s.curvePos=s.loop?0:1,t&&t(),s.loop||s.pause()),function(t){s.projectGround?(i=s.realGroundPath.getPointAt(t),n=s.realGroundPath.getTangentAt(t)):(i=s.path.getPointAt(t),n=s.path.getTangentAt(t)),o=n.clone(),n.z=0,n.normalize(),g.set(n.x,n.y,n.z),u.crossVectors(n,l),u.normalize(),p.set(i.x,i.y,i.z),s._controlCamera(p,g,u),r.set(0,0,0,1);var m=0;if(s.isYawEnabled){var f=n.dot(s.initDirection);f=f<-1?-1:f>1?1:f,m=Math.acos(f),m=n.y<0?-m:m}m+=s.originYaw,a.setFromAxisAngle(l,m),r.multiply(a),a.setFromAxisAngle(l,-s.originYaw),d.set(0,1,0),d.applyQuaternion(a),c.set(d.x,d.y,d.z),c.applyQuaternion(r);var w=0;if(s.isPitchEnabled){o.normalize();var y=o.dot(n);y=y<-1?-1:y>1?1:y,w=Math.acos(y),h.crossVectors(n,o),w=h.dot(c)>0?w:-w}w-=s.originPitch,a.setFromAxisAngle(d,w),r.multiply(a);for(var v=0,b=s.objectIds.length;v<b;v++)if(s.viewer.getExternalComponentManager().setTransform(s.objectIds[v],i,void 0,r,(function(){s.stop()})),s.viewer.getExternalObjectManager()._fireTransformedEvent(s.objectIds[v]),s.viewer instanceof e.Bimface.Viewer.ViewerGIS){const e=s.viewer.getLayerManager().getLayerByType("ExternalObjectLayer");for(let t=0;t<e.length;t++){e[t].getExternalObjectManager()._fireTransformedEvent(s.objectIds[t])}}}(s.curvePos),s.viewer.getViewer().modelManager.forceUpdateSimpleHBAOPass(),s.viewer.render(),m=(new Date).valueOf();let y=m-f;f=m,s.curvePos+=y/s.time}()}pause(){cancelAnimationFrame(this.animationId)}stop(){cancelAnimationFrame(this.animationId),this.curvePos=0}destroy(){this.stop(),this.animationId=null,this.curvePos=null,this.id=null,this.initDirection=null,this.isPitchEnabled=null,this.isYawEnabled=null,this.loop=null,this.objectIds=null,this.objectNames=null,this.originPitch=null,this.originYaw=null,this.path=null,this.projectGround=null,this.realGroundPath=null,this.time=null,this.viewer=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.PathAnimationConfig=class{constructor(){this.loop=!1,this.isPitchEnabled=!1,this.isYawEnabled=!1,this.objectNames=[],this.objectIds=[],this.originPitch=0,this.originYaw=0,this.path=null,this.time=0,this.viewer=null,this.isProjectGround=!1}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.CurveAnimationConfig=class{constructor(){this.curves=null,this.viewer=null,this.type="trail",this.time=null,this.speed=1e4,this.loop=!1}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.CurveAnimation=class{constructor(i){if(t.send("Bimface.Plugins.Animation.FlowEffect","bf_c_animation_newPath"),i)if(this.loop=i.loop,this.curves=i.curves,this.time=i.time,this.viewer=i.viewer,this.speed=i.speed,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.animationId=0,P(this),this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS))if(this.curves){this.setType(i.type),this._times=[],this._curvePositions=[];for(let e=0;e<this.curves.length;e++)this._times.push(.1),this._curvePositions.push(0);this.time?this.setTime(this.time):this.setSpeed(this.speed),this.runningState=!1}else console.log("ERROR::curves must not be empty");else console.log("ERROR::viewer must not be empty or viewer2d.");else console.log("ERROR::curveAnimationConfig must not be empty.")}_addCurvePoints(){this._curvePoints=[];for(let e=0,t=this.curves.length;e<t;e++){let t=this.curves[e],i=new THREE.BufferGeometry;t.geometry instanceof THREE.BufferGeometry?i=t.geometry:(i.setFromObject(t),t.geometry._bufferGeometry=i);let n=i.getAttribute("instanceStart")?i.getAttribute("instanceStart").array:i.getAttribute("position").array;const o=n.length;if(o>3*this._interpolationPositionLength){this._curvePoints.push({points:n,prePositionEnd:0,length:this._computeLength(t,n)});continue}let s=[];for(let e=0;e<o;e+=6)s.push(new THREE.Vector3(n[e],n[e+1],n[e+2]));s.push(new THREE.Vector3(n[o-3],n[o-2],n[o-1])),n=null;let r=new THREE.CatmullRomCurve3(s);r.tension=0,r.type="catmullrom";let a=r.getPoints(this._interpolationPositionLength),l=[];for(let e=0;e<a.length;e++){let t=a[e];l.push(t.x),l.push(t.y),l.push(t.z)}this._curvePoints.push({points:l,prePositionEnd:1,length:r.getLength(),appearedSize:0}),a.length=0}}_distanceTo(e,t,i,n,o,s){const r=n-e,a=o-t,l=s-i,h=r*r+a*a+l*l;return Math.sqrt(h)}_computeLength(t,i){if(t instanceof e.Bimface.Plugins.Geometry.SplineCurve)return t.length;let n=0;for(let e=3;e<i.length;e+=3)n+=this._distanceTo(i[e-3],i[e-2],i[e-1],i[e],i[e+1],i[e+2]);return n}_initializeCurve(){for(let e=0,t=this.curves.length;e<t;e++)this.__initializeCurveByIndex(e);!this.viewer._isDestroyed&&this.viewer.render()}__initializeCurveByIndex(e){let t=this.curves[e],i=t.material;if(i instanceof THREE.LineMaterial||i instanceof CLOUD.MeshLineMaterial)return t.groundCurve.material.isTrail=!0,t.groundCurve.material.needsUpdate=!0,t.groundCurve.material.visibility=0,i.visibility=0,void(i.needsUpdate=!0);let n=this._curvePoints[e];const o=n.points;let s=t.geometry instanceof THREE.BufferGeometry?t.geometry:t.geometry._bufferGeometry;const r=o.length;var a=new Float32Array(r);if(s.getAttribute("instanceStart")){var l=new THREE.InstancedInterleavedBuffer(a,6,1);s.addAttribute("instanceStart",new THREE.InterleavedBufferAttribute(l,3,0)),s.addAttribute("instanceEnd",new THREE.InterleavedBufferAttribute(l,3,3)),l.needsUpdate=!0}else s.addAttribute("position",new THREE.BufferAttribute(a,3));for(let e=0;e<r;e+=3)a[e]=o[0],a[e+1]=o[1],a[e+2]=o[2];n.prePositionEnd=1,n.appearedSize=0}getId(){return this.id}getLoop(){return this.loop}getCurves(){return this.curves}getTime(){return this.time}getSpeed(){return this.speed}setLoop(e){this.loop=e}setSpeed(e){if(e<=0)console.log("ERROR::speed must be >0");else{this.speed=e;for(let t=0;t<this._curvePoints.length;t++){const i=this._curvePoints[t].length;this._times[t]=i/e*1e3}}}setTime(e){if(e<=0)console.log("ERROR::time must not be >0");else{this.time=e;for(let t=0;t<this.curves.length;t++)this._times[t]=e}}play(){if(!this.curves||!this.viewer)return void console.log("ERROR::viewer or curves must not be empty.");if(!0===this.runningState)return;this.runningState=!0;var e=this;let t=(new Date).valueOf(),i=t-16;this._setEnableGroundCurveAnimation(!0),function n(){e.animationId=requestAnimationFrame(n),function(){t=(new Date).valueOf();let n=t-i;i=t,"trail"==e.type?e._loopTrail(n):e._loopFlow(n)}(),e.viewer&&!e.viewer._isDestroyed&&e.viewer.render()}()}_loopFlow(e){var t=this;for(let i=0,n=t.curves.length;i<n;i++){if(t._curvePositions[i]>=1&&(t._curvePositions[i]=t.loop?0:1,!t.loop))continue;let n=t.curves[i];if(!n.geometry)continue;let o=n.material;o instanceof CLOUD.MeshLineMaterial&&o.uniforms.map.value&&(o.uniforms.map.value.offset.y+=e/t._times[i],o.uniforms.map.value.offset.y%=1,CLOUD.MaterialUtil.updateUVMatrix(o.uniforms.map.value),o.needsUpdate=!0),t._curvePositions[i]+=e/t._times[i]}}_loopTrail(e){var t=this;for(let i=0,n=t.curves.length;i<n;i++){let n=t._curvePositions[i];n>=1&&(t._curvePositions[i]=t.loop?0:1,n=t._curvePositions[i],t.loop?(t.__initializeCurveByIndex(i),!t.viewer._isDestroyed&&t.viewer.render()):t.pause());let o=t.curves[i];if(!o.geometry)continue;let s=o.material;if(s instanceof THREE.LineMaterial||s instanceof CLOUD.MeshLineMaterial)s.visibility=n,o.groundCurve.material.visibility=n,s.needUpdate=!0;else{let e=o.geometry instanceof THREE.BufferGeometry?o.geometry:o.geometry._bufferGeometry;t._dealLine(e,t._curvePoints[i],n)}t._curvePositions[i]+=e/t._times[i]}}_dealLine(e,t,i){if("trail"!=this.type)return;const n=t.points;let o=e.getAttribute("position").array,s=o.length/3;if(t.prePositionEnd==s)return;let r=t.length*i,a=t.prePositionEnd;for(;a<s;a++){const e=3*a,i=this._distanceTo(n[e-3],n[e-2],n[e-1],n[e],n[e+1],n[e+2]);if(t.appearedSize+i>r)break;t.appearedSize+=i,o.copyWithin(3),o[0]=n[e],o[1]=n[e+1],o[2]=n[e+2]}t.prePositionEnd=a,e.getAttribute("position").needsUpdate=!0}_setEnableGroundCurveAnimation(e){for(let t=0,i=this.curves.length;t<i;t++){let i=this.curves[t];i.geometry&&(i.groundCurve.material.enableAnimation=e,"trail"==this.getType()?i.groundCurve.material.isTrail=!0:i.groundCurve.material.isTrail=!1)}}pause(){cancelAnimationFrame(this.animationId),this._setEnableGroundCurveAnimation(!1),this.runningState=!1}stop(){cancelAnimationFrame(this.animationId),this._setEnableGroundCurveAnimation(!1);for(let e=0;e<this._curvePositions.length;e++)this._curvePositions[e]=0;"trail"==this.type&&this._initializeCurve(),this.runningState=!1}setType(e){if(this.type!=e&&("trail"==e||"flow"==e))if(this.type=e,"trail"==e)this._interpolationPositionLength=100,this._addCurvePoints(),this._initializeCurve();else{this._curvePoints=[];for(let e=0,t=this.curves.length;e<t;e++){const t=this.curves[e].material;t instanceof CLOUD.MeshLineMaterial?(this.curves[e].groundCurve.material.isTrail=!1,this.curves[e].groundCurve.material.visibility=1,this.curves[e].groundCurve.material.needsUpdate=!0,t.visibility=1,t.needsUpdate=!0,!this.viewer._isDestroyed&&this.viewer.render(),this._curvePoints.push({length:t.totalSize})):this._curvePoints.push(1)}}}getType(){return this.type}getSenceType(){return e.Bimface.Common.Type.EffectType.CurveAnimation}getParams(){let e=[];for(let t=0;t<this.curves.length;t++)e.push(this.curves[t].getParams());return{path:e,time:this.time,loop:this.loop,speed:this.speed,type:this.type}}zoomToBoundingBox(){const e=this.curves[0].geometry;e.computeBoundingBox();let t=e.boundingBox;this.viewer.zoomToBoundingBox({boundingBox:t})}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.GrowthAnimationConfig=class{constructor(){this.conditions=null,this.time=0,this.speed=0,this.direction={x:0,y:0,z:1},this.viewer=null,this.loop=!1}}}();class ds{static addGrowthAnimation(){ds.growthAnimationCount++,ds.isEnableGTAO=CLOUD.GlobalData.GTAO,!0===ds.isEnableGTAO&&(CLOUD.GlobalData.GTAO=!1)}static removeGrowthAnimation(){ds.growthAnimationCount--,0==ds.growthAnimationCount&&1==ds.isEnableGTAO&&(CLOUD.GlobalData.GTAO=!0)}}ds.growthAnimationCount=0,ds.isEnableGTAO=!1,function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.GrowthAnimation=class{constructor(e){if(t.send("Bimface.Plugins.Animation.GrowthAnimation","bf_c_growthAnimation_new"),!e)return void console.log("ERROR::growthAnimationConfig must not be empty.");if(P(this),ds.addGrowthAnimation(),this.viewer=e.viewer,"ViewerGIS"===this.viewer.viewerType)for(const t of e.conditions){const e=t.layerId,i=this.viewer.getLayerManager().getLayer(e);if(!i)return;t.modelId=i.getModelId()}this.manager=this.viewer.getViewer().growthAnimationManager;const i={conditions:e.conditions,direction:e.direction,time:e.time,speed:e.speed,loop:e.loop};this.growthAnimationObject=this.manager.createGrowthAnimationObject(i),this.time=i.time,this.speed=i.speed,this.onProgressChangedEvent=null}play(){this.growthAnimationObject.play()}pause(){this.growthAnimationObject.pause()}stop(){this.growthAnimationObject.stop()}setProgress(e){this.growthAnimationObject.setProgress(e)}setSpeed(e){this.speed=e,this.growthAnimationObject.setSpeed(e)}getSpeed(){return this.speed}setTime(e){this.time=e,this.growthAnimationObject.setTime(e)}getTime(){return this.time}onProgressChanged(e){this.onProgressChangedEvent&&this._removeProgressChanged(this.onProgressChangedEvent),this.onProgressChangedEvent=e,this._addProgressChanged(this.onProgressChangedEvent)}_addProgressChanged(e){e&&this.growthAnimationObject.addProgressChanged(e)}_removeProgressChanged(e){this.growthAnimationObject.removeProgressChanged(e)}destory(){this.manager.deleteGrowthAnimationObject(this.growthAnimationObject),this.growthAnimationObject.destory(),this.growthAnimationObject=null,ds.removeGrowthAnimation()}destroy(){this.destory()}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class n extends i.Plane{constructor(i){t.send("Bimface.Plugins.Geometry.SpatialPlane","bf_c_plane_newPlane"),super(i),i instanceof Array?(this.children=[],this.color=new e.Web.Graphics.Color(50,138,240,.5),this.borderColor=new e.Web.Graphics.Color(50,138,240,1),this.points=i,this.useBorder=!0,this._createPlane()||(this.type="invalidPlane")):console.log("Parameter points should be an array.")}_createGeometry(e){const t=(new THREE.BufferGeometry).setFromPoints(e);t.setIndex([0,1,2,0,2,3]),t.computeVertexNormals();let i=[];return i.push(0,0),i.push(1,0),i.push(1,1),i.push(0,1),t.setAttribute("uv",new THREE.Float32BufferAttribute(i,2)),t}_createPlane(){if(this.points=this._formatPoints(this.points),4!==this.points.length)return this.type="invalidPlane",console.log("Creating a plane needs 4 points."),!1;let e=this._createGeometry(this.points),t=new THREE.Mesh(e,this._createMeshMaterial());return t.updateMatrixWorld(!0),this.add(t),1==this.useBorder&&this.add(this._createBorderLine()),!0}_createBorderLine(){const e=(new THREE.BufferGeometry).setFromPoints(this.points);var t=this._createLineMaterial();return new THREE.Line(e,t)}_formatPoints(e){let t=[];return e.forEach((e=>{t.push(new THREE.Vector3(e.x,e.y,e.z))})),t}}i.SpatialPlane=n}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class n extends THREE.Group{constructor(i){t.send("Bimface.Plugins.Geometry.Band","bf_c_band_new"),super(),i&&(this._option=i,this.splineCurve=i.curve,this._originCurve=i.curve,this.color=null==i.color?new e.Web.Graphics.Color(50,138,240,1):i.color,this.material=i.material,this.width=null==i.width?[10,10]:i.width,this.torsionEnable=null!=i.enableTorsion&&i.enableTorsion,this.borderEnable=!(!i.border||!i.border.enable)&&i.border.enable,this.borderWidth=i.border&&i.border.width?i.border.width:1,this.borderColor=i.border&&i.border.color?i.border.color:new e.Web.Graphics.Color(50,138,240,1),this._adjustGlobalUnit=!1,this._useMaterial=null==i._useMaterial||i._useMaterial,this._createBand(),P(this))}_createBand(){if(!this.splineCurve)return;const e=this.splineCurve.curve;if(!e)return;const t=this.splineCurve.points[0],i=this.splineCurve.divisions,n=e.computeFrenetFrames(i,!1);let o=[],s=[],r=this.splineCurve.curvePositions,a=[];if(this.torsionEnable)for(let e=0,l=i;e<=l;e++)o.push(n.normals[e].x,n.normals[e].y,n.normals[e].z),s.push(-n.binormals[e].x,-n.binormals[e].y,-n.binormals[e].z),a.push(r[3*e]-t.x,r[3*e+1]-t.y,r[3*e+2]-t.z);else{let e=new THREE.Vector3,l=new THREE.Vector3(0,0,1);for(let h=0,d=i;h<=d;h++){let i=e.crossVectors(n.tangents[h],l);i.normalize(),o.push(i.x,i.y,i.z),s.push(0,0,1),a.push(r[3*h]-t.x,r[3*h+1]-t.y,r[3*h+2]-t.z)}}let l,h=new CLOUD.BandGeometry;h.setPositions(a,o,s,this.width[0],this.width[1]),this.material&&this._useMaterial?l=this.material.material:(l=new THREE.MeshStandardMaterial({side:THREE.DoubleSide,color:new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),opacity:this.color.alpha,transparent:this.color.alpha<1}),this.colorMaterial=l);let d=new THREE.Mesh(h,l);this.position.set(t.x,t.y,t.z),this.add(d),this.updateMatrixWorld(!0),this.borderEnable&&this._createBorder()}_createBorder(){var e=this.children[0];if(null==e)return;let t=e.geometry.getWireframe(),i=new CLOUD.MeshLineGeometry;i.setPositions(t);let n=new CLOUD.MeshLineMaterial({color:new THREE.Color(this.borderColor.red/255,this.borderColor.green/255,this.borderColor.blue/255),opacity:this.borderColor.alpha,transparent:this.borderColor.alpha<1,resolution:new THREE.Vector2(window.innerWidth,window.innerHeight),linewidth:this.borderWidth,enableSingleExpand:!0}),o=new CLOUD.MeshLine(i,n);o._oriMaterial=o.material,this.add(o),o.updateMatrixWorld(!0)}_rebuild(e){return this._adjustGlobalUnit?this:this.viewer||e?(this.viewer||(this.viewer=e),this.splineCurve&&(this.children.length>0&&(this.children.length=0),this.splineCurve._rebuild(e),this.width=this.viewer.globalUnitUtil.translate(this.width),this._createBand()),this._adjustGlobalUnit=!0,this):this}clone(){let e={curve:this._originCurve,color:this.color,material:this.material,width:this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate(this.width):this.width,enableTorsion:this.torsionEnable,border:{enable:this.borderEnable,width:this.borderWidth,color:this.borderColor},_useMaterial:this._useMaterial},t=new this.constructor(e);return this.viewer&&(t.viewer=this.viewer),t}dispose(){this.children.length=0,this.splineCurve=null,this.material=null,this.color=null}getCurve(){return this.splineCurve}setCurve(t){!t instanceof e.Bimface.Plugins.Geometry.SplineCurve?console.warn("ERROR: curve is not instance of Glodon.Bimface.Plugins.Geometry.SplineCurve"):(this.splineCurve=t,this._originCurve=t,this._adjustGlobalUnit&&(this.width=this.viewer.globalUnitUtil.revertTranslate(this.width),this._adjustGlobalUnit=!1),this._needsUpdate=!0)}getColor(){return this.color}setColor(t){if(!t instanceof e.Web.Graphics.Color)console.warn("ERROR: color is not instance of Glodon.Web.Graphics.Color");else{this.color=t;var i=this.children[0];null!=i&&(this.colorMaterial?(this.colorMaterial.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255),this.colorMaterial.opacity=this.color.alpha,this.colorMaterial.transparent=this.color.alpha<1,this.colorMaterial.needsUpdate=!0):this.colorMaterial=new THREE.MeshStandardMaterial({side:THREE.DoubleSide,color:new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),opacity:this.color.alpha,transparent:this.color.alpha<1}),i.material=this.colorMaterial,i._oriMaterial=material.material,this._useMaterial=!1)}}getMaterial(){return this.material}setMaterial(t){if(!t instanceof e.Bimface.Plugins.Material.Material)console.warn("ERROR: material is not instance of Glodon.Bimface.Plugins.Material.Material");else{this.material=t;var i=this.children[0];null!=i&&(i.material=t.material,i._oriMaterial=t.material),this._useMaterial=!0}}getWidth(){return this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate(this.width):this.width}setWidth(e){if(!e instanceof Array||2!=e.length)return void console.warn("ERROR: width is not Array with two elements ");let t=this._adjustGlobalUnit?this.viewer.globalUnitUtil.translate(e):e;this.width[0]==t[0]&&this.width[1]==t[1]||(this.width=t,this._adjustGlobalUnit&&(this.splineCurve=this._originCurve,this._adjustGlobalUnit=!0),this._needsUpdate=!0)}isTorsionEnabled(){return this.torsionEnable}enableTorsion(e){e!=this.torsionEnable&&(this.torsionEnable=e,this._needsUpdate=!0,this._adjustGlobalUnit&&(this._adjustGlobalUnit=!1,this.width=this.viewer.globalUnitUtil.revertTranslate(this.width),this.splineCurve=this._originCurve))}isBorderEnabled(){return this.borderEnable}enableBorder(e){e!=this.borderEnable&&(this.borderEnable=e,this._updateBorder=!0)}getBorderWidth(){return this.borderWidth}setBorderWidth(e){if(Number(e)){this.borderWidth=e;var t=this.children[1];null!=t&&(t.material.linewidth=this.borderWidth)}else console.warn("ERROR: borderWidth is not Number ")}getBorderColor(){return this.borderColor}setBorderColor(t){if(!t instanceof e.Web.Graphics.Color)console.warn("ERROR: borderColor is not instance of Glodon.Web.Graphics.Color");else{this.borderColor=t;var i=this.children[1];null!=i&&(i.material.color.setRGB(this.borderColor.red/255,this.borderColor.green/255,this.borderColor.blue/255),i.material.opacity=this.borderColor.alpha,i.material.transparent=this.borderColor.alpha<1,i.material.needsUpdate=!0)}}update(){this.splineCurve&&(this._needsUpdate?(this.children.length=0,this._createBand()):this._updateBorder&&(this.borderEnable?this._createBorder():this.remove(this.children[1])),this._rebuild(this.viewer),this._needsUpdate=!1,this._updateBorder=!1)}}i.Band=n}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Geometry");class n extends THREE.Group{constructor(i){if(t.send("Bimface.Plugins.Geometry.Pipe","bf_c_pipe_new"),super(),!i)return console.log("option.crossSection.radius must not be undefined "),void console.log("option.rail.line or option.rail.arc must not be undefined ");P(this),this._option=i,this.cap=null==i.cap?"None":i.cap,this.color=null==i.color?new e.Web.Graphics.Color(50,138,240,1):i.color,i.crossSection&&i.crossSection.radius?(this.crossSectionRadius=i.crossSection.radius,this.crossSectionSegments=i.crossSection.segments||12,this.material=i.material,i.rail&&(i.rail.line||i.rail.arc)?(this.rail=i.rail,this._rail=i.rail,this._needsUpdate=!1,this._needsUpdateCurve=!1,this._geometryUpdated=!1):console.log("option.rail.line or option.rail.arc must not be undefined ")):console.log("option.crossSection.radius must not be undefined ")}_createPipe(){let e=this._rail.segments<2?this._rail.segments:this._rail.segments+2,t=new CLOUD.TubeGeometry(this._curve,e,this._crossSectionRadius||this.crossSectionRadius,this.crossSectionSegments,!1),i=new CLOUD.CloudStandardMaterial({color:new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255).convertSRGBToLinear(),opacity:this.color.alpha,transparent:this.color.alpha<1,side:THREE.DoubleSide}),n=new THREE.Mesh(t,i);this.add(n),this.updateMatrixWorld(!0)}_updatePipeGeometry(){let e=this._rail.segments<2?this._rail.segments:this._rail.segments+2,t=new CLOUD.TubeGeometry(this._curve,e,this._crossSectionRadius||this.crossSectionRadius,this.crossSectionSegments,!1);var i=this.children[0];null!=i&&(i.geometry.dispose(),i.geometry=t,this._geometryUpdated=!0)}_rebuild(e){return this.viewer=e,this._crossSectionRadius=this.viewer.globalUnitUtil.translate(this.crossSectionRadius),this._createCurve(!0)&&this._createPipe(),this}_createCurve(e=!1){let t=[];e&&(this._rail=this.viewer.globalUnitUtil.translate(this.rail,["x","y","z"]));var i=this._rail;if(i.line){i.segments=null==i.segments?1:i.segments;let e=i.line.startPoint,n=i.line.endPoint;t.push(new THREE.Vector3(e.x,e.y,e.z)),t.push(new THREE.Vector3(n.x,n.y,n.z))}else{i.segments=null==i.segments?8:i.segments;let e=i.arc,n=new THREE.Vector3(e.startPoint.x,e.startPoint.y,e.startPoint.z),o=new THREE.Vector3(e.throughPoint.x,e.throughPoint.y,e.throughPoint.z),s=new THREE.Vector3(e.endPoint.x,e.endPoint.y,e.endPoint.z);this._getArcPoints(n,o,s,t)}return 0!=t.length&&(this._curve=new THREE.CatmullRomCurve3(t),this._curve.curveType="centripetal",!0)}_getArcPoints(e,t,i,n){function o(e,t,i,n,o){let s=new THREE.Vector3;e.set(t.x,t.y,t.z),s.addVectors(m,e.applyAxisAngle(i,n)),o.push(s)}let s=t.clone().sub(e),r=i.clone().sub(e);var a=new THREE.Vector3;a.crossVectors(s,r);let l=a.normalize();if(l.equals(new THREE.Vector3))return void console.log("arc's three points must not be collinear.");let h=s.dot(s),d=r.dot(r),c=s.dot(r),u=.5/(h*d-c*c),g=u*d*(h-c),p=u*h*(d-c),m=new THREE.Vector3;m.addVectors(s.multiplyScalar(g),r.multiplyScalar(p)),m.addVectors(m,e);let f=m.distanceTo(e),w=e.clone().sub(m),y=i.clone().sub(m),v=(t.clone().sub(m),Math.acos(w.dot(y)/(f*f))),b=new THREE.Vector3;b.set(w.x,w.y,w.z),b.applyAxisAngle(l,v),function(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i&&Math.abs(e.z-t.z)<i}(b,y,.1)||(v=2*Math.PI-v);for(let e=0;e<=8;e++)1==e?o(b,w,l,v*e/1e3,n):8==e&&o(b,w,l,999*v/1e3,n),o(b,w,l,v*e/8,n)}clone(){let e={color:this.color,crossSection:{radius:this.crossSectionRadius,segments:this.crossSectionSegments},rail:this.rail};return new this.constructor(e)}dispose(){this.children.length=0,this._curve=null,this._colorMaterial=null}getColor(){return this.color}setColor(t){if(!t instanceof e.Web.Graphics.Color)return void console.warn("ERROR: color is not instance of Glodon.Web.Graphics.Color");this.color=t;var i=this.children[0];if(null==i)return;let n=i.material;n.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255),n.opacity=this.color.alpha,n.transparent=this.color.alpha<1,n.needsUpdate=!0}getCrossSection(){return{radius:this.crossSectionRadius,segments:this.crossSectionSegments}}setCrossSection(e){e.radius&&this.crossSectionRadius!=e.radius&&(this.crossSectionRadius=e.radius,this._crossSectionRadius=this.viewer.globalUnitUtil.translate(this.crossSectionRadius),this._needsUpdate=!0),e.segments&&this.crossSectionSegments!=e.segments&&(this.crossSectionSegments=e.segments,this._needsUpdate=!0)}getRail(){return this.rail}setRail(e){e.line?(this.rail.arc=null,this.rail.line=e.line,this._needsUpdateCurve=!0):e.arc&&(this.rail.line=null,this.rail.arc=e.arc,this._needsUpdateCurve=!0),null!=e.segments&&e.segments!=this.rail.segments&&(this.rail.segments=e.segments,this._needsUpdate=!0)}update(){if(!this._needsUpdate&&!this._needsUpdateCurve)return;let e=!0;this._needsUpdateCurve&&(e=this._createCurve(),this._needsUpdateCurve=!1),e&&(this._updatePipeGeometry(),this._needsUpdate=!1,this.externalComponentManager&&this.externalComponentManager.updateSelectEffect())}}i.Pipe=n}();var cs,us,gs=["attribute vec3 customColor;","attribute float customOpacity;","attribute float customSize;","attribute float customAngle;","attribute float customVisible;","varying vec4 vColor;","varying float vAngle;","varying float clipSize;","#include <common>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>","void main()","{"," if ( customVisible > 0.5 )"," vColor = vec4( customColor, customOpacity );"," else"," vColor = vec4(0.0, 0.0, 0.0, 0.0);"," vAngle = customAngle;"," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );"," #include <clipping_planes_vertex>"," gl_PointSize = customSize * ( 300.0 / length( mvPosition.xyz ) );"," clipSize = gl_PointSize*0.5;"," gl_Position = projectionMatrix * mvPosition;"," #include <logdepthbuf_vertex>","}"].join("\n"),ps=["\n uniform sampler2D pTexture;\n uniform bool isSmoke;\n varying vec4 vColor;\n varying float vAngle;\n varying float clipSize;\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n void main()\n {\n #if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > (plane.w - clipSize) ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > (plane.w - clipSize) ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n \n #include <logdepthbuf_fragment>\n gl_FragColor = vColor;\n float c = cos(vAngle);\n float s = sin(vAngle);\n vec2 rotatedUV = vec2(c * (gl_PointCoord.x - 0.5) + s * (gl_PointCoord.y - 0.5) + 0.5,\n c * (gl_PointCoord.y - 0.5) - s * (gl_PointCoord.x - 0.5) + 0.5); // rotate UV coordinates to rotate texture\n vec4 rotatedTexture = texture2D( pTexture, rotatedUV );\n\n if(isSmoke){\n gl_FragColor.a = gl_FragColor.a * rotatedTexture.a;\n }else{\n gl_FragColor = gl_FragColor * rotatedTexture;\n }\n #include <colorspace_fragment>\n //gl_FragColor = gl_FragColor * rotatedTexture; // sets an otherwise white particle texture to desired color\n }\n"].join("\n");function ms(e,t){this.times=e||[],this.values=t||[]}function fs(){this.position=new THREE.Vector3,this.velocity=new THREE.Vector3,this.acceleration=new THREE.Vector3,this.angle=0,this.angleVelocity=0,this.angleAcceleration=0,this.size=16,this.color=new THREE.Color,this.opacity=1,this.age=0,this.alive=0}function ws(){this.positionStyle=1,this.positionBase=new THREE.Vector3,this.positionSpread=new THREE.Vector3,this.positionRadius=0,this.velocityStyle=1,this.velocityBase=new THREE.Vector3,this.velocitySpread=new THREE.Vector3,this.speedBase=0,this.speedSpread=0,this.accelerationBase=new THREE.Vector3,this.accelerationSpread=new THREE.Vector3,this.angleBase=0,this.angleSpread=0,this.angleVelocityBase=0,this.angleVelocitySpread=0,this.angleAccelerationBase=0,this.angleAccelerationSpread=0,this.sizeBase=0,this.sizeSpread=0,this.sizeTween=new ms,this.colorBase=new THREE.Vector3(0,1,.5),this.colorSpread=new THREE.Vector3(0,0,0),this.colorTween=new ms,this.opacityBase=1,this.opacitySpread=0,this.opacityTween=new ms,this.blendStyle=THREE.NormalBlending,this.particleArray=[],this.particlesPerSecond=100,this.particleDeathAge=1,this.isSmoke=!1,this.emitterAge=0,this.emitterAlive=!0,this.emitterDeathAge=60,this.particleCount=this.particlesPerSecond*Math.min(this.particleDeathAge,this.emitterDeathAge)}ms.prototype.lerp=function(e){for(var t=0,i=this.times.length;t<i&&e>this.times[t];)t++;if(0==t)return this.values[0];if(t==i)return this.values[i-1];var n=(e-this.times[t-1])/(this.times[t]-this.times[t-1]);return this.values[0]instanceof THREE.Vector3?this.values[t-1].clone().lerp(this.values[t],n):this.values[t-1]+n*(this.values[t]-this.values[t-1])},fs.prototype.update=function(e){if(this.position.add(this.velocity.clone().multiplyScalar(e)),this.velocity.add(this.acceleration.clone().multiplyScalar(e)),this.angle+=.01745329251*this.angleVelocity*e,this.angleVelocity+=.01745329251*this.angleAcceleration*e,this.age+=e,this.sizeTween.times.length>0&&(this.size=this.sizeTween.lerp(this.age)),this.colorTween.times.length>0){var t=this.colorTween.lerp(this.age);this.color=(new THREE.Color).setHSL(t.x,t.y,t.z)}this.opacityTween.times.length>0&&(this.opacity=this.opacityTween.lerp(this.age))},ws.prototype.setValues=function(e){if(void 0!==e){for(var t in this.sizeTween=new ms,this.colorTween=new ms,this.opacityTween=new ms,e)this[t]=e[t];this.particleArray=[],this.emitterAlive=!0,this.particleCount=this.particlesPerSecond*Math.min(this.particleDeathAge,this.emitterDeathAge),this.particleGeometry=new THREE.BufferGeometry,this.particleMaterial=new THREE.ShaderMaterial({uniforms:{pTexture:{value:this.particleTexture},isSmoke:{value:this.isSmoke}},clipping:!0,vertexShader:gs,fragmentShader:ps,transparent:!0,blending:THREE.NormalBlending,depthWrite:!1}),this.particleMesh=new CLOUD.PointsEx}},ws.prototype.randomValue=function(e,t){return e+t*(Math.random()-.5)},ws.prototype.randomVector3=function(e,t){var i=new THREE.Vector3(Math.random()-.5,Math.random()-.5,Math.random()-.5);return(new THREE.Vector3).addVectors(e,i.multiplyVectors(t,i))},ws.prototype.updateVector3=function(e,t,i){var n=new THREE.Vector3(Math.random()-.5,Math.random()-.5,Math.random()-.5);e.set(0,0,0),e.addVectors(t,n.multiplyVectors(i,n))},ws.prototype.createParticle=function(){var e=new fs;if(1==this.positionStyle&&(e.position=this.randomVector3(this.positionBase,this.positionSpread)),2==this.positionStyle){var t=2*Math.random()-1,i=6.2832*Math.random(),n=Math.sqrt(1-t*t),o=new THREE.Vector3(n*Math.cos(i),n*Math.sin(i),t);e.position=(new THREE.Vector3).addVectors(this.positionBase,o.multiplyScalar(this.positionRadius))}if(1==this.velocityStyle&&(e.velocity=this.randomVector3(this.velocityBase,this.velocitySpread)),2==this.velocityStyle){var s=(new THREE.Vector3).subVectors(e.position,this.positionBase),r=this.randomValue(this.speedBase,this.speedSpread);e.velocity=s.normalize().multiplyScalar(r)}e.acceleration=this.randomVector3(this.accelerationBase,this.accelerationSpread),e.angle=this.randomValue(this.angleBase,this.angleSpread),e.angleVelocity=this.randomValue(this.angleVelocityBase,this.angleVelocitySpread),e.angleAcceleration=this.randomValue(this.angleAccelerationBase,this.angleAccelerationSpread),e.size=this.randomValue(this.sizeBase,this.sizeSpread);var a=this.randomVector3(this.colorBase,this.colorSpread);return e.color=(new THREE.Color).setHSL(a.x,a.y,a.z).convertSRGBToLinear(),e.opacity=this.randomValue(this.opacityBase,this.opacitySpread),e.age=0,e.alive=0,e.sizeTween=this.sizeTween,e.colorTween=this.colorTween,e.opacityTween=this.opacityTween,e},ws.prototype.updateParticle=function(e){if(1==this.positionStyle&&this.updateVector3(e.position,this.positionBase,this.positionSpread),2==this.positionStyle){var t=2*Math.random()-1,i=6.2832*Math.random(),n=Math.sqrt(1-t*t),o=new THREE.Vector3(n*Math.cos(i),n*Math.sin(i),t);e.position=(new THREE.Vector3).addVectors(this.positionBase,o.multiplyScalar(this.positionRadius))}if(1==this.velocityStyle&&this.updateVector3(e.velocity,this.velocityBase,this.velocitySpread),2==this.velocityStyle){var s=(new THREE.Vector3).subVectors(e.position,this.positionBase),r=this.randomValue(this.speedBase,this.speedSpread);e.velocity=s.normalize().multiplyScalar(r)}if(this.updateVector3(e.acceleration,this.accelerationBase,this.accelerationSpread),e.angle=this.randomValue(this.angleBase,this.angleSpread),e.angleVelocity=this.randomValue(this.angleVelocityBase,this.angleVelocitySpread),e.angleAcceleration=this.randomValue(this.angleAccelerationBase,this.angleAccelerationSpread),e.size=this.randomValue(this.sizeBase,this.sizeSpread),!this.isSmoke){var a=this.randomVector3(this.colorBase,this.colorSpread);e.color=e.color.setHSL(a.x,a.y,a.z)}e.opacity=this.randomValue(this.opacityBase,this.opacitySpread),e.age=0,e.alive=0},ws.prototype.initialize=function(){this.sortArray=[],this.positions=new Float32Array(3*this.particleCount),this.customVisible=new Float32Array(this.particleCount),this.customSize=new Float32Array(this.particleCount),this.customColor=new Float32Array(3*this.particleCount),this.customOpacity=new Float32Array(this.particleCount),this.maxSize=200;for(var e=0;e<this.particleCount;e++)this.particleArray[e]=this.createParticle(),this.positions[3*e]=this.particleArray[e].position.x,this.positions[3*e+1]=this.particleArray[e].position.y,this.positions[3*e+2]=this.particleArray[e].position.z,this.customVisible[e]=this.particleArray[e].alive,this.customColor[3*e]=this.particleArray[e].color.r,this.customColor[3*e+1]=this.particleArray[e].color.g,this.customColor[3*e+2]=this.particleArray[e].color.b,this.customOpacity[e]=this.particleArray[e].opacity,this.customSize[e]=this.particleArray[e].size,this.maxSize=this.maxSize>this.customSize[e]?this.maxSize:this.customSize[e];this.particleMaterial.blending=this.blendStyle,this.particleGeometry.setAttribute("position",new THREE.BufferAttribute(this.positions,3)),this.particleGeometry.setAttribute("customColor",new THREE.BufferAttribute(this.customColor,3)),this.particleGeometry.setAttribute("customVisible",new THREE.BufferAttribute(this.customVisible,1)),this.particleGeometry.setAttribute("customSize",new THREE.BufferAttribute(this.customSize,1)),this.particleGeometry.setAttribute("customOpacity",new THREE.BufferAttribute(this.customOpacity,1)),this.particleMesh=new CLOUD.PointsEx(this.particleGeometry,this.particleMaterial),this.particleMesh.dynamic=!0,this.particleMesh.size=this.maxSize,this.particleMesh.renderOrder=CLOUD.GlobalData.IncrementRender?100:-1,this.initializeScale()},ws.prototype.update=function(e){e=null==e?.015:e;for(var t=[],i=0;i<this.particleCount;i++)this.particleArray[i].alive&&(this.particleArray[i].update(e),this.particleArray[i].age>this.particleDeathAge&&(this.particleArray[i].alive=0,t.push(i)),this.customVisible[i]=this.particleArray[i].alive,this.customOpacity[i]=this.particleArray[i].opacity,this.customSize[i]=this.particleArray[i].size,this.customColor[3*i]=this.particleArray[i].color.r,this.customColor[3*i+1]=this.particleArray[i].color.g,this.customColor[3*i+2]=this.particleArray[i].color.b,this.positions[3*i]=this.particleArray[i].position.x,this.positions[3*i+1]=this.particleArray[i].position.y,this.positions[3*i+2]=this.particleArray[i].position.z,this.maxSize=this.maxSize>this.customSize[i]?this.maxSize:this.customSize[i]);if(this.particleGeometry.getAttribute("customVisible").needsUpdate=!0,this.particleGeometry.getAttribute("customOpacity").needsUpdate=!0,this.particleGeometry.getAttribute("customSize").needsUpdate=!0,this.particleGeometry.getAttribute("customColor").needsUpdate=!0,this.particleGeometry.getAttribute("position").needsUpdate=!0,this.emitterAlive){var n=Math.round(this.particlesPerSecond*(this.emitterAge+0)),o=Math.round(this.particlesPerSecond*(this.emitterAge+e));o>this.particleCount&&(o=this.particleCount);for(i=n;i<o;i++)this.particleArray[i].alive=1;for(var s=0;s<t.length;s++){i=t[s];this.updateParticle(this.particleArray[i]),this.particleArray[i].alive=1,this.positions[3*i]=this.particleArray[i].position.x,this.positions[3*i+1]=this.particleArray[i].position.y,this.positions[3*i+2]=this.particleArray[i].position.z}this.emitterAge+=e}},ws.prototype.setScale=function(e){for(var t=0,i=this.sizeTween.values.length;t<i;t++)this.sizeTween.values[t]=this.sizeTweenClone[t]*e;this.maxSize=this.maxSizeClone*e},ws.prototype.setPositionBaseZ=function(e){this.positionBase.z=e},ws.prototype.setOpacityTween=function(e,t,i,n){this.opacityTween.times[0]=e,this.opacityTween.times[2]=t,this.opacityTween.values[0]=i,this.opacityTween.values[1]=n},ws.prototype.initializeSizetween=function(e,t){for(var i=0,n=this.sizeTween.values.length;i<n;i++)this.sizeTween.values[i]=this.sizeTween.values[i]*e;this.maxSize*=e;for(i=0;i<this.particleCount;i++)this.particleArray[i].size*=e,this.customSize[i]=this.particleArray[i].size,this.maxSize=this.maxSize>this.customSize[i]?this.maxSize:this.customSize[i];this.particleGeometry.getAttribute("customSize").needsUpdate=!0,this.initializeScale(t)},ws.prototype.initializeScale=function(e){e=null==e?1:e;var t=this.sizeTween.values;this.sizeTweenClone=[t[0]/e,t[1]/e],this.maxSizeClone=this.maxSize/e},ws.prototype.updateMaterialParameters=function(e){const t=this.particleMaterial;for(var i in e)t[i]=e[i]},ws.prototype.destroy=function(){},ws.prototype.setColor=function(e){this.colorBase=e;for(var t=0;t<this.particleCount;t++)this.particleArray[t].color.r=this.colorBase.x,this.particleArray[t].color.g=this.colorBase.y,this.particleArray[t].color.b=this.colorBase.z},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem");class n extends THREE.Group{constructor(e,i){t.send("Bimface.Plugins.ParticleSystem.Fire","bf_c_particleSys_newFire"),super(),null!=e&&1!=e||console.warn("[BIMFACE WARN]: ParticleSystem.Fire() is obsolete, please use ParticleSystem.FireEffect() instead."),this.firePosition={x:0,y:0,z:0},this.position.set(this.firePosition.x,this.firePosition.y,this.firePosition.z),this.fireScale=1,this.fireBBoxScale=2.2,this.type="fire",this.disPickable=!0,this.autoAnimation=!0,this._loadTexture(),this.fireType=null==i?"Fire":i.fireType,this.smokeConcentration=.6,i&&i.viewer&&(this.viewer=i.viewer),this._externalNeedScale=!0,this.smokeColor=new THREE.Vector3(0,0,0),this._initialize()}_initialize(){this.fire=new ws,this.fire.setValues({positionStyle:1,positionBase:new THREE.Vector3(0,0,600),positionSpread:new THREE.Vector3(1500,1500,600),velocityStyle:1,velocityBase:new THREE.Vector3(0,0,4600),velocitySpread:new THREE.Vector3(1e3,1e3,4600),accelerationBase:new THREE.Vector3(0,0,2600),particleTexture:this.fireParticle,sizeTween:new ms([0,.1],[32,200]),opacityTween:new ms([.7,1],[.8,0]),colorBase:new THREE.Vector3(.04,1,.4),blendStyle:THREE.AdditiveBlending,isSmoke:!1,particlesPerSecond:80,particleDeathAge:1.5}),this.fire.initialize(),this.fire.updateMaterialParameters({transparent:!1,priorityOrderId:10});var t=2600,i=new ms([.5,1,1.7],[0,.3,0]);this.fireType==e.Bimface.Plugins.ParticleSystem.FireType.Smoke&&(t=0,i=new ms([0,1,1.3],[.3,.3,0]),this.fire.particleMesh.visible=!1),this.smoke=new ws,this.smoke.setValues({positionStyle:1,positionBase:new THREE.Vector3(0,0,t),positionSpread:new THREE.Vector3(1500,1500,600),velocityStyle:1,velocityBase:new THREE.Vector3(0,0,3600),velocitySpread:new THREE.Vector3(1800,1800,1100),accelerationBase:new THREE.Vector3(0,0,2600),particleTexture:this.smokeParticle,sizeTween:new ms([0,1],[32,200]),opacityTween:i,colorBase:this.smokeColor,blendStyle:THREE.NormalBlending,isSmoke:!0,particlesPerSecond:40,particleDeathAge:2}),this.smoke.initialize(),this.smoke.updateMaterialParameters({transparent:!1,priorityOrderId:10,blending:THREE.CustomBlending,blendSrc:THREE.SrcAlphaFactor,blendDst:THREE.OneMinusSrcAlphaFactor,blendSrcAlpha:THREE.OneFactor,blendDstAlpha:THREE.OneMinusSrcAlphaFactor}),this.add(this.fire.particleMesh),this.add(this.smoke.particleMesh)}_initializeSizetween(e){this.viewer&&"ViewerGIS"==this.viewer.viewerType?e=54.827058574958734:e/=.01421,this.fire.initializeSizetween(e,this.fireScale),this.smoke.initializeSizetween(e,this.fireScale)}update(){this.fire.update(),this.smoke.update()}getPosition(){return this.firePosition}setPosition(e){this.firePosition=e;let t=this.viewer?this.viewer.globalUnitUtil.translate(e,["x","y","z"]):e;if(this.position.set(t.x,t.y,t.z),this.updateMatrixWorld(),this.originBox){var i=this.originBox.clone();this.box=i.applyMatrix4(this.matrix),this.levelName=null}}getScale(){return this.fireScale}setScale(e){this.scale.set(e,e,e),this.updateMatrixWorld(),this.fire.setScale(e),this.smoke.setScale(e),this.fireScale=e}_setColor(e){e&&e.smokeColor?this.smokeColor=new THREE.Vector3(e.smokeColor.r/255,e.smokeColor.g/255,e.smokeColor.b/255):this.smokeColor=new THREE.Vector3(0,0,0),this.smoke.setColor(this.smokeColor)}_setType(t){if(this.fireType!=t){this.fireType=t;var i=.5*this.smokeConcentration;t==e.Bimface.Plugins.ParticleSystem.FireType.Smoke?(this.smoke.setPositionBaseZ(0),this.fire.particleMesh.visible=!1,this.smoke.setOpacityTween(0,1.3,i,i)):(this.smoke.setPositionBaseZ(2600),this.fire.particleMesh.visible=!0,this.smoke.setOpacityTween(.5,1.7,0,i))}}_setOriginBoundingBox(){if(this.originBox){this.originBox.max.z=this.originBox.max.z*this.fireBBoxScale,this.originBox.max.y=this.originBox.max.y*this.fireBBoxScale,this.originBox.min.y=this.originBox.min.y*this.fireBBoxScale,this.originBox.max.x=this.originBox.max.x*this.fireBBoxScale,this.originBox.min.x=this.originBox.min.x*this.fireBBoxScale;var e=this.originBox.clone();this.box=e.applyMatrix4(this.matrix)}}_setSmokeConcentration(t){if(this.smokeConcentration!=t){this.smokeConcentration=t;var i=.5*this.smokeConcentration;this.fireType==e.Bimface.Plugins.ParticleSystem.FireType.Smoke?this.smoke.setOpacityTween(0,1.3,i,i):this.smoke.setOpacityTween(.5,1.7,0,i)}}_loadTexture(){var e=new THREE.TextureLoader;this.fireParticle=e.load(`${window.BimfaceLoaderConfig.fullStaticHost}/images/fireParticle.png`),this.smokeParticle=e.load(`${window.BimfaceLoaderConfig.fullStaticHost}/images/smokeParticle.png`)}}i.Fire=n}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Heatmap").Heatmap2DConfig=class{constructor(){this.boundary=[],this.data=[],this.max=null,this.min=0,this.radius=40,this.viewer=null,this.enableColorLegend=!1}},cs=window,us=function(){var e,t={defaultRadius:40,defaultRenderer:"canvas2d",defaultGradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},defaultMaxOpacity:1,defaultMinOpacity:0,defaultBlur:.85,defaultXField:"x",defaultYField:"y",defaultValueField:"value",plugins:{}},i=function(){var e=function(e){this._coordinator={},this._data={},this._radi={},this._min=10,this._max=1,this._xField=e.xField||e.defaultXField,this._yField=e.yField||e.defaultYField,this._valueField=e.valueField||e.defaultValueField,e.radius&&(this._cfgRadius=e.radius)},i=t.defaultRadius;return e.prototype={_organiseData:function(e,t){var n=e[this._xField],o=e[this._yField],s=this._radi,r=this._data,a=this._max,l=this._min,h=e[this._valueField]||1,d=e.radius||this._cfgRadius||i;r[n]||(r[n]={},s[n]={}),r[n][o]?r[n][o]+=h:(r[n][o]=h,s[n][o]=d);var c=r[n][o];return c>a?(t?this.setDataMax(c):this._max=c,!1):c<l?(t?this.setDataMin(c):this._min=c,!1):{x:n,y:o,value:h,radius:d,min:l,max:a}},resetRadius:function(e){var t=e/(this._cfgRadius||i);for(var n in this._radi)if(this._radi.hasOwnProperty(n))for(var o in this._radi[n])this._radi[n].hasOwnProperty(o)&&(this._radi[n][o]=this._radi[n][o]*t);this._cfgRadius=e},_unOrganizeData:function(){var e=[],t=this._data,i=this._radi;for(var n in t)for(var o in t[n])e.push({x:n,y:o,radius:i[n][o],value:t[n][o]});return{min:this._min,max:this._max,data:e}},_onExtremaChange:function(){this._coordinator.emit("extremachange",{min:this._min,max:this._max})},addData:function(){if(arguments[0].length>0)for(var e=arguments[0],t=e.length;t--;)this.addData.call(this,e[t]);else this._organiseData(arguments[0],!0);return this},setData:function(e){var t=e.data,i=t.length;this._data={},this._radi={};for(var n=0;n<i;n++)this._organiseData(t[n],!1);return this._max=e.max,this._min=e.min||0,this._onExtremaChange(),this._coordinator.emit("renderall",this._getInternalData()),this},removeData:function(){},setDataMax:function(e){return this._max=e,this._onExtremaChange(),this},setDataMin:function(e){return this._min=e,this._onExtremaChange(),this},setCoordinator:function(e){this._coordinator=e},_getInternalData:function(){return{max:this._max,min:this._min,data:this._data,radi:this._radi}},getData:function(){return this._unOrganizeData()},getDataMax:function(){return this._max},getDataMin:function(){return this._min}},e}(),n=function(){var e=function(e){var t=e.gradient||e.defaultGradient,i=document.createElement("canvas"),n=i.getContext("2d");i.width=256,i.height=1;var o=n.createLinearGradient(0,0,256,1);for(var s in t)o.addColorStop(s,t[s]);return n.fillStyle=o,n.fillRect(0,0,256,1),n.getImageData(0,0,256,1).data},t=function(e,t){var i=document.createElement("canvas"),n=i.getContext("2d"),o=e,s=e;if(i.width=i.height=2*e,1==t)n.beginPath(),n.arc(o,s,e,0,2*Math.PI,!1),n.fillStyle="rgba(0,0,0,1)",n.fill();else{var r=n.createRadialGradient(o,s,e*t,o,s,e);r.addColorStop(0,"rgba(0,0,0,1)"),r.addColorStop(1,"rgba(0,0,0,0)"),n.fillStyle=r,n.fillRect(0,0,2*e,2*e)}return i};function i(t){var i=t.container,n=this.shadowCanvas=document.createElement("canvas"),o=this.canvas=t.canvas||document.createElement("canvas"),s=(this._renderBoundaries=[1e4,1e4,0,0],getComputedStyle(t.container)||{});o.className="heatmap-canvas",this._width=o.width=n.width=t.width||+s.width.replace(/px/,""),this._height=o.height=n.height=t.height||+s.height.replace(/px/,""),this.shadowCtx=n.getContext("2d"),this.ctx=o.getContext("2d"),o.style.cssText=n.style.cssText="position:absolute;left:0;top:0;",i.style.position="relative",i.appendChild(o),this._palette=e(t),this._setStyles(t)}return i.prototype={renderPartial:function(e){this._drawAlpha(e),this._colorize()},renderAll:function(e){this._clear(),this._drawAlpha(function(e){for(var t=[],i=e.min,n=e.max,o=e.radi,s=(e=e.data,Object.keys(e)),r=s.length;r--;)for(var a=s[r],l=Object.keys(e[a]),h=l.length;h--;){var d=l[h],c=e[a][d],u=n-i==0?0:o[a][d]*(c-i)/(n-i);u<0||t.push({x:a,y:d,value:c,radius:u})}return{min:i,max:n,data:t}}(e)),this._colorize()},_updateGradient:function(t){this._palette=e(t)},updateConfig:function(e){e.gradient&&this._updateGradient(e),this._setStyles(e)},setDimensions:function(e,t){this._width=e,this._height=t,this.canvas.width=this.shadowCanvas.width=e,this.canvas.height=this.shadowCanvas.height=t},_clear:function(){this.shadowCtx.clearRect(0,0,this._width,this._height),this.ctx.clearRect(0,0,this._width,this._height)},_setStyles:function(e){this._blur=0==e.blur?0:e.blur||e.defaultBlur,this._width=this.canvas.width=this.shadowCanvas.width=e.width||this._width,this._height=this.canvas.height=this.shadowCanvas.height=e.height||this._height,e.backgroundColor&&(this.canvas.style.background=e.backgroundColor),this._opacity=255*(e.opacity||0),this._maxOpacity=255*(e.maxOpacity||e.defaultMaxOpacity),this._minOpacity=255*(e.minOpacity||e.defaultMinOpacity),this._useGradientOpacity=!!e.useGradientOpacity},_drawAlpha:function(e){for(var i=this._min=e.min,n=this._max=e.max,o=(e=e.data||[]).length,s=1-this._blur;o--;){var r=e[o],a=r.x,l=r.y,h=r.radius,d=Math.min(r.value,n),c=a-h,u=l-h,g=this.shadowCtx,p=t(h,s),m=(d-i)/(n-i);g.globalAlpha=m<.01?.01:m,p.height>0&&p.width>0&&g.drawImage(p,c,u),c<this._renderBoundaries[0]&&(this._renderBoundaries[0]=c),u<this._renderBoundaries[1]&&(this._renderBoundaries[1]=u),c+2*h>this._renderBoundaries[2]&&(this._renderBoundaries[2]=c+2*h),u+2*h>this._renderBoundaries[3]&&(this._renderBoundaries[3]=u+2*h)}},_colorize:function(){var e=this._renderBoundaries[0],t=this._renderBoundaries[1],i=this._renderBoundaries[2]-e,n=this._renderBoundaries[3]-t,o=(e=0,t=0,i=this._width,n=this._height,this._width),s=this._height,r=this._opacity,a=this._maxOpacity,l=this._minOpacity,h=this._useGradientOpacity;e<0&&(e=0),t<0&&(t=0),e+i>o&&(i=o-e),t+n>s&&(n=s-t);for(var d=this.shadowCtx.getImageData(e,t,i,n),c=d.data,u=c.length,g=this._palette,p=3;p<u;p+=4){var m,f=c[p],w=4*f;w&&(m=r>0?r:f<a?f<l?l:f:a,c[p-3]=g[w],c[p-2]=g[w+1],c[p-1]=g[w+2],c[p]=h?g[w+3]:m)}this.ctx.putImageData(d,e,t),this._renderBoundaries=[1e3,1e3,0,0]},getValueAt:function(e){var t=this.shadowCtx.getImageData(e.x,e.y,1,1).data[3],i=this._max,n=this._min;return Math.abs(i-n)*(t/255)>>0},getDataURL:function(){return this.canvas.toDataURL()},getCanvas:function(){return this.canvas}},i}(),o=(e=!1,"canvas2d"===t.defaultRenderer&&(e=n),e),s=function(){for(var e={},t=arguments.length,i=0;i<t;i++){var n=arguments[i];for(var o in n)e[o]=n[o]}return e},r=function(){var e=function(){function e(){this.cStore={}}return e.prototype={on:function(e,t,i){var n=this.cStore;n[e]||(n[e]=[]),n[e].push((function(e){return t.call(i,e)}))},emit:function(e,t){var i=this.cStore;if(i[e])for(var n=i[e].length,o=0;o<n;o++)(0,i[e][o])(t)}},e}(),n=function(e){var t=e._renderer,i=e._coordinator,n=e._store;i.on("renderpartial",t.renderPartial,t),i.on("renderall",t.renderAll,t),i.on("extremachange",(function(t){e._config.onExtremaChange&&e._config.onExtremaChange({min:t.min,max:t.max,gradient:e._config.gradient||e._config.defaultGradient})})),n.setCoordinator(i)};function r(){var r=this._config=s(t,arguments[0]||{});if(this._coordinator=new e,r.plugin){var a=r.plugin;if(!t.plugins[a])throw new Error("Plugin '"+a+"' not found. Maybe it was not registered.");var l=t.plugins[a];this._renderer=new l.renderer(r),this._store=new l.store(r)}else this._renderer=new o(r),this._store=new i(r);n(this)}return r.prototype={addData:function(){return this._store.addData.apply(this._store,arguments),this},removeData:function(){return this._store.removeData&&this._store.removeData.apply(this._store,arguments),this},setData:function(){return this._store.setData.apply(this._store,arguments),this},setDataMax:function(){return this._store.setDataMax.apply(this._store,arguments),this},setDataMin:function(){return this._store.setDataMin.apply(this._store,arguments),this},configure:function(e){return this._config=s(this._config,e),this._renderer.updateConfig(this._config),e.radius&&this._store.resetRadius(e.radius),this},repaint:function(){return this._coordinator.emit("renderall",this._store._getInternalData()),this},getDataMax:function(){return this._store.getDataMax()},getDataMin:function(){return this._store.getDataMin()},getData:function(){return this._store.getData()},getDataURL:function(){return this._renderer.getDataURL()},getCanvas:function(){return this._renderer.getCanvas()},getValueAt:function(e){return this._store.getValueAt?this._store.getValueAt(e):this._renderer.getValueAt?this._renderer.getValueAt(e):null}},r}();return{create:function(e){return new r(e)},register:function(e,i){t.plugins[e]=i}}},"undefined"!=typeof module&&module.exports?module.exports=us():"function"==typeof define&&define.amd?define(us):cs.heatmapJS=us(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Heatmap");class i extends e.Bimface.Plugins.Geometry.Plane{constructor(e,t){super(e),this.useBorder=!1,this.setRotationFromQuaternion(t),P(this)}_createPlane(){var t=this,i=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(this.points);if(i.invalid)return!1;t.handlePoints=i.handlePoints,t.minX=i.minX,t.minY=i.minY,t.maxX=i.maxX,t.maxY=i.maxY;var n=this._createMeshMaterial(),o=new THREE.Mesh(i,n);return o.position.copy(new THREE.Vector3(0,0,t.height)),o.renderOrder=CLOUD.GlobalData.IncrementRender?100:-1,t.add(o),!0}_createMeshMaterial(){return new CLOUD.MeshBasicMaterial({side:THREE.DoubleSide,transparent:!0})}setMapByCanvas(e){var t=this.children[0];if(t){var i=new THREE.Texture(e);i.flipY=!1,t.material.transparent=!0,t.material.map=i,t.material.needsUpdate=!0}}updateMap(){var e=this.children[0];e&&(e.material.map.needsUpdate=!0)}}t.Heatmap2DPlane=i}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Heatmap");let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class o extends THREE.Group{constructor(i){t.send("Bimface.Plugins.Heatmap.Heatmap2D","bf_c_heatmap_new"),super(),i?(P(this),this.boundary=i.boundary,this.data=i.data,this.max=i.max,this.min=i.min,this.radius=i.radius,this.viewer=i.viewer,this._enableColorLegend=i.enableColorLegend,this.defaultGradient={.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},this.defaultLegendBackground="linear-gradient(180deg, #FF2600 0%, #EFF900 14%, #00F900 38%, #0349E0 66%, #EBECFF 100%)",this.gradient=Object.assign({},this.defaultGradient),this.legendBackground=this.defaultLegendBackground,this.viewer?"Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS?(this._enableColorLegend&&this._createColorLegend(),this._rotateBoundary(this.boundary),this.plane=new e.Bimface.Plugins.Heatmap.Heatmap2DPlane(this._newBoundary,this._reverseQuaternion),this._externalNeedScale=!1,"invalidPlane"!=this.plane.type&&(this._initializeHeatmap(),this.needRepaintHeatmap=!1,this.plane.setMapByCanvas(this.heatmap.getCanvas()),this.add(this.plane),this._addSence(),this.maxSetted=!1,this.disPickable=!0,this.tmpV=new THREE.Vector3)):console.log("ERROR::viewer must not be empty or viewer2d."):console.log("ERROR::viewer must not be empty.")):console.log("ERROR::heatmap2DConfig must not be empty.")}_rotateBoundary(e){function t(e,t){return new THREE.Vector3(e.x-t.x,e.y-t.y,e.z-t.z)}let i=this,n=t(e[1],e[0]).normalize(),o=t(e[2],e[1]).normalize(),s=n.cross(o).normalize(),r=new THREE.Quaternion;r.setFromUnitVectors(s,new THREE.Vector3(0,0,1)),this._quaternion=r;let a=[];e.forEach((function(e){let t=i.viewer.globalUnitUtil.translate(e,["x","y","z"]),n=new THREE.Vector3(t.x,t.y,t.z);n.applyQuaternion(r),a.push(n)})),this._reverseQuaternion=r.clone().setFromUnitVectors(new THREE.Vector3(0,0,1),s),this._newBoundary=a}_addSence(){var t=this;t.objectTpye="Heatmap2D-",t.objectId=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.objectTpye+t.objectId,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t)}_createColorLegend(){let e=n.create("div","bf-colorLegend");e.innerHTML="<div class='bf-colorLegend-card'></div><span class='bf-colorLegend-max'></span><span class='bf-colorLegend-min'></span>",this.viewer.getDomElement().appendChild(e),this.colorLegendPanel=e,this._enableColorLegend=!0,this._updateColorLegend()}enableColorLegend(e){e?this.colorLegendPanel?(this._showColorLegendPanel(!0),this._updateColorLegend()):this._createColorLegend():this._showColorLegendPanel(!1)}_updateColorLegend(){if(this.colorLegendPanel&&this._enableColorLegend){let e=this.colorLegendPanel.querySelector(".bf-colorLegend-max"),t=this.colorLegendPanel.querySelector(".bf-colorLegend-min");e.innerText=parseInt(this.getDataMax()),t.innerText=parseInt(this.getDataMin())}}_showColorLegendPanel(e){this.colorLegendPanel&&(this._enableColorLegend=e,this.colorLegendPanel.style.display=e?"block":"none")}_disposeColorLegendPanel(){this.colorLegendPanel&&(this.colorLegendPanel.parentElement.removeChild(this.colorLegendPanel),this.colorLegendPanel=null)}_initializeHeatmap(){var e=256,t=256;this.heatmap=heatmapJS.create({container:document.createElement("div"),width:e,height:t,gradient:this.gradient});var i=this.plane.maxX-this.plane.minX,n=this.plane.maxY-this.plane.minY;this.dataScale={x:e/i,y:t/n},this.data.length>0&&this.setData(this.data)}_changeDataForHeatmap(e){let t=this.tmpV,i=this.viewer.globalUnitUtil.translate(e,["x","y","z"]);t.set(i.x,i.y,i.z||0),t.applyQuaternion(this._quaternion);var n=(t.x-this.plane.minX)*this.dataScale.x;n=n>0?n:0,o=o>0?o:0;var o=(t.y-this.plane.minY)*this.dataScale.y;return{x:n,y:o,value:e.value}}dispose(){null!=this.extObjMngId&&this.extObjMng.removeNodeById(this.extObjMngId),F.removeExternalObjectManager(this.objectTpye),this.plane.dispose(),this.plane=null,this.heatmap=null,this.viewer=null,this.boundary=null,this.data=null,this.dataScale=null,this.objectId=null,this._disposeColorLegendPanel()}addData(e){if("invalidPlane"!=this.plane.type)if(e instanceof Array&&!(e.length<=0)){for(var t=[],i=0,n=e.length;i<n;i++){var o=this._changeDataForHeatmap(e[i]);t.push(o),this.data.push(e[i]),this.maxSetted||(this.max=this.max>o.value?this.max:o.value)}this.needRepaintHeatmap=!0,this.heatmap.addData(t),this._updateColorLegend()}else console.log("ERROR::data must be array and length >0")}setData(e){if("invalidPlane"!=this.plane.type)if(e instanceof Array&&!(e.length<=0)){this.data=e,this.max=this.maxSetted?this.max:this.min;for(var t=[],i=0,n=e.length;i<n;i++){var o=this._changeDataForHeatmap(e[i]);t.push(o),this.maxSetted||(this.max=this.max>o.value?this.max:o.value)}this.heatmap.setData({max:this.max,min:this.min,data:t}),this._updateColorLegend()}else console.log("ERROR::data must be array and length >0")}setDataMax(e){"invalidPlane"!=this.plane.type&&(this.maxSetted=!0,this.max=e,this.heatmap.setDataMax(e),this.needRepaintHeatmap=!0,this._updateColorLegend())}setDataMin(e){"invalidPlane"!=this.plane.type&&(this.min=e,this.heatmap.setDataMin(e),this.needRepaintHeatmap=!0,this._updateColorLegend())}setRadius(e){"invalidPlane"!=this.plane.type&&(this.radius=e,this.heatmap.configure({radius:e}),this.needRepaintHeatmap=!0)}getData(){return this.data}getDataMax(){return this.max}getDataMin(){return this.min}getRadius(){return this.radius}getBoundary(){return this.boundary}hide(){this.plane.visible=!1,this.viewer.render(),this._showColorLegendPanel(!1)}show(){this.plane.visible=!0,this.viewer.render(),this._showColorLegendPanel(!0)}update(){"invalidPlane"!=this.plane.type&&(this.needRepaintHeatmap&&(this.heatmap.repaint(),this.needRepaintHeatmap=!1),this.plane.updateMap(),this.viewer.render(),this._updateColorLegend())}setHeatMapColor(t){if(String.prototype.insert=function(e,t){return e>0?this.substring(0,e)+t+this.substr(e):t+this},this.gradient={},this.legendBackground="linear-gradient(180deg)",Object.entries(t).sort().reverse().forEach((([t,i])=>{if(!(i instanceof e.Web.Graphics.Color))return console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),void(this.gradient=Object.assign({},this.defaultGradient));this.gradient=Object.assign(this.gradient,{[t]:i.getRGB()});const n=this.legendBackground.lastIndexOf(")"),o=100*(1-[t])+"%";this.legendBackground=this.legendBackground.insert(n,`, ${i.getRGB()} ${o}`)})),this.colorLegendPanel&&this._enableColorLegend){this.colorLegendPanel.querySelector(".bf-colorLegend-card").style.setProperty("background",this.legendBackground)}this._initializeHeatmap(),this.needRepaintHeatmap=!1,this.plane.setMapByCanvas(this.heatmap.getCanvas()),this.setRadius(this.getRadius()),this.update()}getHeatMapColor(){return this.gradient}restoreHeatMapColor(){if(this.gradient=Object.assign({},this.defaultGradient),this.legendBackground=this.defaultLegendBackground,this.colorLegendPanel&&this._enableColorLegend){this.colorLegendPanel.querySelector(".bf-colorLegend-card").style.setProperty("background",this.legendBackground)}this._initializeHeatmap(),this.needRepaintHeatmap=!1,this.plane.setMapByCanvas(this.heatmap.getCanvas()),this.setRadius(this.getRadius()),this.update()}getBoundingBox(){return this.viewer.globalUnitUtil.revertBBox(this.box)}}i.Heatmap2D=o}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Heatmap");let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=new THREE.Matrix4;class s extends THREE.Group{constructor(i){if(t.send("Bimface.Plugins.Heatmap.Heatmap3D","bf_c_heatmap3d_new"),super(),i)if(P(this),this.viewer=i.viewer,this.boundary=i.boundary,this.boundaryHeight=i.boundaryHeight,this._boundary=this.viewer.globalUnitUtil.translate(i.boundary,["x","y","z"]),this._boundaryHeight=this.viewer.globalUnitUtil.translate(i.boundaryHeight),this.data=i.data,this.max=i.max,this._maxSetted=null!=this.max,this.min=i.min,this.radius=i.radius,this._enableColorLegend=i.enableColorLegend,this.defaultGradient={.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},this.defaultLegendBackground="linear-gradient(180deg, #FF2600 0%, #EFF900 14%, #00F900 38%, #0349E0 66%, #EBECFF 100%)",this.gradient=Object.assign({},this.defaultGradient),this.legendBackground=this.defaultLegendBackground,this.viewer)if("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS){if(this._enableColorLegend&&this._createColorLegend(),this._invalid=!1,this._checkIntersect(this._boundary))return console.warn("Failed to create, the boundary is self-intersecting."),void(this._invalid=!0);this.handlePoints.push(new THREE.Vector2(this._boundary[0].x,this._boundary[0].y)),this.offsetZ=this._boundary[0].z,this._needsUpdate=!1,this._radiusScale=new THREE.Vector3,this._normalizeMatrix=new THREE.Matrix4,this._getTransformInfo(),this._heatmap=new CLOUD.Heatmap3D({viewer:this.viewer.getViewer(),boundary:this.handlePoints,height:this._boundaryHeight,offsetZ:this.offsetZ,data:this._handleHeatmapData(),normalizeMatrix:this._normalizeMatrix,radiusScale:this._radiusScale,resolution:this._resolution}),this._externalNeedScale=!1,this.add(this._heatmap),this._addSence(),this.disPickable=!0,this.tmpV=new THREE.Vector3}else console.log("ERROR::viewer must not be empty or viewer3D.");else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::heatmap3DConfig must not be empty.")}_checkIntersect(t){var i=this,n=new THREE.Vector2(t[0].x,t[0].y);i.handlePoints=[],i.handlePoints.push(n),i.minX=n.x,i.maxX=n.x,i.minY=n.y,i.maxY=n.y;for(var o=1;o<t.length;o++){if(null==t[o].x||null==t[o].y||null==t[o].z)return console.log("Failed to create, the format is not right, please follow [{x:,y:,z:},...]"),!0;n=new THREE.Vector2(t[o].x,t[o].y);i.handlePoints.push(n),i.minX>n.x&&(i.minX=n.x),i.minY>n.y&&(i.minY=n.y),i.maxX<n.x&&(i.maxX=n.x),i.maxY<n.y&&(i.maxY=n.y)}return e.Bimface.Plugins.Geometry.PlaneBufferGeometry.checkIntersect(i.handlePoints)}_getTransformInfo(){this._resolution={x:81,y:81,z:81};var e=this.maxX-this.minX,t=this.maxY-this.minY;this.dataScale={x:this._resolution.x/e,y:this._resolution.y/t,z:this._resolution.z/this._boundaryHeight},this._normalizeMatrix.makeTranslation(-this.minX,-this.minY,0);let i=Math.max(Math.max(e,t),this._boundaryHeight);o.makeScale(1/e,1/t,1/this._boundaryHeight),this._normalizeMatrix.multiplyMatrices(o,this._normalizeMatrix),this._radiusScale.set(i/e,i/t,i/this._boundaryHeight)}_handleHeatmapData(){var e=this.data;if(!this._maxSetted){this.max=this.min;for(var t=0,i=e.length;t<i;t++)this.max=this.max>e[t].value?this.max:e[t].value}var n=[];for(t=0,i=e.length;t<i;t++){var o=this._changeDataForHeatmap(e[t]);n.push(o)}return n}_changeDataForHeatmap(e){var t=((e=this.viewer.globalUnitUtil.translate(e,["x","y","z"])).x-this.minX)*this.dataScale.x;t=t>0?t:0,i=i>0?i:0;var i=(e.y-this.minY)*this.dataScale.y,n=(e.z-this.offsetZ)*this.dataScale.z,o=(e.value-this.min)/(this.max-this.min);o=Math.min(Math.max(0,o),1);var s=this.radius*o/256*this._resolution.x;return{x:t,y:i,z:n,value:o,radius:s=Math.max(0,s)}}_addSence(){var t=this;t.objectTpye="Heatmap3D-",t.objectId=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.objectTpye+t.objectId,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t)}dispose(){null!=this.extObjMngId&&this.extObjMng.removeNodeById(this.extObjMngId),F.removeExternalObjectManager(this.objectTpye),this._heatmap.dispose(),this._heatmap=null,this.heatmap=null,this.viewer=null,this.boundary=null,this.data=null,this.dataScale=null,this.objectId=null,this._disposeColorLegendPanel()}addData(e){if(!this._invalid)if(e instanceof Array&&!(e.length<=0)){for(var t=0,i=e.length;t<i;t++)this.data.push(e[t]);this._needsUpdate=!0,this._updateColorLegend()}else console.log("ERROR::data must be array and length >0")}setData(e){this._invalid||(e instanceof Array&&!(e.length<=0)?(this.data=e,this._needsUpdate=!0,this._updateColorLegend()):console.log("ERROR::data must be array and length >0"))}setDataMax(e){this._invalid||(this._maxSetted=!0,this.max!=e&&(this.max=e,this._needsUpdate=!0,this._updateColorLegend()))}setDataMin(e){this._invalid||this.min==e||(this.min=e,this._needsUpdate=!0,this._updateColorLegend())}setRadius(e){this._invalid||this.radius==e||(this.radius=e,this._needsUpdate=!0)}getData(){return this.data}getDataMax(){return this.max}getDataMin(){return this.min}getRadius(){return this.radius}getBoundary(){return this.boundary}getBoundaryHeight(){return this.boundaryHeight}hide(){this.visible=!1,this.viewer.render(),this._showColorLegendPanel(!1)}show(){this.visible=!0,this.viewer.render(),this._showColorLegendPanel(!0)}update(){if(!this._invalid){if(this._needsUpdate){let e=this._handleHeatmapData();this._heatmap.updateDensityMap(e),this._needsUpdate=!1}this.viewer.render(),this._updateColorLegend()}}_createColorLegend(){let e=n.create("div","bf-colorLegend");e.innerHTML="<div class='bf-colorLegend-card'></div><span class='bf-colorLegend-max'></span><span class='bf-colorLegend-min'></span>",this.viewer.getDomElement().appendChild(e),this.colorLegendPanel=e,this._enableColorLegend=!0,this._updateColorLegend()}enableColorLegend(e){e?this.colorLegendPanel?(this._showColorLegendPanel(!0),this._updateColorLegend()):this._createColorLegend():this._showColorLegendPanel(!1)}_updateColorLegend(){if(this.colorLegendPanel&&this._enableColorLegend){let e=this.colorLegendPanel.querySelector(".bf-colorLegend-max"),t=this.colorLegendPanel.querySelector(".bf-colorLegend-min");e.innerText=parseInt(this.getDataMax()),t.innerText=parseInt(this.getDataMin())}}_showColorLegendPanel(e){this.colorLegendPanel&&(this._enableColorLegend=e,this.colorLegendPanel.style.display=e?"block":"none")}_disposeColorLegendPanel(){this.colorLegendPanel&&(this.colorLegendPanel.parentElement.removeChild(this.colorLegendPanel),this.colorLegendPanel=null)}setHeatMapColor(t){if(String.prototype.insert=function(e,t){return e>0?this.substring(0,e)+t+this.substr(e):t+this},this.gradient={},this.legendBackground="linear-gradient(180deg)",Object.entries(t).sort().reverse().forEach((([t,i])=>{if(!(i instanceof e.Web.Graphics.Color))return console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),void(this.gradient=Object.assign({},this.defaultGradient));this.gradient=Object.assign(this.gradient,{[t]:i.getRGB()});const n=this.legendBackground.lastIndexOf(")"),o=100*(1-[t])+"%";this.legendBackground=this.legendBackground.insert(n,`, ${i.getRGB()} ${o}`)})),this._heatmap.setGradient(this.gradient),this.viewer.render(),this.colorLegendPanel&&this._enableColorLegend){this.colorLegendPanel.querySelector(".bf-colorLegend-card").style.setProperty("background",this.legendBackground)}}getHeatMapColor(){return this.gradient}restoreHeatMapColor(){if(this.gradient=Object.assign({},this.defaultGradient),this._heatmap.setGradient(this.gradient),this.viewer.render(),this.legendBackground=this.defaultLegendBackground,this.colorLegendPanel&&this._enableColorLegend){this.colorLegendPanel.querySelector(".bf-colorLegend-card").style.setProperty("background",this.legendBackground)}}getBoundingBox(){return this.viewer.globalUnitUtil.revertBBox(this.box)}}i.Heatmap3D=s}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Heatmap");t.Heatmap3DConfig=class{constructor(){this.boundary=[],this.boundaryHeight=30,this.data=[],this.max=null,this.min=0,this.radius=40,this.viewer=null,this.enableColorLegend=!1}}}();class ys{constructor(t){if(t)if(t.viewer){if("Viewer3D"===t.viewer.viewerType)this.isViewerGIS=!1;else{if(!(t.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");this.isViewerGIS=!0}t.color instanceof e.Web.Graphics.Color?this.color=t.color:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),this.duration=t.duration,this.originPosition=t.originPosition,this.radius=t.radius,this.emitPosition=t.emitPosition,this.progressive=t.progressive,this.range=[],this.bimViewer=t.viewer,this.viewer=this.bimViewer.getViewer(),this.scene=this.viewer.getScene(),this.id=e.Web.Lang.Utility.UUID.createUUID()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::ringScanEffectConfig must not be empty.")}destroy(){}update(){}hide(){}show(){}getColor(){return this.color}getDuration(){return this.duration}getProgressive(){return this.progressive}getOriginPosition(){return this.originPosition}getRadius(){return this.radius}restoreHeightRange(){this.range=[]}setHeightRange(e){e instanceof Array&&2==e.length&&(this.range=e)}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setDuration(e){this.duration=e}setOriginPosition(e){this.originPosition=e}setProgressive(e){this.progressive=e}setRadius(e){this.radius=e}play(){}pause(){}stop(){}}class vs extends ys{constructor(e){super(e),this._updateParameter(),this.ringScanEffect=this.viewer.addRingScanEffect({color:this._color,alpha:this._alpha,duration:this.duration,originPosition:this._originPosition,emitPosition:this._emitPosition,radius:this._radius,progressive:this.progressive,id:this.id,range:this._range})}_updateParameter(){if(this._color=new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),this._alpha=this.color.alpha,this._radius=this.bimViewer.viewerAdapter.worldToDrawing({x:this.radius,y:0,z:0}).x,this._originPosition=this.bimViewer.viewerAdapter.worldToDrawing(this.originPosition),this._emitPosition={x:this._originPosition.x,y:this._originPosition.y+1,z:this._originPosition.z},2==this.range.length){this._range=[];for(let e=0;e<this.range.length;e++){const t=this.bimViewer.viewerAdapter.worldToDrawing({x:this.range[e],y:0,z:0}).x;this._range.push(t)}}else this._range=[]}destroy(){this.viewer.deleteRingScanEffect(this.id)}update(){this._updateParameter(),this.ringScanEffect.setOpts({color:this._color,alpha:this._alpha,duration:this.duration,originPosition:this._originPosition,emitPosition:this._emitPosition,radius:this._radius,progressive:this.progressive,range:this._range})}hide(){this.ringScanEffect.enabled=!1}show(){this.ringScanEffect.enabled=!0}setRadius(e){this.radius=e}play(){this.ringScanEffect.play()}pause(){this.ringScanEffect.pause()}stop(){this.ringScanEffect.stop()}setOriginPosition(e){this.originPosition=e,this._originPosition=this.bimViewer.viewerAdapter.worldToDrawing(this.originPosition)}}class bs extends ys{constructor(e){super(e),this._updateParameter(),this.ringScanEffect=new CLOUD.RingScan({color:this._color,alpha:this._alpha,duration:this.duration,originPosition:this._originPosition,radius:this._radius,progressive:this.progressive}),this._externalNeedScale=!1,this._addSence()}_updateParameter(){this._color=new THREE.Vector3(this.color.red/255,this.color.green/255,this.color.blue/255),this._alpha=this.color.alpha,this._originPosition=this.bimViewer.globalUnitUtil.translate(this.originPosition,["x","y","z"]),this._radius=this.bimViewer.globalUnitUtil.translate(this.radius)}_addSence(){this.objectTpye="ring-",this.id=e.Web.Lang.Utility.UUID.createUUID(),this.extObjMngId=this.objectTpye+this.id,this.extObjMng=F.getExternalObjectManager(this.bimViewer,this.objectTpye),this.extObjMng.addNode(this.extObjMngId,this.ringScanEffect)}destroy(){null!==this.ringScanEffect&&(this.ringScanEffect.destroy(),null!=this.extObjMngId&&this.extObjMng.removeNodeById(this.extObjMngId),F.removeExternalObjectManager(this.objectTpye),this.ringScanEffect=null)}update(){this._updateParameter(),this.ringScanEffect.effectOpt({color:this._color,alpha:this._alpha,duration:this.duration,originPosition:this._originPosition,radius:this._radius,progressive:this.progressive})}hide(){this.ringScanEffect.hide()}show(){this.ringScanEffect.show()}setRadius(e){this.radius!=e&&(this.radius=e,this._radius=this.bimViewer.globalUnitUtil.translate(e),this.ringScanEffect.resetPath=!0)}play(){this.ringScanEffect.play()}pause(){this.ringScanEffect.pause()}stop(){this.ringScanEffect.stop()}setOriginPosition(e){this.originPosition=e,this.ringScanEffect.resetPath=!0,this._originPosition=this.bimViewer.globalUnitUtil.translate(this.originPosition,["x","y","z"])}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.RingScanEffect=class{constructor(e){t.send("Bimface.Plugins.Animation.RingScanEffect","bf_c_RingScan_new"),this.isEnableComponentsScanned=e.enableComponentsScanned,!0===e.enableComponentsScanned?this.ringScanEffectImpl=new vs(e):this.ringScanEffectImpl=new bs(e),P(this)}destroy(){this.ringScanEffectImpl.destroy()}enableComponentsScanned(e){const t={viewer:this.ringScanEffectImpl.bimViewer,color:this.getColor(),duration:this.getDuration(),originPosition:this.getOriginPosition(),radius:this.getRadius(),progressive:this.getProgressive()};this.ringScanEffectImpl.destroy(),this.isEnableComponentsScanned=e,this.ringScanEffectImpl=e?new vs(t):new bs(t)}update(){this.ringScanEffectImpl.update()}hide(){this.ringScanEffectImpl.hide()}show(){this.ringScanEffectImpl.show()}getColor(){return this.ringScanEffectImpl.getColor()}getDuration(){return this.ringScanEffectImpl.getDuration()}getProgressive(){return this.ringScanEffectImpl.getProgressive()}getOriginPosition(){return this.ringScanEffectImpl.getOriginPosition()}getRadius(){return this.ringScanEffectImpl.getRadius()}getSenceType(){return e.Bimface.Common.Type.EffectType.RingScan}getParams(){return{originPosition:this.getOriginPosition(),radius:this.getRadius(),color:this.getColor(),isEnableComponentsScanned:this.isEnableComponentsScanned,duration:this.getDuration(),progressive:this.getProgressive()}}zoomToBoundingBox(){const e=this.ringScanEffectImpl.originPosition,t=this.ringScanEffectImpl.radius;let i=new THREE.Box3(new THREE.Vector3(e.x-t,e.y-t,e.z),new THREE.Vector3(e.x+t,e.y+t,e.z));this.ringScanEffectImpl.viewer.zoomToBBox(i,.5)}restoreHeightRange(){this.ringScanEffectImpl.restoreHeightRange()}setHeightRange(e){this.ringScanEffectImpl.setHeightRange(e)}setColor(e){this.ringScanEffectImpl.setColor(e)}setDuration(e){this.ringScanEffectImpl.setDuration(e)}setOriginPosition(e){this.ringScanEffectImpl.setOriginPosition(e)}setProgressive(e){this.ringScanEffectImpl.setProgressive(e)}setRadius(e){this.ringScanEffectImpl.setRadius(e)}play(){this.ringScanEffectImpl.play()}pause(){this.ringScanEffectImpl.pause()}stop(){this.ringScanEffectImpl.stop()}get id(){return this.ringScanEffectImpl.id}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.RingScanEffectConfig=class{constructor(){this.duration=1e3,this.color=new e.Web.Graphics.Color("#32d3a6",.8),this.originPosition={x:0,y:0,z:0},this.radius=100,this.progressive=10,this.viewer=null,this.enableComponentsScanned=!0}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem");i.SprayWaterEffect=class{constructor(i){if(t.send("Bimface.Plugins.ParticleSystem.SprayWaterEffect","bf_c_SprayWater_new"),P(this),this.isViewerGIS=!1,i)if(!i.color instanceof e.Web.Graphics.Color&&console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),i.viewer){if("Viewer3D"===i.viewer.viewerType)this.isViewerGIS=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");this.isViewerGIS=!0}this.objectTpye="sprayWater-",this.color=i.color,this.originPosition=i.originPosition,this.originPitch=i.originPitch,this.originYaw=i.originYaw,this.originRadius=i.originRadius,this.originIntensity=i.originIntensity,this.spread=i.spread,this.scale=i.scale,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.viewer3D=i.viewer,this.viewer=i.viewer.getViewer(),this.extObjMngId=this.objectTpye+this.id,this.extObjMng=F.getExternalObjectManager(this.viewer3D,this.objectTpye),this._updateParameter(),this.sprayWaterEffect=new CLOUD.SprayWater({color:this._color,alpha:this._alpha,originPosition:this._originPosition,scale:this._scale,originPitch:this.originPitch,originYaw:this.originYaw,originRadius:this._originRadius,originIntensity:this.originIntensity,spread:this._spread,camera:this.viewer.camera,isGis:this.isViewerGIS,scene:this.viewer.getScene()}),this.sprayWaterEffect._externalNeedScale=!1,this._addSence(),this.sprayWaterEffect.play()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::sprayWaterEffectConfig must not be empty.")}_updateParameter(){this._color=new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),this._alpha=this.color.alpha,this.originIntensity>3&&(this.originIntensity=3),this.isViewerGIS=!!this._isSceneMeterUnit();this._originPosition=this.viewer3D.globalUnitUtil.translate(this.originPosition,["x","y","z"]);const e=this.viewer.worldToDrawing({x:1,y:0,z:0}).x;this._scale=60*this.scale*e,this._spread=this.spread,this._originRadius=this.viewer3D.globalUnitUtil.translate(this.originRadius)*e}_addSence(){this.extObjMng.addNode(this.extObjMngId,this.sprayWaterEffect)}destroy(){null!==this.sprayWaterEffect&&(this.sprayWaterEffect.destroy(),null!=this.extObjMngId&&this.extObjMng.removeNodeById(this.extObjMngId),F.removeExternalObjectManager(this.objectTpye),this.sprayWaterEffect=null)}update(){this._updateParameter(),this.sprayWaterEffect.effectOpt({color:this._color,alpha:this._alpha,scale:this._scale,originPosition:this._originPosition,originPitch:this.originPitch,originYaw:this.originYaw,originRadius:this._originRadius,spread:this._spread,isGis:this.isViewerGIS,originIntensity:this.originIntensity})}hide(){this.sprayWaterEffect.hide()}show(){this.sprayWaterEffect.show()}play(){this.sprayWaterEffect.play()}stop(){this.sprayWaterEffect.stop()}getScale(){return this.scale}getColor(){return this.color}getOriginPosition(){return this.originPosition}getOriginPitch(){return this.originPitch}getOriginYaw(){return this.originYaw}getOriginRadius(){return this.originRadius}getOriginIntensity(){return this.originIntensity}getSpread(){return this.spread}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setScale(e){this.scale=e}setOriginPosition(e){this.originPosition=e}setOriginPitch(e){this.originPitch=e}setOriginYaw(e){this.originYaw=e}setOriginIntensity(e){this.originIntensity=e}setOriginRadius(e){this.originRadius=e}setSpread(e){this.spread=e}_isSceneMeterUnit(){return{m:e.Bimface.Common.Units.LengthUnits.Meter,Meter:e.Bimface.Common.Units.LengthUnits.Meter,mm:e.Bimface.Common.Units.LengthUnits.Millimeter,Millimeter:e.Bimface.Common.Units.LengthUnits.Millimeter}[this.viewer3D.globalUnitUtil.isBimtilesAsset()?"m":this.viewer3D.globalUnitUtil.getDefaultUnit()]===e.Bimface.Common.Units.LengthUnits.Meter}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem");t.SprayWaterEffectConfig=class{constructor(){this.color=new e.Web.Graphics.Color("#FFFFFF",1),this.originPosition={x:0,y:0,z:0},this.spread=1,this.scale=1,this.originPitch=0,this.originYaw=0,this.originRadius=500,this.originIntensity=.5,this.viewer=null}}}(),function(){let t=Object.freeze({Fire:"Fire",Smoke:"Smoke"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem").FireType=t}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem");i.FireEffect=class{constructor(i){if(t.send("Bimface.Plugins.ParticleSystem.FireEffect","bf_c_Fire_new"),P(this),this.isViewerGIS=!1,i)if(i.viewer){if("Viewer3D"===i.viewer.viewerType)this.isViewerGIS=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");this.isViewerGIS=!0}this.fireType=i.fireType,this.scale=i.scale||1,this.viewer=i.viewer,this.position=i.position,this.smokeConcentration=i.smokeConcentration,this.color=i.color,this.fireEffect=new e.Bimface.Plugins.ParticleSystem.Fire(!1,{fireType:this.fireType,viewer:this.viewer}),this.fireEffect._externalNeedScale=!1,this._updateParameter(),this._addSence(),this._setFireBoundingBox()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::fireEffectConfig must not be empty.")}_setFireBoundingBox(){this.fireEffect._setOriginBoundingBox()}_updateParameter(){this._scale=this._isSceneMeterUnit()?.001*this.scale:this.scale,this.fireEffect.setPosition(this.position),this.fireEffect.setScale(this._scale),this.fireEffect._setType(this.fireType),this.fireEffect._setSmokeConcentration(this.smokeConcentration),this.fireEffect._setColor(this.color)}_addSence(){this.objectTpye="fire-",this.id=e.Web.Lang.Utility.UUID.createUUID(),this.extObjMngId=this.objectTpye+this.id,this.extObjMng=F.getExternalObjectManager(this.viewer,this.objectTpye),this.extObjMng.addNode(this.extObjMngId,this.fireEffect)}destroy(){null!=this.extObjMngId&&null!=this.extObjMng&&this.extObjMng.removeNodeById(this.extObjMngId),F.removeExternalObjectManager(this.objectTpye),this.fireEffect=null,this.viewer=null,this.extObjMng=null}update(){this._updateParameter(),this.fireEffect.update()}hide(){this.extObjMng&&this.extObjMng._updateNodeVisible(this.extObjMngId,!1)}show(){this.extObjMng&&this.extObjMng._updateNodeVisible(this.extObjMngId,!0)}getScale(){return this.scale}getType(){return this.fireType}getPosition(){return this.position}getSmokeConcentration(){return this.smokeConcentration}setScale(e){this.scale=e}setPosition(e){this.position=e}setType(e){this.fireType=e}setSmokeConcentration(e){this.smokeConcentration=e}setColor(e){this.color=e}getColor(){return this.color}_isSceneMeterUnit(){const t=this.viewer.globalUnitUtil.isBimtilesAsset()?"m":this.viewer.globalUnitUtil.getDefaultUnit();return t===e.Bimface.Common.Units.LengthUnits.Meter||"m"===t}getSenceType(){return e.Bimface.Common.Type.EffectType.FireEffect}getParams(){return{position:this.position,scale:this.scale,fireType:this.fireType,color:this.color,smokeConcentration:this.smokeConcentration}}zoomToBoundingBox(){let e=this.fireEffect.box;this.viewer.zoomToBoundingBox({boundingBox:e})}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.ParticleSystem");t.FireEffectConfig=class{constructor(){this.position={x:0,y:0,z:0},this.scale=1,this.fireType=e.Bimface.Plugins.ParticleSystem.FireType.Fire,this.color={smokeColor:{r:0,g:0,b:0}},this.smokeConcentration=.6,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Anchor");i.AnchorManager=class{constructor(i){var n=this;t.send("Bimface.Plugins.Anchor.AnchorManager","bf_c_anchorMng_new"),P(this),i?i.viewer&&"Viewer3D"!==!i.viewer.viewerType?(n.viewer3D=i.viewer,n.extObjMng=new e.Bimface.Viewer.ExternalObjectManager(n.viewer3D),n.itemList=[],n._onClick=function(e){if(null!=n.itemList&&n.itemList.length>0)for(var t=0;t<n.itemList.length;t++)if(e.objectId==n.itemList[t].objectId)return void(null!=n.itemList[t].onClickFn&&n.itemList[t].onClickFn())},n._onHover=function(e){if(null!=n.itemList&&n.itemList.length>0)for(var t=0;t<n.itemList.length;t++)if(e.objectId==n.itemList[t].objectId)return void(null!=n.itemList[t].onHoverFn&&n.itemList[t].onHoverFn())},n.viewer3D.addEventListener(e.Bimface.Viewer.Viewer3DEvent.MouseClicked,n._onClick),n.viewer3D.addEventListener(e.Bimface.Viewer.Viewer3DEvent.Hover,n._onHover)):console.log("ERROR::viewer must not be empty or viewer2d."):console.log("ERROR::anchorManagerConfig must not be empty.")}destroy(){this.clear(),this.viewer3D.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.MouseClicked,this._onClick),this.viewer3D.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.Hover,this._onHover)}addItem(e){e.initSizeByViewer(this.viewer3D),this.itemList.push(e),e.objectId=this.extObjMng._addObject(e.getId(),e.getPointIns())}addItems(e){if(null!=e&&e.length>0)for(var t=0;t<e.length;t++)this.addItem(e[t])}clear(){for(var e=0;e<this.itemList.length;e++)this.itemList[e].destroy(),this.extObjMng.removeById(this.itemList[e].getId());this.itemList=[]}getAllItems(){return this.itemList}getItemById(e){for(var t=0;t<this.itemList.length;t++)if(e==this.itemList[t].getId())return this.itemList[t];return null}hideAllItems(){for(var e=0;e<this.itemList.length;e++)this.itemList[e].hide()}hideItemsById(e){if(null!=e&&e.length>0){for(var t={},i=0;i<e.length;i++)t[e[i]]=!0;for(i=0;i<this.itemList.length;i++)null!=t[this.itemList[i].getId()]&&this.itemList[i].hide()}}showAllItems(){for(var e=0;e<this.itemList.length;e++)this.itemList[e].show()}showItemsById(e){if(null!=e&&e.length>0){for(var t={},i=0;i<e.length;i++)t[e[i]]=!0;for(i=0;i<this.itemList.length;i++)null!=t[this.itemList[i].getId()]&&this.itemList[i].show()}}removeItemsById(e){if(null!=e&&e.length>0){for(var t={},i=0;i<e.length;i++)t[e[i]]=!0;for(i=this.itemList.length-1;i>=0;i--)null!=t[this.itemList[i].getId()]&&(this.extObjMng.removeById(this.itemList[i].getId()),this.itemList[i].destroy(),this.itemList.splice(i,1))}}update(){for(var e=0;e<this.itemList.length;e++)this.itemList[e].update()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Anchor").AnchorManagerConfig=class{constructor(){this.viewer=null}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Anchor");i.PrismPoint=class{constructor(i){if(t.send("Bimface.Plugins.Anchor.PrismPoint","bf_c_prismPoint_new"),P(this),i){!i.color instanceof e.Web.Graphics.Color&&console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),!i.wireframeColor instanceof e.Web.Graphics.Color&&console.log("ERROR::wireframeColor should be instance of Glodon.Web.Graphics.Color"),this.color=i.color,this.wireframeColor=i.wireframeColor,this.duration=i.duration,this.size=i.size,this.position=i.position,this.id=e.Web.Lang.Utility.UUID.createUUID();var n=new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),o=this.color.alpha,s=new THREE.Color(this.wireframeColor.red/255,this.wireframeColor.green/255,this.wireframeColor.blue/255),r=this.wireframeColor.alpha;this.prismPoint=new CLOUD.PrismPoint({color:n,alpha:o,wireframeColor:s,wireframeAlpha:r,duration:this.duration,size:this.size,originPosition:this.position}),this.prismPoint._externalNeedScale=!1,this.prismPoint.changeRotation()}else console.log("ERROR::prismPointConfig must not be empty.")}initSizeByViewer(t){this._viewer||(this._viewer=t),1e4===this.size?"Viewer3D"===t.getViewerType()&&t.getUnit()===e.Bimface.Common.Units.LengthUnits.Millimeter||(this.setSize(10),this.update()):this.update()}getPointIns(){return this.prismPoint}getId(){return this.id}getColor(){return this.color}getDuration(){return this.duration}getPosition(){return this.position}getSize(){return this.size}getWireframeColor(){return this.wireframeColor}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setWireframeColor(t){t instanceof e.Web.Graphics.Color?this.wireframeColor=t:console.log("ERROR::wireframeColor should be instance of Glodon.Web.Graphics.Color")}setDuration(e){this.duration=e}setPosition(e){this.position=e}setSize(e){this.size=e}destroy(){this.prismPoint.destroy()}update(){var e=new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),t=this.color.alpha,i=new THREE.Color(this.wireframeColor.red/255,this.wireframeColor.green/255,this.wireframeColor.blue/255),n=this.wireframeColor.alpha;this.prismPoint.effectOpt({color:e,alpha:t,wireframeColor:i,wireframeAlpha:n,duration:this.duration,size:this._viewer.globalUnitUtil.translate(this.size),originPosition:this._viewer.globalUnitUtil.translate(this.position,["x","y","z"])})}hide(){this.prismPoint.hide()}show(){this.prismPoint.show()}onHover(e){this.onHoverFn=e}onClick(e){this.onClickFn=e}getSenceType(){return e.Bimface.Common.Type.EffectType.PrismPoint}getParams(){return{color:this.color,wireframeColor:this.wireframeColor,duration:this.duration,size:this.size,position:this.position}}zoomToBoundingBox(e){if(!e)return;const t=this.prismPoint.children[0].geometry;t.computeBoundingBox();let i=t.boundingBox.clone().applyMatrix4(e.getViewer().getScene().getMatrixGlobal().clone().invert());i=this._viewer.globalUnitUtil.revertBBox(i);let n=new THREE.Box3(new THREE.Vector3(this.position.x+i.min.x,this.position.y+i.min.y,this.position.z+i.min.z),new THREE.Vector3(this.position.x+i.max.x,this.position.y+ +i.max.y,this.position.z+ +i.max.z));e.zoomToBoundingBox({boundingBox:n})}play(){this.prismPoint.play()}pause(){this.prismPoint.pause()}stop(){this.prismPoint.stop()}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Anchor");t.PrismPointConfig=class{constructor(){this.color=new e.Web.Graphics.Color("#32D3A6",.4),this.wireframeColor=new e.Web.Graphics.Color("#8EFFDE",1),this.position={x:0,y:0,z:0},this.duration=1e3,this.size=1e4}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.WaterEffect=class{constructor(i){t.send("Bimface.Plugins.Animation.WaterEffect","bf_c_waterEffect_new");var n=this;if(this._console=new e.Web.Common.Console,!i)return void console.log("ERROR::waterEffectConfig must not be empty.");if(P(this),!i.viewer)return void console.log("ERROR::viewer must not be empty.");if("Viewer3D"===i.viewer.viewerType)n.isViewerGIS=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");n.isViewerGIS=!0}if(null!=i.color&&i.color instanceof e.Web.Graphics.Color?n.color=i.color:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),n.viewer=i.viewer,n.engineViewer=n.viewer.getViewer(),n.scale=i.scale,n.xDirection=i.xDirection,n.yDirection=i.yDirection,n.offset=i.offset,n._offset=n.viewer.globalUnitUtil.translate(i.offset),null==i.shadow?n.isViewerGIS?n.shadow=!1:n.shadow=!0:n.shadow=i.shadow,null==i.flow?n.isViewerGIS?n.flow=!1:n.flow=!0:n.flow=i.flow,null!=i.heightTolerance?n.heightTolerance=i.heightTolerance:n.heightTolerance=null,null!=i.boundary&&i.boundary.length>2?n.boundary=i.boundary:n.boundary=[],n.ids=[],null!=i.ids&&i.ids.length>0)for(var o=0;o<i.ids.length;o++){var s={modelId:i.ids[o].modelId,objectIds:i.ids[o].objectIds};if(1==n.isViewerGIS){var r=n.viewer.getLayerManager().getLayer(i.ids[o].layerId);if(null==r){console.log("请指定正确的layerId.layerId:",i.ids[o].layerId);continue}s.modelId=r.getModelId()}null!=s.modelId&&null==n.viewer.getModel(s.modelId)?console.log("请指定正确的modelId.modelId:",s.modelId):n.ids.push(s)}if(null!=i.componentIds&&i.componentIds.length>0){let e=n.viewer.getDefaultModel().modelId.toString(),t=[];for(let e=0;e<i.componentIds.length;e++)t.push(i.componentIds[e]);n.ids.push({modelId:e,objectIds:t})}if(n.componentIds=[],n._boundary=[],0==n.boundary.length&&0==n.ids.length&&0==n.componentIds.length)return;n.offsetBase=0,n.boundary.length>0?(n._boundary=n.viewer.globalUnitUtil.translate(n.boundary,["x","y","z"]),n.offsetBase=n._boundary[0].z,n.boundaryGeometry=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(n._boundary)):n.boundaryGeometry=null;let a=CLOUD.Water;(n.isViewerGIS||n.engineViewer.modelManager.isMeterUnit())&&(a=CLOUD.BimtilesWater),n.water=new a({color:new THREE.Color(n.color.red/255,n.color.green/255,n.color.blue/255),alpha:n.color.alpha,map0:n._getNormalMap0URL(),map1:n._getNormalMap1URL(),shadow:n.shadow,flow:n.flow,scale:n.scale,flowDirection:new THREE.Vector2(n.xDirection,n.yDirection),componentIds:n.componentIds,ids:n.ids,boundaryGeometry:n.boundaryGeometry,heightTolerance:n.heightTolerance,engineViewer:n.engineViewer,viewer:n.viewer}),n._addSence()}_updateParameter(){var e=this;e._color=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255),e._alpha=e.color.alpha}_addSence(){var t=this;t.water.disPickable=!0,t.water.autoAnimation=!0,t.water.translateZ(t._offset+t.offsetBase),t.water.updateMatrixWorld(),t.water._externalNeedScale=!1,t.id=e.Web.Lang.Utility.UUID.createUUID(),t.objectTpye="waterlogging-",t.extObjMngId=t.objectTpye+t.id,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t.water)}getBoundary(){return this.boundary}getColor(){return this.color}getScale(){return this.scale}getXDirection(){return this.xDirection}getYDirection(){return this.yDirection}getOffset(){return this.offset}setBoundary(t){0!=this.boundary.length?(this.boundary=t,this._boundary=this.viewer.globalUnitUtil.translate(this.boundary,["x","y","z"]),this.offsetBase=this._boundary[0].z,this.boundaryGeometry=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(this._boundary),this.water._updateBoundaryGeometry(this.boundaryGeometry),this.water.position.z=this._offset+this.offsetBase,this.water.updateMatrixWorld()):console.log("仅对基于boundary构造的水面效果对象生效")}setColor(t){t instanceof e.Web.Graphics.Color?(this.color=t,this._updateParameter(),null!=this.water&&this.water.setColor(new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),this.color.alpha)):console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setScale(e){this.scale=e,null!=this.water&&this.water.setScale(this.scale)}setXDirection(e){this.xDirection=e,null!=this.water&&this.water.setDirection(this.xDirection,this.yDirection)}setYDirection(e){this.yDirection=e,null!=this.water&&this.water.setDirection(this.xDirection,this.yDirection)}setOffset(e){if(null==this.water)return;this.offset=this.offset+e,this._offset=this.viewer.globalUnitUtil.translate(this.offset);let t=this.viewer.globalUnitUtil.translate(e);this.water.translateZ(t),this.water.updateMatrixWorld()}setShadow(e){this.shadow=e,this.water.shadow=e}setFlow(e){this.flow=e,this.water.flow=e}remove(){this._console.obsolete("WaterEffect.remove","WaterEffect.destroy");var e=this;null!=e.water&&e.water.destroy(),null!=e.extObjMngId&&e.extObjMng.removeNodeById(e.extObjMngId),F.removeExternalObjectManager(e.objectTpye),e.water=null,e.viewer=null,e.extObjMng=null,e.engineViewer.render()}destroy(){var e=this;null!==e.water&&(null!=e.water&&e.water.destroy(),null!=e.extObjMngId&&e.extObjMng.removeNodeById(e.extObjMngId),e.water=null,e.viewer=null,e.extObjMng=null,e.engineViewer.render())}show(){this.water.show()}hide(){this.water.hide()}play(){this.water.enableAnimation(!0)}stop(){this.water.enableAnimation(!1)}getSenceType(){return e.Bimface.Common.Type.EffectType.WaterEffect}getParams(){return{boundary:this.boundary,color:this.color,scale:this.scale,shadow:this.shadow,flow:this.flow,offset:this.offset,xDirection:this.xDirection,yDirection:this.yDirection}}zoomToBoundingBox(){this.viewer.zoomToBoundingBox({boundingBox:this.water.getBoundingBox()})}_getNormalMap0URL(){return`${window.BimfaceLoaderConfig.fullStaticHost}/images/waterNormalMap0.jpg`}_getNormalMap1URL(){return`${window.BimfaceLoaderConfig.fullStaticHost}/images/waterNormalMap1.jpg`}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.WaterEffectConfig=class{constructor(){this.componentIds=[],this.boundary=[],this.ids=[],this.color=new e.Web.Graphics.Color("#4A708B",1),this.scale=4,this.viewer=null,this.offset=0,this.heightTolerance=.001,this.shadow=null,this.flow=null,this.xDirection=1,this.yDirection=1}}}();class Es{constructor(t){var i=this;if(t)if(t.viewer){if("Viewer3D"===t.viewer.viewerType)i.isViewerGIS=!1;else{if(!(t.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");i.isViewerGIS=!0}t.color instanceof e.Web.Graphics.Color?i.color=t.color:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),t.backgroundColor instanceof e.Web.Graphics.Color?i.backgroundColor=t.backgroundColor:console.log("ERROR::backgroundColor should be instance of Glodon.Web.Graphics.Color"),i.duration=t.duration,i.originPosition=t.originPosition,i.radius=t.radius,i.fanAngle=t.fanAngle,i.viewer=t.viewer,i.scene=i.viewer.getViewer().getScene()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::fanScanEffectConfig must not be empty.")}destroy(){}update(){}play(){}pause(){}stop(){}hide(){}show(){}getColor(){return this.color}getBackgroundColor(){return this.backgroundColor}getDuration(){return this.duration}getFanAngle(){return this.fanAngle}getOriginPosition(){return this.originPosition}getRadius(){return this.radius}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setBackgroundColor(t){t instanceof e.Web.Graphics.Color?this.backgroundColor=t:console.log("ERROR::backgroundColor should be instance of Glodon.Web.Graphics.Color")}setDuration(e){this.duration=e}setOriginPosition(e){this.originPosition=e}setFanAngle(e){this.fanAngle=e}setRadius(e){this.radius=e}}class Ms extends Es{constructor(e){super(e);const t=this;t._updateParameter(),t.fanScanEffect=new CLOUD.FanScan({backgroundColor:t._backgroundColor,backgroundAlpha:t._backgroundAlpha,color:t._color,alpha:t._alpha,radius:t._radius,duration:t.duration,originPosition:t._originPosition,fanAngle:t.fanAngle}),t._addSence()}_addSence(){var t=this;t.objectTpye="fan-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.objectTpye+t.id,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t.fanScanEffect)}_updateParameter(){var e=this;e._color=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255),e._alpha=e.color.alpha,e._backgroundColor=new THREE.Color(e.backgroundColor.red/255,e.backgroundColor.green/255,e.backgroundColor.blue/255),e._backgroundAlpha=e.backgroundColor.alpha,e._radius=this.viewer.globalUnitUtil.translate(e.radius),e._originPosition=e.viewer.globalUnitUtil.translate(e.originPosition,["x","y","z"])}destroy(){var e=this;null!==e.fanScanEffect&&(e.fanScanEffect.destroy(),null!=e.extObjMngId&&e.extObjMng.removeNodeById(e.extObjMngId),F.removeExternalObjectManager(e.objectTpye),e.fanScanEffect=null)}update(){var e=this;e._updateParameter(),e.fanScanEffect.effectOpt({backgroundColor:e._backgroundColor,backgroundAlpha:e._backgroundAlpha,color:e._color,alpha:e._alpha,radius:e._radius,duration:e.duration,originPosition:e._originPosition,fanAngle:e.fanAngle})}hide(){this.fanScanEffect.hide()}show(){this.fanScanEffect.show()}getColor(){return this.color}getBackgroundColor(){return this.backgroundColor}getDuration(){return this.duration}getFanAngle(){return this.fanAngle}getOriginPosition(){return this.originPosition}getRadius(){return this.radius}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setBackgroundColor(t){t instanceof e.Web.Graphics.Color?this.backgroundColor=t:console.log("ERROR::backgroundColor should be instance of Glodon.Web.Graphics.Color")}setDuration(e){this.duration=e}setOriginPosition(e){this.originPosition=e,this._originPosition=this.viewer.globalUnitUtil.translate(this.originPosition,["x","y","z"])}setFanAngle(e){this.fanAngle=e}setRadius(e){this.radius!=e&&(this.fanScanEffect.resetMesh=!0,this.radius=e,this._radius=this.viewer.globalUnitUtil.translate(e))}play(){this.fanScanEffect.play()}pause(){this.fanScanEffect.pause()}stop(){this.fanScanEffect.stop()}}class Cs extends Es{constructor(t){super(t),this.cloudViewer=this.viewer.getViewer(),this._updateParameter(),this.id=e.Web.Lang.Utility.UUID.createUUID(),this.fanScanEffect=this.cloudViewer.addFanScanEffect({id:this.id,backgroundColor:this._backgroundColor,backgroundAlpha:this._backgroundAlpha,color:this._color,alpha:this._alpha,radius:this._radius,duration:this.duration,originPosition:this._originPosition,fanAngle:this.fanAngle})}_updateParameter(){this._color=new THREE.Color(this.color.red/255,this.color.green/255,this.color.blue/255),this._alpha=this.color.alpha,this._backgroundColor=new THREE.Color(this.backgroundColor.red/255,this.backgroundColor.green/255,this.backgroundColor.blue/255),this._backgroundAlpha=this.backgroundColor.alpha,this._radius=this.viewer.viewerAdapter.worldToDrawing({x:this.radius,y:0,z:0}).x,this._originPosition=this.viewer.viewerAdapter.worldToDrawing(this.originPosition)}destroy(){this.cloudViewer.deleteFanScanEffect(this.id)}update(){this._updateParameter(),this.fanScanEffect.setOpts({backgroundColor:this._backgroundColor,backgroundAlpha:this._backgroundAlpha,color:this._color,alpha:this._alpha,radius:this._radius,duration:this.duration,originPosition:this._originPosition,fanAngle:this.fanAngle})}hide(){this.fanScanEffect.enabled=!1}show(){this.fanScanEffect.enabled=!0}play(){this.fanScanEffect.play()}pause(){this.fanScanEffect.pause()}stop(){this.fanScanEffect.stop()}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.FanScanEffect=class{constructor(e){t.send("Bimface.Plugins.Animation.FanScanEffect","bf_c_FanScanEffect_new"),!0===e.enableComponentsScanned?this.fanScanEffectImpl=new Cs(e):this.fanScanEffectImpl=new Ms(e),P(this)}destroy(){this.fanScanEffectImpl.destroy()}enableComponentsScanned(e){const t={viewer:this.fanScanEffectImpl.viewer,color:this.getColor(),duration:this.getDuration(),backgroundColor:this.getBackgroundColor(),originPosition:this.getOriginPosition(),radius:this.getRadius(),fanAngle:this.getFanAngle()};this.fanScanEffectImpl.destroy(),this.fanScanEffectImpl=e?new Cs(t):new Ms(t)}update(){this.fanScanEffectImpl.update()}hide(){this.fanScanEffectImpl.hide()}show(){this.fanScanEffectImpl.show()}getColor(){return this.fanScanEffectImpl.getColor()}getBackgroundColor(){return this.fanScanEffectImpl.getBackgroundColor()}getDuration(){return this.fanScanEffectImpl.getDuration()}getFanAngle(){return this.fanScanEffectImpl.getFanAngle()}getOriginPosition(){return this.fanScanEffectImpl.getOriginPosition()}getRadius(){return this.fanScanEffectImpl.getRadius()}setColor(e){this.fanScanEffectImpl.setColor(e)}setBackgroundColor(e){this.fanScanEffectImpl.setBackgroundColor(e)}setDuration(e){this.fanScanEffectImpl.setDuration(e)}setOriginPosition(e){this.fanScanEffectImpl.setOriginPosition(e)}setFanAngle(e){this.fanScanEffectImpl.setFanAngle(e)}setRadius(e){this.fanScanEffectImpl.setRadius(e)}getSenceType(){return e.Bimface.Common.Type.EffectType.FanScan}getParams(){return{duration:this.fanScanEffectImpl.duration,color:this.fanScanEffectImpl.color,backgroundColor:this.fanScanEffectImpl.backgroundColor,originPosition:this.fanScanEffectImpl.originPosition,radius:this.fanScanEffectImpl.radius,fanAngle:this.fanScanEffectImpl.fanAngle,enableComponentsScanned:this.fanScanEffectImpl instanceof Cs}}zoomToBoundingBox(){const e=this.fanScanEffectImpl.originPosition,t=this.fanScanEffectImpl.radius;let i=new THREE.Box3(new THREE.Vector3(e.x-t,e.y-t,e.z),new THREE.Vector3(e.x+t,e.y+t,e.z));this.fanScanEffectImpl.viewer.zoomToBoundingBox({boundingBox:i})}play(){this.fanScanEffectImpl.play()}pause(){this.fanScanEffectImpl.pause()}stop(){this.fanScanEffectImpl.stop()}get id(){return this.fanScanEffectImpl.id}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.FanScanEffectConfig=class{constructor(){this.duration=1e3,this.color=new e.Web.Graphics.Color("#32d3a6",1),this.backgroundColor=new e.Web.Graphics.Color("#000000",.4),this.originPosition={x:0,y:0,z:0},this.radius=1e5,this.fanAngle=Math.PI/3,this.viewer=null,this.enableComponentsScanned=!1}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.WallEffect=class{constructor(i){var n=this;if(t.send("Bimface.Plugins.Animation.WallEffect","bf_c_wallEffect_new"),i)if(P(this),i.viewer){if("Viewer3D"===i.viewer.viewerType)n.isViewerGIS=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");n.isViewerGIS=!0}null!=i.color&&i.color instanceof e.Web.Graphics.Color?n.color=i.color:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),null!=i.path&&i.path.length>0?n.path=i.path:n.path=[],n.loader=new THREE.TextureLoader,null!=i.material&&i.material instanceof e.Bimface.Plugins.Material.Material?(n.material=i.material,n._loadTexture(n.material)):n._loadTexture(),n.duration=i.duration,n.blendingRatio=i.blendingRatio,n.directionType=i.direction.type,n.directionReverse=i.direction.reverse,n.isStretch=i.stretch,n.isRepeat=i.repeat,n.height=i.height,n.viewer=i.viewer,n.viewerViewer=n.viewer.getViewer(),n._updateParameter(),n.wallEffect=new CLOUD.Wall({stretch:n.isStretch,repeat:n.isRepeat,color:n._color,alpha:n._alpha,duration:n.duration,blendingRatio:n.blendingRatio,directionType:n.directionType,directionReverse:n.directionReverse,height:n._height,wallTexture:n.wallTexture,path:n._path,imageWidth:n.imageWidth,imageHeight:n.imageHeight,engineViewer:n.viewerViewer}),n._addSence()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::wallEffectConfig must not be empty.")}_updateParameter(){var e=this;e._color=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255),e._alpha=e.color.alpha,e._height=this.viewer.globalUnitUtil.translate(e.height),e._path=this.viewer.globalUnitUtil.translate(e.path,["x","y","z"])}_addSence(){var t=this;t.objectTpye="wall-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.objectTpye+t.id,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t.wallEffect)}destroy(){var e=this;null!==e.wallEffect&&(e.wallEffect.destroy(),null!=e.extObjMngId&&(e.extObjMng.removeNodeById(e.extObjMngId),e.extObjMng=null),F.removeExternalObjectManager(e.objectTpye),e.wallEffect=null,e.path=null,e._color=null,e.color=null,e.wallTexture=null,e.material=null,e.loader=null,e.viewerViewer=null,e.viewer=null)}update(){var e=this;e._updateParameter(),e.wallEffect.effectOpt({stretch:e.isStretch,repeat:e.isRepeat,color:e._color,alpha:e._alpha,duration:e.duration,blendingRatio:e.blendingRatio,directionType:e.directionType,directionReverse:e.directionReverse,height:e._height,wallTexture:e.wallTexture,path:e._path})}hide(){this.wallEffect.hide()}show(){this.wallEffect.show()}getSenceType(){return e.Bimface.Common.Type.EffectType.WallEffect}getParams(){return{direction:{type:this.directionType,reverse:this.directionReverse},duration:this.duration,height:this.height,color:{red:this.color.red,green:this.color.green,blue:this.color.blue,alpha:this.color.alpha},isRepeat:this.isRepeat,path:this.path}}zoomToBoundingBox(){this.viewer.zoomToBoundingBox({boundingBox:this.wallEffect.getBoundingBox()})}stretch(e){this.isStretch=e}repeat(e){this.isRepeat=e}getColor(){return this.color}getBlendingRatio(){return this.blendingRatio}getDirection(){return{type:this.directionType,reverse:this.directionReverse}}getDuration(){return this.duration}getHeight(){return this.height}getMaterial(){return this.material}getPath(){return this.path}setBlendingRatio(e){this.blendingRatio=e}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setDirection(e){this.directionType=e.type,this.directionReverse=e.reverse}setDuration(e){this.duration=e}setHeight(e){this.height!=e&&(this.wallEffect.resetPath=!0,this.height=e)}setMaterial(e){this.material=e,this._loadTexture(this.material)}setPath(e){null!=e&&e.length>0?(this.wallEffect.resetPath=!0,this.path=e):console.log("电子围墙的路径,由多个点对象组成,不能为空.")}_loadTexture(e){var t=this;null==e?(t.wallTexture=t.loader.load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAAgCAYAAABkS8DlAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAADSSURBVHja7NYxEoUgDEDBYM39z2qHtZViwMFxt1FJnF/98ZXWWkRE7LWWOOt5Lsm9q/vsbu9Zdtazs/J19O5bs1XPZrwze/6V31zxbOZs1n905Wt2p3f25GzE7ohv6q3nLQCA3xEAACAAAAABAAAIAABAAAAAAgAAEAAAgAAAAAQAACAAAAABAAAIAABAAAAAAgAAEAAAgAAAAAQAACAAAEAAAAACAAAQAACAAAAABAAAIAAAAAEAAAgAAEAAAAACAAAQAACAAAAA8g4AAAD//wMA4WEFTJOT5UIAAAAASUVORK5CYII="),t.imageWidth=512,t.imageHeight=32):(t.wallTexture=e.material.map,t.imageWidth=e.width,t.imageHeight=e.height,e.changedWidth=function(){t.wallEffect.imageWidth=e.width,t.wallEffect.refreshUniforms()},e.changedHeight=function(){t.wallEffect.imageHeight=e.height,t.wallEffect.refreshUniforms()})}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.WallEffectConfig=class{constructor(){this.stretch=!1,this.repeat=!0,this.blendingRatio=0,this.color=new e.Web.Graphics.Color("#11DAB7",.8),this.direction={},this.direction.type="Tangent",this.direction.reverse=!1,this.duration=1e3,this.height=1e3,this.material=null,this.path=[],this.viewer=null}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect").SnowConfig=class{constructor(){this.darkness=.5,this.density=2,this.thickness=.8,this.viewer=null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect");t.FogConfig=class{constructor(){this.darkness=.5,this.lightAttenuation=3.5,this.visualDistance=null,this.visibleDistance=null,this.fogColor=new e.Web.Graphics.Color("#FFFFFF",1),this.viewer=null,this.startDistance=0}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect");t.RainConfig=class{constructor(){this.darkness=.5,this.density=2,this.viewer=null}}}(),function(){var t="Bimface.Plugins.WeatherEffect.Snow",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect");n.Snow=class{constructor(n){i.send(t,"bf_c_Snow_new"),n?n.viewer&&("Viewer3D"===n.viewer.viewerType||n.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(P(this),this.darkness=n.darkness,this.density=n.density,this.thickness=n.thickness,this.viewer=n.viewer.getViewer()):console.log("ERROR::viewer must not be empty or viewer2d."):console.log("ERROR::SnowConfig must not be empty.")}update(){this.viewer.snowOpt({darkness:this.darkness,density:this.density,thickness:this.thickness})}reset(){var t=new e.Bimface.Plugins.WeatherEffect.SnowConfig;this.darkness=t.darkness,this.density=t.density,this.thickness=t.thickness,this.update()}enableEffect(e){i.send(t,"enableSnowEffect"),CLOUD.GlobalData.EnableSnowPass=e,this.viewer.render(),CLOUD.GlobalData.EnableSnowPass&&this.update()}getDarkness(){return this.darkness}getDensity(){return this.density}getThickness(){return this.thickness}setDarkness(e){this.darkness=e}setDensity(e){this.density=e}setThickness(e){this.thickness=e}}}(),function(){var t="Bimface.Plugins.WeatherEffect.Fog",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect");n.Fog=class{constructor(n){i.send(t,"bf_c_Fog_new"),n?n.viewer&&("Viewer3D"===n.viewer.viewerType||n.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(P(this),this._viewer3D=n.viewer,this.darkness=n.darkness,this.lightAttenuation=n.lightAttenuation,n.visibleDistance||n.visualDistance||(n.visualDistance=4e5),this.visualDistance=n.visualDistance,this.fogColor=n.fogColor,this.viewer=n.viewer.getViewer(),this.startDistance=n.startDistance,this.visibleDistance=n.visibleDistance):console.log("ERROR::viewer must not be empty or viewer2d."):console.log("ERROR::fogConfig must not be empty.")}update(){var e=new THREE.Color(this.fogColor.red/255,this.fogColor.green/255,this.fogColor.blue/255),t=this._viewer3D.viewerAdapter.worldToDrawing({x:this.visualDistance,y:0,z:0}).x,i=this.setSceneDistance(this.startDistance),n=this.setSceneDistance(this.visibleDistance),o=this.ifVisibleDistanceSet(this.visibleDistance);this.viewer.fogOpt({darkness:this.darkness,lightAttenuation:this.lightAttenuation,visualDistance:t,startDistance:i,visibleDistance:n,visibleDistanceSet:o,fogColor:e}),this.viewer.render()}reset(){var t=new e.Bimface.Plugins.WeatherEffect.FogConfig;this.darkness=t.darkness,this.lightAttenuation=t.lightAttenuation,this.fogColor=t.fogColor,this.update()}ifVisibleDistanceSet(e){return!!e}enableEffect(e){i.send(t,"enableFogEffect"),CLOUD.GlobalData.EnableFogPass=e,this.viewer.render(),CLOUD.GlobalData.EnableFogPass&&this.update()}getDarkness(){return this.darkness}getLightAttenuation(){return this.lightAttenuation}getFogColor(){return this.fogColor}getVisualDistance(){return this.visualDistance}getVisibleDistance(){return this.visibleDistance}getStartDistance(){return this.startDistance}setDarkness(e){this.darkness=e}setLightAttenuation(e){this.lightAttenuation=e}setFogColor(e){this.fogColor=e}setVisualDistance(e){this.turnVisualDistance(e)}turnVisualDistance(e){if(!e)return;let t=typeof e;isNaN(e)||"string"==t?console.log("ERROR::visualDistance must not be anything but numbers."):e<0?console.log("ERROR::visualDistance must not be less than 0.0."):(this.visualDistance=e,this.visibleDistance=null)}setVisibleDistance(e){this.turnVisibleDistance(e)}turnVisibleDistance(e){if(!e)return;let t=typeof e;isNaN(e)||"string"==t?console.log("ERROR::visibleDistance must not be anything but numbers."):e<0?console.log("ERROR::visibleDistance must not be less than 0.0."):(this.visibleDistance=e,this.visualDistance=null)}setStartDistance(e){this.turnStartDistance(e)}turnStartDistance(e){if(!e)return;let t=typeof e;isNaN(e)||"string"==t?console.log("ERROR::startDistance must not be anything but numbers."):e<0?console.log("ERROR::startDistance must not be less than 0.0."):this.startDistance=e}setSceneDistance(e){const t=this.viewer.camera,i=this._viewer3D.viewerAdapter.drawingToWorld(t.position),n=new THREE.Vector3(i.x,i.y,i.z),o=this._viewer3D.viewerAdapter.worldToDrawing(n);let s=new THREE.Vector3(i.x+e,i.y,i.z),r=this._viewer3D.viewerAdapter.worldToDrawing(s),a=new THREE.Vector3;return a.subVectors(o,r),a.length()}}}(),function(){var t="Bimface.Plugins.WeatherEffect.Rain",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WeatherEffect");n.Rain=class{constructor(n){i.send(t,"bf_c_Rain_new"),n?n.viewer&&("Viewer3D"===n.viewer.viewerType||n.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(P(this),this.darkness=n.darkness,this.density=n.density,this.viewer=n.viewer.getViewer()):console.log("ERROR::viewer must not be empty or viewer2d."):console.log("ERROR::rainConfig must not be empty.")}update(){this.viewer.rainOpt({darkness:this.darkness,density:this.density})}reset(){var t=new e.Bimface.Plugins.WeatherEffect.RainConfig;this.darkness=t.darkness,this.density=t.density,this.update()}enableEffect(e){i.send(t,"enableRainEffect"),CLOUD.GlobalData.EnableRainPass=e,this.viewer.render(),CLOUD.GlobalData.EnableRainPass&&this.update()}getDarkness(){return this.darkness}getDensity(){return this.density}setDarkness(e){this.darkness=e}setDensity(e){this.density=e}getSenceType(){return e.Bimface.Common.Type.EffectType.Rain}getParams(){return{darkness:this.darkness,density:this.density}}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");i.PlaneScanEffect=class{constructor(i){var n=this;if(t.send("Bimface.Plugins.Animation.PlaneScanEffect","bf_c_planeScan_new"),i)if(P(this),i.viewer){if("Viewer3D"===i.viewer.viewerType)n.isViewerGIS=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");n.isViewerGIS=!0}if(null!=i.color&&i.color instanceof e.Web.Graphics.Color?n.color=i.color:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),null!=i.boundary&&i.boundary.length>2?n.boundary=i.boundary:n.boundary=[],n.viewer=i.viewer,n.engineViewer=n.viewer.getViewer(),n.duration=i.duration,n.blendingRatio=i.blendingRatio,n.direction=i.direction,n.ids=[],null!=i.ids&&i.ids.length>0)for(var o=0;o<i.ids.length;o++){var s={modelId:i.ids[o].modelId,objectIds:i.ids[o].objectIds};if(1==n.isViewerGIS){var r=n.viewer.getLayerManager().getLayer(i.ids[o].layerId);if(null==r){console.log("请指定正确的layerId.layerId:",i.ids[o].layerId);continue}s.modelId=r.getModelId()}null!=s.modelId&&null==n.viewer.getModel(s.modelId)?console.log("请指定正确的modelId.modelId:",s.modelId):n.ids.push(s)}n.loader=new THREE.TextureLoader,null!=i.material&&i.material instanceof e.Bimface.Plugins.Material.Material?(n.material=i.material,n._loadTexture(n.material)):n._loadTexture(),n._updateParameter(),n.planeScan=new CLOUD.PlaneScan({color:n._color,alpha:n._alpha,duration:n.duration,blendingRatio:n.blendingRatio,direction:n.direction,planeScanTexture:n.planeScanTexture,ids:n.ids,boundaryGeometry:n.boundaryGeometry,viewer:n.engineViewer}),n.planeScan._externalNeedScale=!1,n._addSence()}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::planeScanEffectConfig must not be empty.")}_updateParameter(){var t=this;if(t._color=new THREE.Color(t.color.red/255,t.color.green/255,t.color.blue/255),t._alpha=t.color.alpha,t.boundary.length>0){t.boundaryGeometry=new e.Bimface.Plugins.Geometry.PlaneBufferGeometry(this.viewer.globalUnitUtil.translate(t.boundary,["x","y","z"]));for(var i=this.viewer.globalUnitUtil.translate(t.boundary[0].z),n=t.boundaryGeometry.attributes.position.array,o=0;o<n.length;o++)o%3==2&&(n[o]=i)}else t.boundaryGeometry=null}_addSence(){var t=this;t.objectTpye="planeScan-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.objectTpye+t.id,t.extObjMng=F.getExternalObjectManager(t.viewer,t.objectTpye),t.extObjMng.addNode(t.extObjMngId,t.planeScan)}destroy(){var e=this;null!==e.planeScan&&(e.planeScan.destroy(),null!=e.extObjMngId&&e.extObjMng.removeNodeById(e.extObjMngId),F.removeExternalObjectManager(e.objectTpye),e.planeScan=null,e.engineViewer.render())}update(){var e=this;e._updateParameter(),0!=e.ids.length||null!=e.boundaryGeometry?e.planeScan.effectOpt({color:e._color,alpha:e._alpha,duration:e.duration,blendingRatio:e.blendingRatio,direction:e.direction,planeScanTexture:e.planeScanTexture,ids:e.ids,boundaryGeometry:e.boundaryGeometry,viewer:e.engineViewer}):console.warn("平面扫描的ids与boundary不能同时为空.")}hide(){this.planeScan.hide()}show(){this.planeScan.show()}getColor(){return this.color}getBlendingRatio(){return this.blendingRatio}getDirection(){return this.direction}getDuration(){return this.duration}getMaterial(){return this.material}getIds(){return this.ids}getBoundary(){return this.boundary}setBlendingRatio(e){this.blendingRatio=e}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}setDirection(e){this.direction=e}setDuration(e){this.duration=e}setMaterial(e){this.material=e,this._loadTexture(this.material)}setBoundary(e){null!=e&&e.length>0&&(this.planeScan.resetPath=!0,this.boundary=e)}setIds(e){e&&0!==e.length&&(1==this.isViewerGIS&&e.forEach((e=>{const t=this.viewer.getLayerManager().getLayer(e.layerId);t&&(e.modelId=t.getModelId())})),this.planeScan.resetPath=!0,this.ids=e)}_loadTexture(e){var t=this;t.planeScanTexture=null==e?t.loader.load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAAgCAYAAABkS8DlAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAADSSURBVHja7NYxEoUgDEDBYM39z2qHtZViwMFxt1FJnF/98ZXWWkRE7LWWOOt5Lsm9q/vsbu9Zdtazs/J19O5bs1XPZrwze/6V31zxbOZs1n905Wt2p3f25GzE7ohv6q3nLQCA3xEAACAAAAABAAAIAABAAAAAAgAAEAAAgAAAAAQAACAAAAABAAAIAABAAAAAAgAAEAAAgAAAAAQAACAAAEAAAAACAAAQAACAAAAABAAAIAAAAAEAAAgAAEAAAAACAAAQAACAAAAA8g4AAAD//wMA4WEFTJOT5UIAAAAASUVORK5CYII="):e.material.map}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Animation");t.PlaneScanEffectConfig=class{constructor(){this.blendingRatio=0,this.color=new e.Web.Graphics.Color("#11DAB7",.8),this.boundary=[],this.ids=[],this.direction={x:0,y:1},this.duration=1e3,this.material=null,this.viewer=null}}}(),function(){let t=Object.freeze({Auto:"Auto",BaiDu:"BaiDu",GaoDe:"GaoDe",MapBox:"MapBox",Google:"Google"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cesium").ImageProviderOption=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cesium").CesiumConfig=class{constructor(){this.accessToken=null,this.longitude=null,this.latitude=null,this.imageryLayer=null,this.rotation=null,this.useTerrain=!1,this.clipHeight=0,this.offsetHeight=0,this.duration=5}},function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Cesium"));i.CesiumManager=class{constructor(e){t.send("Bimface.Plugins.Cesium","CesiumManager"),this.scale=.001,this._opt=e,this.curViewToken=void 0,this.rotation=void 0===this._opt.rotation||null===this._opt.rotation?0:this._opt.rotation,this.offsetHeight=null==this._opt.offsetHeight?0:this._opt.offsetHeight,P(this),null!=this._opt.accessToken&&null!=this._opt.accessToken||console.log("The cesium accessToken is null");var i=CLOUD.EnumCesiumImageryLayerType,n={Auto:i.AUTO,BaiDu:i.BAIDU,GaoDe:i.GAODE,MapBox:i.MAPBOX,Google:i.GOOGLE,ArcGis:i.ARCGIS};e.imageryLayer=null==e.imageryLayer?i.AUTO:n[e.imageryLayer],this.cesiumLoader=new CLOUD.CesiumLoader(e),this.inverseGlobalGlobeMatrix=new THREE.Matrix4,this.cameraDistance=1}init(e,t){this.cesiumLoader.init(e,t)}initCameraScale(e){this.viewer3D=e;var t=CLOUD.GlobalData.SceneSize,i=new THREE.Vector3;i=this.viewer3D.getViewer().modelManager.boundingBox.getSize(i);var n=t/Math.max(i.x,i.y,i.z);this.cesiumLoader.cameraScale=this.scale/n,this.cesiumLoader.originBimCameraTar=this.viewer3D.getViewer().camera.target.clone(),this.updateGlobeMatrix(),this.updateCesiumCamera()}updateGlobeMatrix(){var e=0,t=this.viewer3D.getViewer();if(null!=t){var i=t.getScene().getBoundingBox().min.y;e=i*this.cesiumLoader.cameraScale,null!=this._opt.clipHeight&&this.cesiumLoader.clipHeight>=0&&(e+=this.cesiumLoader.clipHeight,this.cesiumLoader.globalPlane=new THREE.Plane(new THREE.Vector3(0,1,0),-i-this.cesiumLoader.clipHeight/this.cesiumLoader.cameraScale),t.rendererManager.renderer.clippingPlanes=[this.cesiumLoader.globalPlane])}var n=Cesium.Transforms.northUpEastToFixedFrame(Cesium.Cartesian3.fromDegrees(this.cesiumLoader.worldCoordinates[0],this.cesiumLoader.worldCoordinates[1],this.cesiumLoader.terrainHeight-e+this.offsetHeight)),o=Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(-90+this.rotation)),s=Cesium.Matrix4.fromRotationTranslation(o);Cesium.Matrix4.multiply(n,s,n),this.cesiumLoader.globeMatrix=(new THREE.Matrix4).set(n[0],n[4],n[8],n[12],n[1],n[5],n[9],n[13],n[2],n[6],n[10],n[14],n[3],n[7],n[11],n[15]),this.inverseGlobalGlobeMatrix.getInverse(this.cesiumLoader.globeMatrix)}updateCesiumCamera(){if(this.viewer3D){var e=this.viewer3D.getViewer();if(e.camera.fov=Cesium.Math.toDegrees(this.cesiumLoader.viewer.camera.frustum.fovy),e.camera.near=this.cesiumLoader.viewer.camera.frustum.near,e.camera.far=this.cesiumLoader.viewer.camera.frustum.far,!(isNaN(e.camera.position.x)||isNaN(e.camera.position.y)||isNaN(e.camera.position.y))){var t=e.camera.up.clone().applyMatrix4(this.cesiumLoader.globeMatrix).normalize(),i=e.camera.position.clone().multiplyScalar(this.cesiumLoader.cameraScale),n=i.clone().applyMatrix4(this.cesiumLoader.globeMatrix),o=e.camera.target.clone().multiplyScalar(this.cesiumLoader.cameraScale),s=o.clone().applyMatrix4(this.cesiumLoader.globeMatrix).clone().sub(n).clone().normalize();this.cameraDistance=o.distanceTo(i);var r=this;r.cesiumLoader.viewer.camera.setView({destination:r.vector3ToCartesian3(n),orientation:{direction:r.vector3ToCartesian3(s),up:r.vector3ToCartesian3(t)}}),r.cesiumLoader.viewer.render()}}}updateBimCamera(){if(this.viewer3D){var e=this.viewer3D.getViewer();this.cesiumLoader.viewer.camera.frustum.near=e.camera.near,this.cesiumLoader.viewer.camera.frustum.far=e.camera.far;var t=this.cartesian3ToVector3(this.cesiumLoader.viewer.camera.up).clone().applyMatrix4(this.inverseGlobalGlobeMatrix).normalize();e.camera.up.set(t.x,-t.y,t.z);var i=this.cartesian3ToVector3(this.cesiumLoader.viewer.camera.position),n=i.clone().applyMatrix4(this.inverseGlobalGlobeMatrix);n=n.multiplyScalar(1/this.cesiumLoader.cameraScale),e.camera.position.set(n.x,n.y,n.z);var o=this.cartesian3ToVector3(this.cesiumLoader.viewer.camera.direction).multiplyScalar(this.cameraDistance).clone().add(i).clone().applyMatrix4(this.inverseGlobalGlobeMatrix);o.multiplyScalar(1/this.cesiumLoader.cameraScale),e.camera.target.set(o.x,o.y,o.z),e.render()}}updateModelPosition(e){null!=e&&(this.cesiumLoader.worldCoordinates[0]=e.longitude||this.cesiumLoader.worldCoordinates[0],this.cesiumLoader.worldCoordinates[1]=e.latitude||this.cesiumLoader.worldCoordinates[1],this.rotation=e.rotation||this.rotation,this.offsetHeight=e.offsetHeight||this.offsetHeight,this.updateGlobeMatrix(),this.updateCesiumCamera())}switchModel(e){var t=this;if(null!=e.viewToken)if(e.viewToken!=t.curViewToken)if(null!=e.longitude&&null!=e.latitude){t.viewer3D.getViewer().unloadAll(),t.cesiumLoader.duration=null==e.duration?5:e.duration,t.cesiumLoader.worldCoordinates=[e.longitude,e.latitude],t.cesiumLoader.clipHeight=null==e.clipHeight?0:e.clipHeight;var i=[Cesium.Cartographic.fromDegrees(t.cesiumLoader.worldCoordinates[0],t.cesiumLoader.worldCoordinates[1])],n=Cesium.sampleTerrainMostDetailed(t.cesiumLoader.terrainProvider,i);t.cesiumLoader.useTerrain?(t.cesiumLoader.terrainHeight=updatedPositions[0].height,Cesium.when(n,(function(i){t.updateViewToken(e.viewToken)}))):(t.cesiumLoader.terrainHeight=0,t.updateViewToken(e.viewToken))}else console.warn("The paramter longitude and latitude can not be undefined");else console.warn("The paramter viewToken is same as current viewToken");else console.warn("The paramter viewToken can not be undefined")}updateViewToken(t){var i=this;i.cesiumLoader.updateCesiumOriginPos(),i.cesiumLoader.viewer.camera.flyTo({destination:i.cesiumLoader.cesiumOriginPos,orientation:{heading:Cesium.Math.toRadians(175),pitch:Cesium.Math.toRadians(-35),roll:0},duration:i.cesiumLoader.duration,complete:function(){i.viewer3D.addView(t),i.viewer3D.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewAdded,(function(e){i.curViewToken=t,i.updateGlobeMatrix()}))}})}loadGltf(e,t,i,n,o,s,r,a){this.cesiumLoader.loadGltf(e,t,i,n,o,s,r,a)}load3dTiles(e,t,i,n){this.cesiumLoader.load3dTiles(e,t,i,n)}load3dTilesByPosition(e,t,i,n,o,s){this.cesiumLoader.load3dTilesByPosition(e,t,i,n,o,s)}setUpGDRoad(e,t){this.cesiumLoader.setUpGDRoad(e,t)}cartesian3ToVector3(e){return new THREE.Vector3(e.x,e.y,e.z)}vector3ToCartesian3(e){return new Cesium.Cartesian3(e.x,e.y,e.z)}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap");t.MapConfig=class{constructor(){this.viewer=null,this.basePoint={x:0,y:0},this.modelAltitude=0,this.modelPosition=[121.49621407,31.17843493],this.modelRotationZ=0,this.enableElevationModel=!1,this.opacity=1,this.viewToken=null,this.sectionable=!1,this.terrainPath=null,this.terrainMetadata={attribution:"https://bimface.com/",description:"https://bimface.com/",format:"heightmap",version:"1.0.0",tiles:["{z}/{x}/{y}.terrain.gz"],tilejson:"1.0",scheme:"tms",name:["world"],projection:"EPSG:4326",maxLevel:14,minLevel:4,boundary:{14:{leftX:11377,rightX:14336,upY:5182,bottomY:7734},13:{leftX:5689,rightX:7167,upY:2591,bottomY:3866},12:{leftX:2845,rightX:3583,upY:1296,bottomY:1932},11:{leftX:1423,rightX:1791,upY:648,bottomY:965},10:{leftX:712,rightX:895,upY:324,bottomY:482},9:{leftX:356,rightX:447,upY:162,bottomY:240},8:{leftX:178,rightX:223,upY:81,bottomY:119},7:{leftX:89,rightX:111,upY:41,bottomY:59},6:{leftX:45,rightX:55,upY:21,bottomY:29},5:{leftX:23,rightX:27,upY:11,bottomY:14},4:{leftX:12,rightX:13,upY:6,bottomY:6}},bounds:{longitude:[70.0048828125,10.012129557908132,135,54.990221720048915]}},this.maxLevel=18}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap").MapStyle=Object.freeze({DarkBlue:"DarkBlue",DarkGreen:"DarkGreen",CustomColor:"CustomColor"}),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap"),i=e.Bimface.Data.StatisticsDataManager.getInstance();class n{constructor(t){i.send("Bimface.Plugins.TileMap.Tile","Tile");var o=t.viewer;if(!o||"Viewer3D"===!o.viewerType)return void console.error("ERROR::viewer must not be empty or viewer2d.");if(!t.basePoint)return void console.error("ERROR::basePoint in mapConfig must not be empty.");if(null==t.basePoint.x||null==t.basePoint.y)return void console.error("ERROR::basePoint.x or basePoint.y must not be empty.");if(isNaN(t.opacity))return void console.warn("the opacity input is not a number");if(t.opacity>1||t.opacity<0)return void console.warn("the opacity must in [0.0,1.0]");if(!(t.modelPosition instanceof Array&&t.modelPosition.length>=2))return void console.error("the position input is inValid");if(null==t.terrainPath){const e=o._getMetaDataManager()._config.resourceHost;t.terrainPath=n.getTerrainRootPath(e)}if(t.useTerrain=t.enableElevationModel,y.GlobalData.ConstraintZoom=!0,this.maximalRangeofCamera=100,o.setMaximalRangeofCamera(this.maximalRangeofCamera),o.lockAxis("Z",[.1,Math.PI/2.01]),this.tileManager=!0,this.viewer=o,this.mapTypeMap={Google_Roadmap:"m",Google_Hybrid:"y",Google_Satellite:"s"},this.currentMapType="Amap_Satellite",this.mapStyle={},this.eventManager=new e.Web.Lang.EventManager,"Amap_Satellite"!==t.mapLayer)return;t.mapUrl="https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=6&x={x}&y={y}&z={z}";const s=ee.parseProvider(t);t.imageryProviderType=s}setModelRotationZ(e){isNaN(e)?console.warn("the radian input is not a number"):this.tileManager.setModelRotationZ(e)}getModelRotationZ(){return this.tileManager.getModelRotationZ()}setModelPosition(e){e instanceof Array&&e.length>=2?this.tileManager.setModelPosition(e):console.warn("the position input is inValid")}getModelPosition(){return this.tileManager.getModelPosition()}setModelAltitude(e){isNaN(e)?console.warn("the altitude input is not a number"):this.tileManager.setModelAltitude(e)}getModelAltitude(){return this.tileManager.getModelAltitude()}getBasePoint(){return this.tileManager.getBasePoint()}setOpacity(e){isNaN(e)?console.warn("the opacity input is not a number"):e>1||e<0?console.warn("the opacity must in [0.0,1.0]"):(this.tileManager.setOpacity(e),this.viewer.render())}getOpacity(){return this.tileManager.getOpacity()}show(){this.tileManager.showAllLayers?this.tileManager.showAllLayers():this.tileManager.show(),this.viewer.render()}hide(){this.tileManager.hideAllLayers?this.tileManager.hideAllLayers():this.tileManager.hide(),this.viewer.render()}destroy(){this.tileManager.getLayer().destroy()}_checkLngLatLegality(e){return e instanceof Array?e.length<2?(console.warn("ERROR::the lngLat input miss parameter"),!1):isNaN(e[0])||isNaN(e[1])?(console.warn("ERROR::the longitude or latitude is not a number"),!1):!(!y.Tile.TileMath.isLongitude(e[0])||!y.Tile.TileMath.isLatitude(e[1]))||(console.log("ERROR::number exceeds latitude and longitude range."),!1):(console.warn("ERROR::the lngLat input is inValid"),!1)}_checkWorldPositionLegality(e){return null!=e.x&&null!=e.y||(console.warn("ERROR::the worldPosition input is invalid"),!1)}lngLatToWorldPosition(e,t){}worldPositionToLngLat(e){}addRoad(){const e=this.tileManager.addRoad("https://webst02.is.autonavi.com/appmaptile?style=8&scale=1&lang=zh_cn&x={x}&y={y}&z={z}",1);return this.viewer.render(),e}removeRoad(e){this.tileManager.removeRoad(e),this.viewer.render()}setMapLayer(e){let t=this.mapTypeMap[e];void 0!==t?e===this.currentMapType?console.warn(`${e} is same as current mapLayer.`):(this.currentMapType=e,this.tileManager&&this.tileManager.setMapLayer(t),this.viewer.render()):console.warn(`${e} input invalid.`)}getMapLayer(){return this.currentMapType}addEventListener(e,t){this.eventManager.addEvent(e,t)}removeEventListener(e,t){this.eventManager.removeEvent(e,t)}addExcavationRegion(e,t){var i=this.viewer.getViewer();if(i&&i.terrainOperationManager){var n=0,o=new Array(t.length);for(n=0;n<t.length;++n){var s=this.viewer.worldToScene(t[n]);o[n]=s}t=o;let r={};r[y.ObjectGroupType.TILEGROUP]=[];const a={points:t,modelIds:r};i.holesManager.addHole(e,a),i.render()}}hideExcavationRegionsById(e){var t=this.viewer.getViewer();t&&t.terrainOperationManager&&(t.holesManager.hideHoleByIds(e),t.render())}showExcavationRegionsById(e){var t=this.viewer.getViewer();t&&t.terrainOperationManager&&(t.holesManager.showHoleByIds(e),t.render())}removeExcavationRegionsById(e){var t=this.viewer.getViewer();t&&t.terrainOperationManager&&(t.holesManager.removeHoleByIds(e),t.render())}clearExcavationRegions(){var e=this.viewer.getViewer();e&&e.terrainOperationManager&&(e.holesManager.clearHoles(),e.render())}addFlattenRegion(e,t,i){var n=this.viewer.getViewer();if(n&&n.terrainOperationManager){var o=0,s=new Array(t.length);for(o=0;o<t.length;++o){var r=this.viewer.viewerAdapter.worldToDrawing(t[o]);s[o]=r}const a=[y.ObjectGroupType.TILEGROUP];n.terrainOperationManager.addFlattenRegion(e,s,i,a),n.render()}}removeFlattenRegionsById(e){var t=this.viewer.getViewer();t&&t.terrainOperationManager&&(t.terrainOperationManager.removeFlattenRegionsById(e),t.render())}clearFlattenRegions(){var e=this.viewer.getViewer();e&&e.terrainOperationManager&&(e.terrainOperationManager.clearFlattenRegions(),e.render())}getMapStyle(){return this.mapStyle}setMapStyle(t){if(t=t||{},this.mapStyle=Object.assign({},t),t.template)switch(t.template){case e.Bimface.Common.ImageStyle.DarkBlue:t.color=new THREE.Vector4(2/255,30/255,88/255,1);break;case e.Bimface.Common.ImageStyle.DarkGreen:t.color=new THREE.Vector4(3/255,63/255,44/255,1);break;case e.Bimface.Common.ImageStyle.CustomColor:if(!t.color)return void console.warn("color is needed when template == Glodon.Bimface.Common.ImageStyle.CustomColor.");t.color=new THREE.Vector4(t.color.red/255,t.color.green/255,t.color.blue/255,t.color.alpha)}if(y.Utils.isDefined(t.brightness)&&(t.brightness+=1,t.brightness=Math.min(Math.max(t.brightness,0),2)),y.Utils.isDefined(t.contrast)){var i=t.contrast+=1;i=Math.min(Math.max(i,0),2),t.contrast=i>1?1+Math.pow(i-1,2):i}y.Utils.isDefined(t.saturation)&&(t.saturation+=1,t.saturation=Math.min(Math.max(t.saturation,0),2)),this.tileManager.setStyle(t),this.viewer.render()}restoreMapStyle(){this.mapStyle={},this.tileManager.setStyle(this.mapStyle),this.viewer.render()}registerMapCreatedEvent(){this.viewer.getViewer().registerEventListener(y.EVENTS.ON_MAP_CREATED,(t=>{this.eventManager.fireEvent(e.Bimface.Plugins.TileMap.MapEvent.Created,t)}))}static getTerrainRootPath(e){return e.indexOf("test")>-1?"https://static-test.bimface.com/gis/dem/srtm/v3/":"https://static.bimface.com/gis/dem/srtm/v3/"}}t.Tile=n}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap"),i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.DataUtil;class o extends e.Bimface.Plugins.TileMap.Tile{constructor(t){if(i.send("Bimface.Plugins.TileMap.Map","Map"),super(t),!this.tileManager)return void console.log("initialize map failed");if(this.maxLevel=t.maxLevel,!t.viewToken)return void this.createTileMap(t);P(this);let n=e.Bimface.Authentication.AuthenticationManager,o=new e.Bimface.Authentication.AuthenticationConfig;o.viewToken=t.viewToken,o.APIHost=t.viewer._opt.APIHost,(this.authenticate=new n(o)).authenticate((e=>{const i=`${t.viewer._opt.resourceHost}/${e.databagId}/resource/v3/model/config.json`;t.terrainPath=`${t.viewer._opt.resourceHost}/${e.databagId}/resource/v3/model/terrain/`;let n=new THREE.FileLoader;n.setResponseType("json"),n.load(i,(e=>{t.zoomRange=e.metadata.zoom,this.createTileMap(t)}))}),(function(e){console.log("the invalid terrain viewtoken"),this.createTileMap(t)}))}getMapSource(){return this.tileSource}setMapSource(t){if(this.tileSource=ee.getTileSource(t),!this._creditWidget){let t=new e.Bimface.Plugins.CreditConfig;t.domElement=this.viewer.getDomElement(),t.viewer=this.viewer,t.class="bf-viewer3d-credit",t=Object.assign({},this.tileSource,t),this._creditWidget=new e.Bimface.Plugins.Credit(t)}return this._creditWidget.update(this.tileSource),new Promise(((e,t)=>{ee.verifyKey(this.tileSource).then((()=>{this.tileManager.setMapUrl(this.tileSource.url,this.tileSource.provider),this.viewer.render(),e()}),(()=>{console.warn("parse key failed"),t()}))}))}createTileMap(e){this.tileSource&&(e.url=e.mapUrl=this.tileSource.url)&&(e.imageryProviderType=this.tileSource.provider),e.basePoint&&(e.basePoint=this.viewer.globalUnitUtil.translateVector(e.basePoint));let t=e.viewer.getViewer().modelManager.createDemModel(e);this.tileManager=t.tileManager,this.registerMapCreatedEvent()}lonLat2Mercator(e,t){return this.tileManager.lonLat2Mercator(e,t)}mercator2lonLat(e){return this.tileManager.mercator2lonLat(e)}lngLatToWorldPosition(e,t){if(this._checkLngLatLegality(e)){if(void 0===t)return this.tileManager.lngLatToWorldPosition(e);this.tileManager.lngLatToWorldPosition(e,t)}}worldPositionToLngLat(e){if(this._checkWorldPositionLegality(e)){var t=this.tileManager.mercator2lonLat(e),i=[t.x,t.y];if(this._checkLngLatLegality(i))return i}}setMaxLevel(e){if(e&&n.assertType(e,"num")&&e>4){if(te(this.tileManager&&this.tileManager.mapUrl,e),!0===this.tileManager.useTerrain&&e>this.tileManager.maxTerrainLevel+4)return void console.log("dem does not support level > 18");this.maxLevel=e,this.tileManager&&this.tileManager.setMaxLevel(e)}}getMaxLevel(){return this.maxLevel}addMap(e){e.imageryProviderType=ee.parseProvider(e);const t=this.tileManager.addImageryLayer(e);return this.viewer.render(),t}removeMap(e){this.tileManager.removeImageryLayer(e),this.viewer.render()}}t.Map=o}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap"),i=e.Bimface.Data.StatisticsDataManager.getInstance();class n extends e.Bimface.Plugins.TileMap.Tile{constructor(e){i.send("Bimface.Plugins.TileMap.GlobalMap","GlobalMap"),super(e),this.tileManager&&(this.tileManager=new y.Tile.TileGlobalManager(e.viewer.getViewer(),e),this.tileManager.addRenderCallback())}}t.GlobalMap=n}();let xs=new THREE.Vector3;!function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap"),i=e.Bimface.Data.StatisticsDataManager.getInstance();class n extends e.Bimface.Plugins.TileMap.Tile{constructor(e){if(i.send("Bimface.Plugins.TileMap.MixTileMap","MixTileMap"),super(e),this.tileManager){var t=new y.Tile.TileGlobalManager(e.viewer.getViewer(),e),n=new y.Tile.TilePlaneManager(e.viewer.getViewer(),e);t.addRenderCallback(),n.addRenderCallback(),e.viewer.getViewer().addRenderCallback((function(){var i=e.viewer.getViewer().camera.position.clone().applyMatrix4(t.globalMatrixInverse),o=t.modelBox.getCenter(xs);i.distanceTo(o)>.8*y.Tile.TileMath.earthRadius?(this.tileManager=t,t.tileGroup.visible=!0,n.tileGroup.visible=!1):(this.tileManager=n,t.tileGroup.visible=!1,n.tileGroup.visible=!0)}))}}}t.MixTileMap=n}(),function(){let t=Object.freeze({Created:"Created"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.TileMap").MapEvent=t}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Map");i.MapManager=class{constructor(e){t.send("Bimface.Plugins.Map.MapManager","bf_c_map_newMapManager"),this.viewer=e.viewer,this.mapManager=new y.MapManager(this.viewer.getViewer()),P(this)}destroy(){this.mapManager.removeCreateMapEvent(),this.mapManager=null}createMapByCamera(e){this.mapManager.addCreateMapEvent(e)}createMapByHeight(e){this.mapManager.createMapByHeight(e)}removeCreateMapEvent(){this.mapManager.removeCreateMapEvent()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Videos").VideoConfig=class{constructor(){this.src=void 0,this.isPlaneOn=!0,this.plane=null,this.viewer=null,this.camera=null,this.mute=!1,this.loop=!0,this.callback=null}};class Ts{constructor(t){t?t.viewer&&("Viewer3D"===t.viewer.viewerType||t.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(this.liveFormats=["m3u8"],this.videoFormats=["mp4","webm","ogg"],this.viewer=t.viewer,this.cloudViewer=this.viewer.getViewer(),t.src?(this.camera=t.camera,this.videoSrc=t.src,this.configMute=void 0,this.configLoop=void 0,this.cameraPara=null,this.scratchAt=new THREE.Vector3,this.id=e.Web.Lang.Utility.UUID.createUUID(),this._extObjMng=new e.Bimface.Viewer.ExternalObjectManager(this.viewer),this.materialConfig=new e.Bimface.Plugins.Material.MaterialConfig,this.materialConfig.viewer=this.viewer,this.materialConfig.src=this.videoSrc,this.materialConfig.textureType=this._checkVideoTextureType()):console.warn("ERROR::src in videoConfig must not be empty.")):console.warn("ERROR::viewer must not be empty or viewer2d."):console.warn("ERROR::videoConfig must not be empty.")}getId(){return this.id}getCamera(){return this.camera}getSrc(){return this.videoSrc}setCamera(e){}_loadVideoTexture(){this.loop(this.configLoop),this.mute(this.configMute)}setSrc(e){this.videoSrc=e,this.material.src=e,this._destroyVideoTexture();const t=this._checkVideoTextureType();"video"===t?this.material._loadVideoTexture((()=>{this._loadVideoTexture()})):"live"===t&&this.material._loadLiveTexture((()=>{this._loadVideoTexture()}))}play(){this.material.video&&this.material.video.play()}pause(){this.material.video&&this.material.video.pause()}mute(e){this.material.video&&(this.configMute=e,this.material.video.muted=e)}loop(e){this.material.video&&(this.configLoop=e,this.material.video.loop=e)}_checkCameraPara(e){return!!(e.position&&e.direction&&e.horizontalFov&&e.verticalFov)||(console.warn("ERROR:: position direction horizontalFov verticalFov must in camera"),!1)}_checkVideoTextureType(){const e=this.videoSrc.lastIndexOf("."),t=this.videoSrc.substr(e+1);return-1!==this.liveFormats.indexOf(t.toLowerCase())?"live":-1!==this.videoFormats.indexOf(t.toLowerCase())?"video":void 0}show(){}hide(){}update(){}_destroyVideoTexture(){this.material.material.map&&this.material.material.map.dispose(),this.material.material.map=null;let e=this.material.video;e.pause(),e.removeAttribute("src"),e.load()}destroy(){this._destroyVideoTexture(),this.material.material.dispose(),this.material=null,this.configMute=void 0,this.configLoop=void 0,this.cameraPara=null,this.id=void 0,this.materialConfig=null}}class Ps extends Ts{constructor(t){super(t),this.planeConfig=null,!1!=!this._checkPlaneSetting(t.plane)&&!1!==this._checkCameraPara(t.camera)&&(this.planeGeometry=new THREE.PlaneGeometry(1,1),this.materialConfig.side=this.planeConfig.side,this.materialConfig.callback=()=>{this.meshMatrix=new THREE.Matrix4,this.mesh=new THREE.Mesh(this.planeGeometry,this.material.material),this.mesh.autoAnimation=!0,this.mesh._externalNeedScale=!1,this._extObjMng.loadObject({name:this.id,object:this.mesh}),this._planeId=this._extObjMng.getObjectIdByName(this.id),this._updatePlaneMatrix(),this.loop(t.loop),this.mute(t.mute),this.pause(),t.callback&&t.callback()},this.material=new e.Bimface.Plugins.Material.Material(this.materialConfig))}getPlane(){return this.planeConfig}setPlane(e){!1!=!this._checkPlaneSetting(e)&&(this.material.material.side=this.planeConfig.side,this.material.material.needsUpdate=!0,this.setCamera(this.camera))}_checkPlaneSetting(e){if(!(e&&e.distance&&0===e.side||1===e.side||2===e.side))return console.warn("ERROR::plane in config incorrect."),!1;this.planeConfig=e}_checkCameraPara(e){super._checkCameraPara(e);let t=this.viewer.globalUnitUtil.translate(e.position,["x","y","z"]);const i=this.viewer.globalUnitUtil.translate(this.planeConfig.distance),n=new THREE.Vector3(e.direction.x,e.direction.y,e.direction.z);n.normalize();const o=new THREE.Vector3(t.x+n.x*i,t.y+n.y*i,t.z+n.z*i),s=i*Math.tan(e.horizontalFov/2)*2,r=i*Math.tan(e.verticalFov/2)*2;this.cameraPara={direction:n,planePosition:o,width:s,height:r}}_updatePlaneMatrix(){const e=new THREE.Vector3(this.cameraPara.width,this.cameraPara.height,1);this.mesh.translateX(this.cameraPara.planePosition.x),this.mesh.translateY(this.cameraPara.planePosition.y),this.mesh.translateZ(this.cameraPara.planePosition.z);const t=new THREE.Vector3(0,0,1);let i=new THREE.Camera;i.up.copy(t),i.position.copy(this.viewer.globalUnitUtil.translate(this.camera.position,["x","y","z"])),0===this.cameraPara.direction.x&&0===this.cameraPara.direction.y&&(i.position.y-=Number.EPSILON),i.lookAt(this.cameraPara.planePosition),this.meshMatrix.compose(this.viewer.globalUnitUtil.revertVector(this.cameraPara.planePosition),i.quaternion,e),this._extObjMng.setTransformation(this._planeId,this.meshMatrix.toArray())}setCamera(e){!1!==this._checkCameraPara(e)&&(this.camera=e,this._updatePlaneMatrix())}show(){this.mesh&&(this.mesh.visible=!0)}hide(){this.mesh&&(this.mesh.visible=!1)}destroy(){super.destroy(),this._extObjMng.removeById(this._planeId),this.planeConfig=null,this.planeGeometry.dispose(),this.planeGeometry=null,this.mesh=null}}class Is extends Ts{constructor(t){if(super(t),!1===this._checkCameraPara(t.camera))return;this._helperId=void 0,this._addCameraHelper();this.materialConfig.callback=()=>{this.videoCast=new y.VideoCast({id:this.id,position:this.viewer.viewerAdapter.worldToDrawing(this.camera.position),direction:this.viewer.viewerAdapter.worldToDrawing(this.cameraPara.direction),distance:"Viewer3D"===t.viewer.viewerType?3e5:3e3,horizontalFov:this.camera.horizontalFov,verticalFov:this.camera.verticalFov,projectorMap:this.material.material.map}),this.cloudViewer.videoCastManager.addVideoCast(this.videoCast),this.loop(t.loop),this.mute(t.mute),this.pause(),t.callback&&t.callback()},this.material=new e.Bimface.Plugins.Material.Material(this.materialConfig)}_addCameraHelper(){this._extObjMng.removeById(this._helperId),this.perspectiveCamera=new THREE.PerspectiveCamera(this.cameraPara.fov,this.cameraPara.aspect,this.viewer.globalUnitUtil.translate(.1),this.viewer.globalUnitUtil.translate(2e3));let e=this.viewer.globalUnitUtil.translate(this.camera.position,["x","y","z"]);this.perspectiveCamera.position.set(e.x,e.y,e.z),this.perspectiveCamera.up.set(0,0,1),this.perspectiveCamera.lookAt(this.cameraPara.target),this.perspectiveCamera.updateMatrixWorld(!0);const t=new THREE.CameraHelper(this.perspectiveCamera);t.visible=!1,this._extObjMng.loadObject({name:this.id,object:t}),this._helperId=this._extObjMng.getObjectIdByName(this.id)}_checkCameraPara(e){super._checkCameraPara(e);const t=new THREE.Vector3(e.direction.x,e.direction.y,e.direction.z);t.normalize(),this.scratchAt.copy(this.viewer.globalUnitUtil.translate(e.position,["x","y","z"])),this.scratchAt.add(t),this.cameraPara={direction:t,aspect:Math.tan(e.horizontalFov/2)/Math.tan(e.verticalFov/2),fov:THREE.Math.radToDeg(e.verticalFov),target:this.scratchAt}}_loadVideoTexture(){super._loadVideoTexture(),this.videoCast.setProjectorMap(this.material.material.map),this.cloudViewer.videoCastManager.update()}show(){this.videoCast.setVisible(!0),this.cloudViewer.videoCastManager.update()}hide(){this.videoCast.setVisible(!1),this.cloudViewer.videoCastManager.update()}update(){this.cloudViewer.videoCastManager.update()}setCamera(e){!1!==this._checkCameraPara(e)&&(this.camera=e,this._addCameraHelper(),this.videoCast&&(this.videoCast.setPosition(this.viewer.viewerAdapter.worldToDrawing(e.position)),this.videoCast.setDirection(this.cloudViewer.worldToDrawing(e.direction)),this.videoCast.setHorizontalFov(e.horizontalFov),this.videoCast.setVerticalFov(e.verticalFov),this.videoCast.updateViewMatrix(),this.videoCast.updateProjMatrix(),this.cloudViewer.videoCastManager.update()))}destroy(){super.destroy(),this._extObjMng.removeById(this._helperId),this.cloudViewer.videoCastManager.removeById(this.videoCast.getId()),this.cloudViewer.videoCastManager.update(),this.videoCast.destroy()}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Videos");i.Video=class{constructor(e){t.send("Bimface.Plugins.Videos.Video","bf_c_Video_new"),this.videoImpl=null,P(this),!0===e.isPlaneOn?this.videoImpl=new Ps(e):this.videoImpl=new Is(e)}getId(){return this.videoImpl.getId()}getCamera(){return this.videoImpl.getCamera()}getSrc(){return this.videoImpl.getSrc()}getPlane(){if(this.videoImpl.planeConfig)return this.videoImpl.getPlane()}setCamera(e){this.videoImpl.setCamera(e)}setSrc(e){this.videoImpl.setSrc(e)}setPlane(e){this.videoImpl.planeConfig&&this.videoImpl.setPlane(e)}play(){this.videoImpl.play()}pause(){this.videoImpl.pause()}mute(e){this.videoImpl.mute(e)}loop(e){this.videoImpl.loop(e)}update(){this.videoImpl.update()}show(){this.videoImpl.show()}hide(){this.videoImpl.hide()}destroy(){this.videoImpl.destroy()}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Videos");t.VideoManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Videos");i.VideoManager=class{constructor(i){t.send("Bimface.Plugins.Videos.VideoManager","bf_c_VideoManager_new"),i?i.viewer&&("Viewer3D"===i.viewer.viewerType||i.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(this.viewer=i.viewer,this.videoMap={},P(this)):console.warn("ERROR::viewer must not be empty or viewer2d."):console.warn("ERROR::VideoManagerConfig must not be empty.")}addVideo(e){this.videoMap[e.getId()]?console.warn("Warn::this video has been in added in videoManager."):this.videoMap[e.getId()]=e}addVideos(e){if(!Array.isArray(e))return void console.warn("WARNING: Glodon.Bimface.Analysis.Videos.VideoManager.addVideos() need array");const t=e.length;for(let i=0;i<t;++i)this.addVideo(e[i])}getVideoById(e){return this.videoMap[e]}getVideos(){return(e=>{let t=[];for(var i in e)e[i]&&t.push(e[i]);return t})(this.videoMap)}hideVideoById(e){this.videoMap[e]?this.videoMap[e].hide():console.warn(`WARNING: no ${e} video in videoManager`)}showVideoById(e){this.videoMap[e]?this.videoMap[e].show():console.warn(`WARNING: no ${e} video in videoManager`)}removeVideoById(e){if(!this.videoMap[e])return void console.warn(`WARNING: no ${e} video in videoManager`);let t=this.videoMap[e];t.destroy(),t=null,this.videoMap[e]=null,delete this.videoMap[e]}clear(){for(let e in this.videoMap)this.removeVideoById(e)}}}(),function(){e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins");var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.GisScene");t.GisScene=class{constructor(e,t){this.app=t,this.viewer=t.getViewer();const i=new THREE.FileLoader;i.setResponseType("json"),i.load(e,(e=>{this.sceneContext=e,this.prepareScene()}),void 0,(t=>{console.error(`Load ${e} failed, ${t}`)})),this.modelIndex=0,this.modelNum=0,this.models=[],P(this)}prepareScene(){var t=new e.Bimface.Plugins.TileMap.MapConfig;t.viewer=this.viewer,t.modelAltitude=0,t.basePoint={x:0,y:0},t.useTerrain=!1,t.maxTerrainLevel=14,t.terrainPath="https://static.bimface.com/gis/dem/srtm/v1/",this.sceneContext.terrainPath&&(t.terrainPath=this.sceneContext.terrainPath),t.modelRotationZ=0*Math.PI/180,t.modelPosition=[this.sceneContext.baseLngLat.lng,this.sceneContext.baseLngLat.lat],this.sceneContext.resources.map((e=>{switch(e.type){case"baseMap":!0===e.visibility&&(t.mapLayer=e.name);break;case"elevationModel":!0===e.visibility&&(t.useTerrain=!0);break;case"BIM":!0===e.visibility&&this.models.push(e)}})),this.models.sort((function(e,t){return e.priority-t.priority}));const i=this.models.length;if(i<=0)return void console.log("no model in scene.json");const n={Google_Roadmap:"m",Google_Hybrid:"y",Google_Satellite:"s"};void 0===n[t.mapLayer]?(console.warn(`${t.mapLayer} invalid, Google_Satellite default`),t.mapLayer="s"):t.mapLayer=n[t.mapLayer],this.modelNum=i;let o={};o.loadConfig=t;let s=this.viewer.getViewer().modelManager.createDemModel(o,!0);this.tileManager=s.tileManager,this.setCamera(),this.viewer.getViewer().modelManager.addEventListener(CLOUD.EVENTS.ON_MAP_LOAD_ALL,(()=>{const t=this.getModelLoadConfig();this.app.addView(this.models[this.modelIndex].viewToken,"bimTiles",t),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewAdded,(e=>{if(this.modelIndex++,this.modelIndex>this.modelNum-1)return;const t=this.getModelLoadConfig();this.app.addView(this.models[this.modelIndex].viewToken,"bimTiles",t)}))})),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ModelAdded,(e=>{if(this.modelIndex++,this.modelIndex>this.modelNum-1)return;const t=this.getModelLoadConfig();this.app.addView(this.models[this.modelIndex].viewToken,"bimTiles",t)}))}getModelLoadConfig(){let e={zoomAll:!1};const t=this.models[this.modelIndex].transformation;return Array.isArray(t)&&16===t.length?e.transformMatrix=(new THREE.Matrix4).fromArray(t):console.log(`${this.models[this.modelIndex].modelId} no transformation or transformation is invalid`),e}setCamera(){const e=this.sceneContext.homeCameraView.position;let t=this.tileManager.lonLat2Mercator(e.lng,e.lat);t.z=e.height;let i=this.viewer.getCameraStatus();i.position=t;const n=this.sceneContext.homeCameraView.orientation,o=n.heading,s=n.pitch;let r=new THREE.Vector3;r.x=Math.sin(o)*Math.cos(s),r.y=Math.cos(o)*Math.cos(s),r.z=Math.sin(s);var a=r.multiplyScalar(1e3).clone().add(t);i.target=a,this.viewer.setCameraStatus(i)}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.WebXR");i.WebXRManager=class{constructor(i){if(t.send("Bimface.Plugins.WebXR.WebXRManager","bf_c_webXRMng"),i){if(i instanceof e.Bimface.Viewer.Viewer3D)this.viewer=viewer,this.isEmulator=!1;else{if(!(i.viewer instanceof e.Bimface.Viewer.Viewer3D))return void console.log("ERROR::viewer must not be empty.");this.viewer=i.viewer,this.isEmulator=!!i.isEmulator}this.isXRSupported=0,this.isEmulatorLoaded=!1,this.isEmulator?this._initializeEmulator():this._checkXRSupported(),this.isXREntered=!1}else console.log("ERROR::viewer must not be empty.")}_checkXRSupported(){let e=this;function t(){e.isXRSupported=0}function i(){console.log("WARNNING::VR NOT FOUND"),e.isXRSupported=1}"xr"in navigator?"isSessionSupported"in navigator.xr?navigator.xr.isSessionSupported("immersive-vr").then((function(e){e?t():i()})):navigator.xr.supportsSession("immersive-vr").then(t).catch(i):(console.log("WARNNING::VR NOT SUPPORTED"),e.isXRSupported=2)}_initializeEmulator(){let t="https://static.bimface.com",i=[`${t}/resources/webxr/webxr-polyfill.js`,`${t}/resources/webxr/ConfigurationManager.js`,`${t}/resources/webxr/content-script.js`];var n=this;e.Web.Lang.Utility.HttpRequest.getScripts(i,(()=>{n.isEmulatorLoaded=!0,console.log("pollyfill loaded successfully")}));var o=this.viewer.getViewer();let s=o.getRenderer(),r=s.domElement;o.editorManager.registerDomEventListeners(r),this.size=new THREE.Vector2,s.getDrawingBufferSize(this.size);var a=new THREE.DepthTexture;a.format=THREE.DepthStencilFormat,a.type=THREE.UnsignedInt248Type,a.minFilter=THREE.NearestFilter,a.magFilter=THREE.NearestFilter,this.depthRenderTarget=new THREE.WebGLRenderTarget(this.size.x,this.size.y,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,depthBuffer:!0,depthTexture:a});let l=new THREE.PlaneGeometry(2,2);this.screenMaterial=new THREE.ShaderMaterial({uniforms:CLOUD.PostDepthShader.uniforms,vertexShader:CLOUD.PostDepthShader.vertexShader,fragmentShader:CLOUD.PostDepthShader.fragmentShader}),this.planeMesh=new THREE.Mesh(l,this.screenMaterial),this.screenMaterial.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.screenMaterial.uniforms.tDepth.value=this.depthRenderTarget.depthTexture,this.screenMaterial.uniforms.isDepthMode.value=!0,this.screenCamera=new THREE.OrthographicCamera(-1,1,1,-1,0,1)}enableXR(e){if(0!=this.isXRSupported||this.isXREntered==e)return;let t=this,i=this.viewer.getViewer();i.enableVR(e);let n=i.getRenderer(),o=i.getScene();function s(){(n.xr&&n.xr.getSession()).removeEventListener("end",s),n.xr.setSession(null),n.setAnimationLoop(null)}if(e){n.setAnimationLoop((function(){if(t.isEmulator)n.setRenderTarget(t.depthRenderTarget),n.render(o,i.camera),n.xr.enabled=!1,n.setRenderTarget(null),t.screenMaterial.uniforms.cameraNear.value=i.camera.near,t.screenMaterial.uniforms.cameraFar.value=i.camera.far,n.render(t.planeMesh,t.screenCamera),n.xr.enabled=!0;else{if(t.xrControllerGroups){let e=t.xrControllerGroups.children;const n=i.getScene().getMatrixGlobal();let o=new THREE.Matrix4;o.copy(n).invert();for(let t=0;t<e.length;t++)e[t].updateMatrixWorld(!0),o.multiplyMatrices(o,e[t].matrixWorld),e[t].matrixWorld=o}i.renderWithXR()}}));let r={optionalFeatures:["local-floor","bounded-floor"]};navigator.xr.requestSession("immersive-vr",r).then((function(i){t.isXREntered=e,i.addEventListener("end",s),n.xr.setSession(i)}))}else{let o=n.xr&&n.xr.getSession();o&&o.end(),i.render(),t.isXREntered=e}}getController(e){const t=this.viewer.getViewer(),i=t.getRenderer(),n=t.getScene(),o=i.xr.getController(e);this.xrControllerGroups=n.getOrCreateObjectGroup("XRControllerGroups"),this.xrControllerGroups.add(o);const s=.5*CLOUD.GlobalData.SceneSize;return this.xrControllerGroups.scale.set(s,s,s),this.xrControllerGroups.updateMatrixWorld(),o}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.IBL").IBLStyle=Object.freeze({CloudySky:"CloudySky",CityNightView:"CityNightView",OpenField:"OpenField",LawnScene:"LawnScene",Sunrise:"Sunrise",HarborSunRise:"HarborSunRise",RiverSide:"RiverSide",SunsetGrass:"SunsetGrass",Harbor:"Harbor",ParkingLot:"ParkingLot",Gray:"Gray"}),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.IBL");t.IBLManagerConfig=class{constructor(){this.style=e.Bimface.Plugins.IBL.IBLStyle.CloudySky,this.roughness=.4,this.metalness=0,this.lightIntensity=null,this.imageVisible=!0,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.IBL");i.IBLManager=class{constructor(i){t.send("Bimface.Plugins.IBL.IBLManager","bf_c_IBLMng_new"),this.style=i.style,this.roughness=i.roughness,this.metalness=i.metalness;const n=i.viewer instanceof e.Bimface.Viewer.ViewerGIS;this.lightIntensity=i.lightIntensity?i.lightIntensity:n?10:1,this.imageVisible=i.imageVisible,this.viewer=i.viewer,this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(P(this),this._enabled=!1,self._IBLConfig=null,this._dataConfig=new e.Bimface.Data.IBLManagerConfig,this._dataManager=new e.Bimface.Data.IBLManager(this._dataConfig),this.enableIBL(!0)):console.log("ERROR::viewer must not be empty or viewer2d.")}enableIBL(e){if(this._enabled==e)return;this._enabled=e;let t=this.viewer.getViewer().IBLManager;this._enabled?this._updateIBL():t.enableIBL(!1)}_updateIBL(){if(!this._enabled)return;let e=this,t=this.viewer.getViewer().IBLManager,i=this.viewer._data,n=i.dataEnvType==_.Local?i.sdkPath:g.staticHost;t.enableIBL(!0),this._getIBLConfig((function(i){const o=e.style;let s=e._IBLConfig[o];s&&(s.url=s.url.replace(g.staticHost,""),s.uniforms.metalness=e.metalness,s.uniforms.roughness=e.roughness,s.uniforms.iblFactor=e.lightIntensity,t.loadIBLMaps(`${n}/${s.url}`,s.isHDR,e.imageVisible,s.uniforms,i))}))}_getIBLConfig(e){let t=this,i=t.viewer._data;t._IBLConfig?e&&e(!0):(i.dataEnvType==_.Local&&(t._dataConfig.resourceHost=i.sdkPath),t._dataManager.getIBLConfig((function(i){t._IBLConfig=i,e&&e(!1)})))}setImageVisible(e){if(this.imageVisible==e)return;this.imageVisible=e;let t=this.viewer.getViewer().IBLManager;e&&this._enabled?(t.addSkyBox(!0,t.IBLParams),this.viewer.render()):t.removeSkyBox()}isImageVisible(){return this.imageVisible}setStyle(e){e&&this.style!=e&&(this.style=e,this._IBLConfig=null,this._updateIBL())}getStyle(){return this.style}setRoughness(e){if(e<0||e>1||this.roughness==e||!this._enabled)return;this.roughness=e;let t=this.viewer.getViewer();t.IBLManager.IBLParams.roughness=e,t.modelManager.updateMaterialsValue("roughness",e,!0)}getRoughness(){return this.roughness}setMetalness(e){if(e<0||e>1||this.metalness==e||!this._enabled)return;this.metalness=e;let t=this.viewer.getViewer();t.IBLManager.IBLParams.metalness=e,t.modelManager.updateMaterialsValue("metalness",e,!0)}getMetalness(){return this.metalness}setLightIntensity(e){if(e<0||this.lightIntensity==e||!this._enabled)return;this.lightIntensity=e;let t=this.viewer.getViewer();t.IBLManager.IBLParams.iblFactor=e,t.modelManager.updateMaterialsValue("iblFactor",e,!0)}getLightIntensity(){return this.lightIntensity}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.EnvMap");t.EnvMapManager=class{constructor(t){if(this.style=t.style,this.viewer=t.viewer,!this.viewer||!("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");P(this);let i=this.viewer._data,n=i.dataEnvType==_.Local?i.sdkPath:g.staticHost;this._config={CloudPuresky:{envMapIntensity:.55,brightness:.45,temperature:3500,temperatureStrength:.45,url:`${n}/resources/EnvMap/CloudPuresky.exr`},MistyMorning:{envMapIntensity:.55,brightness:.45,temperature:4500,temperatureStrength:.45,url:`${n}/resources/EnvMap/MistyMorning.exr`},OvercastPuresky:{envMapIntensity:.45,brightness:.45,temperature:3500,temperatureStrength:.45,url:`${n}/resources/EnvMap/OvercastPuresky.exr`},Puresky:{envMapIntensity:.55,brightness:.45,temperature:3500,temperatureStrength:.45,url:`${n}/resources/EnvMap/Puresky.exr`},RiversidePavement:{envMapIntensity:.55,brightness:.45,temperature:1e3,temperatureStrength:0,url:`${n}/resources/EnvMap/RiversidePavement.exr`},MonoCloudPuresky:{envMapIntensity:.55,brightness:.45,temperature:1e3,temperatureStrength:0,url:`${n}/resources/EnvMap/MonoCloudPuresky.exr`}},this.viewer._oldColorTemperatureInfo||(this.viewer._oldColorTemperatureInfo=this.viewer.getViewer().getColorTemperature()),this.oldColorTemperatureInfo=this.viewer._oldColorTemperatureInfo,this.enableEnvMap(!0)}build(){let e=this.viewer.getViewer();this._config[this.style]&&(e.IBLManager.enableIBL(!1),e.loadEquirectangularMap(this._config[this.style].url,!0,(()=>{e.setEnvMapIntensity(this._config[this.style].envMapIntensity),e.setColorTemperature(this._config[this.style].temperature,this._config[this.style].temperatureStrength),e.modelManager.updateMaterialsValue("reflectedFactor",this._config[this.style].brightness)})),this.viewer.render())}enableEnvMap(e){if(e)this.build();else{this.viewer.getViewer().closeEnvMap(),this.viewer.getViewer().setEnvMapIntensity(1),this.viewer.getViewer().modelManager.updateMaterialsValue("reflectedFactor",1);let e=this.viewer.getColorTemperature()||this.oldColorTemperatureInfo;e&&this.viewer.getViewer().setColorTemperature(e[0]||1e3,e[1]||0)}this.viewer.render()}getCustomizedImage(){return this._config[this.style]}getStyle(){return this.style}setStyle(e){e&&(this.style=e,this.build())}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.EnvMap");t.EnvMapManagerConfig=class{constructor(){this.style=e.Bimface.Plugins.EnvMap.EnvMapStyle.CloudPuresky,this.viewer=null}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.EnvMap").EnvMapStyle=Object.freeze({CloudPuresky:"CloudPuresky",MistyMorning:"MistyMorning",OvercastPuresky:"OvercastPuresky",Puresky:"Puresky",RiversidePavement:"RiversidePavement",MonoCloudPuresky:"MonoCloudPuresky"}),function(){let t=Object.freeze({Line:{width:4,color:new e.Web.Graphics.Color("#20262F",1)},None:"None"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Viewport").BorderStyleOption=t}();class Ss{constructor(e){this.embeddedView=e,this.viewer=e.viewer,this.init()}init(){this.element=document.createElement("div"),this.element.className="bf-viewport-border",this.viewer.getDomElement().appendChild(this.element),this.borderElements={},this.domEvents={resizable:{},movable:void 0},["top","right","bottom","left","topright","bottomright","bottomleft","topleft"].forEach((e=>{let t=this.borderElements[e]=document.createElement("div");t.className=`bf-viewport-border-${e}`,this.element.appendChild(t)})),this.updateResizable(this.embeddedView.isBorderDraggable()),this.updateMovable(this.embeddedView.isEmbeddedViewDraggable()),this.hide()}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}destroy(){this.updateResizable(!1),this.updateMovable(!1),this.embeddedView=null,this.element&&this.viewer.getDomElement().removeChild(this.element),this.element=null,this.viewer=null}update(){if(!this.element)return;let{locationX:e,locationY:t,widthRatio:i,heightRatio:n}=this.embeddedView.getViewRegion(),o=this.updateBorderStyle(),s=this.element.style;s.left=(e-o.left<0?0:e-o.left)+"px",s.top=(t-o.top<0?0:t-o.top)+"px",s.width=`calc(${100*i}% + ${o.left+o.right}px)`,s.height=`calc(${100*n}% + ${o.top+o.bottom}px)`}updateBorderStyle(){let{topBorderStyle:e,rightBorderStyle:t,bottomBorderStyle:i,leftBorderStyle:n}=this.embeddedView.getSubViewBorderStyle(),o={top:e,right:t,bottom:i,left:n},s={};for(let e in o){let t=o[e],i=this.borderElements[e],n=t.width&&!isNaN(t.width)?t.width:4;n>20&&(n=20),n<1&&(n=1),i.style[["top","bottom"].indexOf(e)>=0?"height":"width"]=`${n}px`,s[e]=n/2,i.style.backgroundColor=t===Glodon.Bimface.Plugins.Viewport.BorderStyleOption.None?"transparent":t.color&&t.color.getRGBA?t.color.getRGBA():"#20262F"}return s}updateResizable(e,t){const i=(e,t)=>{let i,n,o,s=!1;const r=t=>{if(!s)return;let r=t.clientX-i,a=r/this.viewer.getDomElement().offsetWidth,l=t.clientY-n,h=l/this.viewer.getDomElement().offsetHeight,{locationX:d,locationY:c,widthRatio:u,heightRatio:g}=o;if(e.indexOf("top")>=0&&(c+=l,g-=h),e.indexOf("right")>=0&&(u+=a),e.indexOf("bottom")>=0&&(g+=h),e.indexOf("left")>=0&&(d+=r,u-=a),d<0||c<0||u<0||g<0)return;const p={locationX:d,locationY:c,widthRatio:u,heightRatio:g};this.embeddedView.setViewRegion(p),this.embeddedView.update()},a=e=>{s=!1,t.removeEventListener("mouseup",a),t.removeEventListener("mousemove",r)};return e=>{e.stopPropagation(),s=!0,i=e.clientX,n=e.clientY,o=Object.assign({},this.embeddedView.getViewRegion()),t.addEventListener("mouseup",a),t.addEventListener("mousemove",r)}};t=t||Object.keys(this.borderElements);for(let n in this.borderElements){let o=this.borderElements[n];if(e&&t.indexOf(n)>=0){if(o.classList.add("resizable"),this.domEvents.resizable[n])continue;let e=i(n,this.viewer.getDomElement());o.addEventListener("mousedown",e),this.domEvents.resizable[n]={type:"mousedown",element:o,handler:e}}else{o.classList.remove("resizable");let e=this.domEvents.resizable[n];if(!e)continue;e.element.removeEventListener(e.type,e.handler),delete this.domEvents.resizable[n]}}}updateMovable(e){if(this.element.style.cursor=e?"move":"unset",e&&!this.domEvents.movable){let e,t,i,n=!1,o=this.viewer.getDomElement();const s=s=>{s.stopPropagation(),n=!0,e=s.clientX,t=s.clientY,i=Object.assign({},this.embeddedView.getViewRegion()),o.addEventListener("mouseup",a),o.addEventListener("mousemove",r)},r=o=>{if(!n)return;let s=o.clientX-e,r=o.clientY-t,{locationX:a,locationY:l,widthRatio:h,heightRatio:d}=i;if(a+=s,l+=r,a<0||l<0)return;const c={locationX:a,locationY:l,widthRatio:h,heightRatio:d};this.embeddedView.setViewRegion(c),this.embeddedView.update()},a=e=>{n=!1,o.removeEventListener("mouseup",a),o.removeEventListener("mousemove",r)};this.element.addEventListener("mousedown",s),this.domEvents.movable={type:"mousedown",element:this.element,handler:s}}else if(!e&&this.domEvents.movable){let e=this.domEvents.movable;e.element.removeEventListener(e.type,e.handler),this.domEvents.movable=void 0}}}!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Viewport");i.Swipe=class{constructor(i){if(t.send("Bimface.Plugins.Viewport.Swipe","bf_c_swipe_new"),!i)return void console.log("ERROR::swipeConfig must not be empty.");if(!i.viewer)return void console.log("ERROR::viewer must not be empty.");if(!("Viewer3D"===i.viewer.viewerType||i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be viewer2d.");P(this),this.visibleLayers=[],this.enableLayerTypes={TileLayer:!0,TerrainLayer:!1,BIMLayer:!0,FeatureLayer:!0,TilesetLayer:!0},this.subViewBorderStyle={topBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,rightBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,bottomBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,leftBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line},this.mainViewContents=[],this.subViewContents=[],this.viewer=i.viewer;const n=new e.Bimface.Plugins.Viewport.SwipeConfig;this.mode=Object.assign(n.mode,i.mode),this.layerCallbackList=[],this.border=new Ss(this),this.setSwipeMode(this.mode),this.setLayerContents(i.layerContents),this.mode.type!==e.Bimface.Plugins.Viewport.SwipeType.SplitView&&(this.setBorderDraggable(i.borderDraggable),this.setEmbeddedViewDraggable(i.embeddedViewDraggable)),this.enableEmbeddedView(!0)}update(){if(null!=this.mainViewContents&&this.needUpdateMain){this._mainViewContents=[],this.layerCallbackList.length>0&&this._updateModelCallback("mainViewContents");for(var e=0;e<this.mainViewContents.length;e++){var t={isVisible:this.mainViewContents[e].isVisible};null==(i=this.viewer.getLayerManager().getLayer(this.mainViewContents[e].layerId))||!i.loaded&&"TileLayer"!=i.typeName?(this.layerCallbackList.push({layerId:this.mainViewContents[e].layerId,isVisible:this.mainViewContents[e].isVisible,content:"mainViewContents"}),this.viewer.getLayerManager().getLoadManager().loadLayer([this.mainViewContents[e].layerId])):(i.loaded?t.modelId=i.modelId:t.imageryId=i._imageryId,this._mainViewContents.push(t))}}if(null!=this.subViewContents&&this.needUpdateSub){this._subViewContents=[],this.layerCallbackList.length>0&&this._updateModelCallback("subViewContents");for(e=0;e<this.subViewContents.length;e++){var i;t={isVisible:this.subViewContents[e].isVisible};null==(i=this.viewer.getLayerManager().getLayer(this.subViewContents[e].layerId))||!i.loaded&&"TileLayer"!=i.typeName?(this.layerCallbackList.push({layerId:this.subViewContents[e].layerId,isVisible:this.subViewContents[e].isVisible,content:"subViewContents"}),this.viewer.getLayerManager().getLoadManager().loadLayer([this.subViewContents[e].layerId])):(i.loaded?t.modelId=i.modelId:t.imageryId=i._imageryId,this._subViewContents.push(t))}}this._addModelCallback(),this.viewer.getViewer().setEmbeddedView({subViewRegion:this.mode.viewRegion,mainViewContents:this.needUpdateMain?this._mainViewContents:null,subViewContents:this.needUpdateSub?this._subViewContents:null}),this.needUpdateSub=!1,this.needUpdateMain=!1,this.border.update()}destroy(){this._removeModelCallback(),this.viewer.getViewer().enableEmbeddedView(!1),this.setLayersVisibleTrue(),this.visibleLayers=[],this.mainViewContents=null,this.subViewContents=null,this.subViewBorderStyle=null,this.border.destroy(),this.border=null,this.viewer=null}_removeModelCallback(){null!=this._modelAddedFn&&(this.viewer.removeEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,this._modelAddedFn),this._modelAddedFn=null)}_addModelCallback(){var t=this;t.layerCallbackList.length>0&&null==t._modelAddedFn&&(t._modelAddedFn=function(e){for(var i=t.layerCallbackList.length-1;i>=0;i--){var n=t.layerCallbackList[i].layerId;if(e==n){var o={isVisible:t.layerCallbackList[i].isVisible},s=t.viewer.getLayerManager().getLayer(n);null!=s&&s.loaded?(s.hide(),o.modelId=s.modelId,"mainViewContents"==t.layerCallbackList[i].content?(t._mainViewContents.push(o),t.viewer.getViewer().setEmbeddedView({mainViewContents:t._mainViewContents})):"subViewContents"==t.layerCallbackList[i].content&&(t._subViewContents.push(o),t.viewer.getViewer().setEmbeddedView({subViewContents:t._subViewContents}))):console.log("请指定正确的layerId.layerId:",n),t.layerCallbackList.removeByValue(t.layerCallbackList[i])}}0==t.layerCallbackList.length&&t._removeModelCallback()},t.viewer.addEventListener(e.Bimface.Viewer.ViewerGISEvent.ModelAdded,t._modelAddedFn))}_updateModelCallback(e){for(var t=this,i=t.layerCallbackList-1;i>=0;i--)e==t.layerCallbackList[i].content&&t.layerCallbackList.removeByValue(t.layerCallbackList[i])}show(){this.setLayersVisibleFalse(),this.enableEmbeddedView(!0)}hide(){this.enableEmbeddedView(!1),this.setLayersVisibleTrue()}setSwipeMode(t){switch((t=Object.assign(this.mode,t)).type){case e.Bimface.Plugins.Viewport.SwipeType.SplitView:this.setBorderDraggable(!0),e.Bimface.Plugins.Viewport.SwipeHelper.assembleSplitView(this,t);break;case e.Bimface.Plugins.Viewport.SwipeType.EmbeddedView:this.setSubViewBorderStyle({topBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,rightBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,bottomBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,leftBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line}),this.setBorderDraggable(!0),this.setEmbeddedViewDraggable(!0),this.update()}}getSwipeMode(){return this.mode}setLayerContents(e){this.viewer.getViewer().enableEmbeddedView(!1),this.setLayersVisibleFalse();let t=(e,i)=>{const n=viewer.getLayerManager().getLayer(e);"GroupLayer"===n.typeName?n.getContents().map((e=>{t(e.id,i)})):i.push(e)};if(this.layerContents=e,!(e instanceof Array&&2===e.length))return void console.warn("The layerContents input is invalid");let i=[],n=[],o=[];e[0].map((e=>{t(e,o)})),o.map((e=>{i.push({layerId:e,isVisible:!0})})),this.setMainViewContents(i),o=[],e[1].map((e=>{t(e,o)})),o.map((e=>{n.push({layerId:e,isVisible:!0})})),this.setSubViewContents(n),this.update(),this.viewer.getViewer().enableEmbeddedView(!0)}getLayerContents(){return this.layerContents}setEmbeddedViewDraggable(e){this.isSubViewMovable=e,this.border.updateMovable(e)}isEmbeddedViewDraggable(){return this.isSubViewMovable}setBorderDraggable(e){this.isSubViewResizable=e,this.border.updateResizable(e)}isBorderDraggable(){return this.isSubViewResizable}getViewRegion(){return this.mode.viewRegion}setViewRegion(e){const{locationX:t,locationY:i,widthRatio:n,heightRatio:o}=e;null!=t&&(this.mode.viewRegion.locationX=t<0?0:t),null!=i&&(this.mode.viewRegion.locationY=i<0?0:i),null!=n&&(this.mode.viewRegion.widthRatio=n),null!=o&&(this.mode.viewRegion.heightRatio=o)}getSubViewContents(){return this.subViewContents}setSubViewContents(e){this.subViewContents=e,this.needUpdateSub=!0}getMainViewContents(){return this.mainViewContents}setMainViewContents(e){this.mainViewContents=e,this.needUpdateMain=!0}getSubViewBorderStyle(){return this.subViewBorderStyle}setSubViewBorderStyle(e){null!=e.topBorderStyle&&(this.subViewBorderStyle.topBorderStyle=e.topBorderStyle),null!=e.rightBorderStyle&&(this.subViewBorderStyle.rightBorderStyle=e.rightBorderStyle),null!=e.bottomBorderStyle&&(this.subViewBorderStyle.bottomBorderStyle=e.bottomBorderStyle),null!=e.leftBorderStyle&&(this.subViewBorderStyle.leftBorderStyle=e.leftBorderStyle),this.border.updateBorderStyle()}getStatus(){return{cameraStatus:this.viewer.getCameraStatus(),mainViewContents:this.mainViewContents,subViewContents:this.subViewContents,borderStyleObject:this.subViewBorderStyle}}enableEmbeddedView(e){this.viewer.getViewer().enableEmbeddedView(e),e?this.border.show():this.border.hide(),this.viewer.render()}setLayersVisibleFalse(){const e=this.viewer.getLayerManager().getRootLayer();let t=e=>{"GroupLayer"===e.typeName?e.getContents().map((e=>{t(e)})):this.enableLayerTypes[e.typeName]&&!0===e.isVisible&&this.visibleLayers.push(e)};t(e),this.visibleLayers.map((e=>{e.hide()}))}setLayersVisibleTrue(){this.visibleLayers.map((e=>{e.show()}))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Viewport").SwipeConfig=class{constructor(){this.viewer=null,this.mode={type:e.Bimface.Plugins.Viewport.SwipeType.SplitView,position:.5,direction:e.Bimface.Common.Direction.Horizontal,viewRegion:{locationX:100,locationY:100,widthRatio:.2,heightRatio:.2}},this.layerContents=[[],[]],this.borderDraggable=!0,this.embeddedViewDraggable=!0}},function(){class t{constructor(){}}t.assembleSplitView=function(t,i){let n={};switch(i.direction){case e.Bimface.Common.Direction.Horizontal:n={locationX:t.viewer.getDomElement().offsetWidth*i.position,locationY:0,widthRatio:1,heightRatio:1},t.setViewRegion(n),t.setSubViewBorderStyle({topBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None,rightBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None,bottomBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None,leftBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line}),t.border.updateResizable(!0,["left"]);break;case e.Bimface.Common.Direction.Vertical:n={locationX:0,locationY:t.viewer.getDomElement().offsetHeight*i.position,widthRatio:1,heightRatio:1},t.setViewRegion(n),t.setSubViewBorderStyle({topBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.Line,leftBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None,rightBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None,bottomBorderStyle:e.Bimface.Plugins.Viewport.BorderStyleOption.None}),t.border.updateResizable(!0,["top"])}t.setEmbeddedViewDraggable(!1),t.update()},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Viewport").SwipeHelper=t}(),function(){let t=Object.freeze({SplitView:"SplitView",EmbeddedView:"EmbeddedView"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Viewport").SwipeType=t}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Effect");t.BloomEffectConfig=class{constructor(){this.ids=[],this.intensity=.5,this.threshold=0,this.spread=3,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Effect");i.BloomEffect=class{constructor(i){t.send("Bimface.Plugins.Effect.BloomEffect","bf_c_bloomEffect_new"),this.ids=i.ids,this.intensity=i.intensity,this.spread=i.spread,this.threshold=i.threshold,this.viewer=i.viewer,this._type="body",this._enable=!0,this._preIds=null,this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(this.isGis=this.viewer instanceof e.Bimface.Viewer.ViewerGIS,this.update(),P(this)):console.log("ERROR::viewer must not be empty or viewer2d.")}setIds(e){this.ids==e||!e instanceof Array||(this._preIds=this.ids,this.ids=e)}getIds(){return this.ids}setIntensity(e){this.intensity!=e&&(this.intensity=e)}getIntensity(){return this.intensity}setSpread(e){this.spread!=e&&(this.spread=e)}getSpread(){return this.spread}setThreshold(e){this.threshold!=e&&(this.threshold=e)}getThreshold(){return this.threshold}clear(){let e=this.ids,t=this.viewer.getViewer();const i=this._getModelIdAndObjectIds(e);for(const e in i){const n=i[e];t.removeGlowEffectById(e,n)}this.ids=[]}update(){let e=this.viewer.getViewer();if(this._preIds){const t=this._getModelIdAndObjectIds(this._preIds);for(const i in t){const n=t[i];e.removeGlowEffectById(i,n)}this._preIds=null}let t=this.ids;const i=this._getModelIdAndObjectIds(t);for(const t in i){const n=i[t];e.setGlowEffectById(t,n,{type:this._type,intensity:this.intensity,spread:this.spread,isGis:this.isGis,useDiffuse:!0,threshold:this.threshold})}this.viewer.render()}_getModelIdAndObjectIds(e){let t={},i=(e,i)=>{void 0!==t[e]?t[e].push(i):t[e]=[i]};const n=e.length;for(let t=0;t<n;t++){const n=e[t];let o=n.modelId;const s=n.layerId;let r=n.objectIds;if(o){r.map((e=>{i(o,e)}));continue}if(s){const e=this.viewer.getLayerManager().getLayer(s);o=e.getModelId(),r.map((e=>{i(o,e)}));continue}if(!r)return;const a=r.length,l=this.viewer.getViewer().modelManager.modelCollection,h=l.getById("ExtrudeBodyManager"),d=l.getById("ExternalComponent");for(let e=0;e<a;e++){const t=r[e];h&&h._hasObjectId(t)?i(CLOUD.ObjectGroupType.EXTRUDEBODYMANAGER,t):d&&d._hasObjectId(t)&&i("ExternalComponent",t)}}return t}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Effect");t.BlinkEffectConfig=class{constructor(){this.ids=[],this.color=null,this.interval=800,this.times=void 0,this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Effect");class n{constructor(i){t.send("Bimface.Plugins.Effect.BlinkEffect","bf_c_BlinkEffect_new"),this.uuid=e.Web.Lang.Utility.UUID.createUUID(),this.ids=i.ids||[],this.interval=i.interval||800,this.times=i.times,this.color=i.color,this.viewer=i.viewer,this._idsChanged=!1,this._isEnable=!0,this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(n.AddReferenceCount(this.viewer),this.isGis=this.viewer instanceof e.Bimface.Viewer.ViewerGIS,this.update()):console.log("ERROR::viewer must not be empty or viewer2d.")}destroy(){this.ids=null,this.interval=void 0,this.times=void 0,this.color=null,this.viewer.getViewer().clearBlinkComponentsByDetail(this.uuid),n.SubtractReferenceCount(this.viewer),this.viewer=null,this.uuid=void 0}setIds(e){e instanceof Array&&(this._idsChanged=!0,this.ids=e)}getIds(){return this.ids}setColor(e){this.color=e}getColor(){return this.color}setInterval(e){this.interval==e||e<=0||(this.interval=e)}getInterval(){return this.interval}setTimes(e){this.times=e}getTimes(){return this.times}clear(){this.ids=[],this.viewer.getViewer().clearBlinkComponentsByDetail(this.uuid)}enable(e){this._isEnable=e,this.update()}update(){let e=this.viewer.getViewer();if(!1===this._isEnable)return void e.clearBlinkComponentsByDetail(this.uuid);e.clearBlinkComponentsByDetail(this.uuid);const t=this.ids,i=this._getModelIdAndObjectIds(t),n={interval:this.interval,times:this.times,color:this.color};for(const t in i)e.addBlinkComponentsByDetail(i[t],t,n,this.uuid);this.viewer.render()}_getModelIdAndObjectIds(e){let t={},i=(e,i)=>{void 0!==t[e]?t[e].push(i):t[e]=[i]};const n=e.length;for(let t=0;t<n;t++){const n=e[t];let o=n.modelId;const s=n.layerId;let r=n.objectIds;if(o){r.map((e=>{i(o,e)}));continue}if(s){const e=this.viewer.getLayerManager().getLayer(s);o=e.getModelId(),r.map((e=>{i(o,e)}));continue}if(!r)return;const a=r.length,l=this.viewer.getViewer().modelManager.modelCollection,h=l.getById("ExtrudeBodyManager"),d=l.getById("ExternalComponent");for(let e=0;e<a;e++){const t=r[e];h&&h._hasObjectId(t)?i(CLOUD.ObjectGroupType.EXTRUDEBODYMANAGER,t):d&&d._hasObjectId(t)&&i("ExternalComponent",t)}}return t}}n.ReferenceCount=0,n.AddReferenceCount=function(e){if(0===n.ReferenceCount){let t=e.getViewer();t.clearAllBlinkComponents(),t.enableBlinkComponents(!0)}n.ReferenceCount++},n.SubtractReferenceCount=function(e){if(n.ReferenceCount--,0===n.ReferenceCount){let t=e.getViewer();t.clearAllBlinkComponents(),t.enableBlinkComponents(!1)}},i.BlinkEffect=n}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");t.TerrainClippingConfig=class{constructor(){this.boundary=null,console.warn("[BIMFACE WARN]: Class Glodon.Bimface.Plugins.Clipping.TerrainClipping is obsolete, please use Class Glodon.Bimface.Plugins.Clipping.Clipping instead.")}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");i.TerrainClipping=class{constructor(i){t.send("Bimface.Plugins.Clipping.TerrainClipping","bf_c_terrainClipping_new"),console.warn("[BIMFACE WARN]: Class Glodon.Bimface.Plugins.Clipping.TerrainClipping is obsolete, please use Class Glodon.Bimface.Plugins.Clipping.Clipping instead."),this._boundary=i.boundary,this._id=e.Web.Lang.Utility.UUID.createUUID(),this._clippingManager=null,P(this)}getId(){return this._id}show(){this._clippingManager&&this._clippingManager.showItems([this.getId()])}hide(){this._clippingManager&&this._clippingManager.hideItems([this.getId()])}getBoundary(){return this._boundary}setBoundary(e){this._boundary=e,this._clippingManager&&(this._clippingManager.removeItems([this.getId()]),this._clippingManager.addItem(this))}_onAdded(e){this._clippingManager=e}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");t.ClippingManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");i.ClippingManager=class{constructor(i){t.send("Bimface.Plugins.Clipping.ClippingManager","bf_c_clippingMng_new"),this._viewer=i.viewer,this.clippingItemMap=new Map,!this._viewer||"Viewer3D"===!this._viewer.viewerType||!this._viewer instanceof e.Bimface.Viewer.ViewerGIS?console.log("ERROR::viewer must be viewer3D or viewerGIS."):P(this)}addItem(e){if(!e)return;const t=e.getBoundary();if(!t)return void console.log("ERROR::clippingItem must contains boundary.");const i=this._viewer.getViewer();if(!i||!i.holesManager)return;let n=new Array(t.length);for(let e=0;e<t.length;++e){const i=this._viewer.viewerAdapter.worldToDrawing(t[e]);n[e]=i}let o={};if("ViewerGIS"===this._viewer.getViewerType()){let t=[],i=e.getLayerIds();if(i=[...new Set(i)],void 0===i||0===i.length)throw console.log("ERROR::clippingItem must contains layerIds."),new Error("ERROR::clippingItem must contains layerIds.");i.map((e=>{const i=this._viewer.getLayerManager().getLayer(e);if(!i||"TileLayer"!==i.typeName&&"TilesetLayer"!==i.typeName)console.warn(`The LayerId ${e} is invalid`);else{const e=i.getModelId(),n=i._imageryId,o=i.id;t.push({pModelId:e,pImageryId:n,pLayerId:o})}})),t.forEach((e=>{const{pModelId:t,pImageryId:i,pLayerId:n}=e;o[t]||(o[t]=[]),o[t].push({pImageryId:i,pLayerId:n})}))}else e.layerIds=void 0,o[CLOUD.ObjectGroupType.TILEGROUP]=[];const s={points:n,modelIds:o};i.holesManager.addHole(e.getId(),s),this.clippingItemMap.set(e.getId(),e),e._onAdded(this)}removeItems(e,t){if(!e)return;const i=this._viewer.getViewer();i&&i.holesManager&&(i.holesManager.removeHoleByIds(e),e.map((e=>{const i=this.clippingItemMap.get(e);i&&t&&i.destroy()})),i.render())}clear(e){const t=this._viewer.getViewer(),i=Array.from(this.clippingItemMap.keys());t.holesManager.removeHoleByIds(i);for(const t of this.clippingItemMap.values())e&&t.destroy();this.clippingItemMap.clear(),t.render()}showItems(e){if(!e)return;var t=this._viewer.getViewer();if(!t||!t.holesManager)return;"ViewerGIS"===this._viewer.getViewerType()?e.forEach((e=>{let t=this.clippingItemMap.get(e);t&&this._showHideItem(e,t.layerIds,!0)})):t.holesManager.showHoleByIds(e),t.render()}_showHideClipping(e){const t=this._viewer.getViewer();let i=[];e.layerIds.map((e=>{const t=this._viewer.getLayerManager().getLayer(e);if(t&&("TileLayer"===t.typeName||"TilesetLayer"===t.typeName)){const e=t.getModelId(),n=t._imageryId,o=t.id;i.push({pModelId:e,pImageryId:n,pLayerId:o})}})),t.holesManager.showHideLayerByLayerIds(e.getId(),i)}_showHideItem(e,t,i){if(!t)return;const n=this._viewer.getViewer();n&&n.holesManager&&(i?n.holesManager.showHoleByIdAndLayerIds(e,t):n.holesManager.hideHoleByIdAndLayerIds(e,t),n.render())}showAll(){const e=Array.from(this.clippingItemMap.keys());this.showItems(e)}hideItems(e){if(!e)return;const t=this._viewer.getViewer();if(!t||!t.holesManager)return;"ViewerGIS"===this._viewer.getViewerType()?e.forEach((e=>{let t=this.clippingItemMap.get(e);t&&this._showHideItem(e,t.layerIds,!1)})):t.holesManager.hideHoleByIds(e),t.render()}hideAll(){const e=Array.from(this.clippingItemMap.keys());this.hideItems(e)}update(){}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");t.ClippingConfig=class{constructor(){this.boundary=null,this.layerIds=void 0}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Clipping");i.Clipping=class{constructor(i){t.send("Bimface.Plugins.Clipping.Clipping","bf_c_clipping_new"),this.boundary=i.boundary,this.layerIds=i.layerIds,this.id=e.Web.Lang.Utility.UUID.createUUID(),P(this)}destroy(){this.boundary=null,this.layerIds=null,this.id=void 0}show(){this._clippingManager&&this.layerIds&&this.layerIds.length>0&&this._clippingManager._showHideItem(this.getId(),this.layerIds,!0),void 0===this.layerIds&&this._clippingManager&&this._clippingManager.showItems([this.getId()])}hide(){this._clippingManager&&this.layerIds&&this.layerIds.length>0&&this._clippingManager._showHideItem(this.getId(),this.layerIds,!1),void 0===this.layerIds&&this._clippingManager&&this._clippingManager.hideItems([this.getId()])}getId(){return this.id}getLayerIds(){if(this._clippingManager){"ViewerGIS"===this._clippingManager._viewer.getViewerType()||(this.layerIds=void 0)}return this.layerIds}setLayerIds(e){if(void 0===e)return;let t=this.layerIds;if(this.layerIds=e,this._clippingManager){if(!("ViewerGIS"===this._clippingManager._viewer.getViewerType()))return;if(0===e.length)throw this.layerIds=t,console.log("ERROR::clippingItem must contains layerIds."),new Error("ERROR::clippingItem must contains layerIds.");let i=this._clippingManager._viewer.getLayerManager(),n=[];for(let t=0;t<e.length;t++){let o=e[t],s=!1;for(let e=0;e<i.getRootLayer().children.length;e++){if("GroupLayer"==i.getRootLayer().children[e].typeName){for(let t=0;t<i.getRootLayer().children[e].children.length;t++)if(i.getRootLayer().children[e].children[t].id==o&&("TileLayer"==i.getRootLayer().children[e].children[t].typeName||"TilesetLayer"==i.getRootLayer().children[e].children[t].typeName)){s=!0;break}if(s)break}if(!s&&("TileLayer"==i.getRootLayer().children[e].typeName||"TilesetLayer"==i.getRootLayer().children[e].typeName)&&i.getRootLayer().children[e].id==o){s=!0;break}}s?n.push(o):console.warn(`The LayerId ${o} is invalid`)}n.length>0?(n=[...new Set(n)],this.layerIds=n,this._clippingManager._showHideClipping(this)):this.layerIds=t}}getBoundary(){return this.boundary}setBoundary(e){void 0!==e&&(this.boundary=e,this._clippingManager&&(this._clippingManager.removeItems([this.getId()]),this._clippingManager.addItem(this)))}zoomToBoundingBox(e,t,i=null){let n=i||this.boundary,o=n[0].x,s=n[0].y,r=n[0].z,a=n[0].x,l=n[0].y,h=n[0].z;n.map((e=>{o=Math.max(o,e.x),s=Math.max(s,e.y),r=Math.max(r,e.z),a=Math.min(a,e.x),l=Math.min(l,e.y),h=Math.min(h,e.z)}));let d=new THREE.Box3(new THREE.Vector3(a,l,h),new THREE.Vector3(o,s,r));e.zoomToBoundingBox({boundingBox:d},t)}_onAdded(e){this._clippingManager=e}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Flats");t.FlatConfig=class{constructor(){this.boundary=null,this.elevation=0,this.layerIds=[]}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Flats");i.Flat=class{constructor(i){t.send("Bimface.Plugins.Flats.Flat","bf_c_flat_new"),this.boundary=i.boundary,this.elevation=i.elevation,this._elevation=null,this.viewer=null,this.layerIds=i.layerIds,i.layerId&&(this.layerIds=[i.layerId]),this.id=e.Web.Lang.Utility.UUID.createUUID(),this.needsUpdate=!0,this.visible=!0,P(this)}initViewer(e){this.viewer||(this.viewer=e,this.viewerType=this.viewer.getViewerType())}destroy(e,t){e.terrainOperationManager&&e.terrainOperationManager.removeFlattenRegionsById([this.id]),t&&(this.boundary=null,this.elevation=void 0,this.layerIds=void 0,this.id=void 0,this.needsUpdate=void 0,this.visible=void 0)}setElevation(e){this.elevation=e,this.enableUpdate(!0)}getElevation(){return this.elevation}getId(){return this.id}getLayerId(){return this.layerIds[0]}setLayerId(e){this.setLayerIds([e])}getLayerIds(){return this.layerIds}setLayerIds(e){this.layerIds=e,this.enableUpdate(!0)}getBoundary(){return this.boundary}setBoundary(e){this.boundary=e,this.enableUpdate(!0)}enableUpdate(e){this.needsUpdate=e}setVisible(e){this.visible=e,this.needsUpdate=!0}draw(e,t){if(!this.needsUpdate)return;if(!0!==this.visible)return void e.terrainOperationManager.removeFlattenRegionsById([this.id]);let i=this.getElevation(),n=this.viewer&&"Viewer3D"==this.viewerType;n&&(i=this.viewer.globalUnitUtil.excute(i,this.viewer.globalUnitUtil.getGlobalUnit(),"m"));const o=this.getBoundary();let s=new Array(o.length);for(let t=0;t<o.length;++t){const i=n?this.viewer.viewerAdapter.worldToDrawing(o[t]):e.worldToDrawing(o[t]);s[t]=i}e.terrainOperationManager.removeFlattenRegionsById([this.id]),e.terrainOperationManager.addFlattenRegion(this.id,s,i,t),this.enableUpdate(!1)}zoomToBoundingBox(e){let t=this.boundary[0].x,i=this.boundary[0].y,n=this.boundary[0].z,o=this.boundary[0].x,s=this.boundary[0].y,r=this.boundary[0].z;this.boundary.map((e=>{t=Math.max(t,e.x),i=Math.max(i,e.y),n=Math.max(n,e.z),o=Math.min(o,e.x),s=Math.min(s,e.y),r=Math.min(r,e.z)})),n=Math.max(n,this.elevation),r=Math.min(r,this.elevation);let a=new THREE.Box3(new THREE.Vector3(o,s,r),new THREE.Vector3(t,i,n));this.viewer?this.viewer.zoomToBoundingBox({boundingBox:a}):e.zoomToBoundingBox({boundingBox:a})}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Flats");t.FlatManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Plugins.Flats");i.FlatManager=class{constructor(e){t.send("Bimface.Plugins.Flats.FlatManager","bf_c_flatMng_new"),this.viewer=e.viewer,this.items={},P(this)}addItem(e){e.initViewer(this.viewer);const t=e.getId();void 0!==t&&(this.items[t]=e,e.enableUpdate(!0),this.update())}removeItems(e,t){e.map((e=>{if(!this.items[e])return;this.items[e].destroy(this.viewer.getViewer(),t),delete this.items[e]})),this.update()}clear(e){for(const t in this.items){this.items[t].destroy(this.viewer.getViewer(),e)}this.items={},this.update()}showItems(e){e.map((e=>{if(!this.items[e])return;this.items[e].setVisible(!0)})),this.update()}showAll(){for(const e in this.items){this.items[e].setVisible(!0)}this.update()}hideItems(e){e.map((e=>{if(!this.items[e])return;this.items[e].setVisible(!1)})),this.update()}hideAll(){for(const e in this.items){this.items[e].setVisible(!1)}this.update()}update(){const e=this.viewer.getViewer(),t="ViewerGIS"===this.viewer.getViewerType();if(e.terrainOperationManager){for(const i in this.items){const n=this.items[i],o=n.getLayerIds();let s=[];if(t?o.map((e=>{const t=this.viewer.getLayerManager().getLayer(e);if(!t||"TileLayer"!==t.typeName&&"TilesetLayer"!==t.typeName)t&&"TerrainLayer"===t.typeName?s.push(CLOUD.ObjectGroupType.TILEGROUP):console.warn(`The LayerId ${e} is invalid`);else{const e=t.getModelId().toString();s.push(e)}})):s.push(CLOUD.ObjectGroupType.TILEGROUP),0===s.length)return void console.warn("The LayerIds is invalid");n.draw(e,s)}e.render()}}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Viewshed").Viewshed3DConfig=class{constructor(){this.position={x:0,y:0,z:0},this.direction={x:0,y:0,z:-1},this.visibleAreaColor=new e.Web.Graphics.Color(0,255,0,.8),this.hiddenAreaColor=new e.Web.Graphics.Color(255,0,0,.8),this.distance=1e3,this.horizontalFov=Math.PI/2,this.verticalFov=Math.PI/3,this.translucenceAvailable=!1,this.frustumVisible=!0}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Viewshed");t.Viewshed3D=class{constructor(e){this._cfg=e,this._viewer=void 0,this._viewer3D=void 0,this._viewshed=void 0,this._scratchVisibleColor=void 0,this._scratchHiddenColor=void 0,this._scratchDirection=void 0,P(this)}_init(t,i){if(this._viewer=t,this._viewer3D=i,!this._viewshed){var n=this._viewer3D.viewerAdapter.worldToDrawing(this._cfg.direction);n.normalize(),this._viewshed=new CLOUD.Viewshed({position:this._viewer3D.viewerAdapter.worldToDrawing(this._cfg.position),direction:n,visibleAreaColor:this._cfg.visibleAreaColor,hiddenAreaColor:this._cfg.hiddenAreaColor,translucenceAvailable:this._cfg.translucenceAvailable,distance:this._viewer3D.viewerAdapter.worldToDrawing({x:this._cfg.distance,y:0,z:0}).x,horizontalFov:this._cfg.horizontalFov,verticalFov:this._cfg.verticalFov,frustumVisible:!1!==this._cfg.frustumVisible}),this._scratchVisibleColor=new e.Web.Graphics.Color(this._cfg.visibleAreaColor.red,this._cfg.visibleAreaColor.green,this._cfg.visibleAreaColor.blue,this._cfg.visibleAreaColor.alpha),this._scratchHiddenColor=new e.Web.Graphics.Color(this._cfg.hiddenAreaColor.red,this._cfg.hiddenAreaColor.green,this._cfg.hiddenAreaColor.blue,this._cfg.hiddenAreaColor.alpha),this._scratchDirection=this._cfg.direction}}getId(){return this._viewshed.getId()}getPositon(){var e=this._viewshed.getPositon();return this._viewer3D.viewerAdapter.drawingToWorld(e)}setPosition(e){var t=this._viewer3D.viewerAdapter.worldToDrawing(e);this._viewshed.setPosition(t)}getDirection(){var e=this._viewer3D.viewerAdapter.drawingToWorld(this._viewshed.getDirection());return e.normalize(),this._scratchDirection.x=e.x,this._scratchDirection.y=e.y,this._scratchDirection.z=e.z,this._scratchDirection}setDirection(e){var t=this._viewer3D.viewerAdapter.worldToDrawing(e);t.normalize(),this._viewshed.setDirection(t)}getVisibleAreaColor(){var e=this._viewshed.getVisibleAreaColor();return this._scratchVisibleColor.red=e.x,this._scratchVisibleColor.green=e.y,this._scratchVisibleColor.blue=e.z,this._scratchVisibleColor.alpha=e.w,this._scratchVisibleColor}setVisibleAreaColor(e){this._viewshed.setVisibleAreaColor(e)}getHiddenAreaColor(){var e=this._viewshed.getHiddenAreaColor();return this._scratchHiddenColor.red=e.x,this._scratchHiddenColor.green=e.y,this._scratchHiddenColor.blue=e.z,this._scratchHiddenColor.alpha=e.w,this._scratchHiddenColor}setHiddenAreaColor(e){this._viewshed.setHiddenAreaColor(e)}getDistance(){var e=this._viewshed.getDistance();return this._viewer3D.viewerAdapter.drawingToWorld({x:e,y:0,z:0}).x}setDistance(e){var t=this._viewer3D.viewerAdapter.worldToDrawing({x:e,y:0,z:0}).x;this._viewshed.setDistance(t)}getHorizontalFov(){return this._viewshed.getHorizontalFov()}setHorizontalFov(e){this._viewshed.setHorizontalFov(e)}getVerticalFov(){return this._viewshed.getVerticalFov()}setVerticalFov(e){this._viewshed.setVerticalFov(e)}setTranslucenceAvailable(e){this._viewshed.setTranslucenceAvailable(e)}hide(){this._viewshed.hide()}show(){this._viewshed.show()}setFrustumVisible(e){this._viewshed.setFrustumVisible(e),this._viewer.render()}isFrustumVisible(){return this._viewshed.isFrustumVisible()}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Viewshed");t.ViewshedManagerConfig=class{constructor(){this.viewer=void 0}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Viewshed");t.ViewshedManager=class{constructor(e){this._viewer3D=e.viewer,this._viewer=e.viewer.getViewer(),this._viewsheds=[],P(this)}addViewshed(e){e._init(this._viewer,this._viewer3D),this._viewsheds.push(e),this._viewer.viewshedManager.addViewshed(e._viewshed)}addViewsheds(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.addViewshed(e[t]);else console.warn("WARNING: Glodon.Bimface.Analysis.Viewshed.ViewshedManager.addViewsheds() need array")}getViewshedById(e){for(var t=0;t<this._viewsheds.length;t++)if(this._viewsheds[t].getId()==e)return this._viewsheds[t]}getViewsheds(){return[...this._viewsheds]}hideById(e){this._viewer.viewshedManager.hideById(e)}showById(e){this._viewer.viewshedManager.showById(e)}removeById(e){for(var t=0;t<this._viewsheds.length;t++)if(this._viewsheds[t].getId()==e){this._viewsheds.splice(t,1);break}this._viewer.viewshedManager.removeById(e)}clear(){this._viewsheds=[],this._viewer.viewshedManager.clear()}update(){this._viewer.viewshedManager.update()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.HeightLimit").HeightLimitAnalysisConfig=class{constructor(){this.color=new e.Web.Graphics.Color(50,211,166,1),this.height=null,this.mode="global",this.layerIds=null,this.area=null,this.viewer=null}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.HeightLimit"),i=e.Bimface.Data.StatisticsDataManager.getInstance();t.HeightLimitAnalysis=class{constructor(t){i.send("Glodon.Bimface.Analysis.HeightLimit.HeightLimitAnalysis","bf_c_heightLimit_new"),this.color=t.color,this.mode=t.mode,this.layerIds=t.layerIds,this.area=t.area,this.viewer=t.viewer,this.id=e.Web.Lang.Utility.UUID.createUUID(),P(this),this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(null==t.height?this.height="Viewer3D"===this.viewer.viewerType?24e3:24:this.setHeight(t.height),this._drawingHeight=this.viewer.viewerAdapter.worldToDrawing({x:0,y:0,z:this.height}).y,this._updateModelIds(),this._createAreaMesh(),this.manager=this.viewer.getViewer().getHeightLimitManager(),"invalidPlane"!=this.areaMesh.type?(this.manager.addLimitAnalysis(this.id,this),this._needCreateMesh=!1):console.log("ERROR::invalid area input")):console.log("ERROR::viewer must not be empty or viewer2d.")}_getBox(){return this.box||this._updateBox(),this.box}_updateBox(){var e=new THREE.Box3;if(!this.areaMesh)return e;e.setFromObject(this.areaMesh),this.box=e}_createAreaMesh(){let t;if("global"==this.mode)t={type:"rectangle",points:[(i=this.viewer.getViewer().getBoundingBoxWorld()).min,i.max],onlyPlane:!0};else if(this.area)t=this.area,t=this.viewer.globalUnitUtil.translate(t,["x","y","z","radius"]),t.onlyPlane=!0;else if(this.layerIds){for(var i=new THREE.Box3,n=0;n<this.layerIds.length;n++){var o=viewer.getLayerManager().getLayer(this.layerIds[n]);i.union(o.getBoundingBox())}t={type:"rectangle",points:[i.min,i.max],onlyPlane:!0}}else{t={type:"rectangle",points:[(i=this.viewer.getViewer().getBoundingBoxWorld()).min,i.max],onlyPlane:!0}}this.areaMesh=new e.Bimface.Plugins.Geometry.Plane(t),this.areaMesh.setColor(this.color),this.areaMesh.clearBorder(),this.areaMesh.name=this.id}clearArea(){this.setArea(null)}clearLayers(){this.setLayerIds(null)}destroy(){this.manager.removeLimitAnalysisById(this.id),this.areaMesh=null,this.area=null,this.layerIds=null}setColor(t){t instanceof e.Web.Graphics.Color?this.color=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}getColor(){return this.color}setHeight(e){this.height!=e&&(this.height=0==e?1e-5:e)}getHeight(){return this.height}setMode(e){"global"==e||"customized"==e?this.mode!=e&&(this.mode=e,this._needCreateMesh=!0):console.log("ERROR::mode should be instance of String and be 'global' or 'customized")}getMode(){return this.mode}setLayerIds(e){e instanceof Array||!e?(this.layerIds=e,this._needCreateMesh=!0):console.log("ERROR::ids should be instance of Array")}getLayerIds(){return this.layerIds}setArea(e){this.area!=e&&(this._needCreateMesh=!0,this.area=e)}getArea(){return this.area}hide(){this.areaMesh&&(this.areaMesh.visible=!1)}show(){this.areaMesh&&(this.areaMesh.visible=!0)}update(){if(this._needCreateMesh&&(this._createAreaMesh(),"invalidPlane"==this.areaMesh.type))return this._needCreateMesh=!1,void console.log("ERROR::invalid area input");this.areaMesh&&this.areaMesh.setColor(this.color),this._updateModelIds(),this._drawingHeight=this.viewer.viewerAdapter.worldToDrawing({x:0,y:0,z:this.height}).y,this.manager.update(this.id,this._needCreateMesh),this._needCreateMesh=!1}_updateModelIds(){if("global"!=this.mode&&this.layerIds){if(this.layerIds){this._modelIds=[];for(var e=0;e<this.layerIds.length;e++){var t=viewer.getLayerManager().getLayer(this.layerIds[e]);this._modelIds.push(t.getModelId())}}}else this._modelIds=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.CutFill");t.CutFillAnalysisConfig=class{constructor(){this.boundary=[],this.level=0,this.viewer=null,this.layerIds=[]}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.CutFill");i.CutFillAnalysis=class{constructor(i){t.send("Bimface.Analysis.CutFillAnalysis.CutFill","bf_c_cutfFill_new");let n=this;if(P(this),i)if(i.viewer){if("Viewer3D"===i.viewer.viewerType);else if(!(i.viewer instanceof e.Bimface.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");if(i.boundary&&!(i.boundary.length<=2)){n.boundary=[i.boundary[0]];for(let e=1;e<i.boundary.length;e++)i.boundary[e].x==i.boundary[e-1].x&&i.boundary[e].y==i.boundary[e-1].y||n.boundary.push(i.boundary[e]);n.boundary.length<=2||(n.level=i.level,n.viewer=i.viewer,n.engineViewer=n.viewer.getViewer(),n.setLayerIds(i.layerIds),n._updateParameter(),n.cutFillAnalysis=new CLOUD.CutFillMeasure({showVisualization:!0,level:n.level,boundary:n._boundary,viewer:n.viewer,layerIds:n.layerIds}),n._addSence())}}else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::cutFillAnalysisConfig must not be empty.")}_updateParameter(){let e=this;e._boundary=[],e.boundary.forEach((t=>{e._boundary.push(e.viewer.viewerAdapter.worldToDrawing(t))}))}_addSence(){var t=this;t.extObjMng=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(t.viewer),t.objectTpye="cutFill-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.cutFillAnalysis._externalNeedScale=!1,t.extObjMngId=t.extObjMng._addObject(t.objectTpye+t.id,t.cutFillAnalysis)}destroy(){var e=this;null!=e.extObjMngId&&e.extObjMng.removeById(e.extObjMngId),e.cutFillAnalysis.destroy(),e.cutFillAnalysis=null,e._boundary=null}update(){var e=this;e._updateParameter(),e.cutFillAnalysis.effectOpt({level:e.level,boundary:e._boundary,layerIds:e.layerIds}),e.viewer.render()}getLayerIds(){let e=this;return e.layerIds?e.layerIds:e.viewer.getLayerManager().terrainLayer&&e.viewer.getLayerManager().terrainLayer.id}setLayerIds(e){let t=this;if("Viewer3D"===t.viewer.viewerType)return void(t.layerIds=void 0);const i=t.viewer.getLayerManager().terrainLayer&&t.viewer.getLayerManager().terrainLayer.id;null!=e&&e instanceof Array&&0!=e.length?(t.layerIds=e,-1!=t.layerIds.indexOf(i)&&(t.layerIds=void 0)):t.layerIds=void 0}hide(){this.cutFillAnalysis.hide(),this.viewer.render()}show(){this.cutFillAnalysis.show(),this.viewer.render()}getTotalArea(){return null==this.cutFillAnalysis?0:this.cutFillAnalysis.getTotalArea()}getCutArea(){return null==this.cutFillAnalysis?0:this.cutFillAnalysis.getCutArea()}getCutVolume(){return null==this.cutFillAnalysis?0:this.cutFillAnalysis.getCutVolume()}getFillArea(){return null==this.cutFillAnalysis?0:this.cutFillAnalysis.getFillArea()}getFillVolume(){return null==this.cutFillAnalysis?0:this.cutFillAnalysis.getFillVolume()}getBoundary(){return this.boundary}getLevel(){return this.level}setBoundary(e){this.boundary=e}setLevel(e){this.level!=e&&(this.level=e)}calculateAccurateResult(e){this.cutFillAnalysis.updateCutFillVolumeData(e)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Sightline");t.SightlineAnalysisConfig=class{constructor(){this.invisibleColor=new e.Web.Graphics.Color(235,0,29,1),this.targetPoints=null,this.viewPoint=null,this.visibleColor=new e.Web.Graphics.Color(50,211,166,1),this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Sightline"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");i.SightlineAnalysis=class{constructor(i){t.send("Bimface.Analysis.Sightline.SightlineAnalysis","bf_c_sightline_new"),this.invisibleColor=i.invisibleColor||new e.Web.Graphics.Color(235,0,29,1),this.targetPoints=i.targetPoints||[],this.viewPoint=i.viewPoint,this.visibleColor=i.visibleColor||new e.Web.Graphics.Color(50,211,166,1),this.viewer=i.viewer,this.obstaclePoints=[],P(this),this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(this._svg=null,this._viewPointDom=null,this._sightlines=[],this._show=!0,this._init()):console.log("ERROR::viewer must not be empty or viewer2d.")}destroy(){this.viewPoint=null,this.targetPoints=[],this.obstaclePoints=[],this._sightlines=[],this.renderCallback&&this.viewer.getViewer().removeRenderCallback(this.renderCallback),this.viewer.getDomElement().removeChild(this._svg)}getInvisibleColor(){return this.invisibleColor}getTargetPoints(){return[...this.targetPoints]}getViewPoint(){return this.viewPoint}getVisibleColor(){return this.visibleColor}getObstaclePoints(){return[...this.obstaclePoints]}setInvisibleColor(t){t instanceof e.Web.Graphics.Color?this.invisibleColor=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),this.update()}setTargetPoints(e){e instanceof Array?this.targetPoints=e:console.log("ERROR::targetPoints should be instance of Array"),this.update()}setViewPoint(e){this.viewPoint=e,this.update()}setVisibleColor(t){t instanceof e.Web.Graphics.Color?this.visibleColor=t:console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color"),this.update()}hide(){this._svg.style.display="none",this._show=!1}show(){this._svg.style.display="block",this._show=!0}update(){if(this.obstaclePoints=[],this._sightlines=[],this.viewPoint&&this.targetPoints&&0!=this.targetPoints.length){this._viewPointDom&&this._viewPointDom.setAttribute("fill",`#${this.visibleColor.getHEX()}`);var e=this.viewer.getViewer().cameraControl,t=e.getIntersectContext(),i=new THREE.Vector3(this.viewPoint.x,this.viewPoint.y,this.viewPoint.z),o=this.viewer.viewerAdapter.worldToDrawing(i);if(!this.viewer.getViewer().clipPoint(o)){for(var s=0;s<this.targetPoints.length;s++){var r=this.targetPoints[s],a=this.viewer.viewerAdapter.worldToDrawing(r);if(this.viewer.getViewer().clipPoint(a))continue;var l=a.clone();l.sub(o),l.normalize();const i=new CLOUD.Raycaster(o,l);const p=e.intersector.getObjectsByRaycaster(t,i,!1)[0];var h={};h.target=r;var d=n.createNS("circle","bf-sightline-targetpoint");d.setAttribute("stroke-width",0),d.setAttribute("r",4),d.setAttribute("fill",`#${this.visibleColor.getHEX()}`),h.targetDom=d;var c=n.createNS("line","bf-sightline-line");if(c.style.strokeWidth=2,c.style.stroke=`#${this.visibleColor.getHEX()}`,h.line1Dom=c,p&&p.point.distanceTo(a)>CLOUD.Math.EPSILON3&&o.distanceTo(p.point)<o.distanceTo(a)){var u=this.viewer.viewerAdapter.drawingToWorld(p.point);this.obstaclePoints.push(u),d.setAttribute("fill",`#${this.invisibleColor.getHEX()}`),h.obstacle=u;var g=n.createNS("line","bf-sightline-line");g.style.strokeWidth=2,g.style.stroke=`#${this.invisibleColor.getHEX()}`,h.line2Dom=g}this._sightlines.push(h)}this.viewer.render()}}}_init(){this._svg=n.createNS("svg","bf-sightline-svg"),this._svg.style="width: 100%;height: 100%;position: absolute;left: 0;top: 0;",(i=n.createNS("circle","bf-sightline-viewpoint")).setAttribute("stroke-width",0),i.setAttribute("r",5),i.setAttribute("stroke","#FFFFFF"),i.setAttribute("stroke-width",2),i.setAttribute("fill",`#${this.visibleColor.getHEX()}`),this._viewPointDom=i;var e=this.viewer.getDomElement();e.appendChild(this._svg);var t=this._svg,i=this._viewPointDom;this.renderCallback=()=>{if(t.innerHTML="",this._show&&this.viewPoint&&this.targetPoints&&0!=this.targetPoints.length&&0!=this._sightlines.length)for(var n=this.viewer.viewerAdapter,o=e.getBoundingClientRect(),s=0;s<this._sightlines.length;s++){var r,a,l=this._sightlines[s],h=l.line1Dom,d=l.line2Dom;if(l.obstacle){if((r=n.worldPointsToClient(this.viewPoint,l.obstacle))&&(i.setAttribute("cx",r.start.x-o.left),i.setAttribute("cy",r.start.y-o.top),t.appendChild(i),h.setAttribute("x1",r.start.x-o.left),h.setAttribute("y1",r.start.y-o.top),h.setAttribute("x2",r.end.x-o.left),h.setAttribute("y2",r.end.y-o.top),t.appendChild(h)),r=n.worldPointsToClient(l.obstacle,l.target))d.setAttribute("x1",r.start.x-o.left),d.setAttribute("y1",r.start.y-o.top),d.setAttribute("x2",r.end.x-o.left),d.setAttribute("y2",r.end.y-o.top),t.appendChild(d),(a=l.targetDom).setAttribute("cx",r.end.x-o.left),a.setAttribute("cy",r.end.y-o.top),t.appendChild(a)}else if(r=n.worldPointsToClient(this.viewPoint,l.target))i.setAttribute("cx",r.start.x-o.left),i.setAttribute("cy",r.start.y-o.top),t.appendChild(i),h.setAttribute("x1",r.start.x-o.left),h.setAttribute("y1",r.start.y-o.top),h.setAttribute("x2",r.end.x-o.left),h.setAttribute("y2",r.end.y-o.top),(a=l.targetDom).setAttribute("cx",r.end.x-o.left),a.setAttribute("cy",r.end.y-o.top),t.appendChild(a),t.appendChild(h)}},this.update(),this.viewer.getViewer().addRenderCallback(this.renderCallback)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Skyline");t.SkylineAnalysisConfig=class{constructor(){this.style={color:new e.Web.Graphics.Color(255,0,0,1),width:1},this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Analysis.Skyline");i.SkylineAnalysis=class{constructor(i){t.send("Bimface.Analysis.Skyline.SkylineAnalysis","bf_c_skyline_new"),this.viewer=i.viewer,this.skylineStyle=i.style,P(this),this.viewer&&("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS)?(this.setStyle(this.skylineStyle),this.show()):console.log("ERROR::viewer must not be empty or viewer2d.")}getStyle(){return this.skylineStyle}setStyle(t){if(t){this.skylineStyle.color=t.color||new e.Web.Graphics.Color(255,0,0,1),this.skylineStyle.width=t.width||1;var i=this.viewer.getViewer(),n={};n.skylineColor=new THREE.Color(t.color.red/255,t.color.green/255,t.color.blue/255),n.skylineWidth=t.width,i.skylineOpt(n)}}getSkyline3D(){var e,t=(n=this.viewer.getViewer()).getSkyline3D(),i={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},n=this.viewer.getViewer();if("Viewer3D"===this.viewer.viewerType){for(var o=0;o<t.length;o++){var s=this.viewer.viewerAdapter.drawingToWorld(t[o]);i.geometry.coordinates.push([parseFloat(s.x.toFixed(4)),parseFloat(s.y.toFixed(4)),parseFloat(s.z.toFixed(4))])}return i}if(n.modelManager.modelCollection.traverse((t=>{t.isDemLayer&&(e=t.tileManager)})),e)for(o=0;o<t.length;o++){s=this.viewer.viewerAdapter.drawingToWorld(t[o]);var r=e.mercator2lonLat(s);i.geometry.coordinates.push([r.x,r.y])}return i}getStatus(){var t={};t.cameraStatus=this.viewer.getCameraStatus();var i=this.skylineStyle;return t.skylineStyle={},t.skylineStyle.color=new e.Web.Graphics.Color(i.color.red,i.color.green,i.color.blue,i.color.alpha),t.skylineStyle.width=i.width,t}setStatus(e){e&&(this.viewer.setCameraStatus(e.cameraStatus),this.setStyle(e.skylineStyle),this.show())}hide(){y.GlobalData.EnableSkylinePass=!1,this._updateSkylineStatus(),this.update()}show(){y.GlobalData.EnableSkylinePass=!0,this._updateSkylineStatus(),this.update()}destroy(){this.hide()}update(){this.viewer.render(),this.setStyle(this.skylineStyle)}_updateSkylineStatus(){this.viewer.getViewer().updateDemMaterialsSide()}}}(),function(){var t="Bimface.Light.CSMLight",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");n.CSMLight=class{constructor(){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.cloudViewer=null,this.isEnabled=!1,this.lightDirection=new THREE.Vector3(1,0,0),P(this)}destroy(){this.isEnabled&&(this.isEnabled=!1,this.cloudViewer.enableShadow(!1),this.cloudViewer.setLightPreset(3),this.cloudViewer.getScene().lightManager.enableCSM(!1));this.cloudViewer=null,this.lightDirection=null}setLightPreset(e){let t=4;const i="ViewerGIS"===this.viewer.viewerType;this.cloudViewer.modelManager.isBimtilesAsset()||i||(t=e?6:3),this.cloudViewer.setLightPreset(t)}enableShadow(e){this.viewer&&"Viewer3D"==this.viewer.viewerType&&i.send(t,"bf_c_csmLight_enable"),this.viewer&&"Viewer3D"==this.viewer.viewerType&&1==e&&i.send(t,"bf_c_csmLight_enable_true"),this.isEnabled=e,this.cloudViewer.enableShadow(e),this.cloudViewer.getScene().lightManager.enableCSM(e),this.cloudViewer.updateShadowMap()}isShadowEnabled(){return this.isEnabled}setDirection(e){this.lightDirection=this.cloudViewer.worldToDrawing(e),this.lightDirection.normalize(),this.cloudViewer.getScene().sunDirection=this.lightDirection,this.cloudViewer.getScene().originSunDirection=this.lightDirection,this.cloudViewer.getScene().lightManager.updateShadowLight()}setDirectionByCondition(e,t){this.lightDirection=this.cloudViewer.calcShadowDirection([e.lon,e.lat],t),this.cloudViewer.getScene().sunDirection=this.lightDirection,this.cloudViewer.getScene().originSunDirection=this.lightDirection,this.cloudViewer.getScene().lightManager.updateShadowLight()}getDirection(){return this.lightDirection}getId(){return this.id}enableAvoidShadowPlaneCutting(e){const t=this.cloudViewer.getScene().lightManager.csm;t&&(t.enableAvoidShadowPlaneCutting=e)}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");i.FillLight=class{constructor(t){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.fillLight=t,P(this)}enableLight(e){t.send("Bimface.Light.FillLight","bf_c_fillLight_enable"),this.fillLight&&(this.fillLight.visible=e)}isEnabled(){if(this.fillLight)return this.fillLight.visible}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");t.SpotLightConfig=class{constructor(){this.id=e.Web.Lang.Utility.UUID.createUUID(),this.position={x:5e3,y:3e3,z:-600},this.target={x:0,y:0,z:0},this.distance=3e3,this.color=new e.Web.Graphics.Color("#FFFFFF",1),this.intensity=3,this.angle=Math.PI/3,this.penumbra=0,this.shadow=!1}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");i.SpotLight=class{constructor(e){t.send("Bimface.Light.SpotLight","bf_c_spotLight"),e?(this._spotLight=new THREE.SpotLight(16777215),this._spotLight.decay=1,this._intensityScale=1e3*Math.PI,this.setPosition(e.position),this.setTarget(e.target),this.setColor(e.color),this.setAngle(e.angle),this.setIntensity(e.intensity),this.setPenumbra(e.penumbra),this.bimColor=e.color,this.worldDistance=e.distance,this.id=e.id,this.enableShadow(e.shadow||!1),P(this)):console.log("ERROR::spotLightConfig must not be empty.")}_updateParams(e){this.viewer=e,this.setPosition(this._spotLight.position),this.setTarget(this._spotLight.target.position),this.setColor(this._spotLight.color),this.setAngle(this._spotLight.angle),this.setIntensity(this._spotLight.intensity/this._intensityScale),this.setPenumbra(this._spotLight.penumbra)}setPosition(e){if(this.viewer){let t=this.viewer.globalUnitUtil.translate(e,["x","y","z"]);this._spotLight.position.set(t.x,t.y,t.z)}else this._spotLight.position.set(e.x,e.y,e.z);this._spotLight.updateMatrixWorld(),this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap()}getPosition(){return this.viewer?this.viewer.globalUnitUtil.revertTranslate({x:this._spotLight.position.x,y:this._spotLight.position.y,z:this._spotLight.position.z},["x","y","z"]):{x:this._spotLight.position.x,y:this._spotLight.position.y,z:this._spotLight.position.z}}setTarget(e){if(this.viewer){let t=this.viewer.globalUnitUtil.translate(e,["x","y","z"]);this._spotLight.target.position.set(t.x,t.y,t.z)}else this._spotLight.target.position.set(e.x,e.y,e.z);this._spotLight.target.updateMatrixWorld(),this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap()}getTarget(){const e=this._spotLight.target.position;return this.viewer?this.viewer.globalUnitUtil.revertTranslate({x:e.x,y:e.y,z:e.z},["x","y","z"]):{x:e.x,y:e.y,z:e.z}}setIntensity(e){e<0||e>3?console.log("ERROR::intensity must be in a range of [0,3], please reset"):(this._spotLight.intensity=e*this._intensityScale,this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap())}getIntensity(){return this._spotLight.intensity/this._intensityScale}setAngle(e){e<0||e>Math.PI/2?console.log("ERROR::penumbra must be in a range of (0,Math.PI / 2), please reset"):(this._spotLight.angle=e,this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap())}getAngle(){return this._spotLight.angle}setDistance(e){this.worldDistance=e,this.updateRealDistance()}updateRealDistance(){if(this.lightManager){this.lightManager.viewer.getViewer();this._spotLight.distance=this.lightManager.viewer.viewerAdapter.worldToDrawing({x:this.worldDistance,y:0,z:0}).x,this._spotLight.castShadow&&this.lightManager.updateShadowMap()}}getDistance(){return this.worldDistance}setPenumbra(e){e<0||e>1?console.log("ERROR::penumbra must be in a range of [0,1], please reset"):(this._spotLight.penumbra=e,this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap())}getPenumbra(){return this._spotLight.penumbra}setColor(t){t instanceof e.Web.Graphics.Color?(this.bimColor=t,this._spotLight.color.setRGB(t.red/255,t.green/255,t.blue/255),this._spotLight.castShadow&&this.lightManager&&this.lightManager.updateShadowMap()):console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}getColor(){return this.bimColor}enableShadow(e){this._spotLight.castShadow!=e&&(this._spotLight.castShadow=e,this._spotLight.shadow.bias=-9e-5,this.lightManager&&this.lightManager.updateShadow())}hide(){this._spotLight.visible=!1}show(){this._spotLight.visible=!0}enableLight(e){this._spotLight.visible=e}isEnabled(){return this._spotLight.visible}getId(){return this.id}setShadowBias(e){this._spotLight.shadow.bias=e}getShadowBias(){return this._spotLight.shadow.bias}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");t.DirectionalLightConfig=class{constructor(){this.direction={x:.64,y:-.48,z:-.6},this.color=new e.Web.Graphics.Color(255,255,255,1),this.intensity=1,this.shadow=!1}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");i.DirectionalLight=class{constructor(i){(!i||!i.isInside)&&t.send("Bimface.Light.DirectionalLight","bf_c_directionalLight_new"),i?(this.id=e.Web.Lang.Utility.UUID.createUUID(),this._dirLight=i.dirLight?i.dirLight:new THREE.DirectionalLight(16777215,1),this.setIntensity(i.intensity),this.setColor(i.color),this.setDirection(i.direction),this.useShadow=i.shadow||!1,P(this)):console.log("ERROR::directionalLightConfig must not be empty.")}setDirection(e){this.direction=e,this.latLon=void 0,this.date=void 0,this.lightManager&&this.lightManager.updateLightDirection(this)}setDirectionByCondition(e,t){this.latLon=e,this.date=t,this.lightManager&&this.lightManager.updateLightDirection(this)}getDirection(){return this.direction}setColor(t){t instanceof e.Web.Graphics.Color?(this.color=t,this._dirLight.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255)):console.log("ERROR::color should be instance of Glodon.Web.Graphics.Color")}getColor(){return this.color}enableShadow(e){if(this.useShadow!=e){if(e)for(let e=0;e<this.lightManager.directionalLights.length;e++){let t=this.lightManager.directionalLights[e];if(t.useShadow)return void console.log(`[BIMFACE WARNING]:DirectionalLight("id":"${t.id}") shadow is already existed.`)}this.useShadow=e,this.lightManager&&this.lightManager.updateShadow()}}isShadowEnabled(){return this.useShadow}update(){this._dirLight.updateMatrixWorld()}setIntensity(e){this._dirLight.intensity=e}getIntensity(){return this._dirLight.intensity}enableLight(e){this._dirLight.visible=e}isEnabled(){return this._dirLight.visible}getId(){return this.id}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light");t.LightManagerConfig=class{constructor(){this.viewer=null}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Light").LightManager=class{constructor(t){if(!t)return void console.log("ERROR::lightManagerConfig must not be empty.");if(this.viewer=t.viewer,!this.viewer||!("Viewer3D"===this.viewer.viewerType||this.viewer instanceof e.Bimface.Viewer.ViewerGIS||this.viewer instanceof e.Bimface.Earth.Viewer.ViewerGIS))return void console.log("ERROR::viewer must not be empty or viewer2d.");var i=this.viewer.getViewer().getScene().lightManager;this.directionalLights=[],this.fillLights=[],this.spotLights=[],this.allLights=[],P(this),this.fillLights.push(new e.Bimface.Light.FillLight(i.dirLight)),this.fillLights.push(new e.Bimface.Light.FillLight(i.sunLight)),this.fillLights.push(new e.Bimface.Light.FillLight(i.fillLight01)),this.fillLights.push(new e.Bimface.Light.FillLight(i.fillLight02)),this.fillLights.push(new e.Bimface.Light.FillLight(i.fillLight03));const n=CLOUD.GlobalData.EnableCSM||CLOUD.GlobalData.EnableShadowMap||6==CLOUD.GlobalData.LightPreset;this.directionalLights.push(new e.Bimface.Light.DirectionalLight({direction:{x:-.2412572336270719,y:-.6729832229612023,z:.6856759814656318},color:new e.Web.Graphics.Color(255,255,255,1),intensity:.5,dirLight:i.light04,shadow:n,isInside:!0})),this.directionalLights[0].lightManager=this,this.updateLightDirection(this.directionalLights[0]),this.csmLight=new e.Bimface.Light.CSMLight,this.csmLight.viewer=this.viewer,this.csmLight.cloudViewer=this.viewer.getViewer(),this.allLights=this.allLights.concat(this.fillLights).concat(this.directionalLights).concat(this.spotLights).concat(this.csmLight),this.handle=()=>{this.updateShadowMap()},this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.RemoveView,this.handle),this.viewer.addEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,this.handle)}destroy(){this.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.RemoveView,this.handle),this.viewer.removeEventListener(e.Bimface.Viewer.Viewer3DEvent.ViewChanged,this.handle),this.handle=void 0,this.directionalLights[0].lightManager=null,this.clear(),this.directionalLights=null,this.csmLight.destroy(),this.csmLight=null,this.fillLights=null,this.spotLights=null,this.allLights=null,this.viewer=null}addLight(t){if(!this.getLightById(t.id)){t.lightManager=this,t._updateParams&&t._updateParams(this.viewer);var i=this.viewer.getViewer().getScene().lightManager;if(t instanceof e.Bimface.Light.SpotLight)i.addExternalSpotLight(t._spotLight),t._spotLight.updateMatrixWorld(),t._spotLight.target.parent=t._spotLight.parent,t._spotLight.target.updateMatrixWorld(),t.updateRealDistance(),this.spotLights.push(t);else if(t instanceof e.Bimface.Light.DirectionalLight){if(1==t.useShadow)for(let e=0;e<this.directionalLights.length;e++)this.directionalLights[e].useShadow&&(console.log(`[BIMFACE WARNING]:DirectionalLight("id":"${this.directionalLights[e].id}") shadow is already existed.`),t.useShadow=!1);i.addExternalDirLight(t._dirLight),t._dirLight.updateMatrixWorld(),this.directionalLights.push(t),this.updateLightDirection(t)}return this.allLights=[],this.allLights=this.allLights.concat(this.fillLights).concat(this.directionalLights).concat(this.spotLights).concat(this.csmLight),this.updateShadow(),t.getId()}console.log("ERROR::light is duplicated.")}getAllLights(){return[...this.allLights]}getLightById(e){for(var t=0;t<this.allLights.length;t++)if(this.allLights[t].id==e)return this.allLights[t]}getAllDirectionalLights(){return[...this.directionalLights]}getAllFillLights(){return[...this.fillLights]}getAllSpotLights(){return[...this.spotLights]}removeLightsById(e){for(var t=this.viewer.getViewer().getScene().lightManager,i=this.directionalLights.length-1;i>=1;i--)e.indexOf(this.directionalLights[i].id)>=0&&(t.removeLight(this.directionalLights[i]._dirLight),this.directionalLights.splice(i,1));for(i=this.spotLights.length-1;i>=0;i--)e.indexOf(this.spotLights[i].id)>=0&&(t.removeLight(this.spotLights[i]._spotLight),this.spotLights.splice(i,1));this.allLights=[],this.allLights=this.allLights.concat(this.fillLights).concat(this.directionalLights).concat(this.spotLights).concat(this.csmLight)}clear(){for(var e=this.viewer.getViewer().getScene().lightManager,t=1;t<this.directionalLights.length;t++)e.removeLight(this.directionalLights[t]._dirLight);for(t=0;t<this.spotLights.length;t++)e.removeLight(this.spotLights[t]._spotLight);this.directionalLights.length=1,this.spotLights=[],this.allLights=[],this.allLights=this.allLights.concat(this.fillLights).concat(this.directionalLights).concat(this.csmLight)}enableAllLights(e){for(var t=0;t<this.allLights.length;t++)this.allLights[t].enableLight&&this.allLights[t].enableLight(e)}enableLightsById(e,t){for(var i=0;i<this.allLights.length;i++)e.indexOf(this.allLights[i].id)>=0&&this.allLights[i].enableLight&&this.allLights[i].enableLight(t)}update(){this.updateShadowMap(),this.viewer.render()}enableShadowsById(e,t){for(var i=0;i<this.directionalLights.length;i++)e.indexOf(this.directionalLights[i].id)>=0&&this.directionalLights[i].enableShadow&&this.directionalLights[i].enableShadow(t);for(i=0;i<this.spotLights.length;i++)e.indexOf(this.spotLights[i].id)>=0&&this.spotLights[i].enableShadow&&this.spotLights[i].enableShadow(t)}getCSMLight(){return this.csmLight}updateShadowMap(){this.viewer.getViewer().updateShadowMap()}updateShadow(){var e=this.viewer.getViewer().getScene().lightManager,t=!1;const i=this.viewer.getViewer().modelManager.isBimtilesAsset(),n="ViewerGIS"===this.viewer.getViewerType();let o=n||i?4:3;for(var s=0;s<this.spotLights.length;s++)if(this.spotLights[s]._spotLight.castShadow){t=!0;break}var r=!1;for(s=0;s<this.directionalLights.length;s++)this.directionalLights[s]._dirLight.castShadow=!1,this.directionalLights[s].useShadow&&!r&&(t=!0,o=n||i?4:6,r=!0,this.directionalLights[s]._dirLight.castShadow=!0,this.directionalLights[s]._dirLight.shadow.mapSize.width=1024,this.directionalLights[s]._dirLight.shadow.mapSize.height=1024,this.directionalLights[s]._dirLight.shadow.bias=-9e-4,e.lightCastShadow=this.directionalLights[s]._dirLight,this.viewer.getViewer().getScene().sunDirection=this.directionalLights[s]._dirLight._sunDirection,this.viewer.getViewer().getScene().originSunDirection=this.directionalLights[s]._dirLight._sunDirection);this.csmLight&&this.csmLight.isEnabled&&(t=!0),this.viewer.getViewer().enableShadow(t),this.viewer.getViewer().setLightPreset(o),this.updateShadowMap()}updateLightDirection(t){if(t instanceof e.Bimface.Light.DirectionalLight)if(t.latLon&&t.date){var i=this.viewer.getViewer().calcShadowDirection([t.latLon.lon,t.latLon.lat],t.date);t.direction=this.viewer.getViewer().drawingToWorld(i),t.direction.normalize(),t._dirLight._sunDirection=i,t._dirLight.position.copy(i),t._dirLight.position.multiplyScalar(1e3),t._dirLight.updateMatrixWorld()}else(i=this.viewer.getViewer().worldToDrawing(t.direction)).normalize(),t._dirLight._sunDirection=i,t._dirLight.position.copy(i),t._dirLight.position.multiplyScalar(1e3),t._dirLight.updateMatrixWorld();this.updateShadow()}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager"),i=Object.freeze({Transformed:"Transformed"});t.ExternalObjectEvent=i}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();let i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager");i.ExternalObjectManager=class{constructor(e,i){t.send("Bimface.ElementManager.ExternalObjectManager","bf_c_extObjMng_new");var n=this;return n.viewer=e,n._objects={},n.isVisible=!0,n.layerId=i,n._createExternalObjectManager(),P(this),n}_createExternalObjectManager(){this._externalObjectManager=new e.Bimface.Plugins.ExternalObject.ExternalObjectManager(this.viewer)}addEventListener(e,t){this._externalObjectManager.addEventListener(e,t)}removeEventListener(e,t){this._externalObjectManager.removeEventListener(e,t)}_fireTransformedEvent(t){this._externalObjectManager.getEventManager().fireEvent(e.Bimface.ElementManager.ExternalObjectEvent.Transformed,{id:t,worldPosition:this.getPosition(t),layerId:this.layerId}),this.viewer.getViewer().updateGlowEffect(this.modelId,t)}loadObject(e,t,i){var n=this;const o=e.name;if(!y.Utils.isDefined(o))return console.warn("option.name is necessary when loadObject"),void(i&&i());void 0!==e.enableLight&&(n._externalObjectManager.enableLight=e.enableLight);const s=e.object,r=e.url;if(y.Utils.isDefined(s)){const r=n._externalObjectManager._addObject(o,s,e.modelId);if(null!=r)return n._objects[r]=o,n.isVisible?n._externalObjectManager._manager.getFilter().showByIds([r]):n._externalObjectManager._manager.getFilter().hideByIds([r]),y.Utils.isDefined(e.objectData)&&n.setObjectData(r,e.objectData),t&&t(),r;i&&i()}else y.Utils.isDefined(r)&&n._externalObjectManager.loadObject({name:o,url:{objectUrl:r.objectUrl,mtlUrl:r.mtlUrl},objectData:e.objectData,association:{modelId:e.modelId},enableLight:e.enableLight},(()=>{var e=n._externalObjectManager.getObjectIdByName(o);null!=e&&(n._objects[e]=o),t&&t()}),i)}getObjectIdByName(e){for(var t in this._objects)if(this._objects[t]===e)return t}setObjectData(e,t){void 0!==this._objects[e]?this._externalObjectManager.setObjectData(e,t):console.warn(`No ${e} in ExternalObjectManager`)}getObjectData(e){if(void 0!==this._objects[e])return this._externalObjectManager.getObjectData(e);console.warn(`No ${e} in ExternalObjectManager`)}getObjectIdAndName(){return this._objects}_updateMeshesVisible(){for(var e in this._externalObjectManager._manager.meshes){var t=this._externalObjectManager._manager.meshes[e];if(null!=t&&null!=this._objects[e])for(var i=0;i<t.length;i++)t[i].visible=this.isVisible}}clone(e,t){const i=this._externalObjectManager.clone(e,t);return i&&(this._objects[i]=t),i}hide(e){this._externalObjectManager.hide(e)}show(e){this._externalObjectManager.show(e)}select(e){this._externalObjectManager.select(e)}removeSelection(e){this._externalObjectManager.removeSelection(e)}getAllObjectIds(){return Object.keys(this._objects)}removeByIds(e){for(var t=0;t<e.length;t++){const i=e[t];this.removeById(i)}}removeById(e){this._objects[e]&&(this._externalObjectManager.removeById(e),delete this._objects[e])}clear(){var e=this,t=Object.keys(e._objects);t.length>0&&(e.clearGlowEffect(),e._externalObjectManager.removeByIds(t),e._objects={})}translate(e,t){null!=this._objects[e]&&(this._externalObjectManager.translate(e,t),this._fireTransformedEvent(e))}rotateOnBasePoint(e,t,i,n){null!=this._objects[e]&&(this._externalObjectManager.rotateOnBasePoint(e,t,i,n),this._fireTransformedEvent(e))}scaleOnBasePoint(e,t,i){null!=this._objects[e]&&(this._externalObjectManager.scaleOnBasePoint(e,t,i),this._fireTransformedEvent(e))}getBoundingBoxById(e){if(null!=this._objects[e])return this._externalObjectManager.getBoundingBoxById(e)}setPosition(e,t){null!=this._objects[e]&&(this._externalObjectManager.setPosition(e,t),this._fireTransformedEvent(e))}getPosition(e){if(null!=this._objects[e])return this._externalObjectManager.getPosition(e)}offset(e,t){null!=this._objects[e]&&(this._externalObjectManager.offset(e,t),this._fireTransformedEvent(e))}offsetX(e,t){this.offset(e,{x:t,y:0,z:0})}offsetY(e,t){this.offset(e,{x:0,y:t,z:0})}offsetZ(e,t){this.offset(e,{x:0,y:0,z:t})}rotate(e,t){null!=this._objects[e]&&(this._externalObjectManager.rotate(e,t),this._fireTransformedEvent(e))}rotateX(e,t){this.rotate(e,{x:t,y:0,z:0})}rotateY(e,t){this.rotate(e,{x:0,y:t,z:0})}rotateZ(e,t){this.rotate(e,{x:0,y:0,z:t})}setRotationX(e,t,i){let n=new THREE.Vector3(1,0,0);this.rotateOnBasePoint(e,t,n,i)}setRotationY(e,t,i){let n=new THREE.Vector3(0,1,0);this.rotateOnBasePoint(e,t,n,i)}setRotationZ(e,t,i){let n=new THREE.Vector3(0,0,1);this.rotateOnBasePoint(e,t,n,i)}scale(e,t){null!=this._objects[e]&&(this._externalObjectManager.scale(e,t),this._fireTransformedEvent(e))}scaleX(e,t){this.scale(e,{x:t,y:1,z:1})}scaleY(e,t){this.scale(e,{x:1,y:t,z:1})}scaleZ(e,t){this.scale(e,{x:1,y:1,z:t})}getTransformation(e){if(null!=this._objects[e])return this._externalObjectManager.getTransformation(e)}setTransformation(e,t){null!=this._objects[e]&&(this._externalObjectManager.setTransformation(e,t),this._fireTransformedEvent(e))}setGlowEffectById(e,t){for(var i=this,n=[],o=0;o<e.length;o++)null!=i._objects[e[o]]&&n.push(e[o]);if(0!=n.length){if("outline"==t.type){null==i.outlineGlowObj&&(i.outlineGlowObj={});for(o=0;o<e.length;o++)i.outlineGlowObj[e[o]]=t}else{null==i.bodyGlowObj&&(i.bodyGlowObj={});for(o=0;o<e.length;o++)i.bodyGlowObj[e[o]]=t}i._externalObjectManager.setGlowEffectById(n,t)}}removeGlowEffectById(e){for(var t=this,i=[],n=0;n<e.length;n++)null!=t._objects[e[n]]&&i.push(e[n]);if(0!=i.length){for(n=0;n<i.length;n++)null!=t.bodyGlowObj&&delete t.bodyGlowObj[i[n]],null!=t.outlineGlowObj&&delete t.outlineGlowObj[i[n]];t._externalObjectManager.removeGlowEffectById(i)}}clearGlowEffect(){var e=this,t=Object.keys(e._objects);t.length>0&&e._externalObjectManager.removeGlowEffectById(t),e.outlineGlowObj=null,e.bodyGlowObj=null}play(e){null!=this._objects[e]&&this._externalObjectManager.play(e)}pause(e){null!=this._objects[e]&&this._externalObjectManager.pause(e)}stop(e){null!=this._objects[e]&&this._externalObjectManager.stop(e)}isAnimatable(e){if(null!=this._objects[e])return this._externalObjectManager.isAnimatable(e)}getBoundingBoxWorld(){let e=new THREE.Box3;const t=this._externalObjectManager._manager.getFilter();for(const i in this._objects){if(t.isHidden(i))continue;const n=this.getBoundingBoxById(i);e.union(n)}return e}overrideColor(e,t){if(!y.Utils.isDefined(e))return;let i=[];const n=this._externalObjectManager._manager.getFilter();if(!y.Utils.isDefined(n))return;if(y.Utils.isDefined(e.all)&&1==e.all&&(i=i.concat(this.getAllObjectIds())),y.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(n.getMatchIds(e.objectData))),y.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0===i.length)return;const o={color:parseInt(t.getHEX(),16),opacity:t.getAlpha()};n.addToOverrideListByColor(i,o)}restoreColor(e){if(!y.Utils.isDefined(e))return;let t=[];const i=this._externalObjectManager._manager.getFilter();y.Utils.isDefined(i)&&(y.Utils.isDefined(e.all)&&1==e.all&&(t=t.concat(this.getAllObjectIds())),y.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),t=t.concat(i.getMatchIds(e.objectData))),y.Utils.isDefined(e.ids)&&(t=t.concat(e.ids)),t=Array.from(new Set(t)),0!==t.length&&i.addToOverrideListByColor(t))}toLocalPosition(e,t){return this._externalObjectManager.toLocalPosition(e,t)}toWorldPosition(e,t){return this._externalObjectManager.toWorldPosition(e,t)}convert(e,t){if(!c.hasProperties(e,"layerId","objectId"))return null;const i=this.viewer.getLayerManager().getLayer(e.layerId);return i?this._externalObjectManager.convert({modelId:i.getModelId(),objectId:e.objectId},t):null}setLocation(e,t){if(c.assertType(t,"obj")){const{latLon:i,worldPosition:n}=t;let o={},s=!1;if(c.assertType(i,"obj")&&c.assertParamsType(i.lat,i.lon,"num")){const e=this.viewer.latLonToWorld({latLon:i});o.x=e.x,o.y=e.y,o.z=c.assertType(i.alt,"num")?i.alt:e.z||0,s=!0}else c.assertType(n,"obj")&&c.assertParamsType(n.x,n.y,n.z,"num")&&(o=n,s=!0);if(s){const t=this.getTransformation(e);if(!t)return;const i=[...t];i[12]=o.x,i[13]=o.y,i[14]=o.z,this.setTransformation(e,i)}}}getLocation(e){const t=this.getTransformation(e);if(!t)return null;const i={x:t[12],y:t[13],z:t[14]},{lat:n,lon:o}=this.viewer.worldToLatLon(i);return{latLon:{lat:Number(n.toFixed(9)),lon:Number(o.toFixed(9)),alt:Number(t[14].toFixed(3))},worldPosition:i}}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Analysis.CutFill");t.CutFillAnalysisConfig=class{constructor(){this.boundary=[],this.level=0,this.viewer=null,this.layerIds=[]}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Analysis.CutFill");i.CutFillAnalysis=class{constructor(i){t.send("Bimface.Earth.Analysis.CutFillAnalysis.CutFill","bf_c_cutfFill_new");let n=this;if(P(this),i)if(i.viewer)if(i.viewer instanceof e.Bimface.Earth.Viewer.ViewerGIS){if(i.boundary&&!(i.boundary.length<=2)){n.boundary=[i.boundary[0]];for(let e=1;e<i.boundary.length;e++)i.boundary[e].lat==i.boundary[e-1].lat&&i.boundary[e].lon==i.boundary[e-1].lon||n.boundary.push(i.boundary[e]);n.boundary.length<=2||(n.level=i.level,n.viewer=i.viewer,n.engineViewer=n.viewer.getViewer(),n.setLayerIds(i.layerIds),n._updateParameter(),n.cutFillAnalysis=new CLOUD.SphereCutFillMeasure({showVisualization:!0,level:n.level,boundary:n._boundary,viewer:n.viewer,layerIds:n.layerIds}),n._addSence())}}else console.log("ERROR::viewer must not be empty or viewer2d.");else console.log("ERROR::viewer must not be empty.");else console.log("ERROR::cutFillAnalysisConfig must not be empty.")}_updateParameter(){let e=this;e._boundary=[],e.boundary.forEach((t=>{e._boundary.push(e.viewer.latLonToWorld(t))}))}_addSence(){var t=this;t.extObjMng=new e.Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager(t.viewer),t.objectTpye="cutFill-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.cutFillAnalysis._externalNeedScale=!1,t.extObjMngId=t.extObjMng._addObject(t.objectTpye+t.id,t.cutFillAnalysis)}destroy(){var e=this;null!=e.extObjMngId&&e.extObjMng.removeById(e.extObjMngId),e.cutFillAnalysis.destroy(),e.cutFillAnalysis=null,e._boundary=null}update(){var e=this;e._updateParameter(),e.cutFillAnalysis.effectOpt({level:e.level,boundary:e._boundary,layerIds:e.layerIds}),e.viewer.render()}getLayerIds(){let e=this;return e.layerIds?e.layerIds:e.viewer.getLayerManager().terrainLayer&&e.viewer.getLayerManager().terrainLayer.id}setLayerIds(e){let t=this;if("Viewer3D"===t.viewer.viewerType)return void(t.layerIds=void 0);const i=t.viewer.getLayerManager().terrainLayer&&t.viewer.getLayerManager().terrainLayer.id;null!=e&&e instanceof Array&&0!=e.length?(t.layerIds=e,-1!=t.layerIds.indexOf(i)&&(t.layerIds=void 0)):t.layerIds=void 0}hide(){this.cutFillAnalysis.hide(),this.viewer.render()}show(){this.cutFillAnalysis.show(),this.viewer.render()}getBoundary(){return this.boundary}getLevel(){return this.level}setBoundary(e){this.boundary=e}setLevel(e){this.level!=e&&(this.level=e)}calculateAccurateResult(e){this.cutFillAnalysis.updateCutFillVolumeData(e)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Analysis.CutFill");t.CutFillComparisonConfig=class{constructor(){this.viewer=null,this.data={}}}}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Analysis.CutFill"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.CutFillComparison=class{constructor(t){P(this),t.viewer?(this.viewer=t.viewer,this.data=t.data,this.cutFillComparison=new CLOUD.SphereCutFillVision({data:[{id:e.Web.Lang.Utility.UUID.createUUID(),data:t.data}]}),this._addSence(),this.colorRanges=this.cutFillComparison._colorRanges,this.heightRange=this.cutFillComparison._cutFillHeightRange,this._createColorLegend(),this.initColorLegendData()):console.log("ERROR::viewer must not be empty.")}_addSence(){var t=this;t.extObjMng=new e.Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager(t.viewer),t.objectTpye="cutFillComparison-",t.id=e.Web.Lang.Utility.UUID.createUUID(),t.extObjMngId=t.extObjMng._addObject(t.objectTpye+t.id,t.cutFillComparison.renderableObject)}zoomToBoundingBox(){this.viewer.zoomToBoundingBox({boundingBox:this.cutFillComparison.boundingBox})}destroy(){var e=this;null!=e.extObjMngId&&e.extObjMng.removeById(e.extObjMngId),e.cutFillComparison.destroy(),e.cutFillComparison=null,e.data=null,this._disposeColorLegendPanel()}setOpacity(e){this.cutFillComparison.setOpacity(e),this.viewer.render()}setCuboidScaleFactor(e){this.cutFillComparison.setCuboidScaleFactor(e),this.viewer.render()}hide(){this.cutFillComparison.hide(),this._showColorLegendPanel(!1),this.viewer.render()}show(){this.cutFillComparison.show(),this._showColorLegendPanel(!0),this.viewer.render()}enableColorLegend(e){e?this.colorLegendPanel?(this._showColorLegendPanel(!0),this._updateColorLegend()):this._createColorLegend():this._showColorLegendPanel(!1)}initColorLegendData(){this.digBackground="linear-gradient(180deg";for(let e=0;e<this.colorRanges.dig.length;e++){const t=100/(this.colorRanges.dig.length-1)*e+"%";this.digBackground+=`, ${this.colorRanges.dig[e]} ${t}`}this.digBackground+=")",this.fillBackground="linear-gradient(180deg";for(let e=0;e<this.colorRanges.fill.length;e++){const t=100/(this.colorRanges.dig.length-1)*e+"%";this.fillBackground+=`, ${this.colorRanges.fill[e]} ${t}`}if(this.fillBackground+=")",this.colorLegendPanel&&this._enableColorLegend){this.colorLegendPanel.querySelector(".bf-colorLegend-cutfill-dig").style.setProperty("background",this.digBackground),this.colorLegendPanel.querySelector(".bf-colorLegend-cutfill-fill").style.setProperty("background",this.fillBackground)}}_createColorLegend(){let e=i.create("div","bf-colorLegend-cutfill");e.innerHTML="<div class='bf-colorLegend-cutfill-dig'></div><div class='bf-colorLegend-cutfill-fill'></div><span class='bf-colorLegend-cutfill-max'></span><span class='bf-colorLegend-cutfill-min'></span>",this.viewer.getDomElement().appendChild(e),this.colorLegendPanel=e,this._enableColorLegend=!0,this._updateColorLegend()}_updateColorLegend(){if(this.colorLegendPanel&&this._enableColorLegend){let e=this.colorLegendPanel.querySelector(".bf-colorLegend-cutfill-max"),t=this.colorLegendPanel.querySelector(".bf-colorLegend-cutfill-min");e.innerText=parseInt(100*this.heightRange.max)/100,t.innerText=parseInt(100*this.heightRange.min)/100}}_showColorLegendPanel(e){this.colorLegendPanel&&(this._enableColorLegend=e,this.colorLegendPanel.style.display=e?"block":"none")}_disposeColorLegendPanel(){this.colorLegendPanel&&(this.colorLegendPanel.parentElement.removeChild(this.colorLegendPanel),this.colorLegendPanel=null)}}}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer").ViewerGISConfig=class{constructor(){let t=e.Bimface.Viewer.OrbitButton,i="Local"==BimfaceLoaderConfig.dataEnvType?`${BimfaceLoaderConfig.staticHost}Glodon/bimface/resources`:`${BimfaceLoaderConfig.staticHost}/../resources`;const n={domElement:null,resourceHost:g.resourceHost,staticHost:g.staticHost+"/api/Glodon",APIHost:g.APIHost,staticResourcesHost:i,securityApi:g.securityApi,sdkUrl:null,staticPath:"/api/Glodon",basePoint:null,homeView:null,orbitButton:t.Left,loading:!1,backgroundColor:{direction:Math.PI,colors:[{color:new e.Web.Graphics.Color(88,103,133,1),stop:"0%"},{color:new e.Web.Graphics.Color(229,234,242,1),stop:"100%"}]},enableExplosion:!1,enableLogarithmicDepthBuffer:!0,enableCompassControl:!0,enableScaleBar:!0,enableInfoBar:!0,enableCreditBar:!0,enableStorage:!0,loadIBLScene:{IBLSceneOption:"",withBackground:!1},memoryThreshold:void 0,enableWireframe:null,enableAutoRaiseCamera:!0,enableSSAO:!1,enableCSMShadow:!1,disableMapOcclusion:!1,enableAtmosphere:!0,enableAutoRotate:!1};for(let e in n)this[e]=n[e]}},function(){let t=Object.freeze({Rendered:"Rendered",CameraPositionChanged:"CameraPositionChanged",SceneAdded:"SceneAdded",SceneLoading:"SceneLoading",Error:"Error",ModelAdded:"ModelAdded",ModelRemoved:"ModelRemoved",LayerAdded:"LayerAdded",ViewChanged:"ViewChanged",MouseClicked:"MouseClicked",MouseClickedWithoutMap:"MouseClickedWithoutMap",MouseHover:"MouseHover",MouseMove:"MouseMove",EarthAnimationCompleted:"EarthAnimationCompleted",MouseDraged:"MouseDraged",MouseDoubleClicked:"MouseDoubleClicked",ContextMenu:"ContextMenu",SelectedObjectsChanged:"SelectedObjectsChanged",SelectionChanged:"SelectionChanged",ComponentsHoverChanged:"ComponentsHoverChanged",ComponentsSelectionChanged:"ComponentsSelectionChanged",RectSelection:"RectSelection",ModelTransformed:"ModelTransformed",FloorExplosion:"FloorExplosion",ModelAddFailed:"ModelAddFailed",ModelInitedWithoutLoad:"ModelInitedWithoutLoad",AllModelInited:"AllModelInited",ZoomEnd:"ZoomEnd",Initialized:"Initialized",ViewProcessing:"ViewProcessing",ViewLoaded:"ViewLoaded",LayerVisibleChanged:"LayerVisibleChanged"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer").ViewerGISEvent=t}(),function(){let t=Object.freeze({Left:"Left",Right:"Right"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer").OrbitButton=t}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer"),i=Object.freeze({Endpoint:"endpoint",Midpoint:"midpoint",Intersection:"intersection",Line:"line",Face:"face"});t.SnapObject=i}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer");t.SnapMode=class{constructor(){this.snapList={},this.snapConditions=[],this.snapCondition={}}setSnapList(e){this.snapList=e}setSnapCondition(e){this.snapCondition=e}getSnapCondition(){return this.snapCondition}setSnap3DList(e){this.snapList=e}getSnap3DList(){return this.snapList}}}();class Bs{constructor(e){this._root=e}query(e){return e=this.parseCondition(e),this.getObjectsByCondition(e)}execute(e,t,i){this.query(e).forEach((e=>{"[object Function]"===Object.prototype.toString.call(e[t])&&(i?e[t](...i):e[t]())}))}getObjectsByCondition(e){if(!e)return;let t=[];const i=n=>{let o;for(let t in e){let i,s,r=e[t];switch(t){case"id":case"name":case"typeName":i=t,s=!0;case"noId":case"noName":case"noTypeName":i=i||{noId:"id",noName:"name",noTypeName:"typeName"}[t],s=s||!1,o=n[i]===r?s:!s;break;case"ids":case"names":case"typeNames":i=/(.*)s/.exec(t)[1],s=!0;case"noIds":case"noNames":case"noTypeNames":if(i=i||{noIds:"id",noNames:"name",noTypeNames:"typeName"}[t],s=s||!1,"[object Array]"!==Object.prototype.toString.call(r))return;o=r.indexOf(n[i])>=0?s:!s}if(!o)break}o&&t.push(n),n.children&&n.children.length>0&&n.children.forEach((e=>{i(e)}))};return i(this._root),t}parseCondition(e){let t;return"[object String]"===Object.prototype.toString.call(e)?t=this.codeTocondition(e):"[object Array]"===Object.prototype.toString.call(e)?t=this.codeTocondition(e.join(" ")):"[object Object]"===Object.prototype.toString.call(e)&&(t=e),t}codeTocondition(e){let t={};if("[object String]"===Object.prototype.toString.call(e)){e.split(" ").forEach((e=>{if(0===e.length)return;const i={id:"noId",typeName:"noTypeName",name:"noName",property:"noProperty",userData:"noUserData",ids:"noIds",typeNames:"noTypeNames",names:"noNames",properties:"noProperties"};let n={id:"id",typeName:"typeName",name:"name",property:"property",userData:"userData",ids:"ids",typeNames:"typeNames",names:"names",properties:"properties"};"!"===e[0]&&(e=/!(.*)/.exec(e)[1],n=i),(e=>{const i=(e,i)=>{const o=n[e],s=n["property"===e?"properties":e+"s"];if(t[s])t[s].push(i);else if(t[o]){let e=[t[o],i];delete t[o],t[s]=e}else t[o]=i};switch(e[0]){case"#":i("id",/#(.*)/.exec(e)[1]);break;case".":i("typeName",/\.(.*)/.exec(e)[1]);break;case"(":let t=/\((.*?)\)(.*)/.exec(e);if(t){const[e,n,o]=t;i(n,o)}default:i("name",e)}})(e)}))}return t}}class _s{constructor(t){const i=e.Web.Lang.Utility.DataUtil;this._getDataUtil=()=>i,this.id=i.assertType(t.id,"str")||i.assertType(t.id,"num")?t.id.toString():e.Web.Lang.Utility.UUID.createUUID(),this.name=t.name,this.typeName=t.typeName,this.userData=t.userData,this.isVisible=!1!==t.isVisible,t.viewer&&(this.getViewer=()=>t.viewer),this.children=[];const n=new Bs(this);this.getOperationManager=()=>n,P(this)}getId(){return this.id}getName(){return this.name}setName(e){this.name=e}getParent(){return this.parent}getContents(){return this.children}show(e){this.getOperationManager().execute(e,"show")}hide(e){this.getOperationManager().execute(e,"hide")}query(e){return this.getOperationManager().query(e)}add(e,t){this.children.push(e),e.parent=this,this.isVisible||(e.isVisible=this.isVisible),e.getViewer||(e.getViewer=()=>this.getViewer()),e.init&&e.init()}remove(e){if(e instanceof _s){const t=e;t.destroy&&t.destroy();const i=this.children.indexOf(t);i>=0&&this.children.splice(i,1)}else this.getOperationManager().execute(e,"remove")}}class Ls extends _s{constructor(e){super(e)}updateParentsVisible(){const e=t=>{let i=!1;t.children.some((e=>i=e.isVisible)),t.isVisible=i,t.parent&&e(t.parent)};this.parent&&e(this.parent)}show(){this.isVisible=!0,this.updateParentsVisible(),setTimeout((()=>this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.LayerVisibleChanged,!0)),0)}hide(){this.isVisible=!1,this.updateParentsVisible(),this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.LayerVisibleChanged,!1)}}var Ds=e.Bimface.Data.StatisticsDataManager.getInstance();class As extends Ls{constructor(e){Ds.send("Glodon.Bimface.Earth.Layer.GroupLayer","bf_c_groupLayer_new"),e.typeName="GroupLayer",super(e)}show(){this.children.forEach((e=>{e.show()})),super.show()}hide(){this.children.forEach((e=>{e.hide()})),super.hide()}destroy(){let e=[];this.children.forEach((t=>e.push(t))),e.forEach((e=>{e.destroy()}))}addLayer(e){this.add(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").GroupLayer=As;class Vs extends Ls{constructor(e){e.children=null,super(e),this.priority=e.priority,this.elementManager={}}}class Rs{static getTileSource(e){e.provider=Rs.parseProvider(e);const{credit:t,url:i,text:n,link:o,copyright:s,provider:r,key:a,parameters:l}=e;if(t===Glodon.Bimface.Common.Credit.Custom)return{credit:t,url:i,text:n,link:o,copyright:s,provider:r,key:a,parameters:l};{let e=this.TileSources[t]||this.TileSources[Glodon.Bimface.Common.Credit.None];return e=Object.assign({},e,{url:i,provider:r,key:a,parameters:l}),e}}static parseProviderByMapUrl(e){return void 0===e||e.indexOf("is.autonavi.com/appmaptile")>-1||e.indexOf("google.cn/vt")>-1||e.indexOf("google.com/vt")>-1||e.indexOf("microsoft.com")>-1||e.indexOf("microsoft.cn")>-1||e.indexOf("tile.openstreetmap.org")>-1||e.indexOf("map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile")>-1?"UrlTemplate":!0===/tianditu.gov.cn.*wmts/.test(e)?"WebMapTileServiceTDU":e.indexOf("tiles.virtualearth.net")>-1?"TileMapBingMapService":e.indexOf("map.gtimg.com/sateTiles")>-1?"TileMapTencentMapService":e.indexOf("bdimg.com")>-1?"BdMapService":"SpecificMapService"}static parseProvider(e){let t;const i=e.mapUrl||e.url;t=void 0===e.provider?Rs.parseProviderByMapUrl(i):Rs.parseProviderByProtocol(e.provider);const n=Rs.fixRequestByProvider(i,t,e.parameters);return e.mapUrl=n,e.url=n,t}static parseProviderByProtocol(e){if(["TileMapBingMapService","WebMapTileServiceTDU","TileMapService","TileMapTencentMapService","WebMapService","WebMapTileService","BdMapService","UrlTemplate"].indexOf(e)>=0)return e;switch(e){case"BingMap":return"TileMapBingMapService";case"Tianditu":return"WebMapTileServiceTDU";case"TMS":return"TileMapService";case"Tencent":return"TileMapTencentMapService";case"WMS":return"WebMapService";case"WMTS":return"WebMapTileService";case"BaiDu":return"BdMapService";default:return"UrlTemplate"}}static fixRequestByProvider(e,t,i){let n=e;switch(t){case"WebMapTileServiceTDU":if(!/tianditu.gov.cn.*wmts.*{x}/.test(e)){const t=e.indexOf("wmts?"),i=e.indexOf("vec_c")>=0?"c":"w",o=t+5,s=t-6,r=e.slice(s,s+3);n=e.slice(0,o)+"SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default"+`&TILEMATRIXSET=${i}`+`&LAYER=${r}&FORMAT=tiles&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}&`+e.slice(o)}break;case"TileMapBingMapService":e.indexOf("tiles.virtualearth.net")>-1&&(n="https://ecn.t0.tiles.virtualearth.net/tiles/a{x}.jpeg?n=z&g=9791");break;case"TileMapTencentMapService":e.indexOf("map.gtimg.com/sateTiles")>-1&&(n="https://p0.map.gtimg.com/sateTiles/{z}/{sx}/{sy}/{x}_{y}.jpg?version=400");break;case"WebMapService":n=e+"?service=WMS&request=GetMap&width=256&height=256&srs=EPSG%3A4326"+`&transparent=${i.transparent}`+`&format=${i.format}`+`&version=${i.version}`+`&styles=${i.styles}`+`&layers=${i.layers}`;break;case"WebMapTileService":(-1===e.indexOf("{x}")||-1===e.indexOf("{y}")&&-1===e.indexOf("{z}"))&&i&&(n=e+"?service=WMTS&request=GetTile"+`&format=${i.format}`+`&tilematrixset=${i.tileMatrixSet}`+`&version=${i.version}`+`&style=${i.style}`+`&layer=${i.layer}&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}`)}return n}static verifyKey(e){return new Promise(((t,i)=>{const n={TileMapTencentMapService:{url:"https://apikey.map.qq.com/mkey/index.php/mkey/check?key={key}&pid=127.0.0.1&channel=0",mkeycb:e=>{e.info&&0===e.info.error&&t(),i(),window.mkeycb=void 0}},TileMapBingMapService:{url:"https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?jsonp=callbackFunction&key={key}&uriScheme=http",callbackFunction:e=>{"ValidCredentials"===e.authenticationResultCode&&t(),i(),window.callbackFunction=void 0}},BdMapService:{url:"http://api.map.baidu.com/?qt=verify&v=3.0&type=webgl&ak={key}&callback=mkeycb",mkeycb:e=>{e&&0===e.error&&t(),i(),window.mkeycb=void 0}}},o=e.provider;let s=n[o]&&n[o].url;if(s)if(e.key){let t=Glodon.Web.Lang.Utility.HttpRequest;s=s.replace("{key}",e.key),window.callbackFunction=n[o].callbackFunction,window.mkeycb=n[o].mkeycb,t.getScript(s)}else i();else t()}))}}Rs.TileSources=Object.freeze({Tianditu:{credit:Glodon.Bimface.Common.Credit.Tianditu,text:"服务条款",link:"http://www.tianditu.gov.cn/about/contact.html?type=2",copyright:"天地图"},None:{credit:Glodon.Bimface.Common.Credit.None,text:"",link:"",copyright:""}});var Os=e.Bimface.Data.StatisticsDataManager.getInstance();class ks extends Vs{constructor(e){Os.send("Glodon.Bimface.Earth.Layer.TileLayer","bf_c_tileLayer_new"),e.typeName="TileLayer",e.priority=e.priority||1,e.castShadow=!!y.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!y.Utils.isDefined(e.receiveShadow)||e.receiveShadow,"https:"===window.location.protocol&&(e.url=e.url.replace("http:","https:")),super(e),this._config=e,this.mapStyle={},this.lastValidMapStyle={},this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.clippingManager=null}init(){const t=this._config;let i=this.getViewer().getLayerManager().baseMap;if(i&&i.tileManager){this._isBaseMap=!1,this.tileManager=i.tileManager,this.tileManager=this.getViewer().getLayerManager().baseMap.tileManager;let e={url:t.url};return e.imageryProviderType=Rs.parseProvider(e),this.tileSource=Rs.getTileSource({credit:t.credit,url:t.url,provider:t.layerConfig&&t.layerConfig.customResource?t.layerConfig.customResource.provider:void 0}),void(this._imageryId=this.tileManager.addImageryLayer(e))}this._isBaseMap=!0,this.getViewer().getLayerManager().baseMap=this;const n=this.getViewer().getViewer();this.loadMap(),this.getViewer()._camera&&this.getViewer()._camera.init(),this.tileSource=Rs.getTileSource({credit:t.credit,url:t.url,provider:t.layerConfig&&t.layerConfig.customResource?t.layerConfig.customResource.provider:void 0});const o=()=>{this.isVisible||this.hide(),this.initSetting(),this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.SceneAdded),n.unregisterEventListener(y.EVENTS.ON_MAP_LOAD_ALL,o)};n.registerEventListener(y.EVENTS.ON_MAP_LOAD_ALL,o)}initSetting(){let e=this._config.style,t=this._config.shadow;e&&y.Utils.isDefined(e.opacity)&&this.setOpacity(e.opacity),t&&y.Utils.isDefined(t.receiveShadow)&&this.enableReceiveShadow(t.receiveShadow)}loadMap(){const t=this._config;t.baseLatLon=t.baseLatLon||this.getViewer()._config.baseLatLon;var i=new e.Bimface.Plugins.TileMap.MapConfig;t.url&&(i.mapUrl=t.url),i.viewer=this.getViewer(),i.modelAltitude=0,i.basePoint={x:0,y:0},i.useTerrain=t.useTerrain||!1,i.provider=t.provider,i.terrainOnlineConfig=t.terrainOnlineConfig,i.maxTerrainLevel=14,i.sectionable=t.sectionable,i.maxLevel=t.maxLevel,t.terrainPath&&(i.terrainPath=t.terrainPath),i.modelRotationZ=0*Math.PI/180,i.modelPosition=[t.baseLatLon.lon,t.baseLatLon.lat],i.mapUrl||(i.mapUrl="https://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}&tk=9fe0f60cd462f38c726d9a12565e4524"),t.layerConfig&&t.layerConfig.customResource&&(i.provider=t.layerConfig.customResource.provider),i.imageryProviderType=Rs.parseProvider(i);let n={};n.loadConfig=i,n.loadConfig.castShadow=this.castShadow,n.loadConfig.receiveShadow=this.receiveShadow;const o=this.getViewer().getViewer();this.model=o.modelManager.createDemModel(n,!0),this.tileManager=this.model.tileManager,this._imageryId=this.tileManager.getBaseLayerId()}destroy(){this._isBaseMap||(this.tileManager&&this.tileManager.removeImageryLayer(this._imageryId),this.tileManager=null)}show(){this.tileManager.show(this._imageryId),super.show(),this.getViewer()._atmosphereState&&this.getViewer().getViewer().getScene().atmosphere.enable(!0)}hide(){this.tileManager.hide(this._imageryId),super.hide(),this.getViewer().getViewer().getScene().atmosphere.enable(!1)}useTerrain(e){this.tileManager.applyTerrain(e)}isUseTerrain(){return this.tileManager.isUseTerrain()}setTerrain(e,t){return this.tileManager.setTerrain(e,t)}getTerrain(){return{url:this.tileManager.getTerrain()}}setOpacity(e){e=y.Utils.isDefined(e)?e:1,"[object Number]"===Object.prototype.toString.call(e)&&this.tileManager.setOpacity(e>1?1:e<0?0:e,this._imageryId)}getOpacity(){return this.tileManager.getOpacity(this._imageryId)}getSource(){return this.tileSource}setSource(e){const t=this.getViewer();this.tileSource=Rs.getTileSource(e),this.id===t.firstTileLayerId&&t._creditWidget.update(this.tileSource),this._imageryId=this.tileManager.updateImageryLayer(this._imageryId,{mapUrl:this.tileSource.url,imageryProviderType:this.tileSource.provider}),null==this._imageryId&&(this._imageryId=this.tileManager.addImageryLayer({mapUrl:this.tileSource.url,imageryProviderType:this.tileSource.provider}));t.getViewer().holesManager.updateImageryId(this.id,this._imageryId),t.render()}updateCredit(e){const t=this.getViewer(),i=Rs.TileSources[e];t._creditWidget.update(i)}getStyle(){return this.mapStyle}getLastValidMapStyle(){return this.lastValidMapStyle}setLastValidMapStyle(e){this.lastValidMapStyle=Object.assign({},e)}setStyle(t){if(t=t||{},this.mapStyle=Object.assign({},t),"{}"!==JSON.stringify(t)&&(this.lastValidMapStyle=Object.assign({},t)),t.template)switch(t.template){case e.Bimface.Common.ImageStyle.DarkBlue:t.color=new THREE.Vector4(2/255,30/255,88/255,1);break;case e.Bimface.Common.ImageStyle.DarkGreen:t.color=new THREE.Vector4(3/255,63/255,44/255,1);break;case e.Bimface.Common.ImageStyle.CustomColor:if(!t.color)return void console.warn("color is needed when template == Glodon.Bimface.Common.ImageStyle.CustomColor.");t.color=new THREE.Vector4(t.color.red/255,t.color.green/255,t.color.blue/255,t.color.alpha)}if(y.Utils.isDefined(t.brightness)&&(t.brightness+=1,t.brightness=Math.min(Math.max(t.brightness,0),2)),y.Utils.isDefined(t.contrast)){var i=t.contrast+=1;i=Math.min(Math.max(i,0),2),t.contrast=i>1?1+Math.pow(i-1,2):i}y.Utils.isDefined(t.saturation)&&(t.saturation+=1,t.saturation=Math.min(Math.max(t.saturation,0),2)),this.tileManager.setStyle(t,this._imageryId),this.getViewer().render()}restoreStyle(){this.mapStyle={},this.tileManager.setStyle(this.mapStyle,this._imageryId),this.getViewer().render()}setMaxLevel(e){e&&this._getDataUtil().assertType(e,"num")&&(te(this._config.url,e),this.tileManager&&this.tileManager.setMaxLevel(e,this._imageryId))}getMaxLevel(){return this.tileManager.getMaxLevel(this._imageryId)}enableCastShadow(e){e!=this.castShadow&&this.model&&(this.model.setCastShadow(e),this.castShadow=e)}isCastShadowEnabled(){return this.castShadow}enableReceiveShadow(e){this.model&&(this.model.setReceiveShadow(e),this.receiveShadow=e)}isReceiveShadowEnabled(){return this.receiveShadow}getId(){return super.getId()}getModelId(){return y.ObjectGroupType.TILEGROUP}getSenceType(){return e.Bimface.Common.Type.EffectType.MapStyle}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").TileLayer=ks;var Hs=e.Bimface.Data.StatisticsDataManager.getInstance();class Us extends Vs{constructor(e){Hs.send("Glodon.Bimface.Earth.Layer.TerrainLayer","bf_c_terrainLayer_new"),e.typeName="TerrainLayer",e.priority=e.priority||1,super(e),this.baseMap=e.baseMap,this.flatManager=null}show(){this.baseMap.useTerrain(!0),super.show()}hide(){this.baseMap.useTerrain(!1),super.hide()}getId(){return super.getId()}setSource(e,t){if(this.baseMap.isUseTerrain())return this.source=e,this.baseMap.setTerrain(e,t);console.warn("open the terrain firstly")}getSource(){return void 0===this.source?this.baseMap.getTerrain():this.source}getAltitude(e,t){if(null==t)return void console.warn("[BIMFACE WARNING]: Glodon.Bimface.Earth.Layer.TerrainLayer.prototype.getAltitude must have parameter 'callback'");const i=this.getViewer().getLayerManager().baseMap,n=i.isUseTerrain();if(i&&i.tileManager&&e.hasOwnProperty("lat")&&e.hasOwnProperty("lon")){const o=this.getViewer();if(!n){const n=i.tileManager.lngLatToWorldPositionWithoutOpenTerrain([e.lon,e.lat]),s=o.worldToLatLon(n).alt;return void t(s)}i.tileManager.lngLatToWorldPositionWithoutOpenTerrain([e.lon,e.lat],(function(e){if(null==e||null==e)console.warn("[BIMFACE WARNING]: The latitude and longitude are out of the data range.");else if(Object.is(e.x,NaN)||Object.is(e.y,NaN)||Object.is(e.z,NaN))console.warn("[BIMFACE WARNING]:The latitude and longitude are out of the data range.");else{const i=o.worldToLatLon(e).alt;t(i)}}))}}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").TerrainLayer=Us,function(){e.Bimface.Data.StatisticsDataManager.getInstance();const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Model"),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.HttpRequest"),e.Web.Lang.Utility.DataUtil);e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),new THREE.Vector3;class n extends e.Bimface.Model.BimModel{constructor(e,t,i,n,o){super(e,t,i,n,o),this.loadConfig=n,this._modelTransformMatrix=n.transformMatrix}onModelLoaded(){this._loaded=!0,this.setBorderLineWithFilter(this._opt),this.wireFrameVisibilityOption&&this.setWireFrameVisibilityCondition(this.wireFrameVisibilityOption),this._opt.enableExplosion&&this.loadFloorsForExplosion&&this.loadFloorsForExplosion();this.getViewer()._data;if("ViewerGIS"===this.viewerType){let e=this._layer._config.config||this.getCloudViewer().getModelManager().getModel(this.modelId)._config;if(e.metadata&&1===e.metadata.hasConvertCoordinateSystem||e.coordinateSystem&&e.coordinateSystem.projCS&&e.coordinateSystem.projCS.projection)return;if(this._layer._config.layerConfig&&this._layer._config.layerConfig.position)return this.setPositionWorld(this._layer._config.layerConfig.position),void(this._layer._config.transformation&&this.setModelTransformation(this._layer._config.transformation));if(this._layer._config.location)return void this.setPositionWorld(this._viewer.latLonToWorld(this._layer._config.location));if(!this._layer._config.transformation||"[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]"===JSON.stringify(this._layer._config.transformation)){let t="EPSG:4490",n=new m,o=!1,s=null;if(i.hasChildProperty(e,"coordinateSystem","projCS","centralMeridian")){const t=e.coordinateSystem.projCS,{name:i}=t;s=`Custom_${i||"自定义"}`,n.defineCustomCoordSys(s,t)}if(!o&&(i.hasChildProperty(e,"coordinateSystem","geogCS","epsg")||i.hasChildProperty(e,"coordinateSystem","geogCS","EPSG"))){let s=e.coordinateSystem.geogCS,r=`EPSG:${s.epsg||s.EPSG}`;if(Object.values(f).includes(r)&&s.latLon){let e,a=n.translateLatLon({lat:s.latLon[0],lon:s.latLon[1]},r,t),{altitude:l,origin:h}=s;e=isNaN(l)||0===l?this.getViewer().latLonToWorld({...a,alt:0}):this.getViewer().latLonToWorld({...a,alt:l}),i.assertType(h,"arr")&&(e.x-=h[0],e.y-=h[1],e.z-=h[2]),this.setPositionWorld(e),o=!0,this.console.info(`layer[${this._layer.id}] is transformed by geographic coordinate system [${r}]`)}}if(!i.hasChildProperty(e,"coordinateSystem","projCS")&&!i.hasChildProperty(e,"coordinateSystem","geogCS")){let e=this.getViewer().getBasePoint(),t=this.getViewer().latLonToWorld({...e,alt:0});this.setPositionWorld(t),o=!0}}}}_getMetaDataManager(){if(this._metaDataManager)return this._metaDataManager;{const t=this.getMetaData();let i=new e.Bimface.Data.MetaDataManagerConfig;return t.integrateDrawings&&"success"==t.integrateDrawings.status&&(i.integrateDrawings=t.integrateDrawings),i.isGlobeScene=!0,i.APIHost=this._opt.APIHost,i.resourceHost=this._opt.resourceHost,i.viewToken=t.viewToken,i.databagId=t.databagId,i.modelId=t.modelId,i.modelType=t.modelType,i.dataEnvType=t.dataEnvType||i.dataEnvType,i.loadMode="Local"!=t.dataEnvType?this._viewer._data.loadMode:"",i.enableComponentCut=!!t.enableComponentCut,t.path?(i.relativeUrlWithoutDatabagId=e.Web.Lang.Utility.ClientHelper.formatURL(t.path),i.relativeUrl=e.Web.Lang.Utility.ClientHelper.formatURL(t.path+"/"+i.databagId)):(i.relativeUrlWithoutDatabagId=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.resourceHost}`),i.relativeUrl=e.Web.Lang.Utility.ClientHelper.formatURL(`${i.resourceHost}/${i.databagId}`)),this._metaDataManager=new e.Bimface.Data.MetaDataManager(i),this._metaDataManager}}getModelTransformationAdaptedUnit(){const e=this.getCloudViewer().modelManager.getModel(this.modelId);if(!e)return;const t=e.getTransformMatrixLocal();return i.limitTransformationDecimal(t.elements)}getPositionWorld(){return this.getCloudViewer().modelManager.getModel(this.modelId).getOriginPositionWorld()}setPositionWorld(e){let t=this.getCloudViewer();if(!this._getModelGroup())return;let i=new THREE.Vector3(e.x,e.y,e.z);t.modelManager.getModel(this.modelId).setOriginPositionWorld(i),t.modelManager.updateScene(),t.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}setModelTranslation(e){if(!e)return void console.log("Parameter translation is required.");let t=this.getCloudViewer(),i=this._getModelGroup();if(!i)return;new THREE.Vector3(e.x,e.y,e.z);let n=t.modelManager.getModel(this.modelId),o=this.getPositionWorld(),s=new THREE.Vector3(o.x+e.x,o.y+e.y,o.z+e.z);n.setOriginPositionWorld(s),i.transformMatrix=n.getTransformMatrixLocal(),t.modelManager.updateScene(),t.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}setModelRotationZ(e,t){let i=new THREE.Vector3(0,0,1);this._setModelRotation(e,i,t)}_setModelRotation(e,t,i){if(!e||!i)return void console.log("Parameter basePoint and rotation is required.");let n=this.getCloudViewer(),o=this._getModelGroup();if(!o)return;let s=e=new THREE.Vector3(e.x,e.y,e.z),r=n.modelManager.getModel(this.modelId);r.rotateOnBasePoint(s,t,i),o.transformMatrix=r.getTransformMatrixLocal(),n.modelManager.updateScene();n.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}setModelScale(e,t){if(!e||!t)return void console.log("Parameter basePoint and scale is required.");if(0===t)return void console.log("Invalid argument, value of scale must a number except zero.");let i=this.getCloudViewer(),n=this._getModelGroup();if(!n)return;let o="number"==typeof t?new THREE.Vector3(t,t,t):t,s=new THREE.Vector3(e.x,e.y,e.z),r=i.modelManager.getModel(this.modelId);r.scaleOnBasePoint(s,o),n.transformMatrix=r.getTransformMatrixLocal(),i.modelManager.updateScene(),i.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}setModelTransformation(e){if(!e)return void console.log("Parameter modelTransformation is required.");if(["[object Float32Array]","[object Array]"].indexOf(Object.prototype.toString.call(e))<0)return void console.log("Parameter modelTransformation should be a array.");const t=this.getCloudViewer(),i=this._getModelGroup();if(!i)return;const n=(new THREE.Matrix4).fromArray(e),o=t.modelManager.getModel(this.modelId);o.transformByMatrix(n),i.transformMatrix=o.getTransformMatrixLocal(),t.modelManager.updateScene();t.rendererManager.getPickingEffecter().apply(!0),this.getViewer().render(),this._fireWhenModelChanged()}loadFeatureLabel(e,t){this.getCloudViewer().modelManager.getModel(this.modelId).loadFeatureLabel(e,t)}}t.BimModel=n}();class Ns extends Vs{constructor(e){e.typeName=e.typeName,e.id=c.assertType(e.id,"str")||c.assertType(e.id,"num")?e.id:e.modelId,e.priority=e.priority||3,e.isVisible=null==e.isVisible||e.isVisible,e.enableBorderLine=!!e.enableBorderLine||!(!e.style||!0!==e.style.wireframe),e.maxDetailLevel=c.assertType(e.maxDetailLevel,"num")?e.maxDetailLevel:void 0,e.visualRange=e.visualRange,e.disableUserData=!0===e.disableUserData,e.metaData=e.metaData,e.coordinateSystem=e.coordinateSystem,e.castShadow=!!e.castShadow,e.receiveShadow=!!e.receiveShadow,e.transformation=e.transformation||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],!0===e.enableBorderLine&&(e.wireFrameVisibilityOption=!0),super(e),this._config=e,this.modelId=e.modelId,this.customId=e.customId,this.loaded=!1!==e.isVisible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.presetWireFrameVisible=e.enableBorderLine}init(){const t=this._config;if(!t.viewToken&&!t.modelId&&!t.databagId)return(new e.Web.Common.Console).warn("Invalid Layer Config"),void this.getParent().remove(this);this.loadStatus="inited",!1!==this.loaded?this.loadModel(t):this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,this.layerId)}destroy(t=!0){if("destroyed"!==this.loadStatus&&(this.loadStatus="destroyed",this._modelAddedCallback&&this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,this._modelAddedCallback),this.model&&this.model.destroy(),this.model=void 0,t&&this.getParent())){let e=[],t=this.getParent();for(;t;)e.push(t.id),t=t.getParent();e.reverse().splice(0,2);let i=this.getViewer()._config.resources;if(e.length>0)for(;e.length>0;){let[t]=i.filter((t=>t.id===e[0]));if(!t||!t.children){i=void 0;break}i=t.children,e.splice(0,1)}if(i){let[e]=i.filter((e=>e.id===this.id));if(e){let t=i.indexOf(e);i.splice(t,1)}}this.getParent()&&this.getParent().remove(this)}}getMetaDataByViewToken(t,i,n){const o=this.getViewer();let s=e.Bimface.Authentication.AuthenticationManager,r=new e.Bimface.Authentication.AuthenticationConfig;r.viewToken=t,r.APIHost=o._opt.APIHost,new s(r).authenticate(i,n)}initSetting(){const e=this._config,t=e.shadow,i=e.style,n=e.maxDetailLevel;e.visualRange;t&&CLOUD.Utils.isDefined(t.castShadow)&&this.enableCastShadow(t.castShadow),t&&CLOUD.Utils.isDefined(t.receiveShadow)&&this.enableReceiveShadow(t.receiveShadow),i&&CLOUD.Utils.isDefined(i.opacity)&&this.setOpacity(i.opacity),n&&CLOUD.Utils.isDefined(n)&&this.setMaxDetailLevel(n),i&&i.enableVisualRange&&CLOUD.Utils.isDefined(i.visualRange)&&this.setVisualRange(i.visualRange)}_onLayerLoaded(){this.loadStatus="loaded",this.getViewer()._getLayerLoadedHandlerList().forEach((e=>"loaded"===e.status&&e.handler&&e.handler(this))),this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.LayerAdded,{layerId:this.id,layerName:this.name,layerType:this.typeName,modelId:this.modelId})}loadModel(t){const i="bimTiles",n=this._getModelLoadConfig(t.transformation);null!=t.layerVersion&&(this.layerVersion=t.layerVersion),this.loadStatus="loading";const o=t=>{this.databagId=t.databagId,this.modelId=t.modelId,this.modelType=t.modelType,this.isVisible=null==t.isVisible||t.isVisible,"point"!==this._config.featureType?(t.customId&&(n.modelId=t.customId),this.model=new e.Bimface.Earth.Model.BimModel(this.getViewer(),t,i,n,this),this._modelAddedCallback=t=>{if(this.getId()===t){if(this.model.setVisible(this.isVisible),this.initSetting(),this.loadStatus="rendered","shp"===this.model.getModelContent()){let t={lineHeight:0,transformMatrix:new THREE.Matrix4};const i=this.getTransformation();if(t.lineHeight=i[14],1===i[0]&&1===i[5]&&1===i[10]){const e=Math.cos(THREE.Math.degToRad(this.getViewer().getBasePoint().lat)),n=(new THREE.Matrix4).makeScale(e,e,e);t.transformMatrix.fromArray(i).multiply(n),this.setTransformation(t.transformMatrix.elements)}this.lineModel=new e.Bimface.Model.LineModel(this.getViewer(),this,t)}this.getViewer()._getLayerLoadedHandlerList().forEach((e=>"rendered"===e.status&&e.handler&&e.handler(this))),this._config.disableUserData||this._onLayerLoaded()}},this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,this._modelAddedCallback)):this.model=new e.Bimface.Model.PointModel(this.getViewer(),t,i,n,this)},s=e=>(t.customId?this.customId=e.customId=t.customId:this.getViewer().getModels().map((e=>e.modelId.toString())).indexOf(e.modelId.toString())>=0?this.customId=e.customId=this.id:this.customId=void 0,e);if(this.viewToken=t.viewToken,t.databagId){const e={databagId:t.databagId,metaData:this.getViewer()._opt.disableConfigCache?void 0:t.config&&t.config.metadata,coordinateSystem:t.config&&t.config.coordinateSystem,modelId:t.modelId,modelType:t.modelType,viewToken:t.viewToken||this.getViewer()._data.viewToken,isVisible:this.isVisible||t.isVisible,name:t.name,renderType:"3DView",renderVersion:"3.0",count:t.config&&t.config.count};s(e),t.config&&t.config.metadata&&"point"===t.config.metadata.FeatureType&&(this._config.featureType=t.config.metadata.FeatureType),o(e)}else t.viewToken&&this.getMetaDataByViewToken(this.viewToken,(e=>{s(e),e=Object.assign({},e,{isVisible:this.isVisible||t.isVisible}),o(e)}),(t=>{this.getViewer().getEventManager().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.Error,t),console.log(t)}))}_getModelLoadConfig(e){let t={zoomAll:!1,enableBorderLine:!!this._config.enableBorderLine||!(!this._config.style||!0!==this._config.style.wireframe),maxDetailLevel:this._config.maxDetailLevel,visualRange:this._config.visualRange,onDemand:this._config.onDemand,condition:this._config.condition,wireFrameVisibilityOption:this._config.componentsFrame,disableUserData:this._config.disableUserData,castShadow:!!this._config.castShadow,receiveShadow:!!this._config.receiveShadow};return t.transformMatrix=new THREE.Matrix4,t}debugShowGeometricError(e){let t=this.getViewer().getViewer().getModelManager().getModel(this.modelId);t&&t.debugShowGeometricError(e)}getRootGeoErrDistance(){return this.model&&this.model.getRootGeoErrDistance()}getCoordinateSystem(e){this.model._getMetaDataManager().getModelInfo((t=>{t.coordinateSystem&&e(t.coordinateSystem),t.coordinateSystems&&e(t.coordinateSystems)}),(t=>{e(t)}))}getManifest(e){this.model._getMetaDataManager().getManifest((t=>{e(t)}),(t=>{e(t)}))}getCurrentVersion(){return this.layerVersion}update(e){this.destroy(!1);let t={transformation:null,isVisible:!0};e.viewToken||e.databagId?Object.assign(t,e):Object.assign(t,this._config,e),this._config=t,this.loadModel(t)}getBoundingBox(){let e=this._getModel().getBoundingBoxWorld();return{min:this.getViewer().worldToLatLon(e.min),max:this.getViewer().worldToLatLon(e.max)}}getBoundingBoxWorld(){return this._getModel().getBoundingBoxWorld()}show(){super.show(),"loading"!==this.loadStatus&&(this.lineModel&&!0===this.lineModel.loaded&&this.lineModel.getOutlineVisible()&&this.lineModel.setVisible(this.isVisible),!0!==this.loaded?(this.loaded=!0,this.init()):this.model.setVisible(this.isVisible))}hide(){this.model&&this.model.setVisible(!1),this.lineModel&&this.lineModel.setVisible(!1),super.hide()}getPositionWorld(){return this.model.getPositionWorld()}setPositionWorld(e){this.model.setPositionWorld(e)}getTransformation(){return this.model.getModelTransformationAdaptedUnit()}setTransformation(e){this.model.setModelTransformation(e)}setTranslation(e){this.model.setModelTranslation(e)}setRotationZ(e,t){this.model.setModelRotationZ(e,t)}setScale(e,t){"x"in e||(e=this.getViewer().latLonToWorld(e)),this.model.setModelScale(e,t)}getBoundaryPoints(){return this._getModel().getBoundaryPoints()}setOpacity(e){e=CLOUD.Utils.isDefined(e)?e:1;let t=Math.min(e,1);t=Math.max(t,0),this._config.opacity=t;let i=this._getModel();i&&i.materialManager&&i.materialManager.setMaterialsOpacity(t)}setExposureCompensation(e){if(isNaN(e))return void console.warn("the exposure compensation input is not a number");if(e<-1||e>1)return void console.warn("the exposure compensation must in [-1, 1]");let t=this._getModel();t&&t.materialManager&&t.setExposureShift(e)}getExposureCompensation(){let e=this._getModel();if(e&&e.materialManager)return e.getExposureShift()}getCategory(){return this._config.category}setCategory(e){this._config.category=Object.assign({},this._config.category,e)}enableCastShadow(e){let t=this._getModel();t&&(t.setCastShadow(e),this.castShadow=e)}isCastShadowEnabled(){return this.castShadow}enableReceiveShadow(e){let t=this._getModel();t&&(t.setReceiveShadow(e),this.receiveShadow=e)}isReceiveShadowEnabled(){return this.receiveShadow}loadBusinessResources(e){if(this._businessResourcesLoaded||!this._config.disableUserData)return;this._businessResourcesLoaded=!0;const t=()=>{this._onLayerLoaded(),e&&e()};requestAnimationFrame((()=>{let e=this._getModel();e&&e.loadBusinessResources&&e.loadBusinessResources(t)}))}getObjectData(){return this.model.getObjectData()}getMaxDetailLevel(){return this.model?this.model.getMaxDetailLevel():this._config.maxDetailLevel}setMaxDetailLevel(e){this._config.maxDetailLevel=e,"point"!==this._config.featureType&&this.model&&this.model.setMaxDetailLevel(e)}setVisualRange(e){this._config.visualRange=e,this.model&&this.model.setVisualRange(e)}getVisualRange(){return this._config.visualRange}setGeometryErrorRatio(e){null!=this.model&&this.model.setDetailRatio(e)}getGeometryErrorRatio(){if(null!=this.model)return this.model.getDetailRatio()}getOpacity(){return this._config.opacity}getId(){return super.getId()}setLocation(e){if(c.assertType(e,"obj")){let t;t=c.assertParamsType(e.x,e.y,e.z,"num")?e:this.getViewer().latLonToWorld(e),this.model.setPositionWorld(t)}}getLocation(){const e=this.model.getPositionWorld();return this.getViewer().worldToLatLon(e)}getExplosionExtent(){return 0}getModelId(){return this.customId||this.modelId}_getModel(){return this.getViewer().getViewer().getModelManager().getModel(this.getModelId())}}class Gs extends _s{constructor(e,t){super({id:e,name:e,typeName:e,userData:e}),this._layer=t}}class js extends Gs{constructor(e){super("RoomManager",e)}}class zs extends Gs{constructor(e,t){super(e,t)}_executeByCondition(e,t){if(!e)return;const i=this._getDataUtil();(e=this._parseCondition(e)).all?i.assertType(t.all,"func")&&t.all():(e.objectData&&e.objectData.length>0&&i.assertType(t.objectData,"func")&&t.objectData(e.objectData),e.ids&&e.ids.length>0&&i.assertType(t.ids,"func")&&t.ids(e.ids),e.noObjectData&&e.noObjectData.length>0&&i.assertType(t.noObjectData,"func")&&t.noObjectData(e.noObjectData),e.noIds&&e.noIds.length>0&&i.assertType(t.noIds,"func")&&t.noIds(e.noIds))}_parseCondition(e){let t;const i=this._getDataUtil();if(i.assertType(e,"str"))t=this._codeToCondition(e);else if(i.assertType(e,"arr")){let n=[],o=[];e.forEach((e=>{i.assertType(e,"obj")?o.push(e):n.push(e)})),t={ids:n,objectData:o}}else i.assertType(e,"obj")&&(t=e);return t}_codeToCondition(e){let t=[],i=[],n=[],o=[];if(this._getDataUtil().assertType(e,"str")){e.split(" ").forEach((e=>{if(0===e.length)return;const s={ids:i,objectData:o};let r={ids:t,objectData:n};"!"===e[0]&&(e=/!(.*)/.exec(e)[1],r=s),(e=>{switch(e[0]){case"#":const t=/#(.*)/.exec(e)[1];r.ids.push(t);break;case"(":let i=/\((.*?)\)(.*)/.exec(e);if(i){const[e,t,n]=i;let o={};o[t]=n,r.objectData.push(o)}}})(e)}))}return{ids:t,noIds:i,objectData:n,noObjectData:o}}getBoundingBox(e){const t=this._layer.model;let i,n=[],o=!1;const s={all:()=>{o=!0},objectData:e=>{n=n.concat(t.getMatchIds(e))},ids:e=>{n=n.concat(e)}};return this._executeByCondition(e,s),o?i=this._layer.getBoundingBox():(i=t.getBoundingBoxByIds(n),i={min:this._layer.model.getViewer().worldToLatLon(i.min),max:this._layer.model.getViewer().worldToLatLon(i.max)}),i}show(e){const t=this._layer.model,i={all:()=>t.showAllComponents(),objectData:e=>t.showComponentsByObjectData(e),ids:e=>t.showComponentsById(e),noObjectData:e=>t.hideComponentsByObjectData(e),noIds:e=>t.hideComponentsById(e)};this._executeByCondition(e,i)}hide(e){const t=this._layer.model,i={all:()=>t.hideAllComponents(),objectData:e=>t.hideComponentsByObjectData(e),ids:e=>t.hideComponentsById(e),noObjectData:e=>t.showComponentsByObjectData(e),noIds:e=>t.showComponentsById(e)};this._executeByCondition(e,i)}select(e){const t=this._layer.model,i={all:()=>t.addSelectedComponentsByObjectData([]),objectData:e=>t.addSelectedComponentsByObjectData(e),ids:e=>t.addSelectedComponentsById(e),noObjectData:e=>{},noIds:e=>t.removeSelectedId(e)};this._executeByCondition(e,i)}clearSelection(){this._layer.model.clearSelectedComponents()}clearSelected(){this.clearSelection()}overrideColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsColorByObjectData([],t),objectData:e=>i.overrideComponentsColorByObjectData(e,t),ids:e=>i.overrideComponentsColorById(e,t),noObjectData:e=>i.restoreComponentsColorByObjectData(e),noIds:e=>i.restoreComponentsColorById(e)};this._executeByCondition(e,n)}restoreColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsColorByObjectData([]),objectData:e=>t.restoreComponentsColorByObjectData(e),ids:e=>t.restoreComponentsColorById(e)};this._executeByCondition(e,i)}overrideFrameColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsFrameColorByObjectData([],t),objectData:e=>i.overrideComponentsFrameColorByObjectData(e,t),ids:e=>i.overrideComponentsFrameColorById(e,t),noObjectData:e=>i.restoreComponentsFrameColorByObjectData(e),noIds:e=>i.restoreComponentsFrameColorById(e)};this._executeByCondition(e,n)}restoreFrameColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsFrameColorByObjectData([]),objectData:e=>t.restoreComponentsFrameColorByObjectData(e),ids:e=>t.restoreComponentsFrameColorById(e)};this._executeByCondition(e,i)}blink(e,t,i,n){const o=this._layer.model;o.getCloudViewer().enableBlinkComponents(!0);const s={ids:e=>o.addBlinkComponentsById(e,{color:t,interval:i,times:n}),objectData:e=>o.addBlinkComponentsByObjectData(e,{color:t,interval:i,times:n})};this._executeByCondition(e,s)}clearAllBlinkComponents(){this._layer.model.clearAllBlinkComponents()}clearBlinkComponents(e){const t=this._layer.model,i={ids:e=>t.clearBlinkComponentsById(e),objectData:e=>t.clearBlinkComponentsByObjectData(e)};this._executeByCondition(e,i)}isolate(e){const t=this._layer.model,i={objectData:e=>t.isolateComponentsByObjectData(e),ids:e=>t.isolateComponentsById(e)};this._executeByCondition(e,i)}clearIsolation(){this._layer.model.clearIsolation()}setGlowEffectById(e,t){this._layer.model.setGlowEffectById(e,t)}removeGlowEffectById(e){this._layer.model.removeGlowEffectById(e)}clearGlowEffect(){this._layer.model.clearGlowEffect()}setStyle(e,t){const i=this._layer.model;let n=[];const o={all:()=>{n=n.concat(i.getMatchIds([]))},objectData:e=>{n=n.concat(i.getMatchIds(e))},ids:e=>{n=n.concat(e)}};this._executeByCondition(e,o);let s={color:parseInt(t.color.getHEX(),16)};const r=((e,t)=>{const n=i.getCloudViewer().domElement;e.viewportSize=new THREE.Vector2(n.offsetWidth,n.offsetHeight);let o=null;switch(t.fillType){default:case"color":o="fullFill";break;case"grid":switch(t.direction){default:case 0:case 2:o="orthogonalCrossLine";break;case 1:case 3:o="skewCrossLine"}break;case"stripe":switch(t.direction){default:case 0:o="horizontalLine";break;case 1:o="rightDiagonalLine";break;case 2:o="verticalLine";break;case 3:o="leftDiagonalLine"}}return o})(s,t);s.fillMap=CLOUD.MaterialUtil.loadFillMap(r,2);const a=CLOUD.MaterialUtil.createStandardMaterial(s,!1);a.name=`${t.color.getRGB()}${t.fillType}${t.direction}${t.width}`,i.overrideComponentsMaterialById(n,a)}restoreStyle(e){const t=this._layer.model;let i=[];const n={all:()=>{i=i.concat(t.getMatchIds([]))},objectData:e=>{i=i.concat(t.getMatchIds(e))},ids:e=>{i=i.concat(e)}};this._executeByCondition(e,n),t.restoreComponentsMaterialById(i)}getObjectDataById(e){if(this._layer&&"loaded"===this._layer.loadStatus)return this._layer.model.getObjectDataById(e)}}class Fs extends zs{constructor(e){super("ComponentManager",e)}isolate(e,t){const i=this._layer.model,n={ids:this._getDataUtil().assertType(e.ids,"arr")?[...e.ids]:[],objectData:this._getDataUtil().assertType(e.objectData,"arr")&&e.objectData.length>0?[...e.objectData]:void 0,all:e.all};n.objectData&&(n.ids=n.ids.concat(i.getMatchIds(n.objectData)));const o={all:()=>i.clearIsolation(),ids:e=>i.isolateComponentsById(e,t)};this._executeByCondition(n,o)}clearIsolation(){this.isolate({all:!0})}overrideOpacity(e,t){const i=this._layer.model,n={all:()=>i._overrideAllComponentsOpacityByObjectData([],t),objectData:e=>i.overrideComponentsOpacityByObjectData(e,t),ids:e=>i.overrideComponentsOpacityById(e,t),noObjectData:e=>i.overrideComponentsOpacityByObjectData(e,1),noIds:e=>i.overrideComponentsOpacityById(e,1)};this._executeByCondition(e,n)}restoreOpacity(e){const t=this._layer.model,i={all:()=>t._restoreAllComponentsOpacityByObjectData([]),objectData:e=>t.restoreComponentsOpacityByObjectData(e),ids:e=>t.restoreComponentsOpacityById(e)};this._executeByCondition(e,i)}transparent(e){const t=this._layer.model;t.opaqueAllComponents();const i={all:()=>t.transparentComponentsByObjectData([]),objectData:e=>t.transparentComponentsByObjectData(e),ids:e=>t.transparentComponentsById(e),noObjectData:e=>t.opaqueComponentsByObjectData(e),noIds:e=>t.opaqueComponentsById(e)};this._executeByCondition(e,i)}deactivate(e){const t=this._layer.model;t.activateAllComponents();const i={all:()=>t.deactivateComponentsByObjectData([]),ids:e=>t.deactivateComponentsById(e),objectData:e=>t.deactivateComponentsByObjectData(e)};this._executeByCondition(e,i)}setFrameVisibility(e){this.wireFrameVisibilityOption=e}getFrameVisibility(){return this.wireFrameVisibilityOption}getComponentsBySetId(e,t){this._layer.model.getComponentsBySetId(e,t)}getSetByComponentId(e,t){this._layer.model.getSetByComponentId(e,t)}overrideFrameColor(e,t){const i=this._layer.model,n={all:()=>i.overrideComponentsFrameColorByObjectData([],t),objectData:e=>i.overrideComponentsFrameColorByObjectData(e,t),ids:e=>i.overrideComponentsFrameColorById(e,t),noObjectData:e=>i.restoreComponentsFrameColorByObjectData(e),noIds:e=>i.restoreComponentsFrameColorById(e)};this._executeByCondition(e,n)}restoreFrameColor(e){const t=this._layer.model,i={all:()=>t.restoreComponentsFrameColorByObjectData([]),objectData:e=>t.restoreComponentsFrameColorByObjectData(e),ids:e=>t.restoreComponentsFrameColorById(e)};this._executeByCondition(e,i)}splitComponentByStretchedPlane(e,t){return this._layer.model.splitComponentByStretchedPlane(e,t)}splitComponentByPlane(e,t){return this._layer.model.splitComponentByPlane(e,t)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager").ComponentManager=Fs;class Ws{constructor(e){this.model=e.model,this.metaDataManager=this.model&&this.model._getMetaDataManager()}getCoordinateSystem(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getModelInfo((t=>{t.coordinateSystem&&e(t.coordinateSystem),t.coordinateSystems&&e(t.coordinateSystems)}),(t=>{e(t)}))}getManifest(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getManifest((t=>{e(t)}),(t=>{e(t)}))}getFloors(e){this.metaDataManager||layer.model._getMetaDataManager(),this.metaDataManager&&this.metaDataManager.getFloors((t=>{e(t)}),(t=>{e(t)}))}getModelTree(e){this.model&&this.model.getModelTree(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface").DataManager=Ws;const $s=e.Bimface.Data.StatisticsDataManager.getInstance();class Xs extends Ns{constructor(e){$s.send("Glodon.Bimface.Earth.Layer.BIMLayer","bf_c_bimLayer_new"),e.typeName="BIMLayer",e.castShadow=!!CLOUD.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!CLOUD.Utils.isDefined(e.receiveShadow)||e.receiveShadow,super(e)}init(){super.init(),this.elementManager.componentManager=new Fs(this),this.elementManager.roomManager=new js(this),this.getComponentManager=()=>this.elementManager.componentManager,this.getRoomManager=()=>this.elementManager.roomManager,this.dataManager=new Ws(this),this.getDataManager=()=>this.dataManager}getFloors(e){this.getDataManager().getFloors(e)}getFloorExplosionList(){return this.getViewer().getViewer().getFloorExplosionList(this.modelId)}getFloorExplosionDirection(){return this.getViewer().getViewer().getFloorExplosionDirection(this.modelId)}getFloorExplosionExtent(){return this.getViewer().getViewer().getFloorExplosionExtent(this.modelId)}setFloorExplosion(e,t,i){this.model&&this.model.setFloorExplosion(e,t,i)}clearFloorExplosion(){this.model&&this.model.clearFloorExplosion()}setWireframeVisible(e){this.presetWireFrameVisible=e,this._setWireframeVisibleByViewer(e)}_setWireframeVisibleByViewer(e){let t=this.getViewer().getViewer().getModelManager().getModel(this.modelId);t&&t.materialManager&&t.setBorderLineVisible(e)}isWireframeVisible(){let e=this.getViewer().getViewer().getModelManager().getModel(this.modelId);if(e&&e.materialManager)return e.isBorderLineVisible()}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").BIMLayer=Xs;class Ys extends zs{constructor(e,t){super(e,t)}getFeatureTypeName(){return this.typeName}getObjectDataById(e){return super.getObjectDataById(e)}setGlowEffectById(e,t){super.setGlowEffectById(e,t)}removeGlowEffectById(e){super.removeGlowEffectById(e)}clearGlowEffect(){super.clearGlowEffect()}}class Zs extends Ys{constructor(e){super("PolygonFeatureManager",e)}setOutlineStyle(e,t){const i=this._layer.lineModel;if(!i||!i.loaded)return void console.warn("No outline or not loaded");const n={all:()=>i.setStyleByObjectData([],t),objectData:e=>i.setStyleByObjectData(e,t),ids:e=>i.setStyleByIds(e,t)};this._executeByCondition(e,n)}restoreOutlineStyle(e){const t=this._layer.lineModel;if(!t||!t.loaded)return void console.warn("No outline");const i={all:()=>t.restoreStyleByObjectData([]),objectData:e=>t.restoreStyleByObjectData(e),ids:e=>t.restoreStyleByIds(e)};this._executeByCondition(e,i)}getArea(e){if(void 0===e)return;const t=this._layer.lineModel;if(t&&t.loaded)return t.getAreaById(e);console.warn("No outline or not loaded")}setStyle(e,t){super.setStyle(e,t)}restoreStyle(e){super.restoreStyle(e)}setOutlineVisible(e){const t=this._layer.lineModel;t&&t.loaded&&t.setOutlineVisible(e)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.ElementManager").PolygonFeatureManager=Zs;class qs extends Ys{constructor(e){super("LineFeatureManager",e)}show(e){return super.show(e)}hide(e){return super.hide(e)}overrideColor(e,t){return super.overrideColor(e,t)}restoreColor(e){return super.restoreColor(e)}overrideFrameColor(e,t){return super.overrideFrameColor(e,t)}restoreFrameColor(e){return super.restoreFrameColor(e)}blink(e,t,i,n){super.blink(e,t,i,n)}clearAllBlinkComponents(){super.clearAllBlinkComponents()}clearBlinkComponents(e){super.clearBlinkComponents(e)}getBoundingBox(e){return super.getBoundingBox(e)}select(e){return super.select(e)}clearSelectedFeatures(){return super.clearSelected()}}class Ks extends Ys{constructor(e){super("PointFeatureManager",e)}show(e){return super.show(e)}hide(e){return super.hide(e)}getIds(e){const t=this._layer.model;if(!t)return;let i=[];const n={all:()=>i=t.points.map((e=>e.id)),objectData:e=>i=t.getMatchIds(e)};return this._executeByCondition(e,n),i}getPosition(e){return this._layer.model.getPositionById(e)}getProperty(e){return this._layer.model.getPropertiesById(e)}setStyle(e,t){const i=this._layer.model,n={all:()=>i.setStyleByObjectData([],t),objectData:e=>i.setStyleByObjectData(e,t),ids:e=>i.setStyleById(e,t)};this._executeByCondition(e,n)}}var Qs=e.Bimface.Data.StatisticsDataManager.getInstance();class Js extends Ns{constructor(e){Qs.send("Glodon.Bimface.Earth.Layer.FeatureLayer","bf_c_featureLayer_new"),e.typeName="FeatureLayer",e.castShadow=!!CLOUD.Utils.isDefined(e.castShadow)&&e.castShadow,e.receiveShadow=!CLOUD.Utils.isDefined(e.receiveShadow)||e.receiveShadow,super(e)}init(){super.init(),this.elementManager.polygonFeatureManager=new Zs(this),this.getPolygonFeatureManager=()=>this.elementManager.polygonFeatureManager,this.elementManager.lineFeatureManager=new qs(this),this.getLineFeatureManager=()=>this.elementManager.lineFeatureManager,this.elementManager.pointFeatureManager=new Ks(this),this.getPointFeatureManager=()=>this.elementManager.pointFeatureManager,this.dataManager=new Ws(this),this.getDataManager=()=>this.dataManager}getLegend(e,t){if(!this.model)return;this.model._getMetaDataManager().getFeatureStyle(e,t)}initSetting(){super.initSetting();const t=this._config.style;if(t&&CLOUD.Utils.isDefined(t.color)){let i=new e.Web.Graphics.Color(t.color);CLOUD.Utils.isDefined(t.opacity)&&(i.alpha=t.opacity),this.getPolygonFeatureManager().overrideColor({all:!0},i)}}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").FeatureLayer=Js;class er extends Ns{constructor(t){e.Bimface.Data.StatisticsDataManager.getInstance().send("Glodon.Bimface.Earth.Layer.TilesetLayer","bf_c_tilesetLayer_new"),t.typeName="TilesetLayer",t.castShadow=!!CLOUD.Utils.isDefined(t.castShadow)&&t.castShadow,t.receiveShadow=!CLOUD.Utils.isDefined(t.receiveShadow)||t.receiveShadow,super(t),this.flatManager=null,this.clippingManager=null}init(){super.init(),this.dataManager=new Ws(this),this.getDataManager=()=>this.dataManager}isVisible(){return this.isVisible}getOpacity(){return this._config.opacity}getAltitude(e,t){if(null==e)return void console.warn("[BIMFACE WARNING]: Glodon.Bimface.Earth.Layer.TilesetLayer.prototype.getAltitude must have parameter 'latlon'");if(!e.hasOwnProperty("lat")||!e.hasOwnProperty("lon"))return void console.warn("[BIMFACE WARNING]: Glodon.Bimface.Earth.Layer.TilesetLayer.prototype.getAltitude must have parameter 'latlon.lat' and 'latlon.lon'");if(null==t)return void console.warn("[BIMFACE WARNING]: Glodon.Bimface.Earth.Layer.TilesetLayer.prototype.getAltitude must have parameter 'callback'");const i=this._getModel();i&&i.getAltitude(e,(function(e){null==e||null==e?console.warn("[BIMFACE WARNING]: The latitude and longitude are out of the data range."):Object.is(e,NaN)||Object.is(e,NaN)||Object.is(e,NaN)?console.warn("[BIMFACE WARNING]:The latitude and longitude are out of the data range."):t(e)}))}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").TilesetLayer=er;e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").ExternalObjectLayer=class extends Vs{constructor(t={}){e.Bimface.Data.StatisticsDataManager.getInstance().send("Bimface.Earth.Layer.ExternalObjectLayer","bf_c_extObjLayer_new"),t.name=t.name||"外部构件",t.typeName="ExternalObjectLayer",t.priority=t.priority||5,null==t.isVisible&&(t.isVisible=!0),super(t)}_createExternalObjectManager(){var t=this;t._externalObjectManager=new e.Bimface.Earth.ElementManager.ExternalObjectManager(t.getViewer(),t.getId())}_hasObjectId(e){return null!=this._externalObjectManager&&-1!==this._externalObjectManager.getAllObjectIds().indexOf(e)}getModelId(){return"ExternalComponent"}getId(){return this.id}getExternalObjectManager(){var e=this;return null==e._externalObjectManager&&null!=e.getViewer()&&(e._createExternalObjectManager(),e.isVisible?e.show():e.hide()),e._externalObjectManager}hide(){const e={ids:this.getExternalObjectManager().getAllObjectIds()};this.getExternalObjectManager().hide(e)}show(){const e={ids:this.getExternalObjectManager().getAllObjectIds()};this.getExternalObjectManager().show(e)}};const tr=e.Bimface.Data.StatisticsDataManager.getInstance();class ir extends Ns{constructor(e){tr.send("Glodon.Bimface.Earth.Layer.DrawingLayer","bf_c_drawingLayer_new"),e.typeName="DrawingLayer",super(e),void 0===this._config.opacity&&(this._config.opacity=1)}init(){super.init()}getId(){return super.getId()}show(){super.show()}hide(){super.hide()}getOpacity(){return super.getOpacity()}setOpacity(e){super.setOpacity(e)}getTransformation(){return super.getTransformation()}setTransformation(e){super.setTransformation(e)}setTranslation(e){super.setTranslation(e)}setRotationZ(e,t){super.setRotationZ(e,t)}setScale(e,t){super.setScale(e,t)}clampMode(e){let t=this.getViewer().getViewer().modelManager.modelCollection._layers;this.dwgLayer||t.map((e=>{e.fileId==this.modelId&&(this.dwgLayer=e)}));let i=[],n=!1;if(e.layerIds&&e.layerIds.map((e=>{let t=this.getViewer().getLayerManager().getLayer(e);t&&("TilesetLayer"==t.typeName&&i.push(t.model.modelId.toString()),"TileLayer"==t.typeName&&(n=!0))})),this.groundId&&(CLOUD.GroundDrawingManager.getInstance().deleteGroundDrawingById(this.groundId),this.groundId=null),e.mode){let o=[];"Ground"==e.mode?(t.map((e=>{e.isDemLayer&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)):"Model"==e.mode?(t.map((e=>{i.length>0?e.isObliquePhotography&&i.indexOf(e.id)>-1&&o.push(e):e.isObliquePhotography&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)):"Both"==e.mode&&(i.length>0||n?t.map((e=>{n&&e.isDemLayer&&o.push(e),e.isObliquePhotography&&i.indexOf(e.id)>-1&&o.push(e)})):t.map((e=>{(e.isObliquePhotography||e.isDemLayer)&&o.push(e)})),this.groundId=CLOUD.GroundDrawingManager.getInstance().createGroundDrawing(this.dwgLayer,o)),this.getViewer().render()}}showAllTexts(){let e=this.getViewer().getViewer().getModelManager().getModel(this.model&&this.model.modelId);e&&e.SetDwgTextState&&e.SetDwgTextState(!0)}hideAllTexts(){let e=this.getViewer().getViewer().getModelManager().getModel(this.model&&this.model.modelId);e&&e.SetDwgTextState&&e.SetDwgTextState(!1)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Layer").DrawingLayer=ir;class nr{constructor(e){this.getLayerManager=()=>e,this.getViewer=e.getViewer,this._allModelInited=!1}buildLayers(t){let i,n,o={},s=[],r=[],a=this.getViewer();const l=t=>{switch(t.typeName){case"GroupLayer":const h=new As(t);t.parent.add(h),t.children&&t.children.length>0&&t.children.forEach((e=>{e.parent=h,l(e)}));break;case"TileLayer":let d={};d.id=t.id,d.provider=t.provider,d.name=t.name,d.credit=t.credit,d.style=t.style,d.shadow=t.shadow,d.maxLevel=t.maxLevel,d.isVisible=!1!==t.isVisible,d.sectionable=!0===t.sectionable,d.tileLayerParent=t.parent,t.layerConfig&&(d.layerConfig=t.layerConfig),this._isValidUrl(t.url)&&(d.url=t.url),s.push(d);break;case"TerrainLayer":this._isValidUrl(t.url)?(o.useTerrain=!1!==t.isVisible,o.terrainPath=t.url,o.terrainViewToken=t.viewToken,o.modelId=t.modelId,o.databagId=t.databagId,o.terrainViewToken=t.viewToken,i=t.parent,n={id:t.id,name:t.name,isVisible:t.isVisible}):(o.useTerrain=!1!==t.isVisible,o.terrainPath=e.Bimface.Plugins.TileMap.Tile.getTerrainRootPath(this.getViewer()._opt.resourceHost),i=t.parent,n={id:t.id,name:t.name,isVisible:t.isVisible});break;case"BIMLayer":case"DrawingLayer":case"FeatureLayer":(t.viewToken||t.modelId&&t.databagId)&&(t.style&&t.style.color?t.disableUserData=!1:t.isVisible&&(t.disableUserData=CLOUD.Utils.isDefined(t.disableUserData)?t.disableUserData:a.disableUserData),r.push(t));break;case"TilesetLayer":(t.viewToken||t.modelId&&t.databagId)&&r.push(t)}};if("[object Array]"===Object.prototype.toString.call(t)){t={id:"root",name:"root",typeName:"GroupLayer",children:t}}t.parent=this.getLayerManager(),l(t);for(let e=0;e<s.length;e++)s[e].useTerrain=o.useTerrain,s[e].terrainPath=o.terrainPath,s[e].terrainViewToken=o.terrainViewToken,s[e].modelId=o.modelId,s[e].databagId=o.databagId,s[e].terrainViewToken=o.terrainViewToken;if(o.databagId)this.loadTerrainConfig(o.databagId,s,(()=>{this.startLoad(s,n,i,r)}));else if(o.terrainViewToken){const t=this.getViewer();let a=e.Bimface.Authentication.AuthenticationManager,l=new e.Bimface.Authentication.AuthenticationConfig;l.viewToken=o.terrainViewToken,l.APIHost=t._opt.APIHost,(this.authenticate=new a(l)).authenticate((e=>{this.loadTerrainConfig(e.databagId,s,(()=>{this.startLoad(s,n,i,r)}))}),(e=>{console.log("the invalid terrain viewtoken"),s.map((e=>e.useTerrain=!1)),this.startLoad(s,void 0,i,r)}))}else this.startLoad(s,n,i,r)}loadTerrainConfig(e,t,i){const n=this.getViewer(),o=`${n._opt.resourceHost}/${e}/resource/v3/model/config.json`;t.map((t=>t.terrainPath=`${n._opt.resourceHost}/${e}/resource/v3/model/terrain/`));let s=new THREE.FileLoader;s.setResponseType("json"),s.load(o,(e=>{t.map((t=>t.terrainOnlineConfig=e.metadata)),i&&i()}))}startLoad(t,i,n,o){for(let e=t.length-1;e>=0;e--)if(t[e].tileLayerParent){let i=new ks(t[e]);t[e].tileLayerParent.add(i)}this.getViewer().firstTileLayerId=t[0].id,i&&(i.baseMap=this.getLayerManager().baseMap,this.getLayerManager().terrainLayer=new Us(i),n.add(this.getLayerManager().terrainLayer)),this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.SceneAdded,(()=>{this.getViewer().initModelSync?this._loadModelSync(o):this._loadModelAsyn(o)}))}_loadModelSync(t){if(t.length>0){let i;const n=()=>{if(t.length>0){let e=this.getViewer().getViewer().getCamera();e!==i&&this.sortModel(t),i=e;const[n]=t.splice(0,1);let o=null;switch(n.typeName){case"BIMLayer":default:o=new Xs(n);break;case"FeatureLayer":o=new Js(n);break;case"TilesetLayer":o=new er(n);break;case"DrawingLayer":o=new ir(n)}n.parent.add(o)}else this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer .DrawingLayer").forEach((e=>e.isVisible&&e.loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.removeEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),this._allModelInited=!0,this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.AllModelInited)};this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.addEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),n()}}_loadModelAsyn(t){this.sortModel(t);let i=t.length;const n=()=>{--i,0===i&&(this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer .DrawingLayer").forEach((e=>e.isVisible&&e.loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.removeEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n),this._allModelInited=!0,this.getViewer().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.AllModelInited))};for(this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,n),this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelInitedWithoutLoad,n),this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAddFailed,n),this.getViewer().getViewer().modelManager.addEventListener(CLOUD.EVENTS.ON_LOAD_INVALID_SCENE,n);t.length>0;){const[e]=t.splice(0,1);let i=null;switch(e.typeName){case"BIMLayer":default:i=new Xs(e);break;case"FeatureLayer":i=new Js(e);break;case"TilesetLayer":i=new er(e);break;case"DrawingLayer":i=new ir(e)}e.parent.add(i)}}sortModel(e,t){t=t||{},e.forEach((e=>{if(!e.box3&&e.boundingBox&&e.boundingBox.min&&e.boundingBox.max){let{x:t,y:i,z:n}=this.getViewer().worldToScene(e.boundingBox.min),{x:o,y:s,z:r}=this.getViewer().worldToScene(e.boundingBox.max);e.box3=new THREE.Box3(new THREE.Vector3(t,i,n),new THREE.Vector3(o,s,r))}})),e.sort(((e,i)=>{let n=e.isVisible,o=i.isVisible;if(!1!==t.visible&&n!==o)return n?-1:1;if(!1===t.visible||n){if(!1!==t.priority){let t=e.priority||3,n=i.priority||3;if(t!==n)return t-n}if(!1!==t.boundingBox){if(!i.box3)return-1;if(!e.box3)return 1;let t=this.getViewer().getViewer().camera.frustum;if(!t.intersectsBox(i.box3))return-1;if(!t.intersectsBox(e.box3))return 1;let n=this.getViewer().getViewer().camera.position.clone();return e.box3.distanceToPoint(n)-i.box3.distanceToPoint(n)}}}))}loadLayer(t,i=!1){if(this._allModelInited){if(t instanceof Array){let n=[];if(t.forEach((e=>{let t=this.getLayerManager().getLayer(e);t&&(t.loaded?i&&t.show():(t._config.disableUserData=!0,n.push(t._config)))})),n.length>0){this.sortModel(n,{visible:!1});let t=n.length,o=0,s=n.map((e=>e.id));const r=a=>{s.includes(a)&&(o++,i||this.getLayerManager().getLayer(a).hide()),o===t&&(n.forEach((e=>this.getLayerManager().getLayer(e.id).loadBusinessResources())),this.getViewer().removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,r))};this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,r),n.forEach((e=>this.getLayerManager().getLayer(e.id).show()))}}}else this.getViewer().addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.AllModelInited,(()=>this.loadLayer(t)))}showLayers(e){this.loadLayer(e,!0)}_isValidUrl(e){return!!e&&/(https?):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/.test(e)}}class or extends _s{constructor(e){super({id:"LayerManager",name:"LayerManager",typeName:"LayerManager",userData:"LayerManager",viewer:e});let t=new nr(this);this.getLoadManager=()=>t}getLayerConfigsObject(){let e=[],t=this.getViewer()._config.resources;if(t){let i=this.getRootLayer(),n={id:i.id,name:i.name,typeName:i.typeName,isVisible:i.isVisible,children:t};e.push(n)}const i=(e,t)=>{const{id:n,name:o,typeName:s,isVisible:r}=e;let a={id:n,name:o,typeName:s,isVisible:r,parentId:e.parent?e.parent.id:""};if("GroupLayer"!=s&&(a.priority=e.priority),"BIMLayer"===s||"FeatureLayer"===s||"TilesetLayer"===s||"DrawingLayer"===s){if("destroyed"===e.loadStatus)return;if(a.modelId=e.modelId,a.modelType=e.modelType,e.viewToken&&(a.viewToken=e.viewToken),e.databagId&&(a.databagId=e.databagId),e.model){let t=e.model.getModelTransformationAdaptedUnit();a.transformation=t?[...t]:void 0}}if(t instanceof Array){let[e]=t.filter((e=>e.id===a.id));if(e){for(let t in a)a.hasOwnProperty(t)&&void 0!==a[t]&&(e[t]=a[t]);a=e}else t.push(a)}e.children.length>0&&(a.children=a.children||[],e.children.forEach((e=>{i(e,a.children)})))};return i(this.getRootLayer(),e),1===e.length?e[0]:e.length>1?e:void 0}buildLayers(e){return this.getLoadManager().buildLayers(e)}showLayers(e){return this.getLoadManager().showLayers(e)}getRootLayer(){if(0===this.children.length){const e=new As({id:"root",name:"root"});this.add(e)}return this.children[0]}getLayer(e){const[t]=this.query(`#${e}`);return t}getLayerByType(e){return this.query({typeName:e})}addLayer(e,t){(this.getLayer(t)||this.getRootLayer()).add(e)}removeLayer(e){const t=this.getLayer(e);if(t&&t.parent.remove(t),"GroupLayer"===t.typeName&&"root"!==e&&t.getParent()){let i=[],n=t.getParent();for(;n;)i.push(n.id),n=n.getParent();i.reverse().splice(0,2);let o=this.getViewer()._config.resources;if(i.length>0)for(;i.length>0;){let[e]=o.filter((e=>e.id===i[0]));if(!e||!e.children){o=void 0;break}o=e.children,i.splice(0,1)}if(o){let[t]=o.filter((t=>t.id===e));if(t){let e=o.indexOf(t);o.splice(e,1)}}}}removeLayerByCondition(e){this.query(e).forEach((e=>{e.parent.remove(e)}))}moveLayer(e,t){const i=this.getLayer(e),n=this.getLayer(t);i&&n&&(i.parent.children.splice(i.parent.children.indexOf(i),1),n.children.push(i),i.parent=n)}zoomToLayer(e,t){const i=this.getLayer(e);if(i&&i.model){let e=i.model.modelId,n=this.getViewer().getViewer().getModelManager().modelCollection.getById(e).getBoundingBoxWorld(),o={};o.boundingBox=n,o.margin=.5,o.duration=1e3,this.getViewer().zoomToBoundingBox(o,this._getDataUtil().assertType(t,"func")?t:void 0)}if(i&&"ExternalObjectLayer"===i.typeName){let e=i.getExternalObjectManager().getBoundingBoxWorld();if(e.isEmpty())return;let n={};n.boundingBox=e,n.margin=.5,n.duration=1e3,this.getViewer().zoomToBoundingBox(n,this._getDataUtil().assertType(t,"func")?t:void 0)}}setLayerPriority(e,t){let i=this.getLayer(e);i&&(i.priority=t)}getLayerPriority(e){let t=this.getLayer(e);if(t)return t.priority}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Layer").LayerManager=or;class sr{constructor(t){this._viewer=t;const i=e.Web.Lang.Utility.DataUtil;this.dataUtil=i,this._panFactor=3e5}init(){if(!this._viewer.getLayerManager().baseMap)return;const e=this.getCloudViewer().cameraControl;e.maxPitch=Math.PI/2,e.minPitch=-Math.PI/2;const t=this._viewer._config,i=t.homeView.position;let n=this._viewer.latLonToWorld({lat:i.lat,lon:i.lon,alt:i.alt});const o=t.homeView.orientation,s=o.yaw;let r=o.pitch;r>=Math.PI/2&&(r=Math.PI/2-Math.PI/1e3),r<=-Math.PI/2&&(r=Math.PI/1e3-Math.PI/2),this.setYawPitch({position:n,yaw:s,pitch:r},!0,(()=>{this.defaultHomeview=this.getCameraStatus()}))}getYawPitch(){let e=this._viewer.getViewer().camera.pitch;return{yaw:this._viewer.getViewer().camera.heading,pitch:e}}setYawPitch(e,t=!0,i){const n=this.getCameraStatus();e.position&&(n.position=e.position),n.orientation={heading:e.yaw,pitch:e.pitch,roll:0},this.setCameraStatus(n,i||void 0,t)}panInUpAndDown(e){const t=this.getCameraStatus(),i=new THREE.Vector3(t.target.x,t.target.y,t.target.z),n=new THREE.Vector3(t.position.x,t.position.y,t.position.z);let o=this.getCloudViewer().camera.rightDir,s=Math.sqrt(this.getCameraStatus().position.x*this.getCameraStatus().position.x+this.getCameraStatus().position.y*this.getCameraStatus().position.y+this.getCameraStatus().position.z*this.getCameraStatus().position.z),r=(new THREE.Quaternion).setFromAxisAngle(o,(e?1:-1)*this.getRatio(s)),a=new THREE.Matrix4;a.makeRotationFromQuaternion(r);let l=a.clone().invert(),h=n.clone().applyMatrix4(l),d=i.clone().applyMatrix4(l);t.target=d,t.position=h,this.setCameraStatus(t,void 0,!0)}panInHorizontal(e){const t=this.getCameraStatus(),i=new THREE.Vector3(t.target.x,t.target.y,t.target.z),n=new THREE.Vector3(t.position.x,t.position.y,t.position.z);let o=Math.sqrt(this.getCameraStatus().position.x*this.getCameraStatus().position.x+this.getCameraStatus().position.y*this.getCameraStatus().position.y+this.getCameraStatus().position.z*this.getCameraStatus().position.z),s=this.getCloudViewer().camera.up,r=(new THREE.Quaternion).setFromAxisAngle(s,(e?1:-1)*this.getRatio(o)),a=new THREE.Matrix4;a.makeRotationFromQuaternion(r);let l=a.clone().invert(),h=n.clone().applyMatrix4(l),d=i.clone().applyMatrix4(l);t.target=d,t.position=h,this.setCameraStatus(t,void 0,!0)}getRatio(e){let t=636e4,i=638e4,n=11e6;if(e<=t)return Math.PI/45e5;if(e<=i){return(e-t)*(Math.PI/12e5-Math.PI/45e5)/2e4}if(e>=n)return Math.PI/2e3;return(e-i)*(Math.PI/2e3-Math.PI/12e5)/462e4}getCloudViewer(){return this._viewer.getViewer()}getCameraStatus(){const e=JSON.parse(this.getCloudViewer().getCamera());return e.coordinateSystem="world",e.orientation={pitch:this._viewer.getViewer().camera.pitch,yaw:this._viewer.getViewer().camera.heading,roll:0},e}setCameraStatus(e,t,i){let n=this.getCameraStatus();"object"==typeof e&&((e={...n,...e}).orientation.heading="number"==typeof e.orientation.heading?e.orientation.heading:e.orientation.yaw,delete e.orientation.yaw,e=JSON.stringify(e)),this.getCloudViewer().setCamera(e,!1,t,i),this.getCloudViewer().render()}recordCustomHomeview(e){this.customedHomeview=e}getCustomHomeview(){return this.customedHomeview}getDefaultHomeview(){return this.defaultHomeview}getHomeView(){return this.getCustomHomeview()||this.getDefaultHomeview()}setHomeView(e){this.recordCustomHomeview(e)}zoomIn(){this.getCloudViewer().cameraControl.zoom(.054,this._viewer.getDomElement().clientWidth/2,this._viewer.getDomElement().clientHeight/2),this._viewer.render()}zoomOut(){this.getCloudViewer().cameraControl.zoom(-.054,this._viewer.getDomElement().clientWidth/2,this._viewer.getDomElement().clientHeight/2),this._viewer.render()}zoomToBoundingBox(e,t){let i=e.boundingBox,n=null!=e.margin?e.margin:.5,o=null!=e.duration?e.duration:1e3;if(!i||!i.min||!i.max)return;const s=[[i.min.x,i.min.y,i.min.z],[i.max.x,i.max.y,i.max.z]];this.getCloudViewer().zoomToBBox(y.Utils.computeBBox(s),n,void 0,"[object Function]"===Object.prototype.toString.call(t)?t:void 0,o,e.direction)}}class rr{constructor(e){this.viewer=e,this.globalUnitUtil=e.globalUnitUtil,this._camera=new sr(e),this.console=e.console,P(this),this._editorConfig={NoZoom:CLOUD.EditorConfig.NoZoom,NoPan:CLOUD.EditorConfig.NoPan,NoRotate:CLOUD.EditorConfig.NoRotate}}getStatus(){let e=this._camera.getCameraStatus();return{orientation:e.orientation,position:this.viewer.worldToLatLon(e.position)}}setStatus(e,t){let i=JSON.parse(JSON.stringify(e));i.position=this.viewer.latLonToWorld(i.position),i&&this._camera.setCameraStatus(i,t)}getHomeView(){let e=this._camera.getHomeView();return{orientation:e.orientation,position:this.viewer.worldToLatLon(e.position)}}setHomeView(e){let t=JSON.parse(JSON.stringify(e));t.position=this.viewer.latLonToWorld(t.position),t&&this._camera.setHomeView(t)}restoreHomeView(){this._camera.setHomeView(this._camera.getDefaultHomeview())}home(){this.setStatus(this.getHomeView())}zoomIn(){this._camera.zoomIn()}zoomOut(){this._camera.zoomOut()}zoomToBoundingBox(e,t,i,n){let o,s=new Object;if(arguments[0]&&arguments[0].boundingBox){if(!(e=arguments[0].boundingBox)||!e.min||!e.max)return;return i=arguments[0].margin,n=arguments[0].duration,o=arguments[0].direction,void 0===i&&(i=.5),void 0===n&&(n=1e3),arguments[1]&&(t=arguments[1]),e={min:this.viewer.latLonToWorld(e.min),max:this.viewer.latLonToWorld(e.max)},s.boundingBox=e,s.margin=i,s.duration=n,s.direction=o,void this._camera.zoomToBoundingBox(s,t)}if(1===arguments.length)e=arguments[0];else if(2===arguments.length&&"[object Number]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],arguments[1]>100?(i=.5,n=arguments[1]):(i=arguments[1],n=1e3),t=void 0;else if(2===arguments.length&&"[object Function]"===Object.prototype.toString.call(arguments[1]))e=arguments[0],t=arguments[1],i=.5,n=1e3;else if(3===arguments.length){for(let e=0;e<arguments.length;e++){const o=arguments[e];"[object Function]"===Object.prototype.toString.call(o)?t=o:"[object Number]"===Object.prototype.toString.call(o)&&(o>100?n=o:i=o)}e=arguments[0],"[object Function]"!==Object.prototype.toString.call(t)&&(t=void 0),void 0===n&&(n=1e3),void 0===i&&(i=.5)}e={min:this.viewer.latLonToWorld(e.min),max:this.viewer.latLonToWorld(e.max)},s.boundingBox=e,s.margin=i,s.duration=n,this._camera.zoomToBoundingBox(s,t)}setCameraAnimation(t){if(this._animationOption&&this.clearCameraAnimation(),this._animationOption=t,!t.pathAnimation instanceof e.Bimface.Earth.Plugins.Animation.PathAnimation)return void this.console.warn("The parameter option.pathAnimation is not type of Glodon.Bimface.Earth.Plugins.Animation.PathAnimation.");let i=null==t.distance?5:t.distance,n=null==t.angle?0:t.angle;this._animationOption.distance=i,this._animationOption.angle=n;let o=this.viewer.getViewer().camera;t.pathAnimation._setCameraAnimation(o,i,n),this._editorConfig.NoZoom=CLOUD.EditorConfig.NoZoom,this._editorConfig.NoPan=CLOUD.EditorConfig.NoPan,this._editorConfig.NoRotate=CLOUD.EditorConfig.NoRotate,CLOUD.EditorConfig.NoZoom=!0,CLOUD.EditorConfig.NoPan=!0,CLOUD.EditorConfig.NoRotate=!0}getCameraAnimation(){return this._animationOption}clearCameraAnimation(){this._animationOption&&(this._animationOption.pathAnimation.camera=null,this._animationOption=null,CLOUD.EditorConfig.NoZoom=this._editorConfig.NoZoom,CLOUD.EditorConfig.NoPan=this._editorConfig.NoPan,CLOUD.EditorConfig.NoRotate=this._editorConfig.NoRotate)}}e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Camera").CameraGIS=rr,function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Viewer"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Viewer"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o="Glodon.Bimface.Earth.Viewer.ViewerGIS",s=e.Bimface.Data.StatisticsDataManager.getInstance(),r=e.Web.Lang.Utility.DataUtil;class a extends t.Viewer{constructor(t){s.send(o,"bf_c_viewerGIS_new"),window.bimfaceSdkVersion&&(s.send(o,"sdkVersion"),delete window.bimfaceSdkVersion),t.enableSSAO&&s.send("Glodon.Bimface.Earth.Viewer","ViewerGISConfig.enableSSAO"),super(),this.viewerType="ViewerGIS",this._opt=t,this._data={},this._beforeInitialize(t),this.console=new e.Web.Common.Console,this._models={},this._defaultModelType="bimtiles",this._defaultUnit="m",this._plugins={},this._layerLoadedHandlerList=[],this.enableStorage=t.enableStorage,this.bIsEnableSelectionChanged=!0,this.globalUnitUtil=new G(this),this.disableUserData=!y.Utils.isDefined(t.disableUserData)||t.disableUserData,this.initModelSync=!!y.Utils.isDefined(t.initModelSync)&&t.initModelSync;const i={sphereScene:!0,setupEarth:t.enableEarth,staticResourcesHost:t.staticResourcesHost,initialGeoCoordinates:t.initialGeoCoordinates,enableStorage:t.enableStorage,maxMemoryUsage:t.memoryThreshold,disableMapOcclusion:t.disableMapOcclusion,gisMode:!0};y.GlobalData.EnableAtmosphere=this._opt.enableAtmosphere,this._atmosphereState=this._opt.enableAtmosphere;const r=new y.Viewer(i);this.viewerAdapter=new j(this,r),r.globalUnitUtil=this.globalUnitUtil,r.viewerAdapter=this.viewerAdapter;const a=n.create("div","bf-view");t.domElement.appendChild(a),r.init(a,!0);r.setOrbitButton({Left:"left",Right:"right"}[t.orbitButton]),this.getViewer=()=>r,this.setBackgroundColors(t.backgroundColor),t.enableSkyBox?this.setSkyBoxType(t.skyBoxType):this.setSkyBoxType(e.Bimface.Earth.Plugins.SkyBox.SkyBoxStyle.Cosmos);const l=new or(this),h=e.Web.Lang.Utility.ClientHelper.getIsDesktop();r.setDeviceMobile&&r.setDeviceMobile(!h),t.enableIBLBackground&&t.loadIBLScene.IBLSceneOption&&this.loadIBLScene(t.loadIBLScene.IBLSceneOption,t.loadIBLScene.withBackground),this.getLayerManager=()=>l,this.getDomElement=()=>a,this.resizeWindow=()=>{this.resize()},window.addEventListener("resize",this.resizeWindow),this.mouseRotating=new U(this),this.hookContextMenu(a),this.hookCloudViewerEvents();const d=()=>{s.modelType="scene",s.modelId=this._config.id,this._config.baseLatLon=this._opt.basePoint||this._config.baseLatLon||{lat:30.94136274453108,lon:120.77426794742208},this.enuMatrix=this._getEnuMatrix(),this._config.homeView=this._opt.homeView||this._config.homeView||{position:{lon:120.77426794742208,lat:30.93136274453108,alt:1e3},orientation:{yaw:0,pitch:-Math.PI/2,roll:0}},this._config.renderingSettings=this._config.renderingSettings||{};let t=this._config.resources=this._config.resources||[];if(this.enableStorage){let e=[];const i=t=>{t.forEach((t=>{t.databagId&&e.push(t.databagId),t.children&&i(t.children)}))};i(t),this.storageManager=new y.Storage.SceneStorageManager({sceneId:this._data.modelId,databagIdList:e})}l.buildLayers(t),this.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ModelAdded,(e=>this.handleLayerEvent(e)));const i=new rr(this);this.getCamera=()=>i,this._camera=i._camera,!this._opt.enableAutoRotate&&this._camera.init()};this.handleLayerEvent=e=>{let t=l.getLayer(e);"DrawingLayer"===t.typeName&&t._config&&t._config.layerConfig&&t._config.layerConfig.isGround&&t.clampMode({mode:"Both"})},this.addModel=this.loadViewCore=(e,t,i)=>{this._data=e,this._config=e.sceneJsonInfo,this._config.sceneSetting&&(this._config.baseLatLon=this._config.sceneSetting.baseLatLon,this._config.homeView=this._config.sceneSetting.homeView),d()},this.addScene=i=>{if(this.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.SceneLoading),t.configUrl){const e=new THREE.FileLoader;e.setResponseType("json"),e.load(t.configUrl,(e=>{this._config=e,d()}),void 0,(e=>{console.error(`Load ${url} failed, ${e}`)}))}else t.config?(this._config=t.config,d()):i?this.addView(i):(this._config={},d());this.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.SceneAdded,(()=>{if(this._opt.enableAutoRotate&&(this.getCamera()._camera.setCameraStatus({orientation:{pitch:-1.5605141337944417,yaw:6.0657203498895065,roll:0},position:{x:8841333.788151901,y:11403673.518361356,z:7319620.286095019}},null,!0),this.getViewer().camera.flyTo({destination:new THREE.Vector3(-2868537.473456441,12714101.953083415,9581841.76514043),orientation:{pitch:-1.5677112692503004,yaw:6.078963824795912,roll:0},duration:3,easingFunction:y.GIS.EasingFunctions.LINEAR_NONE,complete:()=>{this.getCamera().setStatus({position:this._config.homeView.position,orientation:this._config.homeView.orientation},(()=>{this._camera.defaultHomeview=this._camera.getCameraStatus()}))}})),this._opt.enableSSAO&&this.enableSSAOEffect(!0),this._opt.enableCompassControl){const t=new e.Bimface.Earth.Plugins.NorthArrowConfig;t.domElement=this.getDomElement(),t.viewer=this,this._northArrow=new e.Bimface.Earth.Plugins.NorthArrow(t)}if(this._opt.enableScaleBar){const t=new e.Bimface.Earth.Plugins.ScaleBarConfig;t.domElement=this.getDomElement(),t.viewer=this,this._opt.enableInfoBar&&(t.bottom=45),this._scaleWidget=new e.Bimface.Earth.Plugins.ScaleBar(t),this.getScaleBar=()=>this._scaleWidget}if(this._opt.enableInfoBar){const t=new e.Bimface.Earth.Plugins.InfoBarConfig;t.domElement=this.getDomElement(),t.viewer=this,this._infobarWidget=new e.Bimface.Earth.Plugins.InfoBar(t),this.getInfoBar=()=>this._infobarWidget}if(this._opt.enableCreditBar){const t=new e.Bimface.Earth.Plugins.CreditConfig;t.domElement=this.getDomElement(),t.viewer=this,this._creditWidget=new e.Bimface.Earth.Plugins.Credit(t);const i=Object.assign({},e.Bimface.Common.Credit,{OSM:"openstreetmap",Amap:"appmaptile",BingMap:"virtualearth"});let n=this.getLayerManager().getLayer(this.firstTileLayerId),o=n.getSource(),s=o.url.toLowerCase();if(n._config.layerConfig&&n._config.layerConfig.customResource)o.credit=e.Bimface.Common.Credit.None,n.setSource(o);else for(let e in i)s.indexOf(i[e].toLowerCase())>-1&&(o.credit=e,n.setSource(o))}this.getLayerManager().getLayerByType("TileLayer").map((e=>!e.isVisible&&e.hide()))}))}}hookContextMenu(t){let i,n,o,s=!0;this.onTouchstart=r=>{let a=r.touches[0];s=!1,i=[a.pageX,a.pageY],o&&clearTimeout(o),o=setTimeout((()=>{if(s)return;n=n||i;let o=t.getBoundingClientRect(),r={clientPosition:{x:n[0]-o.left,y:n[1]-o.top},containerBox:{width:o.width,height:o.height}};Math.abs(i[0]-n[0])<5&&Math.abs(i[1]-n[1])<5&&this._opt.enableToggleContextMenuDisplay&&this.getEventManager().fireEvent(e.Bimface.Earth.Viewer.Viewer3DEvent.ContextMenu,r),s=!0}),1e3)},this.onTouchmove=e=>{let t=e.touches[0];n=[t.pageX,t.pageY]},this.onTouchend=()=>{n=null,s=!0},t.addEventListener("touchstart",this.onTouchstart),t.addEventListener("touchend",this.onTouchend),t.addEventListener("touchmove",this.onTouchmove)}hookCloudViewerEvents(){const t=this.getViewer(),i=this.getEventManager(),o=e.Bimface.Earth.Viewer.ViewerGISEvent;let s=n.create("div","bf-loading"),r=n.create("div","bf-loading-gif"),a=n.create("div","bf-loading-progress"),l=!1,h=0,d=n.create("div","bf-rect-selcetion"),c=null;const u=2,g=e=>{if(0==this.bIsEnableSelectionChanged||e.intersectInfo&&e.intersectInfo.objectType==y.PICKABLETYPE.Marker3d)return;let t=null,n=null,s=null,r=e.doubleClick?2:1;if(s=e.event.button==u?"RightClick":e.doubleClick?"DoubleClick":"Click",e.intersectInfo){const i=t=>({objectId:t.selectedObjectId,modelId:t.modelId,fileId:null,elementId:t.selectedObjectId,boundingBox:t.worldBoundingBox,click:r,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:t.worldPosition,clientPosition:e.canvasPos,eventType:s,objectType:p(t.objectType)});if(t=i(e.intersectInfo),e.intersectInfo.objectType==y.PICKABLETYPE.Room&&(t.boundaryPoints=e.intersectInfo.boundaryPoints),e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var a=e.intersectInfo.selectedObjectId.split(".");a.length>1&&(t.elementId=a[1],t.fileId=a[0])}if("Map"===t.objectType){const e=this.getLayerManager().baseMap;t.layerType=e.typeName;let i=0,n=e.getId();this.getLayerManager().query(".TileLayer").forEach((e=>{if(e.isVisible){const t=e.tileManager.getImageryLayerIndex(e._imageryId);t>i&&(i=t,n=e.getId())}})),t.layerId=n}else if("Component"===t.objectType&&t.modelId){const e=this._models[t.modelId]._layer;t.layerId=e.getId(),t.modelId=e.modelId,t.layerType=e.typeName}else if("ExternalComponent"===t.objectType){const e=this.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i<e.length;i++){const n=e[i];if(n._hasObjectId(t.elementId)){t.layerId=n.getId(),t.layerType=n.typeName;break}}}if(e.intersectInfoWithoutMap){if(n=i(e.intersectInfoWithoutMap),n&&"Component"===n.objectType&&n.modelId){const e=this._models[n.modelId]._layer;n.layerId=e.getId(),n.modelId=e.modelId,n.layerType=e.typeName}}else n="Map"!==t.objectType?t:null}else t={click:r,screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:s,objectType:""};if(e.event.altKey&&console.log(t),e.doubleClick)this.zoomToSelectedComponents(),i.fireEvent(o.MouseDoubleClicked,t),i.fireEvent(o.ComponentsSelectionChanged,t);else{if(e.event.button===THREE.MOUSE.LEFT){i.fireEvent(o.ComponentsSelectionChanged,t);let e=this.getViewer().pickToPoint(t.clientPosition,5);if(null!=this.snap&&null!=e){let i=this.sceneToWorld(e.pickPoint),n=this.worldToClient(i),o={type:null,worldPosition:i,clientPosition:{x:n.x,y:n.y}};t.snapPoint=o}}t.normal=e.intersectInfo?e.intersectInfo.normal:null,t.location=t.worldPosition?this.worldToLatLon(t.worldPosition):null,delete t.worldPosition,i.fireEvent(o.MouseClicked,t),n&&i.fireEvent(o.MouseClickedWithoutMap,n)}},p=e=>{let t;const i="Component",n="ExternalComponent",o="Room",s="Map";switch(e){case y.PICKABLETYPE.ExternalComponent:t=n;break;case y.PICKABLETYPE.Room:t=o;break;case y.PICKABLETYPE.Map:t=s;break;default:t=i}return t},m=t=>{if(this.bIsEnableSelectionChanged){var i={};if(t.event.button==u){var n=this.getDomElement().getBoundingClientRect(),o={x:t.event.clientX-n.left,y:t.event.clientY-n.top},s={width:n.width,height:n.height};i.clientPosition=o,i.containerBox=s,i.objectType=t.intersectInfo?p(t.intersectInfo.objectType):"",this.getEventManager().fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.ContextMenu,i)}}},f=(e,t)=>{e.visible?("pickByRect"===t?e.dir?d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px solid rgba(0,130,94,1)"}):d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(185,255,235,0.3)",border:"2px dashed rgba(0,130,94,1)"}):d.setCss({left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,background:"rgba(136,136,136,0.2)",border:"solid #888888 1px"}),this._opt.domElement.firstElementChild.appendChild(d),l=!0):(l&&(this._opt.domElement.firstElementChild.removeChild(d),l=!1,i.fireEvent(o.RectSelection,{end:!0})),i.fireEvent(o.RectSelection,e))};y.GlobalData.EnableDemolishByDClick=!0,a.innerText="0%",s.appendChild(r),s.appendChild(a),this._opt.loading&&this._opt.domElement.appendChild(s),this._opt.enableEarth&&!t.isEarthComplete()&&this.getViewer().registerEventListener(y.EVENTS.ON_EARTH_ANIMATION_COMPLETE,(()=>{i.fireEvent(o.EarthAnimationCompleted)})),t.registerEventListener(y.EVENTS.ON_MAP_LOAD_ALL,(()=>{s.parentElement&&0===h&&this._opt.domElement.removeChild(s)})),t.registerEventListener(y.EVENTS.ON_LOAD_START_NO_PROGRESS,(()=>{this._opt.loading&&(h++,s.parentElement||this._opt.domElement.appendChild(s),a.style.display="none")})),t.registerEventListener(y.EVENTS.ON_LOAD_START,(()=>{this._opt.loading&&(h++,s.parentElement||this._opt.domElement.appendChild(s))})),t.registerEventListener(y.EVENTS.ON_LOAD_PROGRESS,(e=>{let t=e.progress,n=Math.round(t.loaded/t.total*100);t.progress=n,a.innerText=n+"%",i.fireEvent(o.SceneLoading,t)})),t.registerEventListener(y.EVENTS.ON_LOAD_EMPTY_SCENE,(()=>{this._opt.loading&&0==h&&s.parentElement&&this._opt.domElement.removeChild(s),i.fireEvent(o.Error,{code:"EmptyData",message:"this view is empty."})})),t.registerEventListener(y.EVENTS.ON_LOAD_COMPLETE,(i=>{h--,this._opt.loading&&0==h&&s.parentElement&&i.modelId&&(a.innerText="0%",this._opt.domElement.removeChild(s)),t.enableTextureMapping(!0),this.removeMouseMotionEventListeners=e.Web.Lang.Utility.MouseMotion.setCursor(this)})),t.addCallbacks("render",(()=>{i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.Rendered)})),t.registerEventListener(y.EVENTS.ON_EDITOR_UPDATEUI,(e=>{f(e.data,e.editor)})),t.registerEventListener(y.EVENTS.ON_CLICK_PICK,(e=>{g(e),m(e)})),t.registerEventListener(y.EVENTS.ON_HOVER_PICK,(e=>{(e=>{let t=null,n="Hover";if(e.intersectInfo){if(t={objectId:e.intersectInfo.selectedObjectId,modelId:e.intersectInfo.modelId,fileId:null,elementId:e.intersectInfo.selectedObjectId,boundingBox:e.intersectInfo.worldBoundingBox,screenPosition:{x:e.event.clientX,y:e.event.clientY},worldPosition:e.intersectInfo.worldPosition,clientPosition:e.canvasPos,eventType:n,objectType:p(e.intersectInfo.objectType)},e.intersectInfo.selectedObjectId&&"string"==typeof e.intersectInfo.selectedObjectId){var s=e.intersectInfo.selectedObjectId.split(".");s.length>1&&(t.elementId=s[1],t.fileId=s[0])}}else c=null,t={screenPosition:{x:e.event.clientX,y:e.event.clientY},clientPosition:e.canvasPos,eventType:n};i.fireEvent(o.ComponentsHoverChanged,t),t.objectId&&c!=t.objectId&&(i.fireEvent(o.MouseHover,t),c=t.objectId)})(e)})),t.registerEventListener(y.EVENTS.ON_MOUSE_MOVE_PICK,(e=>{(e=>{if(!e.intersectInfo)return;const t=e.intersectInfo;var n={};if(void 0!==t.selectedObjectId&&(n.objectId=t.selectedObjectId),void 0!==t.modelId&&(n.modelId=t.modelId),void 0!==t.selectedObjectId&&(n.elementId=t.selectedObjectId),void 0!==t.worldBoundingBox&&(n.boundingBox=t.worldBoundingBox),void 0!==t.worldPosition&&(n.worldPosition=t.worldPosition),void 0!==t.objectType&&(n.objectType=p(e.intersectInfo.objectType)),n.eventType="MouseMove",n.screenPosition={x:e.event.clientX,y:e.event.clientY},n.clientPosition=e.canvasPos,t.selectedObjectId&&"string"==typeof t.selectedObjectId){var s=t.selectedObjectId.split(".");s.length>1&&(n.elementId=s[1],n.fileId=s[0])}i.fireEvent(o.MouseMove,n)})(e)})),t.registerEventListener(y.EVENTS.ON_SELECTION_CHANGED,(t=>{i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.SelectionChanged,t.selectionList);const n=[],o={};Object.entries(t.selectionList).forEach((([e,t])=>{if(t&&t.length>0&&"TileGroup"!==e)if("ExternalComponent"===e){const e=this.getLayerManager().query(".ExternalObjectLayer");t.forEach((t=>{e.some((e=>!(!e._hasObjectId||!e._hasObjectId(t))&&(o[e.id]||(o[e.id]=[]),o[e.id].push(t),!0)))}))}else{const i=this.getModel(e);if(i&&i._layer){const i=this.getModel(e)._layer.id;n.push({layerId:i,objectIds:t})}}})),Object.entries(o).forEach((([e,t])=>n.push({layerId:e,objectIds:t}))),i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.SelectedObjectsChanged,n)})),t.registerEventListener(y.EVENTS.ON_MOUSE_DRAGGED,(t=>{i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.MouseDragged,t)})),t.registerEventListener(y.EVENTS.ON_EDITOR_ZOOM_END,(()=>{i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.ZoomEnd)})),t.registerEventListener(y.EVENTS.ON_FLOOR_EXPLOSION,(function(t){void 0===this.floorData&&(this.floorData={}),this.floorData[t.modelId]=t.floorInfos,i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.FloorExplosion,t)})),t.registerEventListener(y.EVENTS.ON_CAMERA_CHANGED,(t=>{i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.CameraPositionChanged,this.getCameraStatus())})),t.registerEventListener(y.EVENTS.ON_TILES_LOAD_INITIAL,(function(t){i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.Initialized,t)})),t.registerEventListener(y.EVENTS.ON_TILES_LOAD_PROGRESS,(function(t){i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.ViewProcessing,t)})),t.registerEventListener(y.EVENTS.ON_TILES_LOAD_COMPLETE,(function(t){i.fireEvent(e.Bimface.Earth.Viewer.ViewerGISEvent.ViewLoaded,t)})),t.registerEventListener(y.EVENTS.ON_HOVER_SNAP,(e=>{this.snap&&this.snap.snapByPoint(e)}))}setSnapMode(e){this.snapMode=e}enableSnap(t){if(t?(this.getViewer().editorManager.enableTool(this.getViewer(),y.EditToolMode.PICK_BY_RECT),this.getViewer().enableSnap(t)):this.getViewer().editorManager.disableTool(y.EditToolMode.PICK_BY_RECT),!1===t&&null!=this.snap)this.snap.destroy(),this.snap=null;else if(!0===t&&null==this.snap){var i=new e.Bimface.Earth.Plugins.Snap.SnapConfig;i.viewer=this,i.snapMode=this.snapMode,this.snap=new e.Bimface.Earth.Plugins.Snap.Snap(i)}}getModel(e){if(e)return this._models[e]}getModels(){return Object.values(this._models)}destroy(){s.send(o,"destroy"),this._northArrow&&this._northArrow.destroy(),this._scaleWidget&&this._scaleWidget.destroy(),this._creditWidget&&this._creditWidget.destroy(),this._infobarWidget&&this._infobarWidget.destroy(),this.mouseRotating&&(this.mouseRotating.destroy(),this.mouseRotating=null),this._isDestroyed=!0,F.destroy(),this.getViewer().destroy(),window.removeEventListener("resize",this.resizeWindow);var e=this.getDomElement();e&&this.removeMouseMotionEventListeners&&(this.removeMouseMotionEventListeners(),this.removeMouseMotionEventListeners=null),e.parentNode&&e.parentNode.removeChild(e),y.GlobalData.EnableRainPass=!1,t.Viewer.prototype.destroy.call(this)}resize(e,t){var i=this._opt.domElement,n=e||i.clientWidth,o=t||i.clientHeight;this.getViewer().resize(n,o)}fireEvent(e,t){this.getEventManager().fireEvent(e,t)}_beforeInitialize(e){y.GlobalData.LimitFrameTime=1e3/e.minimumFPS,y.GlobalData.EnableDemolishByDClick=!1,y.GlobalData.DisableRotation=e.rotation,y.GlobalData.UseMpkWorker=!1,y.GlobalData.ZipResourcePostfix=e.suffix,y.GlobalData.LightIntensityFactor=1.2,y.GlobalData.Hover=e.enableHover,y.GlobalData.MouseMovePick=e.enableMouseMovePick,y.GlobalData.MaxMemeorySizeToFullRender=e.MaxMemeorySizeToFullRender,y.GlobalData.EnableLoadOnDemand=!0===e.loadOnDemand,y.GlobalData.Instance=!e.enableReplaceMaterial,y.GlobalData.EnableSplitComponent=e.enableSplitComponent,y.GlobalData.EnableExplosion=e.enableExplosion,y.GlobalData.EnableLogarithmicDepthBuffer=e.enableLogarithmicDepthBuffer,y.GlobalData.ConstraintZoom=e.enableConstraintZoom,y.GlobalData.BorderLineDelayLoaded=!1===e.enableBorderLine,y.GlobalData.PickingEffect=!1!==e.pickingEffect}render(){const e=this.getViewer();e.modelManager.setRenderStateChanged(!0),e.render()}getBasePoint(){if(this._config&&this._config.baseLatLon)return this._config.baseLatLon}getSelectedElements(){function e(e,t){return{layerId:e,objectIds:t}}let t=this.getViewer().getModelManager().getModelIds(!0),i=new Array;for(let n=0;n<t.length;n++){let o=this.getViewer().getSelection(t[n]);if("ExternalComponent"!==this.getViewer().getModelManager().getModel(t[n]).getId()){if(this._models[t[n]]&&o.length>0){let s=e(this._models[t[n]]._layer.getId(),o);i.push(s)}}else{const t=this.getLayerManager().getLayerByType("ExternalObjectLayer");for(let n=0;n<t.length;n++){const s=t[n];let r=new Array;for(let e=0;e<o.length;e++)s._hasObjectId(o[e])&&r.push(o[e]);if(r.length>0){let t=e(s.getId(),r);i.push(t)}}}}return i}getCameraStatus(){return this.getCamera().getStatus()}setCameraStatus(e,t){this.getCamera().setStatus(e,t)}setBackgroundColors(e){const t=this._opt.domElement,i=e.colors,n=void 0===e.direction?"180deg":e.direction*(180/Math.PI)+"deg";void 0===e.direction&&(e.direction=Math.PI);const o=[];if(i)if(1==i.length){const e=i[0].color;t.style.background=e.getRGBA(),this._setBackground(t,e)}else{i[0].stop=i[0].stop||"0%",i[1].stop=i[1].stop||"100%";for(let e=0;e<i.length;e++){const t=i[e].color.getRGBA()+" "+i[e].stop;o.push(t)}const e=`${n}, ${o.join(",")}`;t.style.background=`linear-gradient(${e})`,this._setBackground(t)}this._opt.backgroundColor=e}_setBackground(e,t){this.getViewer().setBackground(e,t)}getBackgroundColors(){return this._opt.backgroundColor}getHomeView(){return this.getCamera().getHomeView()}setHomeView(e){this.getCamera().setHomeView(e)}worldToScene(e){return this.getViewer().worldToDrawing(e)}sceneToWorld(e){return this.getViewer().drawingToWorld(e)}worldToClient(e){return this.getViewer().worldToCanvas(e)}clientToWorld(e){return this.getViewer().clientToWorld(e)}zoomIn(){this.getViewer().zoomIn()}zoomOut(){this.getViewer().zoomOut()}zoomToBoundingBox(e,t){this._camera.zoomToBoundingBox(e,t)}enableMouseMovePick(e){s.send(o,"enableMouseMovePick"),this._opt.enableMouseMovePick=e,this.getViewer().enableMouseMovePick(e)}zoomToSelectedComponents(){}worldToLatLon(e){if(!e.x&&!e.y&&!e.z)return{lat:0,lon:0,alt:0};let t=this.getViewer().worldToLonLat(e);return{lat:t.latitude,lon:t.longitude,alt:t.height}}latLonToWorld(e){return this.getViewer().lonLatToWorld({longitude:e.lon,latitude:e.lat,height:e.alt||0})}enableGlowEffect(e){s.send(o,"enableGlowEffect"),y.GlobalData.EnableGlow=e,this.render()}showNorthArrow(){this._northArrow&&this._northArrow.show()}hideNorthArrow(){this._northArrow&&this._northArrow.hide()}isInViewFrustum(e){return this.getViewer().insideCamera(e)}cloneModel(e,t){return this.getViewer().cloneModel(e,t)}enableFullScreen(e){super.enableFullScreen(e)}setSkyBoxType(e){if("Cosmos"!==e&&!this._opt.skyBoxUrls)return void this.console.warn("Customized skyBox must addSkyBox first");this._opt.skyBoxType=e;const t=this.getViewer().IBLManager;let i=[];const n=this._data;if("Cosmos"===e){let e="resources/SkyBox/Pics/"+this._opt.skyBoxType;const t=n.dataEnvType==_.Local?n.sdkPath:g.staticHost,s=["posx.jpg","negx.jpg","posy.jpg","negy.jpg","posz.jpg","negz.jpg"];for(var o=0;o<6;++o)i.push(`${t}/${e}/EnvMap_${s[o]}`)}else i=this._opt.skyBoxUrls;t.loadSkyBox(i,!1),t.setSkyBoxType(this._opt.skyBoxType)}loadIBLScene(e,t){var i=this,n=this.getViewer().IBLManager,o=this._data,s=o.dataEnvType==_.Local?o.sdkPath:g.staticHost;this._opt.enableIBLBackground&&(n.enableIBL(!0),this._getIBLConfig((function(o){var r=o;r[e]&&(i._opt.loadIBLScene=e,r[e].url=r[e].url.replace(g.staticHost,""),n.loadIBLMaps(`${s}/${r[e].url}`,r[e].isHDR,t,r[e].uniforms),t&&n.setSkyBoxType(e))})))}_getIBLConfig(t){var i=this,n=i._data;if(i._IBLConfig)t&&t(i._IBLConfig);else{var o=new e.Bimface.Data.IBLManagerConfig;n.dataEnvType==_.Local&&(o.resourceHost=n.sdkPath),new e.Bimface.Data.IBLManager(o).getIBLConfig((function(e){i._IBLConfig=e,t&&t(e)}))}}enableIBLBackground(e){var t=this.getViewer().IBLManager;if(e&&this._opt.enableIBLBackground){var i=this._opt.loadIBLScene;if(i==t.getSkyBoxType())t.addSkyBox(!0);else{var n="resources/IBL/Pics/"+this._opt.loadIBLScene,o=this._data,s=o.dataEnvType==_.Local?o.sdkPath:g.staticHost;t.loadSkyBox(`${s}/${n}`,!0),t.setSkyBoxType(i)}this._opt.IBLSkyBox=!0}else this._opt.IBLSkyBox=!1,t.removeSkyBox()}enableOrbit(e){y.EditorConfig.NoRotate=null!=e&&!e}_addLayerLoadedHandler(e,t,i="loaded"){r.assertType(e,"func")&&r.assertType(t,"str")&&(this._removeLayerLoadedHandler(t),this._layerLoadedHandlerList.push({handler:e,name:t,status:i}))}_removeLayerLoadedHandler(e){for(let t=0;t<this._layerLoadedHandlerList.length;t++){if(this._layerLoadedHandlerList[t].name===e)return void this._layerLoadedHandlerList.splice(t,1)}}_getLayerLoadedHandlerList(){return this._layerLoadedHandlerList}_executeDirectlyOrLayerLoaded(e,t,i){this._addLayerLoadedHandler(e,t,i),this.getLayerManager()&&this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((t=>{("rendered"===i&&["rendered","loaded"].includes(t.loadStatus)||"loaded"===i&&t.loadStatus===i)&&e(t)}))}setOrbitButton(e){const t=this.getViewer();this._opt.orbitButton=e,t.setOrbitButton({Left:"left",Right:"right"}[e])}setExposureCompensation(e){r.assertType(e,"num")&&(e>1&&(e=1),e<-1&&(e=-1),this._executeDirectlyOrLayerLoaded((t=>{t.setExposureCompensation(e)}),"setExposureCompensation","rendered"))}enableWireframe(e){s.send(o,"enableWireframe"),this._opt.enableWireframe=e;this.getLayerManager().query(".BIMLayer").forEach((t=>{t.presetWireFrameVisible&&t._setWireframeVisibleByViewer(e)})),this.render()}isWireframeEnabled(){return this._opt.enableWireframe}getExternalComponentManager(){return this.externalComponentManager&&!this.externalComponentManager.isDestroyed()||(this.externalComponentManager=new y.ExternalComponentManager(this.getViewer()),this.externalComponentManager._objects={}),this.externalComponentManager}getExternalObjectManager(){return this.externalObjectManager||(this.externalObjectManager=new e.Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager(this)),this.externalObjectManager}getExternalObjectConverter(){return this.externalObjectConverter||(this.externalObjectConverter=new y.ExternalObjectConverter(this.getViewer())),this.externalObjectConverter}getComponentsByRaycaster(e,t,i){i||(i=[]);let n={};this.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((e=>{const t=e.getModelId();n[t]=e.id}));let o=!1;const s=this.getLayerManager().terrainLayer.id;0===i.length&&(o=!0);let r=[];for(const e of i){if(!e.layerId)continue;if(e.layerId===s){1===Object.keys(e).length&&(o=!0);continue}let t={};const i=this.getLayerManager().getLayer(e.layerId);if(!i||!0===i._isBaseMap)continue;const n=i.getModelId().toString();t.modelId=n,e.objectIds?t.userId=e.objectIds:e.objectData&&(t.objectData=e.objectData),r.push(t)}let a=!1;0===r.length&&0!==i.length&&(a=!0);const l=this.getViewer().getComponentsByRaycasterConditions(e,t,r);let h=[];return l.map((e=>{if(e.modelId&&(e.layerId=n[e.modelId],delete e.modelId),!0===e.isMap){if(!1===o)return;e.layerId=s,delete e.id,delete e.isMap,delete e.modelId}e.id&&(e.objectId=e.id,delete e.id),!0===a&&e.layerId!==s||h.push(e)})),h}enableSSAOEffect(e){s.send(o,"enableSSAOEffect"),y.GlobalData.GTAO=e,this.render()}enableAtmosphere(e){this._atmosphereState=e,(1!=e||this.getLayerManager().baseMap.isVisible)&&(this.getViewer().getScene().atmosphere.enable(e),this.render())}isAtmosphereEnabled(){return y.GlobalData.EnableAtmosphere}getLocationByClient(e){var t=this.getDomElement().getBoundingClientRect();if(e.x>t.width||e.y>t.height)return null;let i={x:e.x+t.left,y:e.y+t.top},n=this.getViewer().pickByPoint(i);return n?this.worldToLatLon(n.worldPosition):null}getRaycaster(e,t){var i=new y.Raycaster,n=new THREE.Vector2;return this.getViewer().cameraControl.userInputHelper.clientToViewport(e,t,n),i.setFromCamera(n,this.getViewer().cameraControl.camera),i}_getEnuMatrix(){let{baseLatLon:e}=this._config,t=y.Tile.TileMath.fromDegrees(e.lon,e.lat,0),i=y.GIS.Transforms.eastNorthUpToFixedFrame(t);return i.invert(),i}updateSceneBoundingBox(){}}i.ViewerGIS=a}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Animation");i.AnimationContainer=class{constructor(){t.send("Bimface.Earth.Plugins.Animation.AnimationContainer","bf_c_animation_newContainer"),this.animations={},this._console=new e.Web.Common.Console,P(this)}addAnimation(e){this.animations[e.id]=e}getAllAnimations(){return Object.values(this.animations)}getAnimationById(e){return this.animations[e]}removeAnimationById(e){this.animations[e]&&(this.animations[e].stop(),delete this.animations[e])}destroy(){for(var e in this.animations)this.animations[e].destroy&&(this.animations[e].destroy(),delete this.animations[e])}stop(){for(var e in this.animations)this.animations[e].stop&&(this.animations[e].stop(),delete this.animations[e])}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Animation");i.PathAnimation=class{constructor(i){t.send("Bimface.Earth.Plugins.Animation.FlowEffect","bf_c_animation_newPath"),i?(this.loop=i.loop,this.isPitchEnabled=i.isPitchEnabled,this.isYawEnabled=i.isYawEnabled,this.objectIds=i.objectIds.length>0?i.objectIds:i.objectNames,this.objectNames=i.objectNames,this.path=i.path instanceof e.Bimface.Earth.Plugins.Geometry.SplineCurve?i.path.curve:i.path,this.time=i.time,this.viewer=i.viewer,this.originYaw=i.originYaw,this.originPitch=i.originPitch,this.projectGround=!!i.isProjectGround&&i.isProjectGround,this.id=e.Web.Lang.Utility.UUID.createUUID(),this.animationId=0,this.curvePos=0,this.initDirection=new THREE.Vector3(1,0,0),this.realGroundPath=null,this.projectGround&&this._genGroundPath(),this.viewer&&"Viewer3D"!==!this.viewer.viewerType?this.path?P(this):console.log("ERROR::path must not be empty"):console.log("ERROR::viewer must not be empty or viewer2d.")):console.log("ERROR::pathAnimationConfig must not be empty.")}getId(){return this.id}getLoop(){return this.loop}getObjectNames(){return this.objectNames}getObjectIds(){return this.objectIds}getPath(){if(this.path.clone){let e=this.path.clone(),t=[];return e.points.map((e=>{t.push(this.viewer.worldToLatLon(e))})),e.points=t,e}return this.path}getPitch(){return this.isPitchEnabled}getYaw(){return this.isYawEnabled}getTime(){return this.time}getOriginYaw(){return this.originYaw}getOriginPitch(){return this.originPitch}setLoop(e){this.loop=e}setObjectsByName(e){this.objectNames=e,this.objectIds=e}setObjectsById(e){this.objectIds=e}setOriginPitch(e){this.originPitch=e}setOriginYaw(e){this.originYaw=e}setPitch(e){this.isPitchEnabled=e}setYaw(e){this.isYawEnabled=e}setTime(e){this.time=e}setProjectGround(e){this.projectGround=e,this._genGroundPath()}_genGroundPath(){if(!this.realGroundPath&&this.path){const e=new CLOUD.Raycaster,t=this.viewer.getViewer().cameraControl.getIntersectContext(null);e.camera=t.camera,e.viewportSize=t.viewportSize;let i=[];const n=this.viewer.externalComponentManager._getNodeGroup(),o=n.visible;n.visible=!1;const s=this.viewer.getViewer().getScene().getObjectGroup(CLOUD.GlobalData.TileSphereGroupName);this.path.getPoints(200).forEach((t=>{let n=this.viewer.worldToLatLon(t);if(this.viewer.getLayerManager().terrainLayer.isVisible){let t={lat:n.lat,lon:n.lon,alt:1e3},o={lat:n.lat,lon:n.lon,alt:0},r=this.viewer.latLonToWorld(t),a=this.viewer.latLonToWorld(o),l=a.clone().sub(r).normalize();e.set(r.clone(),l);let h=[];s.raycast(e,h),h.length>0?(h.sort(((e,t)=>e.distance-t.distance)),i.push(h[0].point)):i.push(a)}else{let e=this.viewer.latLonToWorld({lat:n.lat,lon:n.lon,alt:0});i.push(e)}})),this.realGroundPath=new THREE.CatmullRomCurve3(i),n.visible=o}}_setCameraAnimation(e,t,i){this.camera=e;var n=this.viewer.getViewer().getScene().getMatrixGlobal(),o=new THREE.Vector3(t,0,0);o.applyMatrix4(n),this._cameraDistance=o.x,this._cameraAngle=i<0?2*Math.PI+i:i}_controlCamera(e,t,i){if(this.camera){t.applyAxisAngle(i,this._cameraAngle);var n=this.viewer.getViewer().getScene().getMatrixGlobal();e.applyMatrix4(n),t.applyMatrix4(n),t.normalize(),this.camera.LookAt(e,t,null,this._cameraDistance)}}play(t){if(!this.path||!this.viewer)return void console.log("ERROR::viewer or path must not be empty.");var i,n,o,s=this,r=new THREE.Quaternion,a=new THREE.Quaternion,l=new THREE.Vector3(0,0,1),h=new THREE.Vector3,d=(new THREE.Vector3(1,0,0),new THREE.Vector3(0,1,0)),c=new THREE.Vector3(0,1,0);let u=new THREE.Vector3,g=new THREE.Vector3,p=new THREE.Vector3,m=(new Date).valueOf(),f=m-16;!function w(){s.animationId=requestAnimationFrame(w),s.curvePos>=1&&(s.curvePos=s.loop?0:1,t&&t(),s.loop||s.pause()),function(t){s.projectGround?(i=s.realGroundPath.getPointAt(t),n=s.realGroundPath.getTangentAt(t)):(i=s.path.getPointAt(t),n=s.path.getTangentAt(t));let m=CLOUD.GIS.Transforms.eastNorthUpToFixedFrame(i.clone()).clone(),f=new THREE.Matrix4;f.extractRotation(m.clone());let w=f.clone().invert(),y=n.clone();n=n.applyMatrix4(w.clone()),o=n.clone(),n.z=0,n.normalize(),g.set(y.x,y.y,y.z),y.z=0,u.crossVectors(y.applyMatrix4(f.clone()).normalize(),new THREE.Vector3(0,0,1).applyMatrix4(f.clone()).normalize()),u.normalize(),p.set(i.x,i.y,i.z),s._controlCamera(p,g,u),r.set(0,0,0,1);var v=0;if(s.isYawEnabled){var b=n.dot(s.initDirection);b=b<-1?-1:b>1?1:b,v=Math.acos(b),v=n.y<0?-v:v}v+=s.originYaw,a.setFromAxisAngle(l,v),r.multiply(a),a.setFromAxisAngle(l,-s.originYaw),d.set(0,1,0),d.applyQuaternion(a),c.set(d.x,d.y,d.z),c.applyQuaternion(r);var E=0;if(s.isPitchEnabled){o.normalize();var M=o.dot(n);M=M<-1?-1:M>1?1:M,E=Math.acos(M),h.crossVectors(n,o),E=h.dot(c)>0?E:-E}E-=s.originPitch,a.setFromAxisAngle(d,E),r.multiply(a);const C=(new THREE.Euler).setFromQuaternion(r,"XYZ");for(var x=0,T=s.objectIds.length;x<T;x++)if(s.viewer.getExternalObjectManager().setPosition(s.objectIds[x],i),s.viewer.getExternalComponentManager().setTransform(s.objectIds[x],void 0,void 0,{x:C.x,y:C.y,z:C.z}),s.viewer.getExternalObjectManager()._fireTransformedEvent(s.objectIds[x]),s.viewer instanceof e.Bimface.Earth.Viewer.ViewerGIS){const e=s.viewer.getLayerManager().getLayerByType("ExternalObjectLayer");for(let t=0;t<e.length;t++){e[t].getExternalObjectManager()._fireTransformedEvent(s.objectIds[t])}}}(s.curvePos),s.viewer.render(),m=(new Date).valueOf();let y=m-f;f=m,s.curvePos+=y/s.time}()}pause(){cancelAnimationFrame(this.animationId)}stop(){cancelAnimationFrame(this.animationId),this.curvePos=0}destroy(){this.stop(),this.animationId=null,this.curvePos=null,this.id=null,this.initDirection=null,this.isPitchEnabled=null,this.isYawEnabled=null,this.loop=null,this.objectIds=null,this.objectNames=null,this.originPitch=null,this.originYaw=null,this.path=null,this.projectGround=null,this.realGroundPath=null,this.time=null,this.viewer=null}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Animation");t.PathAnimationConfig=class{constructor(){this.loop=!1,this.isPitchEnabled=!1,this.isYawEnabled=!1,this.objectNames=[],this.objectIds=[],this.originPitch=0,this.originYaw=0,this.path=null,this.time=0,this.viewer=null,this.isProjectGround=!1}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable").DrawableContainerConfig=function(){return{viewer:null,maxNum:20,affectedBySection:!0,enableRender:!0}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable").DrawableItemConfig=function(){return{id:null,objectId:null,tooltip:"",tooltipStyle:{},draggable:!1,worldPosition:new e.Web.Geometry.Point3d(0,0,0),angle:0,layerId:void 0,location:null}},function(){var n="Bimface.Earth.Plugins.Drawable.DrawableItem",o=e.Bimface.Data.StatisticsDataManager.getInstance();let s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),r=function(i){this.id=i.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=i.layerId,this.objectId=i.objectId,i.location?this.location=i.location:i.worldPosition?this.location=i.worldPosition:console.log("location must not be empty."),this.config=i,this.angle=i.angle,this.explosionOffset=new t,this.explosionExtent=0,this._enableDepthTest=i.enableDepthTest,this._isCover=!1,this._enableDepthTestCallback=null,P(this)};r.prototype={draw:function(e){},onClick:function(e){o.send(n,"onClick"),this._onclick=e},onDoubleClick:function(e){o.send(n,"onClick"),this._doubleClick=e},onRightClick:function(e){o.send(n,"onRightClick"),this._onrightclick=e},onEndDrag:function(e){o.send(n,"onEndDrag"),this._onenddrag=e},setTooltip:function(e){o.send(n,"setTooltip"),this.tipElement.querySelector("span").innerText=e},setTooltipStyle:function(e){for(var t in o.send(n,"setTooltipStyle"),e)this.tipElement.style[t]=e[t],"backgroundColor"===t&&(this.tipElement.childNodes[0].childNodes[0].style.borderTopColor=e[t])},getTooltip:function(){return this.tipElement.querySelector("span").innerText},getTooltipStyle:function(){return this.tipElement.style},getWorldPosition:function(){return this.location},setWorldPosition:function(e){o.send(n,"setWorldPosition"),this.location=e},getLocation:function(){return this.location},setLocation:function(e){o.send(n,"setLocation"),this.location=e},getSize:function(){return{width:this.config.width,height:this.config.height}},hide:function(){o.send(n,"hide"),this._domElement.style.display="none",this.notControlByCameraPosition=!0,this.forceHide=!0},hideByCameraPosition:function(){this.notControlByCameraPosition||(this._domElement.style.display="none",this.forceHide=!0)},show:function(){o.send(n,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this._domElement.style.display="",this.forceHide=!1)},showByCameraPosition:function(){this.forceHide&&(this.notControlByCameraPosition||(this._domElement.style.display="",this.forceHide=!1))},updateVisibility:function(){this.isHideByClustering||this.forceHide?this._domElement.style.display="none":this._domElement.style.display="block"},attachExplosionOffset:function(e,n){if(!this.location)return;if(!this.viewer)return;let o=this.viewer.latLonToWorld(this.location),s=this._config.objectId;if(s){let i=e.modelManager.getBoundingBoxByIds([s]),r=this.assoiatedComponentBbox,a=i;if(r){let e=a.getCenter().clone();e.sub(r.getCenter().clone()),this.explosionOffset=e,this.explosionExtent>0&&0===n&&(o.x+=e.x,o.y+=e.y,o.z+=e.z,this.explosionExtent=0,this.explosionOffset=new t,this.assoiatedComponentBbox=a.clone(),this.location=this.viewer.worldToLatLon(o))}}else{let t=e.getScene().getOriginalBoundingBoxWorld().getCenter(),s=(new i).expandByPoint(o),r=CLOUD.Utils.computeExplodeTranslation(t,s,n);this.explosionOffset=r}},setInitialExplosionInfo:function(e){if("ViewerGIS"!==e.getViewerType())return;let t=null;t=e.getLayerManager().getLayer(this.layerId)||null,this.explosionExtent=null===t?0:t.getExplosionExtent();const i=this._config.objectId;if(!i)return;e.getViewer().modelManager.getBoundingBoxByIds([i]).isEmpty()&&(this._config.objectId=null,console.log("Cannot find component with Id "+i))},clearExplosionOffset:function(){this.explosionOffset=new t},getCurrentPosition:function(){if(!this.viewer)return;let e=this.viewer.latLonToWorld(this.location);return{x:e.x+this.explosionOffset.x,y:e.y+this.explosionOffset.y,z:e.z+this.explosionOffset.z}},getId:function(){return this.id},handleEnableDepthTest(t){if(!this._enableDepthTest||!this.viewer)return;if("ViewerGIS"!==this.viewer.getViewerType())return;!t&&(t=this.viewer.getCameraStatus().position);let i=new THREE.Vector3(...Object.values(t)),n=this.viewer.latLonToWorld(this.location),o=new THREE.Vector3(...Object.values(n));const s=o.clone().sub(i).normalize(),r=this.viewer.getComponentsByRaycaster(i,s,[]);let a=r.length>0?r[0].distance:o.clone().sub(i).length(),l=1;switch(this.viewer.getUnit()){case e.Bimface.Common.Units.LengthUnits.Kilometer:l=1e-6;break;case e.Bimface.Common.Units.LengthUnits.Meter:l=.001;break;case e.Bimface.Common.Units.LengthUnits.Centimeter:l=.1;break;case e.Bimface.Common.Units.LengthUnits.Millimeter:l=1}let h=o.clone().sub(i).length()>=a+l;this._isCover!=h&&this._enableDepthTestCallback&&this._enableDepthTestCallback(h),this._isCover=h},enableDepthTest:function(e){this._enableDepthTest=e,this.handleEnableDepthTest()},isDepthTestEnabled:function(){return this._enableDepthTest},onObstructionChanged:function(e){this._enableDepthTestCallback=e,this._enableDepthTest&&(this.handleEnableDepthTest(),e(this._isCover))}},s.DrawableItem=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(){this.rootDomElement=i.create("div","bf-drawable-context"),this.clientPosition=null};n.prototype.destroy=function(){this.rootDomElement.parentNode&&this.rootDomElement.parentNode.removeChild(this.rootDomElement)},t.DrawableContext=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),i=new e.Bimface.Earth.Plugins.Drawable.DrawableItemConfig;t.ImageConfig=function(){let e={width:32,height:32,viewer:null,opacity:.75,src:null,offsetX:0,offsetY:0,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1};return Object.assign({},i,e)}}(),function(){var t="Bimface.Earth.Plugins.Drawable.Image",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),o=e.Bimface.Earth.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),r=function(e){o.call(this,e);let t=this;this._isDragging=!1;let i=s.create("div","bf-drawable-text"),n=s.create("img","bf-drawable-image");i.draggable=!1,n.src=e.src,n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,n.style.opacity=`${e.opacity}`,n.style.transform=`rotate(${e.angle}deg)`,i.appendChild(n),this._config=e,this._domElement=i,this._imgElement=n;let r=s.create("div","bf-tooltip tooltipTop");r.style.display="none",r.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${e.tooltip}</span></div></div>`,r.style.left=`${e.tooltipStyle.left}`,r.style.top=`${e.tooltipStyle.top}`;var a,l=e.tooltipStyle;this.tipElement=r,this.setTooltipStyle(l),i.appendChild(r),this.clientPosition={},this.visibleDistance=e.visibleDistance;e.draggable&&s.drag({element:i,cursor:"pointer",end:function(e){t._isDragging=!1;var i=t.viewer,n=e.x-a.x+t.clientPosition.x,o=e.y-a.y+t.clientPosition.y;let s=i.getDomElement().getBoundingClientRect(),r=i.getViewer().pickByPoint({x:n+s.left,y:o+s.top});r&&r.meshId?(r.meshId&&(t._config.objectId=r.meshId),t.worldPosition=r.worldPosition,t.update()):t.update()},start:function(e){a=e},move:function(){t._isDragging=!0}}),i.addEventListener("mouseup",(function(e){var i=e||window.event;"0"==i.button&&t._onclick&&(!t._isDragging||a.x==i.clientX&&a.y==i.clientY)&&(t.clickTimerId&&clearTimeout(t.clickTimerId),t.clickTimerId=setTimeout((()=>{t.event=i,t._onclick(t),delete t.event}),500))})),i.addEventListener("mousedown",(function(e){var i=e||window.event;i.stopPropagation(),"2"==i.button&&t._onrightclick?t._onrightclick(t):"1"==i.button&&t._onmiddleclick&&t._onmiddleclick(t)})),i.addEventListener("mouseover",(function(e){r&&r.querySelector("span").innerText.length>0&&(r.style.display="block")})),i.addEventListener("mouseout",(function(e){t.tipElement&&(t.tipElement.style.display="none")})),i.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),t._doubleClick&&t._doubleClick(t),t.clickTimerId&&clearTimeout(t.clickTimerId)}))};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(r,o);var a={draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._imgElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._imgElement.style.opacity=e},getSrc:function(){return this._config.src},setSrc:function(e){i.send(t,"setSrc"),this._config.src=e,this._imgElement.src=e},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getAngle:function(){return this.angle},setAngle:function(e){i.send(t,"setAngle"),this.angle=e,this._imgElement.style.transform=`rotate(${e}deg)`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)}};!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}(a,r),n.Image=r}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),i=new e.Bimface.Earth.Plugins.Drawable.DrawableItemConfig;t.CustomItemConfig=function(){return Object.assign({},i,{width:0,height:0,opacity:.75,content:"",offsetX:0,offsetY:0,viewer:null,visibleDistance:null,enableDepthTest:!1})}}(),function(){var t="Bimface.Earth.Plugins.Drawable.CustomItem",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins"),s=e.Bimface.Earth.Plugins.Drawable.DrawableItem,r=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),a=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility");o.IE11Store={};let l=function(t){s.call(this,t),this._isDragging=!1;let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),o=r.create("div","bf-drawable-text");o.style.width=`${t.width}px`,o.style.height=`${t.height}px`;let a=r.create("div","bf-drawable-contentwrap");var l;o.appendChild(a),this._domElement=o,this.name="customItem",this._contentElement=a,this._config=t,this.clientPosition={},this.visibleDistance=t.visibleDistance,this.setContent(t.content);let h=r.create("div","bf-tooltip");h.style.display="none",h.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${t.tooltip}</span></div></div>`,h.style.left=`${t.width}px`,h.style.top=`-${t.height}px`;var d=t.tooltipStyle;this.tipElement=h,this.setTooltipStyle(d),o.appendChild(h);t.draggable&&r.drag({element:o,cursor:"pointer",end:function(e){i._isDragging=!1;var t,n=i.viewer,o=e.x-l.x+i.clientPosition.x,s=e.y-l.y+i.clientPosition.y;let r=n.getDomElement().getBoundingClientRect(),a=n.getViewer().pickByPoint({x:o+r.left,y:s+r.top});a&&a.meshId?(a.meshId&&(i._config.objectId=a.meshId),(t=a.worldPosition)&&i.viewer?(i.location=i.viewer.worldToLatLon(t),i.update(),i._onenddrag&&i._onenddrag(i)):i.update()):i.update()},start:function(e){l=e},move:function(){i._isDragging=!0}}),o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.style.opacity=`${t.opacity}`,o.addEventListener("mouseover",(function(e){i.tipElement&&i.tipElement.querySelector("span").innerText.length>0&&(i.tipElement.style.display="block")})),o.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),o.addEventListener("keydown",(function(e){e.stopPropagation()})),n&&o.addEventListener("mouseup",(function(e){var t=e||window.event;"0"==t.button&&i._onclick&&(!i._isDragging||l.x==t.clientX&&l.y==t.clientY)&&(i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i.event=t,i._onclick(i),delete i.event}),500))})),o.addEventListener("mousedown",(function(e){var t=e||window.event;t.stopPropagation(),"2"==t.button&&i._onrightclick?i._onrightclick(i):"1"==t.button&&i._onmiddleclick&&i._onmiddleclick(i)})),o.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),o.addEventListener("touchstart",(function(e){(e||window.event).stopPropagation()})),o.addEventListener("touchmove",(function(e){(e||window.event).stopPropagation()})),!n&&o.addEventListener("touchend",(function(e){var n=e||window.event;n.stopPropagation(),i._onclick&&(!t.draggable||l.x==n.changedTouches[0].clientX&&l.y==n.changedTouches[0].clientY)&&i._onclick(i)}))};a.Type.inheritPrototype(l,s);var h={draw:function(e){if(!this._isDragging){var t=this._domElement,i=this._config;this.clientPosition=e.clientPosition,t.style.left=e.clientPosition.x+i.offsetX-i.width/2+"px",t.style.top=e.clientPosition.y+i.offsetY-i.height/2+"px",""==t.innerHTML&&(this.dom&&this.domId?t.appendChild(o.IE11Store[this.domId].cloneNode(!0)):this.text&&(t.innerText=this.text)),e.rootDomElement.contains&&e.rootDomElement.contains(t)||e.rootDomElement.appendChild(t)}},getWidth:function(){return this._config.width},setWidth:function(e){i.send(t,"setWidth");var n=this._config.width,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.left);this._config.width=e,o.style.width=`${e}px`,o.style.left=`${r+s}px`},getHeight:function(){return this._config.height},setHeight:function(e){i.send(t,"setHeight");var n=this._config.height,o=this._domElement,s=(n-e)/2,r=parseInt(o.style.top);this._config.height=e,o.style.height=`${e}px`,o.style.top=`${r+s}px`},getOpacity:function(){return this._config.opacity},setOpacity:function(e){i.send(t,"setOpacity"),this._config.opacity=e,this._domElement.style.opacity=e},getContent:function(){return this._config.content||this.text},setContent:function(n){i.send(t,"setContent"),this._contentElement.innerHTML="",n instanceof HTMLElement?(n.draggable=!1,this._config.content=n,this._domElement.content=n,this.dom=n,this.domId||(this.domId=e.Web.Lang.Utility.UUID.createUUID()),o.IE11Store[this.domId]=n.cloneNode(!0),this._contentElement.appendChild(n)):(this._contentElement.innerHTML=n,this.text=n,this._config.content="")},getOffsetX:function(){return this._config.offsetX},setOffsetX:function(e){i.send(t,"setOffsetX");var n=this._config.offsetX,o=this._domElement,s=e-n,r=parseInt(o.style.left);this._config.offsetX=e,o.style.left=`${r+s}px`},getOffsetY:function(){return this._config.offsetY},setOffsetY:function(e){i.send(t,"setOffsetY");var n=this._config.offsetY,o=this._domElement,s=e-n,r=parseInt(o.style.top);this._config.offsetY=e,o.style.top=`${r+s}px`},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){s.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return s.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){s.prototype.onObstructionChanged.call(this,e)}};!function(e,t){var i=t.prototype;for(var n in e)i[n]=e[n]}(h,l),n.CustomItem=l}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),i=new e.Bimface.Earth.Plugins.Drawable.DrawableItemConfig;t.LeadLabelConfig=function(){let t={text:null,viewer:null,containerCss:{boxSizing:"border-box",fontSize:"12px",lineHeight:1.5,borderWidth:"2px",borderStyle:"solid",padding:"5px",borderColor:"#1f93ff",backgroundColor:"#eeeeee",padding:"2px 8px",opacity:.9},lineCss:{width:"2px",color:"#1f93ff"},pointCss:{radius:4,backgroundColor:"#1f93ff",borderColor:"#ffffff",borderStyle:"solid",borderWidth:"1px"},offset:{x:27,y:-47},height:26,width:140,layerId:void 0,objectId:void 0,visibleDistance:null,enableDepthTest:!1,style:{lineColor:new e.Web.Graphics.Color(31,147,255,1),lineWidth:2,backgroundColor:new e.Web.Graphics.Color(238,238,238,1),fontSize:12}};return Object.assign({},i,t)}}(),function(){var t="Bimface.Earth.Plugins.Drawable.LeadLabel",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable"),o=e.Bimface.Earth.Plugins.Drawable.DrawableItem,s=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");var r=function(t){o.call(this,t);let i=this,n=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),r=s.create("div","bf-drawable-lead-label"),a=s.create("div","bf-drawable-lead-label-textarea");r.appendChild(a);let l=s.createNS("line","bf-drawable-lead-line"),h=s.createNS("line","bf-drawable-lead-line"),d=s.createNS("circle","bf-drawable-lead-point"),c=s.createNS("g","bf-drawable-group");i._text=t.text,this.name="LeadLabel",this.isAssociateComponentHide=!1,this.visibleDistance=t.visibleDistance,r.setCss(t.containerCss),a.innerText=i._text.replace(/\n/g," ");let u=[r,l,h,d];this._labelCombination=u;let g=s.create("div","bf-tooltip");g.style.display="none",g.innerHTML=`<div class="bf-tooltip-content"><div class="bf-tooltip-arrow"></div><div class="bf-tooltip-inner"><span>${t.tooltip}</span></div></div>`,g.style.left="0px",g.style.top="0px",this.tipElement=g,this.setTooltipStyle(t.tooltipStyle),r.appendChild(g),r.style.width=parseFloat(t.width)+"px",r.style.minHeight=parseFloat(t.height)+"px";let p=Math.trunc((t.height-8)/18);var m;a.style.webkitLineClamp=p||1,h.setAttribute("stroke-width",t.lineCss.width),h.style.stroke=t.lineCss.color,l.setAttribute("stroke-width",t.lineCss.width),l.style.stroke=t.lineCss.color,d.setAttribute("r",t.pointCss.radius),d.style.fill=t.pointCss.backgroundColor,d.setAttribute("stroke-width",t.pointCss.borderWidth),d.style.stroke=t.pointCss.borderColor,h.setAttribute("x1",0),h.setAttribute("y1",0-t.offset.y+18),h.setAttribute("x2",t.offset.x),h.setAttribute("y2",18),l.setAttribute("x1",t.offset.x),l.setAttribute("y1",18),l.setAttribute("x2",t.offset.x+23),l.setAttribute("y2",18),d.setAttribute("cx",0),d.setAttribute("cy",18-t.offset.y),this.setStyle(t.style),this._isDragging=!1;t.draggable&&s.drag({element:r,cursor:"pointer",start:function(e){m=e},move:function(e){i._isDragging=!0;var n=e.x-m.x+i.clientPosition.x,o=e.y-m.y+i.clientPosition.y;c.setAttribute("transform",`translate(${n},${o+t.offset.y-18})`)},end:function(e){i._isDragging=!1;const n=t.viewer||i.viewer;var o=n.getDomElement().getBoundingClientRect(),s={x:e.x-m.x+i.clientPosition.x+o.left,y:e.y-m.y+i.clientPosition.y+o.top};let r=n.getViewer().pickByPoint({x:s.x,y:s.y});if(!r||!r.meshId)return void i.update();r.meshId&&(i._config.objectId=r.meshId);let a=i.viewer.worldToLatLon(r.worldPosition);i.location=a,i.setWorldPosition(a),i.update(),i._dragEnd&&i._dragEnd()}}),r.addEventListener("mousedown",(function(e){(e=e||event).stopPropagation()})),r.addEventListener("mouseover",(function(e){g&&g.querySelector("span").innerText.length>0&&(g.style.display="block")})),r.addEventListener("mouseout",(function(e){i.tipElement&&(i.tipElement.style.display="none")})),n&&r.addEventListener("click",(function(e){(e=e||event).stopPropagation(),i.clickTimerId&&clearTimeout(i.clickTimerId),i.clickTimerId=setTimeout((()=>{i._click&&(i.event=e,i._click(i),delete i.event)}),500)})),!n&&r.addEventListener("touchstart",(function(){(event||window.event).stopPropagation(),i._click&&i._click(i)})),r.addEventListener("contextmenu",(function(e){i._rightClick&&i._rightClick(i)})),r.addEventListener("dblclick",(function(e){(e=e||event).stopPropagation(),i._doubleClick&&i._doubleClick(i),i.clickTimerId&&clearTimeout(i.clickTimerId)})),r.addEventListener("mouseenter",(function(e){a.innerText=i._text;let t=r.offsetHeight;r.addClass("bf-drawable-show"),a.addClass("bf-drawable-show"),t>r.offsetHeight&&(r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show"))})),r.addEventListener("mouseleave",(function(e){a.innerText=i._text.replace(/\n/g," "),r.removeClass("bf-drawable-show"),a.removeClass("bf-drawable-show")})),c.appendChild(h),c.appendChild(l),c.appendChild(d),i._objectId=t.objectId,i._container=r,i._domTextArea=a,i._svgGroup=c,i._config=t,i._offset=t.offset};e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility").Type.inheritPrototype(r,o),r.prototype=Object.assign({},o.prototype,{draw:function(e,t){if(!this._isDragging){var i=this._container,n=this._svgGroup,o=this._offset;!0!==this.isHideByClustering?(this.clientPosition=e.clientPosition,i.style.left=`${e.clientPosition.x+o.x+23}px`,i.style.top=e.clientPosition.y+o.y-18+"px",n.setAttribute("transform",`translate(${e.clientPosition.x},${e.clientPosition.y+o.y-18})`),e.domContainer||(e.domContainer=s.create("div","bf-drawable-container"),e.rootDomElement.appendChild(e.domContainer)),e.svgContainer||(e.rootDomElement.getElementsByClassName("bf-drawable-svg").length>0?e.svgContainer=e.rootDomElement.getElementsByClassName("bf-drawable-svg")[0]:(e.svgContainer=s.createNS("svg","bf-drawable-svg"),e.rootDomElement.appendChild(e.svgContainer))),this.isShow("default"==t),e.rootDomElement.contains&&e.domContainer.contains(i)||(e.domContainer.appendChild(i),e.svgContainer.appendChild(n))):this.hide()}},setDisplayMode:function(e){this.show(),this.displayMode=e,this.isShow()},hide:function(){i.send(t,"hide"),this.forceHide=!0,this.notControlByCameraPosition=!0,this._container.style.display="none",this._svgGroup.style.display="none"},show:function(){i.send(t,"show"),this.notControlByCameraPosition=!1,this.visibleDistance?this.viewer.drawableContainer.showOrHideLabelForCamearPosition():(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},hideByCameraPosition:function(){this.notControlByCameraPosition||(this.forceHide=!0,this._container.style.display="none",this._svgGroup.style.display="none")},showByCameraPosition:function(){!this.notControlByCameraPosition&&this.forceHide&&(this.forceHide=!1,this._container.style.display="",this._svgGroup.style.display="")},onClick:function(e){i.send(t,"onClick"),e&&(this._click=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClick=e)},onDoubleClick:function(e){e&&(this._doubleClick=e)},onEndDrag:function(e){i.send(t,"onEndDrag"),e&&(this._dragEnd=e)},getText:function(){return this._text},setText:function(e){i.send(t,"setText"),this._domTextArea.innerText=e,this._text=e},getOpacity:function(){return this._container.style.opacity},setOpacity:function(e,n){i.send(t,"setOpacity"),this._container.style.opacity=e},getHeight:function(){return parseFloat(this._container.style.height)},setHeight:function(e){i.send(t,"setHeight"),this._container.style.height=parseFloat(e)+"px";let n=Math.trunc((e-8)/18);this._domTextArea.style.webkitLineClamp=n||1},getWidth:function(){return parseFloat(this._container.style.width)},setWidth:function(e){i.send(t,"setWidth"),this._container.style.width=parseFloat(e)+"px"},getObjectId:function(){return this._objectId},isShow:function(e){var t=this._container,i=this._svgGroup;null!=this.displayMode&&(e=1!==this.displayMode),e?(t.removeClass("bf-drawable-mini"),i.removeClass("bf-drawable-mini-svg")):(t.addClass("bf-drawable-mini"),i.addClass("bf-drawable-mini-svg"))},getVisibleDistance:function(){return this.visibleDistance},setVisibleDistance:function(e){this.visibleDistance="number"!=typeof e?Number.POSITIVE_INFINITY:e,this.viewer.drawableContainer.showOrHideLabelForCamearPosition()},enableDepthTest:function(e){o.prototype.enableDepthTest.call(this,e)},isDepthTestEnabled:function(){return o.prototype.isDepthTestEnabled.call(this)},onObstructionChanged:function(e){o.prototype.onObstructionChanged.call(this,e)},setStyle:function(e){if(e&&null!==e){const[t,i,n,o]=this._labelCombination,s=e.lineColor&&e.lineColor.getRGBA();e.lineColor&&(this.config.style.lineColor=e.lineColor,i.style.stroke=s,n.style.stroke=s,t.style.borderColor=s,o.style.fill=s),e.lineWidth&&(this.config.style.lineWidth=e.lineWidth,t.style.borderWidth=e.lineWidth+"px",i.style.strokeWidth=e.lineWidth+"px",n.style.strokeWidth=e.lineWidth+"px",o.style.strokeWidth=e.lineWidth+"px"),e.backgroundColor&&(this.config.style.backgroundColor=e.backgroundColor,t.style.backgroundColor=e.backgroundColor.getRGBA()),e.fontSize&&(this.config.style.fontSize=e.fontSize,t.style.fontSize=e.fontSize+"px")}null!==this.config.style&&null!==e||(this.config.style=new Object),i.send(t,"setStyle")},getStyle:function(){return this.config.style}}),n.LeadLabel=r}(),function(){var t="Bimface.Earth.Plugins.Drawable.DrawableContainer",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Drawable");n.DrawableContainer=class{constructor(t){let i=this,n=t.viewer;if(n.drawableContainer)return n.drawableContainer;n.drawableContainer=this,P(this);let o=e.Bimface.Earth.Viewer.ViewerGIS&&n instanceof e.Bimface.Earth.Viewer.ViewerGIS,s=new e.Web.Lang.EventManager,r=new e.Bimface.Earth.Plugins.Drawable.DrawableContext;if(this.boxMap={},i._enableRender=t.enableRender,n.addEventListener("Rendered",(function(e){i.update(e)})),o){let t=null,o=null;n.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.CameraPositionChanged,(function(e){o||(o=setTimeout((()=>{i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position),o=null}),500)),t&&(clearTimeout(t),t=null),t=setTimeout((()=>{clearTimeout(o),o=null,i.showOrHideLabelForCamearPosition(e.position),i.handleEnableDepthTest(e.position)}),200)}))}o&&(n.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.ViewChanged,(function(){i.handleEnableDepthTest()})),n.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.LayerVisibleChanged,(function(){i.handleEnableDepthTest()})));n.getDomElement().appendChild(r.rootDomElement),this.calculateViewerGISExplosionOffset=e=>{const t=n.getViewer(),o=e.modelId,s=e.floorInfos.length,r=t.getFloorExplosionExtent(o),a=t.getFloorExplosionDirection(o);if(0===r)for(const e of i.getAllItems())e.setInitialExplosionInfo(n);const l=e.floorInfos;let h=[];for(var d=0;d<s;d++){let e=l[d],t=l[d+1],i=l[d-1];if(h.push({box:{min:i?e.boundingBox.min.z:-1/0,max:t?t.boundingBox.min.z:1/0},floorName:e.name,explodedOffset:e.explodedHeight-e.elevation}),h.length==s){this.boxMap[o]=h;break}}const c=n.getLayerManager();let u=this._items;for(let e=0,t=u.length;e<t;e++){if(!u[e].getWorldPosition())continue;const t=c.getLayer(u[e].layerId);if(!t||!t.modelId)continue;if(t.modelId.toString()!==o||!u[e].levelName)continue;let i=h.getObjectByAttribute("floorName",u[e].levelName);i&&(u[e].explosionOffset={x:a.x*i.explodedOffset,y:a.y*i.explodedOffset,z:a.z*i.explodedOffset})}},n.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.FloorExplosion,(e=>{this.calculateViewerGISExplosionOffset(e)})),(()=>{n.getViewer().registerEventListener(CLOUD.EVENTS.ON_EXPLOSION,(e=>{let t=this.getAllItems();for(let i=0,o=t.length;i<o;i++)hn.attachExplosionOffset(n,e.extent,t[i])}))})(),i._items=[],i._viewer=n,i._context=r,i._isViewerGIS=o,i._areaData={},i.loadAreas=void 0,i.addItemCallback=[],i._maxNum=t.maxNum,i.getEventManager=function(){return s}}showOrHideLabelForCamearPosition(e,t){!e&&(e=this._viewer.getCameraStatus().position),t=t||this._items;for(let i=0;i<t.length;i++)if("number"==typeof t[i].visibleDistance){let n=this._viewer.latLonToWorld(t[i].location);Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2)+Math.pow(n.z-e.z,2))>t[i].visibleDistance?t[i].hideByCameraPosition():t[i].showByCameraPosition()}this.update()}handleEnableDepthTest(e){this._items&&this._items.length>0&&this._items.map((t=>{this._viewer.getViewer().camera.frustum.containsPoint(this._viewer.worldToScene(this._viewer.latLonToWorld(t.location)))&&t.handleEnableDepthTest(e)}))}addItem(e){i.send(t,"addItem");const n=this._items,o=this._viewer;if(e.viewer=o,e.update=this.update.bind(this),!e.location)return;let s=hn.ifExploded(o,e,this._isViewerGIS);s&&(n.push(s),this._enableRender&&this.update()),this.showOrHideLabelForCamearPosition(),e.handleEnableDepthTest&&e.handleEnableDepthTest()}removeItemById(e){i.send(t,"removeItemById");let n=this._items.removeObjectByAttribute("id",e);n=n&&n[0];let o=n._domElement||n._container;n&&this._context.rootDomElement.contains(o)&&o.remove(),n._svgGroup&&this._context.svgContainer.contains(n._svgGroup)&&this._context.svgContainer.removeChild(n._svgGroup),this.update()}getItemById(e){return this._items.getObjectByAttribute("id",e)}getAllItems(){return this._items}addItems(e){if(i.send(t,"addItems"),e.length)for(var n=0;n<e.length;n++)e[n].update=this.update.bind(this),e[n].viewer=this._viewer;for(const t of e){t.viewer=this._viewer,t.init&&t.init();let e=hn.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer)}this._enableRender&&this.update()}clear(){i.send(t,"clear"),this._items.map((e=>{let t=e._domElement||e._container;e&&this._context.rootDomElement.contains(t)&&t.remove(),e._svgGroup&&this._context.svgContainer.contains(e._svgGroup)&&this._context.svgContainer.removeChild(e._svgGroup)})),this._items=[],this.update()}update(){let e=this._items,t=this._viewer,i=this._context,n=this._maxNum;for(let i=0,n=e.length;i<n;i++){let n=e[i];n.needForceUpdate&&(n=hn.ifExploded(t,n,this._isViewerGIS),n.needForceUpdate=!1);let o=n.getCurrentPosition();n.clientPosition=t.worldToClient(o);let s=n._container||n._domElement,r=n._svgGroup;if(t.isInViewFrustum(o)){if(this.section&&!this.section.isIncluded(o)||n.forceHide||n.isHideByClustering&&!0!==n.isInAnimation){s&&(s.style.display="none"),r&&(r.style.display="none");continue}s&&(s.style.display=""),r&&(r.style.display="")}else s&&(s.style.display="none"),r&&(r.style.display="none")}e.sort((function(e,t){return e.clientPosition.z>=t.clientPosition.z?1:-1}));for(let t=0;t<e.length;t++){var o="default";t>=n&&(o="mini"),i.clientPosition=e[t].clientPosition,e[t].draw(i,o)}}exit(){i.send(t,"exit"),this.clear(),this._context.destroy()}hideItemsById(e){i.send(t,"hideItemsById");let n=this;if(e&&e.length>0)for(let t=0;t<e.length;t++){var o=n.getItemById(e[t]);o&&o.hide()}}hideAllItems(){i.send(t,"hideAllItems");let e=this._items;if(e&&e.length>0)for(let t=0;t<e.length;t++)e[t].hide()}showItemsById(e){i.send(t,"showItemsById");let n=this;if(e&&e.length>0)for(let t=0;t<e.length;t++){var o=n.getItemById(e[t]);o&&o.show()}}showAllItems(){i.send(t,"showAllItems");let e=this._items;if(e&&e.length>0)for(let t=0;t<e.length;t++)e[t].show()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure").MeasureConfig=function(){return{viewer:null,measureType:e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.PolylineDistance,color:new e.Web.Graphics.Color(249,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),width:3,radius:25,snapDistance:5,precision:{distance:3},scale:1,units:null,layerType:"TerrainLayer"}},function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure");let i=Object.freeze({Measuring:"Measuring",Measured:"Measured",Reset:"Reset",MeasureSelected:"MeasureSelected",MeasureUnselected:"MeasureUnselected",MeasureResultUpdating:"MeasureResultUpdating",MeasureResultUpdated:"MeasureResultUpdated"});t.MeasureEvent=i}(),function(){let t=Object.freeze({Angle:"Angle",Position:"Position",PolylineDistance:"PolylineDistance",TriangleDistance:"TriangleDistance",SpatialArea:"SpatialArea",ProjectedArea:"ProjectedArea",SurfaceArea:"SurfaceArea",GroundlineDistance:"GroundlineDistance"});e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure").MeasureTypeOption=t}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure").MeasureItemConfig=function(){return{id:null,color:new e.Web.Graphics.Color(255,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),fillColor:new e.Web.Graphics.Color(255,157,11,.2),objectColor:new e.Web.Graphics.Color(17,218,183,.9),width:3,radius:25,viewer:null}};class ar extends class{constructor(e){this.type=e,this.observer=null}initialize(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}drawAnnotation(e,t){}calcAnnotationStyle(e,t){}select(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="none"})),this.notationSelected.forEach((e=>{e.style.display="block"})))}unselect(){this.isInitialized()&&(this.notationUnselected.forEach((e=>{e.style.display="block"})),this.notationSelected.forEach((e=>{e.style.display="none"})))}dropShadow(e){this.isInitialized()&&this.notationUnselected.forEach((t=>{t.setAttribute("filter",e),t.setAttribute("filter",e)}))}isInitialized(){return!!this.notationUnselected&&!!this.notationSelected}clear(){this.notationSelected=[],this.notationUnselected=[],this.notationSegmentRects=[]}hitTest(e){if(!this.isInitialized())return!1;let t=this.hitTestEpsilon;return this.notationSegmentRects.some((i=>re.distanceToSegment(e,i.start,i.end)<=t))}}{constructor(e,t){super(e),this.defaultColor=t||"#20262F",this.initialize()}initialize(){super.initialize(),this.annotationStyle={height:this.calcAnnotationHeight(),radius:this.calcAnnotationRadius(),fillOpacity:.85},this.hitTestEpsilon=this.annotationStyle.height/2}drawAnnotation(e,t,i,o){var s=this.calcAnnotationStyle(t,e,o),r=re.makeRectangle({x:s.offsetRect.x,y:s.offsetRect.y,width:s.width,height:this.annotationStyle.height,radius:this.annotationStyle.radius,fillColor:this.defaultColor,fillOpacity:this.annotationStyle.fillOpacity});let a=new n(s.offsetRect.x,s.offsetRect.y+this.annotationStyle.height/2),l=new n(s.offsetRect.x+s.width,a.y);this.notationSegmentRects.push({start:a,end:l});let h=re.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#FFFFFF",fontsize:14,content:t});this.notationSelected.push(h);let d=re.makeText({x:s.offsetText.x,y:s.offsetText.y,color:"#A4A8AE",fontsize:14,content:t});if(this.notationUnselected.push(d),this.svgGroup=[],this.type==Glodon.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position){var c=re.makeRectangle({x:s.offsetArrow.x,y:s.offsetArrow.y,width:7,height:7,radius:0,fillColor:this.defaultColor,fillOpacity:this.annotationStyle.fillOpacity});c.setAttribute("transform",`rotate(45 ${s.offsetArrow.x} ${s.offsetArrow.y})`),this.svgGroup.push(c)}return this.svgGroup.push(r),this.svgGroup.push(d),this.svgGroup.push(h),this.unselect(),this.svgGroup}calcAnnotationStyle(e,t,i){var o=0,s=this.annotationStyle.height,r=new n(t.x,t.y),a=new n(t.x,t.y),l=new n(t.x,t.y);if(this.type==Glodon.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position){e.split("\n").forEach((e=>{let t=re.measureText(e);o=t>o?t:o})),o+=10,r.x-=o/2+5,r.y-=s+8+10,a.x=r.x+10,a.y=r.y+30-3.5}else o=re.measureText(e),!0===i?r.x+=15:r.x-=o/2,r.y-=this.annotationStyle.height/2,a.x=r.x+5,a.y=r.y+19-3.5;return l.y-=22.5,{offsetRect:r,offsetText:a,offsetArrow:l,width:o+=10}}calcAnnotationHeight(){let e=21;return"Position"==this.type&&(e=100),e}calcAnnotationRadius(){let e=4;return"Position"==this.type&&(e=0),e}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=new e.Web.Graphics.Color(17,218,183,.2),o=new e.Web.Graphics.Color(17,218,183,1),s=function(t){this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.nextMeasurePoint=null,this.measurePoints=[],this.maxPointsNum=2,this.measureResult=null,this.measureParams={precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit},this.measureItemConfig=t,this.viewer=t.viewer;t.color.getRGBA();let s=i.createNS("circle","bf-measure-handle");s.setAttribute("stroke-width",0),s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();let r=i.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=n.getRGB();let a=i.createNS("polygon","bf-measure-rect");a.setAttribute("fill",n.getRGBA()),a.setAttribute("stroke",n.getRGB()),a.setAttribute("stroke-width",1);var l=i.createNS("path","bf-measure-foot");l.setAttribute("fill","none"),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("rect","bf-snap-handle");h.setAttribute("width",14),h.setAttribute("height",14),h.setAttribute("fill","none"),h.setAttribute("stroke",o.getRGB()),h.setAttribute("stroke-width",2);const d=i.createNS("path","bf-snap-handle");d.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),d.setAttribute("fill","none"),d.setAttribute("stroke",o.getRGB()),d.setAttribute("stroke-width",2);const c=i.createNS("line","bf-snap-handle");c.setAttribute("x1",0),c.setAttribute("y1",0),c.setAttribute("x2",14),c.setAttribute("y2",14),c.setAttribute("stroke",n.getRGB()),c.setAttribute("stroke-width",2);const u=i.createNS("line","bf-snap-handle");u.setAttribute("x1",14),u.setAttribute("y1",0),u.setAttribute("x2",0),u.setAttribute("y2",14),u.setAttribute("stroke",n.getRGB()),u.setAttribute("stroke-width",2),this.hoverFoot=l,this.hoverPoint=s,this.hoverLine=r,this.hoverPanel=a,this.hoverEndPoint=h,this.hoverMidPoint=d,this.hoverIntersectionPointA=c,this.hoverIntersectionPointB=u,this.hoverPanelSize={width:20,height:20},this.defaultColor=`#${t.color.getHEX()}`||"#F99D0B",this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.measureType=t.type,this.notation=new ar(this.measureType),this.isReserverd=!1,this.hoverPositionUpdated=!1};s.prototype={stretchOnDirection:function(e,t,i){let n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){},drawLine(e){if(0===e.length)return;let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this._svg.appendChild(t)},drawTerminalPoint(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)},drawNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this._svg.appendChild(e)},drawCaptureItem:function(e){let t=this.hoverPoint,i=this.hoverLine,n=this.hoverPanel,o=this.hoverEndPoint,s=this.hoverMidPoint,r=this.hoverIntersectionPointA,a=this.hoverIntersectionPointB,l=e.hoverPosition&&e.hoverPosition.x,h=e.hoverPosition&&e.hoverPosition.y,d=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":t.setAttribute("cx",l),t.setAttribute("cy",h),e.svg.appendChild(t);break;case"EndPoint":o.setAttribute("x",l-7),o.setAttribute("y",h-7),e.svg.appendChild(o);break;case"MidPoint":s.setAttribute("d",`M ${l} ${h-7} L ${l+8} ${h+8} L ${l-8} ${h+8} L ${l} ${h-7}`),e.svg.appendChild(s);break;case"IntersectionPoint":r.setAttribute("x1",l-7),r.setAttribute("y1",h-7),r.setAttribute("x2",l+7),r.setAttribute("y2",h+7),e.svg.appendChild(r),a.setAttribute("x1",l+7),a.setAttribute("y1",h-7),a.setAttribute("x2",l-7),a.setAttribute("y2",h+7),e.svg.appendChild(a);break;case"Line":if(e.footPoint){let t=e.footPoint.x,i=e.footPoint.y;this.hoverFoot.setAttribute("d",`M ${t},${i-14} v 14 h 14 M ${t},${i-9} h 9 v 9`),e.svg.appendChild(this.hoverFoot)}else i.setAttribute("x1",e.lineStartPoint.x),i.setAttribute("y1",e.lineStartPoint.y),i.setAttribute("x2",e.lineEndPoint.x),i.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(i);break;case"Panel":let c=e.clientPts,u=c[0].distanceTo(c[1]),g=c[0].distanceTo(c[3]),p=u/d.width,m=g/d.height;if(1!=p){let e=this.stretchOnDirection(c[0],c[1],d.width),t=this.stretchOnDirection(c[2],c[3],d.width);c=e.concat(t)}if(1!=m){let e=this.stretchOnDirection(c[0],c[3],d.height),t=this.stretchOnDirection(c[1],c[2],d.height);c=[e[0],t[0],t[1],e[1]]}let f="";for(let e=0;e<c.length;e++)f+=c[e].x+",",f+=c[e].y+" ";n.setAttribute("points",f),e.svg.appendChild(n)}},reset:function(){if(this.measurePoints=[],this.nextMeasurePoint=null,this.measureResult=null,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},addPoint:function(e){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)},redo:function(){this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?this.measurePoints.pop():this.measurePoints=[]},getPoints:function(){return this.measurePoints},calcLine:function(e,t){let i=[];var n=this.viewer.getViewer(),o=this.viewer.getDomElement().getBoundingClientRect(),s=n.worldPointsToClient(e,t);if(s){e=new THREE.Vector2(s.start.x-o.left,s.start.y-o.top),t=new THREE.Vector2(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i},setMeasureParams:function(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit},setIsReserverd:function(e){this.isReserverd=e},getIsReserverd:function(){return this.isReserverd}},t.MeasureItem=s}();class lr{constructor(){}static formatDistance(e,t){if(null==e)return null;let i=t.precision,n=t.scale||1,o=t.unit,s=1;return"Centimeter"===o?s=10:"Meter"===o?s=1e3:"Kilometer"===o&&(s=1e6),"m"===t.defaultUnit&&(n*=1e3),e*=n,e/=s,this.formatPrecision(e,i)}static formatArea(e,t){let i=t.precision,n=t.scale,o=t.unit,s=1;return"Centimeter"===o?s=100:"Meter"===o?s=1e6:"Kilometer"===o&&(s=1e13),"m"===t.defaultUnit&&(n*=1e3),e*=Math.pow(n,2),e/=s,this.formatPrecision(e,i)}static getPostFix(e,t){if("None"===e)return"";let i={None:"",Kilometer:"km",Meter:"m",Centimeter:"cm",Millimeter:"mm"}[e];return t?i+="²":i=" "+i,i}static toLocaleString(e){let t=e.toString();return t=t.replace(/\d{1,3}(?=((\d{3})+(\.\d+)?)$)/g,"$&,"),t}static formatPrecision(e,t){if(e=parseInt(Math.round(e*Math.pow(10,t)))/Math.pow(10,t),0!=t){let i=e.toFixed(t).split(".");e=i[0]+"."+i[1]}else e=this.toLocaleString(e);return e}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=(new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.maxPointsNum=3,this.radius=e.radius,this.measurePoints=[];var t=e.color.getRGBA(),o=n.createNS("circle","bf-measure-handle");o.setAttribute("stroke-width",0),o.setAttribute("r",5),o.setAttribute("stroke","#FFFFFF"),o.setAttribute("stroke-width",2),o.setAttribute("fill",t),o.style.fill=t;var s=o.cloneNode(),r=o.cloneNode(),a=n.createNS("path","bf-measure-angle");a.setAttribute("fill","rgba(0,0,0,0)"),a.setAttribute("stroke",t),a.setAttribute("stroke-width",e.width);var l=n.createNS("line","bf-measure-line");l.style.strokeWidth=e.width,l.style.stroke=t,l.setAttribute("stroke-width",e.width);var h=l.cloneNode(),d=n.create("span","bf-measure-number");d.style.backgroundColor=e.color.getRGBA(),this.points=[o,s,r],this.lines=[l,h],this.angleLine=a,this.text=d});t.Type.inheritPrototype(o,i.MeasureItem);var s={_getPoint:function(e,t,i,n){e=new THREE.Vector2(e.x,e.y),t=new THREE.Vector2(t.x,t.y),i=new THREE.Vector2(i.x,i.y);var o=1,s=e.sub(t),r=i.sub(t);if(s.length()<n||r.length()<n)return!1;s.setLength(n),r.setLength(n);var a=s.angle(),l=180*(r.angle()-a)/Math.PI;return l<0&&(l+=360),o=l<180?1:0,{pointA:t.clone().add(s),pointB:t.clone().add(r),flag:1,direction:o}},draw:function(e,t){var i=this.points;if(this._svg=e.svg,this.drawCaptureItem(e),this.getIsReserverd())return;for(var n=0,o=e.clientPoints.length;n<o;n++)e.clientPoints[n]&&(i[n].setAttribute("cx",e.clientPoints[n].x),i[n].setAttribute("cy",e.clientPoints[n].y),e.svg.appendChild(i[n]));"ViewerGIS"===this.viewer.viewerType?this.drawAngleWithResult(e,t):this.drawAngle(e)},drawAngle:function(e){var t=this.lines,i=this.angleLine;switch(e.clientPoints.length){case 3:t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.clientPoints[1].x),t[0].setAttribute("y2",e.clientPoints[1].y),t[1].setAttribute("x1",e.clientPoints[1].x),t[1].setAttribute("y1",e.clientPoints[1].y),t[1].setAttribute("x2",e.clientPoints[2].x),t[1].setAttribute("y2",e.clientPoints[2].y);var n=this.radius,o=this._getPoint(e.clientPoints[0],e.clientPoints[1],e.clientPoints[2],n);o&&(i.setAttribute("d",`M ${o.pointA.x} ${o.pointA.y} A ${n} ${n} 0 0 ${o.direction} ${o.pointB.x} ${o.pointB.y}`),e.svg.appendChild(i)),e.svg.appendChild(t[1]),e.svg.appendChild(t[0]);break;case 2:t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.clientPoints[1].x),t[0].setAttribute("y2",e.clientPoints[1].y),e.svg.appendChild(t[0]),this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(t[1].setAttribute("x1",e.clientPoints[1].x),t[1].setAttribute("y1",e.clientPoints[1].y),t[1].setAttribute("x2",e.hoverPosition.x),t[1].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(t[1]));break;case 1:this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(t[0].setAttribute("x1",e.clientPoints[0].x),t[0].setAttribute("y1",e.clientPoints[0].y),t[0].setAttribute("x2",e.hoverPosition.x),t[0].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(t[0]))}},drawAngleWithResult:function(e,t){var i=this.lines,n=this.angleLine;switch(this.measureResult=t.angle,e.clientPoints.length){case 2:i[0].setAttribute("x1",e.clientPoints[0].x),i[0].setAttribute("y1",e.clientPoints[0].y),i[0].setAttribute("x2",e.clientPoints[1].x),i[0].setAttribute("y2",e.clientPoints[1].y),i[1].setAttribute("x1",e.clientPoints[1].x),i[1].setAttribute("y1",e.clientPoints[1].y),i[1].setAttribute("x2",e.hoverPosition.x),i[1].setAttribute("y2",e.hoverPosition.y);var o=this.radius,s=this._getPoint(e.clientPoints[0],e.clientPoints[1],e.hoverPosition,o);s&&(n.setAttribute("d",`M ${s.pointA.x} ${s.pointA.y} A ${o} ${o} 0 0 ${s.direction} ${s.pointB.x} ${s.pointB.y}`),e.svg.appendChild(n)),e.svg.appendChild(i[1]),e.svg.appendChild(i[0]),this.drawNotation(e,s);break;case 1:this.getPoints().length!=this.maxPointsNum&&e.hoverPosition&&(i[0].setAttribute("x1",e.clientPoints[0].x),i[0].setAttribute("y1",e.clientPoints[0].y),i[0].setAttribute("x2",e.hoverPosition.x),i[0].setAttribute("y2",e.hoverPosition.y),e.svg.appendChild(i[0]))}},drawNotation(e,t){if(t){var i=new THREE.Vector2((t.pointA.x+t.pointB.x)/2,(t.pointA.y+t.pointB.y)/2),n=new THREE.Vector2(e.clientPoints[1].x,e.clientPoints[1].y),o=i.clone().sub(n).normalize().multiplyScalar(35);i=n.clone().add(o);let s=this.notation.drawAnnotation(i,this.getMeasureResult(),this.id);for(const t of s)e.svg.appendChild(t)}},getMeasureResult(){this.measureParams.unit;let e=this.measureResult.toString();return lr.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}};o.prototype=Object.assign(o.prototype,s),i.MeasureAngleItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0!==this.measureEnd||this.measurePoints.length==this.maxPointsNum){if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}else this.maxPointsNum=this.measurePoints.length},draw:function(e,t){if(this.measureResult=t,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.getMeasureResult();this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.drawLine([e.clientPoints[0],e.hoverPosition]),this.drawNotations();break;default:for(let t=1;t<e.clientPoints.length;t++)this.drawTerminalPoint(e.clientPoints[t-1]),this.drawLine([e.clientPoints[t-1],e.clientPoints[t]]),this.drawTerminalPoint(e.clientPoints[t]),e.hoverPosition&&t==e.clientPoints.length-1&&this.drawLine([e.clientPoints[t],e.hoverPosition]);this.drawNotations()}},drawNotations(){let e=[...this.measurePoints];this.hoverPositionUpdated&&this.nextMeasurePoint&&e.push(this.nextMeasurePoint);const t=e.length,i=this.getMeasureResult();for(let n=1;n<t;n++){let t={x:(e[n].x+e[n-1].x)/2,y:(e[n].y+e[n-1].y)/2,z:(e[n].z+e[n-1].z)/2},o=this.viewer.worldToClient(t);this.viewer.isInViewFrustum(t)&&this.drawNotation([o,o],i.distance[n-1])}let n={x:e[t-1].x,y:e[t-1].y,z:e[t-1].z},o=this.viewer.worldToClient(n);this.viewer.isInViewFrustum(n)&&this.drawNotation([o,o],`总长度:${i.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)},getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=lr.formatDistance(o,this.measureParams),o+=lr.getPostFix(e,!1),{distance:n,totalDistance:o}}};n.prototype=Object.assign(n.prototype,o),i.MeasurePolylineDistanceItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){i.MeasureItem.call(this,t),this.viewer=t.viewer,this.maxPointsNum=1;var o=new e.Web.Graphics.Color(17,218,183,.2),s=n.createNS("circle","bf-measure-handle");s.setAttribute("r",t.width),s.setAttribute("fill",o.getRGB()),s.style.fill=o.getRGB();var r=n.createNS("line","bf-measure-line");r.style.strokeWidth=2,r.style.stroke=o.getRGB();var a=n.createNS("polygon","bf-measure-rect");a.setAttribute("fill",o.getRGBA()),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",1),this.hoverLine=r,this.hoverPoint=s,this.hoverPanel=a,this.hoverPanelSize={width:20,height:20}};t.Type.inheritPrototype(o,i.MeasureItem);o.prototype=Object.assign(o.prototype,{draw:function(e){this.drawCaptureItem(e)}}),i.MeasurePositionItem=o}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e)});t.Type.inheritPrototype(n,i.MeasureItem);var o={draw:function(e,t){const i=this.measurePoints,n=this.nextMeasurePoint;if(this._svg=e.svg,this.measureResult={distance:t.distance,horizontalDistance:t.horizontalDistance,verticalDistance:t.verticalDistance},this.drawCaptureItem(e),this.getIsReserverd()||0==i.length)return;let o=i.concat([n]),s=this.getMeasureResult(),r=this.calcLine(o[0],o[1]);if(this.drawTerminalPoint(r[0]),this.drawBorderlineByPoints(o,s.distance),o[0].length()!=o[1].length()){let e=o[0].length()<o[1].length()?o[0]:o[1],t=o[0].length()<o[1].length()?o[1]:o[0],i=this.calcTrianglePoint(o);this.drawBorderlineByPoints([e,i],s.verticalDistance),this.drawBorderlineByPoints([t,i],s.horizontalDistance)}else this.drawBorderlineByPoints([o[0],o[0]],s.horizontalDistance)},calcTrianglePoint(e){if(e.length<2)return null;let t=new THREE.Vector3;if(e[0].length()<e[1].length()){let i=new THREE.Ray;i.direction=e[0].clone().normalize(),i.closestPointToPoint(e[1].clone(),t)}else{let i=new THREE.Ray;i.direction=e[1].clone().normalize(),i.closestPointToPoint(e[0].clone(),t)}return t},drawBorderlineByPoints(e,t){let i=e[0],n=e[1],o=this.calcLine(i,n);this.drawLine(o);let s={x:(i.x+n.x)/2,y:(i.y+n.y)/2,z:(i.z+n.z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.drawNotation([r,r],t)},drawNotation:function(e,t){if(0===e.length)return;let i=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id);for(const e of i)this._svg.appendChild(e)},getMeasureResult:function(){const e=this.measureParams.unit;let{distance:t,horizontalDistance:i,verticalDistance:n}=this.measureResult;return t=t.toString(),t=lr.formatDistance(t,this.measureParams),t+=lr.getPostFix(e,!1),i=i.toString(),i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(e,!1),n=n.toString(),n=lr.formatDistance(n,this.measureParams),n+=lr.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}};n.prototype=Object.assign(n.prototype,o),i.MeasureTriangleDistanceItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureItem.call(this,e),this.measureEnd=!1,this.minPointsNum=3,this.maxPointsNum=1/0});t.Type.inheritPrototype(n,i.MeasureItem);var o={addPoint:function(e){if(!0!==this.measureEnd||this.measurePoints.length==this.maxPointsNum){if(this.measurePoints.length==this.maxPointsNum)this.measureEnd=!1,this.maxPointsNum=1/0,this.measurePoints=[],this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1)}else this.maxPointsNum=this.measurePoints.length},reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}},draw:function(e,t){if(this.measureResult=t.area,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:if(e.hoverPosition){let t=re.makeLine({start:e.clientPoints[0],end:e.hoverPosition,color:this.measureItemConfig.color.getRGBA(),lineWidth:this.measureItemConfig.width});e.svg.appendChild(t)}let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e.clientPoints[0]});t.setAttribute("filter",this.filterUrl),e.svg.appendChild(t);break;default:this.drawArea(e.clientPoints,e.hoverPosition),this.drawNotation(e.hoverPosition,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}},drawArea:function(e,t){const i=t?e.concat(t):e;let n="";i.forEach((e=>{n+=e.x+","+e.y+" "}));let o=re.makePolygon({points:n,width:this.measureItemConfig.width,color:this.measureItemConfig.color.getRGBA(),fillColor:this.measureItemConfig.fillColor.getRGBA()});this._svg.appendChild(o),e.forEach((e=>{let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)}))},drawNotation:function(e,t){let i=this.notation.drawAnnotation({x:e.x,y:e.y},t,this.id,!0);for(const e of i)this._svg.appendChild(e)},getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_spatial_area,getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=lr.formatArea(t,this.measureParams),t+=lr.getPostFix(e,!0),t}};n.prototype=Object.assign(n.prototype,o),i.MeasureSpatialAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e)});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_projected_area};n.prototype=Object.assign(n.prototype,o),i.MeasureProjectedAreaItem=n}();class hr{constructor(t){t&&(this._opt=t,this.measurePoints=t.points||[],this.fillColor=t.fillColor||new e.Web.Graphics.Color(255,157,11,.2),this.borderColor=t.color||new e.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3,this.update())}setMeasurePoints(e){"[object Array]"===Object.prototype.toString.call(e)?(this.measurePoints=e,this.update()):console.warn("Parameter points is invalid.")}update(){if(this.measurePoints.length<2)this.disposeGroundBorder(),this.disposeGroundSurface();else if(2===this.measurePoints.length)this.disposeGroundSurface(),this.updateGroundBorder(this.measurePoints);else if(this.measurePoints.length>2){this.updateGroundSurface(this.measurePoints);let e=[...this.measurePoints];e.push(this.measurePoints[0]),this.updateGroundBorder(e)}}updateGroundBorder(e){this.groundBorder?this.groundBorder.geometry.updateGeometry({points:e}):(this.groundBorder=CLOUD.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundBorder.onAdded())}updateGroundSurface(e){this.groundSurface?this.groundSurface.geometry.updateGeometry({points:e}):(this.groundSurface=CLOUD.GroundPrimitiveManager.getInstance().createGroundPolygon({points:e,color:this.fillColor}),this.groundSurface.onAdded())}updateTerminalPoints(e){this.selectedGroup||(this.selectedGroup=new THREE.Group,this.add(this.selectedGroup));let t=this.selectedGroup.children;for(let e=t.length-1;e>=0;e--)this.selectedGroup.remove(t[e]);let i=new THREE.CircleGeometry(200,180),n=new THREE.MeshBasicMaterial({color:this.borderColor,side:THREE.DoubleSide,depthTest:!1}),o=new THREE.Mesh(i,n);for(let t=0,i=e.length;t<i;t++){let i=o.clone();i.position.copy(e[t]),this.selectedGroup.add(i)}this.updateMatrixWorld()}hide(){this.hideGroundSurface(),this.hideGroundBorder()}hideGroundSurface(){this.groundSurface&&(this.groundSurface.visible=!1)}hideGroundBorder(){this.groundBorder&&(this.groundBorder.visible=!1)}show(){this.showGroundSurface(),this.showGroundBorder()}showGroundSurface(){this.groundSurface&&(this.groundSurface.visible=!0)}showGroundBorder(){this.groundBorder&&(this.groundBorder.visible=!0)}disposeGroundSurface(){this.groundSurface&&(this.groundSurface.onRemoved(),this.groundSurface.dispose(),this.groundSurface=null)}disposeGroundBorder(){this.groundBorder&&(this.groundBorder.onRemoved(),this.groundBorder.dispose(),this.groundBorder=null)}dispose(){this.measurePoints=null,this.disposeGroundSurface(),this.disposeGroundBorder()}}!function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(e){i.MeasureSpatialAreaItem.call(this,e),this.defaultColor=e.color,this.fillColor=e.fillColor,this.borderWidth=e.width,this.measureSurfaceMesh=null});t.Type.inheritPrototype(n,i.MeasureSpatialAreaItem);let o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)},draw:function(e,t){if(this.measureResult=t.area,this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(this.measurePoints.length){case 0:this.measureSurfaceMesh&&this.measureSurfaceMesh.dispose();break;case 1:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition);break;default:this.drawArea(this.measurePoints,e.hoverPosition),this.drawTerminals(e.clientPoints,e.hoverPosition),this.drawNotation(e.hoverPosition,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}},drawArea(t,i){const n=this.viewer.getDomElement().getBoundingClientRect&&this.viewer.getDomElement().getBoundingClientRect(),o=n?n.x:0,s=n?n.y:0,r={x:i.x+o,y:i.y+s,z:i.z};let a=this.viewer.clientToWorld(r),l=[...t];l.push(a),this.measureSurfaceMesh||(this.measureSurfaceMesh=new hr({fillColor:new e.Web.Graphics.Color(255,157,11,.2),color:new e.Web.Graphics.Color(255,157,11,1),width:this.borderWidth})),this.measureSurfaceMesh.setMeasurePoints(l),this.viewer.render()},drawTerminals(e,t){t&&e.concat(t);e.forEach((e=>{let t=re.makeCircle({strokeWidth:2,color:this.measureItemConfig.color.getRGBA(),radius:5,position:e});t.setAttribute("filter",this.filterUrl),this._svg.appendChild(t)}))},getNotationTitle:()=>BimfaceLanguage.bf_tip_measure_surface_area};n.prototype=Object.assign(n.prototype,o),i.MeasureSurfaceAreaItem=n}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),new e.Web.Graphics.Color(17,218,183,.2),function(t){i.MeasureItem.call(this,t),this.measureEnd=!1,this.maxPointsNum=1/0,this.minPointsNum=2,this.groundInfos=[],this.mesh=null,this.borderColor=t.color||new e.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3,this.groundLineInfos=[],this.lastGroundLineMes={}});t.Type.inheritPrototype(n,i.MeasureItem);var o={reset:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},redo(){this.measurePoints.length>0&&this.measurePoints.length<this.maxPointsNum?(this.measurePoints.pop(),this.groundLineInfos.pop()):this.measurePoints=[],this.groundInfos=[],this.clearGroundLine()},clear:function(){if(this.measurePoints=[],this.measureEnd=!1,this.maxPointsNum=1/0,this._svg){for(var e=this._svg.childNodes,t=e.length-1;t>-1;t--)this._svg.removeChild(e[t]);this._svg.innerHTML=""}this.groundInfos=[],this.groundLineInfos=[],this.clearGroundLine()},addPoint:function(e){if(this.hoverPositionUpdated=!1,!0===this.measureEnd&&this.measurePoints.length!=this.maxPointsNum)return this.maxPointsNum=this.measurePoints.length,this.groundInfos.length==this.measurePoints.length&&this.groundInfos.pop(),void this.clearGroundLine();if(this.measurePoints.length==this.maxPointsNum)this.reset();else if(this.measurePoints.length>0){let t=this.measurePoints.length,i=this.measurePoints[t-1];if(e.x===i.x&&e.y===i.y&&e.z===i.z)return}this.measurePoints.push(e),this.setIsReserverd(!1),this.measurePoints.length>1&&this.groundLineInfos.push(this.calculateGroundlineDistance(this.measurePoints[this.measurePoints.length-2],this.measurePoints[this.measurePoints.length-1]))},updateGroundLine(e){this.groundLine?this.groundLine.geometry.updateGeometry({points:e}):(this.groundLine=y.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundLine.onAdded()),this.viewer.render()},clearGroundLine(){this.groundLine&&(this.groundLine.onRemoved(),this.groundLine.dispose(),this.groundLine=null)},calculateGroundlineDistance(t,i){if(!t||!i)return null;let n=this.viewer,o=new THREE.Vector3(t.x,t.y,t.z),s=new THREE.Vector3(i.x,i.y,i.z);if(o.equals(s))return null;if(this.lastPoint0&&this.lastPoint1&&o.equals(this.lastPoint0)&&s.equals(this.lastPoint1))return this.lastGroundInfo;let r,a=[];a.push(o),a.push(s),r=new THREE.CatmullRomCurve3(a),r.tension=0,r.type="catmullrom";var l=new y.Raycaster,h=(new THREE.Vector3,n.getViewer().cameraControl.getIntersectContext(null)),d=new y.SphereIntersectHelper(n.getViewer());l.camera=h.camera,l.viewportSize=h.viewportSize;var c=[];r.getPoints(100).forEach((e=>{n.getViewer().setSphereIntersectRay(l,e);let t=d.getTileSphereGroupByRaycaster(h,l,!0);if(t.length>0){let e;e=n.sceneToWorld(t[0].point),c.push(e)}else c.push(e)})),r=null;let u=new e.Bimface.Plugins.Geometry.SplineCurve(c);return u.projectToGround(!0),n.render(),this.lastPoint0=o,this.lastPoint1=s,this.lastGroundInfo={length:u.length,midPoint:u.getPointByParameter(.5),endPoint:u.getPointByParameter(1),status:"finished"},this.lastGroundInfo},draw:function(e,t){if(this._svg=e.svg,this.drawCaptureItem(e),!this.getIsReserverd())switch(e.clientPoints.length){case 0:break;case 1:this.drawTerminalPoint(e.clientPoints[0]),e.hoverPosition&&this.nextMeasurePoint&&this.updateGroundLine([...this.measurePoints,this.nextMeasurePoint]),this.drawNotations();break;default:for(let t=1;t<e.clientPoints.length;t++)this.drawTerminalPoint(e.clientPoints[t-1]),this.drawTerminalPoint(e.clientPoints[t]);this.updateGroundLine([...this.measurePoints,this.nextMeasurePoint]),this.drawNotations()}},drawNotations(){let e=null,t=0,i=[...this.measurePoints,this.nextMeasurePoint];for(let n=0;n<this.groundInfos.length;n++){let o=this.groundInfos[n],s={x:(i[n].x+i[n+1].x)/2,y:(i[n].y+i[n+1].y)/2,z:(i[n].z+i[n+1].z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.drawNotation([r,r],this.formatDistance(o.length)),t+=o.length,n===this.groundInfos.length-1&&(e=i[n+1])}if(e){let i={x:e.x,y:e.y,z:e.z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.drawNotation([n,n],`总长度:${this.formatDistance(t)}`,!0)}this.notation.dropShadow(this.filterUrl)},formatDistance(e){let t=this.measureParams.unit,i=e.toString();return i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(t,!1),i}};n.prototype=Object.assign(n.prototype,o),i.MeasureGroundlineDistanceItem=n}();class dr{constructor(e,t,i,n){this.viewer=e,this.id=t,this.type=i,this.isShow=!0,this.xmlns="http://www.w3.org/2000/svg",this.defaultColor=n.defaultColor||"#F99D0B",this.svgGroup=[],this.lineWidth="3",this.radius=5,this.strokeWidth=2,this.hitTestEpsilon=10,this.hitTestSegments=[],this.selectElements=[],this.unSelectElements=[],this.elementsOnTop=[],this.isSelected=!0,this.notation=new ar(i),this.measureParams={precision:0,scale:1,unit:"None"}}getSvgGroup(){return this.svgGroup}getId(){return this.id}getType(){return this.type}clear(e){this.detach(e),this.notation.clear(e),this.svgGroup=[],this.hitTestSegments=[]}detach(e){for(const e of this.svgGroup){(t=e.parentNode)&&t.removeChild(e)}for(const e of this.elementsOnTop){var t;(t=e.parentNode)&&t.removeChild(e)}}attach(e){for(const t of this.svgGroup)e.appendChild(t)}calcLine(e,t){let i=[];this.viewer.getViewer();var o=this.viewer.getDomElement().getBoundingClientRect(),s=this.viewer.viewerAdapter.worldPointsToClient(e,t);if(s){e=new n(s.start.x-o.left,s.start.y-o.top),t=new n(s.end.x-o.left,s.end.y-o.top);i.push(e,t)}return i}calcTerminalLines(e,t,i){if(0===e.length)return[];let n=[],o=e[0],s=e[1],r=o.clone().sub(s).normalize(),a=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),t),l=r.clone().multiplyScalar(i).add(o).rotateAround(o.clone(),-t);n.push({start:a,end:l}),r=r.multiplyScalar(-1);let h=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),t),d=r.clone().multiplyScalar(i).add(s).rotateAround(s.clone(),-t);return n.push({start:h,end:d}),n}select(){for(const e of this.selectElements)e.style.display="none";for(const e of this.unSelectElements)e.style.display="block";this.notation.select(),this.isSelected=!0}unselect(){for(const e of this.selectElements)e.style.display="block";for(const e of this.unSelectElements)e.style.display="none";this.notation.unselect(),this.isSelected=!1}getIsSelected(){return this.isSelected}actionWhenSelected(){}actionWhenUnselected(){}dropShadow(e){this.notation.dropShadow(e)}setMeasureParams(e){this.measureParams.precision=e.precision,this.measureParams.scale=e.scale,this.measureParams.unit=e.unit,this.measureParams.defaultUnit=e.defaultUnit}show(){for(const e of this.svgGroup)e.style.display="block";for(const e of this.elementsOnTop)e.style.display="block";this.isShow=!0}hide(){for(const e of this.svgGroup)e.style.display="none";for(const e of this.elementsOnTop)e.style.display="none";this.isShow=!1}getNotation(){return this.notation}hitTest(e){let t=this.hitTestEpsilon;for(let i=0;i<this.hitTestSegments.length-1;i++){if(re.distanceToSegment(e,this.hitTestSegments[i],this.hitTestSegments[i+1])<=t)return!0}return!1}}class cr extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){let e=this.worldPositions.length;if(!(e<2)){for(let t=1;t<e;t++){let e=this.calcLine(this.worldPositions[t],this.worldPositions[t-1]);0!==e.length&&(1===t&&this.hitTestSegments.push(e[1]),this.hitTestSegments.push(e[0]),this.attachSelectedTerminalPoints(e[0]),this.attachLines(e),this.attachSelectedTerminalPoints(e[1]),this.attachUnselectedTerminalPoints(e[0]),this.attachUnselectedTerminalPoints(e[1]))}this.attachNotations(),this.unselect()}}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachLines(e){let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotations(){const e=this.worldPositions.length,t=this.getMeasureResult();for(let i=1;i<e;i++){let e={x:(this.worldPositions[i].x+this.worldPositions[i-1].x)/2,y:(this.worldPositions[i].y+this.worldPositions[i-1].y)/2,z:(this.worldPositions[i].z+this.worldPositions[i-1].z)/2},n=this.viewer.worldToClient(e);this.viewer.isInViewFrustum(e)&&this.attachNotation([n,n],t.distance[i-1])}let i={x:this.worldPositions[e-1].x,y:this.worldPositions[e-1].y,z:this.worldPositions[e-1].z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.attachNotation([n,n],`总长度:${t.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)}attachNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this.svgGroup.push(e)}getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=lr.formatDistance(o,this.measureParams),o+=lr.getPostFix(e,!1),{distance:n,totalDistance:o}}}class ur extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureAngle=t.angle,this.setMeasureParams({precision:t.precision})}initialize(){let e=this.getClientPoints();if(!e)return;this.hitTestSegments=e;for(let t=0;t<e.length-1;t++){let i=re.makeLine({start:e[t],end:e[t+1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(i)}for(let t=0;t<e.length;t++){let i=re.makeCircle({position:e[t],radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.unSelectElements.push(i),this.svgGroup.push(i),i.setAttribute("filter",this.filterUrl)}var t=this.getArcData(e[0],e[1],e[2]);if(!t)return void this.unselect();var i=re.makePath({color:this.defaultColor,lineWidth:this.lineWidth,arcRadius:25,info:t});this.svgGroup.push(i);var o=new n((t.pointA.x+t.pointB.x)/2,(t.pointA.y+t.pointB.y)/2),s=new n(e[1].x,e[1].y),r=o.clone().sub(s);if(0==r.x&&0==r.y){var a=0==s.clone().sub(t.pointA).y;a&&0==t.direction?r.y=35:a&&1==t.direction?r.y=-35:a||0!=t.direction?a||1!=t.direction||(r.x=35):r.x=-35}else r.normalize().multiplyScalar(35);o=s.clone().add(r);let l=this.notation.drawAnnotation(o,this.getMeasureResult(),this.id);for(const e of l)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}getClientPoints(){let e=[],t=this.calcLine(this.worldPositions[0],this.worldPositions[1]),i=this.calcLine(this.worldPositions[1],this.worldPositions[2]);return t.length>0&&e.push(t[0],t[1]),i.length>0&&(e.length>0?e.push(i[1]):e.push(i[0],i[1])),e}getArcData(e,t,i){if(!e||!t||!i)return!1;e=new n(e.x,e.y),t=new n(t.x,t.y),i=new n(i.x,i.y);var o,s=e.sub(t),r=i.sub(t);if(s.length()<25||r.length()<25)return!1;s.setLength(25),r.setLength(25);var a=s.angle(),l=180*(r.angle()-a)/Math.PI;return l<0&&(l+=360),o=l<180?1:0,{pointA:t.clone().add(s),pointB:t.clone().add(r),flag:1,direction:o}}getMeasureResult(){this.measureParams.unit;let e=this.measureAngle.toString();return lr.formatPrecision(e,this.measureParams.precision).split(",").join("")+"°"}}class gr extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult={distance:t.distance,totalDistance:t.totalDistance},this.groundInfos=t.groundInfos,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit}),this.borderColor=n.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=n.width||3}initialize(){let e=this.worldPositions.length;if(!(e<2)){for(let t=1;t<e;t++){let e=this.calcLine(this.worldPositions[t],this.worldPositions[t-1]);0!==e.length&&(1===t&&this.hitTestSegments.push(e[1]),this.hitTestSegments.push(e[0]),this.attachSelectedTerminalPoints(e[0]),this.attachSelectedTerminalPoints(e[1]),this.attachUnselectedTerminalPoints(e[0]),this.attachUnselectedTerminalPoints(e[1]))}this.updateGroundLine(this.worldPositions),this.attachNotations(),this.unselect()}}updateGroundLine(e){this.groundLine?this.groundLine.geometry.updateGeometry({points:e}):(this.groundLine=CLOUD.GroundPrimitiveManager.getInstance().createGroundCurve({points:e,color:this.borderColor,width:this.borderWidth,style:"Continuous",type:"polyline"}),this.groundLine.onAdded())}clearGroundLine(){this.groundLine&&(this.groundLine.onRemoved(),this.groundLine.dispose(),this.groundLine=null)}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachLines(e){}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotations(){const e=this.worldPositions.length,t=this.getMeasureResult();for(let i=0;i<e-1;i++){let e={x:(this.worldPositions[i].x+this.worldPositions[i+1].x)/2,y:(this.worldPositions[i].y+this.worldPositions[i+1].y)/2,z:(this.worldPositions[i].z+this.worldPositions[i+1].z)/2},n=this.viewer.worldToClient(e);this.viewer.isInViewFrustum(e)&&this.attachNotation([n,n],t.distance[i])}let i={x:this.worldPositions[e-1].x,y:this.worldPositions[e-1].y,z:this.worldPositions[e-1].z},n=this.viewer.worldToClient(i);this.viewer.isInViewFrustum(i)&&this.attachNotation([n,n],`总长度:${t.totalDistance}`,!0),this.notation.dropShadow(this.filterUrl)}attachNotation(e,t,i){if(0===e.length)return;let n=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id,i);for(const e of n)this.svgGroup.push(e)}detach(e){super.detach(),e&&this.clearGroundLine()}getMeasureResult(){let e=this.measureParams.unit,{distance:t,totalDistance:i}=this.measureResult,n=[],o=0;return t.forEach((t=>{o+=t;let i=t.toString();i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(e,!1),n.push(i)})),o=o.toString(),o=lr.formatDistance(o,this.measureParams),o+=lr.getPostFix(e,!1),{distance:n,totalDistance:o}}}class pr extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.positionPoint=t.points[0],this.measureResult={alt:t.altitude,lonLat:t.lonLat},this.innerRadius=3,this.innerStrokeWidth=2,this.outerRadius=7,this.outerStrokeWidth=1,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(!this.viewer.isInViewFrustum(this.positionPoint))return;var e=new THREE.Vector3(this.positionPoint.x,this.positionPoint.y,this.positionPoint.z);e=this.viewer.worldToClient(e),this.attachSelectedCircle(e),this.attachUnselectedCircle(e);var t=new THREE.Vector2(e.x,e.y);let i=this.notation.drawAnnotation(t,this.getMeasureResult(),this.id);for(const e of i)this.svgGroup.push(e);this.notation.dropShadow(this.filterUrl),this.unselect()}attachSelectedCircle(e){let t=re.makeConcentricCircle({innerRadius:this.innerRadius,innerStrokeWidth:this.innerStrokeWidth,outerRadius:this.outerRadius,color:this.defaultColor,position:e});this.selectElements.push(t),this.svgGroup.push(t)}attachUnselectedCircle(e){let t=re.makeConcentricCircle({innerRadius:this.innerRadius,innerStrokeWidth:this.innerStrokeWidth,outerRadius:this.outerRadius,outerStrokeWidth:this.outerStrokeWidth,color:this.defaultColor,position:e});this.unSelectElements.push(t),this.svgGroup.push(t)}hitTest(e){var t=new THREE.Vector3(this.positionPoint.x,this.positionPoint.y,this.positionPoint.z);t=this.viewer.worldToClient(t);let i=new THREE.Vector2(t.x-12,t.y-22),n=new THREE.Vector2(t.x+58,t.y-22);return re.distanceToSegment(e,i,n)<=22||this.notation.hitTest(e)}getMeasureResult(){let e=this.measureParams.unit,{alt:t,lonLat:i}=this.measureResult,{elevation:n,latLon:o}=this.measureParams.precision,s={defaultUnit:this.measureParams.defaultUnit,precision:n,scale:this.measureParams.scale,unit:this.measureParams.unit},r=lr.formatPrecision(i.latitude.toString(),o),a=lr.formatPrecision(i.longitude.toString(),o),l=lr.formatDistance(t.toString(),s);return l+=lr.getPostFix(e,!1),`经度:${a} ° \n纬度:${r} ° \n高程:${l}`}}class mr extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.trianglePoint=t.trianglePoint,this.measureResult={distance:t.distance,horizontalDistance:t.horizontalDistance,verticalDistance:t.verticalDistance},this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){if(this.worldPositions.length<2)return;let e=this.getMeasureResult();if(this.attachSegmentByTerminalPoints(this.worldPositions,e.distance),this.worldPositions[0].length()!=this.worldPositions[1].length()){let t=this.worldPositions[0].length()<this.worldPositions[1].length()?this.worldPositions[0]:this.worldPositions[1],i=this.worldPositions[0].length()<this.worldPositions[1].length()?this.worldPositions[1]:this.worldPositions[0],n=this.trianglePoint.clone();this.attachSegmentByTerminalPoints([t,n],e.verticalDistance),this.attachSegmentByTerminalPoints([i,n],e.horizontalDistance)}else this.attachSegmentByTerminalPoints([this.worldPositions[0],this.worldPositions[0]],e.horizontalDistance);this.notation.dropShadow(this.filterUrl),this.unselect()}calcTrianglePoint(e){if(e.length<2)return null;let t=new THREE.Vector3;return e[0].z<e[1].z?t.set(e[0].x,e[0].y,e[1].z):e[0].z>e[1].z&&t.set(e[1].x,e[1].y,e[0].z),t}attachSegmentByTerminalPoints(e,t){let i=e[0],n=e[1],o=this.calcLine(i,n);this.hitTestSegments=this.hitTestSegments.concat(o),this.attachLine(o),this.attachSelectedTerminalPoints(o),this.attachUnselectedTerminalPoints(o);let s={x:(i.x+n.x)/2,y:(i.y+n.y)/2,z:(i.z+n.z)/2},r=this.viewer.worldToClient(s);this.viewer.isInViewFrustum(s)&&this.attachNotation([r,r],t)}attachSelectedTerminalPoints(e){for(const t of e){let e=re.makeCircle({position:t,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(e),e.setAttribute("filter",this.filterUrl),this.selectElements.push(e)}}attachLine(e){if(0===e.length)return;let t=re.makeLine({start:e[0],end:e[1],color:this.defaultColor,lineWidth:this.lineWidth});this.svgGroup.push(t)}attachUnselectedTerminalPoints(e){for(const t of e){let e=re.makeCircle({position:t,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(e),e.setAttribute("filter",this.filterUrl),this.unSelectElements.push(e)}}attachNotation(e,t){if(0===e.length)return;let i=this.notation.drawAnnotation({x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},t,this.id);for(const e of i)this.svgGroup.push(e)}getMeasureResult(){const e=this.measureParams.unit;let{distance:t,horizontalDistance:i,verticalDistance:n}=this.measureResult;return t=t.toString(),t=lr.formatDistance(t,this.measureParams),t+=lr.getPostFix(e,!1),i=i.toString(),i=lr.formatDistance(i,this.measureParams),i+=lr.getPostFix(e,!1),n=n.toString(),n=lr.formatDistance(n,this.measureParams),n+=lr.getPostFix(e,!1),{distance:t,horizontalDistance:i,verticalDistance:n}}}class fr extends dr{constructor(e,t,i,n){super(e,i,t.type,n),this.fillColor=new Glodon.Web.Graphics.Color(255,157,11,.2),this.filterUrl=t.filterUrl,this.worldPositions=t.points,this.measureResult=t.area,this.selectElements=[],this.unSelectElements=[],this.setMeasureParams({precision:t.precision,scale:t.scale,unit:t.unit,defaultUnit:t.defaultUnit})}initialize(){const e=this.worldPositions,t=e.length;if(!(t<3)&&this.areaFrontOfCamera(e)){this.attachArea(e);for(let i=0;i<t;i++){let n=this.viewer.worldToClient(e[i]);n=new THREE.Vector2(n.x,n.y),this.hitTestSegments.push(n),this.attachSelectedTerminalPoints(n),this.attachUnselectedTerminalPoints(n),i==t-1&&this.attachNotation(n,`${this.getNotationTitle()}:${this.getMeasureResult()}`)}this.unselect()}}attachSelectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:0,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.selectElements.push(t)}attachArea(e){let t="";e.forEach((e=>{let i=this.viewer.worldToClient(e);t+=i.x+","+i.y+" "}));let i=re.makePolygon({points:t,width:this.lineWidth,color:this.defaultColor,fillColor:this.fillColor.getRGBA()});this.svgGroup.push(i)}attachUnselectedTerminalPoints(e){let t=re.makeCircle({position:e,radius:this.radius,strokeWidth:this.strokeWidth,color:this.defaultColor});this.svgGroup.push(t),t.setAttribute("filter",this.filterUrl),this.unSelectElements.push(t)}attachNotation(e,t){let i=this.notation.drawAnnotation({x:e.x,y:e.y},t,this.id,!0);for(const e of i)this.svgGroup.push(e)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_spatial_area}areaFrontOfCamera(e){let t=this.viewer,i=t.getViewer(),n=new THREE.Vector3,o=new THREE.Plane(t.sceneToWorld(i.camera.getWorldDirection(n)).normalize());o.constant=-o.distanceToPoint(t.sceneToWorld(i.camera.position));for(let t=0;t<e.length;t++)if(o.distanceToPoint(e[t])<0)return!1;return!0}getMeasureResult(){let e=this.measureParams.unit,t=this.measureResult.toString();return t=lr.formatArea(t,this.measureParams),t+=lr.getPostFix(e,!0),t}}class wr extends fr{constructor(e,t,i,n){super(e,t,i,n)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class yr extends fr{constructor(e,t,i,n){super(e,t,i,n),this.measureSurfaceMesh=null,this.layerType=t.layerType}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new hr({fillColor:new Glodon.Web.Graphics.Color(255,157,11,.2),color:new Glodon.Web.Graphics.Color(255,157,11,1),width:this.lineWidth})),super.initialize()}attachArea(e){this.measureSurfaceMesh.setMeasurePoints(e),this.viewer.render()}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_surface_area}clear(e){super.clear(),this.measureSurfaceMesh&&e&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)}}class vr{constructor(e){this.viewer=e}make(e,t,i,n){let o=null,s={defaultColor:`#${n._opt.color.getHEX()}`,enableAuxiliaryValue:n._opt.enableAuxiliaryValue};switch(e){case"Angle":o=new ur(this.viewer,t,i,s);break;case"GroundlineDistance":o=new gr(this.viewer,t,i,s);break;case"PolylineDistance":o=new cr(this.viewer,t,i,s);break;case"Position":o=new pr(this.viewer,t,i,s);break;case"TriangleDistance":o=new mr(this.viewer,t,i,s);break;case"SpatialArea":o=new fr(this.viewer,t,i,s);break;case"ProjectedArea":o=new wr(this.viewer,t,i,s);break;case"SurfaceArea":o=new yr(this.viewer,t,i,s)}return o.initialize(),o}}class br extends cr{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e;let t=this.worldPositions.length,i=[],n=0;for(let e=1;e<t;e++){let t=this.worldPositions[e].distanceTo(this.worldPositions[e-1]);i.push(t),n+=t}this.measureResult={distance:i,totalDistance:n}}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,points:this.worldPositions,type:this.type}}}class Er extends ur{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureAngle=t.measureAngle,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e;var t=new THREE.Vector3(this.worldPositions[0].x-this.worldPositions[1].x,this.worldPositions[0].y-this.worldPositions[1].y,this.worldPositions[0].z-this.worldPositions[1].z),i=new THREE.Vector3(this.worldPositions[2].x-this.worldPositions[1].x,this.worldPositions[2].y-this.worldPositions[1].y,this.worldPositions[2].z-this.worldPositions[1].z),n=t.angleTo(i);this.measureAngle=180*n/Math.PI}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),angle:this.measureAngle,points:this.worldPositions,type:this.type}}}class Mr extends mr{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult.distance=this.worldPositions[0].distanceTo(this.worldPositions[1]);let t=this.worldPositions[0].clone(),i=0,n=0;if(this.worldPositions[0].length()<this.worldPositions[1].length()){let e=new THREE.Ray;e.direction=this.worldPositions[0].clone().normalize(),e.closestPointToPoint(this.worldPositions[1].clone(),t),i=t.distanceTo(this.worldPositions[1]),n=t.distanceTo(this.worldPositions[0])}else{let e=new THREE.Ray;e.direction=this.worldPositions[1].clone().normalize(),e.closestPointToPoint(this.worldPositions[0].clone(),t),i=t.distanceTo(this.worldPositions[0]),n=t.distanceTo(this.worldPositions[1])}this.trianglePoint=t,this.measureResult.horizontalDistance=i,this.measureResult.verticalDistance=n}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,horizontalDistance:this.measureResult.horizontalDistance,verticalDistance:this.measureResult.verticalDistance,points:this.worldPositions,trianglePoint:this.trianglePoint,type:this.type}}}class Cr extends fr{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.selectElements=[],this.unSelectElements=[]}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=re.calcSpatialArea(this.worldPositions)}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type}}}class xr extends Cr{constructor(e,t){super(e,t)}calculate(e){this.worldPositions[this.updateIndex]=e;let t=[];this.worldPositions.map((e=>{t.push(this.viewer.worldToLatLon(e))}));let i=[];t.map((e=>{e.alt=0,i.push(this.viewer.latLonToWorld(e))})),this.measureResult=re.calcSpatialArea(i)}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_projected_area}}class Tr extends Cr{constructor(e,t){super(e,t),this.measureSurfaceMesh=null,this.layerType=t.layerType}calculate(e){this.worldPositions[this.updateIndex]=e,this.measureResult=re.calcSurfaceAreaEarth(this.worldPositions,this.viewer,this.layerType)}initialize(){this.measureSurfaceMesh||(this.measureSurfaceMesh=new hr({fillColor:new Glodon.Web.Graphics.Color(255,157,11,.2),color:new Glodon.Web.Graphics.Color(255,157,11,1),width:this.lineWidth})),super.initialize()}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),area:this.measureResult,points:this.worldPositions,type:this.type,layerType:this.layerType}}attachArea(e){this.measureSurfaceMesh.setMeasurePoints(e),this.viewer.render()}getNotationTitle(){return BimfaceLanguage.bf_tip_measure_surface_area}clear(){super.clear(),this.measureSurfaceMesh&&(this.measureSurfaceMesh.dispose(),this.measureSurfaceMesh=null)}}class Pr extends gr{constructor(e,t){super(e,t,t.id,{defaultColor:t.defaultColor}),this.worldPositions=t.worldPositions,this.measureResult=t.measureResult,this.updateIndex=t.updateIndex,this.groundInfos=t.groundInfos,this.isFirst=!0,this.lastGroundLineMes={},this.borderColor=t.color||new Glodon.Web.Graphics.Color(255,157,11,1),this.borderWidth=t.width||3}init(){this.updateGroundLine(this.worldPositions)}debounce(e,t=300){let i=null;return function(...n){i&&(clearTimeout(i),i=null),i=setTimeout((()=>{e(...n)}),t)}}calculate(e){this.isFirst&&(this.init(),this.isFirst=!1),this.worldPositions[this.updateIndex]=e;let t=()=>{this.isEnd||this.handle()};this.debounceFun||(this.debounceFun=this.debounce(t)),this.debounceFun(),this.updateGroundLine(this.worldPositions)}handle(){this.groundInfos.length!==this.measureResult.distance.length&&this.groundInfos.pop(),this.updateIndex>0&&(this.groundInfos[this.updateIndex-1]=this.calculateGroundlineDistance(this.worldPositions[this.updateIndex-1],this.worldPositions[this.updateIndex])),this.updateIndex<this.worldPositions.length-1&&(this.groundInfos[this.updateIndex]=this.calculateGroundlineDistance(this.worldPositions[this.updateIndex],this.worldPositions[this.updateIndex+1]));let e=[],t=0;for(let i=0;i<this.groundInfos.length;i++){let n=this.groundInfos[i];e.push(n.length),t+=n.length}this.measureResult.distance=e,this.measureResult.totalDistance=t}end(){this.handle(),this.isEnd=!0}getInfo(){return{id:Glodon.Web.Lang.Utility.UUID.createUUID(),distance:this.measureResult.distance,totalDistance:this.measureResult.totalDistance,points:this.worldPositions,groundInfos:this.groundInfos,type:this.type}}clear(){super.clear(),this.clearGroundLine()}calculateGroundlineDistance(e,t){if(!e||!t)return null;let i=this.viewer,n=new THREE.Vector3(e.x,e.y,e.z),o=new THREE.Vector3(t.x,t.y,t.z);if(n.equals(o))return null;if(this.lastPoint0&&this.lastPoint1&&n.equals(this.lastPoint0)&&o.equals(this.lastPoint1))return this.lastGroundInfo;let s,r=[];r.push(n),r.push(o),s=new THREE.CatmullRomCurve3(r),s.tension=0,s.type="catmullrom";var a=new CLOUD.Raycaster,l=(new THREE.Vector3,i.getViewer().cameraControl.getIntersectContext(null)),h=new CLOUD.SphereIntersectHelper(i.getViewer());a.camera=l.camera,a.viewportSize=l.viewportSize;var d=[];s.getPoints(100).forEach((e=>{i.getViewer().setSphereIntersectRay(a,e);let t=h.getTileSphereGroupByRaycaster(l,a,!0);if(t.length>0){let e;e=i.sceneToWorld(t[0].point),d.push(e)}else d.push(e)})),s=null;let c=new Glodon.Bimface.Plugins.Geometry.SplineCurve(d);return c.projectToGround(!0),this.lastPoint0=n,this.lastPoint1=o,this.lastGroundInfo={length:c.length,midPoint:c.getPointByParameter(.5),endPoint:c.getPointByParameter(1),status:"finished"},this.lastGroundInfo}}class Ir{constructor(e,t,i){this.domContainer=e,this.viewer=t,this.measure=i,this.drawable=null,this.isDrawed=!1,this.lastMeasureType="",this.currentMeasureType=""}createDrawable(e){switch(this.lastMeasureType=this.measure.type,this.currentMeasureType=e.type,e.type){case"PolylineDistance":this.drawable=new br(this.viewer,e);break;case"Angle":this.drawable=new Er(this.viewer,e);break;case"TriangleDistance":this.drawable=new Mr(this.viewer,e);break;case"SpatialArea":this.drawable=new Cr(this.viewer,e);break;case"ProjectedArea":this.drawable=new xr(this.viewer,e);break;case"SurfaceArea":this.drawable=new Tr(this.viewer,e);break;case"GroundlineDistance":this.drawable=new Pr(this.viewer,e);break;default:this.drawable=null}}draw(e,t){if(!this.drawable)return;this.isDrawed||this.measure.setMeasureType(this.currentMeasureType),this.isDrawed=!0;let i="ViewerDrawing"===this.viewer.getViewerType(),n={x:i&&!this.viewer.isFullScreen?e.clientX-t.left:e.clientX,y:i&&!this.viewer.isFullScreen?e.clientY-t.top:e.clientY},o={};if(i){var s=[],r=this.viewer._drawingViewer.snapToPoint(n.x,n.y),a=r.GetViewPortId&&r.GetViewPortId();if(r.GetPoint().length>0&&(s=[r.GetPoint()[0],r.GetPoint()[1],a]),!r.GetID()){let e=this.viewer._drawingViewer.toScreenPoint(r.GetPoint()),t=this.viewer._drawingViewer.toModelWorld(e);s=t,a=t[2]}o=s,this.drawable.calculate(o,a)}else{let e=this.viewer.getViewer().pickToPoint(n,5);e&&e.pickPoint&&(o=this.viewer.sceneToWorld(e.pickPoint),this.drawable.calculate(o))}let l=this.drawable.getInfo();this.measure.getEventManager().fireEvent(Glodon.Bimface.Earth.Plugins.Measure.MeasureEvent.MeasureResultUpdating,l),this.drawable.clear(),this.drawable.initialize(!0,i&&r&&r.GetDrawingIndex(),i&&r&&r.GetViewPortId()),this.drawable.select(),this.drawable.attach(this.domContainer)}end(){if(!this.drawable||!this.isDrawed)return;this.drawable.end&&this.drawable.end();let e=this.drawable.getInfo();this.measure.drawableManager.addItem(e),this.drawable.clear(),this.drawable=null,this.isDrawed=!1,this.measure.getEventManager().fireEvent(Glodon.Bimface.Earth.Plugins.Measure.MeasureEvent.MeasureResultUpdated,e)}update(){this.drawable&&this.isDrawed&&(this.drawable.clear(),this.drawable.initialize(),this.drawable.select(),this.drawable.attach(this.domContainer))}}class Sr{constructor(t,i,n){this.domContainer=t,this.measureItems=i,this.manage=n,this.measureUpdateManage=new Ir(t,n.viewer,n.measure),this.selectedItem=null,this.selectionChanged=null,this.hoverChanged=null,this.isEnableSelection=!0,this.mousedownHitItem=null,this.offset=t.getBoundingClientRect(),e.Web.Lang.Utility.ClientHelper.getIsDesktop()&&this.hookEvents()}hookEvents(){this.domContainer.addEventListener("mousemove",(e=>{if(this.manage.measure.isSelectItem=!1,!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);if(this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top),!this.isMoveed&&this.mouseDownPoint&&(Math.abs(this.mouseDownPoint.x-e.clientX)>=1||Math.abs(this.mouseDownPoint.y-e.clientY)>=1)&&(this.isMoveed=!0),this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type){let t={x:e.clientX,y:e.clientY},i=this.manage.viewer.getViewer().pickToPoint(t,5);if(i&&i.pickPoint){let e=this.manage.viewer.sceneToWorld(i.pickPoint);this.mouseDownHelperHitItem.update(e)}return void(this.isMouseDownHelperHitItemMove=!0)}if(!this.isMouseDownMove&&this.mousedownPoint&&Math.abs(this.mousedownPoint.x-t.x)>=1&&Math.abs(this.mousedownPoint.y-t.y)>=1&&(this.isMouseDownMove=!0,this.mousedownPoint=null),this.isMouseDownMove&&(this.selectPointItemId&&(this.manage.removeItemById(this.selectPointItemId),this.selectPointItemId=null),this.measureUpdateManage.draw(e,this.offset)),this.isMouseDown)return;let i=this.hitTest(t);this.hoverChanged(i),i?(this.domContainer.style.cursor="default",e.preventDefault(),e.stopPropagation()):this.domContainer.style.cursor=""}),!1),this.domContainer.addEventListener("mousedown",(e=>{if(this.mousedownHitItem=null,this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!0,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint={x:e.clientX,y:e.clientY},!this.isEnableSelection)return;let t=new n(e.clientX,e.clientY);this.manage.viewer.isFullScreen||(t.x-=this.offset.left,t.y-=this.offset.top);let i=this.hitTest(t);if(this.mousedownHitItem=i,i){this.manage.measure.isSelectItem=!0;for(let e=0;e<i.hitTestSegments.length;e++)if(Math.abs(i.hitTestSegments[e].x-t.x)<=3&&Math.abs(i.hitTestSegments[e].y-t.y)<=3){let n={...i,...i.measureParams,updateIndex:e};this.measureUpdateManage.createDrawable(n),this.measureUpdateManage.drawable&&(this.selectPointItemId=i.id,this.mousedownPoint=t);break}i.getIsSelected()?(this.selectionChanged(null),this.setSelectedItem(null),i.unselect()):(this.selectionChanged(i),this.setSelectedItem(i),i.select()),e.preventDefault(),e.stopPropagation()}}),!1),this.domContainer.addEventListener("mouseup",(e=>{this.manage.measure.isSelectItem=!1,this.isMoveed&&this.mouseDownHelperHitItem&&this.mouseDownHelperHitItem.canEdit&&this.mouseDownHelperHitItem.selectChild&&"Point"==this.mouseDownHelperHitItem.selectChild.type&&this.isMouseDownHelperHitItemMove&&(this.mouseDownHelperHitItem.endUpdate(this.manage.mapMeasureInfo),this.setSelectedItem(this.mouseDownHelperHitItem),this.mouseDownHelperHitItem.select(),this.mouseDownHelperHitItem=null),this.measureUpdateManage.end(),this.selectPointItemId=null,this.mousedownPoint=null,this.isMouseDownMove=!1,this.isMouseDown=!1,this.mouseDownHelperHitItem=null,this.isMouseDownHelperHitItemMove=!1,this.isMoveed=!1,this.mouseDownPoint=null,this.mousedownHitItem&&(e.preventDefault(),e.stopPropagation())}),!1),this.domContainer.addEventListener("dblclick",(()=>{event.preventDefault(),event.stopPropagation()}),!1)}hitTest(e){for(var t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.getNotation().hitTest(e))return i}for(t=this.measureItems.length-1;t>=0;t--){let i=this.measureItems[t];if(i.hitTest(e))return i}return null}setSelectedItem(e){this.selectedItem&&(this.selectedItem.actionWhenUnselected(),this.selectedItem.unselect()),this.selectedItem=e,e&&e.actionWhenSelected()}getSelectedItem(){return this.selectedItem}hasSelected(){return null!==this.selectedItem}setIsEnableSelection(e){this.isEnableSelection=e}}class Br{constructor(e){this.filterId=e.filterId,this.filterUnits=e.filterUnits,this.stdDeviation=e.stdDeviation,this.feOffset1=e.feOffset1,this.feOffset2=e.feOffset2,this.shadowOpacity=e.opacity,this.initialize()}initialize(){let e=document.createElementNS(this.xmlns,"defs"),t=document.createElementNS(this.xmlns,"filter");t.setAttribute("id",this.filterId),t.setAttribute("filterUnits",this.filterUnits);let i=document.createElementNS(this.xmlns,"feGaussianBlur");i.setAttribute("in","SourceAlpha"),i.setAttribute("stdDeviation",this.stdDeviation),t.appendChild(i);let n=document.createElementNS(this.xmlns,"feOffset");n.setAttribute("dx",this.feOffset1.dx),n.setAttribute("dy",this.feOffset1.dy),n.setAttribute("result","offsetblur");let o=document.createElementNS(this.xmlns,"feOffset");o.setAttribute("dx",this.feOffset2.dx),o.setAttribute("dy",this.feOffset2.dy),o.setAttribute("result","offsetblur"),t.appendChild(n),t.appendChild(o);let s=document.createElementNS(this.xmlns,"feComponentTransfer"),r=document.createElementNS(this.xmlns,"feFuncA");r.setAttribute("type","linear"),r.setAttribute("slope",this.shadowOpacity),s.appendChild(r),t.appendChild(s);let a=document.createElementNS(this.xmlns,"feMerge"),l=document.createElementNS(this.xmlns,"feMergeNode"),h=document.createElementNS(this.xmlns,"feMergeNode");h.setAttribute("in","SourceGraphic");let d=document.createElementNS(this.xmlns,"feMergeNode");d.setAttribute("in","SourceGraphic"),a.appendChild(l),a.appendChild(h),a.appendChild(d),t.appendChild(a),e.appendChild(t),this.dropShadowDefs=e}attach(e){this.dropShadowDefs||this.initialize(),e.appendChild(this.dropShadowDefs);let t=e.innerHTML;e.removeChild(this.dropShadowDefs),e.innerHTML=t}getFilterUrl(){return"url(#"+this.filterId+")"}}class _r{constructor(e,t,i){this.domContainer=e,this.viewer=t,this.measure=i,this.viewId=0,this.itemList=[],this.mapMeasureInfo={},this.initShadowManager(),this.drawableFactory=new vr(t,i),this.hookViewerEvents()}hookViewerEvents(){this.selectionControl=new Sr(this.domContainer,this.itemList,this),this.selectionControl.selectionChanged=e=>{if(e){let t=this.mapMeasureInfo[e.getId()];if(t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t),this.bringToFront(e),this.itemClickCallback){let t=this.mapMeasureInfo[e.getId()];this.itemClickCallback(t)}}else this.eventListener.fireEvent("MeasureUnselected",{})},this.selectionControl.hoverChanged=e=>{e?(this.measure.disableMeasureCursor(),this.measure.setIsEnableSnap(!1)):e&&!this.measure.isMeasureOpen()||(this.measure.enableMeasureCursor(),this.measure.setIsEnableSnap(!0))},this.viewer.addEventListener("Rendered",(()=>{this.update(),this.selectionControl&&this.selectionControl.measureUpdateManage.update()})),document.addEventListener("keyup",(e=>{if(46===e.keyCode){let e=this.selectionControl.getSelectedItem();e&&(this.eventListener.fireEvent("MeasureSelected",{type:e.getType(),isDataEmpty:!0}),this.removeItemById(e.getId()),this.selectionControl.setSelectedItem(null))}})),this.measure._opt.isCreateByUI&&this.viewer.addEventListener("ButtonOnToolbarClicked",(e=>{if("LeftSubToolbar"===e.id&&(this.selectionControl.setSelectedItem(null),this.showExclusiveByViewId(e.viewId),this.viewId=e.viewId),"Measure"===e.id){let t=this.selectionControl.getSelectedItem();if(e.isChecked){if(this.showAll(),t){let e=this.mapMeasureInfo[t.getId()];e.type=t.getType(),t&&t.actionWhenSelected(),this.eventListener.fireEvent("MeasureSelected",e)}}else this.hideAll(),t&&t.actionWhenUnselected()}}))}addItem(e){let t=e.type,i=e.id;if(this.mapMeasureInfo[i])return;this.mapMeasureInfo[i]=e,e.filterUrl=this.dropShadowManager.getFilterUrl();const n=this.measure.getMeasureParams();for(let t in n)e.hasOwnProperty(t)||(e[t]=n[t]);let o=this.drawableFactory.make(t,e,i,this.measure);o.attach(this.domContainer),o.select(),this.selectionControl.setSelectedItem(o),this.itemList.push(o)}removeItemById(e){this.mapMeasureInfo[e]&&delete this.mapMeasureInfo[e];for(var t=0;t<this.itemList.length;t++)if(this.itemList[t].getId()===e){this.itemList[t].clear(!0),this.itemList.splice(t,1);break}}removeItemsByType(e){for(var t=0;t<this.itemList.length;t++)this.itemList[t].type===e&&(this.mapMeasureInfo[this.itemList[t].id]&&delete this.mapMeasureInfo[this.itemList[t].id],this.itemList[t].clear(!0),this.itemList.splice(t,1))}update(){this.clear();for(const e of this.itemList)e.initialize(),e.attach(this.domContainer),e.dropShadow(this.dropShadowManager.getFilterUrl());this.selectionControl.hasSelected()&&this.selectionControl.getSelectedItem().select()}clear(e){for(const t of this.itemList)t.clear(e);e&&(this.itemList.length=0,this.selectionControl.setSelectedItem(null),this.eventListener.fireEvent("MeasureUnselected",{}),this.mapMeasureInfo={})}unselctedAll(){for(const e of this.itemList)e.unselect();this.selectionControl.selectedItem=null}hideAll(){for(const e of this.itemList)e.measureSurfaceMesh&&e.measureSurfaceMesh.hide();this.domContainer.style.display="none"}showAll(){for(const e of this.itemList)e.measureSurfaceMesh&&e.measureSurfaceMesh.show();this.domContainer.style.display="block",this.update()}onClick(e){e&&(this.itemClickCallback=e)}save(){let e=[],t=Object.keys(this.mapMeasureInfo);for(const i of t)e.push(this.mapMeasureInfo[i]);return e}load(e){for(var t=0;t<e.length;t++){var i=e[t];this.addItem(i)}this.unselctedAll()}setEventListener(e){this.eventListener=e,this.eventListener.addEvent("Measuring",(()=>{this.selectionControl.setSelectedItem(null),this.setIsEnableSelection(!1)})),this.eventListener.addEvent("Measured",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("Reset",(()=>{this.setIsEnableSelection(!0)})),this.eventListener.addEvent("MeasureParamsUpdated",(()=>{this.measure.measureItem&&this.measure.measureItem.setMeasureParams(this.measure.getMeasureParams());for(const e of this.itemList){let t=this.measure.getMeasureParams(e.type);e.setMeasureParams(t),this.mapMeasureInfo[e.id].precision=t.precision,this.mapMeasureInfo[e.id].scale=t.scale,this.mapMeasureInfo[e.id].unit=t.unit,this.mapMeasureInfo[e.id].enableAuxiliaryValue=t.enableAuxiliaryValue||!1,this.mapMeasureInfo[e.id].laserXYZ=t.laserXYZ}if(this.update(),this.selectionControl.hasSelected()){let e=this.selectionControl.getSelectedItem(),t=this.mapMeasureInfo[e.getId()];t.type=e.getType(),this.eventListener.fireEvent("MeasureSelected",t)}}))}bringToFront(e){for(var t=0;t<this.itemList.length;t++)if(this.itemList[t].getId()===e.getId()){this.itemList.splice(t,1);break}e.detach(),this.itemList.push(e),e.attach(this.domContainer)}initShadowManager(){this.dropShadowManager=new Br({filterId:"dropShadow",filterUnits:"userSpaceOnUse",stdDeviation:"2",feOffset1:{dx:5,dy:5},feOffset2:{dx:-5,dy:-5},opacity:"0.3"}),this.dropShadowManager.attach(this.domContainer)}getSelectedItem(){return this.selectionControl.getSelectedItem()}showExclusiveByViewId(e){for(const t of this.itemList)t.getViewId()===e?t.show():t.hide()}setIsEnableSelection(e){this.selectionControl.setIsEnableSelection(e)}}!function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=[],s=null,a=null,l=function(t){this.viewer=t.viewer;var n=new e.Web.Lang.EventManager,o=i.create("div","bf-measure-conext");this.isOpen=!1,this.context={rootDomElement:o},this._opt=t,this.type=t.measureType,this.getEventManager=function(){return n},this.isEnableSnap=!0,this._p1=new THREE.Vector3,this._p2=new THREE.Vector3};l.prototype={init:function(){var e=this.context,t=this._opt.viewer;t.getDomElement().appendChild(e.rootDomElement);var n=i.createNS("svg","bf-measure-svg"),o=i.createNS("svg","bf-measure-svg"),s=i.create("div","bf-measure-text");e.rootDomElement.innerHTML="",e.rootDomElement.appendChild(n),e.rootDomElement.appendChild(o),this.drawableManager=new _r(o,t,this),this.drawableManager.setEventListener(this.getEventManager()),this._hookEvents(),this.switchOn(),e.svg=n,e.text=s,t.render()},_onViewerRender(){this.isOpen&&this.update()},_onCloudViewerMeasuring(e){this.isOpen&&(this.measureItem.hoverPositionUpdated=!0,this.measureByPoint(e))},_onCloudViewerMeasureReset(t){if(!this.isOpen)return;const i=this.measureItem;this.type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position||this.type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance||this.type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle||i.getPoints().length<i.minPointsNum?(i.reset(),this.getEventManager().fireEvent(e.Bimface.Earth.Plugins.Measure.MeasureEvent.Reset)):i.getPoints().length!=i.maxPointsNum&&(i.measureEnd=!0,this.measureByPoint(t))},_hookEvents(){const t=this.viewer,i=t.getViewer();this._onRenderBinded=this._onViewerRender.bind(this),this._onMeasuringBinded=this._onCloudViewerMeasuring.bind(this),this._onMeasureResetBinded=this._onCloudViewerMeasureReset.bind(this),t.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.Rendered,this._onRenderBinded),i.registerEventListener(y.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.registerEventListener(y.EVENTS.ON_MEASURE_RESET,this._onMeasureResetBinded)},_unhookEvents(){const t=this.viewer,i=t.getViewer();t.removeEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.Rendered,this._onRenderBinded),i.unregisterEventListener(y.EVENTS.ON_MEASURE_PICK,this._onMeasuringBinded),i.unregisterEventListener(y.EVENTS.ON_MEASURE_RESET,this._onMeasureResetBinded)},enableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=`url(${r}),auto`},disableMeasureCursor(){this._opt.viewer.getDomElement().style.cursor=""},activeByMeasureType:function(){e.Web.Lang.Utility.ClientHelper.getIsDesktop()||this.drawableManager.clear(!0),this.enableMeasureCursor();let t,i=this._opt.viewer.getViewer();i.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),i.editorManager.enableTool(i,y.EditToolMode.PICK_BY_MEASURE);let n=new e.Bimface.Earth.Plugins.Measure.MeasureItemConfig;switch(n=Object.assign(n,this._opt,this.getMeasureParams(),{type:this.type}),this.type){case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle:t=new e.Bimface.Earth.Plugins.Measure.MeasureAngleItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.PolylineDistance:t=new e.Bimface.Earth.Plugins.Measure.MeasurePolylineDistanceItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position:t=new e.Bimface.Earth.Plugins.Measure.MeasurePositionItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance:t=new e.Bimface.Earth.Plugins.Measure.MeasureTriangleDistanceItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SpatialArea:t=new e.Bimface.Earth.Plugins.Measure.MeasureSpatialAreaItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.ProjectedArea:t=new e.Bimface.Earth.Plugins.Measure.MeasureProjectedAreaItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SurfaceArea:t=new e.Bimface.Earth.Plugins.Measure.MeasureSurfaceAreaItem(n);break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance:t=new e.Bimface.Earth.Plugins.Measure.MeasureGroundlineDistanceItem(n)}this.measureItem=t},switchOn:function(){this.isOpen||(this.activeByMeasureType(),this.isOpen=!0,this.drawableManager.setIsEnableSelection(!0))},switchOff:function(){if(this.isOpen){var e=this,t=e._opt.viewer.getViewer();this.disableMeasureCursor(),t.editorManager.disableTool(y.EditToolMode.PICK_BY_MEASURE),t.editorManager.disableTool(y.EditToolMode.VOLUME_MEASURE),e.reset(),e.measureItem=null,this.isOpen=!1,this.drawableManager.setIsEnableSelection(!1)}},measureByPoint:function(t){var i=this,r=e.Web.Lang.Utility.ClientHelper.getIsDesktop(),l=i.measureItem;t&&(n=t.pickPoint?t.pickPoint:null,t.pointType?s=t.pointType:t.pickPlane?(s="Panel",a=t.normal):t.pickLine?(s="Line",o=t.pickLine):s=t.pickPoint?"Point":null,(!t.modelId||"TileGroup"==t.modelId)&&(s=null),t.pick&&t.pickPoint?(l.addPoint(t.pickPoint),l.getPoints().length==l.maxPointsNum?(r||this.drawableManager.clear(!0),this.drawableManager.addItem(this.getInfo(!0,null,!0)),r||this.drawableManager.unselctedAll(),this.measureItem.setIsReserverd(!0),i.getEventManager().fireEvent(e.Bimface.Earth.Plugins.Measure.MeasureEvent.Measured,this.handleData(i.getInfo(!0,null,!0))),l.reset()):(r||this.drawableManager.clear(!0),i.getEventManager().fireEvent(e.Bimface.Earth.Plugins.Measure.MeasureEvent.Measuring,this.handleData(i.getInfo()))),i.update()):this.isEnableSnap&&i.update())},handleData(t){if(!t)return t;let i=JSON.parse(JSON.stringify(t));if(i.points){let e=[];i.points.map((t=>e.push(this.viewer.worldToLatLon(t)))),i.points=e}if(i.type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance&&i.trianglePoint&&(i.trianglePoint=this.viewer.worldToLatLon(i.trianglePoint)),i.type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance){if(i.positions){let e=[];i.positions.map((t=>e.push({midPoint:this.viewer.worldToLatLon(t.midPoint),endPoint:this.viewer.worldToLatLon(t.endPoint)}))),i.positions=e}i.groundInfos&&i.groundInfos.map((e=>{e.midPoint=this.viewer.worldToLatLon(e.midPoint),e.endPoint=this.viewer.worldToLatLon(e.endPoint)}))}return i},reset:function(){this.isOpen&&(this.measureItem.reset(),this.context.svg.innerHTML="",this.getEventManager().fireEvent(e.Bimface.Earth.Plugins.Measure.MeasureEvent.Reset))},setIsEnableSnap:function(e){e||(this.context.svg.innerHTML=""),this.isEnableSnap=e},update:function(){var e=this.measureItem,t=this.context,i=this._opt.viewer,r=i.getDomElement(),l=r.getBoundingClientRect(),h=i.getViewer(),d=e.getPoints(),c=[],u=[];if(this.context.svg.innerHTML="",t.footPoint=null,n?(t.hoverPosition=i.worldToClient(n),t.hoverPositionDS=h.getScene().worldToDrawing(n),e.nextMeasurePoint=n):t.hoverPosition=e.nextMeasurePoint?i.worldToClient(e.nextMeasurePoint):null,0!=d.length&&(c=d.concat([e.nextMeasurePoint])),t.hoverObjectType=s,"Line"==s&&2==o.length){t.lineStartPoint=i.worldToClient(o[0]),t.lineEndPoint=i.worldToClient(o[1]);var g=new THREE.Vector2(t.lineStartPoint.x,t.lineStartPoint.y),p=new THREE.Vector2(t.lineEndPoint.x,t.lineEndPoint.y),m=new THREE.Box2;m.min.set(r.clientLeft,r.clientTop),m.max.set(m.min.x+r.clientWidth,m.min.y+r.clientHeight);var f=!m.containsPoint(g),w=!m.containsPoint(p),v={start:g,end:p},b=y.CameraUtil.lineIntersectWithRect(v,m);if(f&&w)2==b.length&&(t.lineStartPoint=b[0],t.lineEndPoint=b[1]);else if(f||w)for(var E=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y),M=f?p.clone():g.clone(),C=M.clone().sub(E).normalize(),x=0;x<b.length;x++){if(M.clone().sub(b[x]).normalize().dot(C)>0){t.lineStartPoint=M,t.lineEndPoint=b[x];break}}let e=d[d.length-1];if(e){const{x:n,y:s}=i.worldToClient(e),r=new THREE.Vector2(n,s),a=new THREE.Vector2(t.hoverPosition.x,t.hoverPosition.y);if(r.distanceTo(a)>5){let n=o[0].clone(),s=o[1].clone();const r=n.x-s.x,l=n.y-s.y,h=n.z-s.z;let d=(e.x-n.x)*(n.x-s.x)+(e.y-n.y)*(n.y-s.y)+(e.z-n.z)*(n.z-s.z);d/=Math.pow(r,2)+Math.pow(l,2)+Math.pow(h,2);let c=new THREE.Vector3(n.x+d*r,n.y+d*l,n.z+d*h),u=i.worldToClient(c);a.distanceTo(u)<=5&&(t.footPoint=u,t.hoverPosition=u)}}}if("Panel"==t.hoverObjectType){t.normal=h.getScene().worldToDrawing(a),t.normal.normalize();var T=h.cameraControl,P=new THREE.Plane;P.setFromNormalAndCoplanarPoint(t.normal,t.hoverPositionDS);var I=new THREE.Vector2(t.hoverPosition.x-10,t.hoverPosition.y-10),S=new THREE.Vector2(t.hoverPosition.x+10,t.hoverPosition.y-10),B=t.hoverPositionDS,_=i.getRaycaster(I.x,I.y);if(this._p1=_.ray.intersectPlane(P,this._p1),_=i.getRaycaster(S.x,S.y),this._p2=_.ray.intersectPlane(P,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var L=new THREE.Vector3(1,0,0),D=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,0,1);let e=y.GIS.Transforms.eastNorthUpToFixedFrame(t.hoverPositionDS).clone();L.applyMatrix4(e).normalize(),D.applyMatrix4(e).normalize(),A.applyMatrix4(e).normalize();var V=D.clone().cross(t.normal).normalize(),R=t.normal.clone().cross(V).normalize(),O=this._p1.distanceTo(this._p2)/2,k=V.clone().multiplyScalar(O),H=R.clone().multiplyScalar(O),U=B.clone().sub(k).add(H),N=B.clone().add(k).add(H),G=B.clone().sub(k).sub(H),j=B.clone().add(k).sub(H),z=[];z.push(U,N,j,G);for(var F=[],W=T.getContainerDimensions(),$=0;$<z.length;$++){var X=y.CameraUtil.drawingToCanvas(T.camera,z[$],W.width,W.height);F.push(new THREE.Vector3(X.x,X.y,0))}t.clientPts=F}for(x=0;x<c.length-1;x++){var Y=h.worldPointsToClient(c[x],c[x+1]);if(Y){var Z={x:Y.start.x-l.left,y:Y.start.y-l.top};u.push(Z)}}t.clientPoints=u;let q=this.getInfo(!0,c);e.draw(t,q)},getInfo:function(t,i,n){var o={},s=this.measureItem,r=this._opt.viewer;i=i||s.getPoints();switch(o.type=this.type,o.id=e.Web.Lang.Utility.UUID.createUUID(),o.points=i,this.type){case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle:if(3==i.length){var a=new THREE.Vector3(i[0].x-i[1].x,i[0].y-i[1].y,i[0].z-i[1].z),l=new THREE.Vector3(i[2].x-i[1].x,i[2].y-i[1].y,i[2].z-i[1].z),h=a.angleTo(l);o.angle=180*h/Math.PI}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position:if(1==i.length){o.coordinateSystem="GCJ-02";let e=r.worldToLatLon(i[0]);o.lonLat={longitude:e.lon,latitude:e.lat},o.altitude=e.alt}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.PolylineDistance:if(i&&i.length>=2){let e=i.length;o.distance=[],o.totalDistance=0;for(let t=1;t<e;t++){let e=i[t].distanceTo(i[t-1]);o.distance.push(e),o.totalDistance+=e}}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance:if(i&&i.length>=2){o.distance=[],o.totalDistance=0,o.positions=[],o.groundInfos=s.groundInfos,s.lastGroundLineMes.point&&(s.lastGroundLineMes.point.x==s.nextMeasurePoint.x&&s.lastGroundLineMes.point.y==s.nextMeasurePoint.y&&s.lastGroundLineMes.point.z==s.nextMeasurePoint.z?(new Date).getTime()-s.lastGroundLineMes.time>300&&(this.groundLineInfo=s.calculateGroundlineDistance(s.measurePoints[s.measurePoints.length-1],s.nextMeasurePoint)):s.lastGroundLineMes.time=(new Date).getTime()),s.lastGroundLineMes.point=s.nextMeasurePoint,s.groundInfos=this.groundLineInfo&&!s.measureEnd?[...s.groundLineInfos,this.groundLineInfo]:s.groundLineInfos;for(let e=0;e<s.groundInfos.length;e++){let t=s.groundInfos[e];o.distance.push(t.length),o.totalDistance+=t.length;let i={midPoint:t.midPoint,endPoint:t.endPoint};o.positions.push(i)}}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance:if(2==i.length){o.distance=o.points[0].distanceTo(o.points[1]);let e=i[0].clone(),t=0,n=0;if(i[0].length()<i[1].length()){let o=new THREE.Ray;o.direction=i[0].clone().normalize(),o.closestPointToPoint(i[1].clone(),e),t=e.distanceTo(i[1]),n=e.distanceTo(i[0])}else{let o=new THREE.Ray;o.direction=i[1].clone().normalize(),o.closestPointToPoint(i[0].clone(),e),t=e.distanceTo(i[0]),n=e.distanceTo(i[1])}Object.assign(o,{horizontalDistance:t,verticalDistance:n,trianglePoint:e})}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SpatialArea:if(i.length>=3&&t){let e=re.calcSpatialArea(i);Object.assign(o,{area:e})}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.ProjectedArea:if(i.length>=3&&t){let e=[];i.map((t=>{e.push(r.worldToLatLon(t))}));let t=[];e.map((e=>{e.alt=0,t.push(r.latLonToWorld(e))}));let n=re.calcSpatialArea(t);Object.assign(o,{area:n})}break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SurfaceArea:i.length>=3&&t&&(void 0===this.surfaceAreaValue||n?this.surfaceAreaValue=re.calcSurfaceAreaEarth(i,r,this.layerType):(this.surfaceAreaLastTime||(this.surfaceAreaLastTime=(new Date).getTime()),(new Date).getTime()-this.surfaceAreaLastTime>=300&&(this.surfaceAreaValue=re.calcSurfaceAreaEarth(i,r,this.layerType),this.surfaceAreaLastTime=(new Date).getTime())),Object.assign(o,{area:this.surfaceAreaValue,layerType:this.layerType}))}return o},redo:function(){this.measureItem.redo(),this.update(),this.getEventManager().fireEvent(e.Bimface.Earth.Plugins.Measure.MeasureEvent.Measuring,this.handleData(this.getInfo()))},exit:function(){this.switchOff(),this._unhookEvents()},isMeasureOpen:function(){return this.isOpen},getDefaultUnit:function(){return"m"}},t.MeasureViewerGIS=l}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Measure"),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),o=function(t){if(t.viewer){P(this);var o=new e.Web.Lang.EventManager,s=n.create("div","bf-measure-conext");this.context={rootDomElement:s},this.id="Measure",this._opt=t,this.type=t.measureType,this.layerType=t.layerType,this.getEventManager=function(){return o},i.MeasureViewerGIS.call(this,t),this.inherit(e.Bimface.Earth.Plugins.Measure.MeasureViewerGIS.prototype),this._setDefaultUnits(t),this._setDefaultPrecisions(t),this.init()}};o.prototype={inherit:function(e){for(var t in e)this[t]=e[t]},addEventListener:function(e,t){this.getEventManager().addEvent(e,t)},removeEventListener:function(e,t){this.getEventManager().removeEvent(e,t)},_setDefaultUnits:function(t){const i=t.viewer.getViewerType();if(null!=t.lengthUnits&&null==t.units){if("ViewerGIS"===i)t.units={distance:t.lengthUnits,elevation:t.lengthUnits,area:t.lengthUnits};return}const n=this.getDefaultUnit();"m"===n?t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Meter:"mm"===n&&(t.lengthUnits=e.Bimface.Common.Units.LengthUnits.Millimeter);const o=t.units&&t.units.distance||t.lengthUnits||e.Bimface.Common.Units.LengthUnits.Millimeter,s=t.units&&t.units.elevation||e.Bimface.Common.Units.LengthUnits.Meter,r=t.units&&t.units.area||e.Bimface.Common.Units.LengthUnits.Meter;if("ViewerGIS"===i)t.units={distance:o,elevation:s,area:r}},_setDefaultPrecisions:function(e){if("number"==typeof e.precision)e.obsoletePrecision=e.precision,e.precision={distance:e.obsoletePrecision,elevation:e.obsoletePrecision,area:e.obsoletePrecision,angle:e.obsoletePrecision,latLon:e.obsoletePrecision};else{let{distance:t=3,elevation:i=3,area:n=3,angle:o=2,latLon:s=9}=e.precision;e.precision={distance:t,elevation:i,area:n,angle:o,latLon:s}}},getMeasureType:function(){return this.type},setMeasureType:function(e){t.send("Bimface.Earth.Plugins.Measure.Measure","setMeasureType"),this.hideDragButton&&this.hideDragButton(),this.type=e,this.reset(),this.activeByMeasureType(),this.getEventManager().fireEvent("typeChange",e)},setPrecision:function(e){"number"==typeof e||"string"==typeof e?(this._opt.obsoletePrecision=e,this._opt.precision={distance:e,elevation:e,area:e,angle:e,latLon:e}):this._opt.precision=Object.assign(this._opt.precision,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getPrecision:function(){return void 0!==this._opt.obsoletePrecision?this._opt.obsoletePrecision:this._opt.precision},setScale:function(e){this._opt.scale=e,this.getEventManager().fireEvent("MeasureParamsUpdated")},getScale:function(){return this._opt.scale},setLengthUnits:function(e){this._opt.lengthUnits=e;for(const t in this._opt.units)this._opt.units[t]=e;this.getEventManager().fireEvent("MeasureParamsUpdated")},getLengthUnits:function(){return this._opt.lengthUnits},setUnits:function(e){this._opt.units=Object.assign(this._opt.units,e),this.getEventManager().fireEvent("MeasureParamsUpdated")},getUnits:function(){return this._opt.units},getAllItems:function(){let t=this.drawableManager.save(),i=[];for(let n=0;n<t.length;n++){let o={...t[n]};switch(t[n].type){case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.PolylineDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SpatialArea:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.ProjectedArea:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SurfaceArea:let i=[];t[n].points.map((e=>i.push(this.viewer.worldToLatLon(e)))),o.points=i}if(t[n].type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance&&(o.trianglePoint=this.viewer.worldToLatLon(o.trianglePoint)),t[n].type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance){let e=[];t[n].positions.map((t=>e.push({midPoint:this.viewer.worldToLatLon(t.midPoint),endPoint:this.viewer.worldToLatLon(t.endPoint)}))),t[n].positions=e,t[n].groundInfos.map((e=>{e.midPoint=this.viewer.worldToLatLon(e.midPoint),e.endPoint=this.viewer.worldToLatLon(e.endPoint)}))}i.push(o)}return i},setItems:function(t){this.clear();let i=[];for(let n=0;n<t.length;n++){let o={...t[n]};switch(t[n].type){case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.PolylineDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SpatialArea:case e.Bimface.Plugins.Measure.MeasureTypeOption.ProjectedArea:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SurfaceArea:let i=[];t[n].points.map((e=>i.push(this.viewer.latLonToWorld(e)))),o.points=i}if(t[n].type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.TriangleDistance&&(o.trianglePoint=this.viewer.latLonToWorld(o.trianglePoint)),t[n].type==e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.GroundlineDistance){let e=[];o.positions.map((t=>e.push({midPoint:this.viewer.latLonToWorld(t.midPoint),endPoint:this.viewer.latLonToWorld(t.endPoint)}))),o.positions=e,o.groundInfos.map((e=>{e.midPoint=this.viewer.latLonToWorld(e.midPoint),e.endPoint=this.viewer.latLonToWorld(e.endPoint)}))}i.push(o)}this.drawableManager.load(i)},clear:function(){this.drawableManager.clear(!0),this.hideDragButton&&this.hideDragButton()},hideAllItems:function(){this.drawableManager.hideAll()},showAllItems:function(){this.drawableManager.showAll()},onClick:function(e){this.drawableManager.onClick(e)},removeSelectedItem:function(){this.drawableManager.unselctedAll()},getSelectedItem:function(){return this.drawableManager.getSelectedItem()},setLayerType:function(e){this.layerType=e},getMeasureParams:function(t){let i={scale:this.getScale(),defaultUnit:this.getDefaultUnit()};switch(t||this.type){case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Angle:i=Object.assign(i,{precision:this._opt.precision.angle,unit:"°"});break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SpatialArea:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.ProjectedArea:case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.SurfaceArea:i=Object.assign(i,{precision:this._opt.precision.area,unit:this.getUnits().area});break;case e.Bimface.Earth.Plugins.Measure.MeasureTypeOption.Position:i=Object.assign(i,{precision:{elevation:this._opt.precision.elevation,latLon:this._opt.precision.latLon},unit:this.getUnits().elevation});break;default:i=Object.assign(i,{precision:this._opt.precision.distance,unit:this.getUnits().distance})}return i}},i.Measure=o}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Marker3D").Marker3DContainerConfig=function(){return{viewer:null,type:null,layerId:null}},e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Marker3D").Marker3DConfig=function(){return{id:null,size:30,tooltip:"",tooltipStyle:{color:"#333",fontSize:"14px",borderWidth:"1px",borderColor:"#666",borderStyle:"solid",backgroundColor:"#fff"},src:null,canvas:null,location:null,hoverAnimation:!0}},function(){var t="Bimface.Earth.Plugins.Marker3D.Marker3D",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Marker3D"),o=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),s=function(t){var i=this;this.id=t.id||e.Web.Lang.Utility.UUID.createUUID(),this.layerId=t.layerId,this.modelId=t.modelId,this.objectId=t.objectId,this.size=t.size,this.iconUrl=t.canvas?t.canvas.toDataURL():t.src,this.location=JSON.parse(JSON.stringify(t.location)),this.originLocation=JSON.parse(JSON.stringify(t.location)),this.hoverAnimation=t.hoverAnimation,this.explosionOffset=new THREE.Vector3,this.tooltip=t.tooltip,this.tooltipElement=o.create("div","bf-tooltip"),this.tooltipElement.innerHTML=t.tooltip,this.tooltipElement.setCss(t.tooltipStyle),this.isHideByClustering=!1,this._tooltipCallback=function(e,t,n){var o=i.tooltipElement;n.appendChild(o);var s=o.offsetWidth,r=o.offsetHeight;o.style.left=t.x-s/2+"px",o.style.top=t.y-r-i.size+"px",i._hoverCallback&&i._hoverCallback(e)},this._config=t,this.scratchVector=new THREE.Vector3,this.scratchVector_2=new THREE.Vector3,P(this)};s.prototype={getId:function(){return this.id},getWorldPosition:function(){return this.location},setWorldPosition:function(e){i.send(t,"setWorldPosition"),this.location=JSON.parse(JSON.stringify(e)),this.originLocation=JSON.parse(JSON.stringify(e)),this.container&&(this.position=this.container._viewer.latLonToWorld(this.location)),this.update()},getLocation:function(){return this.location},setLocation:function(e){i.send(t,"setLocation"),this.location=JSON.parse(JSON.stringify(e)),this.originLocation=JSON.parse(JSON.stringify(e)),this.container&&(this.position=this.container._viewer.latLonToWorld(this.location)),this.update()},getSize:function(){return this.size},setSize:function(e){i.send(t,"setSize"),this.size=e,this.update()},getSrc:function(){return this.iconUrl},setSrc:function(e){i.send(t,"setSrc"),this.iconUrl=e,this.update()},getTooltip:function(){return this.tooltip},setTooltip:function(e){i.send(t,"setTooltip"),this.tooltip=e,this.tooltipElement.innerHTML=e},onClick:function(e){i.send(t,"onClick"),e&&(this._clickCallback=e)},onHover:function(e){i.send(t,"onHover"),e&&(this._hoverCallback=e)},onDoubleClick:function(e){i.send(t,"onDoubleClick"),e&&(this._doubleClickCallback=e)},onRightClick:function(e){i.send(t,"onRightClick"),e&&(this._rightClickCallback=e)},update:function(){i.send(t,"update"),this.container&&this.container.update()},isHideByClustering:function(){return this.isHideByClustering},hideByClustering:function(e){this.isHideByClustering=!!e},attachExplosionOffset:function(e,t){if(!this.getWorldPosition())return;let i=this._config.objectId;if(i){let n=e.modelManager.getBoundingBoxByIds([i]),o=this.assoiatedComponentBbox,s=n;if(o){let e=s.getCenter(this.scratchVector).clone();if(e.sub(o.getCenter(this.scratchVector_2).clone()),this.explosionOffset=e,this.explosionExtent>0&&0===t){let t=this.container._viewer.latLonToWorld(this.originLocation);t.x+=this.explosionDirection*e.x,t.y+=this.explosionDirection*e.y,t.z+=this.explosionDirection*e.z,this.originLocation=this.container._viewer.worldToLatLon(t),this.explosionExtent=0,this.explosionOffset=new THREE.Vector3,this.assoiatedComponentBbox=s.clone()}}}else{let i=e.getScene().getOriginalBoundingBoxWorld().getCenter(this.scratchVector),n=(new THREE.Box3).expandByPoint(this.container._viewer.latLonToWorld(this.getWorldPosition())),o=CLOUD.Utils.computeExplodeTranslation(i,n,t);this.explosionOffset=o}},updatePosition:function(){let e=this.container._viewer.latLonToWorld(this.location),t=this.container._viewer.latLonToWorld(this.originLocation);e.x=t.x+this.explosionOffset.x,e.y=t.y+this.explosionOffset.y,e.z=t.z+this.explosionOffset.z,this.location=this.container._viewer.worldToLatLon(e)},getOriginalPosition:function(){let e=this.container._viewer.latLonToWorld(this.originLocation);return new THREE.Vector3(e.x,e.y,e.z)},setInitialExplosionInfo:function(e){let t=null;t=e.getLayerManager().getLayer(this.layerId),this.explosionExtent=null===t?t.getExplosionExtent():0;let i=this._config.objectId;if(i){let t=e.getViewer().modelManager.getBoundingBoxByIds([i]);t.isEmpty()?(this._config.objectId=null,console.log("Cannot find component with Id "+i)):this.assoiatedComponentBbox=t.clone()}},getCurrentPosition:function(){return this.container._viewer.latLonToWorld(this.location)},getHoverAnimation:function(){return this.hoverAnimation},setHoverAnimation:function(e){null!=e&&(this.hoverAnimation=e,this.update())},setContainerVisible:function(e){this.hideByClustering(!e),this.update()},getOpacity:function(){return 1},setOpacity:function(e){}},n.Marker3D=s}(),function(){var t="Bimface.Earth.Plugins.Marker3D.Marker3DContainer",i=e.Bimface.Data.StatisticsDataManager.getInstance();let n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Marker3D");n.Marker3DContainer=class{constructor(t){e.Web.Lang.Utility.ClientHelper.getIsDesktop();if(!t.viewer)return void console.log("viewer must not be empty.");this.isMarker3DContainer=!0;const i=e.Bimface.Earth.Viewer.ViewerGIS&&t.viewer instanceof e.Bimface.Earth.Viewer.ViewerGIS;var n=t.viewer.getDomElement(),o=t.viewer.getViewer();if(P(this),"ViewerGIS"===t.viewer.getViewerType()&&"ShpPoint"===t.type)this._helper=new y.ShpPointMarker(o,t.layerId);else{if(t.viewer.marker3DContainer)return t.viewer.marker3DContainer;t.viewer.marker3DContainer=this,this._helper=new y.Marker3D(o,!0)}var s=this;this._viewer=t.viewer,this._items=[],this._areaData={},this.loadAreas=void 0,this.getLevelCallback=[],this.boxMap={},this.hoverListenerAdded=!1,this._isViewerGIS=i,this._pick=e=>{if(!e.doubleClick&&2!==e.event.button){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._clickCallback&&i._clickCallback(i)}}},this._doublePick=e=>{if(e.doubleClick){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._doubleClickCallback&&i._doubleClickCallback(i)}}},this._rightPick=e=>{if(2==e.event.button){var t=e.intersectInfo;if(t&&t.objectType===y.PICKABLETYPE.Marker3d){var i=this.getItemById(t.selectedObjectId);i._rightClickCallback&&i._rightClickCallback(i)}}},this._hover=e=>{var t=this;t.tooltipElement&&n.contains(t.tooltipElement)&&(n.removeChild(t.tooltipElement),t.tooltipElement=null);var i=e.intersectInfo;if(i&&i.objectType===y.PICKABLETYPE.Marker3d){var o=t.getItemById(i.selectedObjectId);t.tooltipElement=o.tooltipElement,o._tooltipCallback&&""!=t.tooltipElement.innerHTML&&o._tooltipCallback(o,e.canvasPos,n)}},o.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,s._pick),o.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,s._rightPick),o.registerEventListener(y.EVENTS.ON_CLICK_MARKER3D_PICK,s._doublePick),this.calculateViewerGISExplosionOffset=e=>{const i=t.viewer,n=i.getViewer(),o=e.modelId,r=e.floorInfos.length,a=n.getFloorExplosionExtent(o),l=n.getFloorExplosionDirection(o);if(0===a)for(const e of s.getAllItems())e.setInitialExplosionInfo(i);const h=e.floorInfos;let d=[];for(var c=0;c<r;c++){let e=h[c],t=h[c+1],i=h[c-1];if(d.push({box:{min:i?e.boundingBox.min.z:-1/0,max:t?t.boundingBox.min.z:1/0},floorName:e.name,explodedOffset:e.explodedHeight-e.elevation}),d.length==r){this.boxMap[o]=d;break}}const u=i.getLayerManager();let g=this._items;for(let e=0,t=g.length;e<t;e++){if(!g[e].getWorldPosition())continue;const t=u.getLayer(g[e].layerId);if(!t||!t.modelId)continue;if(t.modelId.toString()!==o||!g[e].levelName)continue;let i=d.getObjectByAttribute("floorName",g[e].levelName);i&&(g[e].explosionOffset={x:l.x*i.explodedOffset,y:l.y*i.explodedOffset,z:l.z*i.explodedOffset})}this.update()},t.viewer.addEventListener(e.Bimface.Earth.Viewer.ViewerGISEvent.FloorExplosion,(e=>{this.calculateViewerGISExplosionOffset(e)})),t.viewer.getViewer().registerEventListener(y.EVENTS.ON_EXPLOSION,(e=>{let i=this.getAllItems();for(const n of i)hn.attachExplosionOffset(t.viewer,e.extent,n);this.update()}))}addItem(e){i.send(t,"addItem"),e.container=this,e.position=this._viewer.latLonToWorld(e.location);let n=hn.ifExploded(this._viewer,e,this._isViewerGIS);n&&(n.setInitialExplosionInfo(this._viewer),this._items.push(n),this.update()),this.addTipsHoverListener()}addTipsHoverListener(){if(!this.hoverListenerAdded){const i=e.Web.Lang.Utility.ClientHelper.getIsDesktop();var t=this._viewer.getViewer();i&&t.registerEventListener(y.EVENTS.ON_HOVER_PICK,this._hover),this.hoverListenerAdded=i}}addItems(e){i.send(t,"addItems");for(const t of e){t.container=this,t.position=this._viewer.latLonToWorld(t.location);let e=hn.ifExploded(this._viewer,t,this._isViewerGIS);e&&this._items.push(e),t.setInitialExplosionInfo(this._viewer)}this.update(),this.addTipsHoverListener()}removeItemById(e){i.send(t,"removeItemById"),this._items.removeObjectByAttribute("id",e),this.update()}getItemById(e){return this._items.getObjectByAttribute("id",e)}getAllItems(){return[...this._items]}clear(){i.send(t,"clear");var n=this._viewer.getViewer();let o=e.Web.Lang.Utility.ClientHelper.getIsDesktop();n.unregisterEventListener(y.EVENTS.ON_CLICK_PICK,this._pick),o&&n.unregisterEventListener(y.EVENTS.ON_HOVER_PICK,this._hover),this.hoverListenerAdded=!1,this._items=[],this.update()}update(){this._helper.clear();let e=this._items.slice();for(let t=0,i=e.length;t<i;t++){e[t].getWorldPosition()&&e[t].updatePosition()}let t=[];for(let i=0,n=e.length;i<n;i++)!1===e[i].isHideByClustering&&t.push(e[i]);this._helper.add(t),this._helper.update(),this._viewer.render()}hideItemsById(e){i.send(t,"hideItemsById"),this._helper.hideByIds(e),this._viewer.render()}hideAllItems(){i.send(t,"hideAllItems"),this._helper.hide(),this._viewer.render()}showItemsById(e){i.send(t,"showItemsById"),this._helper.showByIds(e),this._viewer.render()}showAllItems(){i.send(t,"showAllItems"),this._helper.show(),this._viewer.render()}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Walkthrough").WalkthroughConfig=function(){return{viewer:null,time:10,stopCallback:null}},function(){var t="Bimface.Earth.Plugins.Walkthrough",i=e.Bimface.Data.StatisticsDataManager.getInstance(),n=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Walkthrough");e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");n.Walkthrough=class{constructor(t){var i=t.viewer,n=i.getViewer();i?"ViewerGIS"===i.getViewerType()?(P(this),this._viewer=i,this.bPause=!1,this.cameraStatus=null,this._walkthrough=new y.SphereLayer.Walkthrough,this._player=new y.SphereLayer.WalkthroughPlayer(n),this._player.setWalkthrough(this._walkthrough),t.stopCallback&&this._player.addStopPlayCallback(t.stopCallback),this.setWalkthroughTime(t.time),this.console=new e.Web.Common.Console):console.log("ViewerType is not supported."):console.log("viewer must not be empty.")}addKeyFrame(n){i.send(t,"addKeyFrame");var o=this._viewer,s=o.getViewer().camera,r={id:e.Web.Lang.Utility.UUID.createUUID(),position:s.position.clone(),orientation:{pitch:s.pitch,heading:s.heading,roll:s.roll},name:n};if(this._walkthrough.addKeyFrame(r),this._walkthrough.checkFrameTimeMode()){const e=this._walkthrough.getKeyFrames();e.length>1&&void 0===e[e.length-2].timeBetweenFrames&&(e[e.length-2].timeBetweenFrames=5)}var a=Object.assign({},r);return a.position=o.worldToLatLon(r.position),a.orientation={pitch:r.orientation.pitch,yaw:r.orientation.heading,roll:r.orientation.roll},a}setKeyFrameCallback(e){i.send(t,"setKeyFrameCallback"),this._player.setKeyFrameCallback(e)}removeKeyFrame(e){i.send(t,"removeKeyFrame"),this._walkthrough.removeKeyFrame(e)}clearKeyFrames(){i.send(t,"clearKeyFrames"),this._walkthrough.clearFrames()}setKeyFrames(e){i.send(t,"setKeyFrames"),"string"==typeof e&&(e=JSON.parse(e));var n=[];e.forEach((e=>{var t=Object.assign({},e);t.position=this._viewer.latLonToWorld(e.position),t.orientation={pitch:e.orientation.pitch,heading:e.orientation.yaw,roll:e.orientation.roll},n.push(t)})),this._walkthrough.setKeyFrameList(n)}getKeyFrames(){var e=this._walkthrough.getKeyFrames(),t=[];return e.forEach((e=>{var i=Object.assign({},e);i.position=this._viewer.worldToLatLon(e.position),i.orientation={pitch:e.orientation.pitch,yaw:e.orientation.heading,roll:e.orientation.roll},t.push(i)})),t}setWalkthroughTime(e){i.send(t,"setWalkthroughTime"),c.assertType(e,"obj")?e.frameTime?this._walkthrough.setWalkthroughTime(e.frameTime):this._walkthrough.setWalkthroughTime(e.totalTime):this._walkthrough.setWalkthroughTime(e)}setDisableAnimation(e){this.disableAnimation=e}play(e){if(!this.disableAnimation){i.send(t,"play");var n=this._player,o=this.cameraStatus;e&&n.startFrom(e),n.stop(!1),!0===this.bPause&&o&&o.position&&this._player.camera.position.copy(this._viewer.latLonToWorld(o.position)),n.walkthrough.keyFrameList&&n.walkthrough.keyFrameList.length>0?(n.play(),this.bPause=!1):this.console.warn("The parameter[keyFrames] cannot be null")}}pause(){this.disableAnimation||(i.send(t,"pause"),this.bPause=!0,this.cameraStatus=this._viewer.getCameraStatus(),this._player.pause())}setProgress(e){this.disableAnimation||"number"==typeof e&&(e<0||e>1||(this._player.setProgress(e),this.cameraStatus=this._viewer.getCameraStatus()))}stop(){this.disableAnimation||(i.send(t,"stop"),this._player.stop(!0),this.bPause=!1)}stopCallback(e){i.send(t,"stopCallback"),e&&(this._stopCallback=e,this._player.addStopPlayCallback(e))}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Walkthrough").WalkthroughManagerConfig=function(){return{viewer:null}},function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Walkthrough");t.WalkthroughManager=class{constructor(e){var t=e.viewer;t?"ViewerGIS"===t.getViewerType()?(P(this),this._viewer=t,this._walkthroughMap={}):console.log("ViewerType is not supported."):console.log("viewer must not be empty.")}addWalkthrough(t,i){var n=e.Web.Lang.Utility.UUID.createUUID(),o={id:n,walkthrough:i};return i._walkthrough.setName(t),this._walkthroughMap[n]=o,n}removeWalkthrough(e){"[object String]"===Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"===Object.prototype.toString.call(e)&&e.forEach((e=>{delete this._walkthroughMap[e]}))}setWalkthroughList(t){"[object Object]"===Object.prototype.toString.call(t)&&t.data.forEach((t=>{var i=new e.Bimface.Earth.Plugins.Walkthrough.WalkthroughConfig;i.viewer=this._viewer;var n=new e.Bimface.Earth.Plugins.Walkthrough.Walkthrough(i);n.setKeyFrames(t.keyFrames),n.setWalkthroughTime(t.time),n._walkthrough.setName(t.name),this._walkthroughMap[t.id]={id:t.id,walkthrough:n}}))}getWalkthroughList(){var e={data:[],version:1};for(var t in this._walkthroughMap){var i={id:t},n=this._walkthroughMap[t].walkthrough;i.keyFrames=n.getKeyFrames(),i.name=n._walkthrough.getName(),i.time=n._walkthrough.walkthroughTime,e.data.push(i)}return e}}}();const Lr="Exit",Dr="EditingModeChanged",Ar=e.Bimface.Data.StatisticsDataManager.getInstance(),Vr="bf_interaction.sceneEditor";let Rr=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");class Or{constructor(e,t,i){this.viewer3D=e,this.objectType=t,this.name="Translation",this._eventManager=i,this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1,"ExternalObject"===t&&(this.externalObjectManager=new Glodon.Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager(e))}setEditedObjectId(e){if(this.handleEditedObjectId(e),e=this.editedObjectId,this.viewer3D instanceof Glodon.Bimface.Earth.Viewer.ViewerGIS){const t=this.viewer3D.getLayerManager().getLayerByType("ExternalObjectLayer");for(let i=0;i<t.length;i++){let n=!1;const o=t[i].getExternalObjectManager(),s=o.getAllObjectIds();if(this.isEditedMulti()){for(let t=0;t<e.length;t++)if(s.includes(e[i])){this.externalObjectManager=o,n=!0;break}if(n)break}else if(s.includes(e)){this.externalObjectManager=o;break}}}this.isEditedMulti()&&this.init()}handleEditedObjectId(e){this.editedObjectId=Array.isArray(e)&&1===e.length?e[0]:e}getEditedObjectId(){return this.editedObjectId}isEditedMulti(){return Array.isArray(this.editedObjectId)&&this.editedObjectId.length>1}init(){if(!this.initialized&&this.isEditedMulti()){const e=this.editedObjectId[0];this.singleModelMatrixInvert=this.getModelTransformMatrix(e).invert();const t=this.editedObjectId.reduce(((e,t)=>{const{min:i,max:n}=this.getSingleBoundingBoxWorld(t);return e.push(i,n),e}),[]),{min:i,max:n}=(new THREE.Box3).setFromPoints(t);this.initialCenter=(new THREE.Vector3).addVectors(i,n).multiplyScalar(.5),this.initialBoundingBoxPoints=[new THREE.Vector3(i.x,i.y,i.z),new THREE.Vector3(n.x,i.y,i.z),new THREE.Vector3(n.x,n.y,i.z),new THREE.Vector3(i.x,n.y,i.z),new THREE.Vector3(i.x,i.y,n.z),new THREE.Vector3(n.x,i.y,n.z),new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(i.x,n.y,n.z)],this.initialized=!0}}resetInitialValues(){this.initialBoundingBoxPoints=[],this.transformMatrix=new THREE.Matrix4,this.singleModelMatrixInvert=new THREE.Matrix4,this.initialized=!1}getBoundingBoxWorld(){const e=this.objectType;if(this.isEditedMulti()){return(new THREE.Box3).setFromPoints(this.initialBoundingBoxPoints.map((e=>e.clone().applyMatrix4(this.transformMatrix))))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundingBoxWorld()}getTransformMatrix(){return this.isEditedMulti()?this.transformMatrix:this.getModelTransformMatrix(this.editedObjectId)}getSingleBoundingBoxWorld(e){if("ExternalObject"===this.objectType)return this.viewer3D.getExternalComponentManager().getBoundingBoxById(e);return this.viewer3D.getViewer().getModelManager().getModel(e).getBoundingBoxWorld()}getModelTransformMatrix(e){if("ExternalObject"===this.objectType){let t=this.viewer3D.getExternalComponentManager().getGroupTransform(e);return(new THREE.Matrix4).compose(t.position,t.rotate,t.scale)}return this.viewer3D.getViewer().getModelManager().getModel(e).getTransformMatrix().clone()}getBoundaryPoints(){const e=this.objectType;if(this.isEditedMulti()){const e=this.transformMatrix;return this.initialBoundingBoxPoints.map((t=>t.clone().applyMatrix4(e)))}if("ExternalObject"===e)return this.viewer3D.getExternalComponentManager().getBoundaryPoints(this.editedObjectId);return this.viewer3D.getViewer().getModelManager().getModel(this.editedObjectId).getBoundaryPoints()}getBoundingBox(){let e=this.getBoundaryPoints(),t=this.getRotationMatrix().invert(),i=[];return e.map((e=>i.push(e.clone().applyMatrix4(t)))),(new THREE.Box3).setFromPoints(i)}getRotationMatrix(){let e=new THREE.Matrix4,t=this.getTransformMatrix();return e.extractRotation(t),e}_fireModelEvent(e){const t=this._eventManager,i=Array.isArray(this.editedObjectId)?this.editedObjectId:[this.editedObjectId],n={};i.map((e=>{n[e]=this.viewer3D.getModel(e).getModelTransformationAdaptedUnit()})),t.fireEvent(e,{modelId:i,transformation:n})}updateController(e){}updateTransformMatrix(){const e=this.editedObjectId[0],t=this.getModelTransformMatrix(e);this.transformMatrix=t.multiply(this.singleModelMatrixInvert)}_scaleOnBasePoint(e,t,i){const n=new THREE.Vector3,o=new THREE.Quaternion,s=new THREE.Vector3;e.decompose(n,o,s),s.multiply(i);const r=i.clone().sub(new THREE.Vector3(1,1,1)),a=o.clone(),l=a.clone().invert(),h=n.clone(),d=t.clone().sub(h).applyQuaternion(l).multiply(r).applyQuaternion(a);n.sub(d);return(new THREE.Matrix4).compose(n,o,s)}_rotateOnBasePoint(e,t,i,n){const o=new THREE.Vector3,s=new THREE.Quaternion,r=new THREE.Vector3;e.decompose(o,s,r);const a=s.clone().invert(),l=(new THREE.Quaternion).setFromAxisAngle(i,n);s.multiply(l);const h=o.clone(),d=t.clone().sub(h).applyQuaternion(a).applyQuaternion(s);o.sub(d).add(t.clone().sub(h));return(new THREE.Matrix4).compose(o,s,r)}getExternalObjectTransform(e){const t=this.externalObjectManager.getTransformation(e);return(new THREE.Matrix4).fromArray(t)}setRotation(e,t){const i=this.objectType,n=t;if(this.isEditedMulti()){const t=this.editedObjectId.length,i=this.viewer3D.globalUnitUtil.revertVector(this.initialCenter.clone().applyMatrix4(this.transformMatrix)),o=this.transformMatrix.clone();let s;switch(n){case"xy":s=new THREE.Vector3(0,0,1);break;case"xz":s=new THREE.Vector3(0,1,0);break;case"yz":s=new THREE.Vector3(1,0,0)}const r=this._rotateOnBasePoint(this.transformMatrix.clone(),i,s,e),a=o.clone().invert();for(let e=0;e<t;e++){const t=this.editedObjectId[e];let i;if("ExternalObject"===this.objectType)i=this.getExternalObjectTransform(t);else{const e=this.viewer3D.getModel(t).getModelTransformation();i=(new THREE.Matrix4).fromArray(e)}const n=r.clone().multiply(a.clone().multiply(i));"ExternalObject"===this.objectType?this.externalObjectManager.setTransformation(t,n.elements):this.viewer3D.getModel(t).setModelTransformation(n.elements)}this.updateTransformMatrix()}else{const t=this.viewer3D.globalUnitUtil.revertVector(this.getEditObjectCenter());if("ExternalObject"===i)"xy"===n&&this.externalObjectManager.setRotationZ(this.editedObjectId,t,e),"xz"===n&&this.externalObjectManager.setRotationY(this.editedObjectId,t,e),"yz"===n&&this.externalObjectManager.setRotationX(this.editedObjectId,t,e);else if("Model"==i){const i=this.viewer3D.getModel(this.editedObjectId);"xy"===n&&i.setModelRotationZ(t,e),"xz"===n&&i.setModelRotationY(t,e),"yz"===n&&i.setModelRotationX(t,e)}}"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}getEditObjectCenter(){return this._modelCenter=new THREE.Vector3,this.getBoundingBoxWorld().getCenter(this._modelCenter),this._modelCenter}setObjectScale(e,t){const i=this.objectType;if(this.isEditedMulti()){const n=this.editedObjectId.length,o=this.transformMatrix.clone(),s=this._scaleOnBasePoint(this.transformMatrix.clone(),e,t),r=o.clone().invert();for(let e=0;e<n;e++){const t=this.editedObjectId[e],n="ExternalObject"===i?this.getExternalObjectTransform(t).elements:this.viewer3D.getModel(t).getModelTransformation(),o=(new THREE.Matrix4).fromArray(n),a=s.clone().multiply(r.clone().multiply(o));"ExternalObject"===this.objectType?this.externalObjectManager.setTransformation(t,a.elements):this.viewer3D.getModel(t).setModelTransformation(a.elements)}this.updateTransformMatrix()}else"ExternalObject"===i?this.externalObjectManager.scaleOnBasePoint(this.getEditedObjectId(),e,t):"Model"===i&&this.viewer3D.getModel(this.getEditedObjectId()).setModelScale(e,t),"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}getPosition(){const e=this.objectType,t=this.editedObjectId;if("ExternalObject"===e)return this.externalObjectManager.getPosition(t);if("Model"===e){return this.viewer3D.getModel(t).getPositionWorld()}}setPosition(e){const t=this.objectType,i=this.editedObjectId;if("ExternalObject"===t)this.externalObjectManager.setPosition(i,e);else if("Model"===t){this.viewer3D.getModel(i).setPositionWorld(e)}}setObjectTranslation(e){const t=this.objectType;if(this.isEditedMulti())this.editedObjectId.forEach((i=>{if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}));else{const i=this.editedObjectId;if("ExternalObject"===t)this.externalObjectManager.translate(i,e);else if("Model"===t){this.viewer3D.getModel(i).setModelTranslation(e)}}this.isEditedMulti()&&this.updateTransformMatrix(),"ExternalObject"!==this.objectType&&this._fireModelEvent("ModelTransforming")}setName(e){this.name=e}}Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Web.Lang.Utility.Dom");let kr=Glodon.Web.Lang.Utility.Namespace.ensureNamespace(Glodon,"Bimface.Earth.Plugins.ObjectEditor");class Hr{constructor(e,t){this.viewer=e,this.editObjectType=t,P(this),this.activeEditors=[],this.rotationController={X:!0,Y:!0,Z:!0},this.translationController={X:!0,Y:!0,Z:!0},this.scaleController={Uniform:!0,X:!0,Y:!0,Z:!0},this.initilize()}initilize(){this.initHelperAndEvent();let e=new Glodon.Web.Lang.EventManager;this.getEventManager=function(){return e},this.activeEditor=new Or(this.viewer,this.editObjectType,e)}initHelperAndEvent(){this.helper=CLOUD.Interaction.InteractionHelper.getInstance(this.viewer.getViewer()),this.helperEvents={},this.addHelperEvent("TransformStarted",(e=>{this.startObjectPosition={...this.activeEditor.getPosition()},"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformStart")})),this.addHelperEvent("TransformChanged",(e=>{if("Translation"===e.id){let t=e.control.position.clone(),i={x:t.x-this.objectPositon.x,y:t.y-this.objectPositon.y,z:t.z-this.objectPositon.z};this.activeEditor.setObjectTranslation(this.viewer.globalUnitUtil.revertTranslate(i,["x","y","z"])),this.objectPositon=t}else if("Scale"===e.id){let t=e.control.scaleInfo,i={};if(t){let n=this.activeEditor.getBoundaryPoints(),o=null;const s=(e,t,i,o)=>{let s=n[e],r=n[t],a=n[i],l=n[o];return(new THREE.Vector3).add(s).add(r).add(a).add(l).multiplyScalar(.25)};switch(t.type){case"AxisX":o=s(0,3,7,4),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisXN":o=s(1,2,6,5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,1,1);break;case"AxisY":o=s(0,1,5,4),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisYN":o=s(2,3,7,6),i=new THREE.Vector3(1,t.scaleFactor/this.objectScale.y,1);break;case"AxisZ":o=s(0,1,2,3),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;case"AxisZN":o=s(4,5,6,7),i=new THREE.Vector3(1,1,t.scaleFactor/this.objectScale.z);break;default:o=s(0,1,2,3).add(s(4,5,6,7)).multiplyScalar(.5),i=new THREE.Vector3(t.scaleFactor/this.objectScale.x,t.scaleFactor/this.objectScale.y,t.scaleFactor/this.objectScale.z)}o=this.viewer.globalUnitUtil.revertVector(o),this.activeEditor.setObjectScale(o,i),e.control.update(this.activeEditor.getBoundingBox());let r=new THREE.Vector3;this.activeEditor.getBoundingBoxWorld().getCenter(r),e.control.setPosition(r),this.objectScale={x:t.scaleFactor,y:t.scaleFactor,z:t.scaleFactor}}}else if("Rotate"===e.id){let t=e.control.rotateInfo,i="";if(t){switch(t.type){case"ringX":default:i="yz";break;case"ringY":i="xz";break;case"ringZ":i="xy"}switch(this.activeEditor.setRotation(t.angle,i),t.type){case"ringX":e.control.rotateX(t.angle);break;case"ringY":e.control.rotateY(t.angle);break;default:e.control.rotateZ(t.angle)}}}})),this.addHelperEvent("TransformFinished",(e=>{if("Translation"===e.id){if(["AxisX","AxisY","PlaneZ"].indexOf(e.object.name)>=0&&this.startObjectPosition&&this.getIsOnlyRotateZ()){let e=this.activeEditor.viewer3D.worldToLatLon(this.startObjectPosition),t=this.activeEditor.viewer3D.worldToLatLon(this.activeEditor.getPosition()),i=this.activeEditor.viewer3D.latLonToWorld({...t,alt:e.alt});this.activeEditor.setPosition(i)}this.startObjectPosition=null,this.helper.getControl("Translation").rotation.x=0,this.helper.getControl("Translation").rotation.y=0,this.helper.getControl("Translation").rotation.z=0;let t=new THREE.Vector3;this.activeEditor.getBoundingBox().getCenter(t),this.helper.getControl("Translation").setPosition(t),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=e.control.position.clone()}"Scale"===e.id&&(this.objectScale={x:1,y:1,z:1}),"Model"===this.editObjectType&&this.activeEditor._fireModelEvent("ModelTransformEnd")}))}addHelperEvent(e,t){this.helperEvents[e]=t,this.helper.addEventListener(e,t)}setEditedObjectId(e){this.editedObjectId=e,Array.isArray(e)&&this.activeEditor.resetInitialValues(),this.activeEditor.setEditedObjectId(e),this.dispose();let t=new THREE.Vector3;switch(this.activeEditor.name){case"Translation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox(),isEarthSceneRestrictLength:this.getIsOnlyRotateZ()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.updateController()}getIsOnlyRotateZ(){let e=this.activeEditor.viewer3D.getModel(this.activeEditor.editedObjectId).getModelTransformationAdaptedUnit();var t=new THREE.Matrix4;t.elements=e;var i=(new THREE.Quaternion).setFromRotationMatrix(t);let n=!1;return Math.abs(i.x)<=.001&&Math.abs(i.y)<=.001&&(n=!0),n}attachInitDrawables(){}getEditedObjectId(){return this.editedObjectId}activateEditor(e){this.dispose();let t=new THREE.Vector3;switch(e){case"Translation":this.activeEditor.setName("Translation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Translation","TranslateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox(),isEarthSceneRestrictLength:this.getIsOnlyRotateZ()}),this.helper.getControl("Translation").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectPositon=this.helper.getControl("Translation").position.clone();break;case"Scaling":this.activeEditor.setName("Scaling"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Scale","ScaleControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Scale").applyMatrix4(this.activeEditor.getRotationMatrix()),this.objectScale={x:1,y:1,z:1};break;case"Rotation":this.activeEditor.setName("Rotation"),this.activeEditor.setEditedObjectId(this.editedObjectId),this.activeEditor.getBoundingBox().getCenter(t),this.helper.addControl("Rotate","RotateControl",{position:t,boundingBox:this.activeEditor.getBoundingBox()}),this.helper.getControl("Rotate").applyMatrix4(this.activeEditor.getRotationMatrix())}this.changeControlArrowDirection(),this.activeEditor.setEditedObjectId(this.editedObjectId),this.updateController()}changeControlArrowDirection(){const e=this.viewer.getViewer().camera._direction&&this.viewer.getViewer().camera._direction.clone().applyMatrix4(this.helper.invertMatrix).normalize(),t=this.viewer.getViewer().camera.position.clone().applyMatrix4(this.helper.invertMatrix),i=this.viewer.getViewer().camera.fov;this.helper.dispatchEvent({type:"CameraChanged",cameraDirection:e,cameraPosition:t,cameraFov:i})}dispose(){this.helper.removeControl("Translation"),this.helper.removeControl("Scale"),this.helper.removeControl("Rotate")}hide(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!1),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!1),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!1),this.viewer.render()}show(){this.helper.getControl("Translation")&&(this.helper.getControl("Translation").visible=!0),this.helper.getControl("Scale")&&(this.helper.getControl("Scale").visible=!0),this.helper.getControl("Rotate")&&(this.helper.getControl("Rotate").visible=!0),this.viewer.render()}onExit(){this.dispose(),this.isExitNow=!0,Object.entries(this.helperEvents).forEach((([e,t])=>{this.helper.removeEventListener(e,t)})),this.viewer.render()}updateController(e,t){switch(t){case"Translation":null!=e.X&&(this.translationController.X=e.X),null!=e.Y&&(this.translationController.Y=e.Y),null!=e.Z&&(this.translationController.Z=e.Z);break;case"Rotation":null!=e.X&&(this.rotationController.X=e.X),null!=e.Y&&(this.rotationController.Y=e.Y),null!=e.Z&&(this.rotationController.Z=e.Z);break;case"Scaling":null!=e.X&&(this.scaleController.X=e.X),null!=e.Y&&(this.scaleController.Y=e.Y),null!=e.Z&&(this.scaleController.Z=e.Z),null!=e.Uniform&&(this.scaleController.Uniform=e.Uniform)}const i={...this.scaleController};this.helper.getControl("Translation")&&this.helper.getControl("Translation").updateAxisVisible(this.translationController),this.helper.getControl("Rotate")&&this.helper.getControl("Rotate").updateAxisVisible(this.rotationController),this.helper.getControl("Scale")&&this.helper.getControl("Scale").updateAxisVisible(i)}}kr.ObjectEditorManager=Hr,e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.ModelEditor").ModelEditorToolbarConfig=function(){return{viewer:null,layerId:null,buttonVisibility:{},translationController:{},rotationController:{},scaleController:{}}},function(){let t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=(e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.ModelEditor"));i.ModelEditorToolbar=class extends class{constructor(e){this.viewer=e.viewer,this.objectId=e.objectId,P(this),this.viewer._objectEditorToolbar&&this.viewer._objectEditorToolbar.exit(),this.mode=null,this.toolBarButtons={translate:!e.buttonVisibility.hasOwnProperty("translate")||e.buttonVisibility.translate,rotate:!e.buttonVisibility.hasOwnProperty("rotate")||e.buttonVisibility.rotate,scale:!e.buttonVisibility.hasOwnProperty("scale")||e.buttonVisibility.scale},this.viewer._objectEditorToolbar=this,this.rotationController={X:!e.rotationController.hasOwnProperty("X")||e.rotationController.X,Y:!e.rotationController.hasOwnProperty("Y")||e.rotationController.Y,Z:!e.rotationController.hasOwnProperty("Z")||e.rotationController.Z},this.translationController={X:!e.translationController.hasOwnProperty("X")||e.translationController.X,Y:!e.translationController.hasOwnProperty("Y")||e.translationController.Y,Z:!e.translationController.hasOwnProperty("Z")||e.translationController.Z},Array.isArray(this.objectId)&&this.objectId.length>1?this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!!e.scaleController.hasOwnProperty("X")&&e.scaleController.X,Y:!!e.scaleController.hasOwnProperty("Y")&&e.scaleController.Y,Z:!!e.scaleController.hasOwnProperty("Z")&&e.scaleController.Z}:this.scaleController={Uniform:!e.scaleController.hasOwnProperty("Uniform")||e.scaleController.Uniform,X:!e.scaleController.hasOwnProperty("X")||e.scaleController.X,Y:!e.scaleController.hasOwnProperty("Y")||e.scaleController.Y,Z:!e.scaleController.hasOwnProperty("Z")||e.scaleController.Z}}setRotationController(e){e&&(this.rotationController=e),this.objectEditorManager.updateController(this.rotationController,"Rotation")}getRotationController(){let e={};return e.X=!this.rotationController.hasOwnProperty("X")||this.rotationController.X,e.Y=!this.rotationController.hasOwnProperty("Y")||this.rotationController.Y,e.Z=!this.rotationController.hasOwnProperty("Z")||this.rotationController.Z,e}setTranslationController(e){e&&(this.translationController=e),this.objectEditorManager.updateController(this.translationController,"Translation")}getTranslationController(){let e={};return e.X=!this.translationController.hasOwnProperty("X")||this.translationController.X,e.Y=!this.translationController.hasOwnProperty("Y")||this.translationController.Y,e.Z=!this.translationController.hasOwnProperty("Z")||this.translationController.Z,e}setScaleController(e){e&&(this.scaleController=e),this.objectEditorManager.updateController(this.scaleController,"Scaling")}getScaleController(){let e={};return e.X=!this.scaleController.hasOwnProperty("X")||this.scaleController.X,e.Y=!this.scaleController.hasOwnProperty("Y")||this.scaleController.Y,e.Z=!this.scaleController.hasOwnProperty("Z")||this.scaleController.Z,e.Uniform=!this.scaleController.hasOwnProperty("Uniform")||this.scaleController.Uniform,e}setButtonVisibility(e){e&&(this.toolBarButtons=e,this._updateButtonsVisibility())}getButtonVisibility(){let e={};return e.translate=!this.toolBarButtons.hasOwnProperty("translate")||this.toolBarButtons.translate,e.rotate=!this.toolBarButtons.hasOwnProperty("rotate")||this.toolBarButtons.rotate,e.scale=!this.toolBarButtons.hasOwnProperty("scale")||this.toolBarButtons.scale,e}_updateButtonsVisibility(){this.toolBarButtons.scale||this.toolBarButtons.rotate||this.toolBarButtons.translate?(this.switchToolbarAllHide=!1,this.show()):(this.setBimfaceUIVisibility(!1),this.switchToolbar.hide(),this.switchToolbarAllHide=!0);let e=this.switchToolbar.getControls(),t=this.getButton("Translation",e),i=this.getButton("Rotation",e),n=this.getButton("Scaling",e);this.toolBarButtons.translate?t.show():t.hide(),this.toolBarButtons.rotate?i.show():i.hide(),this.toolBarButtons.scale?n.show():n.hide()}_updateController(){this.objectEditorManager&&(this.objectEditorManager.updateController(this.translationController,"Translation"),this.objectEditorManager.updateController(this.rotationController,"Rotation"),this.objectEditorManager.updateController(this.scaleController,"Scaling"))}setEditingMode(e){if(this.objectEditorManager){switch(e){case"rotation":this.mode="rotation",this.objectEditorManager.activateEditor("Rotation");break;case"translation":this.mode="translation",this.objectEditorManager.activateEditor("Translation");break;case"scale":this.mode="scale",this.objectEditorManager.activateEditor("Scaling")}this.objectEditorManager.show()}}getEditingMode(){return this.mode}setEditedObjectId(e){this.objectEditorManager.setEditedObjectId(e)}getEditedObjectId(){return this.objectEditorManager.getEditedObjectId()}show(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!1),this.modelEditor.show(),this.switchToolbarAllHide||this.switchToolbar.show(),this.objectEditorManager.show())}hide(){this._destroyed||(this.viewer.viewerType,this.setBimfaceUIVisibility(!0),this.modelEditor.hide(),this.switchToolbar.hide(),this.objectEditorManager.hide())}exit(){this._destroyed||(this.hide(),this._getEventManager().fireEvent(Lr),this.objectEditorManager.onExit(),delete this.viewer._objectEditorToolbar,this.destroy())}destroy(){this.domElement&&this.domElement.remove(),this.domElement=null,this.viewer=null,this.objectId=null,this.objectEditorManager=null,this._destroyed=!0}update(){}updateManagerController(e,t){this.objectEditorManager.updateController(e,type)}initialize(){this.mapUIVisibility={"bf-tree-toolbar":"none","bf-modelTree-panel":"none","bf-toolbar-bottom":"none","bf-property-panel":"none","bf-measurement-panel":"none","bf-sectionPlane-panel":"none","bf-pickSectionPlane-panel":"none","bf-sectionBox-panel":"none","bf-settings-panel":"none","bf-basicInfo-panel":"none","bf-map-panel":"none"},this.recordUIVisibility()}toolBarDom(t=!1){const i=this;let n=[];const o=Rr.create("div",t?"bf-effectToolbar":"bf-roomEditorToolbar");if(i.domElement=o,o.style.zIndex=1,o.addEventListener("mousedown",(e=>(e.stopPropagation(),!1))),t){const t=new e.Bimface.UI.Toolbar.ToolbarConfig;t.element=o,t.className="bf-toolbar bf-toolbar-effectToolbar switch-btn";let s=this.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(t);i.modelEditor=s,n.push(s);const r=new e.Bimface.UI.Button.ButtonConfig;r.className="bf-button bimface-icon gld-bf-edit-24",r.title="点击隐藏编辑控件",r.checkedState=!0;const a=new e.Bimface.UI.Button.ToggleButton(r);a.addEventListener("StateChange",(e=>{e?(a.element.title="点击隐藏编辑控件",Ar.send(Vr,"editorStatusOn"),this.objectEditorManager.show(),this.objectEditorManager.activateEditor("Translation")):(a.element.title="点击显示编辑控件",Ar.send(Vr,"editorStatusOff"),this._getEventManager().fireEvent(Lr),this.objectEditorManager.dispose(),this.objectEditorManager.hide()),this.toggleOtherButtons(e)})),s.addControl(a)}if(void 0===this.switchToolbar){var s=e.Bimface.UI.Toolbar.ToolbarConfig();s.className=t?"bf-toolbar bf-toolbar-effectToolbar":"bf-toolbar bf-toolbar-roomEditor",s.element=o,s.buttons=["ModelEditingTranslate","ModelEditingRotate","ModelEditingScale"],this.viewer.getDomElement().appendChild(o),this.switchToolbar=new e.Bimface.Application.UI.Toolbar.Toolbar(s),n.push(this.switchToolbar)}let r=e.Bimface.UI.Control.ControlEvent,a=this.switchToolbar.getControls();this.uncheckOthers("Translation",a);let l=["Translation","Rotation","Scaling"];i._editingMode="Translation";for(let e=0;e<a.length;e++){let t=a[e];t.addEventListener(r.Click,(function(){if(t.isChecked()){i.objectEditorManager.activateEditor(l[e]),i.uncheckOthers(t.getId(),a);let n="Scaling"===t.getId()?"Scale":t.getId();i._getEventManager().fireEvent(Dr,{previousEditingMode:i._editingMode,followingEditingMode:n}),i._editingMode=n}else t.toggleCheckedState()}))}if(!t){const t=new e.Bimface.UI.Toolbar.ToolbarConfig;t.element=o,t.className="bf-toolbar bf-toolbar-roomEditor";let s=i.modelEditor=new e.Bimface.UI.Toolbar.Toolbar(t);i.modelEditor=s,n.push(s);const r=new e.Bimface.UI.Button.ButtonConfig;r.className="bf-modeleditor-cancel",r.title=BimfaceLanguage.bf_general_exit;const a=new e.Bimface.UI.Button.SingleButton(r);a.setHtml("退出"===BimfaceLanguage.bf_general_exit?"退 出":BimfaceLanguage.bf_general_exit),a.addEventListener("Click",(()=>{this.exit()})),s.addControl(a)}this.viewer.getDomElement().appendChild(o),this._updateButtonsVisibility(),this._updateController()}recordUIVisibility(){let e=Object.keys(this.mapUIVisibility);for(const t of e){let e=document.getElementsByClassName(t);e.length>0&&(this.mapUIVisibility[t]=e[0].style.display)}}uncheckOthers(e,t){for(const i of t)i.getId()===e?i.setCheckedState(!0):i.setCheckedState(!1)}getButton(e,t){for(let i=0;i<t.length;i++){let n=t[i];if(n.getId()===e)return n}}setBimfaceUIVisibility(e){let t=Object.keys(this.mapUIVisibility);for(const i of t){let t=document.getElementsByClassName(i);0!=t.length&&(t[0].style.display=0==e?"none":this.mapUIVisibility[i])}}_getEventManager(){return this.objectEditorManager.getEventManager()}addEventListener(e,t){this._getEventManager().addEvent(e,t)}removeEventListener(e,t){this._getEventManager().removeEvent(e,t)}toggleOtherButtons(e){let t,i=this.switchToolbar.getControls();i.length&&(t=i[0],t.element.parentElement.style.display=e?"flex":"none");for(let n=0;n<i.length;n++)t=i[n],e&&(0===n?t.setCheckedState(!0):t.setCheckedState(!1))}}{constructor(e){t.send("Bimface.Earth.Plugins.ModelEditor","ModelEditorToolbar"),e.objectId=es(e),super(e),this.name="ModelEditorToolbar",this.editedId=e.objectId,this.initialize(),this.toolBarDom(e.isGisEdit)}setButtonVisibility(e){super.setButtonVisibility(e)}getButtonVisibility(){return super.getButtonVisibility()}setEditedModelId(e){super.setEditedObjectId(e)}getEditedModelId(){return super.getEditedObjectId()}setEditedModel(e){const t=es({viewer:this.viewer,modelId:e,layerId:e});super.setEditedObjectId(t),this.editedId=e}getEditedModel(){return this.editedId}show(){super.show()}hide(){super.hide()}exit(){super.exit(),CLOUD.GlobalData.GTAO=this.enableGTAO}setRotationController(e){super.setRotationController(e)}getRotationController(){return super.getRotationController()}setTranslationController(e){super.setTranslationController(e)}getTranslationController(){return super.getTranslationController()}setScaleController(e){super.setScaleController(e)}getScaleController(){return super.getScaleController()}setEditingMode(e){super.setEditingMode(e)}getEditingMode(){return super.getEditingMode()}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}initialize(){super.initialize(),this.objectEditorManager=new Hr(this.viewer,"Model"),this.objectEditorManager.setEditedObjectId(this.objectId),this.enableGTAO=CLOUD.GlobalData.GTAO,!0===this.enableGTAO&&(CLOUD.GlobalData.GTAO=!1)}}}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.ModelEditor");let i=Object.freeze({ModelTransformStart:"ModelTransformStart",ModelTransforming:"ModelTransforming",ModelTransformEnd:"ModelTransformEnd",Exit:"Exit",EditingModeChanged:"EditingModeChanged"});t.ModelEditorToolbarEvent=i}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Snap").SnapConfig=function(){return{id:null,color:new e.Web.Graphics.Color(249,157,11,1),hoverColor:new e.Web.Graphics.Color(17,218,183,.2),objectColor:new e.Web.Graphics.Color(17,218,183,.9),width:3,radius:25,viewer:null}},function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Snap"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=function(t){this.viewer=t.viewer,this.maxPointsNum=1;var n=new e.Web.Graphics.Color(17,218,183,.2);let o=new e.Web.Graphics.Color(17,218,183,1);var s=i.createNS("circle","bf-snap-handle");s.setAttribute("r",6),s.setAttribute("fill",n.getRGB()),s.style.fill=n.getRGB();const r=i.createNS("rect","bf-snap-handle");r.setAttribute("width",14),r.setAttribute("height",14),r.setAttribute("fill","none"),r.setAttribute("stroke",o.getRGB()),r.setAttribute("stroke-width",2);const a=i.createNS("path","bf-snap-handle");a.setAttribute("d","M 7 0 L 16 16 L 0 16 L 7 0"),a.setAttribute("fill","none"),a.setAttribute("stroke",o.getRGB()),a.setAttribute("stroke-width",2);const l=i.createNS("line","bf-snap-handle");l.setAttribute("x1",0),l.setAttribute("y1",0),l.setAttribute("x2",14),l.setAttribute("y2",14),l.setAttribute("stroke",n.getRGB()),l.setAttribute("stroke-width",2);const h=i.createNS("line","bf-snap-handle");h.setAttribute("x1",14),h.setAttribute("y1",0),h.setAttribute("x2",0),h.setAttribute("y2",14),h.setAttribute("stroke",n.getRGB()),h.setAttribute("stroke-width",2);var d=i.createNS("line","bf-snap-line");d.style.strokeWidth=2,d.style.stroke=n.getRGB();var c=i.createNS("polygon","bf-snap-rect");c.setAttribute("fill",n.getRGBA()),c.setAttribute("stroke",n.getRGB()),c.setAttribute("stroke-width",1),this.hoverLine=d,this.hoverPoint=s,this.hoverEndPoint=r,this.hoverMidPoint=a,this.hoverIntersectionPointA=l,this.hoverIntersectionPointB=h,this.hoverPanel=c,this.hoverPanelSize={width:20,height:20}};n.prototype=Object.assign(n.prototype,{stretchOnDirection:function(e,t,i){var n=e.clone().add(t).multiplyScalar(.5),o=t.clone().sub(e).normalize();return[n.clone().sub(o.clone().multiplyScalar(i/2)),n.clone().add(o.clone().multiplyScalar(i/2))]},draw:function(e){var t=this.hoverLine,i=this.hoverPoint;const n=this.hoverEndPoint,o=this.hoverMidPoint,s=this.hoverIntersectionPointA,r=this.hoverIntersectionPointB,a=e.hoverPosition&&e.hoverPosition.x,l=e.hoverPosition&&e.hoverPosition.y;var h=this.hoverPanel,d=this.hoverPanelSize;switch(e.hoverObjectType){case"Point":i.setAttribute("cx",e.hoverPosition.x),i.setAttribute("cy",e.hoverPosition.y),e.svg.appendChild(i);break;case"EndPoint":n.setAttribute("x",a-7),n.setAttribute("y",l-7),e.svg.appendChild(n);break;case"MidPoint":o.setAttribute("d",`M ${a} ${l-7} L ${a+8} ${l+8} L ${a-8} ${l+8} L ${a} ${l-7}`),e.svg.appendChild(o);break;case"IntersectionPoint":s.setAttribute("x1",a-7),s.setAttribute("y1",l-7),s.setAttribute("x2",a+7),s.setAttribute("y2",l+7),e.svg.appendChild(s),r.setAttribute("x1",a+7),r.setAttribute("y1",l-7),r.setAttribute("x2",a-7),r.setAttribute("y2",l+7),e.svg.appendChild(r);break;case"Line":t.setAttribute("x1",e.lineStartPoint.x),t.setAttribute("y1",e.lineStartPoint.y),t.setAttribute("x2",e.lineEndPoint.x),t.setAttribute("y2",e.lineEndPoint.y),e.svg.appendChild(t);break;case"Panel":var c=e.clientPts,u=c[0].distanceTo(c[1]),g=c[0].distanceTo(c[3]),p=u/d.width,m=g/d.height;if(1!=p){var f=this.stretchOnDirection(c[0],c[1],d.width),w=this.stretchOnDirection(c[2],c[3],d.width);c=f.concat(w)}if(1!=m){f=this.stretchOnDirection(c[0],c[3],d.height),w=this.stretchOnDirection(c[1],c[2],d.height);c=[f[0],w[0],w[1],f[1]]}for(var y="",v=0;v<c.length;v++)y+=c[v].x+",",y+=c[v].y+" ";h.setAttribute("points",y),e.svg.appendChild(h)}}}),t.SnapItem=n}(),function(){var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Snap"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=null,o=[],s=null,r=null,a=function(t){var n=t.viewer,o=this;this.snapMode=t.snapMode,o.isOpen=!1,this._p1=new THREE.Vector3,this._p2=new THREE.Vector3;var s=new e.Web.Lang.EventManager,r=i.create("div","bf-snap-conext");this.context={rootDomElement:r},this._opt=t,this.getEventManager=function(){return s},P(this),o.init(t),n.addEventListener("Rendered",(function(){o.isOpen&&o.update()}))};a.prototype={init:function(t){var n=this,o=n.context,s=n._opt.viewer;n.isOpen=!0,s.getDomElement().appendChild(o.rootDomElement),s.getModels().forEach((e=>{e.setSelectedComponentsById()}));var r=i.createNS("svg","bf-snap-svg");o.rootDomElement.innerHTML="",o.rootDomElement.appendChild(r),o.svg=r;var a=new e.Bimface.Plugins.Snap.SnapItem(t);n.snapItem=a,s.render()},snapByPoint:function(e){if(!this.isNeedSnap(e))return;n=e.pickPoint?e.pickPoint:null;let t=this.snapMode?this.snapMode.getSnap3DList():["line","face","endpoint","midpoint","intersection"];e.pointType&&t.includes({EndPoint:"endpoint",MidPoint:"midpoint",IntersectionPoint:"intersection"}[e.pointType])?s=e.pointType:e.pickPlane&&t.includes("face")?(s="Panel",r=e.normal):e.pickLine&&t.includes("line")?(s="Line",o=e.pickLine):s=null,this.update()},isNeedSnap:function(e){if(!this.snapMode)return!0;let t=this.snapMode.getSnap3DList(),i="face",n="line",o="endpoint",s="midpoint",r="intersection",a=!1,l=!1,h=!1,d=!1;e.pointType&&(l=t.includes(o)||t.includes(s)||t.includes(r)),e.pickPlane&&(h=t.includes(i)),e.pickLine&&(d=t.includes(n)),a=l||h||d;let c=this.snapMode.getSnapCondition(),u=this._opt.viewer.getViewer().getUserdataByUserId(e.userId),g=this.isMatchConditions(u,c.objectData),p=!0;if("ViewerGIS"==this._opt.viewer.getViewerType())if(e.modelId){let t=this._opt.viewer.getModel(e.modelId)&&this._opt.viewer.getModel(e.modelId)._layer&&this._opt.viewer.getModel(e.modelId)._layer.id;c.layerIds&&c.layerIds.length>0&&t&&c.layerIds.indexOf(t)<0&&(p=!1)}else p=!1;let m=a&&g&&p&&!0;return m||this.reset(),m},isMatchConditions:function(e,t){if(!e||!t)return!0;for(var i=!0,n=0,o=t.length;n<o;n++){var s=t[n];for(var r in s)if(e[r]!==s[r]){i=!1;break}if(i)break;n<t.length-1&&(i=!0)}return i},update:function(){var e=this.context,t=this._opt.viewer,i=t.getDomElement(),a=i.getBoundingClientRect(),l=t.getViewer(),h=[],d=[];if(this.context.svg.innerHTML="",n?(e.pickPoint=n,e.hoverPosition=l.worldToCanvas(n),e.hoverPositionDS=l.getScene().worldToDrawing(n)):e.hoverPosition=null,e.hoverObjectType=s,"Line"==s&&2==o.length){e.lineStartPoint=l.worldToCanvas(o[0]),e.lineEndPoint=l.worldToCanvas(o[1]);var c=new THREE.Vector2(e.lineStartPoint.x,e.lineStartPoint.y),u=new THREE.Vector2(e.lineEndPoint.x,e.lineEndPoint.y),g=new THREE.Box2;g.min.set(i.clientLeft,i.clientTop),g.max.set(g.min.x+i.clientWidth,g.min.y+i.clientHeight);var p=!g.containsPoint(c),m=!g.containsPoint(u),f={start:c,end:u},w=y.CameraUtil.lineIntersectWithRect(f,g);if(p&&m)2==w.length&&(e.lineStartPoint=w[0],e.lineEndPoint=w[1]);else if(p||m)for(var v=new THREE.Vector2(e.hoverPosition.x,e.hoverPosition.y),b=p?u.clone():c.clone(),E=b.clone().sub(v).normalize(),M=0;M<w.length;M++){if(b.clone().sub(w[M]).normalize().dot(E)>0){e.lineStartPoint=b,e.lineEndPoint=w[M];break}}}if("Panel"==e.hoverObjectType){e.normal=l.getScene().worldToDrawing(r),e.normal.normalize();var C=l.cameraControl,x=new THREE.Plane;x.setFromNormalAndCoplanarPoint(e.normal,e.hoverPositionDS);var T=new THREE.Vector2(e.hoverPosition.x-10,e.hoverPosition.y-10),P=new THREE.Vector2(e.hoverPosition.x+10,e.hoverPosition.y-10),I=e.hoverPositionDS,S=this._opt.viewer.getRaycaster(T.x,T.y);if(this._p1=S.ray.intersectPlane(x,this._p1),S=this._opt.viewer.getRaycaster(P.x,P.y),this._p2=S.ray.intersectPlane(x,this._p2),null==this._p1||null==this._p2)return this._p1=new THREE.Vector3,void(this._p2=new THREE.Vector3);var B=new THREE.Vector3(1,0,0),_=new THREE.Vector3(0,1,0),L=new THREE.Vector3(0,0,1);let t=y.GIS.Transforms.eastNorthUpToFixedFrame(e.hoverPositionDS).clone();B.applyMatrix4(t).normalize(),_.applyMatrix4(t).normalize(),L.applyMatrix4(t).normalize();var D=_.clone().cross(e.normal).normalize(),A=e.normal.clone().cross(D).normalize(),V=this._p1.distanceTo(this._p2)/2,R=D.clone().multiplyScalar(V),O=A.clone().multiplyScalar(V),k=I.clone().sub(R).add(O),H=I.clone().add(R).add(O),U=I.clone().sub(R).sub(O),N=I.clone().add(R).sub(O),G=[];G.push(k,H,N,U);for(var j=[],z=C.getContainerDimensions(),F=0;F<G.length;F++){var W=y.CameraUtil.drawingToCanvas(C.camera,G[F],z.width,z.height);j.push(new THREE.Vector3(W.x,W.y,0))}e.clientPts=j}for(M=0;M<h.length-1;M++){var $=l.worldPointsToClient(h[M],h[M+1]);if($){var X={x:$.start.x-a.left,y:$.start.y-a.top};d.push(X)}}e.clientPoints=d,this.snapItem.draw(e)},reset:function(){s=null,this.context.svg.innerHTML=""},destroy:function(){var e=this.context.rootDomElement,t=this;t.reset(),e.remove(),t.snapItem=null,t.isOpen=!1}},t.Snap=a}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins").NorthArrowConfig=function(){return{domElement:null,viewer:null,right:10,top:10}};class Ur{constructor(e,t,i){this.element=e,this.northArrowElement=t,this.textElement=e.lastElementChild,this._camera=i,this._rotate=0,this._minRadius=4,this._maxRadius=48,this.init()}init(){let e,t,i,n,o;this.isDragging=!1,this.events={mouseout:()=>{this.isDragging||this.element.firstElementChild.setAttribute("filter","")},mousedown:i=>{this.isDragging=!0,e=i.offsetX-50,t=i.offsetY-60,o=this._camera.getYawPitch().pitch,this.element.setAttribute("class","bf-northarrow-yawactive")},mouseover:function(){this.firstElementChild.setAttribute("filter","url(#bf-northarrow-dropshadow)")}};for(let e in this.events)this.element.addEventListener(e,this.events[e].bind(this.element));const s=()=>{this.isDragging=!1,this.element.firstElementChild.setAttribute("filter",""),this.element.setAttribute("class","bf-northarrow-yaw")},r=(i,n)=>{let s=i-e,r=n-t,a=Math.atan(n/i),l=Math.atan(t/e),h=180*Math.abs(a-l)/Math.PI;i>0&&i>Math.abs(n)&&e>0&&e>Math.abs(t)?r>0?this._rotate+=h:this._rotate-=h:i<0&&i<-Math.abs(n)&&e<0&&e<-Math.abs(t)?r>0?this._rotate-=h:this._rotate+=h:(a=Math.atan(i/n),l=Math.atan(e/t),h=180*Math.abs(a-l)/Math.PI,n>0&&t>0?s>0?this._rotate-=h:this._rotate+=h:s>0?this._rotate+=h:this._rotate-=h),this._rotate>360&&(this._rotate=this._rotate-360),this.element.setAttribute("transform",`rotate(${this._rotate}, 0, 0)`);let d=(360-this._rotate)*Math.PI/180;this._camera.setYawPitch({yaw:d,pitch:o},!0),e=i,t=n};this.northArrowEvents={mousemove:e=>{this.isDragging&&(i=e.offsetX-50,n=e.offsetY-60,r(i,n))},mouseup:e=>{this.isDragging&&s()}};for(let e in this.northArrowEvents)this.northArrowElement.addEventListener(e,this.northArrowEvents[e]);this.northArrowParentEvents={mousemove:e=>{this.isDragging&&(i=e.offsetX-50-this.northArrowElement.offsetLeft,n=e.offsetY-60-this.northArrowElement.offsetTop,r(i,n))},mouseup:e=>{this.isDragging&&s()}};for(let e in this.northArrowParentEvents)this.northArrowElement.parentElement.addEventListener(e,this.northArrowParentEvents[e]);this.textEvents={dblclick:e=>{o=this._camera.getYawPitch().pitch,this._camera.setYawPitch({yaw:0,pitch:o},!1)}};for(let e in this.textEvents)this.textElement.addEventListener(e,this.textEvents[e])}update(){if(this.isDragging)return;let{yaw:e}=this._camera.getYawPitch();this._rotate=180*e/Math.PI,this._rotate=360-this._rotate,this.element.setAttribute("transform",`rotate(${this._rotate}, 0, 0)`)}destroy(){if(this.events)for(let e in this.events)this.element.removeEventListener(e,this.events[e]);if(this.northArrowEvents)for(let e in this.northArrowEvents)this.northArrowElement.removeEventListener(e,this.northArrowEvents[e]);if(this.northArrowParentEvents)for(let e in this.northArrowParentEvents)this.northArrowElement.parentElement.removeEventListener(e,this.northArrowParentEvents[e]);if(this.textEvents)for(let e in this.textEvents)this.textElement.removeEventListener(e,this.textEvents[e])}}class Nr{constructor(e,t){this.elements=e,this._camera=t,this.minPitch=-Math.PI/2,this.maxPitch=Math.PI/2,this.init()}init(){const e=this._camera;let t,i,n=this,o=!1;this.events={mousedown:function(){o=!0;let s=e.getYawPitch();i=s.yaw,t=s.pitch;let r=Math.PI/1200;const a=()=>{if(t=-t,t>n.maxPitch&&(t=n.maxPitch),t<n.minPitch&&(t=n.minPitch),t>n.minPitch&&t-r>n.minPitch&&"bf-northarrow-pitchdown"===this.className.baseVal)t-=r;else{if(!(t<n.maxPitch&&t+r<n.maxPitch&&"bf-northarrow-pitchup"===this.className.baseVal))return;t+=r}t=-t,e.setYawPitch({yaw:i,pitch:t},!0),o&&requestAnimationFrame(a)};a()},mouseup:()=>{o=!1},mouseover:function(){this.firstElementChild.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.firstElementChild.setAttribute("filter",""),o=!1},dblclick:function(){if("bf-northarrow-pitchup"===this.className.baseVal){let o=e.getYawPitch();i=o.yaw,t=o.pitch;let s=Math.PI/200;const r=()=>{t=-t,t>n.maxPitch&&(t=n.maxPitch),t<n.minPitch&&(t=n.minPitch),t<n.maxPitch&&t+s<n.maxPitch&&(t+=s,t=-t,e.setYawPitch({yaw:i,pitch:t},!0),requestAnimationFrame(r))};r()}}};for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}class Gr{constructor(e,t){this.elements=e,this._camera=t,this.init()}init(){const e=this._camera;let t=!1;this.events={mousedown:function(){t=!0;const i=()=>{switch(/bf-northarrow-pan(.*)/.exec(this.className.baseVal)[1]){case"up":e.panInUpAndDown(!0);break;case"down":e.panInUpAndDown(!1);break;case"left":e.panInHorizontal(!0);break;case"right":e.panInHorizontal(!1)}t&&requestAnimationFrame(i)};i()},mouseup:()=>{t=!1},mouseover:function(){this.setAttribute("filter","url(#bf-northarrow-dropshadow)")},mouseout:function(){this.setAttribute("filter",""),t=!1}};for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}class jr{constructor(e,t){this.elements=e,this._camera=t,this.init()}init(){const e=this._camera;let t=!1,i=null,n=!1;this.events={mousedown:function(){t=!0,i=(new Date).getTime(),n=!0;const o=()=>{((new Date).getTime()-i>500||n)&&("bf-northarrow-zoomin"===this.className.baseVal?e.zoomIn():e.zoomOut()),t&&requestAnimationFrame(o),n=!1};o()},mouseup:()=>{t=!1}},this.events.mouseout=this.events.mouseup;for(let e in this.events)for(let t in this.elements)this.elements[t].addEventListener(e,this.events[e].bind(this.elements[t]))}destroy(){for(let e in this.events)for(let t in this.elements)this.elements[t].removeEventListener(e,this.events[e])}}!function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.NorthArrow=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-northarrow");n.style.top=`${e.top}px`,n.style.right=`${e.right}px`,t.appendChild(n),this.domElement=n,this._camera=e.viewer._camera,this.init(),P(this)}init(){this.drawElements((()=>{this.addDomElementEvents(),this.northArrowYaw=new Ur(this.elements.yaw,this.domElement,this._camera),this.northArrowPitch=new Nr({pitchUp:this.elements.pitchUp,pitchDown:this.elements.pitchDown},this._camera),this.northArrowZoom=new jr({zoomIn:this.elements.zoomIn,zoomOut:this.elements.zoomOut},this._camera),this.northArrowPan=new Gr({panUp:this.elements.panUp,panDown:this.elements.panDown,panLeft:this.elements.panLeft,panRight:this.elements.panRight},this._camera),this.addRenderCallback()}))}drawElements(e){this.domElement.innerHTML='\n <svg height="180" width="100" class="bf-northarrow-svg" onselectstart="return false;">\n <defs>\n <filter id="bf-northarrow-dropshadow" x="-10" y="-10" width="100" height="100">\n <feDropShadow dx="0" dy="0" stdDeviation="0" \n flood-color="cyan"/>\n </filter>\n </defs>\n \n <g class="bf-northarrow-pitchup" transform="translate(50, 12)" width="500" height="100">\n <path d="M-15,0 A50,50 0 0,1 15,0 A3,3 0 0,1 14.5,8 A42,42 0 0,0 -14.5,8 A3,3 0 0,1 -15,0 Z" shape-rendering="geometricPrecision" />\n <path d="M-4,3 L0,-1 4,3" shape-rendering="geometricPrecision" />\n </g>\n\n <g transform="translate(50, 60)">\n <g class="bf-northarrow-yaw">\n <path d="M39,0 A39,39 0 0,0 -39,0 L-29,0 A29,29 0 0,1 29,0 L39,0 A39,39 0 0,1 0,39 L0,29 A29,29 0 0,0 29,0 L39,0 M-39,0 A39,39 0 0,0 0,39 L0,29 A29,29 0 0,1 -29,0 L-39,0 Z" shape-rendering="geometricPrecision" />\n <g transform="translate(-40, -40)">\n <path />\n <path d="M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z M40,1 C18.4608948,1 1,18.4608948 1,40 C1,61.5391052 18.4608948,79 40,79 C61.5391052,79 79,61.5391052 79,40 C79,18.4608948 61.5391052,1 40,1 Z" shape-rendering="geometricPrecision" />\n <path d="M40,11 C56.0162577,11 69,23.9837423 69,40 C69,56.0162577 56.0162577,69 40,69 C23.9837423,69 11,56.0162577 11,40 C11,23.9837423 23.9837423,11 40,11 Z M40,12 C24.536027,12 12,24.536027 12,40 C12,55.463973 24.536027,68 40,68 C55.463973,68 68,55.463973 68,40 C68,24.536027 55.463973,12 40,12 Z" shape-rendering="geometricPrecision" />\n <rect x="1" y="40" width="10" height="1" />\n <rect x="69" y="40" width="10" height="1" />\n <rect x="39" y="69" width="1" height="10" />\n <path />\n </g>\n <text x="0" y="-30">N</text>\n </g>\n </g>\n\n <g class="bf-northarrow-pitchdown" transform="translate(50, 108)">\n <path d="M-15,0 A50,50 0 0,0 15,0 A3,3 0 0,0 14.5,-8 A42,42 0 0,1 -14.5,-8 A3,3 0 0,0 -15,0 Z" shape-rendering="geometricPrecision" />\n <path d="M-4,-3 L0,1 4,-3" shape-rendering="geometricPrecision" />\n </g>\n\n <g transform="translate(50, 60)">\n <g class="bf-northarrow-panup" transform="translate(-7, -24)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-pandown" transform="translate(-7, 14) rotate(180, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-panleft" transform="translate(-24, -5) rotate(-90, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n <g class="bf-northarrow-panright" transform="translate(10, -5) rotate(90, 7 5)">\n <path d="M7,0 L14,10 0,10 Z" />\n <path d="M7,0 L14,10 L0,10 L7,0 Z M7,1.745 L1.921,9 L12.078,9 L7,1.745 Z" />\n </g>\n\n </g>\n\n <g transform="translate(50, 118)">\n <g transform="translate(-13, 0)">\n <rect id="Rectangle" fill="#2A313B" opacity="0.78" x="0" y="0" width="26" height="53" />\n <path d="M26,0 L26,53 L0,53 L0,0 L26,0 Z M25,1 L1,1 L1,52 L25,52 L25,1 Z" fill="#969FAE" fill-rule="nonzero" />\n <rect fill="#969FAE" x="3" y="26" width="20" height="1" />\n </g>\n <g class="bf-northarrow-zoomin">\n <path d="M-13,0 L13,0 13,26 -13,26 Z" />\n <polygon points="5 5 5 0 7 0 7 5 12 5 12 7 7 7 7 12 5 12 5 7 0 7 0 5" transform="translate(-6, 7)" />\n </g>\n <g class="bf-northarrow-zoomout">\n <path d="M-13,26 L13,26 13,52 -13,52 Z" />\n <rect x="0" y="0" width="12" height="2" transform="translate(-6, 39)" />\n </g>\n </g>\n </svg>\n ',this.elements={},["pitchUp","pitchDown","yaw","panUp","panDown","panLeft","panRight","zoomIn","zoomOut"].forEach((e=>{const t=this.domElement.querySelector(`.bf-northarrow-${e.toLowerCase()}`);this.elements[e]=t})),e()}addDomElementEvents(){this.domElementEvents={mouseover:()=>{this.elements.pitchUp.style.opacity=1,this.elements.pitchDown.style.opacity=1},mouseout:()=>{this.elements.pitchUp.style.opacity=0,this.elements.pitchDown.style.opacity=0},mousedown:e=>(e.stopPropagation(),!1)},this.domElementEvents.mousemove=this.domElementEvents.mouseup=this.domElementEvents.mousedown,this.domElementEvents.mouseout();for(let e in this.domElementEvents)this.domElement.addEventListener(e,this.domElementEvents[e])}addRenderCallback(){this.renderCallback=()=>{this.northArrowYaw&&this.northArrowYaw.update()},this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){if(this.domElement&&this.domElementEvents)for(let e in this.domElementEvents)this.domElement.removeEventListener(e,this.domElementEvents[e]);this.northArrowYaw&&this.northArrowYaw.destroy(),this.northArrowPitch&&this.northArrowPitch.destroy(),this.northArrowPan&&this.northArrowPan.destroy(),this.northArrowZoom&&this.northArrowZoom.destroy(),this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}setLimitPitch(e=null,t=null){this.northArrowPitch.minPitch=null!=e?e:-Math.PI/2,this.northArrowPitch.maxPitch=null!=t?t:Math.PI/2}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins").ScaleBarConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom"),n=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7];t.ScaleBar=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-scale");n.style.bottom=`${e.bottom}px`,n.style.right=`${e.right}px`,t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,this.lastUpdateTime=Date.now(),this.enableScale=!0,this._value=void 0,P(this),this.init()}init(){this.drawElements((()=>{this.addRenderCallback()}))}drawElements(e){this.domElement.innerHTML='\n <svg height="36px" width="140px" class="bf-scale-svg" onselectstart="return false;">\n <rect x="0" y="0" width="140px" height="36px" style="fill:#20262F;opacity:0.85;stroke-width:1px;stroke:#3B4554"/>\n <path class="bf-scale-bar" fill="none"/>\n <text class= "bf-scale-label" fill="#cccccc"></text>\n </svg>\n ',this.barElement=this.domElement.querySelector(".bf-scale-bar"),this.labelElement=this.domElement.querySelector(".bf-scale-label"),this.domElement.style.display="none",e()}addRenderCallback(){let e=()=>{if(this.enableScale&&!this._opt.viewer._isDestroyed){var e=this._opt.viewer.getViewer().camera,t=this._opt.viewer.getViewer().getViewportSize();if(e.position.y<0)this.domElement.style.display="none";else{var i=new THREE.Vector3(t.width/2,t.height-1),o=new THREE.Vector3(t.width/2+1,t.height-1),s=this._opt.viewer.getViewer().pickByPoint(i,!0,!1),r=this._opt.viewer.getViewer().pickByPoint(o,!0,!1);if(s&&r&&s.worldPosition&&r.worldPosition){var a=s.worldPosition.distanceTo(r.worldPosition);if(this._pixelDistance=a,a<0)this.domElement.style.display="none";else{for(var l,h=n.length-1;!l&&h>=0;--h)n[h]/a<=120&&(l=n[h]);if(l){var d;this._value=l,d=l>=1e3?(l/1e3).toString()+"km":l.toString()+"m",this.labelElement.textContent=d;var c=this.labelElement.getBoundingClientRect().width||43;this.labelElement.setAttribute("x",70-c/2),this.labelElement.setAttribute("y",23);var u=l/a,g="M"+(70-u/2).toString()+" 20 L"+(70-u/2).toString()+" 28 L"+(70+u/2).toString()+" 28 L"+(70+u/2).toString()+" 20";this.barElement.setAttribute("d",g),this.domElement.style.display="block"}else this._value=void 0,this._pixelDistance=void 0,this.domElement.style.display="none"}}else this.domElement.style.display="none"}}},t=null,i=null;this.renderCallback=()=>{i||(i=setTimeout((()=>{e(),i=null}),250)),t&&(clearTimeout(t),t=null),t=setTimeout((()=>{clearTimeout(i),i=null,e()}),250)},this._opt.viewer.getViewer().addRenderCallback(this.renderCallback)}destroy(){this.renderCallback&&this._opt.viewer.getViewer().removeRenderCallback(this.renderCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enableScale=!0}hide(){this.domElement.style.display="none",this.enableScale=!1}isVisible(){return this.enableScale}getValue(){return this._pixelDistance}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins").InfoBarConfig=function(){return{domElement:null,viewer:null,right:0,bottom:0}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.InfoBar=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div","bf-infobar");n.style.bottom=`${e.bottom}px`,n.style.right=`${e.right}px`,n.style.display="none",t.appendChild(n),this.domElement=n,this.enable=!0,this._info={},this._inited=!1,this.isMouseClicked=!1,P(this),this._mousemoveCallback=e=>{if(!this.enable)return;if(this.isMouseClicked)return;let t=this._opt.viewer.getViewer().pickByPoint(e,!1,!1);if(!t)return;let i=t.worldPosition,{lat:n,lon:o,alt:s}=this._opt.viewer.worldToLatLon(i);this._info={latitude:n,longtitude:o,altitude:s};let r=`${n.toFixed(6)}${n>=0?"N":"S"}&nbsp;&nbsp;${o.toFixed(6)}${o>=0?"E":"W"}&nbsp;&nbsp;${"-0.000"===s.toFixed(3)?"0.000":s.toFixed(3)}m`;this.domElement.innerHTML=r,this._inited||(this.domElement.style.display="block",this._inited=!0)},this._mousedownCallback=()=>{this.isMouseClicked=!0},this._mouseupCallback=()=>{this.isMouseClicked=!1},this.init()}init(){this._opt.domElement.addEventListener("mousedown",this._mousedownCallback),this._opt.domElement.addEventListener("mouseup",this._mouseupCallback),this._opt.domElement.addEventListener("mousemove",this._mousemoveCallback)}destroy(){this._opt.domElement.removeEventListener("mousemove",this._mousemoveCallback),this._opt.domElement.removeEventListener("mousedown",this._mousedownCallback),this._opt.domElement.removeEventListener("mouseup",this._mouseupCallback),this._opt.domElement.removeChild(this.domElement)}show(){this.domElement.style.display="block",this.enable=!0}hide(){this.domElement.style.display="none",this.enable=!1}isVisible(){return this.enable}getValue(){return this._info}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins").CreditConfig=function(){return{domElement:null,viewer:null,right:10,bottom:10}},function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins"),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Web.Lang.Utility.Dom");t.Credit=class{constructor(e){this._opt=e;const t=e.domElement,n=i.create("div",`bf-credit ${e.class||""}`);t.appendChild(n),this.domElement=n,this.barElement=void 0,this.labelElement=void 0,P(this)}drawElements(){const{credit:t,text:i,link:n,copyright:o}=this._opt;if(t===e.Bimface.Common.Credit.None)this.domElement.innerHTML="";else this.domElement.innerHTML=`\n <div class='copyright'>${o}\n <div class='divider'></div>\n <a class='text' href='${n}' target='_blank'>${i}</a> \n </div>\n `}destroy(){this._opt.domElement.removeChild(this.domElement)}update(e){this._opt=Object.assign({},this._opt,e),this.drawElements()}show(){this.domElement.style.display="block"}hide(){this.domElement.style.display="none"}}}(),e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.SkyBox").SkyBoxStyle=Object.freeze({BlueSky:"BlueSky",CloudySky:"CloudySky",DarkNight:"DarkNight",Galaxy:"Galaxy",Cosmos:"Cosmos",Customized:"Customized"}),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.SkyBox");t.SkyBoxManagerConfig=class{constructor(){this.customizedImage=null,this.style=null,this.viewer=null,this.initializeVisible=!0}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.SkyBox");i.SkyBoxManager=class{constructor(e){t.send("Bimface.Earth.Plugins.SkyBox.SkyBoxManager","bf_c_skyBoxMng_new"),this._customizedImage=e.customizedImage,this._style=e.style,this._viewer=e.viewer,this._enabled=!1,P(this),this.enableSkyBox(e.initializeVisible)}setCustomizedImage(e){this._customizedImage!=e&&(this._customizedImage=e,this._updateSkyBox())}getCustomizedImage(){return this._customizedImage}setStyle(e){this._style!=e&&(this._style=e,this._updateSkyBox())}getStyle(){return this._style}enableSkyBox(e){if(this._enabled!=e){if(this._enabled=e,!this._enabled)this._viewer.getViewer().IBLManager.removeSkyBox();this._updateSkyBox()}}getSenceType(){return e.Bimface.Common.Type.EffectType.SkyBoxManager}show(){this.enableSkyBox(!0)}hide(){this.enableSkyBox(!1)}destroy(){this.enableSkyBox(!1),this._customizedImage=null,this._style=null,this._viewer=null}getParams(){return{customizedImage:this._customizedImage,style:this._style}}_updateSkyBox(){if(this._enabled){var t=this._viewer.getViewer().IBLManager,i=this._style,n=this._viewer._data,o=[];if(this._style==e.Bimface.Earth.Plugins.SkyBox.SkyBoxStyle.Customized&&this._customizedImage?(o.push(this._customizedImage.right),o.push(this._customizedImage.left),o.push(this._customizedImage.top),o.push(this._customizedImage.bottom),o.push(this._customizedImage.front),o.push(this._customizedImage.back)):i=this._style==e.Bimface.Earth.Plugins.SkyBox.SkyBoxStyle.Customized?e.Bimface.Earth.Plugins.SkyBox.SkyBoxStyle.CloudySky:this._style,0==o.length&&i){var s=(n.dataEnvType==_.Local?n.sdkPath:g.staticHost)+"/resources/SkyBox/Pics/"+i;const e=["posx.jpg","negx.jpg","posy.jpg","negy.jpg","posz.jpg","negz.jpg"];for(var r=0;r<6;++r)o.push(s+"/EnvMap_"+e[r])}t.loadSkyBox(o,!1),t.setSkyBoxType(i)}}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance(),i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Geometry");class n extends CLOUD.MeshLine{constructor(i,n,o,s,r,a){super(),t.send("Bimface.Earth.Plugins.Geometry.SplineCurve","bf_c_geometry_newSpline");let l={};if(i instanceof Array?(l.points=i,l.color=o,l.width=s,l.style=r,l.type=a,l.viewer=n):l=i,this.viewer=l.viewer,this.viewer)if(null==i||i&&i.length<2)console.log("ERROR::points must be not empty or only one");else{P(this);for(let e=0;e<l.points.length;e++)l.points[e]=this.viewer.latLonToWorld(l.points[e]);this.viewer=l.viewer,this.points=void 0!==l.points?l.points:[],this.color=void 0!==l.color?l.color:new e.Web.Graphics.Color("#32D3A6"),this.width=void 0!==l.width?l.width:1,this.style=void 0!==l.style?l.style:{lineType:"Continuous",lineStyle:null},this.curveType=void 0!==l.type?l.type:"spline",this.divisions=100,this._clampMode="Space",this.curve=null,this.createCurve(),this.createGroundCurve({points:this.points,color:this.color,width:this.width,style:this.style,type:this.curveType,divisions:this.divisions}),this.groundCurve.visible=!1,this.groundCurveVisible=this.groundCurve.visible,this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1],this.material.linewidth=this.width,this.material.resolution=new THREE.Vector2(window.innerWidth,window.innerHeight),this.setColor(this.color),this.setStyle(this.style),this.highlightColor="#FF7F00",this.addEventListener("removed",(function(){this.groundCurve.onRemoved()})),this.addEventListener("added",(function(){this.groundCurve.onAdded()})),this._widthType="DisplayWidth",this._adjustGlobalUnit=!1,this.mapOption=void 0,this._adjustEarthGlobe=!1,this.disPickable=!0}}createCurve(){for(var e=this.points,t=[],i=0,n=e.length;i<n;i++)t.push(new THREE.Vector3(e[i].x,e[i].y,e[i].z));this.curve=new THREE.CatmullRomCurve3(t),this.curve.tension=0,this.curve.curveType="polyline"==this.curveType?"catmullrom":"centripetal",this.length=this.curve.getLength();var o=Math.ceil(this.length/1e3);this.divisions=o<this.divisions?this.divisions:o;var s=[];if("polyline"===this.curveType)s=this.getPolylinePositions();else{i=0;for(var r=this.divisions;i<=r;i++){var a=this.curve.getPointAt(i/r);s.push(a.x,a.y,a.z)}}const l=(new THREE.Box3).setFromArray(s).getCenter(new THREE.Vector3);var h=[];for(i=0;i<s.length;i+=3)h.push(s[i]-l.x,s[i+1]-l.y,s[i+2]-l.z);this.position.copy(l),this.geometry.setPositions(h),this.material.totalSize=this.geometry.totalSize,this.curvePositions=s}_rebuild(e){if(this._adjustGlobalUnit)return this;this.viewer||(this.viewer=e),this.points=this.viewer.globalUnitUtil.translate(this.points,["x","y","z"]);let t={};return this.style&&"Continuous"==this.style.lineType&&(t.lineType="Continuous",t.lineStyle=null),this.style&&"Dashed"==this.style.lineType&&(t.lineType="Dashed",t.lineStyle={},t.lineStyle.dashLength=this.viewer.globalUnitUtil.translate(this.style.lineStyle.dashLength),t.lineStyle.gapLength=this.viewer.globalUnitUtil.translate(this.style.lineStyle.gapLength)),this.createCurve(),this.createGroundCurve({points:this.points,color:this.color,width:this.width,style:this.style,type:this.curveType,divisions:this.divisions}),this.groundCurve.visible=this.groundCurveVisible,this.startPoint=this.points[0],this.endPoint=this.points[this.points.length-1],this.material.linewidth=this.width,this.material.resolution=new THREE.Vector2(window.innerWidth,window.innerHeight),this.setColor(this.color),this.setStyle(t),this._isStretch&&this.stretch(this.intensty,this.parameter),this._adjustGlobalUnit=!0,this}clone(){var t=this.points.copyWithin(0),i=new e.Web.Graphics.Color(this.color.red,this.color.green,this.color.blue,this.color.alpha),n=this.width,o="Continuous"==this.style.lineType?{lineType:this.style.lineType,lineStyle:this.lineStyle}:{lineType:this.style.lineType,lineStyle:{dashLength:this.style.lineStyle.dashLength,gapLength:this.style.lineStyle.gapLength}},s=new this.constructor(t,i,n,o);return this.material&&(s.material=this.material.clone()),s}dispose(){this.geometry.dispose(),this.material.dispose(),this.points=[],this.curve=null,this.geometry=null,this.material=null,this.color=null,this.width=null,this.style=null,this.startPoint=null,this.endPoint=null,this.groundCurve.dispose()}getPointByLength(e){if(e<0||e>this.length||!this.curve)return null;var t=e/this.length,i=this.curve.getPointAt(t);return this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate({x:i.x,y:i.y,z:i.z},["x","y","z"]):{x:i.x,y:i.y,z:i.z}}getPointByParameter(e){if(e<0||e>1||!this.curve)return null;var t=this.curve.getPointAt(e);return this._adjustGlobalUnit?this.viewer.globalUnitUtil.revertTranslate({x:t.x,y:t.y,z:t.z},["x","y","z"]):{x:t.x,y:t.y,z:t.z}}getTangentByLength(e){if(e<0||e>this.length||!this.curve)return null;var t=e/this.length,i=this.curve.getTangentAt(t);return{x:i.x,y:i.y,z:i.z}}getTangentByParameter(e){if(length<0||length>1||!this.curve)return null;var t=this.curve.getTangentAt(e);return{x:t.x,y:t.y,z:t.z}}setColor(t){!t instanceof e.Web.Graphics.Color?console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color"):(this.color=t,this.material.color.setRGB(t.red/255,t.green/255,t.blue/255),this.material.opacity=t.alpha,t.alpha<1||this.material.map?this.material.transparent=!0:this.material.transparent=!1,this.renderOrder=CLOUD.GlobalData.IncrementRender?100:-1,this.groundCurve.setColor(t))}getColor(){return this.color}setWidth(e){this.width=e,this.material.linewidth=e,this.groundCurve.setWidth(e)}getWidth(){return this.width}setStyle(e){if(this.style=e,"Continuous"==e.lineType)this.material.dashArray=0,this.material.dashRatio=0;else{var t=e.lineStyle.dashLength,i=e.lineStyle.gapLength;this.material.dashArray=(t+i)/this.material.totalSize,this.material.dashRatio=t/(t+i)}this.material.needsUpdate=!0,this.groundCurve.setStyle(e)}getStyle(){return this.style}setType(e){if(this.curveType==e||"polyline"!=e&&"spline"!=e)return;this.curveType=e,this.curve.curveType="polyline"==e?"catmullrom":"centripetal",this.length=this.curve.getLength();var t=this.divisions,i=[];if("polyline"===e)i=this.getPolylinePositions();else for(var n=0,o=t;n<=o;n++){var s=this.curve.getPointAt(n/o);i.push(s.x,s.y,s.z)}const r=(new THREE.Box3).setFromArray(i).getCenter(new THREE.Vector3);var a=[];for(n=0;n<i.length;n+=3)a.push(i[n]-r.x,i[n+1]-r.y,i[n+2]-r.z);this.position.copy(r),this.geometry.setPositions(a),this.curvePositions=i,this.groundCurve.setType(e)}getType(){return this.curveType}getPoints(){let e=this.points,t=[];return e.map((e=>t.push(this.viewer.worldToLatLon(e)))),t}setPoints(e){if(e.length<2)return;let t=[];e.map((e=>t.push(this.viewer.latLonToWorld(e)))),this.points=t;let i=[];for(let t=0,n=e.length;t<n;t++)i.push(new THREE.Vector3(e[t].x,e[t].y,e[t].z));this.curve.points=i,this.length=this.curve.getLength();const n=Math.ceil(this.length/1e3);this.divisions=n<this.divisions?this.divisions:n;let o=[];for(let e=0,t=this.divisions;e<=t;e++){const i=this.curve.getPointAt(e/t);o.push(i.x,i.y,i.z)}const s=(new THREE.Box3).setFromArray(o).getCenter(new THREE.Vector3);for(var r=[],a=0;a<o.length;a+=3)r.push(o[a]-s.x,o[a+1]-s.y,o[a+2]-s.z);this.position.copy(s),this.geometry.setPositions(r),this.material.totalSize=this.geometry.totalSize,this.curvePositions=o,this.groundCurve.geometry.updateGeometry({points:e})}projectToGround(e){this.visible=!e,this.groundCurve.visible=e,this.groundCurveVisible=e,e?(this._clampMode="Both",this._updateClampMode(0)):this._clampMode="Space"}clampMode(e){if(!e)return;var t=CLOUD.Utils.isDefined(e.mode)?e.mode:"Space",i="Space"!=t;switch(this.visible=!i,this.groundCurve.visible=i,this.groundCurveVisible=i,this._clampMode=t,this._clampMode){case"Both":this._updateClampMode(0);break;case"Ground":this._updateClampMode(1);break;case"Model":this._updateClampMode(2)}const n=e.layerIds;this._setVisibleLayerIds(n)}_setVisibleLayerIds(e){let t={};if(!(e instanceof Array)||0===e.length)return void CLOUD.GroundPrimitiveManager.getInstance().setInVisibleModelIdMapAboutGroundCurve(null);if(!this.viewer||"ViewerGIS"!==this.viewer.viewerType)return console.warn("option.layerIds only support ViewerGIS"),t={all:!1},void CLOUD.GroundPrimitiveManager.getInstance().setInVisibleModelIdMapAboutGroundCurve(null);this.viewer.getLayerManager().query(".BIMLayer .FeatureLayer .TilesetLayer").forEach((i=>{if(e.indexOf(i.id)>-1)return;const n=i.getModelId();t[n]=!0})),this.groundCurve.inVisibleModelIdMap=t}_updateClampMode(e){this.groundCurve.setClampMode(e)}setMap(e,t){if(e.src){var i=null==e.offset?[0,0]:[0,e.offset],n=null==e.scale?[1,1]:[1,e.scale];if(this.mapOption=e,this.src!=e.src){this.src=e.src;var o=new THREE.Texture,s=this;(new TEST.CryptoResourceLoader).loadURL(e.src,(r=>{var a=new Blob([r],{type:"jpeg"});let l=new Image;l.onload=function(){o.image=CLOUD.MaterialUtil.ensurePowerOfTwo(l),o.needsUpdate=!0,o.offset.fromArray(i),o.repeat.fromArray(n),o.wrapS=THREE.RepeatWrapping,o.wrapT=THREE.RepeatWrapping,s.material.enableColorOverride=null!=e.enableColorOverride&&e.enableColorOverride,s.material.transparent=!0,s.material.depthWrite=!1,s.material.map=o,s.material.needsUpdate=!0,s.groundCurve.setMap(o,s.material.enableColorOverride),t&&t(o)},l.onerror=e=>{console.log(e),onError&&onError(e)},l.src=URL.createObjectURL(a)}),null,(e=>{console.log(e),onError&&onError(e)}))}else{var r=this.material.map;r&&(r.offset.fromArray(i),r.repeat.fromArray(n),this.material.map=r,this.material.enableColorOverride=null!=e.enableColorOverride&&e.enableColorOverride,this.material.needsUpdate=!0,this.groundCurve.material.enableColorOverride=this.material.enableColorOverride,this.groundCurve.material.needsUpdate=!0,t&&t(r))}}}getMap(){return this.mapOption}stretch(e,t){function i(e,t,i,n){const o=i-e,s=n-t,r=o*o+s*s;return Math.sqrt(r)}this.intensty=e,this.parameter=t;const n=null==e?.5:e,o=null==t?.5:t,s=this.points;var r=[],a=0;for(let e=1;e<s.length;e++){let t=s[e-1],w=s[e];var l=t.x+(w.x-t.x)*o,h=t.y+(w.y-t.y)*o,d=i(t.x,t.y,w.x,w.y),c=t.z+d*n,u=new THREE.Vector3(l,h,c),g=new THREE.QuadraticBezierCurve3(t,u,w),p=10*Math.floor(Math.log(d)/Math.LN10)+10;a+=p;for(var m=0;m<p;m++){var f=m/p;r.push(g.getPointAt(f))}r.push(g.getPointAt(1))}this.curve=new THREE.CatmullRomCurve3(r),this.length=this.curve.getLength(),this.divisions=a;for(var w=[],y=0,v=a;y<v;y++){var b=this.curve.getPointAt(y/v);w.push(b.x,b.y,b.z)}const E=(new THREE.Box3).setFromArray(w).getCenter(new THREE.Vector3);var M=[];for(y=0;y<w.length;y+=3)M.push(w[y]-E.x,w[y+1]-E.y,w[y+2]-E.z);this.position.copy(E),this.geometry.setPositions(M),this.curvePositions=w,this._isStretch=!0}setEntityId(e,t){this.entityId=t,this.layerId=e}hightlight(){let t=new e.Web.Graphics.Color(this.highlightColor,1);this.material.color.setRGB(t.red/255,t.green/255,t.blue/255)}cancelHightlight(){this.material.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255)}setWidthType(e){this._widthType==e||"DisplayWidth"!=e&&"ActualWidth"!=e||(this._widthType=e,this.groundCurve.setWidthType(this._widthType),this.material.sizeAttenuation="DisplayWidth"!=e,this.material.needsUpdate=!0)}getWidthType(){return this._widthType}show(){"Space"===this._clampMode?this.visible=!0:(this.groundCurve.visible=!0,this.groundCurveVisible=!0)}hide(){"Space"===this._clampMode?this.visible=!1:(this.groundCurve.visible=!1,this.groundCurveVisible=!1)}getBox(){let e=this.geometry.boundingBox;return e||(this.geometry.computeBoundingBox(),e=this.geometry.boundingBox),e}getParams(){let e=this.points,t=this.style;return{points:e,color:this.color,width:this.width,style:t,type:this.curveType,widthType:this._widthType,url:this.src,enableColorOverride:this.material.enableColorOverride,intensty:this.intensty,parameter:this.parameter}}getPolylinePositions(){const e=[],t=this.length,i=this.divisions,n=new THREE.Vector3,o=new THREE.Vector3;for(let s=1;s<this.points.length;s++){n.set(this.points[s-1].x,this.points[s-1].y,this.points[s-1].z),o.set(this.points[s].x,this.points[s].y,this.points[s].z);const r=new THREE.CatmullRomCurve3([n,o]);r.tension=0,r.curveType="catmullrom";const a=r.getLength(),l=Math.ceil(i*a/t);for(let t=1===s?0:1;t<=l;t++){const i=r.getPoint(t/l);e.push(i.x,i.y,i.z)}}return e}}i.SplineCurve=n}(),function(){e.Bimface.Data.StatisticsDataManager.getInstance();var t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Geometry");class i extends THREE.Group{constructor(t){if(super(),this._adjustEarthGlobe=!1,!(t.points instanceof Array))return void console.log("Parameter points should be an array.");this.viewer=t.viewer,this.children=[],t.color instanceof e.Web.Graphics.Color?this.color=t.color:this.color=new e.Web.Graphics.Color(50,138,240,.5),t.borderColor instanceof e.Web.Graphics.Color?this.borderColor=t.borderColor:this.borderColor=new e.Web.Graphics.Color(50,138,240,.5);let i=[];t.points.map((e=>{i.push(t.viewer.latLonToWorld(e))})),this.points=i,this.useBorder=!0,this._createPlane()||(this.type="invalidPlane")}_createGeometry(e){const t=(new THREE.BufferGeometry).setFromPoints(e);let i=[];for(let t=2;t<e.length;t++)i.push(0,t-1,t);t.setIndex(i),t.computeVertexNormals();let n=[];return n.push(0,0),n.push(1,0),n.push(1,1),n.push(0,1),t.setAttribute("uv",new THREE.Float32BufferAttribute(n,2)),t}_createPlane(){if(this.points=this._formatPoints(this.points),this.points.length<3)return console.log("Creating a plane needs more 3 points."),!1;let e=this._createGeometry(this.points),t=new THREE.Mesh(e,this._createMeshMaterial());return t.updateMatrixWorld(!0),this.add(t),1==this.useBorder&&this.add(this._createBorderLine()),!0}_createMeshMaterial(){var e=this,t=new THREE.Color(e.color.red/255,e.color.green/255,e.color.blue/255),i=new CLOUD.CloudStandardMaterial({color:t,side:THREE.DoubleSide,depthWrite:!this.isEntityPlane});return i.opacity=e.color.alpha,i.transparent=e.color.alpha<1,i}_createLineMaterial(){var e=this,t=new THREE.Color(e.borderColor.red/255,e.borderColor.green/255,e.borderColor.blue/255),i=new THREE.LineMaterial({color:t,linewidth:2,dashed:!1,depthWrite:!this.isEntityPlane});return i.resolution.set(window.innerWidth,window.innerHeight),i.opacity=null==e.borderColor?1:e.borderColor.alpha,i.transparent=null!=e.borderColor&&e.borderColor.alpha<1,i}_createBorderLine(){var e=this,t=new THREE.LineGeometry;let i=[];for(var n=0;n<e.points.length;n++){var o=new THREE.Vector3(e.points[n].x,e.points[n].y,e.points[n].z);i.push(o.x),i.push(o.y),i.push(o.z)}i.push(e.points[0].x),i.push(e.points[0].y),i.push(e.points[0].z),t.setPositions(i);var s=e._createLineMaterial();let r=new THREE.Line2(t,s);return r.renderOrder=10,r}_formatPoints(e){let t=[];return e.forEach((e=>{t.push(new THREE.Vector3(e.x,e.y,e.z))})),t}setOpacity(e){if(void 0===e&&(e=1),"[object Number]"===Object.prototype.toString.call(e)){e>1&&(e=1),e<0&&(e=0);var t=this.children[0];null!=t&&(t.material.needsUpdate=!0,t.material.opacity=e,t.material.transparent=!!this.mapTransparent||!(Math.abs(e-1)<.001))}}setColor(t){if(t.color){let n=t.color;if(!(n instanceof e.Web.Graphics.Color))return void console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color");this.color=n;var i=this.children[0];null!=i&&(i.material.map=null,i.material.alphaMap=null,i.material.color.setRGB(this.color.red/255,this.color.green/255,this.color.blue/255),i.material.opacity=this.color.alpha,i.material.transparent=this.color.alpha<1,delete i.material.defines.USE_COLORWITHOUTLIGHT,i.material.needsUpdate=!0)}if(t.borderColor){let i=t.borderColor;if(!(i instanceof e.Web.Graphics.Color))return void console.log("ERROR: color is not instance of Glodon.Web.Graphics.Color");this.borderColor=i;var n=this.children[1];null!=n&&n.material.color.setRGB(this.borderColor.red/255,this.borderColor.green/255,this.borderColor.blue/255)}this.viewer.render()}getColor(){return{color:this.color,borderColor:this.borderColor}}clearBorder(){this.useBorder=!1;var e=this.children[1];this.remove(e),this.viewer.render()}clearPlane(){var e=this.children[0];this.remove(e),this.viewer.render()}dispose(){this.points=null,this.mapUrl=null,this.color=null,this.borderColor=null,this.useBorder=null;var e=this.children[0],t=this.children[1];e&&this.remove(e),t&&this.remove(t),this.viewer.render()}show(){this.children.forEach((e=>{e.material.visible=!0})),this.viewer.render()}hide(){this.children.forEach((e=>{e.material.visible=!1})),this.viewer.render()}setMap(e,t,i){if(4!=this.points.length)return void(t&&t(this.children[0]));this._opacity=i;let n=!0;void 0===n&&"[object Boolean]"===Object.prototype.toString.call(i)&&(n=i,i=void 0);const o=()=>{var n=this;n.mapUrl=e;var o=n.children[0];if(null!=o){var s=new THREE.TextureLoader;s.setCrossOrigin("anonymous"),s.load(n.mapUrl,(e=>{e.encoding=THREE.sRGBEncoding,o.material.map=e,!0===this.mapTransparent&&(o.material.alphaMap=e),this.setOpacity(i),o.material.needsUpdate=!0,t&&t(o)}))}};if(!1===n){let t=new Image;t.src=e,t.onload=()=>{const e=t.width,i=t.height,n=e/i,s=Math.abs(this.points[1].x-this.points[0].x),r=Math.abs(this.points[2].y-this.points[0].y),a=s/r;let l=0,h=0,d=0;this.points.forEach((e=>{l+=e.x,h+=e.y,d+=e.z})),l*=1/this.points.length,h*=1/this.points.length,d*=1/this.points.length;const c=new THREE.Vector3(l,h,d);if(n>a){const t=i*s/e/r;this.children.forEach((e=>{e.scale.setY(t),e.position.sub(c).multiply(new THREE.Vector3(1,t,1)).add(c),e.updateMatrixWorld()}))}else if(n<a){const t=e*r/i/s;this.children.forEach((e=>{e.scale.setX(t),e.position.sub(c).multiply(new THREE.Vector3(t,1,1)).add(c),e.updateMatrixWorld()}))}o()}}else o()}enableDepthTest(e){this.children.forEach((t=>{t.material.depthTest!==e&&(t.material.depthTest=e,t.material.needsUpdate=!0)})),this.viewer.render()}}t.Plane=i}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Clipping");t.ClippingConfig=class{constructor(){this.boundary=null,this.layerIds=void 0}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Clipping");i.Clipping=class{constructor(i){t.send("Bimface.Earth.Plugins.Clipping.Clipping","bf_c_clipping_new");const n=[];for(let e=0;e<i.boundary.length;++e)n.push(new THREE.Vector3(i.boundary[e].lon,i.boundary[e].lat,i.boundary[e].alt));this.boundaryLatlon=i.boundary,this.boundary=n,this.layerIds=i.layerIds,this.id=e.Web.Lang.Utility.UUID.createUUID(),P(this)}destroy(){this.boundary=null,this.layerIds=null,this.id=void 0}show(){this._clippingManager&&this.layerIds&&this.layerIds.length>0&&this._clippingManager._showHideItem(this.getId(),this.layerIds,!0),void 0===this.layerIds&&this._clippingManager&&this._clippingManager.showItems([this.getId()])}hide(){this._clippingManager&&this.layerIds&&this.layerIds.length>0&&this._clippingManager._showHideItem(this.getId(),this.layerIds,!1),void 0===this.layerIds&&this._clippingManager&&this._clippingManager.hideItems([this.getId()])}getId(){return this.id}getLayerIds(){if(this._clippingManager){"ViewerGIS"===this._clippingManager._viewer.getViewerType()||(this.layerIds=void 0)}return this.layerIds}setLayerIds(e){if(void 0===e)return;let t=this.layerIds;if(this.layerIds=e,this._clippingManager){if(!("ViewerGIS"===this._clippingManager._viewer.getViewerType()))return;if(0===e.length)throw this.layerIds=t,console.log("ERROR::clippingItem must contains layerIds."),new Error("ERROR::clippingItem must contains layerIds.");let i=this._clippingManager._viewer.getLayerManager(),n=[];for(let t=0;t<e.length;t++){let o=e[t],s=!1;for(let e=0;e<i.getRootLayer().children.length;e++){if("GroupLayer"==i.getRootLayer().children[e].typeName){for(let t=0;t<i.getRootLayer().children[e].children.length;t++)if(i.getRootLayer().children[e].children[t].id==o&&("TileLayer"==i.getRootLayer().children[e].children[t].typeName||"TilesetLayer"==i.getRootLayer().children[e].children[t].typeName)){s=!0;break}if(s)break}if(!s&&("TileLayer"==i.getRootLayer().children[e].typeName||"TilesetLayer"==i.getRootLayer().children[e].typeName)&&i.getRootLayer().children[e].id==o){s=!0;break}}s?n.push(o):console.warn(`The LayerId ${o} is invalid`)}n.length>0?(n=[...new Set(n)],this.layerIds=n,this._clippingManager._showHideClipping(this)):this.layerIds=t}}getBoundary(){return this.boundaryLatlon}getBoundaryVector(){return this.boundary}setBoundary(e){if(void 0===e)return;const t=[];for(let i=0;i<e.length;++i)t.push(new THREE.Vector3(e[i].lon,e[i].lat,e[i].alt));this.boundaryLatlon=e,this.boundary=t,this._clippingManager&&(this._clippingManager.removeItems([this.getId()]),this._clippingManager.addItem(this))}_onAdded(e){this._clippingManager=e}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Clipping");t.ClippingManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Clipping");i.ClippingManager=class{constructor(i){t.send("Bimface.Earth.Plugins.Clipping.ClippingManager","bf_c_clippingMng_new"),this._viewer=i.viewer,this.clippingItemMap=new Map,this._viewer instanceof e.Bimface.Earth.Viewer.ViewerGIS?P(this):console.log("ERROR::viewer must be viewerGIS.")}addItem(e){if(!e)return;const t=e.getBoundaryVector();if(!t)return void console.log("ERROR::clippingItem must contains boundary.");const i=this._viewer.getViewer();if(!i||!i.holesManager)return;let n=new Array(t.length);for(let e=0;e<t.length;++e){const i=this._viewer.viewerAdapter.worldToDrawing(t[e]);n[e]=i}let o={},s=[],r=e.getLayerIds();if(r=[...new Set(r)],void 0===r||0===r.length)throw console.log("ERROR::clippingItem must contains layerIds."),new Error("ERROR::clippingItem must contains layerIds.");r.map((e=>{const t=this._viewer.getLayerManager().getLayer(e);if(!t||"TileLayer"!==t.typeName&&"TilesetLayer"!==t.typeName)console.warn(`The LayerId ${e} is invalid`);else{const e=t.getModelId(),i=t._imageryId,n=t.id;s.push({pModelId:e,pImageryId:i,pLayerId:n})}})),s.forEach((e=>{const{pModelId:t,pImageryId:i,pLayerId:n}=e;o[t]||(o[t]=[]),o[t].push({pImageryId:i,pLayerId:n})}));const a={points:n,modelIds:o};i.holesManager.addHole(e.getId(),a),this.clippingItemMap.set(e.getId(),e),e._onAdded(this)}removeItems(e,t){if(!e)return;const i=this._viewer.getViewer();i&&i.holesManager&&(i.holesManager.removeHoleByIds(e),e.map((e=>{const i=this.clippingItemMap.get(e);i&&t&&i.destroy()})),i.render())}clear(e){const t=this._viewer.getViewer(),i=Array.from(this.clippingItemMap.keys());t.holesManager.removeHoleByIds(i);for(const t of this.clippingItemMap.values())e&&t.destroy();this.clippingItemMap.clear(),t.render()}showItems(e){if(e){var t=this._viewer.getViewer();t&&t.holesManager&&(e.forEach((e=>{let t=this.clippingItemMap.get(e);t&&this._showHideItem(e,t.layerIds,!0)})),t.render())}}_showHideClipping(e){const t=this._viewer.getViewer();let i=[];e.layerIds.map((e=>{const t=this._viewer.getLayerManager().getLayer(e);if(t&&("TileLayer"===t.typeName||"TilesetLayer"===t.typeName)){const e=t.getModelId(),n=t._imageryId,o=t.id;i.push({pModelId:e,pImageryId:n,pLayerId:o})}})),t.holesManager.showHideLayerByLayerIds(e.getId(),i)}_showHideItem(e,t,i){if(!t)return;const n=this._viewer.getViewer();n&&n.holesManager&&(i?n.holesManager.showHoleByIdAndLayerIds(e,t):n.holesManager.hideHoleByIdAndLayerIds(e,t),n.render())}showAll(){const e=Array.from(this.clippingItemMap.keys());this.showItems(e)}hideItems(e){if(!e)return;const t=this._viewer.getViewer();t&&t.holesManager&&(e.forEach((e=>{let t=this.clippingItemMap.get(e);t&&this._showHideItem(e,t.layerIds,!1)})),t.render())}hideAll(){const e=Array.from(this.clippingItemMap.keys());this.hideItems(e)}update(){}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Flats");t.FlatConfig=class{constructor(){this.boundary=null,this.elevation=0,this.layerIds=[]}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Flats");i.Flat=class{constructor(i){t.send("Bimface.Earth.Plugins.Flats.Flat","bf_c_flat_new"),this.boundary=i.boundary,this.elevation=i.elevation,this._elevation=null,this.viewer=null,this.layerIds=i.layerIds,i.layerId&&(this.layerIds=[i.layerId]),this.id=e.Web.Lang.Utility.UUID.createUUID(),this.needsUpdate=!0,this.visible=!0,P(this)}initViewer(e){this.viewer||(this.viewer=e,this.viewerType=this.viewer.getViewerType());let t=[];this.boundary.map((e=>{t.push(this.viewer.latLonToWorld(e))})),this.boundary=t}destroy(e,t){e.terrainOperationManager&&e.terrainOperationManager.removeFlattenRegionsById([this.id]),t&&(this.boundary=null,this.elevation=void 0,this.layerIds=void 0,this.id=void 0,this.needsUpdate=void 0,this.visible=void 0)}setElevation(e){this.elevation=e,this.enableUpdate(!0)}getElevation(){return this.elevation}getId(){return this.id}getLayerId(){return this.layerIds[0]}setLayerId(e){this.setLayerIds([e])}getLayerIds(){return this.layerIds}setLayerIds(e){this.layerIds=e,this.enableUpdate(!0)}getBoundary(){return this.boundary}setBoundary(e){this.boundary=e;let t=[];e.map((e=>{t.push(this.viewer.latLonToWorld(e))})),this.boundary=t,this.enableUpdate(!0)}enableUpdate(e){this.needsUpdate=e}setVisible(e){this.visible=e,this.needsUpdate=!0}draw(e,t){if(!this.needsUpdate)return;if(!0!==this.visible)return void e.terrainOperationManager.removeFlattenRegionsById([this.id]);let i=this.getElevation(),n=this.viewer&&"Viewer3D"==this.viewerType;n&&(i=this.viewer.globalUnitUtil.excute(i,this.viewer.globalUnitUtil.getGlobalUnit(),"m"));const o=this.getBoundary();let s=new Array(o.length);for(let t=0;t<o.length;++t){const i=n?this.viewer.viewerAdapter.worldToDrawing(o[t]):e.worldToDrawing(o[t]);s[t]=i}e.terrainOperationManager.removeFlattenRegionsById([this.id]),e.terrainOperationManager.addFlattenRegion(this.id,s,i,t),this.enableUpdate(!1)}zoomToBoundingBox(e){let t=this.boundary[0].x,i=this.boundary[0].y,n=this.boundary[0].z,o=this.boundary[0].x,s=this.boundary[0].y,r=this.boundary[0].z;this.boundary.map((e=>{t=Math.max(t,e.x),i=Math.max(i,e.y),n=Math.max(n,e.z),o=Math.min(o,e.x),s=Math.min(s,e.y),r=Math.min(r,e.z)})),n=Math.max(n,this.elevation),r=Math.min(r,this.elevation);let a=new THREE.Box3(new THREE.Vector3(o,s,r),new THREE.Vector3(t,i,n));this.viewer?this.viewer.zoomToBoundingBox({boundingBox:a}):e.zoomToBoundingBox({boundingBox:a})}}}(),function(){const t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Flats");t.FlatManagerConfig=class{constructor(){this.viewer=null}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();const i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.Flats");i.FlatManager=class{constructor(e){t.send("Bimface.Earth.Plugins.Flats.FlatManager","bf_c_flatMng_new"),this.viewer=e.viewer,this.items={},P(this)}addItem(e){e.initViewer(this.viewer);const t=e.getId();void 0!==t&&(this.items[t]=e,e.enableUpdate(!0),this.update())}removeItems(e,t){e.map((e=>{if(!this.items[e])return;this.items[e].destroy(this.viewer.getViewer(),t),delete this.items[e]})),this.update()}clear(e){for(const t in this.items){this.items[t].destroy(this.viewer.getViewer(),e)}this.items={},this.update()}showItems(e){e.map((e=>{if(!this.items[e])return;this.items[e].setVisible(!0)})),this.update()}showAll(){for(const e in this.items){this.items[e].setVisible(!0)}this.update()}hideItems(e){e.map((e=>{if(!this.items[e])return;this.items[e].setVisible(!1)})),this.update()}hideAll(){for(const e in this.items){this.items[e].setVisible(!1)}this.update()}update(){const e=this.viewer.getViewer(),t="ViewerGIS"===this.viewer.getViewerType();if(e.terrainOperationManager){for(const i in this.items){const n=this.items[i],o=n.getLayerIds();let s=[];if(t?o.map((e=>{const t=this.viewer.getLayerManager().getLayer(e);if(!t||"TileLayer"!==t.typeName&&"TilesetLayer"!==t.typeName)t&&"TerrainLayer"===t.typeName?s.push(CLOUD.ObjectGroupType.TILEGROUP):console.warn(`The LayerId ${e} is invalid`);else{const e=t.getModelId().toString();s.push(e)}})):s.push(CLOUD.ObjectGroupType.TILEGROUP),0===s.length)return void console.warn("The LayerIds is invalid");n.draw(e,s)}e.render()}}}}(),function(){let t=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.ElementManager"),i=Object.freeze({Transformed:"Transformed"});t.ExternalObjectEvent=i}();e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.ExternalObject").ExternalObjectEditorToolbarEvent={Exit:"Exit",EditingModeChanged:"EditingModeChanged"};!function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();let i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.Plugins.ExternalObject"),n=e.Bimface.Plugins.ExternalObject.ExternalObjectManager;i.ExternalObjectManager=class extends n{constructor(e){return super(e),t.send("Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager","bf_c_extObjMng_new"),this}getTransformationWithoutFixedTransform(e){if(!this._manager._hasObjectId(e))return;const[t]=this._manager.meshes[e];if(t){const i=this._manager.getMeshLocalMatrix(t);return 1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(1/this._sceneScale.x,1/this._sceneScale.y,1/this._sceneScale.z)),i.elements[12]*=1/this._sceneScale.x,i.elements[13]*=1/this._sceneScale.y,i.elements[14]*=1/this._sceneScale.z,c.limitTransformationDecimal(i.elements)}}setTransformationLocal(e,t){if(!this._manager._hasObjectId(e))return;if("[object Array]".indexOf(Object.prototype.toString.call(t))<0)return;const i=new THREE.Matrix4;i.fromArray(t),1==this._scaledIdMap[e]&&i.multiply((new THREE.Matrix4).makeScale(this._sceneScale.x,this._sceneScale.y,this._sceneScale.z)),i.elements[12]*=this._sceneScale.x,i.elements[13]*=this._sceneScale.x,i.elements[14]*=this._sceneScale.x,this._manager.applyTransformMatrixLocal(e,i,!0),this._viewer.getViewer().render(),this._fireTransformedEvent(e)}setPosition(e,t){let i=t;const n=this.getTransformationWithoutFixedTransform(e);if(!n)return;const o=[...n];o[12]=i.x,o[13]=i.y,o[14]=i.z,this.setTransformationLocal(e,o)}}}(),function(){var t=e.Bimface.Data.StatisticsDataManager.getInstance();let i=e.Web.Lang.Utility.Namespace.ensureNamespace(e,"Bimface.Earth.ElementManager");i.ExternalObjectManager=class{constructor(e,i){console.info("ExternalObjectManager----new---"),t.send("Bimface.Earth.ElementManager.ExternalObjectManager","bf_c_extObjMng_new");var n=this;return n.viewer=e,n._objects={},n.isVisible=!0,n.layerId=i,n._createExternalObjectManager(),P(this),n}_createExternalObjectManager(){this._externalObjectManager=new e.Bimface.Earth.Plugins.ExternalObject.ExternalObjectManager(this.viewer)}addEventListener(e,t){this._externalObjectManager.addEventListener(e,t)}removeEventListener(e,t){this._externalObjectManager.removeEventListener(e,t)}_fireTransformedEvent(t){this._externalObjectManager.getEventManager().fireEvent(e.Bimface.Earth.ElementManager.ExternalObjectEvent.Transformed,{id:t,location:this.viewer.worldToLatLon(this.getPosition(t)),layerId:this.layerId}),this.viewer.getViewer().updateGlowEffect(this.modelId,t)}loadObject(e,t,i){var n=this;const o=e.name;if(!y.Utils.isDefined(o))return console.warn("option.name is necessary when loadObject"),void(i&&i());void 0!==e.enableLight&&(n._externalObjectManager.enableLight=e.enableLight);const s=e.object,r=e.url;if(y.Utils.isDefined(s)){const r=n._externalObjectManager._addObject(o,s,e.modelId);if(null!=r)return n._objects[r]=o,n.isVisible?n._externalObjectManager._manager.getFilter().showByIds([r]):n._externalObjectManager._manager.getFilter().hideByIds([r]),y.Utils.isDefined(e.objectData)&&n.setObjectData(r,e.objectData),t&&t(),r;i&&i()}else y.Utils.isDefined(r)&&n._externalObjectManager.loadObject({name:o,url:{objectUrl:r.objectUrl,mtlUrl:r.mtlUrl},objectData:e.objectData,association:{modelId:e.modelId},enableLight:e.enableLight},(()=>{var e=n._externalObjectManager.getObjectIdByName(o);null!=e&&(n._objects[e]=o),t&&t()}),i)}getObjectIdByName(e){for(var t in this._objects)if(this._objects[t]===e)return t}setObjectData(e,t){void 0!==this._objects[e]?this._externalObjectManager.setObjectData(e,t):console.warn(`No ${e} in ExternalObjectManager`)}getObjectData(e){if(void 0!==this._objects[e])return this._externalObjectManager.getObjectData(e);console.warn(`No ${e} in ExternalObjectManager`)}getObjectIdAndName(){return this._objects}_updateMeshesVisible(){for(var e in this._externalObjectManager._manager.meshes){var t=this._externalObjectManager._manager.meshes[e];if(null!=t&&null!=this._objects[e])for(var i=0;i<t.length;i++)t[i].visible=this.isVisible}}clone(e,t){const i=this._externalObjectManager.clone(e,t);return i&&(this._objects[i]=t),i}hide(e){this._externalObjectManager.hide(e)}show(e){this._externalObjectManager.show(e)}select(e){this._externalObjectManager.select(e)}removeSelection(e){this._externalObjectManager.removeSelection(e)}getAllObjectIds(){return Object.keys(this._objects)}removeByIds(e){for(var t=0;t<e.length;t++){const i=e[t];this.removeById(i)}}removeById(e){this._objects[e]&&(this._externalObjectManager.removeById(e),delete this._objects[e])}clear(){var e=this,t=Object.keys(e._objects);t.length>0&&(e.clearGlowEffect(),e._externalObjectManager.removeByIds(t),e._objects={})}translate(e,t){null!=this._objects[e]&&(this._externalObjectManager.translate(e,t),this._fireTransformedEvent(e))}getBoundingBoxById(e){if(null==this._objects[e])return;let t=this._externalObjectManager.getBoundingBoxById(e);return{min:this.viewer.worldToLatLon(t.min),max:this.viewer.worldToLatLon(t.max)}}setPosition(e,t){null!=this._objects[e]&&(this._externalObjectManager.setPosition(e,t),this._fireTransformedEvent(e))}getPosition(e){if(null!=this._objects[e])return this._externalObjectManager.getPosition(e)}offset(e,t){null!=this._objects[e]&&(this._externalObjectManager.offset(e,t),this._fireTransformedEvent(e))}rotate(e,t){null!=this._objects[e]&&(this._externalObjectManager.rotate(e,t),this._fireTransformedEvent(e))}scale(e,t){null!=this._objects[e]&&(this._externalObjectManager.scale(e,t),this._fireTransformedEvent(e))}getTransformationWithoutFixedTransform(e){if(null!=this._objects[e])return this._externalObjectManager.getTransformationWithoutFixedTransform(e)}getTransformation(e){if(null!=this._objects[e])return this._externalObjectManager.getTransformation(e)}setTransformation(e,t){null!=this._objects[e]&&(this._externalObjectManager.setTransformation(e,t),this._fireTransformedEvent(e))}setTransformationLocal(e,t){null!=this._objects[e]&&(this._externalObjectManager.setTransformationLocal(e,t),this._fireTransformedEvent(e))}setGlowEffectById(e,t){for(var i=this,n=[],o=0;o<e.length;o++)null!=i._objects[e[o]]&&n.push(e[o]);if(0!=n.length){if("outline"==t.type){null==i.outlineGlowObj&&(i.outlineGlowObj={});for(o=0;o<e.length;o++)i.outlineGlowObj[e[o]]=t}else{null==i.bodyGlowObj&&(i.bodyGlowObj={});for(o=0;o<e.length;o++)i.bodyGlowObj[e[o]]=t}i._externalObjectManager.setGlowEffectById(n,t)}}removeGlowEffectById(e){for(var t=this,i=[],n=0;n<e.length;n++)null!=t._objects[e[n]]&&i.push(e[n]);if(0!=i.length){for(n=0;n<i.length;n++)null!=t.bodyGlowObj&&delete t.bodyGlowObj[i[n]],null!=t.outlineGlowObj&&delete t.outlineGlowObj[i[n]];t._externalObjectManager.removeGlowEffectById(i)}}clearGlowEffect(){var e=this,t=Object.keys(e._objects);t.length>0&&e._externalObjectManager.removeGlowEffectById(t),e.outlineGlowObj=null,e.bodyGlowObj=null}play(e){null!=this._objects[e]&&this._externalObjectManager.play(e)}pause(e){null!=this._objects[e]&&this._externalObjectManager.pause(e)}stop(e){null!=this._objects[e]&&this._externalObjectManager.stop(e)}isAnimatable(e){if(null!=this._objects[e])return this._externalObjectManager.isAnimatable(e)}getBoundingBoxWorld(){let e=new THREE.Box3;const t=this._externalObjectManager._manager.getFilter();for(const i in this._objects){if(t.isHidden(i))continue;const n=this._externalObjectManager.getBoundingBoxById(i);e.union(n)}return e}overrideColor(e,t){if(!y.Utils.isDefined(e))return;let i=[];const n=this._externalObjectManager._manager.getFilter();if(!y.Utils.isDefined(n))return;if(y.Utils.isDefined(e.all)&&1==e.all&&(i=i.concat(this.getAllObjectIds())),y.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),i=i.concat(n.getMatchIds(e.objectData))),y.Utils.isDefined(e.ids)&&(i=i.concat(e.ids)),i=Array.from(new Set(i)),0===i.length)return;const o={color:parseInt(t.getHEX(),16),opacity:t.getAlpha()};n.addToOverrideListByColor(i,o)}restoreColor(e){if(!y.Utils.isDefined(e))return;let t=[];const i=this._externalObjectManager._manager.getFilter();y.Utils.isDefined(i)&&(y.Utils.isDefined(e.all)&&1==e.all&&(t=t.concat(this.getAllObjectIds())),y.Utils.isDefined(e.objectData)&&(Array.isArray(e.objectData)||(e.objectData=[e.objectData]),t=t.concat(i.getMatchIds(e.objectData))),y.Utils.isDefined(e.ids)&&(t=t.concat(e.ids)),t=Array.from(new Set(t)),0!==t.length&&i.addToOverrideListByColor(t))}setLocation(e,t){if(c.assertType(t,"obj")){let i=this.viewer.latLonToWorld(t);const n=this.getTransformationWithoutFixedTransform(e);if(!n)return;const o=[...n];o[12]=i.x,o[13]=i.y,o[14]=i.z,this.setTransformationLocal(e,o)}}getLocation(e){const t=this.getTransformation(e);if(!t)return null;const i={x:t[12],y:t[13],z:t[14]};return this.viewer.worldToLatLon(i)}}}(),window.Glodon=e}();